{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "loader-percentage",
  "type": "registry:component",
  "title": "Loader Percentage",
  "description": "A large percentage counter inside an SVG ring that fills as it counts. Pass a value, or leave it out to run a looping demo.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "loaders",
    "loader",
    "percentage",
    "progress",
    "ring",
    "counter",
    "svg"
  ],
  "docs": "https://hyperblur.dev/effects/loader-percentage",
  "files": [
    {
      "path": "registry/hyperblur/loader-percentage.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/loader-percentage.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LoaderPercentageProps extends React.HTMLAttributes<HTMLSpanElement> {\n  value?: number;\n  size?: number;\n  color?: string;\n  accent?: string;\n  thickness?: number;\n  duration?: number;\n  label?: string;\n}\n\nconst css = `\n.hb-qc6 {\n  position: relative;\n  display: inline-flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 0.7em;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n  vertical-align: middle;\n}\n.hb-qc6 *, .hb-qc6 *::before, .hb-qc6 *::after { box-sizing: border-box; }\n.hb-qc6-g {\n  position: relative;\n  flex: none;\n  width: var(--hb-qc6-s);\n  height: var(--hb-qc6-s);\n}\n.hb-qc6-svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }\n.hb-qc6-bg { fill: none; stroke: #262626; }\n.hb-qc6-fg { fill: none; stroke-linecap: round; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--hb-qc6-c) 55%, transparent)); }\n.hb-qc6-n {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  font-size: calc(var(--hb-qc6-s) * 0.26);\n  font-weight: 600;\n  letter-spacing: -0.03em;\n  font-variant-numeric: tabular-nums;\n  line-height: 1;\n}\n.hb-qc6-n small { margin-left: 0.08em; font-size: 0.5em; font-weight: 500; color: #8f8f8f; letter-spacing: 0; }\n.hb-qc6-l { font-size: 12px; line-height: 1.3; color: #a1a1a1; white-space: nowrap; }\n.hb-qc6-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  padding: 0;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n  border: 0;\n}\n`;\n\nfunction ease(t: number) {\n  return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;\n}\n\nexport function LoaderPercentage({\n  value,\n  size = 112,\n  color = \"#2f7bff\",\n  accent = \"#7fb3ff\",\n  thickness = 6,\n  duration = 4200,\n  label,\n  className = \"\",\n  style,\n  ...rest\n}: LoaderPercentageProps) {\n  const gid = React.useId();\n  const [loop, setLoop] = React.useState(0);\n  const controlled = typeof value === \"number\" && Number.isFinite(value);\n\n  React.useEffect(() => {\n    if (controlled) return;\n    let raf = 0;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      raf = requestAnimationFrame(() => setLoop(72));\n      return () => cancelAnimationFrame(raf);\n    }\n    let t0 = 0;\n    const hold = 900;\n    const total = Math.max(600, duration);\n    function tick(now: number) {\n      if (!t0) t0 = now;\n      const t = (now - t0) % (total + hold);\n      setLoop(t >= total ? 100 : Math.round(ease(t / total) * 100));\n      raf = requestAnimationFrame(tick);\n    }\n    raf = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(raf);\n  }, [controlled, duration]);\n\n  const pct = Math.min(100, Math.max(0, controlled ? (value as number) : loop));\n  const r = 44;\n  const c = 2 * Math.PI * r;\n  const offset = c * (1 - pct / 100);\n  const stroke = (thickness / size) * 100;\n  const vars = {\n    \"--hb-qc6-s\": `${size}px`,\n    \"--hb-qc6-c\": color,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-loader-percentage\" precedence=\"default\">{css}</style>\n      <span role=\"status\" className={`hb-qc6 ${className}`} style={vars} {...rest}>\n        <span\n          className=\"hb-qc6-g\"\n          role=\"progressbar\"\n          aria-valuemin={0}\n          aria-valuemax={100}\n          aria-valuenow={Math.round(pct)}\n          aria-label={label ?? \"Loading\"}\n        >\n          <svg className=\"hb-qc6-svg\" viewBox=\"0 0 100 100\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient id={`${gid}g`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">\n                <stop offset=\"0%\" stopColor={accent} />\n                <stop offset=\"100%\" stopColor={color} />\n              </linearGradient>\n            </defs>\n            <circle className=\"hb-qc6-bg\" cx=\"50\" cy=\"50\" r={r} strokeWidth={stroke.toFixed(2)} />\n            <circle\n              className=\"hb-qc6-fg\"\n              cx=\"50\"\n              cy=\"50\"\n              r={r}\n              strokeWidth={stroke.toFixed(2)}\n              stroke={`url(#${gid}g)`}\n              strokeDasharray={c.toFixed(3)}\n              strokeDashoffset={offset.toFixed(3)}\n            />\n          </svg>\n          <span className=\"hb-qc6-n\" aria-hidden=\"true\">\n            {Math.round(pct)}\n            <small>%</small>\n          </span>\n        </span>\n        <span className={label ? \"hb-qc6-l\" : \"hb-qc6-sr\"}>{label ?? \"Loading\"}</span>\n      </span>\n    </>\n  );\n}\n"
    }
  ]
}