{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-odometer",
  "type": "registry:component",
  "title": "Button Odometer",
  "description": "An upvote button whose count rolls digit by digit like a mechanical odometer, starting from the ones and settling with a small overshoot. Voting fires the arrow through the top of its tile and floats a +1.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "upvote",
    "counter",
    "odometer",
    "digits",
    "toggle"
  ],
  "docs": "https://hyperblur.dev/effects/button-odometer",
  "files": [
    {
      "path": "registry/hyperblur/button-odometer.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-odometer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonOdometerProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\" | \"onChange\"> {\n  count?: number;\n  defaultCount?: number;\n  voted?: boolean;\n  defaultVoted?: boolean;\n  onVoteChange?: (voted: boolean, count: number) => void;\n  accent?: string;\n  label?: string;\n  locale?: string;\n}\n\nconst css = `\n.hb-xa11 {\n  --hb-xa11-c: #ff6b3d;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.7em;\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0.55em 1em 0.55em 0.6em;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 650;\n  line-height: 1;\n  color: #ededed;\n  background: linear-gradient(180deg, #1a1a1a, #121212);\n  border: 0;\n  border-radius: 12px;\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 0 0 1px #2a2a2a, 0 10px 24px -16px rgba(0, 0, 0, 0.9);\n  cursor: pointer;\n  user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  transition: box-shadow 0.35s ease, background 0.35s ease, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-xa11 *, .hb-xa11 *::before, .hb-xa11 *::after { box-sizing: border-box; }\n.hb-xa11:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 0 1px #363636, 0 10px 24px -16px rgba(0, 0, 0, 0.9); }\n.hb-xa11:active:not(:disabled) { transform: scale(0.96); }\n.hb-xa11:focus-visible { outline: 2px solid var(--hb-xa11-c); outline-offset: 3px; }\n.hb-xa11:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xa11[aria-pressed=\"true\"] {\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xa11-c) 16%, #161616), #121212);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 0 1px color-mix(in srgb, var(--hb-xa11-c) 50%, #2a2a2a), 0 12px 28px -14px color-mix(in srgb, var(--hb-xa11-c) 55%, transparent);\n}\n.hb-xa11-icon {\n  position: relative;\n  display: grid;\n  place-items: center;\n  width: 2em;\n  height: 2em;\n  flex: none;\n  color: #a1a1a1;\n  background: #1f1f1f;\n  border-radius: 8px;\n  box-shadow: inset 0 0 0 1px #2c2c2c;\n  overflow: hidden;\n  transition: color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;\n}\n.hb-xa11[aria-pressed=\"true\"] .hb-xa11-icon { color: #fff; background: var(--hb-xa11-c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 12px -4px var(--hb-xa11-c); }\n.hb-xa11-icon svg { width: 1em; height: 1em; transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xa11:hover:not(:disabled) .hb-xa11-icon svg { transform: translateY(-2px); }\n.hb-xa11[data-kick=\"a\"] .hb-xa11-icon svg { animation: hb-xa11-ka 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xa11[data-kick=\"b\"] .hb-xa11-icon svg { animation: hb-xa11-kb 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xa11-body { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3em; }\n.hb-xa11-label { font-size: 0.68em; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #8f8f8f; }\n.hb-xa11[aria-pressed=\"true\"] .hb-xa11-label { color: color-mix(in srgb, var(--hb-xa11-c) 70%, #fff); }\n.hb-xa11-num {\n  position: relative;\n  display: inline-flex;\n  height: 1.15em;\n  font-family: var(--font-grotesk, inherit);\n  font-size: 1.05em;\n  font-variant-numeric: tabular-nums;\n  overflow: hidden;\n  -webkit-mask: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);\n  mask: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);\n}\n.hb-xa11-col { display: inline-block; width: 0.62em; height: 1.15em; text-align: center; }\n.hb-xa11-sep { display: inline-block; width: 0.3em; text-align: center; color: #8f8f8f; }\n.hb-xa11-strip {\n  display: flex;\n  flex-direction: column;\n  transform: translateY(calc(var(--hb-xa11-d) * -1.15em));\n  transition: transform 0.75s cubic-bezier(0.3, 1.35, 0.5, 1);\n  transition-delay: var(--hb-xa11-dl);\n}\n.hb-xa11-strip span { display: block; height: 1.15em; line-height: 1.15em; }\n.hb-xa11-plus {\n  position: absolute;\n  right: 0.7em;\n  top: 0.2em;\n  font-size: 0.72em;\n  font-weight: 700;\n  color: var(--hb-xa11-c);\n  opacity: 0;\n  pointer-events: none;\n}\n.hb-xa11[data-kick][aria-pressed=\"true\"] .hb-xa11-plus { animation: hb-xa11-plus 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }\n@keyframes hb-xa11-ka { 0% { transform: translateY(0); } 35% { transform: translateY(-140%); } 36% { transform: translateY(140%); } 100% { transform: translateY(0); } }\n@keyframes hb-xa11-kb { 0% { transform: translateY(0); } 35% { transform: translateY(-140%); } 36% { transform: translateY(140%); } 100% { transform: translateY(0); } }\n@keyframes hb-xa11-plus { 0% { opacity: 0; transform: translateY(6px) scale(0.8); } 25% { opacity: 1; transform: translateY(-4px) scale(1); } 100% { opacity: 0; transform: translateY(-18px) scale(1); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xa11, .hb-xa11-icon, .hb-xa11-icon svg, .hb-xa11-strip { transition: none; }\n  .hb-xa11[data-kick] .hb-xa11-icon svg, .hb-xa11[data-kick][aria-pressed=\"true\"] .hb-xa11-plus { animation: none; }\n}\n`;\n\nconst digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\nexport function ButtonOdometer({\n  count,\n  defaultCount = 1284,\n  voted,\n  defaultVoted = false,\n  onVoteChange,\n  accent = \"#ff6b3d\",\n  label = \"Upvote\",\n  locale = \"en-US\",\n  type = \"button\",\n  className = \"\",\n  style,\n  onClick,\n  ...rest\n}: ButtonOdometerProps) {\n  const [innerCount, setInnerCount] = React.useState(defaultCount);\n  const [innerVoted, setInnerVoted] = React.useState(defaultVoted);\n  const [kick, setKick] = React.useState<\"a\" | \"b\" | undefined>(undefined);\n  const isVoted = voted ?? innerVoted;\n  const value = Math.max(0, Math.round(count ?? innerCount));\n  const text = new Intl.NumberFormat(locale).format(value);\n  const chars = Array.from(text);\n  let digitIndex = 0;\n  const totalDigits = chars.filter((c) => c >= \"0\" && c <= \"9\").length;\n\n  const vars = { \"--hb-xa11-c\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-button-odometer\" precedence=\"default\">{css}</style>\n      <button\n        type={type}\n        className={`hb-xa11 ${className}`}\n        style={vars}\n        aria-pressed={isVoted}\n        aria-label={`${label}, ${text} votes`}\n        data-kick={kick}\n        onClick={(e) => {\n          const next = !isVoted;\n          const nextCount = Math.max(0, value + (next ? 1 : -1));\n          if (voted === undefined) setInnerVoted(next);\n          if (count === undefined) setInnerCount(nextCount);\n          if (next) setKick((k) => (k === \"a\" ? \"b\" : \"a\"));\n          onVoteChange?.(next, nextCount);\n          onClick?.(e);\n        }}\n        {...rest}\n      >\n        <span className=\"hb-xa11-icon\" aria-hidden=\"true\">\n          <svg viewBox=\"0 0 16 16\" fill=\"currentColor\">\n            <path d=\"M8 2.6c.3 0 .6.14.8.38l5 6.1c.5.62.06 1.52-.74 1.52H10.5v2.6c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1V10.6H2.94c-.8 0-1.24-.9-.74-1.52l5-6.1c.2-.24.5-.38.8-.38Z\" />\n          </svg>\n        </span>\n        <span className=\"hb-xa11-body\" aria-hidden=\"true\">\n          <span className=\"hb-xa11-label\">{isVoted ? \"Upvoted\" : label}</span>\n          <span className=\"hb-xa11-num\">\n            {chars.map((c, i) => {\n              const fromRight = chars.length - i;\n              if (c < \"0\" || c > \"9\") {\n                return (\n                  <span className=\"hb-xa11-sep\" key={`s${fromRight}`}>\n                    {c}\n                  </span>\n                );\n              }\n              const order = totalDigits - 1 - digitIndex;\n              digitIndex += 1;\n              const v = {\n                \"--hb-xa11-d\": c,\n                \"--hb-xa11-dl\": `${(order * 0.06).toFixed(2)}s`,\n              } as React.CSSProperties;\n              return (\n                <span className=\"hb-xa11-col\" key={`d${fromRight}`}>\n                  <span className=\"hb-xa11-strip\" style={v}>\n                    {digits.map((d) => (\n                      <span key={d}>{d}</span>\n                    ))}\n                  </span>\n                </span>\n              );\n            })}\n          </span>\n        </span>\n        <span className=\"hb-xa11-plus\" aria-hidden=\"true\">+1</span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}