{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-tech-readout",
  "type": "registry:component",
  "title": "Tech Readout",
  "description": "Text that appears like an instrument readout: letters flip through glyphs before settling, corner brackets and a tick scale draw in, and small mono labels fade up around it.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "text",
    "hud",
    "readout",
    "technical",
    "scramble",
    "brackets",
    "sci-fi"
  ],
  "docs": "https://hyperblur.dev/effects/text-tech-readout",
  "files": [
    {
      "path": "registry/hyperblur/text-tech-readout.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/text-tech-readout.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TechReadoutProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  text?: string;\n  meta?: string[];\n  glyphs?: string;\n  duration?: number;\n  size?: number;\n  accent?: string;\n  replayEvery?: number;\n}\n\nconst css = `\n.hb-qs5 {\n  --hb-qs5-c: #2f7bff;\n  position: relative;\n  box-sizing: border-box;\n  display: inline-block;\n  padding: 16px 22px 14px;\n  font-family: ui-monospace, \"Geist Mono\", SFMono-Regular, Menlo, Consolas, monospace;\n  color: #ededed;\n  text-align: center;\n}\n.hb-qs5 *, .hb-qs5 *::before, .hb-qs5 *::after { box-sizing: border-box; }\n.hb-qs5[data-state=\"idle\"] .hb-qs5-in { opacity: 0; }\n.hb-qs5-in { display: block; }\n.hb-qs5-k { position: absolute; width: 14px; height: 14px; pointer-events: none; }\n.hb-qs5-k::before, .hb-qs5-k::after {\n  content: \"\";\n  position: absolute;\n  background: var(--hb-qs5-c);\n  animation-duration: 0.55s;\n  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);\n  animation-fill-mode: both;\n}\n.hb-qs5-k::before { height: 1.5px; width: 100%; animation-name: hb-qs5-armx; }\n.hb-qs5-k::after { width: 1.5px; height: 100%; animation-name: hb-qs5-army; animation-delay: 0.12s; }\n.hb-qs5-tl { top: 0; left: 0; }\n.hb-qs5-tl::before { top: 0; left: 0; transform-origin: left center; }\n.hb-qs5-tl::after { top: 0; left: 0; transform-origin: center top; }\n.hb-qs5-tr { top: 0; right: 0; }\n.hb-qs5-tr::before { top: 0; right: 0; transform-origin: right center; }\n.hb-qs5-tr::after { top: 0; right: 0; transform-origin: center top; }\n.hb-qs5-bl { bottom: 0; left: 0; }\n.hb-qs5-bl::before { bottom: 0; left: 0; transform-origin: left center; }\n.hb-qs5-bl::after { bottom: 0; left: 0; transform-origin: center bottom; }\n.hb-qs5-br { bottom: 0; right: 0; }\n.hb-qs5-br::before { bottom: 0; right: 0; transform-origin: right center; }\n.hb-qs5-br::after { bottom: 0; right: 0; transform-origin: center bottom; }\n.hb-qs5-m {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  min-height: 12px;\n  font-size: 10px;\n  line-height: 12px;\n  font-weight: 500;\n  letter-spacing: 0.14em;\n  text-transform: uppercase;\n  color: #8f8f8f;\n  white-space: nowrap;\n}\n.hb-qs5-m span { animation: hb-qs5-fade 0.5s ease both; animation-delay: calc(0.5s + var(--hb-qs5-n) * 0.14s); }\n.hb-qs5-m span:first-child { color: color-mix(in srgb, var(--hb-qs5-c) 70%, #ffffff); }\n.hb-qs5-tx {\n  display: block;\n  margin: 10px 0 9px;\n  font-size: var(--hb-qs5-s, 30px);\n  font-weight: 600;\n  line-height: 1.1;\n  letter-spacing: 0.04em;\n  white-space: pre;\n}\n.hb-qs5-r { color: #f4f4f4; }\n.hb-qs5-x { color: var(--hb-qs5-c); opacity: 0.8; }\n.hb-qs5-tk {\n  display: block;\n  height: 8px;\n  margin-bottom: 8px;\n  background:\n    repeating-linear-gradient(90deg, var(--hb-qs5-c) 0 1px, transparent 1px 30px) left bottom / 100% 8px no-repeat,\n    repeating-linear-gradient(90deg, color-mix(in srgb, var(--hb-qs5-c) 55%, transparent) 0 1px, transparent 1px 6px) left bottom / 100% 4px no-repeat;\n  animation: hb-qs5-tick 0.85s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;\n}\n.hb-qs5-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-qs5-armx {\n  from { transform: scaleX(0); }\n  to { transform: scaleX(1); }\n}\n@keyframes hb-qs5-army {\n  from { transform: scaleY(0); }\n  to { transform: scaleY(1); }\n}\n@keyframes hb-qs5-fade {\n  from { opacity: 0; transform: translateY(3px); }\n  to { opacity: 1; transform: translateY(0); }\n}\n@keyframes hb-qs5-tick {\n  from { clip-path: inset(0 100% 0 0); }\n  to { clip-path: inset(0 0 0 0); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qs5-k::before, .hb-qs5-k::after, .hb-qs5-m span, .hb-qs5-tk { animation: none; }\n}\n`;\n\nfunction mix(a: number, b: number) {\n  return (Math.imul(a + 1, 2654435761) ^ Math.imul(b + 7, 40503)) >>> 0;\n}\n\nfunction scramble(text: string, from: number, frame: number, glyphs: string) {\n  const pool = Array.from(glyphs);\n  let out = \"\";\n  for (let i = from; i < text.length; i++) {\n    out += text[i] === \" \" || pool.length === 0 ? text[i] : pool[mix(i, frame) % pool.length];\n  }\n  return out;\n}\n\nexport function TechReadout({\n  text = \"TELEMETRY 04\",\n  meta = [\"SYS / NOMINAL\", \"98.2%\", \"LAT 37.77\", \"T+00:14\"],\n  glyphs = \"01<>/\\\\|#%+=[]\",\n  duration = 1100,\n  size = 30,\n  accent = \"#2f7bff\",\n  replayEvery = 0,\n  className = \"\",\n  style,\n  onPointerEnter,\n  ...rest\n}: TechReadoutProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const finished = React.useRef(false);\n  const [mode, setMode] = React.useState<\"idle\" | \"play\" | \"static\">(\"idle\");\n  const [run, setRun] = React.useState(0);\n  const [frame, setFrame] = React.useState<{ k: number; tail: string } | null>(null);\n\n  const begin = React.useCallback(() => {\n    finished.current = false;\n    setFrame({ k: 0, tail: scramble(text, 0, 0, glyphs) });\n    setRun((r) => r + 1);\n  }, [text, glyphs]);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const io = new IntersectionObserver(\n      (entries) => {\n        if (!entries.some((e) => e.isIntersecting)) return;\n        io.disconnect();\n        if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n          setMode(\"static\");\n          return;\n        }\n        setMode(\"play\");\n        begin();\n      },\n      { threshold: 0.2 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [begin]);\n\n  React.useEffect(() => {\n    if (run === 0) return;\n    const total = Math.max(200, duration);\n    const lead = total * 0.3;\n    const per = (total - lead) / Math.max(1, text.length);\n    const t0 = performance.now();\n    let raf = 0;\n    let lastKey = \"\";\n    function tick(now: number) {\n      const t = now - t0;\n      const k = Math.min(text.length, Math.max(0, Math.floor((t - lead) / per) + 1));\n      const f = Math.floor(t / 55);\n      const key = `${k}:${f}`;\n      if (key !== lastKey) {\n        lastKey = key;\n        setFrame({ k, tail: scramble(text, k, f, glyphs) });\n      }\n      if (k >= text.length) {\n        finished.current = true;\n        return;\n      }\n      raf = requestAnimationFrame(tick);\n    }\n    raf = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(raf);\n  }, [run, text, glyphs, duration]);\n\n  React.useEffect(() => {\n    if (!replayEvery || mode !== \"play\") return;\n    const id = window.setInterval(begin, Math.max(1200, replayEvery));\n    return () => window.clearInterval(id);\n  }, [replayEvery, mode, begin]);\n\n  const shown = mode === \"play\" && frame ? frame : { k: text.length, tail: \"\" };\n  const slots = [meta[0], meta[1], meta[2], meta[3]];\n  const vars = { \"--hb-qs5-c\": accent, \"--hb-qs5-s\": `${size}px`, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-text-tech-readout\" precedence=\"default\">{css}</style>\n      <div\n        ref={rootRef}\n        className={`hb-qs5 ${className}`}\n        style={vars}\n        data-state={mode}\n        onPointerEnter={(e) => {\n          onPointerEnter?.(e);\n          if (mode === \"play\" && finished.current) begin();\n        }}\n        {...rest}\n      >\n        <span className=\"hb-qs5-sr\">{text}</span>\n        <span key={run} className=\"hb-qs5-in\" aria-hidden=\"true\">\n          <span className=\"hb-qs5-k hb-qs5-tl\" />\n          <span className=\"hb-qs5-k hb-qs5-tr\" />\n          <span className=\"hb-qs5-k hb-qs5-bl\" />\n          <span className=\"hb-qs5-k hb-qs5-br\" />\n          <span className=\"hb-qs5-m\">\n            <span style={{ \"--hb-qs5-n\": 0 } as React.CSSProperties}>{slots[0] ?? \"\"}</span>\n            <span style={{ \"--hb-qs5-n\": 1 } as React.CSSProperties}>{slots[1] ?? \"\"}</span>\n          </span>\n          <span className=\"hb-qs5-tx\">\n            <span className=\"hb-qs5-r\">{text.slice(0, shown.k)}</span>\n            <span className=\"hb-qs5-x\">{shown.tail}</span>\n          </span>\n          <span className=\"hb-qs5-tk\" />\n          <span className=\"hb-qs5-m\">\n            <span style={{ \"--hb-qs5-n\": 2 } as React.CSSProperties}>{slots[2] ?? \"\"}</span>\n            <span style={{ \"--hb-qs5-n\": 3 } as React.CSSProperties}>{slots[3] ?? \"\"}</span>\n          </span>\n        </span>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}