{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-network-map",
  "title": "Agent Network Map",
  "description": "A live map of how agents, tools and data talk to each other: messages moving along each line, plus who each one talks to and how much.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/agent-network-map/agent-network-map.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type NetworkKind = \"agent\" | \"tool\" | \"data\";\n\nexport interface NetworkNode {\n  id: string;\n  label: string;\n  kind: NetworkKind;\n  /** Position as a percent of the map. */\n  x: number;\n  y: number;\n  /** One line about what it does. */\n  role: string;\n}\n\nexport interface NetworkEdge {\n  from: string;\n  to: string;\n  /** Messages a minute. */\n  rate: number;\n}\n\nexport interface AgentNetworkMapProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  subtitle?: string;\n  nodes?: NetworkNode[];\n  edges?: NetworkEdge[];\n  defaultSelected?: string;\n  onSelectNode?: (node: NetworkNode) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst H = 372;\nconst R = 21;\nconst PAD_X = 46;\nconst PAD_TOP = 30;\nconst PAD_BOTTOM = 46;\n\nconst KINDS: Record<NetworkKind, { label: string; color: string }> = {\n  agent: { label: \"Agents\", color: \"#5E6AD2\" },\n  tool: { label: \"Tools\", color: \"#4EA7FC\" },\n  data: { label: \"Data\", color: \"#8A8F98\" },\n};\nconst KIND_ORDER: NetworkKind[] = [\"agent\", \"tool\", \"data\"];\n\nconst PALETTES = {\n  dark: {\n    card: \"#08090A\",\n    node: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    wire: \"rgba(255,255,255,0.1)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    node: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.08)\",\n    wire: \"rgba(8,9,10,0.12)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n  },\n};\n\nconst DEFAULT_NODES: NetworkNode[] = [\n  {\n    id: \"lead\",\n    label: \"Lead\",\n    kind: \"agent\",\n    x: 50,\n    y: 48,\n    role: \"Splits the work and checks what comes back.\",\n  },\n  {\n    id: \"research\",\n    label: \"Research\",\n    kind: \"agent\",\n    x: 20,\n    y: 18,\n    role: \"Finds sources and pulls out the facts.\",\n  },\n  {\n    id: \"writer\",\n    label: \"Writer\",\n    kind: \"agent\",\n    x: 80,\n    y: 18,\n    role: \"Turns the findings into a first draft.\",\n  },\n  {\n    id: \"review\",\n    label: \"Review\",\n    kind: \"agent\",\n    x: 80,\n    y: 80,\n    role: \"Checks drafts against the style guide.\",\n  },\n  {\n    id: \"support\",\n    label: \"Support\",\n    kind: \"agent\",\n    x: 20,\n    y: 80,\n    role: \"Answers customers using the same sources.\",\n  },\n  {\n    id: \"search\",\n    label: \"Search\",\n    kind: \"tool\",\n    x: 0,\n    y: 48,\n    role: \"Searches the web and internal wikis.\",\n  },\n  {\n    id: \"email\",\n    label: \"Email\",\n    kind: \"tool\",\n    x: 50,\n    y: 100,\n    role: \"Sends replies once they're approved.\",\n  },\n  {\n    id: \"docs\",\n    label: \"Docs\",\n    kind: \"data\",\n    x: 50,\n    y: 0,\n    role: \"The shared library everyone reads from.\",\n  },\n  {\n    id: \"crm\",\n    label: \"CRM\",\n    kind: \"data\",\n    x: 100,\n    y: 48,\n    role: \"Customer records and history.\",\n  },\n];\n\nconst DEFAULT_EDGES: NetworkEdge[] = [\n  { from: \"lead\", to: \"research\", rate: 184 },\n  { from: \"lead\", to: \"writer\", rate: 142 },\n  { from: \"writer\", to: \"review\", rate: 96 },\n  { from: \"review\", to: \"lead\", rate: 88 },\n  { from: \"lead\", to: \"support\", rate: 121 },\n  { from: \"research\", to: \"search\", rate: 236 },\n  { from: \"research\", to: \"docs\", rate: 118 },\n  { from: \"writer\", to: \"docs\", rate: 74 },\n  { from: \"support\", to: \"email\", rate: 63 },\n  { from: \"review\", to: \"crm\", rate: 41 },\n  { from: \"support\", to: \"search\", rate: 57 },\n];\n\nconst round = (n: number) => Math.round(n * 10) / 10;\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction useWidth<T extends HTMLElement>(fallback: number) {\n  const ref = React.useRef<T>(null);\n  const [width, setWidth] = React.useState(fallback);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      setWidth(Math.round(entry.contentRect.width));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  return [ref, width] as const;\n}\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle cx={r} cy={r} r={r} style={{ fill: color }} />\n    </svg>\n  );\n}\n\nexport function AgentNetworkMap({\n  theme = \"dark\",\n  title = \"Agent network\",\n  subtitle = \"Who talks to whom, and how much.\",\n  nodes = DEFAULT_NODES,\n  edges = DEFAULT_EDGES,\n  defaultSelected = \"lead\",\n  onSelectNode,\n  className,\n  style,\n  ...rest\n}: AgentNetworkMapProps) {\n  const c = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const [selected, setSelected] = React.useState(defaultSelected);\n  const [hidden, setHidden] = React.useState<NetworkKind[]>([]);\n  const [mapRef, width] = useWidth<HTMLDivElement>(560);\n  const svgRef = React.useRef<SVGSVGElement>(null);\n\n  const byId = new Map(nodes.map((n) => [n.id, n]));\n  const shownNodes = nodes.filter((n) => !hidden.includes(n.kind));\n  const shownEdges = edges.filter((e) => {\n    const a = byId.get(e.from);\n    const b = byId.get(e.to);\n    return a && b && !hidden.includes(a.kind) && !hidden.includes(b.kind);\n  });\n  const linksOf = (id: string) =>\n    edges.filter((e) => e.from === id || e.to === id);\n  const rateOf = (id: string) =>\n    linksOf(id).reduce((sum, e) => sum + e.rate, 0);\n  const current = byId.get(selected) ?? nodes[0];\n\n  const px = (n: NetworkNode) =>\n    round(PAD_X + (n.x / 100) * (width - PAD_X * 2));\n  const py = (n: NetworkNode) =>\n    round(PAD_TOP + (n.y / 100) * (H - PAD_TOP - PAD_BOTTOM));\n\n  const pathOf = (e: NetworkEdge) => {\n    const a = byId.get(e.from);\n    const b = byId.get(e.to);\n    if (!a || !b) return \"\";\n    const [x1, y1, x2, y2] = [px(a), py(a), px(b), py(b)];\n    // A slight bow keeps two lines that share a node from reading as one.\n    const cx = round((x1 + x2) / 2 - (y2 - y1) * 0.08);\n    const cy = round((y1 + y2) / 2 + (x2 - x1) * 0.08);\n    return `M${x1} ${y1} Q${cx} ${cy} ${x2} ${y2}`;\n  };\n\n  // Each packet is a short dash sliding along its line. Web Animations keep it in step with the page.\n  const hiddenKey = hidden.join(\",\");\n  React.useEffect(() => {\n    if (reduce) return;\n    const svg = svgRef.current;\n    if (!svg) return;\n    const running = [...svg.querySelectorAll(\"[data-packet]\")].map((el, i) =>\n      el.animate([{ strokeDashoffset: 1.06 }, { strokeDashoffset: 0 }], {\n        duration: 2000,\n        iterations: Infinity,\n        iterationStart: (i * 0.37) % 1,\n        easing: \"linear\",\n      }),\n    );\n    return () => running.forEach((a) => a.cancel());\n  }, [reduce, hiddenKey]);\n\n  const select = (node: NetworkNode) => {\n    setSelected(node.id);\n    onSelectNode?.(node);\n  };\n\n  const toggleKind = (kind: NetworkKind) => {\n    const next = hidden.includes(kind)\n      ? hidden.filter((k) => k !== kind)\n      : [...hidden, kind];\n    setHidden(next);\n    if (next.includes(current.kind)) {\n      const first = nodes.find((n) => !next.includes(n.kind));\n      if (first) setSelected(first.id);\n    }\n  };\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div className=\"p-5 pb-3 @2xl:p-6 @2xl:pb-3\">\n        <div className=\"flex items-start justify-between gap-4\">\n          <header className=\"min-w-0\">\n            <h3 className=\"m-0 text-[20px] leading-[26px] font-[590] tracking-[-0.012em]\">\n              {title}\n            </h3>\n            <p\n              className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n              style={{ color: c.sub }}\n            >\n              {subtitle}\n            </p>\n          </header>\n          <div className=\"shrink-0 text-right\">\n            <p className=\"m-0 text-[32px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\">\n              {rateOf(current.id).toLocaleString(\"en-US\")}\n            </p>\n            <p\n              className=\"m-0 mt-1.5 text-[13px] leading-[20px]\"\n              style={{ color: c.sub }}\n            >\n              {current.label}, messages a minute\n            </p>\n          </div>\n        </div>\n        <div className=\"mt-3 flex flex-wrap gap-1.5\">\n          {KIND_ORDER.map((kind) => {\n            const off = hidden.includes(kind);\n            return (\n              <button\n                key={kind}\n                type=\"button\"\n                data-kind={kind}\n                aria-pressed={!off}\n                onClick={() => toggleKind(kind)}\n                className={`flex h-7 cursor-pointer items-center gap-2 rounded-full border-0 px-3 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] motion-safe:transition-opacity motion-safe:duration-150 ${RING}`}\n                style={{\n                  background: c.chip,\n                  color: c.text,\n                  opacity: off ? 0.45 : 1,\n                }}\n              >\n                <Dot size={8} color={KINDS[kind].color} />\n                {KINDS[kind].label}\n                <span className=\"tabular-nums\" style={{ color: c.sub }}>\n                  {nodes.filter((n) => n.kind === kind).length}\n                </span>\n              </button>\n            );\n          })}\n        </div>\n      </div>\n\n      <div\n        className=\"grid @2xl:grid-cols-[minmax(0,1fr)_240px]\"\n        style={{ borderColor: c.border }}\n      >\n        <div ref={mapRef} className=\"min-w-0\" style={{ height: H }}>\n          <svg\n            ref={svgRef}\n            role=\"group\"\n            aria-label=\"Network map\"\n            width={width}\n            height={H}\n            className=\"block\"\n          >\n            {shownEdges.map((e) => {\n              const on = e.from === current.id || e.to === current.id;\n              const d = pathOf(e);\n              const color = KINDS[current.kind].color;\n              return (\n                <g key={`${e.from}-${e.to}`}>\n                  <path\n                    d={d}\n                    fill=\"none\"\n                    stroke={on ? color : c.wire}\n                    strokeWidth=\"1.25\"\n                    className=\"motion-safe:transition-[stroke] motion-safe:duration-200\"\n                  />\n                  <path\n                    data-packet=\"\"\n                    d={d}\n                    fill=\"none\"\n                    pathLength={1}\n                    stroke={on ? c.text : c.faint}\n                    strokeWidth=\"2.5\"\n                    strokeLinecap=\"round\"\n                    strokeDasharray=\"0.04 1.02\"\n                    strokeDashoffset=\"1.06\"\n                    opacity={reduce ? 0 : on ? 1 : 0.5}\n                  />\n                </g>\n              );\n            })}\n            {shownNodes.map((n) => {\n              const on = n.id === current.id;\n              const near =\n                on ||\n                edges.some(\n                  (e) =>\n                    (e.from === current.id && e.to === n.id) ||\n                    (e.to === current.id && e.from === n.id),\n                );\n              const color = KINDS[n.kind].color;\n              return (\n                <g\n                  key={n.id}\n                  data-node={n.id}\n                  role=\"button\"\n                  tabIndex={0}\n                  aria-pressed={on}\n                  aria-label={`${n.label}, ${rateOf(n.id)} messages a minute`}\n                  onClick={() => select(n)}\n                  onKeyDown={(e) => {\n                    if (e.key === \"Enter\" || e.key === \" \") {\n                      e.preventDefault();\n                      select(n);\n                    }\n                  }}\n                  className=\"cursor-pointer outline-none [&:focus-visible>circle]:[stroke-width:2] [&:focus-visible>circle]:[stroke:#5E6AD2]\"\n                  style={{ opacity: near ? 1 : 0.5 }}\n                >\n                  <circle\n                    cx={px(n)}\n                    cy={py(n)}\n                    r={R}\n                    fill={c.node}\n                    stroke={on ? color : c.border}\n                    strokeWidth={on ? 1.5 : 1}\n                    className=\"motion-safe:transition-[stroke] motion-safe:duration-200\"\n                  />\n                  <text\n                    x={px(n)}\n                    y={py(n) + 5}\n                    textAnchor=\"middle\"\n                    fontSize=\"14\"\n                    fontWeight=\"590\"\n                    fill={color}\n                  >\n                    {n.label.slice(0, 1)}\n                  </text>\n                  <text\n                    x={px(n)}\n                    y={py(n) + R + 16}\n                    textAnchor=\"middle\"\n                    fontSize=\"12\"\n                    fontWeight=\"510\"\n                    fill={on ? c.text : c.sub}\n                    style={{\n                      paintOrder: \"stroke\",\n                      stroke: c.card,\n                      strokeWidth: 4,\n                    }}\n                  >\n                    {n.label}\n                  </text>\n                </g>\n              );\n            })}\n          </svg>\n        </div>\n\n        {/* Every node's details share one cell, so picking one never changes the card's height. */}\n        <div\n          className=\"grid border-t p-5 @2xl:border-t-0 @2xl:border-l\"\n          style={{ borderColor: c.border }}\n        >\n          {nodes.map((n) => {\n            const on = n.id === current.id;\n            return (\n              <div\n                key={n.id}\n                aria-hidden={!on}\n                className={`min-w-0 [grid-area:1/1] motion-safe:transition-opacity motion-safe:duration-200 ${on ? \"visible opacity-100\" : \"invisible opacity-0\"}`}\n              >\n                <p className=\"m-0 flex items-center gap-2 text-[15px] leading-[22px] font-[590] tracking-[-0.012em]\">\n                  <Dot size={8} color={KINDS[n.kind].color} />\n                  {n.label}\n                </p>\n                <p\n                  className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n                  style={{ color: c.sub, minHeight: 40 }}\n                >\n                  {n.role}\n                </p>\n                <ul className=\"m-0 mt-3 list-none p-0\">\n                  {linksOf(n.id)\n                    .sort((a, b) => b.rate - a.rate)\n                    .map((e) => {\n                      const out = e.from === n.id;\n                      const other = byId.get(out ? e.to : e.from);\n                      return (\n                        <li\n                          key={`${e.from}-${e.to}`}\n                          className=\"flex items-center justify-between gap-3 border-t py-1.5 text-[13px] leading-[20px] tracking-[-0.011em]\"\n                          style={{ borderColor: c.border }}\n                        >\n                          <span className=\"truncate\" style={{ color: c.soft }}>\n                            <span style={{ color: c.faint }}>\n                              {out ? \"To \" : \"From \"}\n                            </span>\n                            {other?.label}\n                          </span>\n                          <span\n                            className=\"shrink-0 tabular-nums\"\n                            style={{ color: c.sub }}\n                          >\n                            {e.rate}\n                          </span>\n                        </li>\n                      );\n                    })}\n                </ul>\n              </div>\n            );\n          })}\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}