{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "first-run",
  "type": "registry:block",
  "title": "First Run",
  "description": "A four-step setup for a brand-new AI workspace, with a springy stepper, tools that connect right where they sit, invites as chips, a live preview of your first agent and a calm summary you can jump back from.",
  "categories": [
    "screen",
    "Product"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/avatar.json",
    "https://coss.com/ui/r/badge.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/input.json",
    "https://coss.com/ui/r/popover.json",
    "https://coss.com/ui/r/select.json",
    "https://coss.com/ui/r/spinner.json",
    "https://coss.com/ui/r/textarea.json"
  ],
  "files": [
    {
      "path": "registry/devl/first-run.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  ArrowLeftIcon,\n  ArrowRightIcon,\n  BotIcon,\n  CalendarCheckIcon,\n  CheckIcon,\n  FlameIcon,\n  GitBranchIcon,\n  LifeBuoyIcon,\n  type LucideIcon,\n  MailIcon,\n  MessagesSquareIcon,\n  NotebookPenIcon,\n  PenToolIcon,\n  PlugIcon,\n  PlusIcon,\n  RotateCcwIcon,\n  SparklesIcon,\n  TableIcon,\n  TelescopeIcon,\n  UserPlusIcon,\n  UsersIcon,\n  XIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { type KeyboardEvent, type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Popover, PopoverPopup, PopoverTrigger } from \"@/components/ui/popover\";\nimport { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from \"@/components/ui/select\";\nimport { Spinner } from \"@/components/ui/spinner\";\nimport { Textarea } from \"@/components/ui/textarea\";\n\nexport type FirstRunTone = \"orange\" | \"teal\" | \"violet\" | \"amber\" | \"rose\" | \"info\" | \"success\" | \"destructive\";\n\nexport interface FirstRunTool {\n  id: string;\n  name: string;\n  blurb: string;\n  icon: LucideIcon;\n  tone: FirstRunTone;\n}\n\nexport interface AgentTemplate {\n  id: string;\n  name: string;\n  description: string;\n  icon: LucideIcon;\n  tone: FirstRunTone;\n  instructions: string;\n}\n\nconst softTone: Record<FirstRunTone, string> = {\n  orange: \"bg-orange-500/12 text-orange-700 dark:bg-orange-400/14 dark:text-orange-300\",\n  teal: \"bg-teal-500/12 text-teal-700 dark:bg-teal-400/14 dark:text-teal-300\",\n  violet: \"bg-violet-500/12 text-violet-700 dark:bg-violet-400/14 dark:text-violet-300\",\n  amber: \"bg-amber-500/12 text-amber-700 dark:bg-amber-400/14 dark:text-amber-300\",\n  rose: \"bg-rose-500/12 text-rose-700 dark:bg-rose-400/14 dark:text-rose-300\",\n  info: \"bg-info/12 text-info-foreground\",\n  success: \"bg-success/12 text-success-foreground\",\n  destructive: \"bg-destructive/12 text-destructive-foreground\",\n};\n\nconst tileTone: Record<FirstRunTone, string> = {\n  orange: \"bg-orange-700\",\n  teal: \"bg-teal-700\",\n  violet: \"bg-violet-600\",\n  amber: \"bg-amber-700\",\n  rose: \"bg-rose-700\",\n  info: \"bg-blue-600\",\n  success: \"bg-emerald-700\",\n  destructive: \"bg-red-700\",\n};\n\nconst defaultTools: FirstRunTool[] = [\n  { id: \"relay\", name: \"Relay\", blurb: \"Team chat\", icon: MessagesSquareIcon, tone: \"info\" },\n  { id: \"forge\", name: \"Forge\", blurb: \"Code & reviews\", icon: GitBranchIcon, tone: \"violet\" },\n  { id: \"postbox\", name: \"Postbox\", blurb: \"Shared inbox\", icon: MailIcon, tone: \"orange\" },\n  { id: \"gridline\", name: \"Gridline\", blurb: \"Spreadsheets\", icon: TableIcon, tone: \"success\" },\n  { id: \"harbor\", name: \"Harbor Desk\", blurb: \"Support tickets\", icon: LifeBuoyIcon, tone: \"teal\" },\n  { id: \"inkwell\", name: \"Inkwell\", blurb: \"Design files\", icon: PenToolIcon, tone: \"rose\" },\n];\n\nconst defaultTemplates: AgentTemplate[] = [\n  {\n    id: \"triage\",\n    name: \"Support triage\",\n    description: \"Tags and drafts first replies\",\n    icon: LifeBuoyIcon,\n    tone: \"teal\",\n    instructions:\n      \"Read every new ticket. Tag it by product area and urgency, draft a friendly first reply, and escalate anything about billing to a human.\",\n  },\n  {\n    id: \"research\",\n    name: \"Research analyst\",\n    description: \"Digs up sources, cites them\",\n    icon: TelescopeIcon,\n    tone: \"info\",\n    instructions:\n      \"When asked a question, search our docs and the web, compare at least three sources and answer with a short summary plus citations.\",\n  },\n  {\n    id: \"standup\",\n    name: \"Standup writer\",\n    description: \"Daily digest from your tools\",\n    icon: NotebookPenIcon,\n    tone: \"orange\",\n    instructions:\n      \"Every weekday at 9:00, collect yesterday's merged work and open blockers, then post a three-bullet standup per person in #team.\",\n  },\n  {\n    id: \"blank\",\n    name: \"Start blank\",\n    description: \"Write your own brief\",\n    icon: SparklesIcon,\n    tone: \"amber\",\n    instructions: \"\",\n  },\n];\n\nconst defaultUseCases = [\"Support\", \"Engineering\", \"Sales\", \"Research\", \"Operations\", \"Marketing\"];\nconst defaultSuggestions = [\"maya@northwind.io\", \"theo@northwind.io\", \"ines@northwind.io\"];\nconst swatches: { tone: FirstRunTone; label: string }[] = [\n  { tone: \"orange\", label: \"Orange\" },\n  { tone: \"teal\", label: \"Teal\" },\n  { tone: \"violet\", label: \"Violet\" },\n  { tone: \"amber\", label: \"Amber\" },\n  { tone: \"info\", label: \"Blue\" },\n  { tone: \"rose\", label: \"Rose\" },\n];\nconst defaultTakenSlugs = [\"northwind\", \"acme\", \"hearth\", \"admin\"];\nconst defaultSlots = [\"Tue, Oct 28 · 10:00\", \"Tue, Oct 28 · 14:30\", \"Wed, Oct 29 · 09:30\", \"Thu, Oct 30 · 16:00\"];\nconst roleItems = { admin: \"Admin\", member: \"Member\", viewer: \"Viewer\" };\ntype Role = keyof typeof roleItems;\ntype ToolStatus = \"idle\" | \"connecting\" | \"connected\";\n\nconst spring = { type: \"spring\", stiffness: 420, damping: 38 } as const;\nconst easeOut = [0.23, 1, 0.32, 1] as const;\nconst press = \"transition-[box-shadow,transform,background-color] duration-150 ease-out active:scale-[0.97]\";\nconst STEPS = [\"Workspace\", \"Tools\", \"Team\", \"Agent\"];\n\nfunction slugify(v: string) {\n  return v\n    .toLowerCase()\n    .trim()\n    .replace(/[^a-z0-9]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\")\n    .slice(0, 32);\n}\n\nfunction initials(v: string) {\n  const parts = v.trim().split(/[\\s@._-]+/).filter(Boolean);\n  return ((parts[0]?.[0] ?? \"\") + (parts[1]?.[0] ?? \"\")).toUpperCase() || \"?\";\n}\n\nfunction useReducedMotionAfterMount() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && !!prefers;\n}\n\nconst isEmail = (v: string) => /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v);\n\nfunction Rolling({ value }: { value: number | string }) {\n  const reduce = useReducedMotionAfterMount();\n  return (\n    <span className=\"relative inline-flex overflow-hidden tabular-nums\">\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        <motion.span\n          animate={{ y: 0, opacity: 1 }}\n          exit={reduce ? { opacity: 0 } : { y: \"-100%\", opacity: 0 }}\n          initial={reduce ? { opacity: 0 } : { y: \"100%\", opacity: 0 }}\n          key={value}\n          transition={spring}\n        >\n          {value}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\ntype StepStatus = \"done\" | \"skipped\" | \"current\" | \"upcoming\";\n\nfunction CheckDot({ checked, active }: { checked: boolean; active?: boolean }) {\n  const reduce = useReducedMotionAfterMount();\n  return (\n    <motion.span\n      animate={checked && !reduce ? { scale: [1, 1.12, 1] } : { scale: 1 }}\n      className={cn(\n        \"relative flex size-5 shrink-0 items-center justify-center rounded-full border transition-colors duration-200\",\n        checked ? \"border-primary bg-primary text-primary-foreground\" : active ? \"border-foreground/72 bg-background\" : \"border-input bg-background\",\n      )}\n      transition={{ duration: 0.3, times: [0, 0.4, 1], ease: \"easeOut\" }}\n    >\n      {active && !checked && <span className=\"size-1.5 rounded-full bg-primary\" />}\n      <svg aria-hidden className=\"absolute size-3\" fill=\"none\" viewBox=\"0 0 24 24\">\n        <motion.path\n          animate={{ pathLength: checked ? 1 : 0, opacity: checked ? 1 : 0 }}\n          d=\"M5 12.5l4.5 4.5L19 7.5\"\n          initial={false}\n          stroke=\"currentColor\"\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n          strokeWidth={3.5}\n          transition={reduce ? { duration: 0.15 } : { duration: 0.25, delay: checked ? 0.05 : 0, ease: \"easeOut\" }}\n        />\n      </svg>\n    </motion.span>\n  );\n}\n\ninterface ChecklistItem {\n  label: string;\n  hint: string;\n  done: boolean;\n  step: number;\n}\n\nfunction Checklist({ items, current, onGo }: { items: ChecklistItem[]; current: number | null; onGo: (step: number) => void }) {\n  const reduce = useReducedMotionAfterMount();\n  const doneCount = items.filter((i) => i.done).length;\n\n  return (\n    <div className=\"flex flex-col\">\n      <div className=\"px-2\">\n        <div className=\"flex items-baseline justify-between text-xs\">\n          <span className=\"font-medium\">{doneCount === items.length ? \"All done\" : \"Your progress\"}</span>\n          <span className=\"flex text-muted-foreground tabular-nums\">\n            <Rolling value={doneCount} />\n            &nbsp;of {items.length}\n          </span>\n        </div>\n        <span className=\"mt-2 block h-1 overflow-hidden rounded-full bg-foreground/8\">\n          <motion.span\n            animate={{ scaleX: doneCount / items.length }}\n            className=\"block h-full origin-left rounded-full bg-primary/72\"\n            initial={false}\n            transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 220, damping: 32 }}\n          />\n        </span>\n      </div>\n      <ol className=\"mt-4 flex flex-col gap-px\">\n        {items.map((item) => {\n          const active = current === item.step;\n          return (\n            <li key={item.label}>\n              <button\n                aria-current={active ? \"step\" : undefined}\n                className={cn(\n                  \"flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-2 text-start outline-none transition-[background-color,scale] duration-150 ease-out focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\",\n                  active ? \"bg-accent\" : \"hover:bg-accent/60\",\n                )}\n                onClick={() => onGo(item.step)}\n                type=\"button\"\n              >\n                <CheckDot active={active} checked={item.done} />\n                <span className=\"min-w-0 flex-1\">\n                  <span className={cn(\"block font-medium leading-5 transition-colors\", item.done && !active && \"text-muted-foreground\")}>{item.label}</span>\n                  <span className=\"block truncate text-muted-foreground text-xs\">{item.hint}</span>\n                </span>\n              </button>\n            </li>\n          );\n        })}\n      </ol>\n    </div>\n  );\n}\n\nfunction StepTitle({ title, sub }: { title: string; sub: string }) {\n  return (\n    <div className=\"mb-8\">\n      <h2 className=\"text-balance font-heading font-semibold text-2xl tracking-tight\">{title}</h2>\n      <p className=\"mt-1.5 text-pretty text-muted-foreground\">{sub}</p>\n    </div>\n  );\n}\n\nfunction FieldLabelText({ children, htmlFor }: { children: ReactNode; htmlFor?: string }) {\n  return (\n    <label className=\"mb-2 block font-medium\" htmlFor={htmlFor}>\n      {children}\n    </label>\n  );\n}\n\nexport interface FirstRunProps {\n  productName?: string;\n  domain?: string;\n  defaultWorkspaceName?: string;\n  useCases?: string[];\n  tools?: FirstRunTool[];\n  templates?: AgentTemplate[];\n  inviteSuggestions?: string[];\n  takenSlugs?: string[];\n  walkthroughSlots?: string[];\n  connectDelay?: number;\n  onFinish?: (summary: { workspace: string; tools: string[]; invites: number; agent: string }) => void;\n  className?: string;\n}\n\nexport function FirstRun({\n  productName = \"Hearth\",\n  domain = \"hearth.app\",\n  defaultWorkspaceName = \"Northwind Labs\",\n  useCases = defaultUseCases,\n  tools = defaultTools,\n  templates = defaultTemplates,\n  inviteSuggestions = defaultSuggestions,\n  takenSlugs = defaultTakenSlugs,\n  walkthroughSlots = defaultSlots,\n  connectDelay = 1000,\n  onFinish,\n  className,\n}: FirstRunProps) {\n  const reduce = useReducedMotionAfterMount();\n  const ids = useId();\n  const [step, setStep] = useState(0);\n  const [dir, setDir] = useState(1);\n  const [finished, setFinished] = useState(false);\n  const [left, setLeft] = useState<number[]>([]);\n  const [maxReached, setMaxReached] = useState(0);\n\n  const [name, setName] = useState(defaultWorkspaceName);\n  const [slug, setSlug] = useState(slugify(defaultWorkspaceName));\n  const [slugEdited, setSlugEdited] = useState(false);\n  const [picked, setPicked] = useState<string[]>([\"Support\"]);\n  const [color, setColor] = useState<FirstRunTone>(\"teal\");\n\n  const [toolStatus, setToolStatus] = useState<Record<string, ToolStatus>>({});\n  const timers = useRef<number[]>([]);\n\n  const [draft, setDraft] = useState<string[]>([]);\n  const [emailText, setEmailText] = useState(\"\");\n  const [emailError, setEmailError] = useState(\"\");\n  const [shake, setShake] = useState(0);\n  const [role, setRole] = useState<Role>(\"member\");\n  const [invites, setInvites] = useState<{ email: string; role: Role }[]>([]);\n\n  const [templateId, setTemplateId] = useState(templates[0]?.id ?? \"\");\n  const [agentName, setAgentName] = useState(templates[0]?.name ?? \"My agent\");\n  const [agentNameEdited, setAgentNameEdited] = useState(false);\n  const [instructions, setInstructions] = useState(templates[0]?.instructions ?? \"\");\n\n  useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => window.clearTimeout(t));\n  }, []);\n\n  const connectedTools = tools.filter((t) => toolStatus[t.id] === \"connected\");\n  const template = templates.find((t) => t.id === templateId) ?? templates[0];\n  const slugTaken = takenSlugs.includes(slug);\n  const workspaceValid = !!name.trim() && !!slug && !slugTaken;\n\n  const doneByStep = [\n    workspaceValid && (left.includes(0) || finished),\n    connectedTools.length > 0,\n    invites.length > 0,\n    finished,\n  ];\n  const statuses: StepStatus[] = STEPS.map((_, i) =>\n    !finished && i === step ? \"current\" : doneByStep[i] ? \"done\" : left.includes(i) ? \"skipped\" : \"upcoming\",\n  );\n\n  const checklist: ChecklistItem[] = [\n    {\n      label: \"Name your workspace\",\n      hint: name.trim() ? `${domain}/${slug || \"…\"}` : \"Pick a name and URL\",\n      done: doneByStep[0],\n      step: 0,\n    },\n    {\n      label: \"Connect a tool\",\n      hint: connectedTools.length\n        ? connectedTools.map((t) => t.name).join(\", \")\n        : left.includes(1)\n          ? \"Skipped for now\"\n          : `${tools\n            .slice(0, 2)\n            .map((t) => t.name)\n            .join(\", \")} and more`,\n      done: doneByStep[1],\n      step: 1,\n    },\n    {\n      label: \"Invite a teammate\",\n      hint: invites.length\n        ? `${invites.length} invite${invites.length > 1 ? \"s\" : \"\"} sent`\n        : left.includes(2)\n          ? \"Skipped for now\"\n          : \"Work is better together\",\n      done: doneByStep[2],\n      step: 2,\n    },\n    {\n      label: \"Create your first agent\",\n      hint: finished ? `${agentName} is live` : \"Start from a template\",\n      done: doneByStep[3],\n      step: 3,\n    },\n  ];\n\n  const go = (target: number) => {\n    setDir(finished || target > step ? 1 : -1);\n    setFinished(false);\n    setStep(target);\n    setMaxReached((m) => Math.max(m, target));\n  };\n\n  const next = () => {\n    setLeft((l) => (l.includes(step) ? l : [...l, step]));\n    if (step === STEPS.length - 1) {\n      setDir(1);\n      setFinished(true);\n      setMaxReached(STEPS.length - 1);\n      onFinish?.({\n        workspace: name,\n        tools: connectedTools.map((t) => t.name),\n        invites: invites.length,\n        agent: agentName,\n      });\n      return;\n    }\n    go(step + 1);\n  };\n\n  const restart = () => {\n    setFinished(false);\n    setLeft([]);\n    setMaxReached(0);\n    setToolStatus({});\n    setInvites([]);\n    setDraft([]);\n    setDir(-1);\n    setStep(0);\n  };\n\n  const onName = (v: string) => {\n    setName(v);\n    if (!slugEdited) setSlug(slugify(v));\n  };\n\n  const toggleTool = (id: string) => {\n    const s = toolStatus[id] ?? \"idle\";\n    if (s === \"connecting\") return;\n    if (s === \"connected\") {\n      setToolStatus((m) => ({ ...m, [id]: \"idle\" }));\n      return;\n    }\n    setToolStatus((m) => ({ ...m, [id]: \"connecting\" }));\n    timers.current.push(window.setTimeout(() => setToolStatus((m) => ({ ...m, [id]: \"connected\" })), connectDelay));\n  };\n\n  const commitEmail = (raw: string) => {\n    const v = raw.trim().replace(/,$/, \"\");\n    if (!v) return true;\n    if (!isEmail(v)) {\n      setEmailError(`“${v}” doesn't look like an email`);\n      setShake((n) => n + 1);\n      return false;\n    }\n    setEmailError(\"\");\n    setDraft((d) => (d.includes(v) || invites.some((i) => i.email === v) ? d : [...d, v]));\n    setEmailText(\"\");\n    return true;\n  };\n\n  const onEmailKey = (e: KeyboardEvent<HTMLInputElement>) => {\n    if ([\"Enter\", \",\", \" \", \"Tab\"].includes(e.key) && emailText.trim()) {\n      e.preventDefault();\n      commitEmail(emailText);\n    } else if (e.key === \"Backspace\" && !emailText && draft.length) {\n      setDraft((d) => d.slice(0, -1));\n    }\n  };\n\n  const sendInvites = () => {\n    const ok = commitEmail(emailText);\n    if (!ok) return;\n    const pending = [...draft, ...(isEmail(emailText.trim()) ? [emailText.trim()] : [])];\n    if (!pending.length) return;\n    setInvites((list) => [\n      ...pending.filter((e) => !list.some((i) => i.email === e)).map((email) => ({ email, role })),\n      ...list,\n    ]);\n    setDraft([]);\n    setEmailText(\"\");\n  };\n\n  const pickTemplate = (t: AgentTemplate) => {\n    setTemplateId(t.id);\n    setInstructions(t.instructions);\n    if (!agentNameEdited) setAgentName(t.id === \"blank\" ? \"My agent\" : t.name);\n  };\n\n  const canNext = step === 0 ? workspaceValid : step === 3 ? !!agentName.trim() : true;\n  const skipping = (step === 1 && !connectedTools.length) || (step === 2 && !invites.length);\n\n  const variants = {\n    enter: (d: number) => (reduce ? { opacity: 0 } : { opacity: 0, x: d * 32 }),\n    center: { opacity: 1, x: 0 },\n    exit: (d: number) => ({ opacity: 0, x: reduce ? 0 : d * -24, transition: { duration: 0.12 } }),\n  };\n\n  return (\n    <div\n      className={cn(\n        \"@container/screen relative isolate flex h-[760px] w-full overflow-hidden bg-background text-foreground text-sm\",\n        className,\n      )}\n    >\n      <aside className=\"hidden w-64 shrink-0 flex-col border-e bg-muted/30 px-3 py-4 @3xl/screen:flex\">\n        <div className=\"flex h-8 items-center gap-2 px-2\">\n          <span className=\"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground\">\n            <FlameIcon className=\"size-3.5\" />\n          </span>\n          <span className=\"font-medium\">{productName}</span>\n        </div>\n        <div className=\"mt-8 px-2\">\n          <p className=\"font-medium\">Set up your workspace</p>\n          <p className=\"mt-0.5 text-muted-foreground text-xs\">Takes about three minutes.</p>\n        </div>\n        <div className=\"mt-6\">\n          <Checklist current={finished ? null : step} items={checklist} onGo={go} />\n        </div>\n        <WalkthroughCard slots={walkthroughSlots} />\n      </aside>\n\n      <div className=\"@container flex min-w-0 flex-1 flex-col\">\n        <header className=\"flex h-12 shrink-0 items-center gap-2 border-b px-4 @3xl/screen:hidden\">\n          <span className=\"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground\">\n            <FlameIcon className=\"size-3.5\" />\n          </span>\n          <span className=\"font-medium\">{productName}</span>\n          <span className=\"truncate text-muted-foreground\">/ Set up</span>\n        </header>\n\n        <div className=\"min-h-0 flex-1 overflow-y-auto overflow-x-hidden\">\n          <div className=\"mx-auto flex max-w-2xl flex-col px-5 pt-8 pb-10 @2xl:px-6 @3xl/screen:pt-16\">\n            {!finished && (\n              <div className=\"mb-6 flex items-center gap-3\">\n                <span className=\"shrink-0 text-muted-foreground text-xs tabular-nums\">\n                  Step {step + 1} of {STEPS.length}\n                </span>\n                <div aria-hidden className=\"flex w-28 gap-1\">\n                  {STEPS.map((sName, i) => (\n                    <span className=\"h-1 flex-1 overflow-hidden rounded-full bg-foreground/10\" key={sName}>\n                      <motion.span\n                        animate={{ scaleX: i <= step ? 1 : 0 }}\n                        className=\"block h-full origin-left rounded-full bg-primary/80\"\n                        initial={false}\n                        transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 320, damping: 36 }}\n                      />\n                    </span>\n                  ))}\n                </div>\n              </div>\n            )}\n            <AnimatePresence custom={dir} initial={false} mode=\"wait\">\n              {finished ? (\n                <FinishView\n                  agentName={agentName}\n                  color={color}\n                  invites={invites.length}\n                  key=\"finish\"\n                  onEdit={go}\n                  tools={connectedTools}\n                  url={`${domain}/${slug}`}\n                  workspace={name}\n                />\n              ) : (\n                <motion.section\n                  animate=\"center\"\n                  custom={dir}\n                  exit=\"exit\"\n                  initial=\"enter\"\n                  key={step}\n                  transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 380, damping: 34 }}\n                  variants={variants}\n                >\n                  {step === 0 && (\n                    <>\n                      <StepTitle sub=\"This is where your agents and your team will live.\" title=\"Name your workspace\" />\n                      <div className=\"flex flex-col gap-5\">\n                        <div className=\"flex items-center gap-4\">\n                          <span\n                            className={cn(\n                              \"flex size-14 shrink-0 items-center justify-center rounded-2xl font-heading font-semibold text-lg text-white tabular-nums transition-colors duration-200 ease-out\",\n                              tileTone[color],\n                            )}\n                          >\n                            {initials(name)}\n                          </span>\n                          <div>\n                            <p className=\"mb-1.5 font-medium\">Workspace colour</p>\n                            <div aria-label=\"Workspace colour\" className=\"-ms-1 flex flex-wrap gap-0.5\" role=\"radiogroup\">\n                              {swatches.map((sw) => (\n                                <button\n                                  aria-checked={color === sw.tone}\n                                  aria-label={sw.label}\n                                  className=\"relative flex size-8 cursor-pointer items-center justify-center rounded-full outline-none transition-transform duration-150 ease-out focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.92]\"\n                                  key={sw.tone}\n                                  onClick={() => setColor(sw.tone)}\n                                  role=\"radio\"\n                                  tabIndex={color === sw.tone ? 0 : -1}\n                                  onKeyDown={(e) => {\n                                    const d = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 0;\n                                    if (!d) return;\n                                    e.preventDefault();\n                                    const idx = swatches.findIndex((x) => x.tone === color);\n                                    const nextTone = swatches[(idx + d + swatches.length) % swatches.length].tone;\n                                    setColor(nextTone);\n                                    const btns = e.currentTarget.parentElement?.querySelectorAll(\"button\");\n                                    btns?.[(idx + d + swatches.length) % swatches.length]?.focus();\n                                  }}\n                                  type=\"button\"\n                                >\n                                  {color === sw.tone && (\n                                    <motion.span\n                                      className=\"absolute inset-0.5 rounded-full border-2 border-foreground/70\"\n                                      layoutId={`${ids}-swatch`}\n                                      transition={reduce ? { duration: 0 } : spring}\n                                    />\n                                  )}\n                                  <span className={cn(\"size-5 rounded-full\", tileTone[sw.tone])} />\n                                </button>\n                              ))}\n                            </div>\n                          </div>\n                        </div>\n                        <div>\n                          <FieldLabelText htmlFor={`${ids}-name`}>Workspace name</FieldLabelText>\n                          <Input\n                            aria-describedby={`${ids}-name-hint`}\n                            aria-invalid={!name.trim() || undefined}\n                            id={`${ids}-name`}\n                            onChange={(e) => onName(e.target.value)}\n                            placeholder=\"Acme Inc.\"\n                            value={name}\n                          />\n                          <p\n                            className={cn(\"mt-1.5 text-xs\", name.trim() ? \"text-muted-foreground\" : \"text-destructive-foreground\")}\n                            id={`${ids}-name-hint`}\n                          >\n                            {name.trim() ? \"Teammates see this in invites and emails.\" : \"Give your workspace a name to continue.\"}\n                          </p>\n                        </div>\n                        <div>\n                          <FieldLabelText htmlFor={`${ids}-slug`}>Workspace URL</FieldLabelText>\n                          <div\n                            className={cn(\n                              \"flex w-full items-center overflow-hidden rounded-lg border border-input bg-background shadow-xs/5 focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/24\",\n                              (slugTaken || !slug) && \"border-destructive/48 focus-within:border-destructive/64 focus-within:ring-destructive/16\",\n                            )}\n                          >\n                            <span className=\"shrink-0 border-e bg-muted px-2.5 py-1.5 text-muted-foreground\">\n                              {domain}/\n                            </span>\n                            <input\n                              aria-describedby={`${ids}-slug-hint`}\n                              aria-invalid={slugTaken || !slug || undefined}\n                              className=\"h-8 min-w-0 flex-1 bg-transparent px-2.5 font-mono text-sm outline-none\"\n                              id={`${ids}-slug`}\n                              onChange={(e) => {\n                                setSlugEdited(true);\n                                setSlug(slugify(e.target.value));\n                              }}\n                              value={slug}\n                            />\n                            <AnimatePresence initial={false} mode=\"popLayout\">\n                              {slug && (\n                                <motion.span\n                                  animate={{ scale: 1, opacity: 1 }}\n                                  className={cn(\n                                    \"me-2.5 flex items-center gap-1 text-xs\",\n                                    slugTaken ? \"text-destructive-foreground\" : \"text-success-foreground\",\n                                  )}\n                                  exit={{ scale: 0.95, opacity: 0, transition: { duration: 0.1 } }}\n                                  initial={reduce ? { opacity: 0 } : { scale: 0.95, opacity: 0 }}\n                                  key={slugTaken ? \"taken\" : \"free\"}\n                                  transition={{ duration: 0.18, ease: easeOut }}\n                                >\n                                  {slugTaken ? <XIcon className=\"size-3.5\" /> : <CheckIcon className=\"size-3.5\" />}\n                                  <span className=\"hidden @md:inline\">{slugTaken ? \"Taken\" : \"Available\"}</span>\n                                </motion.span>\n                              )}\n                            </AnimatePresence>\n                          </div>\n                          <p\n                            className={cn(\"mt-1.5 text-xs\", slugTaken || !slug ? \"text-destructive-foreground\" : \"text-muted-foreground\")}\n                            id={`${ids}-slug-hint`}\n                          >\n                            {!slug\n                              ? \"Pick a URL for your workspace.\"\n                              : slugTaken\n                                ? `${domain}/${slug} is taken. Try ${slug}-team?`\n                                : slugEdited\n                                  ? \"Lowercase letters, numbers and dashes.\"\n                                  : \"Filled in from the name. Edit it if you like.\"}\n                          </p>\n                        </div>\n                        <div>\n                          <p className=\"mb-2 font-medium\">What will you use {productName} for?</p>\n                          <div className=\"flex flex-wrap gap-1.5\">\n                            {useCases.map((u) => {\n                              const on = picked.includes(u);\n                              return (\n                                <motion.button\n                                  aria-pressed={on}\n                                  className={cn(\n                                    \"flex h-8 cursor-pointer items-center gap-1 rounded-full border px-3 outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-ring\",\n                                    on\n                                      ? \"border-primary bg-primary text-primary-foreground\"\n                                      : \"bg-background text-muted-foreground hover:text-foreground\",\n                                  )}\n                                  key={u}\n                                  layout={!reduce}\n                                  onClick={() => setPicked((p) => (on ? p.filter((x) => x !== u) : [...p, u]))}\n                                  transition={spring}\n                                  type=\"button\"\n                                  whileTap={reduce ? undefined : { scale: 0.97 }}\n                                >\n                                  <AnimatePresence initial={false}>\n                                    {on && (\n                                      <motion.span\n                                        animate={{ width: \"auto\", opacity: 1 }}\n                                        className=\"overflow-hidden\"\n                                        exit={{ width: 0, opacity: 0 }}\n                                        initial={{ width: 0, opacity: 0 }}\n                                        transition={spring}\n                                      >\n                                        <CheckIcon className=\"size-3.5\" />\n                                      </motion.span>\n                                    )}\n                                  </AnimatePresence>\n                                  {u}\n                                </motion.button>\n                              );\n                            })}\n                          </div>\n                        </div>\n                      </div>\n                    </>\n                  )}\n\n                  {step === 1 && (\n                    <>\n                      <StepTitle sub=\"Agents can read and act in the tools you connect. You can change this later.\" title=\"Connect your tools\" />\n                      <div className=\"divide-y overflow-hidden rounded-xl border bg-card\">\n                        {tools.map((t, i) => {\n                          const s = toolStatus[t.id] ?? \"idle\";\n                          const Icon = t.icon;\n                          return (\n                            <motion.div\n                              animate={{ opacity: 1, y: 0 }}\n                              className=\"flex items-center gap-3 px-4 py-3\"\n                              initial={reduce ? false : { opacity: 0, y: 6 }}\n                              key={t.id}\n                              transition={{ duration: 0.22, ease: easeOut, delay: i * 0.03 }}\n                            >\n                              <span className={cn(\"flex size-9 shrink-0 items-center justify-center rounded-lg\", softTone[t.tone])}>\n                                <Icon className=\"size-4.5\" />\n                              </span>\n                              <span className=\"min-w-0 flex-1\">\n                                <span className=\"block truncate font-medium\">{t.name}</span>\n                                <span className=\"block truncate text-muted-foreground text-xs\">{t.blurb}</span>\n                              </span>\n                              <button\n                                aria-label={s === \"connected\" ? `Disconnect ${t.name}` : `Connect ${t.name}`}\n                                className={cn(\n                                  \"flex h-8 w-28 shrink-0 cursor-pointer items-center justify-center gap-1 overflow-hidden rounded-lg border px-2.5 font-medium text-xs shadow-xs/5 outline-none transition-[background-color,border-color,color,transform] duration-150 ease-out focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.97] disabled:cursor-default\",\n                                  s === \"connected\"\n                                    ? \"border-success/32 bg-success/8 text-success-foreground hover:bg-success/14 dark:bg-success/16\"\n                                    : \"bg-background text-foreground hover:bg-accent\",\n                                )}\n                                disabled={s === \"connecting\"}\n                                onClick={() => toggleTool(t.id)}\n                                type=\"button\"\n                              >\n                                {s === \"connecting\" && <Spinner className=\"size-3.5\" />}\n                                {s === \"connected\" && (\n                                  <motion.span\n                                    animate={{ scale: 1, opacity: 1 }}\n                                    initial={reduce ? { opacity: 0 } : { scale: 0.8, opacity: 0 }}\n                                    transition={{ duration: 0.18, ease: easeOut }}\n                                  >\n                                    <CheckIcon className=\"size-3.5\" strokeWidth={3} />\n                                  </motion.span>\n                                )}\n                                {s === \"idle\" && <PlusIcon className=\"size-3.5\" />}\n                                {s === \"connecting\" ? \"Connecting\" : s === \"connected\" ? \"Connected\" : \"Connect\"}\n                              </button>\n                            </motion.div>\n                          );\n                        })}\n                      </div>\n                      <p className=\"mt-3 text-muted-foreground text-xs tabular-nums\">\n                        <Rolling value={connectedTools.length} /> of {tools.length} connected · read-only until you grant more\n                      </p>\n                    </>\n                  )}\n\n                  {step === 2 && (\n                    <>\n                      <StepTitle sub=\"Invite people now or later. They'll get an email with a link.\" title=\"Invite your team\" />\n                      <div className=\"flex flex-col gap-2\">\n                        <FieldLabelText htmlFor={`${ids}-email`}>Email addresses</FieldLabelText>\n                        <div className=\"flex flex-col gap-2 @md:flex-row\">\n                          <motion.div\n                            animate={shake && !reduce ? { x: shake % 2 ? [0, -6, 6, -4, 4, 0] : [0, 6, -6, 4, -4, 0] } : { x: 0 }}\n                            className={cn(\n                              \"flex min-h-9 min-w-0 flex-1 flex-wrap items-center gap-1 rounded-lg border border-input bg-background px-1.5 py-1 shadow-xs/5 focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/24\",\n                              emailError && \"border-destructive/60\",\n                            )}\n                            transition={{ duration: 0.35 }}\n                          >\n                            <AnimatePresence initial={false} mode=\"popLayout\">\n                              {draft.map((d) => (\n                                <motion.span\n                                  animate={{ scale: 1, opacity: 1 }}\n                                  className=\"flex h-6 items-center gap-1 rounded-full bg-muted ps-2 pe-0.5 text-xs\"\n                                  exit={{ scale: 0.95, opacity: 0, transition: { duration: 0.1 } }}\n                                  initial={reduce ? { opacity: 0 } : { scale: 0.95, opacity: 0 }}\n                                  key={d}\n                                  layout={!reduce}\n                                  transition={{ type: \"spring\", stiffness: 520, damping: 40 }}\n                                >\n                                  {d}\n                                  <button\n                                    aria-label={`Remove ${d}`}\n                                    className=\"relative flex size-5 cursor-pointer items-center justify-center rounded-full text-muted-foreground outline-none transition-colors before:absolute before:-inset-1.5 before:rounded-full hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                                    onClick={() => setDraft((x) => x.filter((y) => y !== d))}\n                                    type=\"button\"\n                                  >\n                                    <XIcon className=\"size-3\" />\n                                  </button>\n                                </motion.span>\n                              ))}\n                            </AnimatePresence>\n                            <input\n                              aria-describedby={emailError ? `${ids}-email-err` : undefined}\n                              aria-invalid={!!emailError || undefined}\n                              className=\"h-6 min-w-32 flex-1 bg-transparent px-1 outline-none placeholder:text-muted-foreground/72\"\n                              id={`${ids}-email`}\n                              onBlur={() => emailText.trim() && commitEmail(emailText)}\n                              onChange={(e) => {\n                                setEmailText(e.target.value);\n                                if (emailError) setEmailError(\"\");\n                              }}\n                              onKeyDown={onEmailKey}\n                              placeholder={draft.length ? \"Add another\" : \"name@company.com\"}\n                              value={emailText}\n                            />\n                          </motion.div>\n                          <div className=\"flex gap-2\">\n                            <Select items={roleItems} onValueChange={(v) => v && setRole(v as Role)} value={role}>\n                              <SelectTrigger aria-label=\"Role\" className=\"w-28\">\n                                <SelectValue />\n                              </SelectTrigger>\n                              <SelectPopup>\n                                {Object.entries(roleItems).map(([v, l]) => (\n                                  <SelectItem key={v} value={v}>\n                                    {l}\n                                  </SelectItem>\n                                ))}\n                              </SelectPopup>\n                            </Select>\n                            <Button\n                              className={cn(\"flex-1 @md:flex-none\", press)}\n                              disabled={!draft.length && !emailText.trim()}\n                              onClick={sendInvites}\n                            >\n                              <UserPlusIcon />\n                              Invite\n                            </Button>\n                          </div>\n                        </div>\n                        <p\n                          className={cn(\"text-xs\", emailError ? \"text-destructive-foreground\" : \"text-muted-foreground\")}\n                          id={`${ids}-email-err`}\n                        >\n                          {emailError || \"Press Enter or comma to add each address.\"}\n                        </p>\n                      </div>\n\n                      {inviteSuggestions.some((s) => !invites.some((i) => i.email === s) && !draft.includes(s)) && (\n                        <div className=\"mt-4\">\n                          <p className=\"mb-2 font-medium\">Suggested from your domain</p>\n                          <div className=\"flex flex-wrap gap-1.5\">\n                            {inviteSuggestions\n                              .filter((s) => !invites.some((i) => i.email === s) && !draft.includes(s))\n                              .map((s) => (\n                                <button\n                                  className=\"flex h-8 cursor-pointer items-center gap-1.5 rounded-full border border-dashed ps-1.5 pe-3 text-xs outline-none transition-[background-color,transform] duration-150 ease-out hover:border-solid hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.97]\"\n                                  key={s}\n                                  onClick={() => setDraft((d) => [...d, s])}\n                                  type=\"button\"\n                                >\n                                  <Avatar className=\"size-5 text-[9px]\">\n                                    <AvatarFallback>{initials(s)}</AvatarFallback>\n                                  </Avatar>\n                                  {s}\n                                  <PlusIcon className=\"size-3 text-muted-foreground\" />\n                                </button>\n                              ))}\n                          </div>\n                        </div>\n                      )}\n\n                      <div className=\"mt-5 rounded-xl border\">\n                        <div className=\"flex items-center justify-between border-b px-3 py-2\">\n                          <span className=\"font-medium text-xs\">Pending invites</span>\n                          <span className=\"text-muted-foreground text-xs\">\n                            <Rolling value={invites.length} />\n                          </span>\n                        </div>\n                        <ul className=\"divide-y\">\n                          <AnimatePresence initial={false}>\n                            {invites.length === 0 && (\n                              <motion.li\n                                animate={{ opacity: 1 }}\n                                className=\"px-3 py-6 text-center text-muted-foreground text-xs\"\n                                exit={{ opacity: 0, height: 0, paddingTop: 0, paddingBottom: 0 }}\n                                initial={{ opacity: 0 }}\n                                key=\"empty\"\n                              >\n                                No invites yet. You can always do this later.\n                              </motion.li>\n                            )}\n                            {invites.map((inv) => (\n                              <motion.li\n                                animate={{ opacity: 1, height: \"auto\" }}\n                                className=\"overflow-hidden\"\n                                exit={{ opacity: 0, height: 0 }}\n                                initial={reduce ? false : { opacity: 0, height: 0 }}\n                                key={inv.email}\n                                transition={spring}\n                              >\n                                <div className=\"flex items-center gap-2.5 py-2 ps-3 pe-2\">\n                                  <Avatar className=\"size-7 text-[11px]\">\n                                    <AvatarFallback>{initials(inv.email)}</AvatarFallback>\n                                  </Avatar>\n                                  <span className=\"min-w-0 flex-1\">\n                                    <span className=\"block truncate\">{inv.email}</span>\n                                    <span className=\"block text-muted-foreground text-xs\">Invite sent · pending</span>\n                                  </span>\n                                  <Badge variant=\"outline\">{roleItems[inv.role]}</Badge>\n                                  <Button\n                                    aria-label={`Cancel invite for ${inv.email}`}\n                                    onClick={() => setInvites((l) => l.filter((x) => x.email !== inv.email))}\n                                    className={press}\n                                    size=\"icon-sm\"\n                                    variant=\"ghost\"\n                                  >\n                                    <XIcon />\n                                  </Button>\n                                </div>\n                              </motion.li>\n                            ))}\n                          </AnimatePresence>\n                        </ul>\n                      </div>\n                    </>\n                  )}\n\n                  {step === 3 && template && (\n                    <>\n                      <StepTitle sub=\"Pick a starting point. You can tune everything after.\" title=\"Create your first agent\" />\n                      <div className=\"grid grid-cols-1 gap-6 @3xl:grid-cols-[1fr_16rem]\">\n                        <div className=\"flex min-w-0 flex-col gap-4\">\n                          <div aria-label=\"Template\" className=\"grid grid-cols-2 gap-2\" role=\"radiogroup\">\n                            {templates.map((t) => {\n                              const on = t.id === templateId;\n                              const Icon = t.icon;\n                              return (\n                                <button\n                                  aria-checked={on}\n                                  className=\"relative flex cursor-pointer flex-col items-start gap-2 rounded-xl border bg-card p-3 text-start outline-none transition-[background-color,transform] duration-150 ease-out hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\"\n                                  key={t.id}\n                                  onClick={() => pickTemplate(t)}\n                                  role=\"radio\"\n                                  type=\"button\"\n                                >\n                                  {on && (\n                                    <motion.span\n                                      className=\"absolute -inset-px rounded-xl border-2 border-primary\"\n                                      layoutId={`${ids}-template`}\n                                      transition={reduce ? { duration: 0 } : spring}\n                                    />\n                                  )}\n                                  <span className={cn(\"relative flex size-8 items-center justify-center rounded-lg\", softTone[t.tone])}>\n                                    <Icon className=\"size-4\" />\n                                  </span>\n                                  <span className=\"relative min-w-0\">\n                                    <span className=\"block font-medium leading-tight\">{t.name}</span>\n                                    <span className=\"block text-muted-foreground text-xs leading-snug\">{t.description}</span>\n                                  </span>\n                                </button>\n                              );\n                            })}\n                          </div>\n                          <div>\n                            <FieldLabelText htmlFor={`${ids}-agent`}>Agent name</FieldLabelText>\n                            <Input\n                              id={`${ids}-agent`}\n                              onChange={(e) => {\n                                setAgentNameEdited(true);\n                                setAgentName(e.target.value);\n                              }}\n                              aria-describedby={`${ids}-agent-hint`}\n                              aria-invalid={!agentName.trim() || undefined}\n                              value={agentName}\n                            />\n                            <p\n                              className={cn(\"mt-1.5 text-xs\", agentName.trim() ? \"text-muted-foreground\" : \"text-destructive-foreground\")}\n                              id={`${ids}-agent-hint`}\n                            >\n                              {agentName.trim() ? \"Shown when it posts or replies. You can rename it later.\" : \"Your agent needs a name.\"}\n                            </p>\n                          </div>\n                          <div>\n                            <FieldLabelText htmlFor={`${ids}-instr`}>Instructions</FieldLabelText>\n                            <Textarea\n                              id={`${ids}-instr`}\n                              onChange={(e) => setInstructions(e.target.value)}\n                              placeholder=\"Describe what this agent should do, in plain words.\"\n                              value={instructions}\n                            />\n                          </div>\n                        </div>\n\n                        <div className=\"@3xl:sticky @3xl:top-0 @3xl:self-start\">\n                          <p className=\"mb-2 font-medium\">Preview</p>\n                          <div className=\"rounded-xl border bg-card p-4\">\n                            <div className=\"flex items-center gap-2.5\">\n                              <AnimatePresence initial={false} mode=\"popLayout\">\n                                <motion.span\n                                  animate={{ scale: 1, opacity: 1 }}\n                                  className={cn(\"flex size-10 shrink-0 items-center justify-center rounded-xl\", softTone[template.tone])}\n                                  exit={{ scale: 0.95, opacity: 0, transition: { duration: 0.1 } }}\n                                  initial={reduce ? { opacity: 0 } : { scale: 0.95, opacity: 0 }}\n                                  key={template.id}\n                                  transition={{ duration: 0.2, ease: easeOut }}\n                                >\n                                  <BotIcon className=\"size-5\" />\n                                </motion.span>\n                              </AnimatePresence>\n                              <span className=\"min-w-0 flex-1\">\n                                <span className=\"block truncate font-medium\">{agentName || \"Untitled agent\"}</span>\n                                <span className=\"block truncate text-muted-foreground text-xs\">in {name || \"your workspace\"}</span>\n                              </span>\n                              <Badge variant=\"warning\">Draft</Badge>\n                            </div>\n                            <p className=\"mt-3 line-clamp-4 text-muted-foreground text-xs leading-relaxed\">\n                              {instructions || \"No instructions yet.\"}\n                            </p>\n                            <div className=\"mt-3 flex flex-wrap gap-1\">\n                              {connectedTools.length ? (\n                                connectedTools.map((t) => {\n                                  const Icon = t.icon;\n                                  return (\n                                    <span className=\"flex h-6 items-center gap-1 rounded-full bg-muted px-2 text-xs\" key={t.id}>\n                                      <Icon className=\"size-3\" />\n                                      {t.name}\n                                    </span>\n                                  );\n                                })\n                              ) : (\n                                <span className=\"text-muted-foreground text-xs\">No tools connected yet</span>\n                              )}\n                            </div>\n                          </div>\n                        </div>\n                      </div>\n                    </>\n                  )}\n                </motion.section>\n              )}\n            </AnimatePresence>\n          </div>\n        </div>\n\n        <footer className=\"shrink-0 border-t bg-background\">\n          <div className=\"mx-auto flex h-14 max-w-2xl items-center gap-2 px-5 @2xl:px-6\">\n          {finished ? (\n            <Button className={cn(\"-ms-2.5\", press)} onClick={restart} variant=\"ghost\">\n              <RotateCcwIcon />\n              Start over\n            </Button>\n          ) : (\n            <Button className={cn(\"-ms-2.5\", press)} disabled={step === 0} onClick={() => go(step - 1)} variant=\"ghost\">\n              <ArrowLeftIcon />\n              Back\n            </Button>\n          )}\n          <div className=\"ms-auto\">\n            {finished ? (\n              <Button className={cn(\"min-w-32\", press)}>\n                Open workspace\n                <ArrowRightIcon />\n              </Button>\n            ) : (\n              <Button\n                className={cn(\"min-w-32\", press)}\n                disabled={!canNext}\n                onClick={next}\n                variant={skipping ? \"outline\" : \"default\"}\n              >\n                {step === STEPS.length - 1 ? \"Create agent\" : skipping ? \"Skip for now\" : \"Continue\"}\n                {step === STEPS.length - 1 ? <SparklesIcon /> : <ArrowRightIcon />}\n              </Button>\n            )}\n          </div>\n          </div>\n        </footer>\n      </div>\n    </div>\n  );\n}\n\nfunction WalkthroughCard({ slots }: { slots: string[] }) {\n  const ids = useId();\n  const [open, setOpen] = useState(false);\n  const [choice, setChoice] = useState(slots[0] ?? \"\");\n  const [booked, setBooked] = useState<string | null>(null);\n\n  return (\n    <div className=\"mt-auto rounded-xl border bg-card p-2\">\n      <div className=\"flex items-start gap-2.5 px-1.5 pt-1.5 pb-2.5\">\n        <span\n          className={cn(\n            \"flex size-7 shrink-0 items-center justify-center rounded-lg transition-colors duration-200\",\n            booked ? \"bg-success/12 text-success-foreground\" : \"bg-muted text-muted-foreground\",\n          )}\n        >\n          {booked ? <CalendarCheckIcon className=\"size-4\" /> : <LifeBuoyIcon className=\"size-4\" />}\n        </span>\n        <div className=\"min-w-0\">\n          <p className=\"font-medium text-xs\">{booked ? \"Walkthrough booked\" : \"Need a hand?\"}</p>\n          <p className=\"mt-0.5 text-pretty text-muted-foreground text-xs tabular-nums\">\n            {booked ? `${booked}. We'll send a calendar invite.` : \"Set up your first agents with us on a 15 minute call.\"}\n          </p>\n        </div>\n      </div>\n      <Popover onOpenChange={setOpen} open={open}>\n        <PopoverTrigger render={<Button className={cn(\"w-full\", press)} size=\"sm\" variant=\"outline\" />}>\n          {booked ? \"Change time\" : \"Book a walkthrough\"}\n        </PopoverTrigger>\n        <PopoverPopup align=\"end\" className=\"w-64\" side=\"top\" sideOffset={6}>\n          <p className=\"font-medium text-sm\" id={`${ids}-title`}>\n            Pick a time\n          </p>\n          <p className=\"mt-0.5 text-muted-foreground text-xs\">15 min video call, in your time zone</p>\n          <div aria-labelledby={`${ids}-title`} className=\"mt-3 flex flex-col gap-1\" role=\"radiogroup\">\n            {slots.map((slot) => {\n              const on = slot === choice;\n              return (\n                <button\n                  aria-checked={on}\n                  className={cn(\n                    \"flex h-8 cursor-pointer items-center justify-between rounded-md border px-2.5 text-start text-xs tabular-nums outline-none transition-[background-color,border-color,transform] duration-150 ease-out focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\",\n                    on ? \"border-border bg-accent font-medium\" : \"border-transparent hover:bg-accent/60\",\n                  )}\n                  key={slot}\n                  onClick={() => setChoice(slot)}\n                  role=\"radio\"\n                  type=\"button\"\n                >\n                  {slot}\n                  {on && <CheckIcon className=\"size-3.5\" />}\n                </button>\n              );\n            })}\n          </div>\n          <Button\n            className={cn(\"mt-3 w-full\", press)}\n            onClick={() => {\n              setBooked(choice);\n              setOpen(false);\n            }}\n            size=\"sm\"\n          >\n            {booked === choice ? \"Keep this time\" : \"Book call\"}\n          </Button>\n        </PopoverPopup>\n      </Popover>\n    </div>\n  );\n}\n\nfunction FinishView({\n  workspace,\n  url,\n  color,\n  tools,\n  invites,\n  agentName,\n  onEdit,\n}: {\n  workspace: string;\n  url: string;\n  color: FirstRunTone;\n  tools: FirstRunTool[];\n  invites: number;\n  agentName: string;\n  onEdit: (step: number) => void;\n}) {\n  const reduce = useReducedMotionAfterMount();\n  const rows: { step: number; label: string; value: ReactNode; icon: ReactNode; empty?: boolean }[] = [\n    {\n      step: 0,\n      label: \"Workspace\",\n      icon: (\n        <span className={cn(\"flex size-8 items-center justify-center rounded-lg font-semibold text-[11px] text-white\", tileTone[color])}>\n          {initials(workspace)}\n        </span>\n      ),\n      value: (\n        <>\n          <span className=\"block truncate font-medium\">{workspace || \"Your workspace\"}</span>\n          <span className=\"block truncate font-mono text-muted-foreground text-xs\">{url}</span>\n        </>\n      ),\n    },\n    {\n      step: 1,\n      label: \"Tools\",\n      empty: !tools.length,\n      icon: (\n        <span className=\"flex size-8 items-center justify-center rounded-lg bg-muted text-muted-foreground\">\n          <PlugIcon className=\"size-4\" />\n        </span>\n      ),\n      value: (\n        <>\n          <span className=\"block truncate font-medium tabular-nums\">\n            {tools.length ? `${tools.length} connected` : \"No tools yet\"}\n          </span>\n          <span className=\"block truncate text-muted-foreground text-xs\">\n            {tools.length ? tools.map((t) => t.name).join(\", \") : \"Agents work best with at least one\"}\n          </span>\n        </>\n      ),\n    },\n    {\n      step: 2,\n      label: \"Team\",\n      empty: !invites,\n      icon: (\n        <span className=\"flex size-8 items-center justify-center rounded-lg bg-muted text-muted-foreground\">\n          <UsersIcon className=\"size-4\" />\n        </span>\n      ),\n      value: (\n        <>\n          <span className=\"block truncate font-medium tabular-nums\">\n            {invites ? `${invites} invite${invites > 1 ? \"s\" : \"\"} pending` : \"Just you for now\"}\n          </span>\n          <span className=\"block truncate text-muted-foreground text-xs\">\n            {invites ? \"They'll get an email with a link\" : \"Invite people any time from Settings\"}\n          </span>\n        </>\n      ),\n    },\n    {\n      step: 3,\n      label: \"Agent\",\n      icon: (\n        <span className=\"flex size-8 items-center justify-center rounded-lg bg-muted text-muted-foreground\">\n          <BotIcon className=\"size-4\" />\n        </span>\n      ),\n      value: (\n        <>\n          <span className=\"flex min-w-0 items-center gap-2\">\n            <span className=\"truncate font-medium\">{agentName}</span>\n            <Badge className=\"shrink-0\" variant=\"success\">\n              Live\n            </Badge>\n          </span>\n          <span className=\"block truncate text-muted-foreground text-xs\">Picks up its first task in a moment</span>\n        </>\n      ),\n    },\n  ];\n\n  return (\n    <motion.section\n      animate={{ opacity: 1, y: 0 }}\n      className=\"mx-auto flex w-full max-w-md flex-col items-center pt-4 text-center\"\n      exit={{ opacity: 0, transition: { duration: 0.12 } }}\n      initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8 }}\n      transition={{ duration: 0.25, ease: easeOut }}\n    >\n      <div className=\"relative flex size-12 items-center justify-center\">\n        {!reduce && (\n          <motion.span\n            animate={{ scale: 1.9, opacity: 0 }}\n            aria-hidden\n            className=\"absolute inset-0 rounded-full border border-success/50\"\n            initial={{ scale: 1, opacity: 1 }}\n            transition={{ duration: 0.8, delay: 0.3, ease: easeOut }}\n          />\n        )}\n        <motion.span\n          animate={{ scale: 1, opacity: 1 }}\n          className=\"flex size-12 items-center justify-center rounded-full bg-success/12 text-success-foreground\"\n          initial={reduce ? false : { scale: 0.9, opacity: 0 }}\n          transition={{ duration: 0.25, ease: easeOut }}\n        >\n          <svg aria-hidden className=\"size-6\" fill=\"none\" viewBox=\"0 0 24 24\">\n            <motion.path\n              animate={{ pathLength: 1 }}\n              d=\"M5 12.5l4.5 4.5L19 7.5\"\n              initial={reduce ? false : { pathLength: 0 }}\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              strokeWidth={2.5}\n              transition={{ duration: 0.3, delay: 0.12, ease: \"easeOut\" }}\n            />\n          </svg>\n        </motion.span>\n      </div>\n      <h2 className=\"mt-4 text-balance font-heading font-semibold text-lg tracking-tight\">\n        {workspace || \"Your workspace\"} is ready\n      </h2>\n      <p className=\"mt-1 text-pretty text-muted-foreground\">Here's what you set up. You can change any of it later.</p>\n\n      <ul className=\"mt-6 w-full divide-y rounded-xl border bg-card text-start\">\n        {rows.map((r, i) => (\n          <motion.li\n            animate={{ opacity: 1, y: 0 }}\n            className=\"flex items-center gap-3 py-2.5 ps-3 pe-2\"\n            initial={reduce ? false : { opacity: 0, y: 4 }}\n            key={r.label}\n            transition={{ duration: 0.22, ease: easeOut, delay: 0.12 + i * 0.035 }}\n          >\n            <span className=\"shrink-0\">{r.icon}</span>\n            <span className=\"min-w-0 flex-1\">{r.value}</span>\n            {r.empty ? (\n              <Button aria-label={`Add ${r.label.toLowerCase()}`} className={press} onClick={() => onEdit(r.step)} size=\"sm\" variant=\"outline\">\n                <PlusIcon />\n                Add\n              </Button>\n            ) : (\n              <Button aria-label={`Edit ${r.label.toLowerCase()}`} className={press} onClick={() => onEdit(r.step)} size=\"sm\" variant=\"ghost\">\n                Edit\n              </Button>\n            )}\n          </motion.li>\n        ))}\n      </ul>\n\n    </motion.section>\n  );\n}\n"
    }
  ]
}