{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-gauge",
  "title": "Activity Gauge",
  "description": "Concentric progress rings in SVG, one arc per series.",
  "dependencies": [
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "@pestoui/arc",
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/components/activity-gauge.tsx",
      "content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { circumferenceOf, clampPercent } from \"@/lib/arc\"\nimport { cn } from \"@/lib/utils\"\n\n/* Concentric progress rings, pure SVG. Each arc paints with currentColor so the\n   tone stays on the semantic token utilities — no stroke hex ever lands here.\n\n   Motion: the arc sweeps up to its value rather than being painted at it, on\n   mount and on every change after. The offset is carried in a custom property\n   so the mount value can come from `@starting-style` — no state, no effect, no\n   first-paint flash, and a browser without support simply renders the finished\n   arc rather than breaking.\n\n   Glide, not one of the overshooting springs, and this is exactly why the glide\n   curve is tuned slightly overdamped: an arc that overshoots its value has, for\n   a few frames, told the reader a number that is not true. */\nconst activityGaugeArcVariants = cva(\n  \"transition-[stroke-dashoffset] duration-spring-glide ease-spring-glide [stroke-dashoffset:var(--arc-offset)] starting:[stroke-dashoffset:var(--arc-length)]\",\n  {\n    variants: {\n      tone: {\n        info: \"text-info\",\n        success: \"text-success\",\n        warning: \"text-warning\",\n        destructive: \"text-destructive\",\n        selected: \"text-selected\",\n        neutral: \"text-muted-foreground\",\n      },\n    },\n    defaultVariants: {\n      tone: \"info\",\n    },\n  }\n)\n\nconst activityGaugeDotVariants = cva(\"size-2 shrink-0 rounded-full\", {\n  variants: {\n    tone: {\n      info: \"bg-info\",\n      success: \"bg-success\",\n      warning: \"bg-warning\",\n      destructive: \"bg-destructive\",\n      /* The dot is the legend's only link back to its arc, so it tracks the arc\n         tone rather than the fill — a swatch that does not match the ring it\n         names has stopped being a key. */\n      selected: \"bg-selected\",\n      neutral: \"bg-muted-foreground\",\n    },\n  },\n  defaultVariants: {\n    tone: \"info\",\n  },\n})\n\ntype ActivityGaugeTone = NonNullable<\n  VariantProps<typeof activityGaugeArcVariants>[\"tone\"]\n>\n\ntype ActivityRing = {\n  /** 0–100. Values outside the range are clamped. */\n  value: number\n  tone?: ActivityGaugeTone\n  label?: string\n}\n\ntype ActivityGaugeProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n  rings: ActivityRing[]\n  /** Outer diameter in px. */\n  size?: number\n  /** Stroke width of each ring in px. */\n  thickness?: number\n  /** Space between concentric rings in px. */\n  gap?: number\n  showLegend?: boolean\n  /** Centre slot — usually a total. */\n  children?: React.ReactNode\n}\n\nfunction ActivityGauge({\n  rings,\n  size = 160,\n  thickness = Math.max(6, Math.round(size / 14)),\n  gap = Math.max(2, Math.round(thickness * 0.4)),\n  showLegend = false,\n  className,\n  children,\n  ...props\n}: ActivityGaugeProps) {\n  const center = size / 2\n  const step = thickness + gap\n  /* Centre-line radius of the outermost ring, then step inwards per ring. */\n  const outer = (size - thickness) / 2\n\n  const arcs = rings\n    .map((ring, index) => {\n      const radius = outer - index * step\n      const pct = clampPercent(ring.value)\n      const circumference = circumferenceOf(radius)\n      return { ...ring, radius, pct, circumference }\n    })\n    .filter((arc) => arc.radius > thickness / 2)\n\n  /* Inset the centre slot to the innermost ring's clear opening. */\n  const centreInset = thickness + Math.max(0, arcs.length - 1) * step\n\n  const summary = rings\n    .map(\n      (ring, index) =>\n        `${ring.label ?? `Ring ${index + 1}`}: ${Math.round(clampPercent(ring.value))}%`\n    )\n    .join(\", \")\n\n  return (\n    <div\n      data-slot=\"activity-gauge\"\n      className={cn(\"flex flex-col items-center gap-5\", className)}\n      {...props}\n    >\n      <div\n        data-slot=\"activity-gauge-rings\"\n        className=\"relative shrink-0\"\n        style={{ width: size, height: size }}\n      >\n        <svg\n          width={size}\n          height={size}\n          viewBox={`0 0 ${size} ${size}`}\n          className=\"block\"\n          role={showLegend ? undefined : \"img\"}\n          aria-label={showLegend ? undefined : summary}\n          aria-hidden={showLegend || undefined}\n        >\n          <g\n            transform={`rotate(-90 ${center} ${center})`}\n            fill=\"none\"\n            strokeLinecap=\"round\"\n          >\n            {arcs.map((arc, index) => (\n              <React.Fragment key={index}>\n                <circle\n                  cx={center}\n                  cy={center}\n                  r={arc.radius}\n                  className=\"text-border\"\n                  stroke=\"currentColor\"\n                  strokeWidth={thickness}\n                />\n                {/* Rings set off in a tight cascade, outermost first, so a stack\n                    of them reads as concentric rather than as one thick arc. */}\n                {arc.pct > 0 ? (\n                  <circle\n                    cx={center}\n                    cy={center}\n                    r={arc.radius}\n                    className={cn(activityGaugeArcVariants({ tone: arc.tone }))}\n                    stroke=\"currentColor\"\n                    strokeWidth={thickness}\n                    strokeDasharray={arc.circumference}\n                    style={\n                      {\n                        \"--arc-length\": `${arc.circumference}`,\n                        \"--arc-offset\": `${arc.circumference * (1 - arc.pct / 100)}`,\n                        transitionDelay: `calc(${index} * var(--stagger-tight))`,\n                      } as React.CSSProperties\n                    }\n                  />\n                ) : null}\n              </React.Fragment>\n            ))}\n          </g>\n        </svg>\n\n        {children ? (\n          <div\n            data-slot=\"activity-gauge-center\"\n            className=\"absolute flex flex-col items-center justify-center gap-0.5 text-center\"\n            style={{ inset: centreInset }}\n          >\n            {children}\n          </div>\n        ) : null}\n      </div>\n\n      {showLegend ? (\n        <ul\n          data-slot=\"activity-gauge-legend\"\n          className=\"flex w-full min-w-0 flex-col gap-2\"\n        >\n          {rings.map((ring, index) => (\n            <li\n              key={index}\n              data-slot=\"activity-gauge-legend-item\"\n              className=\"flex items-center gap-2 text-caption leading-none\"\n            >\n              <span\n                aria-hidden=\"true\"\n                className={cn(activityGaugeDotVariants({ tone: ring.tone }))}\n              />\n              <span className=\"min-w-0 truncate text-muted-foreground\">\n                {ring.label ?? `Ring ${index + 1}`}\n              </span>\n              <span className=\"ml-auto font-medium tabular-nums text-foreground\">\n                {Math.round(clampPercent(ring.value))}%\n              </span>\n            </li>\n          ))}\n        </ul>\n      ) : null}\n    </div>\n  )\n}\n\nexport { ActivityGauge, activityGaugeArcVariants, activityGaugeDotVariants }\nexport type { ActivityGaugeProps, ActivityGaugeTone, ActivityRing }\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}