{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "autopilot-multiplayer-demo",
  "type": "registry:block",
  "title": "Autopilot: Design Review",
  "description": "Product Demo Cursor example, Design Review: Two teammates on a design canvas, with their steps running at the same time. Maya drags the Features frame into place, and its snap guides show through `data-autopilot-drop`, while Leo drops a comment pin and asks a question. Then Maya replies and Leo likes it. Move your mouse in and both step aside, and the canvas is yours: drag the frame or leave a comment. A take on the product demo (interactive demo) and cursor (custom cursor). Fits hero and features sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "hero",
    "features",
    "product-demo",
    "cursor",
    "interaction",
    "showcase"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/autopilot#autopilot-multiplayer-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/autopilot.json"
  ],
  "files": [
    {
      "path": "components/autopilot-multiplayer-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Autopilot, type AutopilotChapter } from \"@/components/ui/autopilot\";\n\nconst team = {\n  maya: { name: \"Maya\", color: \"#e0457b\" },\n  leo: { name: \"Leo\", color: \"#2f7cf6\" },\n  you: { name: \"You\", color: \"#18181b\" },\n};\ntype Author = keyof typeof team;\n\ntype Pos = { x: number; y: number }; // percent of the canvas\nconst SIZE = { w: 43, h: 38 };\nconst HERO: Pos = { x: 5, y: 9 };\nconst PRICING: Pos = { x: 52, y: 9 };\nconst SLOT: Pos = { x: 5, y: 55 }; // under the hero, on its left edge\nconst ASTRAY: Pos = { x: 55, y: 58 };\nconst PIN: Pos = { x: 33, y: 27 };\n\ntype Message = { author: Author; text: string };\ntype Board = {\n  features: Pos;\n  tool: \"move\" | \"comment\";\n  pin: Pos | null;\n  draft: string;\n  author: Author;\n  messages: Message[];\n  liked: boolean;\n};\n\nconst fresh: Board = { features: ASTRAY, tool: \"move\", pin: null, draft: \"\", author: \"you\", messages: [], liked: false };\nconst asked: Board = {\n  ...fresh,\n  features: SLOT,\n  pin: PIN,\n  messages: [{ author: \"leo\", text: \"Can we try a darker hero image?\" }],\n};\n\nconst near = (a: Pos, b: Pos) => Math.abs(a.x - b.x) < 4 && Math.abs(a.y - b.y) < 5;\n\nexport function AutopilotMultiplayerDemo() {\n  const [board, setBoard] = React.useState(fresh);\n  const [snapping, setSnapping] = React.useState(false);\n  const update = (patch: Partial<Board>) => setBoard((current) => ({ ...current, ...patch }));\n  const canvasRef = React.useRef<HTMLDivElement>(null);\n  const grab = React.useRef<{ x: number; y: number; from: Pos } | null>(null);\n\n  const chapters: AutopilotChapter[] = [\n    {\n      title: \"Arrange\",\n      setup: () => setBoard(fresh),\n      steps: [\n        { cursor: \"maya\", move: \"features\", at: [0.3, 0.2] },\n        {\n          cursor: \"maya\",\n          drag: \"features\",\n          to: \"slot\",\n          drop: () => update({ features: SLOT }),\n        },\n        { cursor: \"maya\", move: \"pricing\", at: [0.4, 0.8] },\n        { cursor: \"leo\", wait: 500 },\n        { cursor: \"leo\", click: \"tool-comment\" },\n        { cursor: \"leo\", click: \"hero\", at: [0.65, 0.48] },\n        { cursor: \"leo\", do: () => update({ author: \"leo\" }) },\n        { cursor: \"leo\", type: \"Can we try a darker hero image?\", into: \"reply\" },\n        { cursor: \"leo\", click: \"post\" },\n      ],\n    },\n    {\n      title: \"Reply\",\n      setup: () => setBoard(asked),\n      steps: [\n        { cursor: \"maya\", do: () => update({ author: \"maya\" }) },\n        { cursor: \"maya\", type: \"On it, trying v4 now\", into: \"reply\" },\n        { cursor: \"maya\", click: \"post\" },\n        { cursor: \"maya\", move: \"pricing\", at: [0.3, 0.75] },\n        { cursor: \"leo\", wait: 2600 },\n        { cursor: \"leo\", click: \"like\" },\n        { cursor: \"leo\", wait: 1200 },\n      ],\n    },\n  ];\n\n  const post = () => {\n    const text = board.draft.trim();\n    if (!text) return;\n    update({ messages: [...board.messages, { author: board.author, text }], draft: \"\", author: \"you\" });\n  };\n\n  const place = (event: React.MouseEvent) => {\n    const canvas = canvasRef.current?.getBoundingClientRect();\n    if (board.tool !== \"comment\" || !canvas) return;\n    update({\n      tool: \"move\",\n      pin: {\n        x: ((event.clientX - canvas.left) / canvas.width) * 100,\n        y: ((event.clientY - canvas.top) / canvas.height) * 100,\n      },\n      messages: [],\n      liked: false,\n    });\n  };\n\n  // The visitor drags the frame themselves; it snaps when it's close to the hero's edge.\n  const dragHandlers = {\n    onPointerDown: (event: React.PointerEvent<HTMLDivElement>) => {\n      if (board.tool !== \"move\" || !event.nativeEvent.isTrusted) return;\n      event.currentTarget.setPointerCapture(event.pointerId);\n      grab.current = { x: event.clientX, y: event.clientY, from: board.features };\n    },\n    onPointerMove: (event: React.PointerEvent<HTMLDivElement>) => {\n      const start = grab.current;\n      const canvas = canvasRef.current?.getBoundingClientRect();\n      if (!start || !canvas) return;\n      const next = {\n        x: start.from.x + ((event.clientX - start.x) / canvas.width) * 100,\n        y: start.from.y + ((event.clientY - start.y) / canvas.height) * 100,\n      };\n      setSnapping(near(next, SLOT));\n      update({ features: next });\n    },\n    onPointerUp: () => {\n      if (!grab.current) return;\n      grab.current = null;\n      setSnapping(false);\n      setBoard((current) => (near(current.features, SLOT) ? { ...current, features: SLOT } : current));\n    },\n  };\n\n  const threadLeft = board.pin && board.pin.x > 55;\n\n  return (\n    <Autopilot\n      cursors={[\n        { id: \"maya\", label: team.maya.name, color: team.maya.color, home: [0.86, 0.5] },\n        { id: \"leo\", label: team.leo.name, color: team.leo.color, home: [0.42, 0.9] },\n      ]}\n      chapters={chapters}\n      park=\"bottom-left\"\n      className=\"w-full max-w-3xl\"\n      stageClassName=\"overflow-hidden rounded-xl border border-zinc-200 bg-white text-zinc-900 shadow-sm dark:border-white/10 dark:bg-zinc-900 dark:text-zinc-100\"\n    >\n      <div className=\"flex h-[28rem] flex-col\">\n        {/* Toolbar */}\n        <div className=\"flex h-11 shrink-0 items-center gap-2 border-b border-zinc-200 px-3 dark:border-white/10\">\n          <span className=\"grid size-6 place-items-center rounded-md bg-zinc-900 text-white dark:bg-white dark:text-zinc-900\">\n            <svg viewBox=\"0 0 12 12\" className=\"size-3\" fill=\"currentColor\" aria-hidden>\n              <path d=\"M6 1 11 6 6 11 1 6Z\" />\n            </svg>\n          </span>\n          <p className=\"truncate text-sm font-medium\">\n            Landing v3 <span className=\"hidden text-zinc-400 sm:inline\">/ Review</span>\n          </p>\n          <div className=\"mx-auto flex items-center gap-0.5 rounded-lg bg-zinc-100 p-0.5 dark:bg-white/5\">\n            <Tool label=\"Move\" active={board.tool === \"move\"} onClick={() => update({ tool: \"move\" })}>\n              <path d=\"M3 2.5 12 7 7.6 8 6 12.5Z\" />\n            </Tool>\n            <Tool\n              label=\"Comment\"\n              name=\"tool-comment\"\n              active={board.tool === \"comment\"}\n              onClick={() => update({ tool: board.tool === \"comment\" ? \"move\" : \"comment\" })}\n            >\n              <path d=\"M2.5 3.5a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H6l-2.5 2v-2h0a1 1 0 0 1-1-1Z\" />\n            </Tool>\n          </div>\n          <div className=\"flex -space-x-1.5\">\n            {([\"maya\", \"leo\", \"you\"] as const).map((id) => (\n              <span\n                key={id}\n                title={team[id].name}\n                style={{ backgroundColor: team[id].color }}\n                className=\"grid size-6 place-items-center rounded-full text-[10px] font-semibold text-white ring-2 ring-white dark:ring-zinc-900\"\n              >\n                {team[id].name[0]}\n              </span>\n            ))}\n          </div>\n          <span className=\"hidden h-7 items-center rounded-md bg-[#2f7cf6] px-2.5 text-xs font-medium text-white sm:inline-flex\">\n            Share\n          </span>\n        </div>\n\n        <div className=\"flex min-h-0 flex-1\">\n          {/* Layers */}\n          <div className=\"hidden w-36 shrink-0 border-r border-zinc-200 p-3 text-xs sm:block dark:border-white/10\">\n            <p className=\"mb-2 text-[10px] font-medium tracking-wide text-zinc-400 uppercase\">Layers</p>\n            {[\"Hero\", \"Pricing\", \"Features\"].map((layer) => (\n              <p key={layer} className=\"flex items-center gap-2 rounded px-1.5 py-1 text-zinc-600 dark:text-zinc-300\">\n                <span className=\"size-2.5 rounded-[3px] border border-current opacity-60\" />\n                {layer}\n              </p>\n            ))}\n          </div>\n\n          {/* Canvas */}\n          <div\n            ref={canvasRef}\n            onClick={place}\n            className={`relative min-w-0 flex-1 overflow-hidden bg-zinc-100 dark:bg-zinc-950 ${board.tool === \"comment\" ? \"cursor-crosshair\" : \"\"}`}\n            style={{\n              backgroundImage: \"radial-gradient(circle, rgb(120 120 130 / 0.22) 1px, transparent 1px)\",\n              backgroundSize: \"16px 16px\",\n            }}\n          >\n            <Frame name=\"hero\" label=\"Hero\" at={HERO}>\n              <div className=\"flex h-full gap-2\">\n                <div className=\"flex flex-1 flex-col justify-center gap-1.5\">\n                  <span className=\"h-2 w-4/5 rounded-sm bg-zinc-800 dark:bg-zinc-200\" />\n                  <span className=\"h-2 w-3/5 rounded-sm bg-zinc-800 dark:bg-zinc-200\" />\n                  <span className=\"mt-1 h-1 w-4/5 rounded-sm bg-zinc-300 dark:bg-zinc-700\" />\n                  <span className=\"h-1 w-2/3 rounded-sm bg-zinc-300 dark:bg-zinc-700\" />\n                  <span className=\"mt-1.5 h-3 w-10 rounded-full bg-[#2f7cf6]\" />\n                </div>\n                <div className=\"w-2/5 rounded-md bg-gradient-to-br from-sky-200 via-indigo-200 to-rose-200 dark:from-sky-900 dark:via-indigo-900 dark:to-rose-900\" />\n              </div>\n            </Frame>\n            <Frame name=\"pricing\" label=\"Pricing\" at={PRICING}>\n              <div className=\"grid h-full grid-cols-3 gap-1.5\">\n                {[0, 1, 2].map((i) => (\n                  <div\n                    key={i}\n                    className={`flex flex-col gap-1 rounded-md border p-1.5 ${i === 1 ? \"border-[#2f7cf6]/60 bg-[#2f7cf6]/5\" : \"border-zinc-200 dark:border-white/10\"}`}\n                  >\n                    <span className=\"h-1 w-2/3 rounded-sm bg-zinc-300 dark:bg-zinc-600\" />\n                    <span className=\"h-2 w-1/2 rounded-sm bg-zinc-800 dark:bg-zinc-200\" />\n                    <span className=\"mt-auto h-2 rounded-sm bg-zinc-200 dark:bg-zinc-700\" />\n                  </div>\n                ))}\n              </div>\n            </Frame>\n\n            {/* Where the features frame belongs: guides show as it nears */}\n            <div\n              data-autopilot=\"slot\"\n              data-snapping={snapping || undefined}\n              className=\"group/slot absolute\"\n              style={{ left: `${SLOT.x}%`, top: `${SLOT.y}%`, width: `${SIZE.w}%`, height: `${SIZE.h}%` }}\n            >\n              <div className=\"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-150 group-data-[autopilot-drop]/slot:opacity-100 group-data-[snapping]/slot:opacity-100\">\n                <span className=\"absolute -top-[1.2rem] bottom-0 -left-px w-px bg-[#e0457b]\" />\n                <span className=\"absolute -top-[1.2rem] left-1/2 h-[1.2rem] w-px -translate-x-1/2 bg-[#e0457b]\" />\n                <span className=\"absolute -top-[1.05rem] left-1/2 ml-1 rounded-sm bg-[#e0457b] px-1 text-[9px] leading-3.5 font-medium text-white tabular-nums\">\n                  24\n                </span>\n              </div>\n            </div>\n\n            <Frame\n              name=\"features\"\n              label=\"Features\"\n              at={board.features}\n              className=\"touch-none data-[autopilot-drag]:outline-2 data-[autopilot-drag]:outline-[#e0457b]\"\n              {...dragHandlers}\n            >\n              <div className=\"grid h-full grid-cols-2 gap-x-2 gap-y-1.5\">\n                {[0, 1, 2, 3].map((i) => (\n                  <div key={i} className=\"flex items-start gap-1.5\">\n                    <span className=\"size-3 shrink-0 rounded-[4px] bg-indigo-200 dark:bg-indigo-800\" />\n                    <span className=\"flex flex-1 flex-col gap-1 pt-0.5\">\n                      <span className=\"h-1 w-4/5 rounded-sm bg-zinc-700 dark:bg-zinc-300\" />\n                      <span className=\"h-1 w-3/5 rounded-sm bg-zinc-300 dark:bg-zinc-700\" />\n                    </span>\n                  </div>\n                ))}\n              </div>\n            </Frame>\n\n            {/* Comment */}\n            {board.pin && (\n              <>\n                <span\n                  aria-hidden\n                  className=\"absolute z-10 grid size-6 -translate-y-full place-items-center rounded-full rounded-bl-none text-[10px] font-semibold text-white shadow-md ring-2 ring-white dark:ring-zinc-900\"\n                  style={{\n                    left: `${board.pin.x}%`,\n                    top: `${board.pin.y}%`,\n                    backgroundColor: team[board.messages[0]?.author ?? board.author].color,\n                  }}\n                >\n                  {team[board.messages[0]?.author ?? board.author].name[0]}\n                </span>\n                <div\n                  onClick={(event) => event.stopPropagation()}\n                  className=\"absolute z-20 rounded-xl border border-zinc-200 bg-white p-2.5 text-xs shadow-xl dark:border-white/10 dark:bg-zinc-800\"\n                  style={{\n                    top: `calc(${board.pin.y}% - 1.5rem)`,\n                    ...(threadLeft\n                      ? { right: `calc(${100 - board.pin.x}% + 0.5rem)`, width: `min(13rem, ${board.pin.x}% - 1rem)` }\n                      : { left: `calc(${board.pin.x}% + 2rem)`, width: `min(13rem, ${100 - board.pin.x}% - 2.5rem)` }),\n                  }}\n                >\n                  {board.messages.map((message, i) => (\n                    <div key={i} className=\"mb-2.5 flex gap-2\">\n                      <span\n                        style={{ backgroundColor: team[message.author].color }}\n                        className=\"grid size-5 shrink-0 place-items-center rounded-full text-[9px] font-semibold text-white\"\n                      >\n                        {team[message.author].name[0]}\n                      </span>\n                      <div className=\"min-w-0 flex-1\">\n                        <p className=\"text-[11px]\">\n                          <span className=\"font-semibold\">{team[message.author].name}</span>\n                          <span className=\"ml-1.5 text-zinc-400\">now</span>\n                        </p>\n                        <p className=\"mt-0.5 leading-snug text-pretty text-zinc-700 dark:text-zinc-200\">\n                          {message.text}\n                        </p>\n                        {message.author === \"maya\" && (\n                          <button\n                            type=\"button\"\n                            data-autopilot=\"like\"\n                            onClick={() => update({ liked: !board.liked })}\n                            className={`mt-1.5 inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] transition-colors data-[autopilot-hover]:border-zinc-300 ${\n                              board.liked\n                                ? \"border-[#2f7cf6]/40 bg-[#2f7cf6]/10 text-[#2f7cf6]\"\n                                : \"border-zinc-200 text-zinc-500 dark:border-white/10\"\n                            }`}\n                          >\n                            👍 {board.liked ? 1 : \"\"}\n                          </button>\n                        )}\n                      </div>\n                    </div>\n                  ))}\n                  <form\n                    className=\"flex items-center gap-1.5\"\n                    onSubmit={(event) => {\n                      event.preventDefault();\n                      post();\n                    }}\n                  >\n                    <input\n                      data-autopilot=\"reply\"\n                      value={board.draft}\n                      onChange={(event) => update({ draft: event.target.value })}\n                      placeholder={board.messages.length ? \"Reply\" : \"Add a comment\"}\n                      aria-label=\"Comment\"\n                      className=\"h-7 min-w-0 flex-1 rounded-md border border-zinc-200 bg-transparent px-2 text-base outline-none placeholder:text-zinc-400 focus:border-[#2f7cf6] data-[autopilot-focus]:border-[#2f7cf6] sm:text-xs dark:border-white/10\"\n                    />\n                    <button\n                      type=\"submit\"\n                      data-autopilot=\"post\"\n                      aria-label=\"Post\"\n                      disabled={!board.draft.trim()}\n                      className=\"grid size-7 shrink-0 place-items-center rounded-md bg-[#2f7cf6] text-white transition-[opacity,scale] disabled:opacity-40 data-[autopilot-press]:scale-95\"\n                    >\n                      <svg viewBox=\"0 0 12 12\" className=\"size-3\" fill=\"none\" aria-hidden>\n                        <path d=\"M6 10V2.5M2.5 6 6 2.5 9.5 6\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                      </svg>\n                    </button>\n                  </form>\n                </div>\n              </>\n            )}\n          </div>\n        </div>\n      </div>\n    </Autopilot>\n  );\n}\n\nfunction Frame({\n  name,\n  label,\n  at,\n  className,\n  children,\n  ...props\n}: {\n  name: string;\n  label: string;\n  at: Pos;\n  className?: string;\n  children: React.ReactNode;\n} & React.HTMLAttributes<HTMLDivElement>) {\n  return (\n    <div\n      {...props}\n      data-autopilot={name}\n      className={`absolute rounded-lg border border-zinc-200 bg-white p-2.5 shadow-sm dark:border-white/10 dark:bg-zinc-900 ${className ?? \"\"}`}\n      style={{ left: `${at.x}%`, top: `${at.y}%`, width: `${SIZE.w}%`, height: `${SIZE.h}%` }}\n    >\n      <span className=\"pointer-events-none absolute -top-4 left-0 text-[10px] font-medium text-zinc-500 dark:text-zinc-400\">\n        {label}\n      </span>\n      {children}\n    </div>\n  );\n}\n\nfunction Tool({\n  label,\n  name,\n  active,\n  onClick,\n  children,\n}: {\n  label: string;\n  name?: string;\n  active: boolean;\n  onClick: () => void;\n  children: React.ReactNode;\n}) {\n  return (\n    <button\n      type=\"button\"\n      aria-label={label}\n      aria-pressed={active}\n      data-autopilot={name}\n      onClick={onClick}\n      className={`grid size-7 place-items-center rounded-md transition-colors data-[autopilot-hover]:bg-white dark:data-[autopilot-hover]:bg-white/10 ${\n        active\n          ? \"bg-white text-zinc-900 shadow-sm dark:bg-white/15 dark:text-white\"\n          : \"text-zinc-500 hover:bg-white/70 dark:hover:bg-white/10\"\n      }`}\n    >\n      <svg viewBox=\"0 0 14 14\" className=\"size-3.5\" fill=\"currentColor\" aria-hidden>\n        {children}\n      </svg>\n    </button>\n  );\n}\n"
    }
  ]
}