{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "onboarding-checklist-widget",
  "title": "Onboarding Checklist Widget",
  "description": "A floating setup guide for the corner of an app: a progress ring that shrinks into a pill showing the next step, steps grouped into sections with their own counts, one step open at a time with its time estimate and action button, Skip for now, a reward for finishing, confetti, and dismiss with a way back.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/onboarding-checklist-widget/onboarding-checklist-widget.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface OnboardingStep {\n  id: string;\n  title: string;\n  description?: string;\n  /** Button label, e.g. \"Connect\". */\n  action: string;\n  /** Rough time, e.g. \"2 min\". */\n  time?: string;\n  done?: boolean;\n}\n\nexport interface OnboardingSection {\n  id: string;\n  title: string;\n  steps: OnboardingStep[];\n}\n\nexport interface OnboardingChecklistWidgetProps {\n  title?: string;\n  sections?: OnboardingSection[];\n  /** Shown as the reward for finishing everything. */\n  reward?: string;\n  /** Run a step. Resolve when it is done; without it, steps complete after a short delay. */\n  onStep?: (id: string) => Promise<void> | void;\n  onDismiss?: () => void;\n  /** Start open (otherwise the widget is a small pill). */\n  defaultOpen?: boolean;\n  /** Draw a sample dashboard behind the widget. */\n  showBackdrop?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", card: \"#141414\", border: \"rgba(255,255,255,0.1)\", chip: \"rgba(255,255,255,0.06)\", skel: \"rgba(255,255,255,0.045)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", accent: \"#FB923C\", track: \"rgba(255,255,255,0.1)\", ring: \"rgba(245,244,241,0.6)\", shadow: \"0 30px 80px -20px rgba(0,0,0,0.8)\" },\n  light: { bg: \"#F4F4F1\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", border: \"rgba(10,10,10,0.1)\", chip: \"rgba(10,10,10,0.05)\", skel: \"rgba(10,10,10,0.05)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", accent: \"#EA580C\", track: \"rgba(10,10,10,0.08)\", ring: \"rgba(10,10,10,0.5)\", shadow: \"0 30px 80px -24px rgba(0,0,0,0.22)\" },\n};\nconst CONFETTI = [\"#FB923C\", \"#F472B6\", \"#60A5FA\", \"#4ADE80\", \"#FBBF24\", \"#A78BFA\"];\n\nconst DEFAULT_SECTIONS: OnboardingSection[] = [\n  {\n    id: \"setup\",\n    title: \"Set up your workspace\",\n    steps: [\n      { id: \"profile\", title: \"Add your profile photo\", action: \"Upload\", time: \"30 sec\", done: true },\n      { id: \"brand\", title: \"Pick your brand colour\", action: \"Choose\", time: \"1 min\", done: true },\n      { id: \"domain\", title: \"Connect a custom domain\", description: \"Point a CNAME record at nexora.app. We check it for you.\", action: \"Connect domain\", time: \"3 min\" },\n    ],\n  },\n  {\n    id: \"team\",\n    title: \"Bring your team\",\n    steps: [\n      { id: \"invite\", title: \"Invite two teammates\", description: \"Work goes faster together. Invites expire after 7 days.\", action: \"Invite\", time: \"1 min\" },\n      { id: \"slack\", title: \"Turn on notifications\", description: \"Get a ping when someone mentions you.\", action: \"Turn on\", time: \"30 sec\" },\n    ],\n  },\n  {\n    id: \"live\",\n    title: \"Go live\",\n    steps: [\n      { id: \"import\", title: \"Import your first data\", description: \"Upload a CSV or connect a source.\", action: \"Import\", time: \"2 min\" },\n      { id: \"publish\", title: \"Publish your first page\", description: \"It goes live on your domain right away.\", action: \"Publish\", time: \"1 min\" },\n    ],\n  },\n];\n\nfunction Ring({ pct, size, stroke, color, track }: { pct: number; size: number; stroke: number; color: string; track: string }) {\n  const r = (size - stroke) / 2;\n  const c = 2 * Math.PI * r;\n  return (\n    <svg width={size} height={size} className=\"-rotate-90\" aria-hidden=\"true\">\n      <circle cx={size / 2} cy={size / 2} r={r} fill=\"none\" stroke={track} strokeWidth={stroke} />\n      <motion.circle cx={size / 2} cy={size / 2} r={r} fill=\"none\" stroke={color} strokeWidth={stroke} strokeLinecap=\"round\" strokeDasharray={c} initial={false} animate={{ strokeDashoffset: c * (1 - pct) }} transition={{ duration: 0.6, ease: [0.22, 1, 0.36, 1] }} />\n    </svg>\n  );\n}\n\nexport function OnboardingChecklistWidget({ title = \"Get started\", sections: sectionsProp = DEFAULT_SECTIONS, reward = \"14 more days of trial\", onStep, onDismiss, defaultOpen = true, showBackdrop = true, theme = \"dark\", className }: OnboardingChecklistWidgetProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [done, setDone] = React.useState<string[]>(() => sectionsProp.flatMap((s) => s.steps.filter((x) => x.done).map((x) => x.id)));\n  const [busy, setBusy] = React.useState<string | null>(null);\n  const [open, setOpen] = React.useState(defaultOpen);\n  const [dismissed, setDismissed] = React.useState(false);\n  const [confirmDismiss, setConfirmDismiss] = React.useState(false);\n  const allSteps = sectionsProp.flatMap((s) => s.steps);\n  const firstOpen = allSteps.find((x) => !done.includes(x.id))?.id ?? null;\n  const [active, setActive] = React.useState<string | null>(firstOpen);\n  const [celebrate, setCelebrate] = React.useState(0);\n\n  const total = allSteps.length;\n  const count = done.length;\n  const pct = count / total;\n  const finished = count === total;\n  const next = allSteps.find((x) => !done.includes(x.id));\n\n  const run = async (step: OnboardingStep) => {\n    if (busy) return;\n    setBusy(step.id);\n    if (onStep) await onStep(step.id);\n    else await new Promise((r) => setTimeout(r, reduce ? 200 : 900));\n    setBusy(null);\n    const nextDone = [...done, step.id];\n    setDone(nextDone);\n    const following = allSteps.find((x) => !nextDone.includes(x.id));\n    setActive(following?.id ?? null);\n    if (!following) setCelebrate((c) => c + 1);\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const check = (on: boolean, size = 18) => (\n    <motion.span className=\"flex shrink-0 items-center justify-center rounded-full border\" style={{ width: size, height: size }} initial={false} animate={{ background: on ? p.green : \"rgba(0,0,0,0)\", borderColor: on ? p.green : p.faint }} transition={{ duration: 0.25 }} aria-hidden=\"true\">\n      <AnimatePresence>\n        {on && (\n          <motion.svg width={size * 0.55} height={size * 0.55} viewBox=\"0 0 16 16\" fill=\"none\" stroke={p.onText} strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={reduce ? false : { scale: 0 }} animate={{ scale: 1 }} exit={{ scale: 0 }}>\n            <motion.path d=\"m3 8.5 3 3 7-7\" initial={reduce ? false : { pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ duration: 0.3, delay: 0.05 }} />\n          </motion.svg>\n        )}\n      </AnimatePresence>\n    </motion.span>\n  );\n\n  return (\n    <section className={cn(\"@container relative w-full overflow-hidden\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"relative mx-auto min-h-[680px] max-w-6xl px-4 py-8 @[640px]:px-6\">\n        {/* Sample dashboard behind the widget */}\n        {showBackdrop && (\n          <div className=\"pointer-events-none grid gap-4 opacity-90 select-none @[720px]:grid-cols-[180px_1fr]\" aria-hidden=\"true\">\n            <div className=\"hidden flex-col gap-2 @[720px]:flex\">\n              <span className=\"mb-3 h-6 w-28 rounded-md\" style={{ background: p.skel }} />\n              {[70, 55, 80, 60, 50].map((w, i) => (\n                <span key={i} className=\"h-3 rounded\" style={{ width: `${w}%`, background: p.skel }} />\n              ))}\n            </div>\n            <div className=\"flex flex-col gap-4\">\n              <span className=\"h-7 w-48 rounded-md\" style={{ background: p.skel }} />\n              <div className=\"grid grid-cols-2 gap-3 @[640px]:grid-cols-4\">\n                {[0, 1, 2, 3].map((i) => (\n                  <span key={i} className=\"h-24 rounded-xl\" style={{ background: p.skel }} />\n                ))}\n              </div>\n              <span className=\"h-64 rounded-xl\" style={{ background: p.skel }} />\n            </div>\n          </div>\n        )}\n\n        <AnimatePresence>\n          {!dismissed && (\n            <motion.div className=\"absolute right-4 bottom-6 left-4 z-10 flex justify-end @[640px]:right-6 @[640px]:left-auto\" initial={reduce ? false : { opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: 16, scale: 0.96 }}>\n              <AnimatePresence mode=\"popLayout\" initial={false}>\n                {open ? (\n                  <motion.div key=\"panel\" layoutId={reduce ? undefined : `${uid}-shell`} className=\"relative w-full max-w-[380px] overflow-hidden rounded-2xl border\" style={{ background: p.card, borderColor: p.border, boxShadow: p.shadow }} role=\"region\" aria-labelledby={`${uid}-title`}>\n                    {/* Confetti */}\n                    {celebrate > 0 && !reduce && (\n                      <div key={celebrate} className=\"pointer-events-none absolute inset-x-0 top-10 z-20 flex justify-center\" aria-hidden=\"true\">\n                        {Array.from({ length: 28 }, (_, i) => {\n                          const angle = (i / 28) * Math.PI * 2;\n                          const dist = 90 + (i % 5) * 22;\n                          return <motion.span key={i} className=\"absolute h-2 w-1 rounded-sm\" style={{ background: CONFETTI[i % CONFETTI.length] }} initial={{ x: 0, y: 0, opacity: 1, rotate: 0 }} animate={{ x: Math.cos(angle) * dist, y: Math.sin(angle) * dist + 60, opacity: 0, rotate: 360 + i * 20 }} transition={{ duration: 1.3, ease: \"easeOut\" }} />;\n                        })}\n                      </div>\n                    )}\n                    <div className=\"flex items-center gap-3 border-b p-4\" style={{ borderColor: p.border }}>\n                      <span className=\"relative flex h-11 w-11 items-center justify-center\">\n                        <Ring pct={pct} size={44} stroke={4} color={finished ? p.green : p.accent} track={p.track} />\n                        <span className=\"absolute text-[11px] font-semibold tabular-nums\">{Math.round(pct * 100)}%</span>\n                      </span>\n                      <div className=\"min-w-0 flex-1\">\n                        <h2 id={`${uid}-title`} className=\"m-0 text-[15px] font-semibold tracking-[-0.01em]\">\n                          {finished ? \"You're all set\" : title}\n                        </h2>\n                        <p className=\"m-0 text-[12px] tabular-nums\" style={{ color: p.muted }} aria-live=\"polite\">\n                          {count} of {total} done{!finished && next?.time ? ` · next takes ${next.time}` : \"\"}\n                        </p>\n                      </div>\n                      <button type=\"button\" onClick={() => setOpen(false)} aria-label=\"Minimize\" className={cn(\"flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg border-0 bg-transparent\", focus)} style={{ color: p.muted, ...ring }}>\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                          <path d=\"m4 6 4 4 4-4\" />\n                        </svg>\n                      </button>\n                    </div>\n\n                    <div className=\"max-h-[420px] overflow-y-auto p-2\">\n                      {finished ? (\n                        <motion.div initial={reduce ? false : { opacity: 0, scale: 0.96 }} animate={{ opacity: 1, scale: 1 }} className=\"px-3 py-6 text-center\">\n                          <p className=\"m-0 text-[32px]\" aria-hidden=\"true\">\n                            🎉\n                          </p>\n                          <p className=\"m-0 mt-2 text-[14px] font-medium\">Setup complete</p>\n                          <p className=\"m-0 mt-1 text-[13px]\" style={{ color: p.muted }}>\n                            You unlocked <span style={{ color: p.green }}>{reward}</span>.\n                          </p>\n                          <button\n                            type=\"button\"\n                            onClick={() => {\n                              setDismissed(true);\n                              onDismiss?.();\n                            }}\n                            className={cn(\"mt-4 h-9 cursor-pointer rounded-lg border-0 px-4 text-[13px] font-medium\", focus)}\n                            style={{ background: p.on, color: p.onText, ...ring }}\n                          >\n                            Close guide\n                          </button>\n                        </motion.div>\n                      ) : (\n                        sectionsProp.map((sec) => {\n                          const secDone = sec.steps.filter((x) => done.includes(x.id)).length;\n                          const complete = secDone === sec.steps.length;\n                          return (\n                            <div key={sec.id} className=\"mb-1\">\n                              <div className=\"flex items-center justify-between px-2.5 pt-2.5 pb-1.5\">\n                                <h3 className=\"m-0 flex items-center gap-2 text-[12px] font-medium tracking-wide uppercase\" style={{ color: complete ? p.green : p.faint }}>\n                                  {complete && check(true, 14)}\n                                  {sec.title}\n                                </h3>\n                                <span className=\"text-[11.5px] tabular-nums\" style={{ color: p.faint }}>\n                                  {secDone}/{sec.steps.length}\n                                </span>\n                              </div>\n                              <ul className=\"m-0 list-none p-0\">\n                                {sec.steps.map((st) => {\n                                  const isDone = done.includes(st.id);\n                                  const isActive = active === st.id && !isDone;\n                                  return (\n                                    <li key={st.id} className=\"rounded-xl\" style={{ background: isActive ? p.chip : \"transparent\" }}>\n                                      <button type=\"button\" aria-expanded={isDone ? undefined : isActive} aria-controls={`${uid}-${st.id}`} disabled={isDone} onClick={() => setActive(isActive ? null : st.id)} className={cn(\"flex w-full cursor-pointer items-center gap-3 rounded-xl border-0 bg-transparent px-2.5 py-2.5 text-left disabled:cursor-default\", focus)} style={{ color: p.text, ...ring }}>\n                                        {check(isDone)}\n                                        <span className=\"min-w-0 flex-1 text-[13.5px]\" style={{ color: isDone ? p.faint : p.text, textDecoration: isDone ? \"line-through\" : undefined }}>\n                                          {st.title}\n                                          <span className=\"sr-only\">{isDone ? \", done\" : \"\"}</span>\n                                        </span>\n                                        {!isDone && st.time && (\n                                          <span className=\"shrink-0 text-[11.5px]\" style={{ color: p.faint }}>\n                                            {st.time}\n                                          </span>\n                                        )}\n                                      </button>\n                                      <AnimatePresence initial={false}>\n                                        {isActive && (\n                                          <motion.div id={`${uid}-${st.id}`} initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.22 }} className=\"overflow-hidden\">\n                                            <div className=\"pr-3 pb-3 pl-[41px]\">\n                                              {st.description && (\n                                                <p className=\"m-0 text-[12.5px] leading-[1.55]\" style={{ color: p.muted }}>\n                                                  {st.description}\n                                                </p>\n                                              )}\n                                              <div className=\"mt-2.5 flex items-center gap-2\">\n                                                <button type=\"button\" onClick={() => run(st)} disabled={!!busy} className={cn(\"flex h-8 cursor-pointer items-center gap-2 rounded-lg border-0 px-3 text-[12.5px] font-medium disabled:cursor-wait\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                                                  {busy === st.id && <motion.span className=\"h-3 w-3 rounded-full border-2\" style={{ borderTopColor: \"transparent\", borderRightColor: p.onText, borderBottomColor: p.onText, borderLeftColor: p.onText }} animate={reduce ? undefined : { rotate: 360 }} transition={{ duration: 0.7, repeat: Infinity, ease: \"linear\" }} aria-hidden=\"true\" />}\n                                                  {busy === st.id ? \"Working…\" : st.action}\n                                                </button>\n                                                <button\n                                                  type=\"button\"\n                                                  disabled={!!busy}\n                                                  onClick={() => {\n                                                    const rest = allSteps.filter((x) => !done.includes(x.id) && x.id !== st.id);\n                                                    setActive(rest[0]?.id ?? null);\n                                                  }}\n                                                  className={cn(\"h-8 cursor-pointer rounded-lg border-0 bg-transparent px-2 text-[12.5px]\", focus)}\n                                                  style={{ color: p.muted, ...ring }}\n                                                >\n                                                  Skip for now\n                                                </button>\n                                              </div>\n                                            </div>\n                                          </motion.div>\n                                        )}\n                                      </AnimatePresence>\n                                    </li>\n                                  );\n                                })}\n                              </ul>\n                            </div>\n                          );\n                        })\n                      )}\n                    </div>\n\n                    {!finished && (\n                      <div className=\"flex items-center justify-between gap-2 border-t px-4 py-2.5 text-[12px]\" style={{ borderColor: p.border, color: p.faint }}>\n                        <span>\n                          Finish to unlock <span style={{ color: p.accent }}>{reward}</span>\n                        </span>\n                        {confirmDismiss ? (\n                          <span className=\"flex items-center gap-1.5\">\n                            Hide guide?\n                            <button\n                              type=\"button\"\n                              onClick={() => {\n                                setDismissed(true);\n                                onDismiss?.();\n                              }}\n                              className={cn(\"cursor-pointer rounded border-0 bg-transparent px-1 font-medium\", focus)}\n                              style={{ color: p.text, ...ring }}\n                            >\n                              Yes\n                            </button>\n                            <button type=\"button\" onClick={() => setConfirmDismiss(false)} className={cn(\"cursor-pointer rounded border-0 bg-transparent px-1\", focus)} style={{ color: p.muted, ...ring }}>\n                              No\n                            </button>\n                          </span>\n                        ) : (\n                          <button type=\"button\" onClick={() => setConfirmDismiss(true)} className={cn(\"cursor-pointer rounded border-0 bg-transparent px-1\", focus)} style={{ color: p.muted, ...ring }}>\n                            Dismiss\n                          </button>\n                        )}\n                      </div>\n                    )}\n                  </motion.div>\n                ) : (\n                  <motion.button key=\"pill\" layoutId={reduce ? undefined : `${uid}-shell`} type=\"button\" onClick={() => setOpen(true)} aria-label={`Open ${title}, ${count} of ${total} done`} className={cn(\"flex h-12 cursor-pointer items-center gap-2.5 rounded-full border py-1 pr-4 pl-1\", focus)} style={{ background: p.card, borderColor: p.border, color: p.text, boxShadow: p.shadow, ...ring }}>\n                    <span className=\"relative flex h-10 w-10 items-center justify-center\">\n                      <Ring pct={pct} size={40} stroke={3.5} color={finished ? p.green : p.accent} track={p.track} />\n                      <span className=\"absolute text-[10.5px] font-semibold tabular-nums\">\n                        {count}/{total}\n                      </span>\n                    </span>\n                    <span className=\"text-left\">\n                      <span className=\"block text-[13px] font-medium\">{finished ? \"All done\" : title}</span>\n                      {next && (\n                        <span className=\"block max-w-[180px] truncate text-[11.5px]\" style={{ color: p.faint }}>\n                          Next: {next.title}\n                        </span>\n                      )}\n                    </span>\n                  </motion.button>\n                )}\n              </AnimatePresence>\n            </motion.div>\n          )}\n        </AnimatePresence>\n        {dismissed && (\n          <div className=\"absolute right-6 bottom-6 z-10\">\n            <button type=\"button\" onClick={() => { setDismissed(false); setConfirmDismiss(false); }} className={cn(\"h-9 cursor-pointer rounded-full border px-3.5 text-[12.5px]\", focus)} style={{ background: p.card, borderColor: p.border, color: p.muted, ...ring }}>\n              Show setup guide\n            </button>\n          </div>\n        )}\n      </div>\n    </section>\n  );\n}\n\nexport default OnboardingChecklistWidget;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}