{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "curtain-clip-wipe",
  "type": "registry:component",
  "title": "Curtain Clip Wipe",
  "description": "A crisp clip-path wipe that pulls the curtain away with a bright leading edge and a soft trailing glow, in five directions.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "curtain",
    "wipe",
    "clip-path",
    "reveal",
    "transition",
    "edge"
  ],
  "docs": "https://hyperblur.dev/effects/curtain-clip-wipe",
  "files": [
    {
      "path": "registry/hyperblur/curtain-clip-wipe.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/curtain-clip-wipe.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type CurtainClipWipeTrigger = \"mount\" | \"view\" | \"manual\";\nexport type CurtainClipWipeDirection = \"left\" | \"right\" | \"up\" | \"down\" | \"diagonal\";\n\nexport interface CurtainClipWipeProps\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?: CurtainClipWipeTrigger;\n  duration?: number;\n  color?: string;\n  accent?: string;\n  direction?: CurtainClipWipeDirection;\n  replay?: string | number;\n  closeAfter?: number;\n  loop?: boolean;\n}\n\nconst css = `\n.hb-zy2 {\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n  box-sizing: border-box;\n  font-family: inherit;\n}\n.hb-zy2 *, .hb-zy2 *::before, .hb-zy2 *::after { box-sizing: border-box; }\n.hb-zy2-c { position: relative; z-index: 0; height: 100%; }\n.hb-zy2-k, .hb-zy2-e {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  transition: clip-path var(--hb-zy2-d) cubic-bezier(0.76, 0, 0.24, 1);\n}\n.hb-zy2-g {\n  position: absolute;\n  pointer-events: none;\n  transition: transform var(--hb-zy2-d) cubic-bezier(0.76, 0, 0.24, 1);\n}\n.hb-zy2-k {\n  z-index: 1;\n  background:\n    linear-gradient(135deg, color-mix(in srgb, var(--hb-zy2-col) 88%, #ffffff) 0%, var(--hb-zy2-col) 55%),\n    var(--hb-zy2-col);\n}\n.hb-zy2[data-open=\"false\"] .hb-zy2-k { pointer-events: auto; }\n.hb-zy2-g {\n  z-index: 2;\n  background: linear-gradient(var(--hb-zy2-a), transparent 0%, color-mix(in srgb, var(--hb-zy2-acc) 55%, transparent) 100%);\n  mix-blend-mode: screen;\n}\n.hb-zy2-e {\n  z-index: 3;\n  background: color-mix(in srgb, var(--hb-zy2-acc) 35%, #ffffff);\n  box-shadow: 0 0 12px var(--hb-zy2-acc);\n}\n.hb-zy2[data-instant=\"true\"] .hb-zy2-k,\n.hb-zy2[data-instant=\"true\"] .hb-zy2-g,\n.hb-zy2[data-instant=\"true\"] .hb-zy2-e { transition: none !important; }\n.hb-zy2-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 85% 50%, rgba(47, 123, 255, 0.45), transparent 45%),\n    linear-gradient(120deg, #101114 0%, #16181f 100%);\n}\n.hb-zy2-s small {\n  font-size: 11px;\n  letter-spacing: 0.14em;\n  text-transform: uppercase;\n  color: #8f8f8f;\n}\n.hb-zy2-s strong { font-size: 24px; line-height: 1.15; font-weight: 600; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-zy2-k, .hb-zy2-g, .hb-zy2-e { transition: none !important; }\n}\n`;\n\nconst angles: Record<CurtainClipWipeDirection, string> = {\n  right: \"90deg\",\n  left: \"270deg\",\n  down: \"180deg\",\n  up: \"0deg\",\n  diagonal: \"90deg\",\n};\n\nfunction haloStyle(dir: CurtainClipWipeDirection, size: number, open: boolean): React.CSSProperties {\n  const span = dir === \"diagonal\" ? size + 30 : size;\n  const far = `${((100 / span) * 100).toFixed(2)}%`;\n  const len = `${span.toFixed(2)}%`;\n  if (dir === \"left\") {\n    return { top: 0, bottom: 0, right: 0, width: len, transform: `translateX(${open ? `-${far}` : \"100%\"})` };\n  }\n  if (dir === \"down\") {\n    return { left: 0, right: 0, top: 0, height: len, transform: `translateY(${open ? far : \"-100%\"})` };\n  }\n  if (dir === \"up\") {\n    return { left: 0, right: 0, bottom: 0, height: len, transform: `translateY(${open ? `-${far}` : \"100%\"})` };\n  }\n  const shape =\n    dir === \"diagonal\"\n      ? `polygon(${((30 / span) * 100).toFixed(2)}% 0%, 100% 0%, ${((size / span) * 100).toFixed(2)}% 100%, 0% 100%)`\n      : undefined;\n  return { top: 0, bottom: 0, left: 0, width: len, clipPath: shape, transform: `translateX(${open ? far : \"-100%\"})` };\n}\n\nfunction band(dir: CurtainClipWipeDirection, a: number, b: number) {\n  const f = (n: number) => `${n.toFixed(2)}%`;\n  if (dir === \"right\") return `polygon(${f(a)} 0%, ${f(b)} 0%, ${f(b)} 100%, ${f(a)} 100%)`;\n  if (dir === \"left\") return `polygon(${f(100 - b)} 0%, ${f(100 - a)} 0%, ${f(100 - a)} 100%, ${f(100 - b)} 100%)`;\n  if (dir === \"down\") return `polygon(0% ${f(a)}, 100% ${f(a)}, 100% ${f(b)}, 0% ${f(b)})`;\n  if (dir === \"up\") return `polygon(0% ${f(100 - b)}, 100% ${f(100 - b)}, 100% ${f(100 - a)}, 0% ${f(100 - a)})`;\n  return `polygon(${f(a)} 0%, ${f(b)} 0%, ${f(b - 30)} 100%, ${f(a - 30)} 100%)`;\n}\n\nfunction useCurtain(\n  open: boolean | undefined,\n  defaultOpen: boolean,\n  onOpenChange: ((open: boolean) => void) | undefined,\n  trigger: CurtainClipWipeTrigger,\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\nexport function CurtainClipWipe({\n  children,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  trigger = \"mount\",\n  duration = 900,\n  color = \"#171717\",\n  accent = \"#2f7bff\",\n  direction = \"right\",\n  replay,\n  closeAfter,\n  loop = false,\n  className = \"\",\n  style,\n  ...rest\n}: CurtainClipWipeProps) {\n  const { ref, isOpen, instant } = useCurtain(\n    open,\n    defaultOpen,\n    onOpenChange,\n    trigger,\n    replay,\n    closeAfter,\n    loop,\n    duration,\n  );\n\n  const end = direction === \"diagonal\" ? 130 : 100;\n  const vertical = direction === \"up\" || direction === \"down\";\n  const line = vertical ? 2.4 : 1.1;\n  const glow = vertical ? 26 : 16;\n  const curtain = isOpen ? band(direction, end, end) : band(direction, 0, end);\n  const edge = isOpen ? band(direction, end, end + line) : band(direction, -line, 0);\n\n  const vars = {\n    \"--hb-zy2-col\": color,\n    \"--hb-zy2-acc\": accent,\n    \"--hb-zy2-d\": `${duration}ms`,\n    \"--hb-zy2-a\": angles[direction],\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-curtain-clip-wipe\" precedence=\"default\">{css}</style>\n      <div\n        ref={ref}\n        className={`hb-zy2 ${className}`}\n        style={vars}\n        data-open={isOpen}\n        data-instant={instant}\n        {...rest}\n      >\n        <div className=\"hb-zy2-c\">\n          {children ?? (\n            <div className=\"hb-zy2-s\">\n              <small>Release 4.2</small>\n              <strong>Faster builds, quieter logs</strong>\n            </div>\n          )}\n        </div>\n        <div className=\"hb-zy2-k\" aria-hidden=\"true\" style={{ clipPath: curtain }} />\n        <div className=\"hb-zy2-g\" aria-hidden=\"true\" style={haloStyle(direction, glow, isOpen)} />\n        <div className=\"hb-zy2-e\" aria-hidden=\"true\" style={{ clipPath: edge }} />\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}