{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-type-confirm",
  "type": "registry:component",
  "title": "Button Type Confirm",
  "description": "Type the resource name to unlock the delete button. Each matched character lights up in the name, a wrong key shakes the field and the lock icon springs open on a full match.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "confirm",
    "delete",
    "input",
    "type to confirm",
    "danger",
    "form"
  ],
  "docs": "https://hyperblur.dev/effects/button-type-confirm",
  "files": [
    {
      "path": "registry/hyperblur/button-type-confirm.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-type-confirm.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonTypeConfirmProps\n  extends Omit<React.HTMLAttributes<HTMLFormElement>, \"children\" | \"onSubmit\" | \"onChange\"> {\n  confirmText?: string;\n  label?: string;\n  doneLabel?: string;\n  hint?: string;\n  caseSensitive?: boolean;\n  accent?: string;\n  resetAfter?: number;\n  disabled?: boolean;\n  onConfirm?: () => void;\n  onValueChange?: (value: string, matched: boolean) => void;\n}\n\nconst css = `\n.hb-xd5 {\n  display: flex;\n  flex-direction: column;\n  gap: 10px;\n  box-sizing: border-box;\n  width: 100%;\n  max-width: 340px;\n  margin: 0;\n  font-family: inherit;\n  font-size: 0.8125rem;\n  color: #ededed;\n}\n.hb-xd5 *, .hb-xd5 *::before, .hb-xd5 *::after { box-sizing: border-box; }\n.hb-xd5-hint { margin: 0; line-height: 1.5; color: #a1a1a1; }\n.hb-xd5-target {\n  display: inline-flex;\n  flex-wrap: wrap;\n  vertical-align: baseline;\n  padding: 1px 6px;\n  margin: 0 2px;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 0.92em;\n  color: #d4d4d4;\n  background: #1a1a1a;\n  border: 1px solid #2a2a2a;\n  border-radius: 6px;\n  transition: border-color 0.3s ease, background 0.3s ease;\n}\n.hb-xd5-ch { position: relative; transition: color 0.18s ease; white-space: pre; }\n.hb-xd5-ch[data-s=\"ok\"] { color: color-mix(in srgb, var(--hb-xd5-c) 55%, #fff); text-shadow: 0 0 10px color-mix(in srgb, var(--hb-xd5-c) 60%, transparent); }\n.hb-xd5-ch[data-s=\"bad\"] { color: #fff; }\n.hb-xd5-ch[data-s=\"bad\"]::after {\n  content: \"\";\n  position: absolute;\n  left: -1px;\n  right: -1px;\n  bottom: -1px;\n  height: 2px;\n  border-radius: 2px;\n  background: #f5a524;\n}\n.hb-xd5-ch[data-s=\"next\"]::before {\n  content: \"\";\n  position: absolute;\n  left: -1px;\n  top: 10%;\n  bottom: 10%;\n  width: 1.5px;\n  background: color-mix(in srgb, var(--hb-xd5-c) 70%, #fff);\n  animation: hb-xd5-caret 1s steps(2, start) infinite;\n}\n.hb-xd5[data-match=\"true\"] .hb-xd5-target { border-color: color-mix(in srgb, var(--hb-xd5-c) 50%, #2a2a2a); background: color-mix(in srgb, var(--hb-xd5-c) 10%, #1a1a1a); }\n.hb-xd5-row { display: flex; gap: 8px; }\n.hb-xd5-field { position: relative; flex: 1; min-width: 0; }\n.hb-xd5-input {\n  width: 100%;\n  height: 38px;\n  padding: 0 34px 0 11px;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 0.8125rem;\n  color: #ededed;\n  background: linear-gradient(180deg, #0c0c0c, #121212);\n  border: 1px solid #2a2a2a;\n  border-radius: 10px;\n  outline: none;\n  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);\n  transition: border-color 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-xd5-input::placeholder { color: #5c5c5c; }\n.hb-xd5-input:focus { border-color: #4a4a4a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.6), 0 0 0 3px rgba(255,255,255,0.06); }\n.hb-xd5[data-bad=\"true\"] .hb-xd5-input { border-color: #8a5a12; }\n.hb-xd5[data-match=\"true\"] .hb-xd5-input { border-color: color-mix(in srgb, var(--hb-xd5-c) 60%, #2a2a2a); box-shadow: inset 0 1px 2px rgba(0,0,0,0.6), 0 0 0 3px color-mix(in srgb, var(--hb-xd5-c) 16%, transparent); }\n.hb-xd5[data-shake=\"true\"] .hb-xd5-field { animation: hb-xd5-shake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97); }\n.hb-xd5-meter {\n  position: absolute;\n  right: 10px;\n  top: 50%;\n  width: 16px;\n  height: 16px;\n  margin-top: -8px;\n  transform: rotate(-90deg);\n}\n.hb-xd5-meter circle { fill: none; stroke-width: 2.4; }\n.hb-xd5-meter .hb-xd5-trk { stroke: #262626; }\n.hb-xd5-meter .hb-xd5-arc { stroke: var(--hb-xd5-c); stroke-linecap: round; transition: stroke-dashoffset 0.25s cubic-bezier(0.3, 0.9, 0.3, 1); }\n.hb-xd5-btn {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 7px;\n  height: 38px;\n  padding: 0 14px;\n  font: inherit;\n  font-weight: 600;\n  white-space: nowrap;\n  color: #6b6b6b;\n  background: #161616;\n  border: 1px solid #262626;\n  border-radius: 10px;\n  cursor: not-allowed;\n  overflow: hidden;\n  transition: color 0.25s ease, background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, transform 0.18s cubic-bezier(0.3, 1.5, 0.5, 1);\n}\n.hb-xd5[data-match=\"true\"] .hb-xd5-btn {\n  color: #fff;\n  cursor: pointer;\n  border-color: color-mix(in srgb, var(--hb-xd5-c) 70%, #000);\n  background:\n    linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0) 60%),\n    var(--hb-xd5-c);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 6px 18px -8px var(--hb-xd5-c);\n}\n.hb-xd5[data-match=\"true\"] .hb-xd5-btn:active { transform: scale(0.97); }\n.hb-xd5-btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--hb-xd5-c) 70%, #fff); outline-offset: 2px; }\n.hb-xd5-shackle { transform-box: fill-box; transform-origin: 85% 100%; transition: transform 0.45s cubic-bezier(0.3, 1.8, 0.5, 1); }\n.hb-xd5[data-match=\"true\"] .hb-xd5-shackle { transform: translateY(-2px) rotate(-28deg); }\n.hb-xd5[data-match=\"true\"] .hb-xd5-btn::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);\n  transform: translateX(-120%);\n  animation: hb-xd5-sweep 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;\n}\n.hb-xd5-done {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  height: 38px;\n  padding: 0 12px;\n  color: color-mix(in srgb, var(--hb-xd5-c) 45%, #fff);\n  background: color-mix(in srgb, var(--hb-xd5-c) 10%, #111);\n  border: 1px solid color-mix(in srgb, var(--hb-xd5-c) 35%, #262626);\n  border-radius: 10px;\n  animation: hb-xd5-in 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);\n}\n.hb-xd5-done b { font-weight: 600; color: #fff; }\n.hb-xd5-done code { font-family: var(--font-mono), ui-monospace, monospace; font-size: 0.92em; text-decoration: line-through; opacity: 0.7; }\n@keyframes hb-xd5-caret { to { visibility: hidden; } }\n@keyframes hb-xd5-shake {\n  20% { transform: translateX(-4px); }\n  40% { transform: translateX(4px); }\n  60% { transform: translateX(-2px); }\n  80% { transform: translateX(2px); }\n}\n@keyframes hb-xd5-sweep { to { transform: translateX(120%); } }\n@keyframes hb-xd5-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd5-btn, .hb-xd5-shackle, .hb-xd5-ch, .hb-xd5-meter .hb-xd5-arc { transition: none; }\n  .hb-xd5[data-shake=\"true\"] .hb-xd5-field, .hb-xd5[data-match=\"true\"] .hb-xd5-btn::after, .hb-xd5-done, .hb-xd5-ch[data-s=\"next\"]::before { animation: none; }\n}\n`;\n\nexport function ButtonTypeConfirm({\n  confirmText = \"acme/billing-api\",\n  label = \"Delete\",\n  doneLabel = \"Repository deleted\",\n  hint = \"This permanently deletes the repository, its issues and 214 releases. Type\",\n  caseSensitive = true,\n  accent = \"#ef4444\",\n  resetAfter = 3200,\n  disabled = false,\n  onConfirm,\n  onValueChange,\n  className = \"\",\n  style,\n  ...rest\n}: ButtonTypeConfirmProps) {\n  const id = React.useId();\n  const [value, setValue] = React.useState(\"\");\n  const [shake, setShake] = React.useState(0);\n  const [done, setDone] = React.useState(false);\n  const latest = React.useRef({ onConfirm, onValueChange });\n  const inputRef = React.useRef<HTMLInputElement>(null);\n\n  React.useEffect(() => {\n    latest.current = { onConfirm, onValueChange };\n  }, [onConfirm, onValueChange]);\n\n  React.useEffect(() => {\n    if (!shake) return;\n    const t = window.setTimeout(() => setShake(0), 340);\n    return () => window.clearTimeout(t);\n  }, [shake]);\n\n  React.useEffect(() => {\n    if (!done || resetAfter <= 0) return;\n    const t = window.setTimeout(() => {\n      setDone(false);\n      setValue(\"\");\n    }, resetAfter);\n    return () => window.clearTimeout(t);\n  }, [done, resetAfter]);\n\n  const norm = (s: string) => (caseSensitive ? s : s.toLowerCase());\n  const a = norm(value);\n  const b = norm(confirmText);\n  let prefix = 0;\n  while (prefix < a.length && prefix < b.length && a[prefix] === b[prefix]) prefix++;\n  const matched = a === b;\n  const bad = a.length > prefix;\n  const ratio = b.length ? prefix / b.length : 0;\n  const circ = 2 * Math.PI * 6;\n\n  const chars = Array.from(confirmText).map((c, i) => {\n    let s = \"idle\";\n    if (i < prefix) s = \"ok\";\n    else if (bad && i === prefix) s = \"bad\";\n    else if (!bad && i === prefix && value.length > 0) s = \"next\";\n    return { c, s };\n  });\n\n  return (\n    <form\n      className={`hb-xd5 ${className}`.trim()}\n      data-match={matched}\n      data-bad={bad}\n      data-shake={shake > 0}\n      style={{ \"--hb-xd5-c\": accent, ...style } as React.CSSProperties}\n      onSubmit={(e) => {\n        e.preventDefault();\n        if (disabled || done) return;\n        if (!matched) {\n          setShake((n) => n + 1);\n          inputRef.current?.focus();\n          return;\n        }\n        setDone(true);\n        latest.current.onConfirm?.();\n      }}\n      {...rest}\n    >\n      <style href=\"hb-button-type-confirm\" precedence=\"default\">{css}</style>\n      <p className=\"hb-xd5-hint\" id={`${id}-hint`}>\n        {hint}\n        <span className=\"hb-xd5-target\" aria-label={confirmText}>\n          {chars.map((ch, i) => (\n            <span key={i} className=\"hb-xd5-ch\" data-s={ch.s} aria-hidden=\"true\">{ch.c}</span>\n          ))}\n        </span>\n        to confirm.\n      </p>\n      {done ? (\n        <div className=\"hb-xd5-done\" role=\"status\" aria-live=\"polite\">\n          <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n          <b>{doneLabel}</b>\n          <code>{confirmText}</code>\n        </div>\n      ) : (\n        <div className=\"hb-xd5-row\">\n          <div className=\"hb-xd5-field\">\n            <input\n              ref={inputRef}\n              className=\"hb-xd5-input\"\n              value={value}\n              disabled={disabled}\n              spellCheck={false}\n              autoComplete=\"off\"\n              autoCapitalize=\"off\"\n              placeholder={confirmText}\n              aria-label={`Type ${confirmText} to confirm`}\n              aria-describedby={`${id}-hint`}\n              aria-invalid={bad || undefined}\n              onChange={(e) => {\n                const v = e.target.value;\n                const na = norm(v);\n                if (na.length > a.length && !b.startsWith(na)) setShake((n) => n + 1);\n                setValue(v);\n                latest.current.onValueChange?.(v, na === b);\n              }}\n            />\n            <svg className=\"hb-xd5-meter\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n              <circle className=\"hb-xd5-trk\" cx=\"8\" cy=\"8\" r=\"6\" />\n              <circle className=\"hb-xd5-arc\" cx=\"8\" cy=\"8\" r=\"6\" strokeDasharray={circ.toFixed(2)} strokeDashoffset={(circ * (1 - ratio)).toFixed(2)} />\n            </svg>\n          </div>\n          <button type=\"submit\" className=\"hb-xd5-btn\" aria-disabled={!matched || disabled || undefined}>\n            <svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <rect x=\"5\" y=\"11\" width=\"14\" height=\"9\" rx=\"2\" />\n              <path className=\"hb-xd5-shackle\" d=\"M8 11V8a4 4 0 0 1 8 0v3\" />\n            </svg>\n            {label}\n          </button>\n        </div>\n      )}\n    </form>\n  );\n}\n"
    }
  ]
}