{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"radial-flow","type":"registry:ui","title":"Radial Flow","description":"A hub-and-spoke diagram where glowing data pulses stream along curved links between a central node and its connected services.","dependencies":[],"registryDependencies":["utils"],"files":[{"path":"registry/ui/radial-flow.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface RadialFlowNode {\n  label: string;\n  icon?: ReactNode;\n  /** Small second line under the label. */\n  hint?: string;\n}\n\nexport interface RadialFlowProps {\n  /** Center node. */\n  hub: { label: string; icon?: ReactNode };\n  /** Nodes placed around the hub. */\n  nodes: RadialFlowNode[];\n  /** Pulse and highlight color. */\n  accent?: string;\n  /** Seconds for one pulse to travel a link. */\n  duration?: number;\n  /** Pulses in flight per link. */\n  pulses?: number;\n  /** Which way data flows. \"both\" alternates per link. */\n  direction?: \"in\" | \"out\" | \"both\";\n  /** How much the links bow, as a fraction of their length. */\n  curvature?: number;\n  className?: string;\n}\n\nconst css = `\n@keyframes rf-out{0%{stroke-dashoffset:14;opacity:0}12%{opacity:1}88%{opacity:1}100%{stroke-dashoffset:-100;opacity:0}}\n@keyframes rf-in{0%{stroke-dashoffset:-100;opacity:0}12%{opacity:1}88%{opacity:1}100%{stroke-dashoffset:14;opacity:0}}\n@keyframes rf-draw{from{stroke-dashoffset:100}to{stroke-dashoffset:0}}\n@keyframes rf-pop{from{opacity:0;transform:translate(-50%,-50%) scale(.85)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}\n@keyframes rf-ring{0%{transform:scale(1);opacity:.55}100%{transform:scale(1.9);opacity:0}}\n.rf-link{stroke-dasharray:100;animation:rf-draw 1.1s cubic-bezier(.3,.7,.2,1) both}\n.rf-pulse{stroke-dasharray:14 200;stroke-dashoffset:14;animation:var(--rf-anim) var(--rf-d) linear infinite;animation-delay:var(--rf-delay)}\n.rf-node{animation:rf-pop .6s cubic-bezier(.2,.8,.2,1) both}\n.rf-ring{animation:rf-ring 2.8s cubic-bezier(.2,.6,.3,1) infinite}\n.rf-root[data-paused] *{animation-play-state:paused!important}\n@media (prefers-reduced-motion:reduce){.rf-pulse,.rf-ring{display:none}.rf-link,.rf-node{animation:none}}\n`;\n\nexport function RadialFlow({\n  hub,\n  nodes,\n  accent = \"#a3e635\",\n  duration = 2.6,\n  pulses = 1,\n  direction = \"both\",\n  curvature = 0.18,\n  className,\n}: RadialFlowProps) {\n  const root = useRef<HTMLDivElement>(null);\n  const [size, setSize] = useState({ w: 0, h: 0 });\n  const [hot, setHot] = useState<number | null>(null);\n  const n = nodes.length;\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([e]) => setSize({ w: e.contentRect.width, h: e.contentRect.height }));\n    ro.observe(el);\n    const io = new IntersectionObserver(([e]) => {\n      if (e.isIntersecting) delete el.dataset.paused;\n      else el.dataset.paused = \"\";\n    });\n    io.observe(el);\n    return () => {\n      ro.disconnect();\n      io.disconnect();\n    };\n  }, []);\n\n  // Ellipse layout, in fractions of the box; offset by half a step so no node sits dead-center on top.\n  const pts = nodes.map((_, i) => {\n    const a = ((-90 + 180 / n + (360 / n) * i) * Math.PI) / 180;\n    return { fx: 0.5 + Math.cos(a) * 0.39, fy: 0.5 + Math.sin(a) * 0.37 };\n  });\n\n  const { w, h } = size;\n  const cx = w / 2;\n  const cy = h / 2;\n  const links = pts.map(({ fx, fy }) => {\n    const x = fx * w;\n    const y = fy * h;\n    const dx = x - cx;\n    const dy = y - cy;\n    // Control point pushed perpendicular to the spoke, same side for every link, so the diagram swirls.\n    const qx = cx + dx / 2 - dy * curvature;\n    const qy = cy + dy / 2 + dx * curvature;\n    return `M${cx},${cy} Q${qx},${qy} ${x},${y}`;\n  });\n\n  const k = Math.max(1, Math.min(4, Math.round(pulses)));\n\n  return (\n    <div\n      ref={root}\n      className={cn(\"rf-root relative aspect-[16/9] w-full max-w-[44rem] select-none\", className)}\n      style={{ [\"--rf-accent\" as string]: accent } as CSSProperties}\n    >\n      <style href=\"radial-flow\" precedence=\"default\">\n        {css}\n      </style>\n\n      {w > 0 && (\n        <svg aria-hidden width={w} height={h} viewBox={`0 0 ${w} ${h}`} className=\"absolute inset-0 overflow-visible\">\n          {links.map((d, i) => {\n            const dim = hot !== null && hot !== i;\n            const lit = hot === i;\n            const inward = direction === \"in\" || (direction === \"both\" && i % 2 === 1);\n            return (\n              <g key={i} style={{ opacity: dim ? 0.25 : 1, transition: \"opacity .3s\" }}>\n                <path\n                  d={d}\n                  pathLength={100}\n                  fill=\"none\"\n                  strokeWidth={lit ? 1.75 : 1.25}\n                  className=\"rf-link\"\n                  style={{\n                    stroke: lit ? accent : \"color-mix(in oklab, var(--foreground) 22%, transparent)\",\n                    animationDelay: `${i * 70}ms`,\n                    transition: \"stroke .3s\",\n                  }}\n                />\n                {Array.from({ length: k }, (_, j) => {\n                  const style = {\n                    [\"--rf-anim\" as string]: inward ? \"rf-in\" : \"rf-out\",\n                    [\"--rf-d\" as string]: `${duration}s`,\n                    // Deterministic scatter so pulses never fire in lockstep.\n                    [\"--rf-delay\" as string]: `${-(((i * 0.61 + j / k) % 1) * duration).toFixed(2)}s`,\n                  } as CSSProperties;\n                  return (\n                    <g key={j}>\n                      <path d={d} pathLength={100} fill=\"none\" stroke={accent} strokeWidth={7} strokeLinecap=\"round\" strokeOpacity={0.18} className=\"rf-pulse\" style={style} />\n                      <path d={d} pathLength={100} fill=\"none\" stroke={accent} strokeWidth={2.5} strokeLinecap=\"round\" className=\"rf-pulse\" style={style} />\n                    </g>\n                  );\n                })}\n              </g>\n            );\n          })}\n        </svg>\n      )}\n\n      <ul className=\"contents\">\n        {nodes.map((node, i) => (\n          <li\n            key={node.label}\n            tabIndex={0}\n            onPointerEnter={() => setHot(i)}\n            onPointerLeave={() => setHot(null)}\n            onFocus={() => setHot(i)}\n            onBlur={() => setHot(null)}\n            className=\"rf-node absolute flex items-center gap-2.5 whitespace-nowrap rounded-xl border bg-card/90 py-2 pl-2 pr-3.5 shadow-[0_10px_30px_-12px_rgba(0,0,0,.6)] outline-none backdrop-blur transition-[border-color,box-shadow] duration-300 focus-visible:ring-2 focus-visible:ring-ring\"\n            style={{\n              left: `${pts[i].fx * 100}%`,\n              top: `${pts[i].fy * 100}%`,\n              transform: \"translate(-50%,-50%)\",\n              animationDelay: `${250 + i * 70}ms`,\n              borderColor: hot === i ? accent : \"var(--border)\",\n              boxShadow: hot === i ? `0 0 0 4px color-mix(in oklab, ${accent} 14%, transparent), 0 10px 30px -12px rgba(0,0,0,.6)` : undefined,\n            }}\n          >\n            {node.icon && (\n              <span className=\"grid size-8 place-items-center rounded-lg bg-muted text-foreground [&_svg]:size-4\" aria-hidden>\n                {node.icon}\n              </span>\n            )}\n            <span className=\"leading-tight\">\n              <span className=\"block text-[13px] font-medium text-foreground\">{node.label}</span>\n              {node.hint && <span className=\"block text-[11px] text-muted-foreground\">{node.hint}</span>}\n            </span>\n          </li>\n        ))}\n      </ul>\n\n      <div className=\"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2\">\n        {[0, 1].map((r) => (\n          <span\n            key={r}\n            aria-hidden\n            className=\"rf-ring absolute inset-0 rounded-[22px] border\"\n            style={{ borderColor: accent, animationDelay: `${r * 1.4}s` }}\n          />\n        ))}\n        <div\n          className=\"relative flex flex-col items-center gap-1.5 rounded-[22px] border bg-card px-5 py-4 text-center\"\n          style={{\n            borderColor: `color-mix(in oklab, ${accent} 45%, var(--border))`,\n            boxShadow: `0 0 50px -10px color-mix(in oklab, ${accent} 55%, transparent), inset 0 1px 0 rgba(255,255,255,.06)`,\n          }}\n        >\n          {hub.icon && (\n            <span\n              className=\"grid size-11 place-items-center rounded-xl text-black [&_svg]:size-5\"\n              style={{ background: `linear-gradient(135deg, ${accent}, color-mix(in oklab, ${accent} 55%, #10b981))` }}\n              aria-hidden\n            >\n              {hub.icon}\n            </span>\n          )}\n          <span className=\"text-sm font-semibold text-foreground\">{hub.label}</span>\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}