{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "orb-avatar",
  "title": "Orb Avatar",
  "description": "Gradient orb avatar in identity hues, and a stack of orbs.",
  "registryDependencies": [
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/components/orb-avatar.tsx",
      "content": "import { useId } from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport type OrbHue = \"violet\" | \"pink\" | \"orange\" | \"blue\" | \"teal\"\n\n/* cx, cy, rx, ry and rotation in degrees, then opacity: one ellipse of colour on a\n   100-unit disc. Its colour is the matching --orb-<hue>-<n> in styles/orb.css. */\ntype OrbEllipse = readonly [number, number, number, number, number, number]\n\n/* Each disc is fitted to a painted original, so these numbers and the colours in\n   styles/orb.css only mean anything together. `rim` is the rim's opacity at each of\n   RIM_OFFSETS; it starts from nothing at RIM_START. */\nconst DISCS: Record<\n  OrbHue,\n  { ellipses: readonly OrbEllipse[]; rim: readonly number[] }\n> = {\n  violet: {\n    ellipses: [\n      [42.4, 39.8, 75.6, 37.1, 39, 1],\n      [37.9, 81.2, 74, 30.8, 80, 1],\n      [23.6, 23.8, 52.4, 46.5, 176, 1],\n      [87.3, 34.8, 60.4, 25.5, 15, 0.95],\n    ],\n    rim: [0.16, 0.45, 0.85],\n  },\n  pink: {\n    ellipses: [\n      [61.3, 39.9, 71.3, 53.5, 135, 0.9],\n      [44.3, 8.1, 58.7, 32.2, 115, 0.9],\n      [30.8, 71.4, 35.2, 27.3, 140, 0.77],\n      [89.8, 61.1, 34.4, 61.2, 76, 0.89],\n    ],\n    rim: [0.12, 0.4, 0.82],\n  },\n  orange: {\n    ellipses: [\n      [54, 68.3, 76, 57.9, 24, 0.97],\n      [73.1, 26.8, 34.4, 30.2, 137, 1],\n      [25.5, 39.6, 66.3, 48.6, 73, 0.22],\n    ],\n    rim: [0.13, 0.44, 0.84],\n  },\n  blue: {\n    ellipses: [\n      [14.7, 33.9, 160, 50.4, 55, 0.91],\n      [22.9, 49.4, 63.1, 42.6, 4, 0.87],\n      [51.5, 14.3, 38.5, 30.3, 141, 0.85],\n      [108.7, 46.5, 89.7, 58, 158, 1],\n    ],\n    rim: [0.1, 0.41, 0.83],\n  },\n  teal: {\n    ellipses: [\n      [62.3, 61.9, 59.2, 48.6, 36, 1],\n      [95.3, 40.1, 67.6, 31, 11, 0.74],\n      [44.4, 93.3, 58.7, 31.4, 64, 0.62],\n      [30.6, 31.9, 35, 24.5, 39, 0.87],\n    ],\n    rim: [0.14, 0.45, 0.84],\n  },\n}\n\n/* An ellipse's opacity from its centre to its edge, offset then opacity: close to a\n   Gaussian in as few stops as still look like one, since each is markup in every\n   avatar. */\nconst FADE = [\n  [0, 1],\n  [0.25, 0.82],\n  [0.49, 0.41],\n  [0.73, 0.12],\n  [1, 0],\n] as const\n\nconst RIM_START = 0.8\nconst RIM_OFFSETS = [0.87, 0.93, 1] as const\n\n/* A soft disc of blended colour, the identity \"orb\" avatar. Gradients alone, with no\n   canvas, filter or image, so it renders on the server and draws under a strict CSP. */\nexport function OrbAvatar({\n  hue = \"violet\",\n  className,\n}: {\n  hue?: OrbHue\n  className?: string\n}) {\n  /* A gradient is found by an id that the whole document shares, and the shape of\n     useId's value varies across React 19. Reduced to characters that are safe in\n     url(#…), and with the hue kept in it, so two React roots or two Server Component\n     requests, whose ids can repeat, still draw their own colours. The one loss: when\n     the first copy of a repeated id is under display:none, browsers paint no gradient\n     from it, and the later disc shows only its flat base. */\n  const id = `orb-${hue}-${useId().replace(/[^A-Za-z0-9_-]/g, \"\")}`\n  const { ellipses, rim } = DISCS[hue]\n  return (\n    <svg\n      viewBox=\"0 0 100 100\"\n      aria-hidden=\"true\"\n      /* rounded-full is the disc's edge: it needs no id of its own, and the ring\n         OrbStack draws follows the same curve. */\n      className={cn(\"size-6 shrink-0 rounded-full\", className)}\n    >\n      <defs>\n        {ellipses.map((_, i) => (\n          <radialGradient key={i} id={`${id}-${i}`}>\n            {FADE.map(([offset, opacity]) => (\n              <stop\n                key={offset}\n                offset={offset}\n                stopColor={`var(--orb-${hue}-${i + 1})`}\n                stopOpacity={opacity}\n              />\n            ))}\n          </radialGradient>\n        ))}\n        <radialGradient id={`${id}-rim`}>\n          <stop\n            offset={RIM_START}\n            stopColor={`var(--orb-${hue}-rim)`}\n            stopOpacity={0}\n          />\n          {RIM_OFFSETS.map((offset, i) => (\n            <stop\n              key={offset}\n              offset={offset}\n              stopColor={`var(--orb-${hue}-rim)`}\n              stopOpacity={rim[i]}\n            />\n          ))}\n        </radialGradient>\n      </defs>\n      <rect width=\"100\" height=\"100\" fill={`var(--orb-${hue}-base)`} />\n      {ellipses.map(([cx, cy, rx, ry, rotation, opacity], i) => (\n        <ellipse\n          key={i}\n          cx={cx}\n          cy={cy}\n          rx={rx}\n          ry={ry}\n          transform={`rotate(${rotation} ${cx} ${cy})`}\n          fill={`url(#${id}-${i})`}\n          fillOpacity={opacity}\n        />\n      ))}\n      <rect width=\"100\" height=\"100\" fill={`url(#${id}-rim)`} />\n    </svg>\n  )\n}\n\nexport function OrbStack({\n  hues = [\"violet\", \"pink\", \"orange\", \"blue\", \"teal\"],\n  className,\n  orbClassName,\n}: {\n  hues?: OrbHue[]\n  className?: string\n  orbClassName?: string\n}) {\n  return (\n    <div className={cn(\"flex -space-x-1.5\", className)}>\n      {hues.map((hue, i) => (\n        <OrbAvatar\n          key={i}\n          hue={hue}\n          className={cn(\"size-7 rounded-full ring-2 ring-card\", orbClassName)}\n        />\n      ))}\n    </div>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}