{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog-transfer-confirm",
  "type": "registry:component",
  "title": "Transfer Confirm Dialog",
  "description": "A high-stakes confirmation that shows ownership moving between two people and stays locked until the user ticks an acknowledgement. On success the crown hops from one avatar to the other.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "confirm",
    "dialog",
    "ownership",
    "acknowledge",
    "async",
    "modal"
  ],
  "docs": "https://hyperblur.dev/effects/dialog-transfer-confirm",
  "files": [
    {
      "path": "registry/hyperblur/dialog-transfer-confirm.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/dialog-transfer-confirm.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TransferPerson {\n  name: string;\n  role: string;\n  colors?: [string, string];\n}\n\nexport interface DialogTransferConfirmProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  embedded?: boolean;\n  trigger?: React.ReactNode;\n  workspace?: string;\n  description?: string;\n  from?: TransferPerson;\n  to?: TransferPerson;\n  consequences?: string[];\n  acknowledgement?: string;\n  confirmLabel?: string;\n  onConfirm?: () => void | Promise<void>;\n  accent?: string;\n}\n\nconst defaultFrom: TransferPerson = { name: \"Sam Okafor\", role: \"Owner\", colors: [\"#fbbf24\", \"#f97316\"] };\nconst defaultTo: TransferPerson = { name: \"Jordan Lee\", role: \"Admin\", colors: [\"#67e8f9\", \"#6366f1\"] };\nconst defaultConsequences = [\n  \"You become an Admin of the workspace\",\n  \"Billing, invoices and the card on file move to Jordan\",\n  \"Only the new owner can delete the workspace\",\n];\n\nconst css = `\n.hb-xe6 { --hb-xe6-accent: #f43f5e; display: inline-block; box-sizing: border-box; color: #ededed; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); }\n.hb-xe6 *, .hb-xe6 *::before, .hb-xe6 *::after { box-sizing: border-box; }\n.hb-xe6[data-embedded] { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-height: 190px; border-radius: 16px; overflow: hidden; isolation: isolate; background: #0b0b0c; }\n.hb-xe6-trigger { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px; border: 1px solid color-mix(in srgb, var(--hb-xe6-accent) 35%, #2a2a2c); border-radius: 9px; background: color-mix(in srgb, var(--hb-xe6-accent) 8%, #121213); color: color-mix(in srgb, var(--hb-xe6-accent) 55%, #fff); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; transition: background-color 0.2s ease, transform 0.15s ease; }\n.hb-xe6-trigger:hover { background: color-mix(in srgb, var(--hb-xe6-accent) 14%, #121213); }\n.hb-xe6-trigger:active { transform: scale(0.97); }\n.hb-xe6-trigger svg { width: 14px; height: 14px; }\n.hb-xe6 button:focus-visible, .hb-xe6-check:focus-within .hb-xe6-box { outline: 2px solid var(--hb-xe6-accent); outline-offset: 2px; }\n.hb-xe6-layer { position: fixed; inset: 0; z-index: 1000; height: 100dvh; display: grid; place-items: center; padding: 16px; }\n.hb-xe6[data-embedded] .hb-xe6-layer { position: absolute; height: auto; z-index: 2; padding: 10px; }\n.hb-xe6-scrim { position: absolute; inset: 0; background: rgba(3, 3, 4, 0.64); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: hb-xe6-fade 0.25s ease both; }\n.hb-xe6-layer[data-state=\"closed\"] .hb-xe6-scrim { animation: hb-xe6-fade-out 0.2s ease both; }\n.hb-xe6-panel { position: relative; width: 100%; max-width: 420px; max-height: 100%; overflow: auto; border: 1px solid #262628; border-radius: 18px; background: #121213; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 30px 80px -24px rgba(0, 0, 0, 0.9); outline: none; animation: hb-xe6-in 0.36s cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe6-layer[data-state=\"closed\"] .hb-xe6-panel { animation: hb-xe6-out 0.2s ease both; }\n.hb-xe6-stage { position: relative; display: grid; grid-template-columns: 1fr 96px 1fr; align-items: center; padding: 20px 18px 16px; border-bottom: 1px solid #1f1f21; background: radial-gradient(70% 120% at 50% 0%, color-mix(in srgb, var(--hb-xe6-accent) 10%, transparent), transparent 70%), linear-gradient(180deg, #161617, #121213); border-radius: 18px 18px 0 0; }\n.hb-xe6-person { display: grid; justify-items: center; gap: 6px; text-align: center; min-width: 0; }\n.hb-xe6-av { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; color: #111; font-size: 15px; font-weight: 700; box-shadow: 0 0 0 3px #121213, 0 0 0 4px #2a2a2d, 0 10px 20px -8px rgba(0, 0, 0, 0.8); }\n.hb-xe6-pname { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }\n.hb-xe6-prole { margin-top: -4px; color: #85858a; font-size: 11px; transition: color 0.3s ease; }\n.hb-xe6-track { position: relative; height: 2px; margin-bottom: 26px; border-radius: 2px; background: repeating-linear-gradient(90deg, #333336 0 4px, transparent 4px 9px); overflow: visible; }\n.hb-xe6-pulse { position: absolute; font-style: normal; top: -2px; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--hb-xe6-accent); box-shadow: 0 0 10px var(--hb-xe6-accent); animation: hb-xe6-flow 1.8s cubic-bezier(0.6, 0, 0.4, 1) infinite; animation-delay: calc(var(--hb-xe6-i) * 0.6s); opacity: 0; }\n.hb-xe6-crown { position: absolute; top: 12px; left: 18px; z-index: 1; width: calc((100% - 36px - 96px) / 2); display: flex; justify-content: center; pointer-events: none; transition: transform 0.9s cubic-bezier(0.65, 0, 0.25, 1); }\n.hb-xe6-crown span { display: grid; place-items: center; width: 22px; height: 22px; margin-right: -30px; border-radius: 50%; background: linear-gradient(180deg, #fde68a, #f59e0b); color: #4a2a00; box-shadow: 0 0 0 2px #121213, 0 4px 10px -2px rgba(245, 158, 11, 0.6); }\n.hb-xe6-crown svg { width: 12px; height: 12px; }\n.hb-xe6-crown[data-moved=\"true\"] { transform: translateX(calc(100% + 96px)); }\n.hb-xe6-crown[data-moved=\"true\"] span { animation: hb-xe6-hop 0.9s cubic-bezier(0.65, 0, 0.25, 1); }\n.hb-xe6-body { padding: 16px 18px 0; }\n.hb-xe6-title { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -0.012em; }\n.hb-xe6-desc { margin: 4px 0 0; color: #9c9ca2; font-size: 12.5px; line-height: 1.5; }\n.hb-xe6-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 7px; }\n.hb-xe6-list li { display: grid; grid-template-columns: 16px 1fr; gap: 9px; align-items: start; color: #c8c8cd; font-size: 12.5px; line-height: 1.4; }\n.hb-xe6-list svg { width: 14px; height: 14px; margin-top: 1px; color: #6c6c72; }\n.hb-xe6-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 10px 11px; border-radius: 11px; background: #0d0d0e; box-shadow: inset 0 0 0 1px #232325; cursor: pointer; font-size: 12.5px; color: #d4d4d8; line-height: 1.4; transition: box-shadow 0.2s ease; }\n.hb-xe6-check[data-on=\"true\"] { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hb-xe6-accent) 45%, transparent); }\n.hb-xe6-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }\n.hb-xe6-box { flex: none; display: grid; place-items: center; width: 17px; height: 17px; margin-top: 0; border-radius: 5px; border: 1.5px solid #47474c; transition: background-color 0.2s ease, border-color 0.2s ease; }\n.hb-xe6-check[data-on=\"true\"] .hb-xe6-box { border-color: var(--hb-xe6-accent); background: var(--hb-xe6-accent); }\n.hb-xe6-box svg { width: 11px; height: 11px; color: #fff; stroke-dasharray: 16; stroke-dashoffset: 16; transition: stroke-dashoffset 0.25s ease 0.05s; }\n.hb-xe6-check[data-on=\"true\"] .hb-xe6-box svg { stroke-dashoffset: 0; }\n.hb-xe6-err { margin: 10px 0 0; color: #ff8a8f; font-size: 12px; }\n.hb-xe6-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 18px 18px; }\n.hb-xe6-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 88px; height: 36px; padding: 0 14px; border: 1px solid #2b2b2e; border-radius: 10px; background: transparent; color: #d4d4d8; font: inherit; font-size: 13px; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background-color 0.15s ease, opacity 0.2s ease, transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe6-btn:hover:not(:disabled) { background: #1b1b1d; }\n.hb-xe6-btn:active:not(:disabled) { transform: scale(0.97); }\n.hb-xe6-btn[data-primary] { min-width: 160px; border-color: transparent; background: var(--hb-xe6-accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 18px -10px var(--hb-xe6-accent); }\n.hb-xe6-btn[data-primary]:hover:not(:disabled) { background: color-mix(in srgb, var(--hb-xe6-accent) 88%, #fff); }\n.hb-xe6-btn[data-primary]:disabled { background: #2a2a2d; color: #6f6f75; box-shadow: none; cursor: not-allowed; }\n.hb-xe6-btn[data-state=\"done\"] { background: #1f9d5b; }\n.hb-xe6-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; animation: hb-xe6-spin 0.7s linear infinite; }\n.hb-xe6[data-embedded] .hb-xe6-stage { padding: 14px 18px 10px; }\n.hb-xe6[data-embedded] .hb-xe6-crown { top: 6px; }\n.hb-xe6[data-embedded] .hb-xe6-foot { padding: 14px 18px 16px; }\n@keyframes hb-xe6-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-xe6-fade-out { from { opacity: 1; } to { opacity: 0; } }\n@keyframes hb-xe6-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe6-out { from { opacity: 1; } to { opacity: 0; transform: scale(0.97); } }\n@keyframes hb-xe6-flow { 0% { left: 0; opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } 100% { left: calc(100% - 6px); opacity: 0; } }\n@keyframes hb-xe6-hop { 0%, 100% { translate: 0 0; } 50% { translate: 0 -16px; } }\n@keyframes hb-xe6-spin { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xe6-scrim, .hb-xe6-panel, .hb-xe6-layer[data-state=\"closed\"] .hb-xe6-panel, .hb-xe6-layer[data-state=\"closed\"] .hb-xe6-scrim, .hb-xe6-crown[data-moved=\"true\"] span { animation: none; }\n  .hb-xe6-pulse { animation: none; opacity: 0; }\n  .hb-xe6-layer[data-state=\"closed\"] { opacity: 0; }\n  .hb-xe6-crown, .hb-xe6-box, .hb-xe6-box svg, .hb-xe6-btn, .hb-xe6-check, .hb-xe6-trigger { transition: none; }\n}\n`;\n\nconst focusable =\n  'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction useLayer(\n  open: boolean,\n  embedded: boolean,\n  panel: React.RefObject<HTMLElement | null>,\n  onClose: () => void,\n  userOpened: React.RefObject<boolean>,\n) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const node = panel.current;\n    const steal = !embedded || userOpened.current;\n    const previous = document.activeElement as HTMLElement | null;\n    const html = document.documentElement;\n    const overflow = html.style.overflow;\n    if (!embedded) html.style.overflow = \"hidden\";\n    if (steal && node) {\n      const target = node.querySelector<HTMLElement>(\"[data-autofocus]\") ?? node.querySelector<HTMLElement>(focusable) ?? node;\n      target.focus({ preventScroll: true });\n    }\n    const onKey = (e: KeyboardEvent) => {\n      if (!node) return;\n      if (embedded && !node.contains(document.activeElement)) return;\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const items = Array.from(node.querySelectorAll<HTMLElement>(focusable)).filter((el) => el.getClientRects().length > 0);\n      if (!items.length) {\n        e.preventDefault();\n        node.focus();\n        return;\n      }\n      const first = items[0];\n      const last = items[items.length - 1];\n      const active = document.activeElement;\n      if (!node.contains(active)) {\n        e.preventDefault();\n        first.focus();\n      } else if (e.shiftKey && (active === first || active === node)) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && active === last) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      if (!embedded) html.style.overflow = overflow;\n      if (steal && previous && previous.isConnected && previous !== document.body) previous.focus({ preventScroll: true });\n    };\n  }, [open, embedded, panel, userOpened]);\n}\n\nfunction initials(name: string) {\n  return name\n    .split(\" \")\n    .map((p) => p[0])\n    .join(\"\")\n    .slice(0, 2)\n    .toUpperCase();\n}\n\nexport function DialogTransferConfirm({\n  open,\n  defaultOpen,\n  onOpenChange,\n  embedded = false,\n  trigger = \"Transfer ownership\",\n  workspace = \"Acme Robotics\",\n  description,\n  from = defaultFrom,\n  to = defaultTo,\n  consequences = defaultConsequences,\n  acknowledgement = \"I understand only the new owner can transfer it back.\",\n  confirmLabel = \"Transfer ownership\",\n  onConfirm,\n  accent = \"#f43f5e\",\n  className = \"\",\n  style,\n  ...rest\n}: DialogTransferConfirmProps) {\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const [present, setPresent] = React.useState(isOpen);\n  const [ack, setAck] = React.useState(false);\n  const [state, setState] = React.useState<\"idle\" | \"busy\" | \"done\" | \"error\">(\"idle\");\n  const userOpened = React.useRef(false);\n  const panel = React.useRef<HTMLDivElement>(null);\n  const timers = React.useRef<number[]>([]);\n  const id = React.useId();\n\n  if (isOpen && !present) setPresent(true);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => clearTimeout(t));\n  }, []);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (next) {\n        userOpened.current = true;\n        setAck(false);\n        setState(\"idle\");\n      }\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n  const close = React.useCallback(() => {\n    if (state === \"busy\") return;\n    setOpen(false);\n  }, [state, setOpen]);\n\n  React.useEffect(() => {\n    if (isOpen || !present) return;\n    const t = setTimeout(() => setPresent(false), 220);\n    return () => clearTimeout(t);\n  }, [isOpen, present]);\n\n  useLayer(isOpen, embedded, panel, close, userOpened);\n\n  function confirm() {\n    if (!ack || state === \"busy\" || state === \"done\") return;\n    setState(\"busy\");\n    const started = performance.now();\n    Promise.resolve()\n      .then(() => onConfirm?.())\n      .then(\n        () => {\n          const wait = Math.max(0, 700 - (performance.now() - started));\n          timers.current.push(\n            window.setTimeout(() => {\n              setState(\"done\");\n              timers.current.push(window.setTimeout(() => setOpen(false), 1600));\n            }, wait),\n          );\n        },\n        () => setState(\"error\"),\n      );\n  }\n\n  const moved = state === \"done\";\n  const vars = { \"--hb-xe6-accent\": accent, ...style } as React.CSSProperties;\n  const av = (p: TransferPerson) => ({ background: `linear-gradient(135deg, ${(p.colors ?? [\"#e4e4e7\", \"#a1a1aa\"])[0]}, ${(p.colors ?? [\"#e4e4e7\", \"#a1a1aa\"])[1]})` });\n\n  return (\n    <div className={`hb-xe6 ${className}`} data-embedded={embedded || undefined} style={vars} {...rest}>\n      <style href=\"hb-xe6-css\" precedence=\"default\">{css}</style>\n      {trigger !== null && (\n        <button type=\"button\" className=\"hb-xe6-trigger\" aria-haspopup=\"dialog\" aria-expanded={isOpen} onClick={() => setOpen(true)}>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M2.5 5.5h9m0 0-2.5-2.5m2.5 2.5L9 8M13.5 10.5h-9m0 0L7 8m-2.5 2.5L7 13\" />\n          </svg>\n          {trigger}\n        </button>\n      )}\n      {present && (\n        <div className=\"hb-xe6-layer\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xe6-scrim\" onClick={close} aria-hidden=\"true\" />\n          <div\n            ref={panel}\n            role=\"alertdialog\"\n            aria-modal=\"true\"\n            aria-labelledby={`${id}-t`}\n            aria-describedby={`${id}-d`}\n            tabIndex={-1}\n            className=\"hb-xe6-panel\"\n          >\n            <div className=\"hb-xe6-stage\" aria-hidden=\"true\">\n              <div className=\"hb-xe6-crown\" data-moved={moved ? \"true\" : undefined}>\n                <span>\n                  <svg viewBox=\"0 0 12 12\" fill=\"currentColor\"><path d=\"M1.5 4 4 6l2-3.5L8 6l2.5-2-1 5.5h-7Z\" /></svg>\n                </span>\n              </div>\n              <div className=\"hb-xe6-person\">\n                <span className=\"hb-xe6-av\" style={av(from)}>{initials(from.name)}</span>\n                <span className=\"hb-xe6-pname\">{from.name}</span>\n                <span className=\"hb-xe6-prole\">{moved ? \"Admin\" : from.role}</span>\n              </div>\n              <div className=\"hb-xe6-track\">\n                {!moved && [0, 1, 2].map((i) => <i key={i} className=\"hb-xe6-pulse\" style={{ \"--hb-xe6-i\": i } as React.CSSProperties} />)}\n              </div>\n              <div className=\"hb-xe6-person\">\n                <span className=\"hb-xe6-av\" style={av(to)}>{initials(to.name)}</span>\n                <span className=\"hb-xe6-pname\">{to.name}</span>\n                <span className=\"hb-xe6-prole\" style={moved ? { color: \"#fbbf24\" } : undefined}>{moved ? \"Owner\" : to.role}</span>\n              </div>\n            </div>\n            <div className=\"hb-xe6-body\">\n              <h2 id={`${id}-t`} className=\"hb-xe6-title\">Transfer {workspace}?</h2>\n              <p id={`${id}-d`} className=\"hb-xe6-desc\">\n                {description ?? `${to.name} becomes the owner as soon as you confirm. Here is what changes for you.`}\n              </p>\n              {consequences.length > 0 && (\n                <ul className=\"hb-xe6-list\">\n                  {consequences.map((c) => (\n                    <li key={c}>\n                      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                        <circle cx=\"8\" cy=\"8\" r=\"6\" />\n                        <path d=\"M8 5v3.5M8 10.8v.2\" />\n                      </svg>\n                      {c}\n                    </li>\n                  ))}\n                </ul>\n              )}\n              <label className=\"hb-xe6-check\" data-on={ack ? \"true\" : undefined}>\n                <input type=\"checkbox\" checked={ack} disabled={state === \"busy\" || moved} onChange={(e) => setAck(e.target.checked)} data-autofocus=\"\" />\n                <span className=\"hb-xe6-box\" aria-hidden=\"true\">\n                  <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"m2.5 6.2 2.2 2.2L9.5 3.6\" /></svg>\n                </span>\n                {acknowledgement}\n              </label>\n              {state === \"error\" && <p className=\"hb-xe6-err\" role=\"alert\">The transfer did not go through. Try again.</p>}\n            </div>\n            <div className=\"hb-xe6-foot\">\n              <button type=\"button\" className=\"hb-xe6-btn\" onClick={close} disabled={state === \"busy\"}>Cancel</button>\n              <button\n                type=\"button\"\n                className=\"hb-xe6-btn\"\n                data-primary=\"\"\n                data-state={state}\n                disabled={!ack || state === \"busy\"}\n                aria-busy={state === \"busy\" || undefined}\n                onClick={confirm}\n              >\n                {state === \"busy\" && <span className=\"hb-xe6-spin\" aria-hidden=\"true\" />}\n                <span aria-live=\"polite\">{state === \"busy\" ? \"Transferring\" : moved ? `${to.name.split(\" \")[0]} is the owner` : confirmLabel}</span>\n              </button>\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}