{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "social-follow-count",
  "type": "registry:component",
  "title": "Social Follow Count",
  "description": "A Follow button joined to the follower count, where following rolls the digits up by one and slides your avatar into the front of the stack. The label flips to Following with a check that draws itself.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "follow",
    "counter",
    "avatars",
    "profile",
    "social",
    "odometer"
  ],
  "docs": "https://hyperblur.dev/effects/social-follow-count",
  "files": [
    {
      "path": "registry/hyperblur/social-follow-count.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/social-follow-count.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SocialFollowCountLabels {\n  follow?: string;\n  following?: string;\n  followers?: string;\n}\n\nexport interface SocialFollowCountProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  following?: boolean;\n  defaultFollowing?: boolean;\n  onFollowChange?: (following: boolean, count: number) => void;\n  count?: number;\n  avatars?: string[];\n  viewerInitials?: string;\n  accent?: string;\n  locale?: string;\n  labels?: SocialFollowCountLabels;\n  disabled?: boolean;\n}\n\nconst css = `\n.hb-xc10 { --hb-xc10-a: #2f7bff; position: relative; display: inline-flex; align-items: stretch; height: 40px; max-width: 100%; box-sizing: border-box; font-family: inherit; border-radius: 999px; background: #121212; box-shadow: inset 0 0 0 1px #262626, inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 24px -16px rgba(0, 0, 0, 0.9); }\n.hb-xc10 *, .hb-xc10 *::before, .hb-xc10 *::after { box-sizing: border-box; }\n.hb-xc10-b {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 7px;\n  flex: none;\n  margin: 3px;\n  padding: 0 15px 0 12px;\n  border: 0;\n  border-radius: 999px;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 600;\n  color: #ffffff;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xc10-a) 82%, #ffffff), var(--hb-xc10-a));\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 14px -6px color-mix(in srgb, var(--hb-xc10-a) 70%, transparent);\n  cursor: pointer;\n  overflow: hidden;\n  -webkit-tap-highlight-color: transparent;\n  transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-xc10-b:active:not(:disabled) { transform: scale(0.95); }\n.hb-xc10-b:focus-visible { outline: 2px solid var(--hb-xc10-a); outline-offset: 2px; }\n.hb-xc10-b:disabled { opacity: 0.5; cursor: not-allowed; }\n.hb-xc10[data-on=\"true\"] .hb-xc10-b { color: #ededed; background: #1d1d1d; box-shadow: inset 0 0 0 1px #2e2e2e, inset 0 1px 0 rgba(255, 255, 255, 0.05); }\n.hb-xc10-g { position: relative; width: 14px; height: 14px; flex: none; }\n.hb-xc10-g svg { position: absolute; inset: 0; width: 14px; height: 14px; transition: transform 0.45s cubic-bezier(0.34, 1.5, 0.5, 1), opacity 0.2s ease; }\n.hb-xc10-g svg + svg { opacity: 0; transform: rotate(-45deg) scale(0.4); }\n.hb-xc10[data-on=\"true\"] .hb-xc10-g svg:first-child { opacity: 0; transform: rotate(90deg) scale(0.4); }\n.hb-xc10[data-on=\"true\"] .hb-xc10-g svg + svg { opacity: 1; transform: none; color: #3ddc84; }\n.hb-xc10-g path.hb-xc10-ck { stroke-dasharray: 16; stroke-dashoffset: 16; transition: stroke-dashoffset 0.35s cubic-bezier(0.65, 0, 0.35, 1) 0.12s; }\n.hb-xc10[data-on=\"true\"] .hb-xc10-g path.hb-xc10-ck { stroke-dashoffset: 0; }\n.hb-xc10-txt { display: grid; }\n.hb-xc10-txt > span { grid-area: 1 / 1; white-space: nowrap; transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease; }\n.hb-xc10-txt > span + span { opacity: 0; transform: translateY(100%); }\n.hb-xc10[data-on=\"true\"] .hb-xc10-txt > span:first-child { opacity: 0; transform: translateY(-100%); }\n.hb-xc10[data-on=\"true\"] .hb-xc10-txt > span + span { opacity: 1; transform: none; }\n.hb-xc10-meta { display: inline-flex; align-items: center; gap: 9px; min-width: 0; padding: 0 14px 0 6px; }\n.hb-xc10-st { display: inline-flex; align-items: center; flex: none; }\n.hb-xc10-av {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  width: 24px;\n  height: 24px;\n  margin-left: -7px;\n  border-radius: 50%;\n  font-size: 9px;\n  font-weight: 700;\n  letter-spacing: 0.02em;\n  color: rgba(255, 255, 255, 0.92);\n  background: var(--hb-xc10-bg);\n  box-shadow: 0 0 0 2px #121212;\n  transition: margin 0.45s cubic-bezier(0.34, 1.4, 0.5, 1);\n}\n.hb-xc10-av:first-child { margin-left: 0; }\n.hb-xc10-you { width: 0; margin-left: 0; overflow: hidden; transform: scale(0.2); opacity: 0; transition: width 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), margin 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), transform 0.45s cubic-bezier(0.34, 1.6, 0.5, 1), opacity 0.2s ease; background: linear-gradient(135deg, color-mix(in srgb, var(--hb-xc10-a) 70%, #ffffff), var(--hb-xc10-a)); }\n.hb-xc10[data-on=\"true\"] .hb-xc10-you { width: 24px; transform: scale(1); opacity: 1; }\n.hb-xc10[data-on=\"true\"] .hb-xc10-you + .hb-xc10-av { margin-left: -7px; }\n.hb-xc10-you + .hb-xc10-av { margin-left: 0; }\n.hb-xc10-n { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; white-space: nowrap; }\n.hb-xc10-num { font-size: 13px; font-weight: 650; color: #ededed; font-variant-numeric: tabular-nums; }\n.hb-xc10-lbl { font-size: 12px; color: #8f8f8f; overflow: hidden; text-overflow: ellipsis; }\n.hb-xc10-roll { display: inline-flex; overflow: hidden; height: 1.15em; line-height: 1.15; }\n.hb-xc10-col { display: inline-flex; flex-direction: column; transition: transform 0.65s cubic-bezier(0.2, 0.9, 0.2, 1); transition-delay: var(--hb-xc10-dl, 0ms); }\n.hb-xc10-col span, .hb-xc10-sep { display: block; height: 1.15em; }\n.hb-xc10-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xc10-b, .hb-xc10-g svg, .hb-xc10-g path.hb-xc10-ck, .hb-xc10-txt > span, .hb-xc10-av, .hb-xc10-you, .hb-xc10-col { transition: none; }\n  .hb-xc10-b:active:not(:disabled) { transform: none; }\n}\n`;\n\nconst PALETTE = [\"#7c5cff\", \"#ff7a59\", \"#1fb5a8\", \"#e6489a\", \"#d9a21b\", \"#4a8cff\"];\n\nfunction hash(s: string) {\n  let h = 2166136261;\n  for (let i = 0; i < s.length; i++) {\n    h ^= s.charCodeAt(i);\n    h = Math.imul(h, 16777619);\n  }\n  return h >>> 0;\n}\n\nfunction Roll({ value, locale }: { value: number; locale: string }) {\n  const chars = new Intl.NumberFormat(locale).format(value).split(\"\");\n  return (\n    <span className=\"hb-xc10-roll\" aria-hidden=\"true\">\n      {chars.map((ch, i) => {\n        const fromRight = chars.length - 1 - i;\n        const d = Number(ch);\n        if (Number.isNaN(d) || ch === \" \") {\n          return (\n            <span key={`s${fromRight}`} className=\"hb-xc10-sep\">\n              {ch}\n            </span>\n          );\n        }\n        return (\n          <span\n            key={`d${fromRight}`}\n            className=\"hb-xc10-col\"\n            style={{ transform: `translateY(${(-d * 1.15).toFixed(2)}em)`, \"--hb-xc10-dl\": `${fromRight * 45}ms` } as React.CSSProperties}\n          >\n            {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((k) => (\n              <span key={k}>{k}</span>\n            ))}\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n\nexport function SocialFollowCount({\n  following: followingProp,\n  defaultFollowing = false,\n  onFollowChange,\n  count = 12839,\n  avatars = [\"MR\", \"JS\", \"AK\"],\n  viewerInitials = \"AM\",\n  accent = \"#2f7bff\",\n  locale = \"en-US\",\n  labels,\n  disabled = false,\n  className = \"\",\n  style,\n  ...rest\n}: SocialFollowCountProps) {\n  const [inner, setInner] = React.useState(defaultFollowing);\n  const on = followingProp ?? inner;\n  const baseFollowing = followingProp ?? defaultFollowing;\n  const base = baseFollowing ? count - 1 : count;\n  const value = base + (on ? 1 : 0);\n  const t = { follow: \"Follow\", following: \"Following\", followers: \"followers\", ...labels };\n  const fmt = new Intl.NumberFormat(locale);\n\n  function toggle() {\n    const next = !on;\n    if (followingProp === undefined) setInner(next);\n    onFollowChange?.(next, base + (next ? 1 : 0));\n  }\n\n  return (\n    <>\n      <style href=\"hb-social-follow-count\" precedence=\"default\">{css}</style>\n      <div\n        className={`hb-xc10 ${className}`}\n        style={{ \"--hb-xc10-a\": accent, ...style } as React.CSSProperties}\n        data-on={on ? \"true\" : undefined}\n        {...rest}\n      >\n        <button type=\"button\" className=\"hb-xc10-b\" aria-pressed={on} disabled={disabled} onClick={toggle}>\n          <span className=\"hb-xc10-g\" aria-hidden=\"true\">\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\">\n              <path d=\"M8 3v10M3 8h10\" />\n            </svg>\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.2} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <path className=\"hb-xc10-ck\" d=\"m3 8.5 3.2 3.2L13 4.8\" />\n            </svg>\n          </span>\n          <span className=\"hb-xc10-txt\">\n            <span aria-hidden={on || undefined}>{t.follow}</span>\n            <span aria-hidden={!on || undefined}>{t.following}</span>\n          </span>\n        </button>\n        <span className=\"hb-xc10-meta\">\n          <span className=\"hb-xc10-st\" aria-hidden=\"true\">\n            <span className=\"hb-xc10-av hb-xc10-you\">{viewerInitials}</span>\n            {avatars.slice(0, 3).map((a, i) => (\n              <span\n                key={`${a}-${i}`}\n                className=\"hb-xc10-av\"\n                style={{ \"--hb-xc10-bg\": PALETTE[hash(`${a}${i}`) % PALETTE.length] } as React.CSSProperties}\n              >\n                {a}\n              </span>\n            ))}\n          </span>\n          <span className=\"hb-xc10-n\">\n            <span className=\"hb-xc10-num\">\n              <Roll value={value} locale={locale} />\n            </span>\n            <span className=\"hb-xc10-lbl\">{t.followers}</span>\n            <span className=\"hb-xc10-sr\" aria-live=\"polite\">\n              {fmt.format(value)} {t.followers}\n            </span>\n          </span>\n        </span>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}