{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "micro-copy-chip",
  "type": "registry:component",
  "title": "Copy Chip",
  "description": "A command chip that copies on click. A ghost of the text lifts off and flies into the clipboard icon, which gulps it, turns into a drawn check and sweeps a light across the chip.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "copy",
    "clipboard",
    "command",
    "chip",
    "feedback",
    "micro"
  ],
  "docs": "https://hyperblur.dev/effects/micro-copy-chip",
  "files": [
    {
      "path": "registry/hyperblur/micro-copy-chip.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/micro-copy-chip.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MicroCopyChipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"value\" | \"children\" | \"onCopy\"> {\n  value?: string;\n  prefix?: string;\n  copiedLabel?: string;\n  timeout?: number;\n  accent?: string;\n  onCopy?: (value: string) => void;\n}\n\nconst css = `\n.hb-wf6 {\n  --hb-wf6-c: #2f7bff;\n  --hb-wf6-dx: 120px;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 10px;\n  max-width: 100%;\n  height: 40px;\n  padding: 0 6px 0 14px;\n  margin: 0;\n  box-sizing: border-box;\n  border: 1px solid #262626;\n  border-radius: 12px;\n  background: linear-gradient(180deg, #141414, #0e0e0e);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 8px 20px -12px rgba(0,0,0,0.9);\n  color: #d8d8d8;\n  font: inherit;\n  cursor: pointer;\n  overflow: hidden;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.25s ease, transform 0.22s cubic-bezier(0.3, 1.6, 0.5, 1);\n}\n.hb-wf6 *, .hb-wf6 *::before, .hb-wf6 *::after { box-sizing: border-box; }\n.hb-wf6:hover { border-color: #353535; }\n.hb-wf6:active { transform: scale(0.98); }\n.hb-wf6:focus-visible { outline: 2px solid var(--hb-wf6-c); outline-offset: 3px; }\n.hb-wf6:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-wf6[data-done=\"true\"] { border-color: color-mix(in srgb, var(--hb-wf6-c) 55%, #262626); }\n.hb-wf6-sw {\n  position: absolute;\n  inset: -1px;\n  border-radius: inherit;\n  pointer-events: none;\n  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--hb-wf6-c) 28%, transparent) 50%, transparent 70%);\n  background-size: 250% 100%;\n  background-position: 130% 0;\n  opacity: 0;\n}\n.hb-wf6[data-done=\"true\"] .hb-wf6-sw { animation: hb-wf6-sweep 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.28s both; }\n@keyframes hb-wf6-sweep { 0% { opacity: 1; background-position: 130% 0; } 100% { opacity: 1; background-position: -30% 0; } }\n.hb-wf6-tx {\n  position: relative;\n  display: inline-flex;\n  gap: 8px;\n  min-width: 0;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 12.5px;\n  white-space: nowrap;\n  overflow: hidden;\n  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);\n  mask-image: linear-gradient(90deg, #000 85%, transparent);\n}\n.hb-wf6-pf { color: #5c5c5c; user-select: none; }\n.hb-wf6-vl { overflow: hidden; text-overflow: clip; transition: opacity 0.3s ease; }\n.hb-wf6[data-done=\"true\"] .hb-wf6-vl { animation: hb-wf6-dim 0.9s ease both; }\n@keyframes hb-wf6-dim { 0% { opacity: 1; } 25% { opacity: 0.35; } 100% { opacity: 1; } }\n.hb-wf6-gh {\n  position: absolute;\n  top: 50%;\n  white-space: nowrap;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 12.5px;\n  color: var(--hb-wf6-c);\n  pointer-events: none;\n  transform-origin: 0 50%;\n  translate: 0 -50%;\n  animation: hb-wf6-fly 0.5s cubic-bezier(0.55, 0, 0.75, 0.3) both;\n}\n@keyframes hb-wf6-fly {\n  0% { transform: translate(0, 0) scale(1); opacity: 0.95; filter: blur(0); }\n  25% { transform: translate(4px, -8px) scale(0.92); opacity: 0.9; }\n  100% { transform: translate(var(--hb-wf6-dx), 0) scale(0.08); opacity: 0; filter: blur(1px); }\n}\n.hb-wf6-ic {\n  position: relative;\n  flex: none;\n  display: grid;\n  place-items: center;\n  width: 30px;\n  height: 30px;\n  border-radius: 8px;\n  background: #1c1c1c;\n  border: 1px solid #2a2a2a;\n  color: #a8a8a8;\n  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;\n}\n.hb-wf6:hover .hb-wf6-ic { color: #fff; }\n.hb-wf6[data-done=\"true\"] .hb-wf6-ic { background: var(--hb-wf6-c); border-color: var(--hb-wf6-c); color: #fff; animation: hb-wf6-gulp 0.45s cubic-bezier(0.3, 1.8, 0.4, 1) 0.4s both; }\n@keyframes hb-wf6-gulp { 0% { transform: scale(1); } 40% { transform: scale(0.82, 1.12); } 100% { transform: scale(1); } }\n.hb-wf6-ic svg { position: absolute; width: 15px; height: 15px; transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }\n.hb-wf6-ck { opacity: 0; transform: scale(0.5); }\n.hb-wf6-ck path { stroke-dasharray: 16; stroke-dashoffset: 16; }\n.hb-wf6[data-done=\"true\"] .hb-wf6-cl { opacity: 0; transform: scale(0.5) rotate(-20deg); transition-delay: 0.38s; }\n.hb-wf6[data-done=\"true\"] .hb-wf6-ck { opacity: 1; transform: none; transition-delay: 0.4s; }\n.hb-wf6[data-done=\"true\"] .hb-wf6-ck path { animation: hb-wf6-draw 0.35s ease-out 0.45s forwards; }\n@keyframes hb-wf6-draw { to { stroke-dashoffset: 0; } }\n.hb-wf6-tag {\n  position: absolute;\n  right: 44px;\n  top: 50%;\n  padding: 3px 7px;\n  border-radius: 6px;\n  background: color-mix(in srgb, var(--hb-wf6-c) 18%, #0e0e0e);\n  border: 1px solid color-mix(in srgb, var(--hb-wf6-c) 40%, transparent);\n  color: #fff;\n  font-size: 11px;\n  font-weight: 600;\n  translate: 0 -50%;\n  opacity: 0;\n  transform: translateX(8px);\n  transition: opacity 0.2s ease, transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);\n  pointer-events: none;\n}\n.hb-wf6[data-done=\"true\"] .hb-wf6-tag { opacity: 1; transform: none; transition-delay: 0.5s; }\n.hb-wf6-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wf6, .hb-wf6-ic, .hb-wf6-ic svg, .hb-wf6-tag, .hb-wf6-vl { transition: none; transition-delay: 0s; }\n  .hb-wf6-gh { display: none; }\n  .hb-wf6[data-done=\"true\"] .hb-wf6-sw, .hb-wf6[data-done=\"true\"] .hb-wf6-ic, .hb-wf6[data-done=\"true\"] .hb-wf6-vl { animation: none; }\n  .hb-wf6[data-done=\"true\"] .hb-wf6-ck path { animation: none; stroke-dashoffset: 0; }\n}\n`;\n\nfunction writeClipboard(text: string) {\n  if (typeof navigator !== \"undefined\" && navigator.clipboard && window.isSecureContext) {\n    return navigator.clipboard.writeText(text).catch(() => undefined);\n  }\n  const ta = document.createElement(\"textarea\");\n  ta.value = text;\n  ta.setAttribute(\"readonly\", \"\");\n  ta.style.position = \"fixed\";\n  ta.style.opacity = \"0\";\n  document.body.appendChild(ta);\n  ta.select();\n  try {\n    document.execCommand(\"copy\");\n  } catch {}\n  document.body.removeChild(ta);\n  return Promise.resolve();\n}\n\nexport function MicroCopyChip({\n  value = \"npx shadcn@latest add https://hyperblur.dev/r/aurora.json\",\n  prefix = \"$\",\n  copiedLabel = \"Copied\",\n  timeout = 1800,\n  accent = \"#2f7bff\",\n  onCopy,\n  className = \"\",\n  style,\n  onClick,\n  ...rest\n}: MicroCopyChipProps) {\n  const [done, setDone] = React.useState(false);\n  const [shot, setShot] = React.useState(0);\n  const [dx, setDx] = React.useState(120);\n  const [gl, setGl] = React.useState(14);\n  const txtRef = React.useRef<HTMLSpanElement>(null);\n  const icRef = React.useRef<HTMLSpanElement>(null);\n\n  React.useEffect(() => {\n    if (!done) return;\n    const t = window.setTimeout(() => setDone(false), timeout);\n    return () => window.clearTimeout(t);\n  }, [done, shot, timeout]);\n\n  return (\n    <button\n      type=\"button\"\n      className={`hb-wf6 ${className}`}\n      data-done={done}\n      aria-label={`Copy ${value}`}\n      style={{ ...style, [\"--hb-wf6-c\" as string]: accent, [\"--hb-wf6-dx\" as string]: `${dx.toFixed(1)}px` }}\n      onClick={(e) => {\n        onClick?.(e);\n        if (e.defaultPrevented) return;\n        const a = txtRef.current?.getBoundingClientRect();\n        const b = icRef.current?.getBoundingClientRect();\n        const c = e.currentTarget.getBoundingClientRect();\n        if (a && b) {\n          setDx(b.left + b.width / 2 - a.left);\n          setGl(a.left - c.left);\n        }\n        void writeClipboard(value);\n        setDone(false);\n        setShot((n) => n + 1);\n        window.requestAnimationFrame(() => setDone(true));\n        onCopy?.(value);\n      }}\n      {...rest}\n    >\n      <style href=\"hb-micro-copy-chip\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"hb-wf6-sw\" aria-hidden=\"true\" />\n      <span className=\"hb-wf6-tx\" aria-hidden=\"true\">\n        {prefix ? <span className=\"hb-wf6-pf\">{prefix}</span> : null}\n        <span ref={txtRef} className=\"hb-wf6-vl\">\n          {value}\n        </span>\n      </span>\n      {shot > 0 && done ? (\n        <span key={shot} className=\"hb-wf6-gh\" aria-hidden=\"true\" style={{ left: `${gl.toFixed(1)}px` }}>\n          {value}\n        </span>\n      ) : null}\n      <span className=\"hb-wf6-tag\" aria-hidden=\"true\">\n        {copiedLabel}\n      </span>\n      <span ref={icRef} className=\"hb-wf6-ic\" aria-hidden=\"true\">\n        <svg className=\"hb-wf6-cl\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\">\n          <rect x=\"5.25\" y=\"5.25\" width=\"8\" height=\"8.5\" rx=\"1.8\" />\n          <path d=\"M10.75 5.25V3.8c0-.8-.6-1.4-1.4-1.4H4.2c-.8 0-1.4.6-1.4 1.4v5.6c0 .8.6 1.4 1.4 1.4h1.05\" />\n        </svg>\n        <svg className=\"hb-wf6-ck\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          <path d=\"M3.5 8.5l3 3 6-7\" />\n        </svg>\n      </span>\n      <span className=\"hb-wf6-sr\" aria-live=\"polite\">\n        {done ? copiedLabel : \"\"}\n      </span>\n    </button>\n  );\n}\n"
    }
  ]
}