{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "next-best-action-card",
  "title": "Next Best Action Card",
  "description": "A focused suggestion card with contextual reasoning, async actions, set-aside and dismiss controls, undo and completion states.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/next-best-action-card/next-best-action-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport { clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\nimport { ArrowUpRight, Check, ChevronDown, Clock3, RotateCcw, X } from \"lucide-react\";\n\nexport interface SuggestedAction { id: string; title: string; description: string; reason: string; label: string; effort?: string; context?: string }\nexport interface NextBestActionCardProps {\n  actions?: SuggestedAction[];\n  onAction?: (action: SuggestedAction) => void | Promise<void>;\n  onSnooze?: (action: SuggestedAction) => void;\n  onDismiss?: (action: SuggestedAction) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\nconst seed: SuggestedAction[] = [\n  { id: \"prototype\", title: \"Share the new prototype.\", description: \"Give your team a little time to explore before Friday’s design review.\", reason: \"Your project brief lists the prototype as ready. Sharing it now gives reviewers time to leave useful feedback.\", label: \"Prepare update\", effort: \"About 2 minutes\", context: \"Workspace redesign\" },\n  { id: \"feedback\", title: \"Bring the feedback together.\", description: \"Turn the open research notes into a focused review agenda.\", reason: \"The research notes contain several recurring questions. A short agenda can help the team make decisions together.\", label: \"Create agenda\", effort: \"About 5 minutes\", context: \"Customer research\" },\n  { id: \"owners\", title: \"Make the next step clear.\", description: \"Assign an owner to the follow-ups from your last review.\", reason: \"The meeting notes include follow-up work without owners. Assigning a person to each item makes it easier to move forward.\", label: \"Review follow-ups\", effort: \"About 3 minutes\", context: \"Design review\" },\n];\nconst SHEEN = \"linear-gradient(115deg,rgba(255,255,255,.08),rgba(255,255,255,.02) 30%,transparent 48%,rgba(255,255,255,.04) 74%,transparent),linear-gradient(180deg,rgba(255,255,255,.05),transparent 60%)\";\nfunction Island({ children, theme, active = false, warm = false, className }: { children: React.ReactNode; theme: \"dark\" | \"light\"; active?: boolean; warm?: boolean; className?: string }) {\n  const reduce = useReducedMotion();\n  return <motion.div layout={!reduce} transition={{ type: \"spring\", stiffness: 260, damping: 30 }} className={twMerge(clsx(\"relative isolate w-full rounded-[32px] border font-sans antialiased [font-family:Inter,ui-sans-serif,system-ui,sans-serif]\", theme === \"dark\" ? \"border-white/[0.09] bg-[#0E0E10] text-[#EDEDED]\" : \"border-black/[0.09] bg-[#f7f7f8] text-[#202023]\", className))} style={{ backgroundImage: SHEEN, boxShadow: theme === \"dark\" ? \"inset 0 1px 0 #ffffff1f,0 16px 48px #00000025\" : \"inset 0 1px 0 #ffffff,0 16px 48px #00000008\" }}>\n    <motion.div aria-hidden=\"true\" className=\"pointer-events-none absolute -inset-px rounded-[inherit]\" animate={{ opacity: active && !reduce ? [0.35, 0.8, 0.35] : active ? 0.5 : 0.18 }} transition={{ duration: 3, repeat: active && !reduce ? Infinity : 0 }} style={{ padding: 1, background: warm ? \"conic-gradient(from 40deg,transparent 10%,#FF7BD5 32%,#FFB86B 45%,transparent 65%)\" : \"conic-gradient(from 40deg,transparent 10%,#7CF3FF 32%,#6EA8FF 45%,#9B7BFF 55%,transparent 75%)\", mask: \"linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0)\", maskComposite: \"exclude\", WebkitMaskComposite: \"xor\" }} />\n    {children}\n  </motion.div>;\n}\nfunction Orb({ active = false, warm = false, size = 40 }: { active?: boolean; warm?: boolean; size?: number }) {\n  const reduce = useReducedMotion();\n  return <span aria-hidden=\"true\" className=\"relative inline-flex shrink-0 items-center justify-center\" style={{ width: size, height: size }}>\n    <motion.span className=\"absolute inset-0 rounded-full blur-md\" style={{ background: warm ? \"radial-gradient(circle,#ffb86b55,transparent 70%)\" : \"radial-gradient(circle,#9b7bff55,transparent 70%)\" }} animate={{ opacity: active && !reduce ? [0.3, 0.9, 0.3] : 0.3 }} transition={{ duration: 2.5, repeat: active && !reduce ? Infinity : 0 }} />\n    <motion.svg viewBox=\"0 0 40 40\" className=\"relative size-full\" animate={active && !reduce ? { rotate: [0, 12, 0] } : { rotate: 0 }} transition={{ duration: 5, repeat: active && !reduce ? Infinity : 0 }}>{Array.from({ length: 81 }, (_, i) => { const x = i % 9 - 4; const y = Math.floor(i / 9) - 4; const d = Math.hypot(x, y); return d <= 4.1 ? <circle key={i} cx={20 + x * 3.9} cy={20 + y * 3.9} r={Number((1 - d * .13).toFixed(3))} fill=\"currentColor\" opacity={Number((.95 - d * .16).toFixed(3))} /> : null; })}</motion.svg>\n  </span>;\n}\nconst action = \"inline-flex min-h-10 shrink-0 items-center justify-center gap-2 rounded-full border border-current/[0.12] px-4 text-[11px] transition-colors hover:bg-current/[0.06] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9B7BFF] disabled:cursor-not-allowed disabled:opacity-35 motion-reduce:transition-none [&_svg]:shrink-0\";\n\n\nexport function NextBestActionCard({ actions = seed, onAction, onSnooze, onDismiss, theme = \"dark\", className }: NextBestActionCardProps) {\n  const [states, setStates] = React.useState<Record<string, \"done\" | \"snoozed\" | \"dismissed\">>({});\n  const [pending, setPending] = React.useState(false);\n  const [expanded, setExpanded] = React.useState(false);\n  const [error, setError] = React.useState(\"\");\n  const [last, setLast] = React.useState<{ id: string; title: string; state: \"done\" | \"snoozed\" | \"dismissed\" } | null>(null);\n  const generation = React.useRef(0);\n  const id = React.useId();\n  React.useEffect(() => () => { generation.current++; }, []);\n  const current = actions.find(a => !states[a.id]);\n  const remaining = actions.filter(a => !states[a.id]).length;\n  async function apply() {\n    if (!current || pending) return;\n    const token = ++generation.current; setPending(true); setError(\"\");\n    try { await onAction?.(current); if (token === generation.current) { setStates(s => ({ ...s, [current.id]: \"done\" })); setLast({ id: current.id, title: current.title, state: \"done\" }); setExpanded(false); } }\n    catch (e) { if (token === generation.current) setError(e instanceof Error ? e.message : \"Could not complete this action. Please try again.\"); }\n    finally { if (token === generation.current) setPending(false); }\n  }\n  function skip(state: \"snoozed\" | \"dismissed\") {\n    if (!current || pending) return;\n    try { if (state === \"snoozed\") onSnooze?.(current); else onDismiss?.(current); setStates(s => ({ ...s, [current.id]: state })); setLast({ id: current.id, title: current.title, state }); setExpanded(false); setError(\"\"); }\n    catch (e) { setError(e instanceof Error ? e.message : \"Could not update this action.\"); }\n  }\n  function restore() { setStates({}); setLast(null); setExpanded(false); setError(\"\"); }\n  return <div className={twMerge(\"mx-auto w-full max-w-[460px]\", className)}><Island theme={theme} active={pending} warm className=\"overflow-hidden p-5 sm:p-6\">\n    <header className=\"flex items-center gap-3\"><Orb size={44} active={pending} warm /><div className=\"flex-1\"><p className=\"text-[10px] uppercase tracking-[0.12em] opacity-40\">A little momentum</p><p className=\"mt-1 text-[12px] opacity-65\">Your next best action</p></div><span className=\"rounded-full border border-current/10 px-2.5 py-1.5 text-[9px] tabular-nums opacity-40\">{remaining} remaining</span></header>\n    {current ? <><div className=\"mt-6\"><p className=\"text-[10px] opacity-35\">{current.context ?? \"Suggested for you\"}</p><h3 className=\"mt-2 break-words text-[25px] font-medium leading-[1.2] tracking-[-0.045em]\">{current.title}</h3><p className=\"mt-3 text-[13px] leading-6 opacity-50\">{current.description}</p>{current.effort && <p className=\"mt-4 flex items-center gap-2 text-[10px] opacity-40\"><Clock3 size={16} />{current.effort}</p>}</div>\n      <div className=\"mt-5 rounded-2xl border border-current/[0.08] bg-current/[0.025]\"><button type=\"button\" aria-expanded={expanded} aria-controls={id} onClick={() => setExpanded(!expanded)} className=\"flex min-h-12 w-full items-center justify-between gap-3 rounded-2xl px-4 text-[11px] outline-none focus-visible:ring-2 focus-visible:ring-[#9B7BFF]\"><span className=\"opacity-65\">Why this next?</span><ChevronDown size={17} className={clsx(\"opacity-40 transition-transform motion-reduce:transition-none\", expanded && \"rotate-180\")} /></button><p id={id} hidden={!expanded} className=\"px-4 pb-4 text-[12px] leading-6 opacity-50\">{current.reason}</p></div>\n      {error && <p role=\"alert\" className=\"mt-4 text-[11px] text-red-400\">{error}</p>}\n      <div className=\"mt-6 flex flex-wrap gap-2\"><button type=\"button\" disabled={pending} onClick={apply} className={action + (theme === \"dark\" ? \" flex-1 border-transparent bg-[#EDEDED] text-[#0E0E10] hover:bg-white\" : \" flex-1 bg-[#202023] text-white hover:bg-[#333]\")}>{pending ? \"Working…\" : current.label}<ArrowUpRight size={18} /></button><button type=\"button\" disabled={pending} onClick={() => skip(\"snoozed\")} className={action}><Clock3 size={17} />Later</button><button type=\"button\" aria-label=\"Dismiss suggestion\" disabled={pending} onClick={() => skip(\"dismissed\")} className={action + \" size-10 p-0\"}><X size={18} /></button></div>\n      {!onAction && <p className=\"mt-3 text-[10px] opacity-35\">Demo · actions are marked complete in this preview.</p>}\n    </> : <div className=\"py-9 text-center\"><span className=\"mx-auto flex size-12 items-center justify-center rounded-full border border-current/10 bg-current/[0.03]\"><Check size={22} /></span><h3 className=\"mt-5 text-[20px] font-medium tracking-[-0.03em]\">A little breathing room.</h3><p className=\"mt-2 text-xs opacity-45\">{actions.length ? \"You’ve reviewed every suggestion.\" : \"There are no suggested actions right now.\"}</p>{actions.length > 0 && <button type=\"button\" onClick={restore} className={action + \" mt-6\"}><RotateCcw size={17} />Review again</button>}</div>}\n    <footer className=\"mt-5 border-t border-current/[0.08] pt-4\"><div className=\"flex items-start justify-between gap-3\"><p role=\"status\" className=\"text-[10px] leading-5 opacity-40\">{last ? `${last.state === \"done\" ? \"Completed\" : last.state === \"snoozed\" ? \"Set aside for later\" : \"Dismissed\"}: ${last.title}` : \"One useful step. At your own pace.\"}</p>{last && last.state !== \"done\" && <button type=\"button\" disabled={pending} onClick={() => { setStates(s => { const next = { ...s }; delete next[last.id]; return next; }); setLast(null); setExpanded(false); }} className=\"shrink-0 text-[10px] underline underline-offset-4\">Undo</button>}</div></footer>\n  </Island></div>;\n}\nexport default NextBestActionCard;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}