{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-install-diagnostics",
  "title": "Installation trace",
  "author": "andongmin94",
  "description": "Sequential install stages with environment controls, duration units, and stage shares.",
  "dependencies": [
    "recharts@^3.10.1"
  ],
  "registryDependencies": [
    "https://neobrutal-ui.andongmin.com/r/chart.json",
    "https://neobrutal-ui.andongmin.com/r/card.json"
  ],
  "files": [
    {
      "path": "src/components/ui/chart-install-diagnostics.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Bar, BarChart, CartesianGrid, XAxis, YAxis } from \"recharts\";\n\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport {\n  ChartContainer,\n  ChartSelect,\n  ChartTooltip,\n  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\";\n\n// Timing keys must not collide with SVG attributes such as transform.\nconst traces = {\n  Local: { resolveMs: 120, downloadMs: 840, transformMs: 210, writeMs: 90 },\n  CI: { resolveMs: 180, downloadMs: 1480, transformMs: 240, writeMs: 110 },\n};\nconst stages = [\"resolveMs\", \"downloadMs\", \"transformMs\", \"writeMs\"] as const;\nconst config = {\n  resolveMs: { label: \"Resolve\", color: \"var(--chart-1)\" },\n  downloadMs: { label: \"Download\", color: \"var(--chart-2)\" },\n  transformMs: { label: \"Transform\", color: \"var(--chart-3)\" },\n  writeMs: { label: \"Write\", color: \"var(--chart-4)\" },\n} satisfies ChartConfig;\n\nexport default function ChartInstallDiagnostics() {\n  const [profile, setProfile] = useState<keyof typeof traces>(\"Local\");\n  const [unit, setUnit] = useState(\"ms\");\n  const trace = traces[profile];\n  const total = stages.reduce((sum, key) => sum + trace[key], 0);\n  const largest = stages.reduce((key, next) => (trace[next] > trace[key] ? next : key));\n  const formatDuration = (milliseconds: number) =>\n    unit === \"ms\" ? `${milliseconds} ms` : `${(milliseconds / 1000).toFixed(2)} s`;\n  const data = [{ profile, ...trace }];\n\n  return (\n    <Card className=\"min-w-0\" data-chart-recipe=\"diagnostics\">\n      <CardHeader>\n        <p className=\"font-mono text-xs uppercase tracking-widest\">\n          Diagnostics / Locate the bottleneck\n        </p>\n        <CardTitle>\n          <h3>Installation trace</h3>\n        </CardTitle>\n        <CardDescription>\n          A sample sequential installation split into four stages. Not live CLI telemetry.\n        </CardDescription>\n      </CardHeader>\n      <CardContent className=\"grid min-w-0 gap-6\">\n        <div className=\"flex flex-wrap gap-4\">\n          <ChartSelect\n            label=\"Install environment\"\n            value={profile}\n            onValueChange={(value) => setProfile(value as keyof typeof traces)}\n            options={Object.keys(traces).map((value) => ({ value, label: value }))}\n          />\n          <ChartSelect\n            label=\"Duration unit\"\n            value={unit}\n            onValueChange={setUnit}\n            options={[\n              { value: \"ms\", label: \"Milliseconds\" },\n              { value: \"s\", label: \"Seconds\" },\n            ]}\n          />\n        </div>\n        <dl className=\"grid gap-4 border-y-2 border-border py-4 sm:grid-cols-3\" aria-live=\"polite\">\n          {[\n            [\"Total duration\", formatDuration(total)],\n            [\"Longest stage\", config[largest].label],\n            [\"Longest-stage share\", `${((trace[largest] / total) * 100).toFixed(1)}%`],\n          ].map(([label, value]) => (\n            <div key={label}>\n              <dt className=\"text-xs\">{label}</dt>\n              <dd className=\"mt-1 text-2xl font-heading tabular-nums\">{value}</dd>\n            </div>\n          ))}\n        </dl>\n        <figure aria-label=\"Sequential installation stage durations\" className=\"min-w-0\">\n          <ChartContainer config={config} className=\"h-48 w-full min-w-0 aspect-auto\">\n            <BarChart\n              accessibilityLayer\n              data={data}\n              layout=\"vertical\"\n              margin={{ top: 12, right: 12, bottom: 8, left: 0 }}\n            >\n              <CartesianGrid horizontal={false} />\n              <XAxis\n                type=\"number\"\n                domain={[0, 2200]}\n                tickLine={false}\n                axisLine={false}\n                tickFormatter={(value) => formatDuration(Number(value))}\n                minTickGap={32}\n              />\n              <YAxis\n                type=\"category\"\n                dataKey=\"profile\"\n                width={40}\n                tickLine={false}\n                axisLine={false}\n              />\n              <ChartTooltip\n                content={\n                  <ChartTooltipContent\n                    formatter={(value, name) =>\n                      `${config[name as keyof typeof config]?.label ?? name}: ${formatDuration(Number(value))}`\n                    }\n                  />\n                }\n              />\n              {stages.map((key) => (\n                <Bar\n                  key={key}\n                  dataKey={key}\n                  stackId=\"trace\"\n                  fill={`var(--color-${key})`}\n                  stroke=\"var(--foreground)\"\n                  strokeWidth={2}\n                  maxBarSize={56}\n                  isAnimationActive={false}\n                />\n              ))}\n            </BarChart>\n          </ChartContainer>\n          <figcaption className=\"mt-3 text-xs leading-5\">\n            Left to right: Resolve, Download, Transform, Write. These sequential stages add up to\n            the total; parallel work cannot be interpreted this way.\n          </figcaption>\n        </figure>\n        <output className=\"border-l-4 border-main pl-3 text-sm leading-6\">\n          {config[largest].label} takes {formatDuration(trace[largest])} of {formatDuration(total)}.\n          Unit changes only affect formatting, not the underlying measurements.\n        </output>\n        <details className=\"min-w-0 border-t-2 border-border pt-4\">\n          <summary className=\"cursor-pointer text-sm font-heading\">View installation data</summary>\n          <table className=\"mt-3 w-full text-left text-xs tabular-nums\">\n            <caption className=\"pb-3 text-left\">\n              {profile} trace. All durations displayed in{\" \"}\n              {unit === \"ms\" ? \"milliseconds\" : \"seconds\"}.\n            </caption>\n            <thead>\n              <tr>\n                {[\"Stage\", \"Duration\", \"Share\"].map((label) => (\n                  <th key={label} scope=\"col\" className=\"border-b-2 border-border py-2 pr-2\">\n                    {label}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {stages.map((key) => (\n                <tr key={key}>\n                  <th scope=\"row\" className=\"py-3 pr-2\">\n                    {config[key].label}\n                  </th>\n                  <td>{formatDuration(trace[key])}</td>\n                  <td>{((trace[key] / total) * 100).toFixed(1)}%</td>\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </details>\n      </CardContent>\n    </Card>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "data-display",
    "data-visualization",
    "recipe"
  ],
  "type": "registry:component"
}