{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-report",
  "type": "registry:block",
  "title": "Report",
  "description": "A report on a grey canvas: a date range and an export above key figures, charts and a breakdown table, each in its own white section.",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/app-shell.json",
    "https://wideset.co/r/avatar.json",
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/date-range-picker.json",
    "https://wideset.co/r/dropdown-menu.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/select.json",
    "https://wideset.co/r/sidebar.json",
    "https://wideset.co/r/status-badge.json",
    "https://wideset.co/r/table.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/report/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/brand-mark.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nconst TILE =\n  'M0 16C0 8.45753 0 4.68629 2.34315 2.34315C4.68629 0 8.45753 0 16 0C23.5425 0 27.3137 0 29.6569 2.34315C32 4.68629 32 8.45753 32 16C32 23.5425 32 27.3137 29.6569 29.6569C27.3137 32 23.5425 32 16 32C8.45753 32 4.68629 32 2.34315 29.6569C0 27.3137 0 23.5425 0 16Z';\n\n/**\n * Orbit's mark: a planet and its ring on the inverse tile, so it inverts in dark mode. It takes\n * the size of its place (32px in a sidebar, 36px in a larger switcher). Decorative beside the\n * product's name; give it a `label` when it stands alone.\n */\nexport function BrandMark({ className, label }: { className?: string; label?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 32 32\"\n      role={label ? 'img' : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      className={cn('size-ws-14 shrink-0', className)}\n    >\n      <path d={TILE} className=\"fill-(--ws-static-fill-inverse-background)\" />\n      <ellipse\n        cx=\"16\"\n        cy=\"16\"\n        rx=\"10.5\"\n        ry=\"4\"\n        transform=\"rotate(-28 16 16)\"\n        strokeWidth=\"1.75\"\n        className=\"fill-none stroke-(--ws-static-text-inverse-strong)\"\n      />\n      <circle cx=\"16\" cy=\"16\" r=\"4.75\" className=\"fill-(--ws-static-text-inverse-strong)\" />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/report/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBarChartBoxLine,\n  RiBriefcase4Line,\n  RiFileChart2Line,\n  RiHome5Line,\n  RiInbox2Line,\n  RiLineChartLine,\n  RiPieChart2Line,\n  RiUserLine,\n} from '@remixicon/react';\n\nexport const WORKSPACE = { name: 'Lumen Studio' };\nexport const ACCOUNT = {\n  name: 'Nina Alvarez',\n  initials: 'NA',\n  email: 'nina@lumen.studio',\n  role: 'Account executive',\n};\n\nexport const NAVIGATION: {\n  id: string;\n  label: string;\n  icon: RemixiconComponentType;\n  count?: number;\n}[] = [\n  { id: 'home', label: 'Home', icon: RiHome5Line },\n  { id: 'inbox', label: 'Inbox', icon: RiInbox2Line, count: 4 },\n  { id: 'customers', label: 'Customers', icon: RiUserLine },\n  { id: 'deals', label: 'Deals', icon: RiBriefcase4Line },\n  { id: 'analytics', label: 'Analytics', icon: RiBarChartBoxLine },\n];\n\nexport const REPORTS: { id: string; label: string; icon: RemixiconComponentType }[] = [\n  { id: 'revenue', label: 'Revenue', icon: RiLineChartLine },\n  { id: 'retention', label: 'Retention', icon: RiPieChart2Line },\n  { id: 'pipeline', label: 'Pipeline', icon: RiFileChart2Line },\n];\n\nexport type PlanId = 'starter' | 'growth' | 'scale' | 'enterprise';\nexport type RegionId = 'na' | 'eu' | 'apac' | 'latam';\nexport type Compare = 'period' | 'year';\n\nexport const COMPARE_OPTIONS: { value: Compare; label: string }[] = [\n  { value: 'period', label: 'Previous period' },\n  { value: 'year', label: 'Previous year' },\n];\n\n/*\n  The dataset: every MRR movement since Jan 1, 2023, one row per new customer, expansion and\n  cancellation, each with its plan and region. Every figure on the screen is summed from these\n  rows and the opening balances, so the KPIs, the charts and the table always add up.\n\n  The rows are generated once from a seeded random sequence. The report opens on a sample period\n  that the server and browser can render identically. The data also extends through today for\n  the date picker's relative presets. A real app fetches the rows for the range on screen.\n*/\n\nconst DAY = 86_400_000;\nconst START = Date.UTC(2023, 0, 1);\nexport const SAMPLE_RANGE = { from: '2026-01-01', to: '2026-11-10' };\nconst now = new Date();\n/** The last available day, as the number of days since Jan 1, 2023. */\nexport const TODAY = Math.round(\n  (Math.max(\n    Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()),\n    Date.parse(SAMPLE_RANGE.to),\n  ) -\n    START) /\n    DAY,\n);\n/** The first day a range may start: a year in, so a range always has a year before it. */\nexport const FIRST_DAY = 365;\n\n/** A calendar day (`2026-11-10`) as a day number, and back. */\nexport const dayOf = (iso: string) => Math.round((Date.parse(iso) - START) / DAY);\nexport const isoOf = (day: number) => new Date(START + day * DAY).toISOString().slice(0, 10);\n\ntype PlanDef = {\n  id: PlanId;\n  label: string;\n  /** Customers and their average MRR on Jan 1, 2023. */\n  customers: number;\n  arpa: number;\n  /** A new customer's MRR, low to high, in whole dollars of `step`. */\n  price: [number, number];\n  step: number;\n  newPerDay: number;\n  /** Share of customers who cancel, and who expand, in a month. */\n  churn: number;\n  expansion: number;\n};\n\nconst PLAN_DEFS: PlanDef[] = [\n  {\n    id: 'starter',\n    label: 'Starter',\n    customers: 720,\n    arpa: 79,\n    price: [49, 129],\n    step: 10,\n    newPerDay: 1.45,\n    churn: 0.034,\n    expansion: 0.015,\n  },\n  {\n    id: 'growth',\n    label: 'Growth',\n    customers: 330,\n    arpa: 410,\n    price: [240, 640],\n    step: 20,\n    newPerDay: 0.52,\n    churn: 0.017,\n    expansion: 0.026,\n  },\n  {\n    id: 'scale',\n    label: 'Scale',\n    customers: 58,\n    arpa: 1_620,\n    price: [1_100, 2_400],\n    step: 50,\n    newPerDay: 0.08,\n    churn: 0.009,\n    expansion: 0.036,\n  },\n  {\n    id: 'enterprise',\n    label: 'Enterprise',\n    customers: 6,\n    arpa: 6_100,\n    price: [4_000, 9_000],\n    step: 250,\n    newPerDay: 0.008,\n    churn: 0.004,\n    expansion: 0.04,\n  },\n];\n\nexport const PLANS = PLAN_DEFS.map(({ id, label }) => ({ id, label }));\n\nexport const REGIONS: { id: RegionId; label: string; share: number }[] = [\n  { id: 'na', label: 'North America', share: 0.46 },\n  { id: 'eu', label: 'Europe', share: 0.31 },\n  { id: 'apac', label: 'Asia Pacific', share: 0.15 },\n  { id: 'latam', label: 'Latin America', share: 0.08 },\n];\n\nexport type Kind = 'new' | 'expansion' | 'churn';\n/** One MRR movement. `amount` is always positive; a churn takes it away. */\nexport type Movement = {\n  day: number;\n  plan: PlanId;\n  region: RegionId;\n  kind: Kind;\n  amount: number;\n};\n\ntype Cell = { plan: PlanId; region: RegionId; mrr: number; customers: number };\n\n/** A repeatable sequence in [0, 1). */\nconst random = (() => {\n  let seed = 20_230_101;\n  return () => {\n    seed = (seed + 0x6d2b79f5) | 0;\n    let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n    return ((t ^ (t >>> 14)) >>> 0) / 4_294_967_296;\n  };\n})();\n/** How many events happen in a day that averages `mean` of them. */\nconst poisson = (mean: number) => {\n  const limit = Math.exp(-mean);\n  let count = 0;\n  for (let p = random(); p > limit; p *= random()) count++;\n  return count;\n};\n// Sunday to Saturday: sign-ups and cancellations happen on working days.\nconst WEEKDAY = [0.35, 1.18, 1.22, 1.2, 1.16, 1.05, 0.4];\n\n/** Every plan in every region on Jan 1, 2023. */\nexport const OPENING: Cell[] = PLAN_DEFS.flatMap((plan) =>\n  REGIONS.map((region) => {\n    const customers = Math.round(plan.customers * region.share);\n    return { plan: plan.id, region: region.id, customers, mrr: customers * plan.arpa };\n  }),\n);\n\nexport const MOVEMENTS: Movement[] = (() => {\n  const cells = OPENING.map((cell) => ({ ...cell }));\n  const rows: Movement[] = [];\n  for (let day = 0; day <= TODAY; day++) {\n    const weekday = WEEKDAY[new Date(START + day * DAY).getUTCDay()];\n    // Sign-ups grow slowly as the product does.\n    const growth = 0.85 + day * 0.000_25;\n    cells.forEach((cell, index) => {\n      const plan = PLAN_DEFS[Math.floor(index / REGIONS.length)];\n      const region = REGIONS[index % REGIONS.length];\n      const add = (kind: Kind, amount: number) =>\n        rows.push({ day, plan: cell.plan, region: cell.region, kind, amount });\n\n      for (let n = poisson(plan.newPerDay * region.share * weekday * growth); n > 0; n--) {\n        const steps = (plan.price[1] - plan.price[0]) / plan.step;\n        const amount = plan.price[0] + Math.floor(random() * (steps + 1)) * plan.step;\n        cell.mrr += amount;\n        cell.customers += 1;\n        add('new', amount);\n      }\n      const average = cell.customers ? cell.mrr / cell.customers : 0;\n      for (let n = poisson((cell.customers * plan.expansion * weekday) / 30); n > 0; n--) {\n        const amount = Math.round((average * (0.15 + random() * 0.35)) / 10) * 10;\n        cell.mrr += amount;\n        add('expansion', amount);\n      }\n      for (let n = poisson((cell.customers * plan.churn * weekday) / 30); n > 0; n--) {\n        if (cell.customers <= 1) break;\n        const amount = Math.min(Math.round(average * (0.6 + random() * 0.8)), cell.mrr);\n        cell.mrr -= amount;\n        cell.customers -= 1;\n        add('churn', amount);\n      }\n    });\n  }\n  return rows;\n})();\n\n/** A span of whole days, both ends included, as day numbers. */\nexport type Range = { from: number; to: number };\n\nconst OPENING_MRR = OPENING.reduce((sum, cell) => sum + cell.mrr, 0);\nconst OPENING_CUSTOMERS = OPENING.reduce((sum, cell) => sum + cell.customers, 0);\n\n/** MRR and customers at the close of every day, summed once from the movements. */\nconst CLOSE = (() => {\n  const mrr = new Array<number>(TODAY + 1).fill(0);\n  const customers = new Array<number>(TODAY + 1).fill(0);\n  for (const row of MOVEMENTS) {\n    mrr[row.day] += row.kind === 'churn' ? -row.amount : row.amount;\n    customers[row.day] += row.kind === 'new' ? 1 : row.kind === 'churn' ? -1 : 0;\n  }\n  for (let day = 0; day <= TODAY; day++) {\n    mrr[day] += day ? mrr[day - 1] : OPENING_MRR;\n    customers[day] += day ? customers[day - 1] : OPENING_CUSTOMERS;\n  }\n  return { mrr, customers };\n})();\n\nconst mrrAt = (day: number) => (day < 0 ? OPENING_MRR : CLOSE.mrr[day]);\n\n/** The same calendar day a year earlier; Feb 29 falls back to Feb 28. */\nconst yearEarlier = (day: number) => {\n  const iso = isoOf(day);\n  return dayOf(\n    `${Number(iso.slice(0, 4)) - 1}${iso.slice(4) === '-02-29' ? '-02-28' : iso.slice(4)}`,\n  );\n};\n\n/** What a range is compared with: the same number of days just before it, or a year earlier. */\nexport function comparisonOf({ from, to }: Range, compare: Compare): Range {\n  if (compare === 'year') return { from: yearEarlier(from), to: yearEarlier(to) };\n  return { from: from - (to - from + 1), to: from - 1 };\n}\n\nexport type Unit = 'day' | 'week' | 'month';\nexport type Bucket = { from: number; to: number; new: number; expansion: number; churn: number };\n\n/** How finely the movements chart splits a range: by day up to a month, by week up to ~4 months. */\nconst unitOf = ({ from, to }: Range): Unit =>\n  to - from < 31 ? 'day' : to - from < 120 ? 'week' : 'month';\n\n/** The key a day falls under at a unit: itself, its week's Monday, or its month. */\nconst keyOf = (day: number, unit: Unit) => {\n  if (unit === 'day') return String(day);\n  if (unit === 'week') return String(day - ((new Date(START + day * DAY).getUTCDay() + 6) % 7));\n  return isoOf(day).slice(0, 7);\n};\n\n/** Everything the page shows for one range, summed from the movements. */\nfunction summarise(range: Range) {\n  const { from, to } = range;\n  const rows = MOVEMENTS.filter((row) => row.day >= from && row.day <= to);\n  const total = (kind: Kind, list: Movement[] = rows) =>\n    list.reduce((sum, row) => (row.kind === kind ? sum + row.amount : sum), 0);\n  const signed = (row: Movement) => (row.kind === 'churn' ? -row.amount : row.amount);\n\n  const unit = unitOf(range);\n  const buckets: Bucket[] = [];\n  for (let day = from; day <= to; day++) {\n    const last = buckets[buckets.length - 1];\n    if (last && keyOf(last.from, unit) === keyOf(day, unit)) last.to = day;\n    else buckets.push({ from: day, to: day, new: 0, expansion: 0, churn: 0 });\n  }\n  for (const row of rows) {\n    const bucket = buckets.find((entry) => row.day >= entry.from && row.day <= entry.to)!;\n    bucket[row.kind] += row.amount;\n  }\n\n  // Each plan's and region's MRR at the close of the range: its opening plus everything since.\n  const upTo = MOVEMENTS.filter((row) => row.day <= to);\n  const closing = (match: (cell: { plan: PlanId; region: RegionId }) => boolean) =>\n    OPENING.filter(match).reduce((sum, cell) => sum + cell.mrr, 0) +\n    upTo.filter(match).reduce((sum, row) => sum + signed(row), 0);\n\n  const movements = { new: total('new'), expansion: total('expansion'), churn: total('churn') };\n  return {\n    range,\n    opening: mrrAt(from - 1),\n    mrr: mrrAt(to),\n    customers: CLOSE.customers[to],\n    ...movements,\n    net: movements.new + movements.expansion - movements.churn,\n    /** MRR at the close of the day before the range, then of every day in it. */\n    daily: Array.from({ length: to - from + 2 }, (_, index) => mrrAt(from - 1 + index)),\n    unit,\n    buckets,\n    plans: PLANS.map((plan) => ({ ...plan, mrr: closing((cell) => cell.plan === plan.id) })),\n    regions: REGIONS.map((region) => {\n      const inRegion = rows.filter((row) => row.region === region.id);\n      const regionMovements = {\n        new: total('new', inRegion),\n        expansion: total('expansion', inRegion),\n        churn: total('churn', inRegion),\n      };\n      return {\n        id: region.id,\n        label: region.label,\n        ...regionMovements,\n        net: regionMovements.new + regionMovements.expansion - regionMovements.churn,\n        mrr: closing((cell) => cell.region === region.id),\n      };\n    }),\n  };\n}\n\nexport type Summary = ReturnType<typeof summarise>;\n\n/**\n * The report for a range and what it is compared with. Without data for the comparison (a long\n * custom range that reaches back before the first day), `previous` is `null`.\n */\nexport function revenueReport(range: Range, compare: Compare) {\n  const comparison = comparisonOf(range, compare);\n  return {\n    current: summarise(range),\n    previous: comparison.from >= 0 ? summarise(comparison) : null,\n  };\n}\n"
    },
    {
      "path": "src/blocks/report/format.ts",
      "type": "registry:file",
      "target": "blocks/wideset/report/format.ts",
      "content": "import { isoOf } from './data';\n\n// One locale and currency for the whole screen; swap them for the workspace's.\nconst LOCALE = 'en-US';\nconst CURRENCY = 'USD';\n\nconst usd = new Intl.NumberFormat(LOCALE, {\n  style: 'currency',\n  currency: CURRENCY,\n  maximumFractionDigits: 0,\n});\nconst usdSigned = new Intl.NumberFormat(LOCALE, {\n  style: 'currency',\n  currency: CURRENCY,\n  maximumFractionDigits: 0,\n  signDisplay: 'exceptZero',\n});\nconst usdCompact = new Intl.NumberFormat(LOCALE, {\n  style: 'currency',\n  currency: CURRENCY,\n  notation: 'compact',\n  maximumFractionDigits: 1,\n});\nconst count = new Intl.NumberFormat(LOCALE);\nconst percent = new Intl.NumberFormat(LOCALE, {\n  style: 'percent',\n  minimumFractionDigits: 1,\n  maximumFractionDigits: 1,\n});\nconst percentSigned = new Intl.NumberFormat(LOCALE, {\n  style: 'percent',\n  minimumFractionDigits: 1,\n  maximumFractionDigits: 1,\n  signDisplay: 'exceptZero',\n});\nconst share = new Intl.NumberFormat(LOCALE, { style: 'percent', maximumFractionDigits: 0 });\n// Days are calendar days (`2026-11-10`), parsed as UTC midnight: format them in UTC too.\nconst day = new Intl.DateTimeFormat(LOCALE, { month: 'short', day: 'numeric', timeZone: 'UTC' });\nconst month = new Intl.DateTimeFormat(LOCALE, { month: 'short', timeZone: 'UTC' });\nconst fullDay = new Intl.DateTimeFormat(LOCALE, {\n  month: 'short',\n  day: 'numeric',\n  year: 'numeric',\n  timeZone: 'UTC',\n});\n\nconst dateOf = (dayNumber: number) => new Date(isoOf(dayNumber));\n\nexport const formatUsd = (value: number) => usd.format(value);\n/** A movement with its sign: `+$11,640`, `-$2,310`. */\nexport const formatUsdSigned = (value: number) => usdSigned.format(value);\nexport const formatUsdCompact = (value: number) => usdCompact.format(value);\nexport const formatCount = (value: number) => count.format(value);\n/** A change, unsigned: an arrow or the column says which way. */\nexport const formatPercent = (value: number) => percent.format(Math.abs(value));\nexport const formatPercentSigned = (value: number) => percentSigned.format(value);\nexport const formatShare = (value: number) => share.format(value);\nexport const formatDay = (dayNumber: number) => day.format(dateOf(dayNumber));\nexport const formatMonth = (dayNumber: number) => month.format(dateOf(dayNumber));\n/** `Jan 1 – Nov 10, 2026`, or one day: `Nov 10, 2026`. */\nexport const formatRange = (from: number, to: number) =>\n  from === to ? fullDay.format(dateOf(from)) : fullDay.formatRange(dateOf(from), dateOf(to));\n"
    },
    {
      "path": "src/blocks/report/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { AppShell } from '@/components/ui/wideset/app-shell/AppShell';\nimport { cn } from '@/lib/wideset/utils';\nimport { type DateRangePreset, type DateRangeValue } from '@/components/ui/wideset/daterangepicker/DateRangePicker.types';\nimport { useState } from 'react';\n\nimport {\n  type Compare,\n  comparisonOf,\n  dayOf,\n  FIRST_DAY,\n  isoOf,\n  type Range,\n  revenueReport,\n  SAMPLE_RANGE,\n  type Summary,\n  TODAY,\n} from './data';\nimport { formatCount, formatPercent, formatRange, formatUsd, formatUsdSigned } from './format';\nimport { KpiCard } from './kpi-card';\nimport { MovementsChart } from './movements-chart';\nimport { MrrChart } from './mrr-chart';\nimport { PageHeader } from './page-header';\nimport { PlanBreakdown } from './plan-breakdown';\nimport { RegionTable } from './region-table';\nimport { ReportSidebar } from './sidebar';\n\n/** One column for the title row and every section, so their edges line up. */\nconst COLUMN = 'mx-auto w-full max-w-[80rem]';\n/** A module of the report: white on the grey canvas, no border, a light shadow to lift it. */\nconst SECTION = 'bg-ws-static-foreground rounded-ws-container-md shadow-ws-low p-ws-12';\n\ntype Figure = {\n  label: string;\n  value: number;\n  previous?: number;\n  /** The direction that is good news: churned MRR going down is. */\n  better: 'up' | 'down';\n  format: (value: number) => string;\n};\n\n/** A figure as a key figure: the value, its change and what the change is measured against. */\nconst toKpi = ({ label, value, previous, better, format }: Figure) => {\n  const direction = previous === undefined || value >= previous ? 'up' : 'down';\n  return {\n    label,\n    value: format(value),\n    // A change in percent needs a positive base: a net loss before the range has none.\n    change:\n      previous !== undefined && previous > 0\n        ? formatPercent((value - previous) / previous)\n        : undefined,\n    direction,\n    good: direction === better,\n    comparison: previous === undefined ? 'Nothing to compare with' : `from ${format(previous)}`,\n  } as const;\n};\n\n/** The region breakdown as a CSV file, the way a spreadsheet opens it. */\nfunction exportCsv({ range, regions, ...total }: Summary) {\n  const lines = [\n    ['Region', 'New MRR', 'Expansion MRR', 'Churned MRR', 'Net new MRR', 'MRR'],\n    ...regions.map((r) => [r.label, r.new, r.expansion, r.churn, r.net, r.mrr]),\n    ['Total', total.new, total.expansion, total.churn, total.net, total.mrr],\n  ];\n  const file = new Blob([lines.map((line) => line.join(',')).join('\\n')], { type: 'text/csv' });\n  const link = document.createElement('a');\n  link.href = URL.createObjectURL(file);\n  link.download = `revenue-report-${isoOf(range.from)}-to-${isoOf(range.to)}.csv`;\n  link.click();\n  URL.revokeObjectURL(link.href);\n}\n\n/** The day of every point of a daily series: the close of the day before the range, then each day. */\nconst daysFrom = (range: Range) =>\n  Array.from({ length: range.to - range.from + 2 }, (_, index) => range.from - 1 + index);\n\n/**\n * Revenue report, Canvas direction: the sidebar and the title row on the grey canvas, every module\n * in its own white section. MRR for a range against an earlier one. The date range and the\n * comparison recount every figure on the page from one set of MRR movements, so the key figures,\n * the charts and the table always add up.\n */\nexport default function Report() {\n  const [picked, setPicked] = useState<{ range: DateRangeValue; preset: DateRangePreset }>({\n    range: SAMPLE_RANGE,\n    preset: 'custom',\n  });\n  const [compare, setCompare] = useState<Compare>('year');\n\n  // A preset can reach past today (\"This year\" ends on Dec 31): the report stops at today.\n  const range: Range = {\n    from: Math.max(dayOf(picked.range.from!), FIRST_DAY),\n    to: Math.min(dayOf(picked.range.to!), TODAY),\n  };\n  const comparison = comparisonOf(range, compare);\n  const { current, previous } = revenueReport(range, compare);\n  const currentLabel = formatRange(range.from, range.to);\n  const previousLabel = formatRange(comparison.from, comparison.to);\n\n  const figures: Figure[] = [\n    { label: 'MRR', value: current.mrr, previous: previous?.mrr, better: 'up', format: formatUsd },\n    {\n      label: 'Net new MRR',\n      value: current.net,\n      previous: previous?.net,\n      better: 'up',\n      format: formatUsdSigned,\n    },\n    {\n      label: 'Churned MRR',\n      value: current.churn,\n      previous: previous?.churn,\n      better: 'down',\n      format: formatUsd,\n    },\n    {\n      label: 'Customers',\n      value: current.customers,\n      previous: previous?.customers,\n      better: 'up',\n      format: formatCount,\n    },\n  ];\n\n  return (\n    <AppShell className=\"ws-block-utility\" direction=\"canvas\">\n      <ReportSidebar />\n      <AppShell.Main className=\"flex flex-col\">\n        <PageHeader\n          range={picked.range}\n          preset={picked.preset}\n          onRangeChange={(next, preset) => setPicked({ range: next, preset })}\n          compare={compare}\n          onCompareChange={setCompare}\n          summary={\n            previous\n              ? `${currentLabel}, compared with ${previousLabel}`\n              : `${currentLabel}; there is no earlier data to compare with`\n          }\n          onExport={() => exportCsv(current)}\n        />\n\n        {/* The controls stay in view; the report scrolls under them. */}\n        <div className=\"px-ws-12 pb-ws-12 ws-scrollbar min-h-0 flex-1 overflow-y-auto\">\n          <div className={cn(COLUMN, 'gap-ws-9 flex flex-col')}>\n            <section aria-label=\"Key figures\" className=\"gap-ws-9 grid grid-cols-4\">\n              {figures.map((figure) => (\n                <KpiCard key={figure.label} {...toKpi(figure)} className={SECTION} />\n              ))}\n            </section>\n\n            <MrrChart\n              days={daysFrom(range)}\n              current={current.daily}\n              previous={previous?.daily ?? null}\n              previousDays={previous ? daysFrom(comparison) : null}\n              currentLabel={currentLabel}\n              previousLabel={previousLabel}\n              className={SECTION}\n            />\n\n            <div className=\"gap-ws-9 grid grid-cols-3\">\n              <MovementsChart\n                buckets={current.buckets}\n                unit={current.unit}\n                totals={current}\n                className={cn(SECTION, 'col-span-2')}\n              />\n              <PlanBreakdown plans={current.plans} className={SECTION} />\n            </div>\n\n            <RegionTable current={current} previous={previous} className={SECTION} />\n          </div>\n        </div>\n      </AppShell.Main>\n    </AppShell>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/kpi-card.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/kpi-card.tsx",
      "content": "'use client';\n\n// TODO(custom): key figure card, version 01 (figure, delta, comparison); no KpiCard in Wideset yet.\nimport { RiArrowDownLine, RiArrowUpLine } from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\n\nexport type KpiCardProps = {\n  label: string;\n  /** The figure, formatted: `$897,873`, `2,056`. */\n  value: string;\n  /** The change against the comparison, formatted and unsigned (`11.0%`); left out without one. */\n  change?: string;\n  direction: 'up' | 'down';\n  /** Whether the change is good news. It picks the colour; the arrow follows `direction`. */\n  good: boolean;\n  /** What the change is measured against, e.g. `from $728,506`. */\n  comparison: string;\n  className?: string;\n};\n\n/**\n * A key figure: what it measures, the number, and how it moved against the comparison. The colour\n * of the change follows its meaning, not its direction: churned MRR going down is green.\n */\nexport function KpiCard({\n  label,\n  value,\n  change,\n  direction,\n  good,\n  comparison,\n  className,\n}: KpiCardProps) {\n  const Arrow = direction === 'up' ? RiArrowUpLine : RiArrowDownLine;\n\n  return (\n    <div className={cn('gap-ws-5 flex flex-col', className)}>\n      <div className=\"gap-ws-3 flex flex-col\">\n        <p className=\"typography-label-sm text-ws-static-subtle\">{label}</p>\n        <p className=\"typography-title-md text-ws-static-strong tabular-nums\">{value}</p>\n      </div>\n      <div className=\"gap-ws-5 flex items-center\">\n        {change && (\n          <StatusBadge size=\"sm\" color={good ? 'positive' : 'negative'}>\n            <StatusBadge.Icon icon={Arrow} />\n            <StatusBadge.Label>\n              <span className=\"sr-only\">{direction === 'up' ? 'Up' : 'Down'} </span>\n              {change}\n            </StatusBadge.Label>\n          </StatusBadge>\n        )}\n        <span className=\"typography-label-sm text-ws-static-subtle tabular-nums\">{comparison}</span>\n      </div>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/movements-chart.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/movements-chart.tsx",
      "content": "'use client';\n\n// TODO(custom): hand-built SVG stacked bar chart (new and expansion up, churned down) with a hover readout; no chart component and no data-viz colour tokens.\nimport { cn } from '@/lib/wideset/utils';\nimport { useId, useState } from 'react';\n\nimport type { Bucket, Unit } from './data';\nimport { formatDay, formatMonth, formatUsd, formatUsdCompact } from './format';\n\n// What the money did, in Wideset's one highlight and its lighter step; churn is the neutral grey\n// below the line, so the colours stay for growth.\nconst SERIES = [\n  { key: 'new', label: 'New', fill: 'fill-(--ws-non-semantic-fill-blue-strong)' },\n  { key: 'expansion', label: 'Expansion', fill: 'fill-(--ws-non-semantic-fill-blue-subtle)' },\n  { key: 'churn', label: 'Churned', fill: 'fill-(--ws-static-fill-alpha-strong)' },\n] as const;\n\n/** The axis step: 1, 2, 2.5 or 5 times a power of ten, for about three gridlines a side. */\nconst niceStep = (max: number) => {\n  const raw = Math.max(max, 1) / 3;\n  const power = 10 ** Math.floor(Math.log10(raw));\n  return [1, 2, 2.5, 5, 10].map((factor) => factor * power).find((step) => step >= raw)!;\n};\n\nconst labelOf = (bucket: Bucket, unit: Unit) =>\n  unit === 'month' ? formatMonth(bucket.from) : formatDay(bucket.from);\nconst pct = (value: number) => `${value * 100}%`;\n\ntype MovementsChartProps = {\n  buckets: Bucket[];\n  unit: Unit;\n  /** The range's totals, shown in the legend while no bar is hovered. */\n  totals: { new: number; expansion: number; churn: number };\n  className?: string;\n};\n\n/**\n * Where MRR came from and where it went, bar by bar: new and expansion stacked above the line,\n * churned below it. Hovering a bar reads it in the legend.\n */\nexport function MovementsChart({ buckets, unit, totals, className }: MovementsChartProps) {\n  const titleId = useId();\n  const [hovered, setHover] = useState<number | null>(null);\n  // A range change (by keyboard, the pointer still) can leave fewer buckets than the hovered index.\n  const hover = hovered !== null && hovered < buckets.length ? hovered : null;\n\n  const up = Math.max(...buckets.map((b) => b.new + b.expansion));\n  const down = Math.max(...buckets.map((b) => b.churn));\n  const step = niceStep(Math.max(up, down));\n  // Whole steps above and below the line, at least one each way.\n  const top = Math.max(Math.ceil(up / step), 1);\n  const bottom = Math.max(Math.ceil(down / step), 1);\n  const span = (top + bottom) * step;\n  const ticks = Array.from({ length: top + bottom + 1 }, (_, index) => (top - index) * step);\n  /** A value's height as a share of the plot; `y` places it from the top. */\n  const h = (value: number) => value / span;\n  const y = (value: number) => (top * step - value) / span;\n\n  const band = 1 / buckets.length;\n  const bar = band * (buckets.length > 16 ? 0.56 : 0.36);\n  const stride = Math.ceil(buckets.length / 8);\n  const shown = hover === null ? totals : buckets[hover];\n\n  return (\n    <section aria-labelledby={titleId} className={cn('gap-ws-11 flex flex-col', className)}>\n      <div className=\"gap-ws-9 flex items-center justify-between\">\n        <h2 id={titleId} className=\"typography-subtitle-xs text-ws-static-strong\">\n          MRR movements\n        </h2>\n        <ul className=\"gap-ws-11 typography-label-sm flex items-center\">\n          {hover !== null && (\n            <li className=\"text-ws-static-strong\">{labelOf(buckets[hover], unit)}</li>\n          )}\n          {SERIES.map((series) => (\n            <li key={series.key} className=\"gap-ws-5 flex items-center\">\n              <svg aria-hidden viewBox=\"0 0 8 8\" className={cn('size-ws-5', series.fill)}>\n                <rect width=\"8\" height=\"8\" rx=\"2\" />\n              </svg>\n              <span className=\"text-ws-static-subtle\">{series.label}</span>\n              <span className=\"text-ws-static-base tabular-nums\">\n                {formatUsd(shown[series.key])}\n              </span>\n            </li>\n          ))}\n        </ul>\n      </div>\n\n      <figure aria-label=\"New, expansion and churned MRR\" className=\"gap-ws-5 flex flex-col\">\n        <div className=\"relative h-[13rem]\">\n          <svg aria-hidden className=\"inset-ws-0 absolute size-full overflow-visible\">\n            {ticks.map((tick) => (\n              <text\n                key={tick}\n                x=\"0\"\n                y={pct(y(tick))}\n                dominantBaseline=\"middle\"\n                className=\"typography-caption-md fill-ws-static-subtle tabular-nums\"\n              >\n                {tick < 0 ? `-${formatUsdCompact(-tick)}` : formatUsdCompact(tick)}\n              </text>\n            ))}\n          </svg>\n          {/* No viewBox: bars are placed in percent, so their corners stay round at any width. */}\n          <div className=\"inset-y-ws-0 left-ws-18 right-ws-0 absolute\">\n            <svg\n              aria-hidden\n              className=\"size-full overflow-visible\"\n              onPointerLeave={() => setHover(null)}\n            >\n              {ticks.map((tick) => (\n                <line\n                  key={tick}\n                  x1=\"0\"\n                  x2=\"100%\"\n                  y1={pct(y(tick))}\n                  y2={pct(y(tick))}\n                  className={\n                    tick === 0 ? 'stroke-ws-static-subtle' : 'stroke-(--ws-static-stroke-base)'\n                  }\n                />\n              ))}\n              {buckets.map((bucket, index) => {\n                const x = pct(index * band + (band - bar) / 2);\n                const width = pct(bar);\n                const dim = hover !== null && hover !== index;\n                return (\n                  <g key={bucket.from} opacity={dim ? 0.4 : 1}>\n                    <rect\n                      x={x}\n                      width={width}\n                      y={pct(y(bucket.new))}\n                      height={pct(h(bucket.new))}\n                      rx=\"2\"\n                      className={SERIES[0].fill}\n                    />\n                    <rect\n                      x={x}\n                      width={width}\n                      y={pct(y(bucket.new + bucket.expansion))}\n                      height={pct(h(bucket.expansion))}\n                      rx=\"2\"\n                      className={SERIES[1].fill}\n                    />\n                    <rect\n                      x={x}\n                      width={width}\n                      y={pct(y(0))}\n                      height={pct(h(bucket.churn))}\n                      rx=\"2\"\n                      className={SERIES[2].fill}\n                    />\n                    {/* The whole band is the hover target, not only the bar. */}\n                    <rect\n                      x={pct(index * band)}\n                      width={pct(band)}\n                      y=\"0\"\n                      height=\"100%\"\n                      fill=\"transparent\"\n                      onPointerEnter={() => setHover(index)}\n                    />\n                  </g>\n                );\n              })}\n            </svg>\n          </div>\n        </div>\n        <div className=\"pl-ws-18\">\n          <svg aria-hidden className=\"h-ws-9 w-full overflow-visible\">\n            {buckets.map((bucket, index) =>\n              index % stride === 0 ? (\n                <text\n                  key={bucket.from}\n                  x={pct((index + 0.5) * band)}\n                  y=\"50%\"\n                  dominantBaseline=\"middle\"\n                  textAnchor=\"middle\"\n                  className={cn(\n                    'typography-caption-md',\n                    hover === index ? 'fill-ws-static-strong' : 'fill-ws-static-subtle',\n                  )}\n                >\n                  {labelOf(bucket, unit)}\n                </text>\n              ) : null,\n            )}\n          </svg>\n        </div>\n        {/* The bars are drawn for the eye and read by the pointer; this is the same data in text. */}\n        <figcaption className=\"sr-only\">\n          In the range: {formatUsd(totals.new)} new, {formatUsd(totals.expansion)} expansion,{' '}\n          {formatUsd(totals.churn)} churned.\n        </figcaption>\n        <table className=\"sr-only\">\n          <caption>MRR movements by {unit}</caption>\n          <thead>\n            <tr>\n              <th scope=\"col\">\n                {unit === 'month' ? 'Month' : unit === 'week' ? 'Week of' : 'Day'}\n              </th>\n              {SERIES.map((series) => (\n                <th key={series.key} scope=\"col\">\n                  {series.label}\n                </th>\n              ))}\n            </tr>\n          </thead>\n          <tbody>\n            {buckets.map((bucket) => (\n              <tr key={bucket.from}>\n                <th scope=\"row\">{labelOf(bucket, unit)}</th>\n                {SERIES.map((series) => (\n                  <td key={series.key}>{formatUsd(bucket[series.key])}</td>\n                ))}\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </figure>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/mrr-chart.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/mrr-chart.tsx",
      "content": "'use client';\n\n// TODO(custom): hand-built SVG line chart with a comparison series and a hover readout; no chart component and no data-viz colour tokens (uses non-semantic blue).\nimport { cn } from '@/lib/wideset/utils';\nimport { useId, useState } from 'react';\n\nimport { isoOf } from './data';\nimport { formatDay, formatMonth, formatRange, formatUsd, formatUsdCompact } from './format';\n\n// The plot in viewBox units; the SVG stretches to its box and the strokes keep their width.\nconst WIDTH = 1000;\nconst HEIGHT = 240;\n\n// Wideset has no data-visualisation colours yet: the range in view takes the blue highlight, the\n// range it is compared with stays a neutral grey.\nconst CURRENT = 'stroke-(--ws-non-semantic-fill-blue-strong)';\nconst PREVIOUS = 'stroke-ws-static-subtle';\n\n/** The axis step: 1, 2, 2.5 or 5 times a power of ten, for about four gridlines. */\nconst niceStep = (span: number) => {\n  const raw = span / 4;\n  const power = 10 ** Math.floor(Math.log10(raw));\n  return [1, 2, 2.5, 5, 10].map((factor) => factor * power).find((step) => step >= raw)!;\n};\n\n/** Which points get a date under the axis: month starts on a long range, else every few days. */\nconst labelled = (days: number[]) => {\n  const last = days.length - 1;\n  if (last > 62) {\n    return days\n      .map((day, index) => ({ day, index }))\n      .filter(({ day, index }) => index > 0 && isoOf(day).endsWith('-01'))\n      .map(({ index }) => index);\n  }\n  // The first point is the close of the day before the range: it gets no date of its own.\n  const step = last <= 8 ? 1 : last <= 31 ? 7 : 14;\n  return days.map((_, index) => index).filter((index) => index > 0 && (last - index) % step === 0);\n};\n\ntype MrrChartProps = {\n  /** The day of every point: the close of the day before the range, then every day in it. */\n  days: number[];\n  current: number[];\n  /** The comparison range, point by point; `null` when there is none. */\n  previous: number[] | null;\n  previousDays: number[] | null;\n  currentLabel: string;\n  previousLabel: string;\n  className?: string;\n};\n\n/**\n * MRR at the close of every day of the range, over the range it is compared with. Hovering the\n * plot reads one day off both lines in the legend.\n */\nexport function MrrChart({\n  days,\n  current,\n  previous,\n  previousDays,\n  currentLabel,\n  previousLabel,\n  className,\n}: MrrChartProps) {\n  const id = useId().replace(/[^\\w-]/g, '');\n  const [hovered, setHover] = useState<number | null>(null);\n  const last = current.length - 1;\n  // A range change (by keyboard, the pointer still) can leave fewer days than the hovered index.\n  const hover = hovered !== null && hovered <= last ? hovered : null;\n\n  const values = [...current, ...(previous ?? [])];\n  const low = Math.min(...values);\n  const high = Math.max(...values);\n  const step = niceStep(Math.max(high - low, high * 0.02));\n  const floor = Math.floor(low / step) * step;\n  const ceiling = Math.max(Math.ceil(high / step) * step, floor + step);\n  const ticks = Array.from(\n    { length: Math.round((ceiling - floor) / step) + 1 },\n    (_, index) => ceiling - index * step,\n  );\n\n  const x = (index: number, count: number) => (count > 1 ? (index / (count - 1)) * WIDTH : WIDTH);\n  const y = (value: number) => HEIGHT - ((value - floor) / (ceiling - floor)) * HEIGHT;\n  const line = (series: number[]) =>\n    series\n      .map((value, index) => `${index ? 'L' : 'M'}${x(index, series.length)} ${y(value)}`)\n      .join('');\n\n  // The point the readout shows: the hovered day, or the last one.\n  const at = hover ?? last;\n  const previousAt = previous ? Math.round((at / Math.max(last, 1)) * (previous.length - 1)) : 0;\n\n  return (\n    <section aria-labelledby={`${id}-title`} className={cn('gap-ws-11 flex flex-col', className)}>\n      <div className=\"gap-ws-9 flex items-center justify-between\">\n        <h2 id={`${id}-title`} className=\"typography-subtitle-xs text-ws-static-strong\">\n          MRR\n        </h2>\n        <ul className=\"gap-ws-12 typography-label-sm flex items-center\">\n          <li className=\"gap-ws-5 flex items-center\">\n            <Swatch className={CURRENT} />\n            <span className=\"text-ws-static-subtle\">\n              {hover === null ? currentLabel : formatRange(days[at], days[at])}\n            </span>\n            <span className=\"text-ws-static-strong tabular-nums\">{formatUsd(current[at])}</span>\n          </li>\n          {previous && previousDays && (\n            <li className=\"gap-ws-5 flex items-center\">\n              <Swatch className={PREVIOUS} dashed />\n              <span className=\"text-ws-static-subtle\">\n                {hover === null\n                  ? previousLabel\n                  : formatRange(previousDays[previousAt], previousDays[previousAt])}\n              </span>\n              <span className=\"text-ws-static-base tabular-nums\">\n                {formatUsd(previous[previousAt])}\n              </span>\n            </li>\n          )}\n        </ul>\n      </div>\n\n      <figure aria-label={`MRR, ${currentLabel}, against ${previousLabel}`}>\n        <div className=\"relative h-[15rem]\">\n          {/* Tick values: a second SVG with no viewBox, so the text keeps its shape. */}\n          <svg aria-hidden className=\"inset-ws-0 absolute size-full overflow-visible\">\n            {ticks.map((tick) => (\n              <text\n                key={tick}\n                x=\"0\"\n                y={`${((ceiling - tick) / (ceiling - floor)) * 100}%`}\n                dominantBaseline=\"middle\"\n                className=\"typography-caption-md fill-ws-static-subtle tabular-nums\"\n              >\n                {formatUsdCompact(tick)}\n              </text>\n            ))}\n          </svg>\n          <div\n            className=\"inset-y-ws-0 left-ws-18 right-ws-0 absolute\"\n            onPointerMove={(event) => {\n              const box = event.currentTarget.getBoundingClientRect();\n              const fraction = (event.clientX - box.left) / box.width;\n              setHover(Math.min(Math.max(Math.round(fraction * last), 0), last));\n            }}\n            onPointerLeave={() => setHover(null)}\n          >\n            <svg\n              viewBox={`0 0 ${WIDTH} ${HEIGHT}`}\n              preserveAspectRatio=\"none\"\n              aria-hidden\n              className=\"size-full overflow-visible\"\n            >\n              <defs>\n                <linearGradient\n                  id={`${id}-fill`}\n                  x1=\"0\"\n                  y1=\"0\"\n                  x2=\"0\"\n                  y2=\"1\"\n                  className=\"text-(--ws-non-semantic-fill-blue-strong)\"\n                >\n                  <stop offset=\"0\" stopColor=\"currentColor\" stopOpacity={0.12} />\n                  <stop offset=\"1\" stopColor=\"currentColor\" stopOpacity={0} />\n                </linearGradient>\n              </defs>\n              {ticks.map((tick) => (\n                <line\n                  key={tick}\n                  x1=\"0\"\n                  x2={WIDTH}\n                  y1={y(tick)}\n                  y2={y(tick)}\n                  vectorEffect=\"non-scaling-stroke\"\n                  className=\"stroke-(--ws-static-stroke-base)\"\n                />\n              ))}\n              {previous && (\n                <path\n                  d={line(previous)}\n                  fill=\"none\"\n                  strokeWidth={1.5}\n                  strokeDasharray=\"4 4\"\n                  strokeLinejoin=\"round\"\n                  vectorEffect=\"non-scaling-stroke\"\n                  className={PREVIOUS}\n                />\n              )}\n              <path\n                d={`${line(current)}L${WIDTH} ${HEIGHT}L0 ${HEIGHT}Z`}\n                fill={`url(#${id}-fill)`}\n              />\n              {hover !== null && (\n                <line\n                  x1={x(at, current.length)}\n                  x2={x(at, current.length)}\n                  y1=\"0\"\n                  y2={HEIGHT}\n                  vectorEffect=\"non-scaling-stroke\"\n                  className=\"stroke-(--ws-static-stroke-strong)\"\n                />\n              )}\n              <g fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className={CURRENT}>\n                <path d={line(current)} strokeWidth={2} vectorEffect=\"non-scaling-stroke\" />\n                {/* The point in the readout: a round cap on a zero-length line stays a circle. */}\n                <path\n                  d={`M${x(at, current.length)} ${y(current[at])}h0`}\n                  strokeWidth={8}\n                  vectorEffect=\"non-scaling-stroke\"\n                />\n              </g>\n            </svg>\n          </div>\n        </div>\n        <div className=\"pl-ws-18 mt-ws-5\">\n          <svg aria-hidden className=\"h-ws-9 w-full overflow-visible\">\n            {labelled(days).map((index) => (\n              <text\n                key={days[index]}\n                x={`${(index / Math.max(last, 1)) * 100}%`}\n                y=\"50%\"\n                dominantBaseline=\"middle\"\n                textAnchor={index === last ? 'end' : index === 0 ? 'start' : 'middle'}\n                className=\"typography-caption-md fill-ws-static-subtle\"\n              >\n                {last > 62 ? formatMonth(days[index]) : formatDay(days[index])}\n              </text>\n            ))}\n          </svg>\n        </div>\n        {/* The lines are drawn for the eye and read by the pointer; this is the same data in text. */}\n        <figcaption className=\"sr-only\">\n          {currentLabel}: from {formatUsd(current[0])} to {formatUsd(current[last])}.\n          {previous && ` ${previousLabel}: closed at ${formatUsd(previous[previous.length - 1])}.`}\n        </figcaption>\n        <table className=\"sr-only\">\n          <caption>MRR at the close of each day</caption>\n          <thead>\n            <tr>\n              <th scope=\"col\">Day</th>\n              <th scope=\"col\">{currentLabel}</th>\n              {previous && <th scope=\"col\">{previousLabel}</th>}\n            </tr>\n          </thead>\n          <tbody>\n            {days.map((day, index) => {\n              // The day it is compared with, as the readout pairs them.\n              const paired = previous\n                ? Math.round((index / Math.max(last, 1)) * (previous.length - 1))\n                : 0;\n              return (\n                <tr key={day}>\n                  <th scope=\"row\">{formatDay(day)}</th>\n                  <td>{formatUsd(current[index])}</td>\n                  {previous && (\n                    <td>\n                      {formatUsd(previous[paired])}\n                      {previousDays && `, ${formatDay(previousDays[paired])}`}\n                    </td>\n                  )}\n                </tr>\n              );\n            })}\n          </tbody>\n        </table>\n      </figure>\n    </section>\n  );\n}\n\n/** A legend key: a short stroke in the series' colour and dash. */\nfunction Swatch({ className, dashed }: { className: string; dashed?: boolean }) {\n  return (\n    <svg\n      aria-hidden\n      viewBox=\"0 0 20 2\"\n      className={cn('w-ws-11 h-ws-2 overflow-visible', className)}\n    >\n      <line\n        x1=\"0\"\n        x2=\"20\"\n        y1=\"1\"\n        y2=\"1\"\n        strokeWidth={2}\n        strokeDasharray={dashed ? '4 4' : undefined}\n      />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/page-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/page-header.tsx",
      "content": "'use client';\n\nimport { RiDownload2Line } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';\nimport { type DateRangePreset, type DateRangeValue } from '@/components/ui/wideset/daterangepicker/DateRangePicker.types';\nimport { Select } from '@/components/ui/wideset/select/Select';\n\nimport { type Compare, COMPARE_OPTIONS, FIRST_DAY, isoOf, TODAY } from './data';\n\n/** The presets in the product's sentence case. */\nconst PRESET_LABELS: Partial<Record<DateRangePreset, string>> = {\n  thisWeek: 'This week',\n  lastWeek: 'Last week',\n  thisMonth: 'This month',\n  lastMonth: 'Last month',\n  thisYear: 'This year',\n  lastYear: 'Last year',\n};\n\n/** A calendar day as a local Date, for the picker's disabled days. */\nconst localDate = (day: number) => {\n  const [year, month, date] = isoOf(day).split('-').map(Number);\n  return new Date(year, month - 1, date);\n};\n// Ranges start a year into the data, so a comparison always has numbers, and end today.\nconst DISABLED = [{ before: localDate(FIRST_DAY) }, { after: localDate(TODAY) }];\n\ntype PageHeaderProps = {\n  range: DateRangeValue;\n  preset: DateRangePreset;\n  onRangeChange: (range: DateRangeValue, preset: DateRangePreset) => void;\n  compare: Compare;\n  onCompareChange: (compare: Compare) => void;\n  /** The dates on screen and what they are compared with, in words. */\n  summary: string;\n  onExport: () => void;\n};\n\n/**\n * The report's title, the dates it covers, what it is compared with, and its export, on the grey\n * canvas with no fill and no line under it.\n */\nexport function PageHeader({\n  range,\n  preset,\n  onRangeChange,\n  compare,\n  onCompareChange,\n  summary,\n  onExport,\n}: PageHeaderProps) {\n  return (\n    <header className=\"px-ws-12 shrink-0\">\n      <div className=\"gap-ws-9 pt-ws-11 pb-ws-12 mx-auto flex w-full max-w-[80rem] items-center justify-between\">\n        <div className=\"gap-ws-3 flex min-w-0 flex-col\">\n          <h1 className=\"typography-title-md text-ws-static-strong\">Revenue report</h1>\n          <p className=\"typography-body-md text-ws-static-base\">{summary}</p>\n        </div>\n        <div className=\"gap-ws-5 flex shrink-0 items-center\">\n          <DateRangePicker\n            size=\"sm\"\n            aria-label=\"Report period\"\n            className=\"w-[14.5rem]\"\n            showDatePresets\n            presetLabels={PRESET_LABELS}\n            selected={range}\n            activeDatePreset={preset}\n            weekStartsOn={1}\n            dateFormat=\"MMM d, yyyy\"\n            disabledDates={DISABLED}\n            onSelect={(next, nextPreset) => {\n              if (next?.from && next.to) onRangeChange(next, nextPreset ?? 'custom');\n            }}\n          />\n          <Select\n            size=\"sm\"\n            options={COMPARE_OPTIONS}\n            value={compare}\n            onValueChange={(value) => onCompareChange(value as Compare)}\n            aria-label=\"Compare with\"\n            className=\"w-[10rem]\"\n          />\n          <Button size=\"sm\" variant=\"secondary\" preset=\"border\" onClick={onExport}>\n            <Button.Icon icon={RiDownload2Line} />\n            Export\n          </Button>\n        </div>\n      </div>\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/plan-breakdown.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/plan-breakdown.tsx",
      "content": "'use client';\n\n// TODO(custom): bar list (bar behind a label, value and share on the right); no BarList in Wideset.\nimport { cn } from '@/lib/wideset/utils';\nimport { useId } from 'react';\n\nimport { formatShare, formatUsd } from './format';\n\ntype Plan = { id: string; label: string; mrr: number };\n\n/**\n * MRR at the close of the range by plan, largest first: each bar is the plan's MRR against the\n * largest plan, drawn behind its name, with its share of the total beside the amount.\n */\nexport function PlanBreakdown({ plans, className }: { plans: Plan[]; className?: string }) {\n  const titleId = useId();\n  const total = plans.reduce((sum, plan) => sum + plan.mrr, 0);\n  const sorted = [...plans].sort((a, b) => b.mrr - a.mrr);\n  const max = sorted[0]?.mrr || 1;\n\n  return (\n    <section aria-labelledby={titleId} className={cn('gap-ws-11 flex flex-col', className)}>\n      <h2 id={titleId} className=\"typography-subtitle-xs text-ws-static-strong\">\n        MRR by plan\n      </h2>\n      {/* Four 40px rows 16px apart span the 13rem plot beside them. */}\n      <ul className=\"gap-ws-9 flex flex-col\">\n        {sorted.map((plan) => (\n          <li key={plan.id} className=\"h-ws-16 gap-ws-9 flex items-center\">\n            <div className=\"h-ws-14 relative flex min-w-0 flex-1 items-center\">\n              <svg aria-hidden className=\"inset-ws-0 absolute size-full\">\n                <rect\n                  width={`${(plan.mrr / max) * 100}%`}\n                  height=\"100%\"\n                  rx=\"6\"\n                  className=\"fill-(--ws-static-fill-alpha-base)\"\n                />\n              </svg>\n              <span className=\"px-ws-5 typography-label-sm text-ws-static-base relative truncate\">\n                {plan.label}\n              </span>\n            </div>\n            <span className=\"typography-label-sm text-ws-static-strong w-[5.5rem] text-right tabular-nums\">\n              {formatUsd(plan.mrr)}\n            </span>\n            <span className=\"typography-label-sm text-ws-static-subtle w-[2.5rem] text-right tabular-nums\">\n              {formatShare(plan.mrr / total)}\n            </span>\n          </li>\n        ))}\n      </ul>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/region-table.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/region-table.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\nimport { type SortDirection } from '@/components/ui/wideset/table/Table.types';\nimport { Table } from '@/components/ui/wideset/table/Table';\nimport { useId, useState } from 'react';\n\nimport type { Summary } from './data';\nimport { formatPercentSigned, formatUsd, formatUsdSigned } from './format';\n\ntype Row = Omit<Summary['regions'][number], 'id'> & { id: string; change: number | null };\ntype Key = 'label' | 'new' | 'expansion' | 'churn' | 'net' | 'mrr' | 'change';\n\nconst money = (key: 'new' | 'expansion' | 'mrr') => (row: Row) => formatUsd(row[key]);\nconst change = (value: number | null) => (value === null ? '—' : formatPercentSigned(value));\n\nconst COLUMNS: {\n  key: Key;\n  label: string;\n  format: (row: Row) => string;\n  /** The region's name and its MRR: what the eye looks for. */\n  strong?: boolean;\n  className?: string;\n}[] = [\n  { key: 'label', label: 'Region', format: (row) => row.label, strong: true, className: 'w-[22%]' },\n  { key: 'new', label: 'New', format: money('new') },\n  { key: 'expansion', label: 'Expansion', format: money('expansion') },\n  { key: 'churn', label: 'Churned', format: (row) => formatUsdSigned(-row.churn) },\n  { key: 'net', label: 'Net new', format: (row) => formatUsdSigned(row.net) },\n  { key: 'mrr', label: 'MRR', format: money('mrr'), strong: true },\n  { key: 'change', label: 'Change', format: (row) => change(row.change) },\n];\n\n// The first and last columns sit on the section's padding, in line with its title.\nconst flush = (index: number) => index === 0 || index === COLUMNS.length - 1;\n\ntype RegionTableProps = {\n  current: Summary;\n  previous: Summary | null;\n  className?: string;\n};\n\n/**\n * The range by region: the money that came in and went out, the MRR it left, and how that MRR\n * moved against the comparison. Every column sorts; the totals stay in the footer.\n */\nexport function RegionTable({ current, previous, className }: RegionTableProps) {\n  const titleId = useId();\n  const [sort, setSort] = useState<{ key: Key; direction: SortDirection }>({\n    key: 'mrr',\n    direction: 'desc',\n  });\n\n  const growth = (now: number, before?: number) => (before ? now / before - 1 : null);\n  const regions: Row[] = current.regions.map((region, index) => ({\n    ...region,\n    change: growth(region.mrr, previous?.regions[index].mrr),\n  }));\n  const total: Row = {\n    id: 'total',\n    label: 'Total',\n    new: current.new,\n    expansion: current.expansion,\n    churn: current.churn,\n    net: current.net,\n    mrr: current.mrr,\n    change: growth(current.mrr, previous?.mrr),\n  };\n\n  const rows = sort.direction\n    ? [...regions].sort((a, b) => {\n        const left = a[sort.key] ?? -Infinity;\n        const right = b[sort.key] ?? -Infinity;\n        const order = left < right ? -1 : left > right ? 1 : 0;\n        return sort.direction === 'asc' ? order : -order;\n      })\n    : regions;\n\n  // A column sorts in its natural order first: amounts largest first, names from A.\n  const sortBy = (key: Key) =>\n    setSort((now) => ({\n      key,\n      direction:\n        now.key === key\n          ? now.direction === 'desc'\n            ? 'asc'\n            : 'desc'\n          : key === 'label'\n            ? 'asc'\n            : 'desc',\n    }));\n\n  return (\n    <section aria-labelledby={titleId} className={cn('gap-ws-7 flex flex-col', className)}>\n      <h2 id={titleId} className=\"typography-subtitle-xs text-ws-static-strong\">\n        By region\n      </h2>\n      <Table aria-labelledby={titleId} className=\"w-full table-fixed\">\n        <Table.Head>\n          <Table.Row>\n            {COLUMNS.map((column, index) => (\n              <Table.Header\n                key={column.key}\n                align={index ? 'right' : 'left'}\n                flushMargin={flush(index)}\n                className={column.className}\n                sortable\n                sortDirection={sort.key === column.key ? sort.direction : null}\n                onSort={() => sortBy(column.key)}\n              >\n                {column.label}\n              </Table.Header>\n            ))}\n          </Table.Row>\n        </Table.Head>\n        <Table.Body>\n          {rows.map((row) => (\n            <Table.Row key={row.id}>\n              {COLUMNS.map((column, index) => (\n                <Table.Cell\n                  key={column.key}\n                  align={index ? 'right' : 'left'}\n                  flushMargin={flush(index)}\n                >\n                  <span\n                    className={cn(\n                      index > 0 && 'tabular-nums',\n                      column.strong && 'text-ws-static-strong',\n                    )}\n                  >\n                    {column.format(row)}\n                  </span>\n                </Table.Cell>\n              ))}\n            </Table.Row>\n          ))}\n        </Table.Body>\n        <Table.Foot>\n          <Table.Row>\n            {COLUMNS.map((column, index) => (\n              <Table.Cell\n                key={column.key}\n                align={index ? 'right' : 'left'}\n                flushMargin={flush(index)}\n              >\n                <span\n                  className={cn(\n                    'text-ws-static-strong font-ws-medium',\n                    index > 0 && 'tabular-nums',\n                  )}\n                >\n                  {column.format(total)}\n                </span>\n              </Table.Cell>\n            ))}\n          </Table.Row>\n        </Table.Foot>\n      </Table>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/report/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/report/sidebar.tsx",
      "content": "'use client';\n\n// TODO(custom): account menu trigger is composed by hand; no account switcher in Wideset.\nimport { RiArrowDownSLine } from '@remixicon/react';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\nimport { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';\nimport { useState } from 'react';\n\nimport { BrandMark } from './brand-mark';\nimport { ACCOUNT, NAVIGATION, REPORTS, WORKSPACE } from './data';\n\n/** The account menu: who is signed in, their settings and sign-out. */\nfunction AccountMenu() {\n  return (\n    <DropdownMenu>\n      <DropdownMenu.Trigger asChild>\n        <button\n          type=\"button\"\n          className=\"gap-ws-5 px-ws-5 py-ws-3 rounded-ws-control-lg hover:bg-ws-dynamic-tertiary-alpha-strong-default focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default flex w-full items-center text-left\"\n        >\n          <Avatar initials={ACCOUNT.initials} status=\"online\" />\n          <span className=\"flex min-w-0 flex-1 flex-col\">\n            <span className=\"typography-label-strong-sm text-ws-static-base truncate\">\n              {ACCOUNT.name}\n            </span>\n            <span className=\"typography-label-sm text-ws-static-subtle truncate\">\n              {ACCOUNT.role}\n            </span>\n          </span>\n          <RiArrowDownSLine aria-hidden=\"true\" className=\"size-ws-9 text-ws-static-strong\" />\n        </button>\n      </DropdownMenu.Trigger>\n      <DropdownMenu.Content side=\"top\" align=\"start\" className=\"ws-block-utility w-[13.875rem]\">\n        <DropdownMenu.Item>\n          <ListItem.Prefix>\n            <Avatar initials={ACCOUNT.initials} status=\"online\" />\n          </ListItem.Prefix>\n          <ListItem.Content>\n            <ListItem.Label>{ACCOUNT.name}</ListItem.Label>\n            <ListItem.Description>{ACCOUNT.email}</ListItem.Description>\n          </ListItem.Content>\n        </DropdownMenu.Item>\n        <DropdownMenu.Separator />\n        <DropdownMenu.Item>\n          <ListItem.Content>\n            <ListItem.Label>Account</ListItem.Label>\n          </ListItem.Content>\n        </DropdownMenu.Item>\n        <DropdownMenu.Item>\n          <ListItem.Content>\n            <ListItem.Label>Preferences</ListItem.Label>\n          </ListItem.Content>\n        </DropdownMenu.Item>\n        <DropdownMenu.Separator />\n        <DropdownMenu.Item variant=\"danger\">\n          <ListItem.Content>\n            <ListItem.Label>Log out</ListItem.Label>\n          </ListItem.Content>\n        </DropdownMenu.Item>\n      </DropdownMenu.Content>\n    </DropdownMenu>\n  );\n}\n\n/** The app sidebar (Canvas direction: no fill and no line, on the grey canvas beside the page). */\nexport function ReportSidebar() {\n  const [active, setActive] = useState('revenue');\n\n  const item = ({ id, label, icon, count }: (typeof NAVIGATION)[number]) => (\n    <Sidebar.Item\n      key={id}\n      href={`#${id}`}\n      icon={icon}\n      label={label}\n      suffix={count}\n      active={active === id}\n      onClick={() => setActive(id)}\n    />\n  );\n\n  const nav = (\n    <nav aria-label=\"Main\" className=\"gap-ws-7 flex flex-col\">\n      <div className=\"flex flex-col\">{NAVIGATION.map(item)}</div>\n      <div role=\"group\" aria-labelledby=\"sidebar-reports\" className=\"gap-ws-2 flex flex-col\">\n        <Sidebar.SectionHeader id=\"sidebar-reports\">Reports</Sidebar.SectionHeader>\n        {REPORTS.map(item)}\n      </div>\n    </nav>\n  );\n\n  return (\n    <Sidebar>\n      <Sidebar.Header>\n        <Sidebar.Expanded>\n          <div className=\"gap-ws-7 py-ws-3 pl-ws-5 flex items-center\">\n            <BrandMark />\n            <span className=\"typography-label-strong-sm text-ws-static-strong min-w-0 flex-1 truncate\">\n              {WORKSPACE.name}\n            </span>\n            <Sidebar.Trigger />\n          </div>\n        </Sidebar.Expanded>\n        <Sidebar.Collapsed>\n          <div className=\"gap-ws-7 flex flex-col items-center\">\n            <BrandMark label={WORKSPACE.name} />\n            <Sidebar.Trigger />\n          </div>\n        </Sidebar.Collapsed>\n      </Sidebar.Header>\n\n      <Sidebar.Section scrollable>{nav}</Sidebar.Section>\n\n      <Sidebar.Footer>\n        <Sidebar.Expanded>\n          <AccountMenu />\n        </Sidebar.Expanded>\n        <Sidebar.Collapsed>\n          <Avatar initials={ACCOUNT.initials} status=\"online\" aria-label={ACCOUNT.name} />\n        </Sidebar.Collapsed>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
