{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "billing-04",
  "description": "Monthly and annual recurring revenue, revenue per account and net revenue retention, each with its change from the previous month.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/billing.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/stat-group.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/billing/billing-04.tsx",
      "content": "'use client'\n\nimport { getRevenueMetrics } from '@/registry/components/dashboardblocks/billing'\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  Stat,\n  StatChange,\n  StatGroup,\n  StatLabel,\n  type StatMetric,\n  StatValue,\n  formatStatValue,\n  getStatPlaceholders,\n} from '@/registry/components/dashboardblocks/stat-group'\nimport {\n  formatCurrency,\n  formatNumber,\n  formatPercent,\n} from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface RevenueSnapshot {\n  customers: number\n  mrr: number\n  /** Trailing twelve months, as a fraction: 1.08 is 108%. */\n  netRevenueRetention: number\n}\n\ninterface Billing4Props extends BlockStateProps {\n  /** Follows each previous value. @default 'last month' */\n  comparison?: string\n  /** @default 'USD' */\n  currency?: string\n  /** Leave out to show the empty state. */\n  current?: RevenueSnapshot\n  description: string\n  previous?: RevenueSnapshot\n  title: string\n}\n\nconst exampleProps: Billing4Props = {\n  comparison: 'in August',\n  current: { customers: 1_284, mrr: 201_530, netRevenueRetention: 1.124 },\n  description:\n    'September 2026. 81 more customers than August, each paying a little more.',\n  previous: { customers: 1_203, mrr: 182_400, netRevenueRetention: 1.098 },\n  title: 'Revenue',\n}\n\nfunction getMetrics(\n  current: RevenueSnapshot,\n  previous: RevenueSnapshot | undefined,\n  currency: string,\n): (StatMetric & { hint: string })[] {\n  const now = getRevenueMetrics(current)\n  const before = previous ? getRevenueMetrics(previous) : undefined\n  const money = (value: number) => formatCurrency(value, { currency })\n\n  return [\n    {\n      formatter: money,\n      hint: 'Monthly recurring revenue',\n      key: 'mrr',\n      label: 'MRR',\n      previous: previous?.mrr,\n      value: current.mrr,\n    },\n    {\n      formatter: (value) => formatCurrency(value, { compact: true, currency }),\n      hint: 'MRR × 12',\n      key: 'arr',\n      label: 'ARR',\n      previous: before?.arr,\n      value: now.arr,\n    },\n    {\n      formatter: (value) => formatCurrency(value, { currency, precision: 'exact' }),\n      hint: `Per customer, across ${formatNumber(current.customers)}`,\n      key: 'arpu',\n      label: 'ARPU',\n      previous: before?.arpu,\n      value: now.arpu,\n    },\n    {\n      changeType: 'points',\n      formatter: (value) => formatPercent(value / 100),\n      hint: 'Net revenue retention, last 12 months',\n      key: 'nrr',\n      label: 'NRR',\n      previous: previous\n        ? Math.round(previous.netRevenueRetention * 1000) / 10\n        : undefined,\n      value: Math.round(current.netRevenueRetention * 1000) / 10,\n    },\n  ]\n}\n\nconst Billing4 = (props: Billing4Props) => {\n  const {\n    comparison = 'last month',\n    currency = 'USD',\n    current,\n    description,\n    previous,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const metrics = current ? getMetrics(current, previous, currency) : []\n  const shown: (StatMetric & { hint?: string })[] =\n    status === 'loading' ? getStatPlaceholders(4) : metrics\n\n  return (\n    <BlockStateProvider\n      errorMessage={errorMessage}\n      state={getBlockState(status, metrics)}\n    >\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>{description}</p>\n            </header>\n            <StatGroup className='grid-cols-1 @md:grid-cols-2 @3xl:grid-cols-4'>\n              {shown.map((metric) => (\n                <Stat key={metric.key}>\n                  <StatLabel>{metric.label}</StatLabel>\n                  <StatValue className='text-3xl @2xl:text-4xl'>\n                    {formatStatValue(metric)}\n                  </StatValue>\n                  <StatChange comparison={comparison} metric={metric} />\n                  <dd className='text-muted-foreground text-xs'>\n                    <BlockReady className='text-xs'>{metric.hint}</BlockReady>\n                  </dd>\n                </Stat>\n              ))}\n            </StatGroup>\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Billing4, exampleProps as billing4ExampleProps, type Billing4Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/billing/billing-04.tsx"
    }
  ],
  "meta": {
    "shows": "Monthly and annual recurring revenue, revenue per account and net revenue retention, each with its change from the previous month.",
    "size": "full",
    "usedWith": [
      "billing-01",
      "chart-panel-01",
      "retention-03"
    ],
    "component": "Billing4",
    "props": "{ comparison?: string; currency?: string; current?: { customers: number; mrr: number; netRevenueRetention: number }; description: string; previous?: { customers: number; mrr: number; netRevenueRetention: number }; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
