{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "loader-gauge-counter",
  "type": "registry:component",
  "title": "Loader Gauge Counter",
  "description": "A segmented 240 degree gauge fills with a color ramp and a glowing tip while an odometer of rolling digits counts up in the center. Leading zeros stay dimmed like an instrument panel.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "loaders",
    "progress",
    "gauge",
    "odometer",
    "counter",
    "backup",
    "svg"
  ],
  "docs": "https://hyperblur.dev/effects/loader-gauge-counter",
  "files": [
    {
      "path": "registry/hyperblur/loader-gauge-counter.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/loader-gauge-counter.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LoaderGaugeCounterProps extends React.HTMLAttributes<HTMLDivElement> {\n  value?: number;\n  size?: number;\n  segments?: number;\n  color?: string;\n  accent?: string;\n  detail?: string;\n  duration?: number;\n  label?: string;\n}\n\nconst START = 150;\nconst SWEEP = 240;\n\nfunction polar(r: number, deg: number): [number, number] {\n  const a = (deg * Math.PI) / 180;\n  return [50 + Math.cos(a) * r, 50 + Math.sin(a) * r];\n}\n\nfunction arc(r: number, a1: number, a2: number) {\n  const [x1, y1] = polar(r, a1);\n  const [x2, y2] = polar(r, a2);\n  return `M${x1.toFixed(2)} ${y1.toFixed(2)}A${r} ${r} 0 ${a2 - a1 > 180 ? 1 : 0} 1 ${x2.toFixed(2)} ${y2.toFixed(2)}`;\n}\n\nconst css = `\n.hb-vk8 {\n  position: relative;\n  display: inline-flex;\n  flex-direction: column;\n  align-items: center;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n  vertical-align: middle;\n}\n.hb-vk8 *, .hb-vk8 *::before, .hb-vk8 *::after { box-sizing: border-box; }\n.hb-vk8-g {\n  position: relative;\n  width: var(--hb-vk8-s);\n  height: calc(var(--hb-vk8-s) * 0.84);\n  flex: none;\n}\n.hb-vk8-svg { position: absolute; left: 0; top: 0; width: 100%; height: calc(var(--hb-vk8-s)); display: block; overflow: visible; }\n.hb-vk8-seg { fill: none; stroke: #232323; stroke-width: 7; transition: stroke 180ms ease; }\n.hb-vk8-seg[data-on=\"true\"] { stroke: var(--hb-vk8-col); }\n.hb-vk8-in { fill: none; stroke: #1c1c1c; stroke-width: 0.8; stroke-dasharray: 0.6 2.4; }\n.hb-vk8-tip { fill: #fff; filter: drop-shadow(0 0 3px var(--hb-vk8-a)) drop-shadow(0 0 7px var(--hb-vk8-c)); }\n.hb-vk8-c {\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: calc(var(--hb-vk8-s) * 0.33);\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: calc(var(--hb-vk8-s) * 0.03);\n}\n.hb-vk8-num {\n  display: flex;\n  align-items: flex-start;\n  font-size: calc(var(--hb-vk8-s) * 0.22);\n  font-weight: 600;\n  letter-spacing: -0.04em;\n  line-height: 1;\n  font-variant-numeric: tabular-nums;\n}\n.hb-vk8-col {\n  position: relative;\n  height: 1em;\n  width: 0.62em;\n  overflow: hidden;\n  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);\n  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);\n}\n.hb-vk8-strip {\n  display: flex;\n  flex-direction: column;\n  transform: translateY(calc(var(--hb-vk8-d) * -1em));\n  transition: transform 520ms cubic-bezier(0.34, 1.3, 0.64, 1), color 300ms ease;\n}\n.hb-vk8-strip span { display: block; height: 1em; text-align: center; }\n.hb-vk8-col[data-dim=\"true\"] .hb-vk8-strip { color: #343434; }\n.hb-vk8-pct { font-size: 0.42em; margin: 0.14em 0 0 0.08em; color: #8f8f8f; font-weight: 500; letter-spacing: 0; }\n.hb-vk8-det {\n  font-size: calc(var(--hb-vk8-s) * 0.075);\n  line-height: 1.2;\n  color: var(--hb-vk8-a);\n  letter-spacing: 0.02em;\n  white-space: nowrap;\n  font-variant-numeric: tabular-nums;\n}\n.hb-vk8-scale {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: calc(var(--hb-vk8-s) * 0.02);\n  display: flex;\n  justify-content: space-between;\n  padding: 0 calc(var(--hb-vk8-s) * 0.17);\n  font-size: calc(var(--hb-vk8-s) * 0.06);\n  color: #5a5a5a;\n  font-variant-numeric: tabular-nums;\n}\n.hb-vk8-l { margin-top: 0.5em; font-size: 12px; line-height: 1.3; color: #a1a1a1; white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vk8-seg, .hb-vk8-strip { transition: none; }\n}\n`;\n\nfunction easeOut(t: number) {\n  return 1 - Math.pow(1 - t, 2.4);\n}\n\nexport function LoaderGaugeCounter({\n  value,\n  size = 150,\n  segments = 36,\n  color = \"#2f7bff\",\n  accent = \"#7fb3ff\",\n  detail,\n  duration = 5200,\n  label,\n  className = \"\",\n  style,\n  ...rest\n}: LoaderGaugeCounterProps) {\n  const gid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const controlled = typeof value === \"number\" && Number.isFinite(value);\n  const [loop, setLoop] = React.useState(0);\n\n  React.useEffect(() => {\n    if (controlled) return;\n    let id = 0;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      id = window.setTimeout(() => setLoop(100), 0);\n      return () => window.clearTimeout(id);\n    }\n    const total = Math.max(1500, duration);\n    const hold = 1200;\n    let t = 0;\n    function step() {\n      t += 120;\n      const local = t % (total + hold);\n      setLoop(local >= total ? 100 : Math.floor(easeOut(local / total) * 100));\n      id = window.setTimeout(step, 120);\n    }\n    id = window.setTimeout(step, 120);\n    return () => window.clearTimeout(id);\n  }, [controlled, duration]);\n\n  const pct = Math.min(100, Math.max(0, controlled ? (value as number) : loop));\n  const shown = Math.floor(pct);\n  const n = Math.max(8, Math.min(80, Math.round(segments)));\n  const slot = SWEEP / n;\n  const gap = Math.min(2.2, slot * 0.35);\n  const lit = (pct / 100) * n;\n  const tipDeg = START + (SWEEP * pct) / 100;\n  const [tx, ty] = polar(36.5, tipDeg);\n  const digits = [Math.floor(shown / 100) % 10, Math.floor(shown / 10) % 10, shown % 10];\n  const vars = {\n    \"--hb-vk8-s\": `${size}px`,\n    \"--hb-vk8-c\": color,\n    \"--hb-vk8-a\": accent,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-loader-gauge-counter\" precedence=\"default\">{css}</style>\n      <div className={`hb-vk8 ${className}`} style={vars} {...rest}>\n        <div\n          className=\"hb-vk8-g\"\n          role=\"progressbar\"\n          aria-valuemin={0}\n          aria-valuemax={100}\n          aria-valuenow={shown}\n          aria-valuetext={detail ? `${shown}%, ${detail}` : `${shown}%`}\n          aria-label={label ?? \"Progress\"}\n        >\n          <svg className=\"hb-vk8-svg\" viewBox=\"0 0 100 100\" aria-hidden=\"true\">\n            <defs>\n              <filter id={`${gid}b`} x=\"-20%\" y=\"-20%\" width=\"140%\" height=\"140%\">\n                <feGaussianBlur stdDeviation=\"2.4\" />\n              </filter>\n            </defs>\n            <path className=\"hb-vk8-in\" d={arc(30, START, START + SWEEP)} />\n            {pct > 0 ? (\n              <path\n                d={arc(40, START, START + Math.max(0.5, (SWEEP * pct) / 100))}\n                fill=\"none\"\n                stroke={color}\n                strokeWidth=\"7\"\n                opacity=\"0.35\"\n                filter={`url(#${gid}b)`}\n              />\n            ) : null}\n            {Array.from({ length: n }, (_, i) => {\n              const a1 = START + i * slot + gap / 2;\n              const a2 = START + (i + 1) * slot - gap / 2;\n              const mix = Math.round((i / Math.max(1, n - 1)) * 100);\n              return (\n                <path\n                  key={i}\n                  className=\"hb-vk8-seg\"\n                  data-on={i < lit}\n                  d={arc(40, a1, a2)}\n                  style={{ \"--hb-vk8-col\": `color-mix(in srgb, var(--hb-vk8-a) ${mix}%, var(--hb-vk8-c))` } as React.CSSProperties}\n                />\n              );\n            })}\n            <circle className=\"hb-vk8-tip\" cx={tx.toFixed(2)} cy={ty.toFixed(2)} r=\"1.6\" />\n          </svg>\n          <div className=\"hb-vk8-c\" aria-hidden=\"true\">\n            <div className=\"hb-vk8-num\">\n              {digits.map((d, i) => (\n                <span\n                  key={i}\n                  className=\"hb-vk8-col\"\n                  data-dim={(i === 0 && shown < 100) || (i === 1 && shown < 10)}\n                  style={{ \"--hb-vk8-d\": d } as React.CSSProperties}\n                >\n                  <span className=\"hb-vk8-strip\">\n                    {Array.from({ length: 10 }, (_, k) => (\n                      <span key={k}>{k}</span>\n                    ))}\n                  </span>\n                </span>\n              ))}\n              <span className=\"hb-vk8-pct\">%</span>\n            </div>\n            {detail ? <span className=\"hb-vk8-det\">{detail}</span> : null}\n          </div>\n          <div className=\"hb-vk8-scale\" aria-hidden=\"true\">\n            <span>0</span>\n            <span>100</span>\n          </div>\n        </div>\n        {label ? <span className=\"hb-vk8-l\">{label}</span> : null}\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}