{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-line-rise",
  "type": "registry:component",
  "title": "Text Line Rise",
  "description": "Finds where the paragraph actually wraps and lifts each visual line out of its own mask with a skew that straightens on arrival. A hairline draws above each line just before it rises.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "text",
    "lines",
    "mask",
    "reveal",
    "paragraph",
    "editorial",
    "scroll"
  ],
  "docs": "https://hyperblur.dev/effects/text-line-rise",
  "files": [
    {
      "path": "registry/hyperblur/text-line-rise.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/text-line-rise.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TextLineRiseProps extends React.HTMLAttributes<HTMLDivElement> {\n  text: string;\n  stagger?: number;\n  duration?: number;\n  delay?: number;\n  rule?: boolean;\n  ruleColor?: string;\n  once?: boolean;\n  loop?: number;\n}\n\nconst css = `\n@keyframes hb-vi6-rise {\n  0% { transform: translate3d(0, 112%, 0) skewY(7deg) scaleY(1.3); }\n  100% { transform: translate3d(0, 0, 0) skewY(0deg) scaleY(1); }\n}\n@keyframes hb-vi6-rule {\n  0% { transform: scaleX(0); opacity: 1; }\n  55% { transform: scaleX(1); opacity: 1; }\n  100% { transform: scaleX(1); opacity: 0.35; }\n}\n.hb-vi6 { position: relative; display: block; font-family: inherit; box-sizing: border-box; }\n.hb-vi6 *, .hb-vi6 *::before, .hb-vi6 *::after { box-sizing: border-box; }\n.hb-vi6-sr {\n  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;\n  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;\n}\n.hb-vi6-measure {\n  position: absolute;\n  inset: 0;\n  visibility: hidden;\n  pointer-events: none;\n}\n.hb-vi6-hold { visibility: hidden; }\n.hb-vi6-line {\n  position: relative;\n  display: block;\n  overflow: hidden;\n  padding: 0.06em 0 0.14em;\n  margin: -0.06em 0 -0.14em;\n  white-space: nowrap;\n}\n.hb-vi6-in {\n  display: inline-block;\n  transform: translate3d(0, 112%, 0);\n  transform-origin: 0 100%;\n  will-change: transform;\n}\n.hb-vi6-rule {\n  position: absolute;\n  left: 0; right: 0; top: 0;\n  height: 1px;\n  background: var(--hb-vi6-rule);\n  transform: scaleX(0);\n  transform-origin: 0 50%;\n}\n.hb-vi6[data-active] .hb-vi6-in {\n  animation: hb-vi6-rise var(--hb-vi6-dur) cubic-bezier(.16, 1, .3, 1) both;\n  animation-delay: calc(var(--hb-vi6-delay) + var(--hb-vi6-n) * var(--hb-vi6-stagger) + var(--hb-vi6-dur) * 0.18);\n}\n.hb-vi6[data-active] .hb-vi6-rule {\n  animation: hb-vi6-rule calc(var(--hb-vi6-dur) * 1.3) cubic-bezier(.65, 0, .35, 1) both;\n  animation-delay: calc(var(--hb-vi6-delay) + var(--hb-vi6-n) * var(--hb-vi6-stagger));\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-vi6 .hb-vi6-in { transform: none; animation: none !important; will-change: auto; }\n  .hb-vi6 .hb-vi6-rule { display: none; }\n}\n`;\n\nexport function TextLineRise({\n  text,\n  stagger = 0.1,\n  duration = 1,\n  delay = 0,\n  rule = true,\n  ruleColor = \"rgba(255, 255, 255, 0.22)\",\n  once = true,\n  loop = 0,\n  className = \"\",\n  style,\n  ...rest\n}: TextLineRiseProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const measureRef = React.useRef<HTMLDivElement>(null);\n  const words = React.useMemo(() => text.split(/\\s+/).filter(Boolean), [text]);\n  const [lines, setLines] = React.useState<string[] | null>(null);\n  const [inView, setInView] = React.useState(false);\n  const [resting, setResting] = React.useState(false);\n  const [cycle, setCycle] = React.useState(0);\n\n  React.useLayoutEffect(() => {\n    const box = measureRef.current;\n    if (!box) return;\n    const measure = () => {\n      const spans = Array.from(box.querySelectorAll<HTMLSpanElement>(\"[data-w]\"));\n      const out: string[] = [];\n      let top = Number.NaN;\n      let current: string[] = [];\n      spans.forEach((s) => {\n        const t = Math.round(s.offsetTop);\n        if (current.length && Math.abs(t - top) > 2) {\n          out.push(current.join(\" \"));\n          current = [];\n        }\n        if (!current.length) top = t;\n        current.push(s.textContent ?? \"\");\n      });\n      if (current.length) out.push(current.join(\" \"));\n      setLines((prev) => (prev && prev.join(\"\\n\") === out.join(\"\\n\") ? prev : out));\n    };\n    measure();\n    if (typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(measure);\n    ro.observe(box);\n    if (document.fonts?.ready) document.fonts.ready.then(measure).catch(() => undefined);\n    return () => ro.disconnect();\n  }, [words]);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") {\n      const id = requestAnimationFrame(() => setInView(true));\n      return () => cancelAnimationFrame(id);\n    }\n    const io = new IntersectionObserver(\n      (entries) => {\n        for (const entry of entries) {\n          if (entry.isIntersecting) {\n            setInView(true);\n            if (once) io.disconnect();\n          } else if (!once) {\n            setInView(false);\n          }\n        }\n      },\n      { threshold: 0.25 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [once]);\n\n  const count = lines ? lines.length : 1;\n\n  React.useEffect(() => {\n    if (!inView || loop <= 0) return;\n    if (resting) {\n      const id = setTimeout(() => {\n        setResting(false);\n        setCycle((c) => c + 1);\n      }, 420);\n      return () => clearTimeout(id);\n    }\n    const total = (delay + duration * 1.4 + stagger * count + loop) * 1000;\n    const id = setTimeout(() => setResting(true), total);\n    return () => clearTimeout(id);\n  }, [inView, loop, resting, delay, duration, stagger, count]);\n\n  const vars = {\n    \"--hb-vi6-dur\": `${duration}s`,\n    \"--hb-vi6-delay\": `${delay}s`,\n    \"--hb-vi6-stagger\": `${stagger}s`,\n    \"--hb-vi6-rule\": ruleColor,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <div\n      ref={ref}\n      className={`hb-vi6 ${className}`}\n      style={vars}\n      data-active={inView && lines && !resting ? \"\" : undefined}\n      {...rest}\n    >\n      <style href=\"hb-text-line-rise\" precedence=\"default\">{css}</style>\n      <span className=\"hb-vi6-sr\">{text}</span>\n      <div ref={measureRef} className=\"hb-vi6-measure\" aria-hidden=\"true\">\n        {words.map((w, i) => (\n          <React.Fragment key={i}>\n            <span data-w=\"\">{w}</span>{\" \"}\n          </React.Fragment>\n        ))}\n      </div>\n      {lines ? (\n        <div aria-hidden=\"true\" key={cycle}>\n          {lines.map((line, i) => (\n            <span className=\"hb-vi6-line\" key={`${i}-${line}`} style={{ \"--hb-vi6-n\": i } as React.CSSProperties}>\n              {rule ? <span className=\"hb-vi6-rule\" /> : null}\n              <span className=\"hb-vi6-in\">{line}</span>\n            </span>\n          ))}\n        </div>\n      ) : (\n        <div className=\"hb-vi6-hold\" aria-hidden=\"true\">{text}</div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}