{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-analytics",
  "type": "registry:block",
  "title": "Analytics",
  "description": "A product analytics overview: a period switch, four key figures with their change, a trend chart and the top pages.",
  "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/segmented-control.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/analytics/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/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/analytics/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBarChartBoxLine,\n  RiBriefcase4Line,\n  RiFileChart2Line,\n  RiHome5Line,\n  RiInbox2Line,\n  RiLineChartLine,\n  RiMoneyDollarCircleLine,\n  RiPieChart2Line,\n  RiTeamLine,\n} from '@remixicon/react';\n\nexport const WORKSPACE = { name: 'Lumen Studio', plan: 'Growth plan', seats: 24 };\nexport const ACCOUNT = { name: 'Nina Alvarez', initials: 'NA', email: 'nina@lumen.studio' };\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: RiTeamLine },\n  { id: 'deals', label: 'Deals', icon: RiBriefcase4Line },\n  { id: 'analytics', label: 'Analytics', icon: RiBarChartBoxLine },\n  { id: 'revenue', label: 'Revenue', icon: RiMoneyDollarCircleLine },\n];\n\nexport const DASHBOARDS: { id: string; label: string; icon: RemixiconComponentType }[] = [\n  { id: 'marketing-site', label: 'Marketing site', icon: RiLineChartLine },\n  { id: 'onboarding', label: 'Onboarding funnel', icon: RiPieChart2Line },\n  { id: 'pricing-test', label: 'Pricing page test', icon: RiFileChart2Line },\n];\n\nexport type Period = '7d' | '30d' | '90d';\n\nexport const PERIODS: { value: Period; label: string; days: number }[] = [\n  { value: '7d', label: 'Last 7 days', days: 7 },\n  { value: '30d', label: 'Last 30 days', days: 30 },\n  { value: '90d', label: 'Last 90 days', days: 90 },\n];\n\n/*\n  180 days of lumen.studio traffic up to today, enough for the longest period and the one before\n  it. Every figure on the screen is summed from these days, so the numbers always add up. The\n  series is generated once, deterministically: weekdays busier than weekends, slow growth, and the\n  December newsletter on the 3rd and 4th.\n*/\nconst TODAY = Date.UTC(2026, 11, 14);\nconst DAY = 86_400_000;\nconst WEEKDAY = [0.62, 1.08, 1.12, 1.1, 1.06, 0.94, 0.58];\nconst NEWSLETTER: Record<string, number> = { '2026-12-03': 1.9, '2026-12-04': 1.35 };\n/** Repeatable noise in [-1, 1]. */\nconst noise = (seed: number) => {\n  const x = Math.sin(seed * 12.9898) * 43_758.5453;\n  return (x - Math.floor(x)) * 2 - 1;\n};\n\nexport type Day = { date: string; visitors: number; signups: number; bounces: number };\n\nexport const DAYS: Day[] = Array.from({ length: 180 }, (_, index) => {\n  const time = TODAY - (179 - index) * DAY;\n  const date = new Date(time).toISOString().slice(0, 10);\n  const boost = NEWSLETTER[date] ?? 1;\n  const visitors = Math.round(\n    1_034 *\n      (1 + index * 0.0024) *\n      WEEKDAY[new Date(time).getUTCDay()] *\n      (1 + noise(index) * 0.07) *\n      boost,\n  );\n  // Newsletter readers sign up less and leave sooner than search traffic.\n  const conversion = (0.0284 - index * 0.000_008 + noise(index + 500) * 0.0025) / Math.sqrt(boost);\n  const bounce = 0.5 - index * 0.000_8 + noise(index + 900) * 0.02 + (boost - 1) * 0.1;\n  return {\n    date,\n    visitors,\n    signups: Math.round(visitors * conversion),\n    bounces: Math.round(visitors * bounce),\n  };\n});\n\n/** Each page's share of the period's visitors, and how people use it. */\nexport const PAGES = [\n  { path: '/', share: 0.58, viewsPerVisitor: 1.38, bounceRate: 0.42, seconds: 48 },\n  { path: '/pricing', share: 0.27, viewsPerVisitor: 1.52, bounceRate: 0.24, seconds: 104 },\n  {\n    path: '/product/scheduling',\n    share: 0.19,\n    viewsPerVisitor: 1.21,\n    bounceRate: 0.31,\n    seconds: 87,\n  },\n  {\n    path: '/blog/reduce-no-shows',\n    share: 0.14,\n    viewsPerVisitor: 1.06,\n    bounceRate: 0.68,\n    seconds: 192,\n  },\n  { path: '/customers', share: 0.08, viewsPerVisitor: 1.17, bounceRate: 0.36, seconds: 71 },\n  { path: '/changelog', share: 0.05, viewsPerVisitor: 1.44, bounceRate: 0.29, seconds: 63 },\n];\n\n/** Where visitors came from, as shares of the period's visitors; the rest is spread thin. */\nexport const SOURCES = [\n  { name: 'Google', share: 0.41 },\n  { name: 'Direct', share: 0.23 },\n  { name: 'LinkedIn', share: 0.12 },\n  { name: 'Newsletter', share: 0.09 },\n  { name: 'ChatGPT', share: 0.06 },\n  { name: 'G2', share: 0.04 },\n];\n\nexport type Metric = {\n  label: string;\n  value: number;\n  previous: number;\n  /** A `rate` is a fraction; its change is told in percentage points. */\n  kind: 'count' | 'rate';\n  decimals?: number;\n  /** The direction that is good news: bounce rate going down is. */\n  better: 'up' | 'down';\n};\n\nconst total = (days: Day[], key: Exclude<keyof Day, 'date'>) =>\n  days.reduce((sum, day) => sum + day[key], 0);\n\n/** Everything the screen shows for one period, summed from `DAYS`. */\nexport function report(period: Period) {\n  const { days } = PERIODS.find((entry) => entry.value === period)!;\n  const current = DAYS.slice(-days);\n  const previous = DAYS.slice(-2 * days, -days);\n  const visitors = total(current, 'visitors');\n  const previousVisitors = total(previous, 'visitors');\n\n  const metrics: Metric[] = [\n    { label: 'Visitors', value: visitors, previous: previousVisitors, kind: 'count', better: 'up' },\n    {\n      label: 'Sign-ups',\n      value: total(current, 'signups'),\n      previous: total(previous, 'signups'),\n      kind: 'count',\n      better: 'up',\n    },\n    {\n      label: 'Conversion rate',\n      value: total(current, 'signups') / visitors,\n      previous: total(previous, 'signups') / previousVisitors,\n      kind: 'rate',\n      decimals: 2,\n      better: 'up',\n    },\n    {\n      label: 'Bounce rate',\n      value: total(current, 'bounces') / visitors,\n      previous: total(previous, 'bounces') / previousVisitors,\n      kind: 'rate',\n      decimals: 1,\n      better: 'down',\n    },\n  ];\n\n  return {\n    current,\n    previous,\n    metrics,\n    pages: PAGES.map(({ share, viewsPerVisitor, ...page }) => ({\n      ...page,\n      visitors: Math.round(visitors * share),\n      views: Math.round(visitors * share * viewsPerVisitor),\n    })),\n    sources: SOURCES.map((source) => ({\n      ...source,\n      visitors: Math.round(visitors * source.share),\n    })),\n  };\n}\n"
    },
    {
      "path": "src/blocks/analytics/format.ts",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/format.ts",
      "content": "// One locale for the whole screen; swap it for the user's.\nconst LOCALE = 'en-US';\n\nconst count = new Intl.NumberFormat(LOCALE);\nconst compact = new Intl.NumberFormat(LOCALE, { notation: 'compact', maximumFractionDigits: 1 });\nconst percent = (decimals: number) =>\n  new Intl.NumberFormat(LOCALE, {\n    style: 'percent',\n    minimumFractionDigits: decimals,\n    maximumFractionDigits: decimals,\n  });\nconst points = (decimals: number) =>\n  new Intl.NumberFormat(LOCALE, {\n    minimumFractionDigits: decimals,\n    maximumFractionDigits: decimals,\n  });\n// Dates are calendar days (`2026-12-14`), parsed as UTC midnight: format them in UTC too.\nconst day = new Intl.DateTimeFormat(LOCALE, { month: 'short', day: 'numeric', timeZone: 'UTC' });\nconst dayAndYear = new Intl.DateTimeFormat(LOCALE, {\n  month: 'short',\n  day: 'numeric',\n  year: 'numeric',\n  timeZone: 'UTC',\n});\n\nexport const formatCount = (value: number) => count.format(value);\nexport const formatCompact = (value: number) => compact.format(value);\nexport const formatPercent = (value: number, decimals = 1) => percent(decimals).format(value);\n/** A change between two rates, in percentage points, unsigned: an arrow carries the direction. */\nexport const formatPoints = (value: number, decimals = 1) =>\n  `${points(decimals).format(Math.abs(value) * 100)} pts`;\nexport const formatDay = (iso: string) => day.format(new Date(iso));\nexport const formatRange = (from: string, to: string) =>\n  dayAndYear.formatRange(new Date(from), new Date(to));\n/** Seconds as m:ss. */\nexport const formatDuration = (seconds: number) =>\n  `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;\n"
    },
    {
      "path": "src/blocks/analytics/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/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 { useState } from 'react';\n\nimport { type Metric, type Period, PERIODS, report } from './data';\nimport { formatCount, formatPercent, formatPoints, formatRange } from './format';\nimport { KpiCard } from './kpi-card';\nimport { PageHeader } from './page-header';\nimport { AppSidebar } from './sidebar';\nimport { TopPagesTable } from './top-pages-table';\nimport { TrafficSources } from './traffic-sources';\nimport { TrendChart } from './trend-chart';\n\nconst formatValue = (metric: Metric) =>\n  metric.kind === 'rate' ? formatPercent(metric.value, metric.decimals) : formatCount(metric.value);\n\n/** A metric as a key figure: the value, its change and what the change is measured against. */\nconst toKpi = (metric: Metric) => {\n  const delta = metric.value - metric.previous;\n  const direction = delta >= 0 ? 'up' : 'down';\n  return {\n    label: metric.label,\n    value: formatValue(metric),\n    change:\n      metric.kind === 'rate'\n        ? formatPoints(delta, metric.decimals)\n        : formatPercent(Math.abs(delta / metric.previous)),\n    direction,\n    good: direction === metric.better,\n    comparison: `from ${formatValue({ ...metric, value: metric.previous })}`,\n  } as const;\n};\n\n/**\n * Product analytics, Flat direction: the sidebar and the page on one white surface, the page's\n * regions split by lines. The period switch in the header recounts every figure.\n */\nexport default function Analytics() {\n  const [period, setPeriod] = useState<Period>('30d');\n  const { days } = PERIODS.find((entry) => entry.value === period)!;\n  const { current, previous, metrics, pages, sources } = report(period);\n  const first = current[0].date;\n  const last = current[current.length - 1].date;\n\n  return (\n    <AppShell className=\"ws-block-utility\" direction=\"flat\">\n      <AppSidebar />\n      <AppShell.Main className=\"flex flex-col\">\n        <PageHeader period={period} onPeriodChange={setPeriod} range={formatRange(first, last)} />\n\n        <section aria-label=\"Key figures\" className=\"border-ws-static-subtle px-ws-14 border-b\">\n          <div className=\"mx-auto grid w-full max-w-[80rem] grid-cols-4\">\n            {metrics.map((metric, index) => (\n              <KpiCard\n                key={metric.label}\n                {...toKpi(metric)}\n                className={cn(\n                  'py-ws-14 pr-ws-14',\n                  index > 0 && 'border-ws-static-subtle pl-ws-14 border-l',\n                )}\n              />\n            ))}\n          </div>\n        </section>\n\n        <div className=\"border-ws-static-subtle px-ws-14 py-ws-14 border-b\">\n          <TrendChart\n            title=\"Visitors\"\n            dates={current.map((day) => day.date)}\n            current={current.map((day) => day.visitors)}\n            previous={previous.map((day) => day.visitors)}\n            currentLabel={`Last ${days} days`}\n            previousLabel={`Previous ${days} days`}\n            className=\"mx-auto w-full max-w-[80rem]\"\n          />\n        </div>\n\n        {/* The last band takes the rest of the window: the line between its columns runs to the\n            bottom edge instead of stopping in the air. */}\n        <div className=\"px-ws-14 flex-1\">\n          <div className=\"mx-auto grid h-full w-full max-w-[80rem] grid-cols-4\">\n            <TopPagesTable\n              pages={pages}\n              className=\"border-ws-static-subtle py-ws-14 pr-ws-14 col-span-3 border-r\"\n            />\n            <TrafficSources sources={sources} className=\"py-ws-14 pl-ws-14\" />\n          </div>\n        </div>\n      </AppShell.Main>\n    </AppShell>\n  );\n}\n"
    },
    {
      "path": "src/blocks/analytics/kpi-card.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/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: `41,968`, `2.67%`. */\n  value: string;\n  /** The change against the previous period, formatted and unsigned: `11.0%`, `0.06 pts`. */\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 37,823`. */\n  comparison: string;\n  className?: string;\n};\n\n/**\n * A key figure: what it measures, the number, and how it moved against the previous period. The\n * colour of the change follows its meaning, not its direction: bounce rate 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        <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        <span className=\"typography-caption-md text-ws-static-subtle tabular-nums\">\n          {comparison}\n        </span>\n      </div>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/analytics/page-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/page-header.tsx",
      "content": "'use client';\n\nimport { RiDownload2Line } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { SegmentedControl } from '@/components/ui/wideset/segmented-control/SegmentedControl';\n\nimport { type Period, PERIODS } from './data';\n\ntype PageHeaderProps = {\n  period: Period;\n  onPeriodChange: (period: Period) => void;\n  /** The dates the period covers, formatted. */\n  range: string;\n};\n\n/** The page's title bar: what the page is, the period it shows and its one action. */\nexport function PageHeader({ period, onPeriodChange, range }: PageHeaderProps) {\n  return (\n    <header className=\"border-ws-static-subtle px-ws-14 shrink-0 border-b\">\n      <div className=\"h-ws-20 gap-ws-9 mx-auto flex w-full max-w-[80rem] items-center justify-between\">\n        <h1 className=\"typography-title-sm text-ws-static-strong\">Analytics</h1>\n        <div className=\"gap-ws-9 flex items-center\">\n          <p className=\"typography-body-md text-ws-static-subtle\">{range}</p>\n          <SegmentedControl\n            size=\"sm\"\n            value={period}\n            onValueChange={(value) => onPeriodChange(value as Period)}\n            aria-label=\"Period\"\n          >\n            {PERIODS.map((option) => (\n              <SegmentedControl.Item\n                key={option.value}\n                value={option.value}\n                aria-label={option.label}\n              >\n                {option.value}\n              </SegmentedControl.Item>\n            ))}\n          </SegmentedControl>\n          <Button size=\"sm\" variant=\"secondary\" preset=\"border\">\n            <Button.Icon icon={RiDownload2Line} />\n            Export\n          </Button>\n        </div>\n      </div>\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/analytics/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/sidebar.tsx",
      "content": "'use client';\n\n// TODO(custom): workspace switcher and account menu are composed by hand (copied from kanban).\nimport { RiArrowDownSLine } from '@remixicon/react';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\nimport { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';\nimport { useState } from 'react';\n\nimport { BrandMark } from './brand-mark';\nimport { ACCOUNT, DASHBOARDS, NAVIGATION, WORKSPACE } from './data';\n\n/** The workspace sidebar: product, workspace switcher, pages, saved dashboards and the account. */\nexport function AppSidebar() {\n  const [active, setActive] = useState('analytics');\n\n  const links = (\n    <nav aria-label=\"Workspace\" className=\"gap-ws-11 flex flex-col\">\n      <div className=\"flex flex-col\">\n        {NAVIGATION.map((item) => (\n          <Sidebar.Item\n            key={item.id}\n            href={`#${item.id}`}\n            icon={item.icon}\n            label={item.label}\n            suffix={item.count}\n            active={active === item.id}\n            onClick={() => setActive(item.id)}\n          />\n        ))}\n      </div>\n      <div role=\"group\" aria-labelledby=\"sidebar-dashboards\" className=\"gap-ws-2 flex flex-col\">\n        <Sidebar.SectionHeader id=\"sidebar-dashboards\">Dashboards</Sidebar.SectionHeader>\n        {DASHBOARDS.map((item) => (\n          <Sidebar.Item\n            key={item.id}\n            href={`#${item.id}`}\n            icon={item.icon}\n            label={item.label}\n            active={active === item.id}\n            onClick={() => setActive(item.id)}\n          />\n        ))}\n      </div>\n    </nav>\n  );\n\n  return (\n    <Sidebar>\n      <Sidebar.Header>\n        <Sidebar.Expanded>\n          <div className=\"gap-ws-7 flex flex-col\">\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                Orbit\n              </span>\n              <Sidebar.Trigger />\n            </div>\n            {/* No workspace switcher in Wideset yet: a bordered button, as Figma draws it. */}\n            <button\n              type=\"button\"\n              className=\"border-ws-dynamic-secondary-default bg-ws-static-highlight-base shadow-ws-forms-base rounded-ws-control-lg h-ws-19 px-ws-7 hover:border-ws-dynamic-secondary-hover focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default flex w-full items-center border text-left\"\n            >\n              <span className=\"flex min-w-0 flex-1 flex-col\">\n                <span className=\"typography-label-strong-sm text-ws-static-strong truncate\">\n                  {WORKSPACE.name}\n                </span>\n                <span className=\"typography-label-sm text-ws-static-subtle truncate\">\n                  {WORKSPACE.plan} · {WORKSPACE.seats} seats\n                </span>\n              </span>\n              <span className=\"size-ws-11 flex shrink-0 items-center justify-center\">\n                <RiArrowDownSLine aria-hidden className=\"size-ws-9 text-ws-static-strong\" />\n              </span>\n            </button>\n          </div>\n        </Sidebar.Expanded>\n        <Sidebar.Collapsed>\n          <div className=\"py-ws-3 flex items-center\">\n            <Sidebar.Trigger />\n          </div>\n        </Sidebar.Collapsed>\n      </Sidebar.Header>\n\n      <Sidebar.Section scrollable>{links}</Sidebar.Section>\n\n      <Sidebar.Footer>\n        <Sidebar.Expanded>\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.email}\n              </span>\n            </span>\n            <span className=\"size-ws-11 flex shrink-0 items-center justify-center\">\n              <RiArrowDownSLine aria-hidden className=\"size-ws-9 text-ws-static-strong\" />\n            </span>\n          </button>\n        </Sidebar.Expanded>\n        <Sidebar.Collapsed>\n          <Avatar initials={ACCOUNT.initials} status=\"online\" title={ACCOUNT.name} />\n        </Sidebar.Collapsed>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    },
    {
      "path": "src/blocks/analytics/top-pages-table.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/top-pages-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 { report } from './data';\nimport { formatCount, formatDuration, formatPercent } from './format';\n\ntype Page = ReturnType<typeof report>['pages'][number];\ntype Key = keyof Page;\n\nconst COLUMNS: {\n  key: Key;\n  label: string;\n  format: (page: Page) => string;\n  numeric?: boolean;\n  /** The page's name and the column the table is about: what the eye looks for. */\n  strong?: boolean;\n  className?: string;\n}[] = [\n  { key: 'path', label: 'Page', format: (page) => page.path, strong: true, className: 'w-[30%]' },\n  {\n    key: 'visitors',\n    label: 'Visitors',\n    format: (page) => formatCount(page.visitors),\n    numeric: true,\n    strong: true,\n  },\n  { key: 'views', label: 'Views', format: (page) => formatCount(page.views), numeric: true },\n  {\n    key: 'bounceRate',\n    label: 'Bounce rate',\n    format: (page) => formatPercent(page.bounceRate),\n    numeric: true,\n  },\n  {\n    key: 'seconds',\n    label: 'Avg. time',\n    format: (page) => formatDuration(page.seconds),\n    numeric: true,\n  },\n];\n\n// The first and last columns sit on the section's edges, in line with its title.\nconst flush = (index: number) => index === 0 || index === COLUMNS.length - 1;\n\n/** The most visited pages of the period; every column sorts, most visitors first. */\nexport function TopPagesTable({ pages, className }: { pages: Page[]; className?: string }) {\n  const titleId = useId();\n  const [sort, setSort] = useState<{ key: Key; direction: SortDirection }>({\n    key: 'visitors',\n    direction: 'desc',\n  });\n\n  const rows = sort.direction\n    ? [...pages].sort((a, b) => {\n        const order = a[sort.key] < b[sort.key] ? -1 : a[sort.key] > b[sort.key] ? 1 : 0;\n        return sort.direction === 'asc' ? order : -order;\n      })\n    : pages;\n\n  // A column sorts in its natural order first: numbers largest first, text from A.\n  const sortBy = (key: Key, numeric?: boolean) =>\n    setSort((current) => ({\n      key,\n      direction:\n        current.key === key\n          ? current.direction === 'desc'\n            ? 'asc'\n            : 'desc'\n          : numeric\n            ? 'desc'\n            : 'asc',\n    }));\n\n  return (\n    <section aria-labelledby={titleId} className={cn('gap-ws-9 flex flex-col', className)}>\n      <h2 id={titleId} className=\"typography-label-strong-md text-ws-static-strong\">\n        Top pages\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={column.numeric ? '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, column.numeric)}\n              >\n                {column.label}\n              </Table.Header>\n            ))}\n          </Table.Row>\n        </Table.Head>\n        <Table.Body>\n          {rows.map((page) => (\n            <Table.Row key={page.path}>\n              {COLUMNS.map((column, index) => (\n                <Table.Cell\n                  key={column.key}\n                  align={column.numeric ? 'right' : 'left'}\n                  flushMargin={flush(index)}\n                  truncate={!column.numeric}\n                >\n                  <span\n                    className={cn(\n                      column.numeric && 'tabular-nums',\n                      column.strong && 'text-ws-static-strong',\n                    )}\n                  >\n                    {column.format(page)}\n                  </span>\n                </Table.Cell>\n              ))}\n            </Table.Row>\n          ))}\n        </Table.Body>\n      </Table>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/analytics/traffic-sources.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/traffic-sources.tsx",
      "content": "'use client';\n\n// TODO(custom): bar list (bar behind a label, value on the right); no BarList in Wideset.\nimport { cn } from '@/lib/wideset/utils';\nimport { useId } from 'react';\n\nimport { formatCount } from './format';\n\ntype Source = { name: string; visitors: number };\n\n/**\n * Where the period's visitors came from, as a bar list: each bar is the source's visitors against\n * the largest source, drawn behind its name.\n */\nexport function TrafficSources({ sources, className }: { sources: Source[]; className?: string }) {\n  const titleId = useId();\n  const max = Math.max(...sources.map((source) => source.visitors));\n\n  return (\n    <section aria-labelledby={titleId} className={cn('gap-ws-9 flex flex-col', className)}>\n      <h2 id={titleId} className=\"typography-label-strong-md text-ws-static-strong\">\n        Traffic sources\n      </h2>\n      <ul className=\"flex flex-col\">\n        {sources.map((source) => (\n          <li key={source.name} 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={`${(source.visitors / 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                {source.name}\n              </span>\n            </div>\n            <span className=\"typography-number-sm text-ws-static-base tabular-nums\">\n              {formatCount(source.visitors)}\n            </span>\n          </li>\n        ))}\n      </ul>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/analytics/trend-chart.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/analytics/trend-chart.tsx",
      "content": "'use client';\n\n// TODO(custom): hand-built SVG line chart; no chart component and no data-viz colour tokens (uses non-semantic blue).\nimport { cn } from '@/lib/wideset/utils';\nimport { useId } from 'react';\n\nimport { formatCompact, formatDay } 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 period in view takes the blue highlight, the\n// period 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 three gridlines. */\nconst niceStep = (max: number) => {\n  const raw = max / 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\n/** Every `step`-th day counted back from the last, so the newest day always has its label. */\nconst labelled = (count: number) => {\n  const step = count <= 7 ? 1 : count <= 30 ? 7 : 14;\n  return Array.from({ length: count }, (_, index) => index).filter(\n    (index) => (count - 1 - index) % step === 0,\n  );\n};\n\ntype TrendChartProps = {\n  title: string;\n  /** Calendar days (`2026-12-14`), one per value of `current`. */\n  dates: string[];\n  current: number[];\n  /** The previous period, day by day, drawn under the current one. */\n  previous: number[];\n  currentLabel: string;\n  previousLabel: string;\n  className?: string;\n};\n\n/** A daily series for the period in view, drawn over the same days of the period before it. */\nexport function TrendChart({\n  title,\n  dates,\n  current,\n  previous,\n  currentLabel,\n  previousLabel,\n  className,\n}: TrendChartProps) {\n  const id = useId().replace(/[^\\w-]/g, '');\n  const step = niceStep(Math.max(...current, ...previous));\n  const max = Math.ceil(Math.max(...current, ...previous) / step) * step;\n  const ticks = Array.from({ length: max / step + 1 }, (_, index) => max - index * step);\n\n  const x = (index: number) => (index / (current.length - 1)) * WIDTH;\n  const y = (value: number) => HEIGHT - (value / max) * HEIGHT;\n  const line = (values: number[]) =>\n    values.map((value, index) => `${index ? 'L' : 'M'}${x(index)} ${y(value)}`).join('');\n  const last = current.length - 1;\n  // The drawing is hidden from screen readers; this is its text: the totals, the peak, every day.\n  const sum = (values: number[]) => values.reduce((total, value) => total + value, 0);\n  const peak = current.indexOf(Math.max(...current));\n  const number = (value: number) => value.toLocaleString('en-US');\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-label-strong-md text-ws-static-strong\">\n          {title}\n        </h2>\n        <ul className=\"gap-ws-11 typography-label-sm text-ws-static-base flex items-center\">\n          <li className=\"gap-ws-5 flex items-center\">\n            <Swatch className={CURRENT} />\n            {currentLabel}\n          </li>\n          <li className=\"gap-ws-5 flex items-center\">\n            <Swatch className={PREVIOUS} dashed />\n            {previousLabel}\n          </li>\n        </ul>\n      </div>\n\n      <figure aria-label={`${title}, ${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={`${(1 - tick / max) * 100}%`}\n                dominantBaseline=\"middle\"\n                className=\"typography-caption-md fill-ws-static-subtle tabular-nums\"\n              >\n                {formatCompact(tick)}\n              </text>\n            ))}\n          </svg>\n          <div className=\"inset-y-ws-0 left-ws-16 right-ws-0 absolute\">\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              <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              <path\n                d={`${line(current)}L${WIDTH} ${HEIGHT}L0 ${HEIGHT}Z`}\n                fill={`url(#${id}-fill)`}\n              />\n              <g fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className={CURRENT}>\n                <path d={line(current)} strokeWidth={2} vectorEffect=\"non-scaling-stroke\" />\n                {/* Today: a round cap on a zero-length line stays a circle however the plot stretches. */}\n                <path\n                  d={`M${x(last)} ${y(current[last])}h0`}\n                  strokeWidth={8}\n                  vectorEffect=\"non-scaling-stroke\"\n                />\n              </g>\n            </svg>\n          </div>\n        </div>\n        <div className=\"pl-ws-16 mt-ws-5\">\n          <svg aria-hidden className=\"h-ws-9 w-full overflow-visible\">\n            {labelled(dates.length).map((index) => (\n              <text\n                key={dates[index]}\n                x={`${(index / last) * 100}%`}\n                y=\"50%\"\n                dominantBaseline=\"middle\"\n                textAnchor={index === last ? 'end' : 'middle'}\n                className=\"typography-caption-md fill-ws-static-subtle\"\n              >\n                {formatDay(dates[index])}\n              </text>\n            ))}\n          </svg>\n        </div>\n        <figcaption className=\"sr-only\">\n          {currentLabel}: {number(sum(current))} in total, the most on {formatDay(dates[peak])} (\n          {number(current[peak])}). {previousLabel}: {number(sum(previous))} in total.\n        </figcaption>\n        <table className=\"sr-only\">\n          <caption>{title} by day</caption>\n          <thead>\n            <tr>\n              <th scope=\"col\">Day</th>\n              <th scope=\"col\">{currentLabel}</th>\n              <th scope=\"col\">{previousLabel}</th>\n            </tr>\n          </thead>\n          <tbody>\n            {dates.map((date, index) => (\n              <tr key={date}>\n                <th scope=\"row\">{formatDay(date)}</th>\n                <td>{number(current[index])}</td>\n                <td>{previous[index] === undefined ? '' : number(previous[index])}</td>\n              </tr>\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"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
