{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "flow-04",
  "description": "The most common routes as steps, ranked by how many people took them, with how often each reaches the goal.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/flow.json",
    "https://www.dashboardblocks.com/r/radix/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/flow/flow-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { FlowPathSteps } from '@/registry/components/dashboardblocks/flow'\nimport { formatNumber, formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface FlowPath {\n  converted: number\n  count: number\n  steps: string[]\n}\n\ninterface Flow4Props extends BlockStateProps {\n  description: string\n  goal: string\n  /** Leave out, or pass none, to show the empty state. */\n  paths?: FlowPath[]\n  title: string\n  /** Everyone, including paths not listed. @default the listed paths' total */\n  total?: number\n  /** @default 'sessions' */\n  unit?: string\n}\n\nconst exampleProps: Flow4Props = {\n  description: 'The most common routes through the site, last 30 days.',\n  goal: 'Signed up',\n  paths: [\n    { converted: 1_020, count: 6_480, steps: ['Home', 'Pricing', 'Sign up'] },\n    { converted: 140, count: 5_910, steps: ['Blog', 'Home'] },\n    { converted: 610, count: 4_270, steps: ['Home', 'Features', 'Pricing'] },\n    { converted: 380, count: 3_150, steps: ['Docs', 'Quickstart', 'API reference'] },\n    { converted: 540, count: 2_640, steps: ['Pricing', 'Compare plans', 'Sign up'] },\n    { converted: 90, count: 1_980, steps: ['Home', 'Customers', 'Case study'] },\n  ],\n  title: 'Top paths',\n  total: 62_300,\n  unit: 'sessions',\n}\n\nconst Flow4 = (props: Flow4Props) => {\n  const {\n    description,\n    goal,\n    paths = [],\n    errorMessage,\n    status,\n    title,\n    unit = 'sessions',\n  } = props\n  const listed = paths.reduce((sum, path) => sum + path.count, 0)\n  const { total = listed } = props\n  const widest = Math.max(1, ...paths.map((path) => path.count))\n  const bestIndex = paths.reduce(\n    (best, path, index) =>\n      path.converted / (path.count || 1) >\n      paths[best].converted / (paths[best].count || 1)\n        ? index\n        : best,\n    0,\n  )\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={getBlockState(status, paths)}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>{description}</p>\n            </header>\n            <div className='flex flex-col border-t'>\n              <div className='text-muted-foreground flex justify-between gap-4 pt-3 text-xs'>\n                <span>Path</span>\n                <span>{goal}</span>\n              </div>\n              <BlockStateRows rows={6} />\n              <ol className='flex flex-col divide-y empty:hidden'>\n                {!status &&\n                  paths.map((path, index) => {\n                    const rate = path.converted / (path.count || 1)\n                    return (\n                      <li\n                        key={path.steps.join('>')}\n                        className='flex flex-col gap-2 py-2.5'\n                      >\n                        <div className='flex items-start justify-between gap-4'>\n                          <FlowPathSteps steps={path.steps.map((label) => ({ label }))} />\n                          <span className='text-sm font-medium tabular-nums'>\n                            {formatPercent(rate)}\n                            {index === bestIndex && (\n                              <span className='sr-only'>, the highest</span>\n                            )}\n                          </span>\n                        </div>\n                        <div className='flex items-center gap-3'>\n                          <span\n                            aria-hidden\n                            className='bg-muted h-1.5 flex-1 overflow-hidden rounded-full'\n                          >\n                            <span\n                              className='bg-chart-2 block h-full rounded-full'\n                              style={{ width: `${(path.count / widest) * 100}%` }}\n                            />\n                          </span>\n                          <span className='text-muted-foreground w-28 shrink-0 text-right text-xs tabular-nums'>\n                            {formatNumber(path.count)} {unit}\n                          </span>\n                        </div>\n                      </li>\n                    )\n                  })}\n              </ol>\n            </div>\n            <BlockReady className='border-t pt-3 text-sm'>\n              <p className='text-muted-foreground border-t pt-3 text-sm'>\n                {`These ${paths.length} paths cover ${formatPercent(listed / (total || 1), { maximumFractionDigits: 0 })} of ${formatNumber(total)} ${unit}. `}\n                {paths[bestIndex] && (\n                  <span className='text-foreground'>\n                    {`${paths[bestIndex].steps.join(' → ')} converts best.`}\n                  </span>\n                )}\n              </p>\n            </BlockReady>\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Flow4, exampleProps as flow4ExampleProps, type Flow4Props, type FlowPath }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/flow/flow-04.tsx"
    }
  ],
  "meta": {
    "shows": "The most common routes as steps, ranked by how many people took them, with how often each reaches the goal.",
    "size": "full",
    "usedWith": [
      "flow-02",
      "funnel-03"
    ],
    "component": "Flow4",
    "props": "{ description: string; goal: string; paths?: { converted: number; count: number; steps: string[] }[]; title: string; total?: number; unit?: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
