{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "account-setup-sections",
  "title": "Account Setup Sections",
  "description": "A first-run account setup in collapsible sections: profile with avatar color and role chips, workspace name with an auto-generated URL, email invites as chips with validation, preferences, a segmented progress bar, completed sections that collapse to an editable summary, an optional skip and a finish card.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/account-setup-sections/account-setup-sections.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 AccountSetupValue {\n  name: string;\n  role: string;\n  color: string;\n  workspace: string;\n  slug: string;\n  invites: string[];\n  timezone: string;\n  digest: boolean;\n}\n\nexport interface AccountSetupSectionsProps {\n  defaultValue?: Partial<AccountSetupValue>;\n  onComplete?: (value: AccountSetupValue) => void;\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: \"#121212\", well: \"rgba(255,255,255,0.035)\", border: \"rgba(255,255,255,0.09)\", input: \"#0D0D0D\", track: \"rgba(255,255,255,0.1)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", red: \"#F87171\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.42)\", card: \"#FFFFFF\", well: \"rgba(10,10,10,0.03)\", border: \"rgba(10,10,10,0.1)\", input: \"#FAFAF8\", track: \"rgba(10,10,10,0.1)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", red: \"#DC2626\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst COLORS = [\"#60A5FA\", \"#A78BFA\", \"#F472B6\", \"#FB923C\", \"#34D399\", \"#FBBF24\"];\nconst ROLES = [\"Founder\", \"Engineering\", \"Design\", \"Product\", \"Marketing\", \"Operations\"];\nconst ZONES = [\"Europe/Berlin (GMT+1)\", \"Europe/London (GMT)\", \"America/New_York (GMT-5)\", \"America/Los_Angeles (GMT-8)\", \"Asia/Tokyo (GMT+9)\"];\nconst SECTIONS = [\n  { id: \"profile\", title: \"Your profile\", hint: \"How teammates will see you\" },\n  { id: \"workspace\", title: \"Workspace\", hint: \"Name your team's home\" },\n  { id: \"invite\", title: \"Invite teammates\", hint: \"Optional · you can do this later\", optional: true },\n  { id: \"prefs\", title: \"Preferences\", hint: \"Time zone and email digest\" },\n] as const;\ntype Id = (typeof SECTIONS)[number][\"id\"];\n\nconst slugify = (s: string) =>\n  s\n    .toLowerCase()\n    .normalize(\"NFKD\")\n    .replace(/[̀-ͯ]/g, \"\")\n    .replace(/[^a-z0-9]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\")\n    .slice(0, 32);\nconst initials = (s: string) =>\n  s\n    .trim()\n    .split(/\\s+/)\n    .slice(0, 2)\n    .map((w) => w[0]?.toUpperCase() ?? \"\")\n    .join(\"\") || \"?\";\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nexport function AccountSetupSections({ defaultValue, onComplete, theme = \"dark\", className }: AccountSetupSectionsProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [v, setV] = React.useState<AccountSetupValue>({ name: \"\", role: \"\", color: COLORS[0], workspace: \"\", slug: \"\", invites: [], timezone: ZONES[0], digest: true, ...defaultValue });\n  const [slugEdited, setSlugEdited] = React.useState(false);\n  const [open, setOpen] = React.useState<Id | null>(\"profile\");\n  const [done, setDone] = React.useState<Record<Id, \"done\" | \"skipped\" | undefined>>({ profile: undefined, workspace: undefined, invite: undefined, prefs: undefined });\n  const [draft, setDraft] = React.useState(\"\");\n  const [inviteError, setInviteError] = React.useState<string | null>(null);\n  const [finished, setFinished] = React.useState(false);\n\n  const complete = SECTIONS.filter((s) => done[s.id]).length;\n  const canContinue: Record<Id, boolean> = {\n    profile: v.name.trim().length > 1 && !!v.role,\n    workspace: v.workspace.trim().length > 1 && v.slug.length > 2,\n    invite: v.invites.length > 0,\n    prefs: true,\n  };\n  const set = <K extends keyof AccountSetupValue>(k: K, val: AccountSetupValue[K]) => setV((s) => ({ ...s, [k]: val }));\n  const advance = (id: Id, how: \"done\" | \"skipped\") => {\n    const nextDone = { ...done, [id]: how };\n    setDone(nextDone);\n    const nextOpen = SECTIONS.find((s) => !nextDone[s.id]);\n    setOpen(nextOpen ? nextOpen.id : null);\n    if (!nextOpen) {\n      setFinished(true);\n      onComplete?.(v);\n    }\n  };\n  const addInvites = (raw: string) => {\n    const parts = raw.split(/[\\s,;]+/).filter(Boolean);\n    const bad = parts.find((x) => !EMAIL.test(x));\n    if (bad) {\n      setInviteError(`“${bad}” doesn't look like an email`);\n      return false;\n    }\n    setInviteError(null);\n    setV((s) => ({ ...s, invites: [...s.invites, ...parts.filter((x) => !s.invites.includes(x.toLowerCase())).map((x) => x.toLowerCase())] }));\n    return true;\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 input = cn(\"h-9 w-full rounded-lg border px-3 text-[13.5px] outline-none focus-visible:ring-2\");\n  const inputStyle = { borderColor: p.border, background: p.input, color: p.text, ...ring };\n  const label = \"mb-1.5 block text-[12.5px] font-medium\";\n  const btn = cn(\"flex h-9 shrink-0 cursor-pointer items-center justify-center rounded-lg px-3.5 text-[13px] font-medium disabled:cursor-not-allowed disabled:opacity-40\", focus);\n  const fold = reduce ? {} : { initial: { height: 0, opacity: 0 }, animate: { height: \"auto\", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.28, ease: [0.22, 1, 0.36, 1] as const } };\n\n  const summary: Record<Id, React.ReactNode> = {\n    profile: v.name ? `${v.name} · ${v.role}` : null,\n    workspace: v.workspace ? `${v.workspace} · nexora.app/${v.slug}` : null,\n    invite: done.invite === \"skipped\" ? \"Skipped\" : `${v.invites.length} ${v.invites.length === 1 ? \"invite\" : \"invites\"} ready to send`,\n    prefs: `${v.timezone.split(\" \")[0]} · ${v.digest ? \"weekly digest on\" : \"no digest\"}`,\n  };\n\n  const body = (id: Id) => {\n    if (id === \"profile\")\n      return (\n        <div className=\"grid grid-cols-1 gap-4 @[560px]:grid-cols-[auto_minmax(0,1fr)]\">\n          <div className=\"flex items-center gap-3 @[560px]:flex-col\">\n            <motion.span key={v.color} initial={reduce ? false : { scale: 0.85 }} animate={{ scale: 1 }} className=\"grid h-14 w-14 shrink-0 place-items-center rounded-full text-[18px] font-semibold text-[#0A0A0A]\" style={{ background: v.color }} aria-hidden=\"true\">\n              {initials(v.name)}\n            </motion.span>\n            <div role=\"radiogroup\" aria-label=\"Avatar color\" className=\"flex gap-1.5 @[560px]:grid @[560px]:grid-cols-3\">\n              {COLORS.map((c) => (\n                <button key={c} type=\"button\" role=\"radio\" aria-checked={v.color === c} aria-label={`Color ${c}`} onClick={() => set(\"color\", c)} className={cn(\"h-5 w-5 cursor-pointer rounded-full border-2\", focus)} style={{ background: c, borderColor: v.color === c ? p.text : \"transparent\", ...ring }} />\n              ))}\n            </div>\n          </div>\n          <div className=\"flex flex-col gap-3\">\n            <div>\n              <label htmlFor={`${uid}-name`} className={label}>\n                Full name\n              </label>\n              <input id={`${uid}-name`} value={v.name} onChange={(e) => set(\"name\", e.target.value)} autoComplete=\"name\" placeholder=\"Lena Hartmann\" className={input} style={inputStyle} />\n            </div>\n            <div>\n              <span className={label} id={`${uid}-role`}>\n                What do you do?\n              </span>\n              <div role=\"radiogroup\" aria-labelledby={`${uid}-role`} className=\"flex flex-wrap gap-1.5\">\n                {ROLES.map((r) => (\n                  <button key={r} type=\"button\" role=\"radio\" aria-checked={v.role === r} onClick={() => set(\"role\", r)} className={cn(\"h-8 cursor-pointer rounded-full border px-3 text-[12.5px] transition-colors\", focus)} style={{ borderColor: v.role === r ? p.text : p.border, background: v.role === r ? p.on : \"transparent\", color: v.role === r ? p.onText : p.muted, ...ring }}>\n                    {r}\n                  </button>\n                ))}\n              </div>\n            </div>\n          </div>\n        </div>\n      );\n    if (id === \"workspace\")\n      return (\n        <div className=\"flex flex-col gap-3\">\n          <div>\n            <label htmlFor={`${uid}-ws`} className={label}>\n              Workspace name\n            </label>\n            <input\n              id={`${uid}-ws`}\n              value={v.workspace}\n              onChange={(e) => {\n                const w = e.target.value;\n                setV((s) => ({ ...s, workspace: w, slug: slugEdited ? s.slug : slugify(w) }));\n              }}\n              placeholder=\"Halden Studio\"\n              className={input}\n              style={inputStyle}\n            />\n          </div>\n          <div>\n            <label htmlFor={`${uid}-slug`} className={label}>\n              Workspace URL\n            </label>\n            <div className=\"flex h-9 items-center overflow-hidden rounded-lg border focus-within:ring-2\" style={inputStyle}>\n              <span className=\"flex h-full shrink-0 items-center border-r px-3 text-[13px]\" style={{ borderColor: p.border, color: p.faint, background: p.well }}>\n                nexora.app/\n              </span>\n              <input\n                id={`${uid}-slug`}\n                value={v.slug}\n                onChange={(e) => {\n                  setSlugEdited(true);\n                  set(\"slug\", slugify(e.target.value));\n                }}\n                className=\"h-full min-w-0 flex-1 border-0 bg-transparent px-2.5 text-[13.5px] outline-none\"\n                style={{ color: p.text }}\n              />\n              <AnimatePresence>\n                {v.slug.length > 2 && (\n                  <motion.span key=\"ok\" initial={reduce ? false : { opacity: 0, scale: 0.6 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0 }} className=\"mr-2.5 shrink-0 text-[12px]\" style={{ color: p.green }}>\n                    ✓ Available\n                  </motion.span>\n                )}\n              </AnimatePresence>\n            </div>\n          </div>\n        </div>\n      );\n    if (id === \"invite\")\n      return (\n        <div>\n          <label htmlFor={`${uid}-inv`} className={label}>\n            Email addresses\n          </label>\n          <div className=\"flex min-h-9 flex-wrap items-center gap-1.5 rounded-lg border px-2 py-1.5 focus-within:ring-2\" style={{ ...inputStyle, borderColor: inviteError ? p.red : p.border }}>\n            <AnimatePresence initial={false}>\n              {v.invites.map((e) => (\n                <motion.span key={e} layout={!reduce} initial={reduce ? false : { opacity: 0, scale: 0.8 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0, scale: 0.8 }} className=\"flex items-center gap-1 rounded-md py-0.5 pr-1 pl-2 text-[12.5px]\" style={{ background: p.track }}>\n                  {e}\n                  <button type=\"button\" onClick={() => set(\"invites\", v.invites.filter((x) => x !== e))} aria-label={`Remove ${e}`} className={cn(\"grid h-4 w-4 cursor-pointer place-items-center rounded border-0 bg-transparent p-0 text-[13px] leading-none\", focus)} style={{ color: p.faint, ...ring }}>\n                    ×\n                  </button>\n                </motion.span>\n              ))}\n            </AnimatePresence>\n            <input\n              id={`${uid}-inv`}\n              value={draft}\n              onChange={(e) => {\n                setDraft(e.target.value);\n                setInviteError(null);\n              }}\n              onKeyDown={(e) => {\n                if ((e.key === \"Enter\" || e.key === \",\" || e.key === \" \") && draft.trim()) {\n                  e.preventDefault();\n                  if (addInvites(draft)) setDraft(\"\");\n                } else if (e.key === \"Backspace\" && !draft && v.invites.length) set(\"invites\", v.invites.slice(0, -1));\n              }}\n              onBlur={() => draft.trim() && addInvites(draft) && setDraft(\"\")}\n              placeholder={v.invites.length ? \"\" : \"name@company.com, press Enter\"}\n              aria-invalid={!!inviteError || undefined}\n              aria-describedby={`${uid}-inv-h`}\n              className=\"h-6 min-w-[120px] flex-1 border-0 bg-transparent px-1 text-[13.5px] outline-none\"\n              style={{ color: p.text }}\n            />\n          </div>\n          <p id={`${uid}-inv-h`} className=\"m-0 mt-1.5 text-[12px]\" style={{ color: inviteError ? p.red : p.faint }} role={inviteError ? \"alert\" : undefined}>\n            {inviteError ?? \"They'll join as members. You can change roles later.\"}\n          </p>\n        </div>\n      );\n    return (\n      <div className=\"flex flex-col gap-3\">\n        <div>\n          <label htmlFor={`${uid}-tz`} className={label}>\n            Time zone\n          </label>\n          <select id={`${uid}-tz`} value={v.timezone} onChange={(e) => set(\"timezone\", e.target.value)} className={cn(input, \"cursor-pointer\")} style={inputStyle}>\n            {ZONES.map((z) => (\n              <option key={z}>{z}</option>\n            ))}\n          </select>\n        </div>\n        <label className=\"flex cursor-pointer items-start gap-2.5 text-[12.5px]\" style={{ color: p.muted }}>\n          <input type=\"checkbox\" checked={v.digest} onChange={(e) => set(\"digest\", e.target.checked)} className=\"mt-0.5 h-3.5 w-3.5 shrink-0 cursor-pointer\" style={{ accentColor: p.green }} />\n          <span>\n            <span className=\"block font-medium\" style={{ color: p.text }}>\n              Weekly digest\n            </span>\n            A Monday email with what changed in your workspace.\n          </span>\n        </label>\n      </div>\n    );\n  };\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-2xl px-4 py-10 @[640px]:px-6\">\n        <div className=\"flex flex-wrap items-end justify-between gap-3\">\n          <div>\n            <h2 className=\"m-0 text-[22px] font-semibold tracking-[-0.01em]\">Set up your account</h2>\n            <p className=\"m-0 mt-1 text-[13.5px]\" style={{ color: p.muted }}>\n              A few details so Nexora feels like yours. Takes about two minutes.\n            </p>\n          </div>\n          <span className=\"text-[12.5px] tabular-nums\" style={{ color: p.muted }} aria-live=\"polite\">\n            {complete} of {SECTIONS.length} complete\n          </span>\n        </div>\n        <div className=\"mt-4 grid grid-cols-4 gap-1.5\" aria-hidden=\"true\">\n          {SECTIONS.map((s) => (\n            <span key={s.id} className=\"h-1 overflow-hidden rounded-full\" style={{ background: p.track }}>\n              <motion.span className=\"block h-full rounded-full\" initial={false} animate={{ width: done[s.id] ? \"100%\" : open === s.id ? \"35%\" : \"0%\", backgroundColor: done[s.id] === \"skipped\" ? p.faint : p.green }} transition={{ duration: reduce ? 0 : 0.45, ease: [0.22, 1, 0.36, 1] }} />\n            </span>\n          ))}\n        </div>\n\n        <ol className=\"m-0 mt-5 flex list-none flex-col gap-2.5 p-0\">\n          {SECTIONS.map((s, i) => {\n            const isOpen = open === s.id;\n            const state = done[s.id];\n            return (\n              <li key={s.id} className=\"overflow-hidden rounded-2xl border transition-colors\" style={{ background: p.card, borderColor: isOpen ? p.ring.replace(/[\\d.]+\\)$/, \"0.28)\") : p.border }}>\n                <h3 className=\"m-0\">\n                  <button type=\"button\" onClick={() => setOpen(isOpen ? null : s.id)} aria-expanded={isOpen} aria-controls={`${uid}-${s.id}`} className={cn(\"flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-4 py-3.5 text-left\", focus)} style={{ color: p.text, ...ring }}>\n                    <span className=\"grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12px] font-semibold transition-colors\" style={{ background: state === \"done\" ? p.green : isOpen ? p.on : p.track, color: state === \"done\" || isOpen ? p.onText : p.muted }}>\n                      {state === \"done\" ? (\n                        <motion.svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={reduce ? false : { scale: 0, rotate: -30 }} animate={{ scale: 1, rotate: 0 }} aria-hidden=\"true\">\n                          <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n                        </motion.svg>\n                      ) : (\n                        i + 1\n                      )}\n                    </span>\n                    <span className=\"min-w-0 flex-1\">\n                      <span className=\"block text-[14px] font-medium\">{s.title}</span>\n                      <span className=\"block truncate text-[12px]\" style={{ color: state && !isOpen ? (state === \"done\" ? p.muted : p.faint) : p.faint }}>\n                        {state && !isOpen ? summary[s.id] : s.hint}\n                      </span>\n                    </span>\n                    {state && !isOpen && (\n                      <span className=\"text-[12px]\" style={{ color: p.muted }}>\n                        Edit\n                      </span>\n                    )}\n                    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" className=\"shrink-0 transition-transform\" style={{ color: p.faint, transform: isOpen ? \"rotate(180deg)\" : undefined }} aria-hidden=\"true\">\n                      <path d=\"m6 9 6 6 6-6\" />\n                    </svg>\n                  </button>\n                </h3>\n                <AnimatePresence initial={false}>\n                  {isOpen && (\n                    <motion.div key=\"b\" id={`${uid}-${s.id}`} role=\"region\" aria-label={s.title} {...fold} className=\"overflow-hidden\">\n                      <div className=\"px-4 pb-4 @[480px]:pl-14\">\n                        {body(s.id)}\n                        <div className=\"mt-4 flex flex-wrap items-center justify-end gap-2\">\n                          {\"optional\" in s && s.optional && (\n                            <button type=\"button\" onClick={() => advance(s.id, \"skipped\")} className={cn(btn, \"mr-auto border-0 bg-transparent px-0\")} style={{ color: p.muted, ...ring }}>\n                              Skip for now\n                            </button>\n                          )}\n                          <button type=\"button\" disabled={!canContinue[s.id]} onClick={() => advance(s.id, \"done\")} className={cn(btn, \"border-0\")} style={{ background: p.on, color: p.onText, ...ring }}>\n                            {SECTIONS.filter((x) => x.id !== s.id && !done[x.id]).length === 0 ? \"Finish setup\" : \"Continue\"}\n                          </button>\n                        </div>\n                      </div>\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </li>\n            );\n          })}\n        </ol>\n\n        <AnimatePresence>\n          {finished && complete === SECTIONS.length && (\n            <motion.div key=\"fin\" role=\"status\" initial={reduce ? false : { opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} className=\"mt-4 flex flex-wrap items-center gap-3 rounded-2xl border p-4\" style={{ borderColor: `${p.green}55`, background: `${p.green}12` }}>\n              <span className=\"grid h-9 w-9 shrink-0 place-items-center rounded-full text-[15px] font-semibold text-[#0A0A0A]\" style={{ background: v.color }} aria-hidden=\"true\">\n                {initials(v.name)}\n              </span>\n              <span className=\"min-w-0 flex-1\">\n                <span className=\"block text-[14px] font-semibold\">You&apos;re all set{v.name ? `, ${v.name.split(\" \")[0]}` : \"\"}</span>\n                <span className=\"block text-[12.5px]\" style={{ color: p.muted }}>\n                  {v.workspace || \"Your workspace\"} is ready{v.invites.length ? ` · ${v.invites.length} ${v.invites.length === 1 ? \"invite\" : \"invites\"} sent` : \"\"}.\n                </span>\n              </span>\n              <a href=\"#\" className={cn(btn, \"no-underline\")} style={{ background: p.on, color: p.onText, ...ring }}>\n                Go to dashboard →\n              </a>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </section>\n  );\n}\n\nexport default AccountSetupSections;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}