{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "loader-battery-fill",
  "type": "registry:component",
  "title": "Loader Battery Fill",
  "description": "A battery icon fills with segments, pulses when full and starts over. Pass a value to show a fixed charge level instead.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "loaders",
    "loader",
    "battery",
    "charging",
    "progress",
    "device",
    "css"
  ],
  "docs": "https://hyperblur.dev/effects/loader-battery-fill",
  "files": [
    {
      "path": "registry/hyperblur/loader-battery-fill.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/loader-battery-fill.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LoaderBatteryFillProps extends React.HTMLAttributes<HTMLSpanElement> {\n  size?: number;\n  color?: string;\n  accent?: string;\n  speed?: number;\n  segments?: number;\n  value?: number;\n  label?: string;\n}\n\nconst css = `\n.hb-yb4 {\n  position: relative;\n  display: inline-flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 8px;\n  vertical-align: middle;\n  box-sizing: border-box;\n  font-family: inherit;\n}\n.hb-yb4 *, .hb-yb4 *::before, .hb-yb4 *::after { box-sizing: border-box; }\n.hb-yb4-bat {\n  display: flex;\n  flex: none;\n  align-items: center;\n  width: calc(var(--hb-yb4-w) + var(--hb-yb4-w) * 0.07);\n  height: calc(var(--hb-yb4-w) * 0.5);\n}\n.hb-yb4-body {\n  position: relative;\n  display: flex;\n  flex: none;\n  align-items: stretch;\n  width: var(--hb-yb4-w);\n  height: 100%;\n  padding: var(--hb-yb4-pd);\n  border: var(--hb-yb4-b) solid var(--hb-yb4-a);\n  border-radius: calc(var(--hb-yb4-w) * 0.12);\n}\n.hb-yb4-nub {\n  flex: none;\n  width: calc(var(--hb-yb4-w) * 0.07);\n  height: 38%;\n  margin-left: 1px;\n  border-radius: 0 3px 3px 0;\n  background: var(--hb-yb4-a);\n}\n.hb-yb4-fill {\n  flex: none;\n  width: var(--hb-yb4-f, 100%);\n  height: 100%;\n  overflow: hidden;\n  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-yb4-segs {\n  display: flex;\n  gap: var(--hb-yb4-sg);\n  width: var(--hb-yb4-iw);\n  height: 100%;\n}\n.hb-yb4-segs i {\n  display: block;\n  flex: 1;\n  border-radius: calc(var(--hb-yb4-w) * 0.035);\n  background: linear-gradient(180deg, var(--hb-yb4-a), var(--hb-yb4-c) 70%);\n}\n.hb-yb4-loop .hb-yb4-fill {\n  width: 0;\n  transition: none;\n  animation:\n    hb-yb4-grow var(--hb-yb4-d) steps(var(--hb-yb4-n), end) infinite,\n    hb-yb4-out var(--hb-yb4-d) linear infinite;\n}\n.hb-yb4-loop .hb-yb4-bat {\n  animation: hb-yb4-pulse var(--hb-yb4-d) ease-in-out infinite;\n}\n.hb-yb4-full .hb-yb4-bat {\n  animation: hb-yb4-beat 1.8s ease-in-out infinite;\n}\n.hb-yb4-l {\n  font-size: 12px;\n  line-height: 1.2;\n  letter-spacing: 0.01em;\n  color: inherit;\n  opacity: 0.72;\n  white-space: nowrap;\n}\n.hb-yb4-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@keyframes hb-yb4-grow {\n  0% { width: 0; }\n  66%, 100% { width: 100%; }\n}\n@keyframes hb-yb4-out {\n  0%, 90% { opacity: 1; }\n  98%, 100% { opacity: 0; }\n}\n@keyframes hb-yb4-pulse {\n  0%, 64%, 92%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }\n  72% { transform: scale(1.06); filter: drop-shadow(0 0 7px var(--hb-yb4-c)); }\n  80% { transform: scale(1); filter: drop-shadow(0 0 1px var(--hb-yb4-c)); }\n  86% { transform: scale(1.06); filter: drop-shadow(0 0 7px var(--hb-yb4-c)); }\n}\n@keyframes hb-yb4-beat {\n  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }\n  50% { transform: scale(1.06); filter: drop-shadow(0 0 7px var(--hb-yb4-c)); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-yb4-loop .hb-yb4-fill {\n    animation: none;\n    width: calc(100% * (var(--hb-yb4-n) - 1) / var(--hb-yb4-n));\n  }\n  .hb-yb4-loop .hb-yb4-bat, .hb-yb4-full .hb-yb4-bat { animation: none; }\n  .hb-yb4-fill { transition: none; }\n}\n`;\n\nexport function LoaderBatteryFill({\n  size = 56,\n  color = \"#2f7bff\",\n  accent = \"#7fb3ff\",\n  speed = 2.8,\n  segments = 4,\n  value,\n  label,\n  className = \"\",\n  style,\n  ...rest\n}: LoaderBatteryFillProps) {\n  const n = Math.max(2, Math.min(8, Math.round(segments)));\n  const controlled = typeof value === \"number\" && Number.isFinite(value);\n  const clamped = controlled ? Math.max(0, Math.min(100, value)) : 0;\n  const lit = controlled ? Math.round((clamped / 100) * n) : n;\n  const border = Math.max(1.5, size * 0.045);\n  const pad = Math.max(1.5, size * 0.05);\n  const gap = Math.max(1, size * 0.03);\n\n  const vars = {\n    \"--hb-yb4-w\": `${size}px`,\n    \"--hb-yb4-b\": `${border.toFixed(2)}px`,\n    \"--hb-yb4-pd\": `${pad.toFixed(2)}px`,\n    \"--hb-yb4-sg\": `${gap.toFixed(2)}px`,\n    \"--hb-yb4-iw\": `${(size - 2 * border - 2 * pad).toFixed(2)}px`,\n    \"--hb-yb4-n\": n,\n    \"--hb-yb4-d\": `${(speed > 0 ? speed : 2.8).toFixed(3)}s`,\n    \"--hb-yb4-c\": color,\n    \"--hb-yb4-a\": accent,\n    \"--hb-yb4-f\": controlled ? `${((lit / n) * 100).toFixed(2)}%` : undefined,\n    ...style,\n  } as React.CSSProperties;\n\n  const mode = !controlled ? \"hb-yb4-loop\" : lit === n ? \"hb-yb4-full\" : \"\";\n  const percent = controlled ? ` ${Math.round(clamped)}%` : \"\";\n\n  return (\n    <span role=\"status\" className={`hb-yb4 ${mode} ${className}`} style={vars} {...rest}>\n      <style href=\"hb-loader-battery-fill\" precedence=\"default\">{css}</style>\n      <span className=\"hb-yb4-bat\" aria-hidden=\"true\">\n        <span className=\"hb-yb4-body\">\n          <span className=\"hb-yb4-fill\">\n            <span className=\"hb-yb4-segs\">\n              {Array.from({ length: n }, (_, i) => (\n                <i key={i} />\n              ))}\n            </span>\n          </span>\n        </span>\n        <span className=\"hb-yb4-nub\" />\n      </span>\n      {label ? (\n        <>\n          <span className=\"hb-yb4-l\">{label}</span>\n          {percent ? <span className=\"hb-yb4-sr\">{percent}</span> : null}\n        </>\n      ) : (\n        <span className=\"hb-yb4-sr\">{`Charging${percent}`}</span>\n      )}\n    </span>\n  );\n}\n"
    }
  ]
}