{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "donut-chart",
  "type": "registry:item",
  "title": "Donut Chart",
  "description": "A donut chart of `segments` (`[{ label, value, tone }]`, `tone` 0–7), with the total in the middle and a legend. Choosing a segment (or its legend entry) selects it; again clears it.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "display"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/donut-chart.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/donut-chart.js",
      "content": "// Generated by zubra from donut-chart.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"donut-chart\";\n\nexport default $define(tag, {\n  props: {\n    \"segments\": { attribute: \"segments\", default: [], required: false },\n    \"value\": { attribute: \"value\", default: \"\", required: false, model: true },\n    \"label\": { attribute: \"label\", default: \"Chart\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [\"default\"],\n  events: [\"valuechange\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (donut-chart) to ([data-zb-slotted=\\\"donut-chart\\\"]) {\\n  :scope { display: grid; grid-template-columns: 11rem 1fr; gap: 1.25rem; align-items: center; }\\n  .chart { position: relative; }\\n  svg { display: block; width: 100%; transform: rotate(-90deg); }\\n  circle { fill: none; stroke-width: 5; cursor: pointer; transition: stroke-width var(--duration-fast, 150ms), opacity var(--duration-fast, 150ms); }\\n  circle.track { stroke: var(--muted, #f3f4f7); cursor: default; }\\n  circle.dim { opacity: 0.3; }\\n  circle.on { stroke-width: 6.5; }\\n  .middle { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }\\n  ul { display: grid; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }\\n  button { display: grid; grid-template-columns: 0.75rem 1fr auto; gap: 0.5rem; align-items: center; width: 100%; padding: 0.3rem 0.45rem; border: 0; border-radius: calc(var(--radius, 0.625rem) * 0.72); background: none; color: inherit; font: inherit; font-size: 0.875rem; text-align: left; cursor: pointer; }\\n  button:hover, button[aria-pressed=true] { background: var(--muted, #f3f4f7); }\\n  .swatch { width: 0.75rem; height: 0.75rem; border-radius: calc(var(--radius, 0.625rem) * 0.32); }\\n  .pct { color: var(--muted-foreground, #667085); font-variant-numeric: tabular-nums; }\\n  .t0 { stroke: var(--chart-1, #4f46e5); background: var(--chart-1, #4f46e5); } .t1 { stroke: var(--chart-2, #0891b2); background: var(--chart-2, #0891b2); }\\n  .t2 { stroke: var(--chart-3, #16a34a); background: var(--chart-3, #16a34a); } .t3 { stroke: var(--chart-4, #ca8a04); background: var(--chart-4, #ca8a04); }\\n  .t4 { stroke: var(--chart-5, #ea580c); background: var(--chart-5, #ea580c); } .t5 { stroke: #db2777; background: #db2777; }\\n  .t6 { stroke: #7c3aed; background: #7c3aed; } .t7 { stroke: #64748b; background: #64748b; }\\n  @media (max-width: 34rem) { :scope { grid-template-columns: 1fr; } .chart { max-width: 12rem; margin: 0 auto; } }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <div class=\\\"chart\\\">\\n    <svg viewBox=\\\"0 0 42 42\\\" role=\\\"img\\\">\\n      <circle class=\\\"track\\\" cx=\\\"21\\\" cy=\\\"21\\\"></circle>\\n      <!--[--><!--]-->\\n    </svg>\\n    <div class=\\\"middle\\\"><!--[--><!--]--></div>\\n  </div>\\n  <ul>\\n    <!--[--><!--]-->\\n  </ul>\\n\",\n  setup($p, $emit) {\n  const R = 15.915494309189533 // circumference 100, so lengths are percentages\n  const total = __zubraComputed(() => ($p.segments.reduce((sum, segment) => sum + segment.value, 0)))\n  const arcs = __zubraComputed(() => ($p.segments.reduce((list, segment) => {\n    const start = list.length ? list[list.length - 1].end : 0\n    const length = total.get() ? (segment.value / total.get()) * 100 : 0\n    return [...list, { ...segment, start, end: start + length, length }]\n  }, []).filter((arc) => arc.length > 0)))\n  const percent = (arc) => `${Math.round(arc.length)}%`\n\n  function select(label) {\n    $p.value = $p.value === label ? \"\" : label\n  }\n    return [\n      { path: [0, 0], attribute: \"aria-label\", value: () => $p.label },\n      { path: [0, 0, 0], attribute: \"r\", value: () => $r(R) },\n      { path: [0, 0, 1], each: () => $r(arcs), key: (arc, $index) => $r(arc).label, block: { template: \"\\n        <circle cx=\\\"21\\\" cy=\\\"21\\\"><title></title></circle>\\n      \", parts: (arc, $index) => [{ path: [0], classes: () => (`t${$r(arc).tone}`) }, { path: [0], toggle: \"dim\", value: () => ($p.value && ($p.value !== $r(arc).label)) }, { path: [0], toggle: \"on\", value: () => ($p.value === $r(arc).label) }, { path: [0], attribute: \"r\", value: () => $r(R) }, { path: [0], attribute: \"stroke-dasharray\", value: () => (`${$r(arc).length} ${100 - $r(arc).length}`) }, { path: [0], attribute: \"stroke-dashoffset\", value: () => -($r(arc).start) }, { path: [0], attribute: \"data-label\", value: () => $r(arc).label }, { path: [0], on: \"click\", handler: () => (() => select($r(arc).label)) }, { path: [0, 0], text: () => $t($r(arc).label) + \": \" + $t((percent($r(arc)))) }] } },\n      { path: [0, 1, 0], slot: \"default\", fallback: { template: \"<strong></strong>\", parts: () => [{ path: [0], text: () => $t($r(total)) }] } },\n      { path: [1, 0], each: () => $r(arcs), key: (arc, $index) => $r(arc).label, block: { template: \"\\n      <li><button type=\\\"button\\\"><span></span><span></span><span class=\\\"pct\\\"></span></button></li>\\n    \", parts: (arc, $index) => [{ path: [0, 0], attribute: \"aria-pressed\", value: () => (($p.value === $r(arc).label) ? \"true\" : \"false\") }, { path: [0, 0], attribute: \"data-label\", value: () => $r(arc).label }, { path: [0, 0], on: \"click\", handler: () => (() => select($r(arc).label)) }, { path: [0, 0, 0], attribute: \"class\", value: () => (`swatch t${$r(arc).tone}`) }, { path: [0, 0, 1], text: () => $t($r(arc).label) }, { path: [0, 0, 2], text: () => $t((percent($r(arc)))) }] } },\n    ];\n  },\n});\n"
    }
  ]
}
