{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-build-duration",
  "title": "Build duration",
  "description": "Paired cold and cached build timings with a budget reference.",
  "registryDependencies": [
    "@neumorphism-ui/chart",
    "@neumorphism-ui/select"
  ],
  "files": [
    {
      "path": "src/components/blocks/build-duration-chart.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { CartesianGrid, Line, LineChart, ReferenceLine, XAxis, YAxis } from \"recharts\";\n\nimport { ChartContainer, ChartTooltip, ChartLegend } from \"@/components/ui/chart\";\nimport { Select, SelectItem } from \"@/components/ui/select\";\n\nconst copy = {\n  \"en\": {\n    \"title\": \"Build duration\",\n    \"description\": \"Paired cold and cached build runs in seconds.\",\n    \"meanCold\": \"Mean cold\",\n    \"cached\": \"cached\",\n    \"overBudget\": \"cold runs over budget\",\n    \"empty\": \"No build runs.\",\n    \"series\": \"Visible series\",\n    \"both\": \"Both\",\n    \"coldOnly\": \"Cold only\",\n    \"cachedOnly\": \"Cached only\",\n    \"table\": \"View build data\",\n    \"caption\": \"Build duration data\",\n    \"period\": \"Build\",\n    \"cold\": \"Cold\",\n    \"cachedHead\": \"Cached\",\n    \"saved\": \"Saved\",\n    \"coldBuild\": \"Cold build\",\n    \"cachedBuild\": \"Cached build\",\n    \"budget\": \"Budget\"\n  },\n  \"ko\": {\n    \"title\": \"빌드 시간\",\n    \"description\": \"캐시를 사용하지 않은 빌드와 캐시를 사용한 빌드의 소요 시간(초)입니다.\",\n    \"meanCold\": \"캐시 미사용 평균\",\n    \"cached\": \"캐시 사용 평균\",\n    \"overBudget\": \"캐시 미사용 빌드가 목표 초과\",\n    \"empty\": \"빌드 기록이 없습니다.\",\n    \"series\": \"표시할 계열\",\n    \"both\": \"모두\",\n    \"coldOnly\": \"캐시 미사용\",\n    \"cachedOnly\": \"캐시 사용\",\n    \"table\": \"빌드 데이터 보기\",\n    \"caption\": \"빌드 시간 데이터\",\n    \"period\": \"빌드\",\n    \"cold\": \"캐시 미사용\",\n    \"cachedHead\": \"캐시 사용\",\n    \"saved\": \"단축 시간\",\n    \"coldBuild\": \"캐시 미사용\",\n    \"cachedBuild\": \"캐시 사용\",\n    \"budget\": \"목표\"\n  },\n  \"ja\": {\n    \"title\": \"ビルド時間\",\n    \"description\": \"キャッシュ未使用・使用時のビルド所要時間（秒）です。\",\n    \"meanCold\": \"キャッシュ未使用の平均\",\n    \"cached\": \"使用時の平均\",\n    \"overBudget\": \"未使用ビルドが目標超過\",\n    \"empty\": \"ビルド記録はありません。\",\n    \"series\": \"表示する系列\",\n    \"both\": \"両方\",\n    \"coldOnly\": \"キャッシュ未使用\",\n    \"cachedOnly\": \"キャッシュ使用\",\n    \"table\": \"ビルドデータを表示\",\n    \"caption\": \"ビルド時間データ\",\n    \"period\": \"ビルド\",\n    \"cold\": \"未使用\",\n    \"cachedHead\": \"使用\",\n    \"saved\": \"短縮時間\",\n    \"coldBuild\": \"キャッシュ未使用\",\n    \"cachedBuild\": \"キャッシュ使用\",\n    \"budget\": \"目標\"\n  },\n  \"zh\": {\n    \"title\": \"构建耗时\",\n    \"description\": \"比较未使用缓存和使用缓存的构建耗时，单位为秒。\",\n    \"meanCold\": \"未使用缓存平均\",\n    \"cached\": \"使用缓存平均\",\n    \"overBudget\": \"次无缓存构建超出目标\",\n    \"empty\": \"暂无构建记录。\",\n    \"series\": \"显示系列\",\n    \"both\": \"全部\",\n    \"coldOnly\": \"未使用缓存\",\n    \"cachedOnly\": \"使用缓存\",\n    \"table\": \"查看构建数据\",\n    \"caption\": \"构建耗时数据\",\n    \"period\": \"构建\",\n    \"cold\": \"未使用缓存\",\n    \"cachedHead\": \"使用缓存\",\n    \"saved\": \"节省时间\",\n    \"coldBuild\": \"未使用缓存\",\n    \"cachedBuild\": \"使用缓存\",\n    \"budget\": \"目标\"\n  }\n} as const;\n\nexport type BuildDurationPoint = {\n  label: string;\n  coldSeconds: number;\n  cachedSeconds: number;\n};\n\nexport function BuildDurationChart({\n  data,\n  budgetSeconds = 220,\n  locale = \"en\",\n}: {\n  data: readonly BuildDurationPoint[];\n  budgetSeconds?: number;\n  locale?: keyof typeof copy;\n}) {\n  const t = copy[locale];\n  const number = new Intl.NumberFormat(locale, { maximumFractionDigits: 1 });\n  const [series, setSeries] = React.useState<\"both\" | \"cold\" | \"cached\">(\"both\");\n  const coldMean = data.length ? data.reduce((sum, row) => sum + row.coldSeconds, 0) / data.length : 0;\n  const cachedMean = data.length ? data.reduce((sum, row) => sum + row.cachedSeconds, 0) / data.length : 0;\n  const breaches = data.filter((row) => row.coldSeconds > budgetSeconds).length;\n\n  return (\n    <ChartContainer\n      data-chart=\"build-duration\"\n      title={t.title}\n      description={t.description}\n      summary={data.length ? `${t.meanCold} ${number.format(coldMean)} s · ${t.cached} ${number.format(cachedMean)} s · ${breaches}/${data.length} ${t.overBudget}` : t.empty}\n      actions={\n        <label className=\"grid gap-1.5 text-xs\">\n          {t.series}\n          <Select value={series} onChange={(event) => setSeries(event.target.value as typeof series)}>\n            <SelectItem value=\"both\">{t.both}</SelectItem>\n            <SelectItem value=\"cold\">{t.coldOnly}</SelectItem>\n            <SelectItem value=\"cached\">{t.cachedOnly}</SelectItem>\n          </Select>\n        </label>\n      }\n      tableLabel={t.table}\n      emptyLabel={t.empty}\n      empty={!data.length}\n      table={\n        <table>\n          <caption className=\"sr-only\">{t.caption}</caption>\n          <thead><tr><th>{t.period}</th><th>{t.cold} (s)</th><th>{t.cachedHead} (s)</th><th>{t.saved} (s)</th></tr></thead>\n          <tbody>{data.map((row) => <tr key={row.label}><th scope=\"row\">{row.label}</th><td>{row.coldSeconds}</td><td>{row.cachedSeconds}</td><td>{row.coldSeconds - row.cachedSeconds}</td></tr>)}</tbody>\n        </table>\n      }\n    >\n      <LineChart data={data} accessibilityLayer margin={{ top: 12, right: 12, bottom: 4, left: 0 }}>\n        <CartesianGrid vertical={false} stroke=\"var(--border)\" strokeDasharray=\"3 4\" />\n        <XAxis dataKey=\"label\" tick={{ fill: \"var(--muted-foreground)\" }} tickLine={false} axisLine={false} />\n        <YAxis domain={[0, \"auto\"]} width={52} tickFormatter={(value: number) => `${value}s`} tick={{ fill: \"var(--muted-foreground)\" }} tickLine={false} axisLine={false} />\n        <ChartLegend reference={{ value: `${t.budget} ${number.format(budgetSeconds)} s`, color: \"var(--destructive)\", dashArray: \"4 4\" }} />\n        <ReferenceLine ifOverflow=\"extendDomain\" y={budgetSeconds} stroke=\"var(--destructive)\" strokeDasharray=\"4 4\" />\n        <ChartTooltip formatter={(value) => `${Number(value)} s`} />\n        {series !== \"cached\" && <Line dataKey=\"coldSeconds\" name={t.coldBuild} legendType=\"plainline\" stroke=\"var(--foreground)\" strokeWidth={2.5} dot={{ r: 3 }} isAnimationActive={false} />}\n        {series !== \"cold\" && <Line dataKey=\"cachedSeconds\" name={t.cachedBuild} legendType=\"plainline\" stroke=\"var(--primary)\" strokeWidth={2.5} strokeDasharray=\"7 4\" dot={{ r: 3 }} isAnimationActive={false} />}\n      </LineChart>\n    </ChartContainer>\n  );\n}\n\nconst exampleBuilds: BuildDurationPoint[] = [\n  { label: \"B1\", coldSeconds: 210, cachedSeconds: 108 },\n  { label: \"B2\", coldSeconds: 195, cachedSeconds: 102 },\n  { label: \"B3\", coldSeconds: 238, cachedSeconds: 114 },\n  { label: \"B4\", coldSeconds: 226, cachedSeconds: 109 },\n  { label: \"B5\", coldSeconds: 204, cachedSeconds: 96 },\n  { label: \"B6\", coldSeconds: 188, cachedSeconds: 93 },\n];\n\nexport function BuildDurationExample({ locale = \"en\" }: { locale?: keyof typeof copy }) {\n  return <BuildDurationChart data={exampleBuilds} locale={locale} />;\n}\n",
      "type": "registry:component",
      "target": "@components/blocks/build-duration-chart.tsx"
    }
  ],
  "categories": [
    "chart"
  ],
  "type": "registry:block"
}