{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "action-panel",
  "title": "Action Panel",
  "description": "A stack of action panels for an account page, each a title, a sentence and one action that really works: export with progress and a JSON download, two-step verification with recovery codes to copy, an inline billing email change, ownership transfer with a warning step, and leave workspace behind a typed confirmation.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/action-panel/action-panel.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 ActionPanelProps {\n  billingEmail?: string;\n  members?: string[];\n  workspace?: string;\n  onExport?: () => Promise<object> | object;\n  onEmailChange?: (email: string) => void;\n  onTransfer?: (member: string) => void;\n  onLeave?: () => 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: \"#181818\", border: \"rgba(255,255,255,0.09)\", chip: \"rgba(255,255,255,0.06)\", input: \"#0D0D0D\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", amber: \"#FBBF24\", red: \"#F87171\", ring: \"rgba(245,244,241,0.6)\", track: \"rgba(255,255,255,0.08)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", well: \"#FAFAF8\", border: \"rgba(10,10,10,0.09)\", chip: \"rgba(10,10,10,0.05)\", input: \"#FAFAF8\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", amber: \"#B45309\", red: \"#DC2626\", ring: \"rgba(10,10,10,0.5)\", track: \"rgba(10,10,10,0.07)\" },\n};\nconst CODES = [\"4F7Q-2KXM\", \"9TPL-AH3D\", \"XR8C-6N2B\", \"M3VD-QW7E\", \"J8KZ-5UYP\", \"B2HN-T9RF\"];\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nexport function ActionPanel({ billingEmail = \"billing@nexora.io\", members = [\"Daniel Reyes\", \"Lena Brandt\", \"Tomás Ferreira\"], workspace = \"Nexora\", onExport, onEmailChange, onTransfer, onLeave, theme = \"dark\", className }: ActionPanelProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [exportState, setExportState] = React.useState<\"idle\" | \"working\" | \"ready\">(\"idle\");\n  const [progress, setProgress] = React.useState(0);\n  const [file, setFile] = React.useState<string | null>(null);\n  const [mfa, setMfa] = React.useState(false);\n  const [codesCopied, setCodesCopied] = React.useState(false);\n  const [email, setEmail] = React.useState(billingEmail);\n  const [draft, setDraft] = React.useState(billingEmail);\n  const [editingEmail, setEditingEmail] = React.useState(false);\n  const [emailSaved, setEmailSaved] = React.useState(false);\n  const [owner, setOwner] = React.useState(\"\");\n  const [transferStep, setTransferStep] = React.useState<0 | 1 | 2>(0);\n  const [leaveText, setLeaveText] = React.useState(\"\");\n  const [left, setLeft] = React.useState(false);\n  const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);\n  // Stable callback ref: focuses an element once when it mounts.\n  const focusOnce = React.useCallback((el: HTMLElement | null) => el?.focus({ preventScroll: true }), []);\n  const focusSelect = React.useCallback((el: HTMLInputElement | null) => {\n    el?.focus({ preventScroll: true });\n    el?.select();\n  }, []);\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach(clearTimeout);\n  }, []);\n  React.useEffect(\n    () => () => {\n      if (file) URL.revokeObjectURL(file);\n    },\n    [file],\n  );\n  React.useEffect(() => {\n    if (!codesCopied && !emailSaved) return;\n    const t = setTimeout(() => {\n      setCodesCopied(false);\n      setEmailSaved(false);\n    }, 1800);\n    return () => clearTimeout(t);\n  }, [codesCopied, emailSaved]);\n\n  const startExport = async () => {\n    setExportState(\"working\");\n    setProgress(0);\n    const steps = reduce ? 1 : 12;\n    for (let i = 1; i <= steps; i++) timers.current.push(setTimeout(() => setProgress(i / steps), i * 120));\n    const data = onExport ? await onExport() : { workspace, exportedAt: \"2026-11-01T15:00:00Z\", members: members.length + 1, projects: 14, documents: 238 };\n    timers.current.push(\n      setTimeout(() => {\n        setFile(URL.createObjectURL(new Blob([JSON.stringify(data, null, 2)], { type: \"application/json\" })));\n        setExportState(\"ready\");\n      }, steps * 120 + 150),\n    );\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 btn = cn(\"flex h-9 shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3.5 text-[13px] font-medium disabled:cursor-not-allowed disabled:opacity-40\", focus);\n  const panel = (id: string, title: string, desc: React.ReactNode, action: React.ReactNode, body?: React.ReactNode, danger = false) => (\n    <section className=\"rounded-2xl border p-5 @[640px]:p-6\" style={{ background: p.card, borderColor: danger ? `${p.red}66` : p.border }} aria-labelledby={`${uid}-${id}`}>\n      <div className=\"flex flex-col gap-4 @[640px]:flex-row @[640px]:items-start @[640px]:justify-between\">\n        <div className=\"min-w-0 @[640px]:max-w-[60%]\">\n          <h3 id={`${uid}-${id}`} className=\"m-0 text-[15px] font-semibold\" style={{ color: danger ? p.red : p.text }}>\n            {title}\n          </h3>\n          <div className=\"mt-1 text-[13.5px] leading-[1.55]\" style={{ color: p.muted }}>\n            {desc}\n          </div>\n        </div>\n        {action}\n      </div>\n      {body}\n    </section>\n  );\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto flex max-w-3xl flex-col gap-3 px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        {/* Export */}\n        {panel(\n          \"export\",\n          \"Export your data\",\n          \"Download every project, document and member list as a single JSON file.\",\n          <AnimatePresence mode=\"wait\" initial={false}>\n            {exportState === \"ready\" && file ? (\n              <motion.a key=\"dl\" href={file} download={`${workspace.toLowerCase()}-export.json`} initial={reduce ? false : { opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} className={cn(btn, \"no-underline\")} style={{ background: p.green, color: p.onText, ...ring }}>\n                <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"M12 4v11m0 0-4-4m4 4 4-4M5 20h14\" />\n                </svg>\n                Download export\n              </motion.a>\n            ) : (\n              <motion.button key=\"go\" type=\"button\" onClick={startExport} disabled={exportState === \"working\"} className={cn(btn, \"border\")} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                {exportState === \"working\" ? `Preparing… ${Math.round(progress * 100)}%` : \"Start export\"}\n              </motion.button>\n            )}\n          </AnimatePresence>,\n          <AnimatePresence initial={false}>\n            {exportState === \"working\" && (\n              <motion.div initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} className=\"overflow-hidden\">\n                <div className=\"mt-4 h-1.5 overflow-hidden rounded-full\" style={{ background: p.track }} role=\"progressbar\" aria-label=\"Export progress\" aria-valuenow={Math.round(progress * 100)} aria-valuemin={0} aria-valuemax={100}>\n                  <motion.div className=\"h-full rounded-full\" style={{ background: p.on }} animate={{ width: `${progress * 100}%` }} transition={{ duration: 0.12 }} />\n                </div>\n              </motion.div>\n            )}\n          </AnimatePresence>,\n        )}\n\n        {/* 2FA */}\n        {panel(\n          \"mfa\",\n          \"Two-step verification\",\n          mfa ? <span style={{ color: p.green }}>On. You will be asked for a code from your authenticator app.</span> : \"Add a second step when you sign in, using an authenticator app.\",\n          <button type=\"button\" role=\"switch\" aria-checked={mfa} aria-labelledby={`${uid}-mfa`} onClick={() => setMfa((m) => !m)} className={cn(\"relative h-6 w-11 shrink-0 cursor-pointer rounded-full border-0 transition-colors\", focus)} style={{ background: mfa ? p.green : p.chip, ...ring }}>\n            <motion.span className=\"absolute top-0.5 h-5 w-5 rounded-full shadow\" style={{ background: mfa ? \"#fff\" : p.faint }} initial={false} animate={{ left: mfa ? 22 : 2 }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 600, damping: 34 }} />\n          </button>,\n          <AnimatePresence initial={false}>\n            {mfa && (\n              <motion.div initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} className=\"overflow-hidden\">\n                <div className=\"mt-4 rounded-xl border p-4\" style={{ borderColor: p.border, background: p.well }}>\n                  <div className=\"flex items-center justify-between gap-3\">\n                    <p className=\"m-0 text-[13px] font-medium\">Recovery codes</p>\n                    <button\n                      type=\"button\"\n                      onClick={() => {\n                        navigator.clipboard?.writeText(CODES.join(\"\\n\")).catch(() => {});\n                        setCodesCopied(true);\n                      }}\n                      className={cn(\"h-7 cursor-pointer rounded-md border bg-transparent px-2.5 text-[12px]\", focus)}\n                      style={{ borderColor: p.border, color: codesCopied ? p.green : p.text, ...ring }}\n                    >\n                      {codesCopied ? \"✓ Copied\" : \"Copy all\"}\n                    </button>\n                  </div>\n                  <p className=\"m-0 mt-1 text-[12px]\" style={{ color: p.faint }}>\n                    Keep them somewhere safe. Each one works once if you lose your phone.\n                  </p>\n                  <ul className=\"m-0 mt-3 grid list-none grid-cols-2 gap-1.5 p-0 font-mono text-[12.5px] @[480px]:grid-cols-3\">\n                    {CODES.map((c, i) => (\n                      <motion.li key={c} initial={reduce ? false : { opacity: 0, y: 4 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: reduce ? 0 : 0.05 * i }} className=\"rounded-md px-2 py-1.5 text-center\" style={{ background: p.chip }}>\n                        {c}\n                      </motion.li>\n                    ))}\n                  </ul>\n                </div>\n              </motion.div>\n            )}\n          </AnimatePresence>,\n        )}\n\n        {/* Billing email */}\n        {panel(\n          \"email\",\n          \"Billing email\",\n          <>\n            Invoices and receipts go to <span style={{ color: p.text }}>{email}</span>.\n            <AnimatePresence>\n              {emailSaved && (\n                <motion.span initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} exit={reduce ? undefined : { opacity: 0 }} className=\"ml-1.5\" style={{ color: p.green }} role=\"status\">\n                  Saved\n                </motion.span>\n              )}\n            </AnimatePresence>\n          </>,\n          !editingEmail ? (\n            <button type=\"button\" onClick={() => { setDraft(email); setEditingEmail(true); }} className={cn(btn, \"border\")} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n              Change\n            </button>\n          ) : null,\n          <AnimatePresence initial={false}>\n            {editingEmail && (\n              <motion.form\n                initial={reduce ? false : { height: 0, opacity: 0 }}\n                animate={{ height: \"auto\", opacity: 1 }}\n                exit={reduce ? undefined : { height: 0, opacity: 0 }}\n                className=\"overflow-hidden\"\n                onSubmit={(e) => {\n                  e.preventDefault();\n                  if (!EMAIL.test(draft)) return;\n                  setEmail(draft);\n                  setEditingEmail(false);\n                  setEmailSaved(true);\n                  onEmailChange?.(draft);\n                }}\n              >\n                <div className=\"mt-4 flex flex-col gap-2 @[560px]:flex-row\">\n                  <label htmlFor={`${uid}-em`} className=\"sr-only\">\n                    New billing email\n                  </label>\n                  <input id={`${uid}-em`} ref={focusSelect} type=\"email\" value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => e.key === \"Escape\" && setEditingEmail(false)} aria-invalid={!EMAIL.test(draft)} className={cn(\"h-9 min-w-0 flex-1 rounded-lg border px-3 text-[13.5px]\", focus)} style={{ borderColor: EMAIL.test(draft) ? p.border : p.red, background: p.input, color: p.text, ...ring }} />\n                  <div className=\"flex gap-2\">\n                    <button type=\"button\" onClick={() => setEditingEmail(false)} className={cn(btn, \"border\")} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                      Cancel\n                    </button>\n                    <button type=\"submit\" disabled={!EMAIL.test(draft) || draft === email} className={cn(btn, \"border-0\")} style={{ background: p.on, color: p.onText, ...ring }}>\n                      Save\n                    </button>\n                  </div>\n                </div>\n              </motion.form>\n            )}\n          </AnimatePresence>,\n        )}\n\n        {/* Transfer */}\n        {panel(\n          \"transfer\",\n          \"Transfer ownership\",\n          transferStep === 2 ? <span style={{ color: p.green }}>{owner} now owns {workspace}. You are an admin.</span> : `Make someone else the owner of ${workspace}. You will become an admin.`,\n          transferStep === 2 ? null : (\n            <div className=\"flex shrink-0 gap-2\">\n              <label htmlFor={`${uid}-own`} className=\"sr-only\">\n                New owner\n              </label>\n              <select id={`${uid}-own`} value={owner} onChange={(e) => { setOwner(e.target.value); setTransferStep(0); }} className={cn(\"h-9 cursor-pointer rounded-lg border px-2.5 text-[13px]\", focus)} style={{ borderColor: p.border, background: p.input, color: owner ? p.text : p.faint, ...ring }}>\n                <option value=\"\">Choose a member</option>\n                {members.map((m) => (\n                  <option key={m}>{m}</option>\n                ))}\n              </select>\n              <button type=\"button\" disabled={!owner} onClick={() => setTransferStep(1)} className={cn(btn, \"border\")} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                Transfer\n              </button>\n            </div>\n          ),\n          <AnimatePresence initial={false}>\n            {transferStep === 1 && (\n              <motion.div initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} className=\"overflow-hidden\" role=\"alertdialog\" aria-labelledby={`${uid}-tw`}>\n                <div className=\"mt-4 flex flex-col gap-3 rounded-xl border p-4 @[560px]:flex-row @[560px]:items-center @[560px]:justify-between\" style={{ borderColor: `${p.amber}66`, background: p.well }}>\n                  <p id={`${uid}-tw`} className=\"m-0 flex gap-2 text-[13px]\" style={{ color: p.text }}>\n                    <span style={{ color: p.amber }} aria-hidden=\"true\">\n                      ⚠\n                    </span>\n                    {owner} will control billing and can remove you. This can only be undone by them.\n                  </p>\n                  <div className=\"flex shrink-0 gap-2\">\n                    <button type=\"button\" ref={focusOnce} onClick={() => setTransferStep(0)} className={cn(btn, \"border\")} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                      Cancel\n                    </button>\n                    <button\n                      type=\"button\"\n                      onClick={() => {\n                        setTransferStep(2);\n                        onTransfer?.(owner);\n                      }}\n                      className={cn(btn, \"border-0\")}\n                      style={{ background: p.amber, color: \"#0A0A0A\", ...ring }}\n                    >\n                      Yes, transfer\n                    </button>\n                  </div>\n                </div>\n              </motion.div>\n            )}\n          </AnimatePresence>,\n        )}\n\n        {/* Leave */}\n        {panel(\n          \"leave\",\n          \"Leave workspace\",\n          left ? <span style={{ color: p.text }}>You left {workspace}. Ask an admin to invite you back.</span> : `You lose access to ${workspace} right away. Type LEAVE to confirm.`,\n          left ? (\n            <button type=\"button\" onClick={() => { setLeft(false); setLeaveText(\"\"); }} className={cn(btn, \"border\")} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n              Undo\n            </button>\n          ) : (\n            <div className=\"flex shrink-0 gap-2\">\n              <label htmlFor={`${uid}-lv`} className=\"sr-only\">\n                Type LEAVE to confirm\n              </label>\n              <input id={`${uid}-lv`} value={leaveText} onChange={(e) => setLeaveText(e.target.value)} placeholder=\"LEAVE\" autoComplete=\"off\" className={cn(\"h-9 w-28 rounded-lg border px-3 font-mono text-[13px]\", focus)} style={{ borderColor: p.border, background: p.input, color: p.text, ...ring }} />\n              <button\n                type=\"button\"\n                disabled={leaveText !== \"LEAVE\"}\n                onClick={() => {\n                  setLeft(true);\n                  onLeave?.();\n                }}\n                className={cn(btn, \"border-0\")}\n                style={{ background: p.red, color: \"#fff\", ...ring }}\n              >\n                Leave\n              </button>\n            </div>\n          ),\n          undefined,\n          true,\n        )}\n      </div>\n    </section>\n  );\n}\n\nexport default ActionPanel;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}