{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "curtain-stagger-wipe",
  "type": "registry:component",
  "title": "Curtain Stagger Wipe",
  "description": "Vertical bars sweep off one after another, each trailed by a colored layer, then drop back in reverse to cover the content.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "curtain",
    "bars",
    "stagger",
    "wipe",
    "reveal",
    "transition"
  ],
  "docs": "https://hyperblur.dev/effects/curtain-stagger-wipe",
  "files": [
    {
      "path": "registry/hyperblur/curtain-stagger-wipe.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/curtain-stagger-wipe.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type CurtainStaggerWipeTrigger = \"mount\" | \"view\" | \"manual\";\n\nexport interface CurtainStaggerWipeProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"color\"> {\n  children?: React.ReactNode;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  trigger?: CurtainStaggerWipeTrigger;\n  duration?: number;\n  color?: string;\n  accent?: string;\n  colors?: string[];\n  direction?: \"up\" | \"down\";\n  bars?: number;\n  stagger?: number;\n  replay?: string | number;\n  closeAfter?: number;\n  loop?: boolean;\n}\n\nconst css = `\n.hb-zy6 {\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n  box-sizing: border-box;\n  font-family: inherit;\n}\n.hb-zy6 *, .hb-zy6 *::before, .hb-zy6 *::after { box-sizing: border-box; }\n.hb-zy6-c { position: relative; z-index: 0; height: 100%; }\n.hb-zy6-k {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  display: flex;\n  pointer-events: none;\n}\n.hb-zy6[data-open=\"false\"] .hb-zy6-k { pointer-events: auto; }\n.hb-zy6-b {\n  position: relative;\n  flex: 1 1 0;\n  margin: 0 -0.5px;\n}\n.hb-zy6-f, .hb-zy6-u {\n  position: absolute;\n  inset: 0;\n  transition: transform var(--hb-zy6-d) cubic-bezier(0.76, 0, 0.24, 1);\n}\n.hb-zy6-u { background: var(--hb-zy6-u); }\n.hb-zy6-f {\n  background:\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-zy6-col) 90%, #ffffff), var(--hb-zy6-col) 40%),\n    var(--hb-zy6-col);\n  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.04);\n}\n.hb-zy6-f::after {\n  content: \"\";\n  position: absolute;\n  left: 0;\n  right: 0;\n  height: 2px;\n  background: var(--hb-zy6-acc);\n  box-shadow: 0 0 10px var(--hb-zy6-acc);\n}\n.hb-zy6[data-dir=\"up\"] .hb-zy6-f::after { bottom: 0; }\n.hb-zy6[data-dir=\"down\"] .hb-zy6-f::after { top: 0; }\n.hb-zy6-u { transition-delay: calc(var(--hb-zy6-i) * var(--hb-zy6-s)); }\n.hb-zy6-f { transition-delay: calc(var(--hb-zy6-i) * var(--hb-zy6-s) + var(--hb-zy6-l)); }\n.hb-zy6[data-open=\"true\"] .hb-zy6-f { transition-delay: calc(var(--hb-zy6-i) * var(--hb-zy6-s)); }\n.hb-zy6[data-open=\"true\"] .hb-zy6-u { transition-delay: calc(var(--hb-zy6-i) * var(--hb-zy6-s) + var(--hb-zy6-l)); }\n.hb-zy6[data-open=\"true\"][data-dir=\"up\"] .hb-zy6-f,\n.hb-zy6[data-open=\"true\"][data-dir=\"up\"] .hb-zy6-u { transform: translateY(-101%); }\n.hb-zy6[data-open=\"true\"][data-dir=\"down\"] .hb-zy6-f,\n.hb-zy6[data-open=\"true\"][data-dir=\"down\"] .hb-zy6-u { transform: translateY(101%); }\n.hb-zy6[data-instant=\"true\"] .hb-zy6-f,\n.hb-zy6[data-instant=\"true\"] .hb-zy6-u { transition: none !important; }\n.hb-zy6-s {\n  display: flex;\n  min-height: 220px;\n  flex-direction: column;\n  justify-content: center;\n  gap: 6px;\n  padding: 24px;\n  color: #ededed;\n  background:\n    radial-gradient(circle at 90% 10%, rgba(127, 179, 255, 0.4), transparent 45%),\n    linear-gradient(150deg, #111318, #0a0a0a);\n}\n.hb-zy6-s small {\n  font-size: 11px;\n  letter-spacing: 0.16em;\n  text-transform: uppercase;\n  color: rgba(237, 237, 237, 0.6);\n}\n.hb-zy6-s strong { font-size: 26px; line-height: 1.1; font-weight: 600; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-zy6-f, .hb-zy6-u { transition: none !important; }\n}\n`;\n\nfunction useCurtain(\n  open: boolean | undefined,\n  defaultOpen: boolean,\n  onOpenChange: ((open: boolean) => void) | undefined,\n  trigger: CurtainStaggerWipeTrigger,\n  replay: string | number | undefined,\n  closeAfter: number | undefined,\n  loop: boolean,\n  total: number,\n) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const controlled = open !== undefined;\n  const [inner, setInner] = React.useState(defaultOpen);\n  const [instant, setInstant] = React.useState(false);\n  const isOpen = controlled ? open : inner;\n  const live = React.useRef({ controlled, onOpenChange, isOpen });\n  const opened = React.useRef(defaultOpen);\n  const prevReplay = React.useRef(replay);\n\n  React.useEffect(() => {\n    live.current = { controlled, onOpenChange, isOpen };\n    if (isOpen) opened.current = true;\n  });\n\n  const setOpen = React.useCallback((next: boolean) => {\n    if (live.current.isOpen === next) return;\n    live.current.isOpen = next;\n    if (!live.current.controlled) setInner(next);\n    live.current.onOpenChange?.(next);\n  }, []);\n\n  React.useEffect(() => {\n    if (trigger !== \"mount\") return;\n    let b = 0;\n    const a = requestAnimationFrame(() => {\n      b = requestAnimationFrame(() => setOpen(true));\n    });\n    return () => {\n      cancelAnimationFrame(a);\n      cancelAnimationFrame(b);\n    };\n  }, [trigger, setOpen]);\n\n  React.useEffect(() => {\n    if (trigger !== \"view\") return;\n    const el = ref.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(\n      (entries) => {\n        if (!entries.some((e) => e.isIntersecting)) return;\n        setOpen(true);\n        io.disconnect();\n      },\n      { threshold: 0.3 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [trigger, setOpen]);\n\n  React.useEffect(() => {\n    if (prevReplay.current === replay) return;\n    prevReplay.current = replay;\n    let b = 0;\n    let c = 0;\n    const a = requestAnimationFrame(() => {\n      setInstant(true);\n      setOpen(false);\n      b = requestAnimationFrame(() => {\n        c = requestAnimationFrame(() => {\n          setInstant(false);\n          setOpen(true);\n        });\n      });\n    });\n    return () => {\n      cancelAnimationFrame(a);\n      cancelAnimationFrame(b);\n      cancelAnimationFrame(c);\n    };\n  }, [replay, setOpen]);\n\n  React.useEffect(() => {\n    if (instant) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let t = 0;\n    if (isOpen && closeAfter !== undefined) {\n      t = window.setTimeout(() => setOpen(false), total + closeAfter);\n    } else if (!isOpen && loop && opened.current) {\n      t = window.setTimeout(() => setOpen(true), total + 800);\n    }\n    return () => window.clearTimeout(t);\n  }, [isOpen, instant, closeAfter, loop, total, setOpen]);\n\n  return { ref, isOpen, instant };\n}\n\nconst palette = [\"#2f7bff\", \"#7fb3ff\", \"#ededed\", \"#5b5bff\", \"#1d4ed8\"];\n\nexport function CurtainStaggerWipe({\n  children,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  trigger = \"mount\",\n  duration = 750,\n  color = \"#111111\",\n  accent = \"#2f7bff\",\n  colors = palette,\n  direction = \"up\",\n  bars = 5,\n  stagger = 70,\n  replay,\n  closeAfter,\n  loop = false,\n  className = \"\",\n  style,\n  ...rest\n}: CurtainStaggerWipeProps) {\n  const count = Math.max(1, Math.min(24, Math.round(bars)));\n  const lag = Math.round(duration * 0.2);\n  const total = duration + lag + stagger * (count - 1);\n  const { ref, isOpen, instant } = useCurtain(\n    open,\n    defaultOpen,\n    onOpenChange,\n    trigger,\n    replay,\n    closeAfter,\n    loop,\n    total,\n  );\n  const list = colors.length ? colors : palette;\n\n  const vars = {\n    \"--hb-zy6-col\": color,\n    \"--hb-zy6-acc\": accent,\n    \"--hb-zy6-d\": `${duration}ms`,\n    \"--hb-zy6-s\": `${stagger}ms`,\n    \"--hb-zy6-l\": `${lag}ms`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-curtain-stagger-wipe\" precedence=\"default\">{css}</style>\n      <div\n        ref={ref}\n        className={`hb-zy6 ${className}`}\n        style={vars}\n        data-open={isOpen}\n        data-instant={instant}\n        data-dir={direction}\n        {...rest}\n      >\n        <div className=\"hb-zy6-c\">\n          {children ?? (\n            <div className=\"hb-zy6-s\">\n              <small>Spring 2027</small>\n              <strong>The Field Collection</strong>\n            </div>\n          )}\n        </div>\n        <div className=\"hb-zy6-k\" aria-hidden=\"true\">\n          {Array.from({ length: count }, (_, i) => (\n            <span\n              key={i}\n              className=\"hb-zy6-b\"\n              style={{ \"--hb-zy6-i\": i, \"--hb-zy6-u\": list[i % list.length] } as React.CSSProperties}\n            >\n              <span className=\"hb-zy6-u\" />\n              <span className=\"hb-zy6-f\" />\n            </span>\n          ))}\n        </div>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}