{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "curtain-iris",
  "type": "registry:component",
  "title": "Curtain Iris",
  "description": "A scope-style iris that opens a circle from a chosen point, with a bright ring at its edge. In pointer mode a click picks the point.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "transitions",
    "curtain",
    "iris",
    "circle",
    "scope",
    "reveal",
    "clip-path"
  ],
  "docs": "https://hyperblur.dev/effects/curtain-iris",
  "files": [
    {
      "path": "registry/hyperblur/curtain-iris.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/curtain-iris.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type CurtainIrisTrigger = \"mount\" | \"view\" | \"manual\";\nexport type CurtainIrisOrigin = \"center\" | \"pointer\" | { x: number; y: number };\n\nexport interface CurtainIrisProps\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?: CurtainIrisTrigger;\n  duration?: number;\n  color?: string;\n  accent?: string;\n  origin?: CurtainIrisOrigin;\n  replay?: string | number;\n  closeAfter?: number;\n  loop?: boolean;\n}\n\nconst css = `\n@property --hb-zy5-r {\n  syntax: \"<percentage>\";\n  inherits: false;\n  initial-value: 0%;\n}\n.hb-zy5 {\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n  box-sizing: border-box;\n  font-family: inherit;\n  background: var(--hb-zy5-col);\n}\n.hb-zy5 *, .hb-zy5 *::before, .hb-zy5 *::after { box-sizing: border-box; }\n.hb-zy5[data-pick=\"true\"][data-open=\"false\"] { cursor: crosshair; }\n.hb-zy5:focus-visible { outline: 2px solid var(--hb-zy5-acc); outline-offset: 2px; }\n.hb-zy5-k {\n  position: absolute;\n  inset: 0;\n  z-index: 0;\n  pointer-events: none;\n  background:\n    repeating-radial-gradient(circle at var(--hb-zy5-x) var(--hb-zy5-y), rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 24px),\n    repeating-conic-gradient(from 0deg at var(--hb-zy5-x) var(--hb-zy5-y), rgba(255, 255, 255, 0.025) 0deg 15deg, transparent 15deg 30deg),\n    radial-gradient(circle at var(--hb-zy5-x) var(--hb-zy5-y), color-mix(in srgb, var(--hb-zy5-acc) 22%, transparent), transparent 55%);\n}\n.hb-zy5-v, .hb-zy5-h, .hb-zy5-o {\n  position: absolute;\n  background: color-mix(in srgb, var(--hb-zy5-acc) 45%, transparent);\n}\n.hb-zy5-v { top: 0; bottom: 0; left: var(--hb-zy5-x); width: 1px; }\n.hb-zy5-h { left: 0; right: 0; top: var(--hb-zy5-y); height: 1px; }\n.hb-zy5-o {\n  left: var(--hb-zy5-x);\n  top: var(--hb-zy5-y);\n  width: 18px;\n  height: 18px;\n  margin: -9px 0 0 -9px;\n  border: 1px solid color-mix(in srgb, var(--hb-zy5-acc) 80%, #ffffff);\n  border-radius: 50%;\n  background: transparent;\n  animation: hb-zy5-pulse 1.6s ease-in-out infinite;\n}\n.hb-zy5-g {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  pointer-events: none;\n  background: radial-gradient(circle at var(--hb-zy5-x) var(--hb-zy5-y), #ffffff, var(--hb-zy5-acc) 30%);\n  --hb-zy5-r: 0%;\n  clip-path: circle(var(--hb-zy5-r) at var(--hb-zy5-x) var(--hb-zy5-y));\n  transition: --hb-zy5-r calc(var(--hb-zy5-d) * 1.12) cubic-bezier(0.65, 0, 0.25, 1);\n}\n.hb-zy5-c {\n  position: relative;\n  z-index: 2;\n  height: 100%;\n  --hb-zy5-r: 0%;\n  clip-path: circle(var(--hb-zy5-r) at var(--hb-zy5-x) var(--hb-zy5-y));\n  transition: --hb-zy5-r var(--hb-zy5-d) cubic-bezier(0.65, 0, 0.25, 1);\n}\n.hb-zy5[data-open=\"true\"] .hb-zy5-g {\n  --hb-zy5-r: 149%;\n  transition-duration: calc(var(--hb-zy5-d) * 0.86);\n}\n.hb-zy5[data-open=\"true\"] .hb-zy5-c { --hb-zy5-r: 145%; }\n.hb-zy5[data-instant=\"true\"] .hb-zy5-g,\n.hb-zy5[data-instant=\"true\"] .hb-zy5-c { transition: none !important; }\n.hb-zy5-s {\n  display: flex;\n  min-height: 220px;\n  flex-direction: column;\n  justify-content: flex-end;\n  gap: 4px;\n  padding: 22px;\n  color: #ededed;\n  background:\n    radial-gradient(circle at 70% 30%, rgba(185, 140, 255, 0.5), transparent 40%),\n    radial-gradient(circle at 30% 80%, rgba(47, 123, 255, 0.4), transparent 45%),\n    #07080d;\n}\n.hb-zy5-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-zy5-s strong { font-size: 26px; line-height: 1.1; font-weight: 600; }\n@keyframes hb-zy5-pulse {\n  0%, 100% { transform: scale(0.8); opacity: 0.5; }\n  50% { transform: scale(1.15); opacity: 1; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-zy5-g, .hb-zy5-c { transition: none !important; }\n  .hb-zy5-o { animation: none; }\n}\n`;\n\nconst spots = [\n  { x: 50, y: 50 },\n  { x: 24, y: 32 },\n  { x: 76, y: 68 },\n  { x: 68, y: 26 },\n  { x: 30, y: 72 },\n];\n\nfunction useCurtain(\n  open: boolean | undefined,\n  defaultOpen: boolean,\n  onOpenChange: ((open: boolean) => void) | undefined,\n  trigger: CurtainIrisTrigger,\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, setOpen };\n}\n\nexport function CurtainIris({\n  children,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  trigger = \"mount\",\n  duration = 1000,\n  color = \"#0b0c10\",\n  accent = \"#2f7bff\",\n  origin = \"center\",\n  replay,\n  closeAfter,\n  loop = false,\n  className = \"\",\n  style,\n  onPointerDown,\n  onKeyDown,\n  ...rest\n}: CurtainIrisProps) {\n  const pick = origin === \"pointer\";\n  const [point, setPoint] = React.useState(() =>\n    typeof origin === \"object\" ? { x: origin.x, y: origin.y } : spots[0],\n  );\n  const clicked = React.useRef(false);\n  const step = React.useRef(0);\n  const timer = React.useRef(0);\n  const live = React.useRef({ pick, onOpenChange, duration });\n\n  React.useEffect(() => {\n    live.current = { pick, onOpenChange, duration };\n  });\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  const handleChange = React.useCallback((next: boolean) => {\n    const cur = live.current;\n    if (!next && cur.pick && !clicked.current) {\n      window.clearTimeout(timer.current);\n      timer.current = window.setTimeout(() => {\n        step.current = (step.current + 1) % spots.length;\n        setPoint(spots[step.current]);\n      }, cur.duration * 1.15);\n    }\n    cur.onOpenChange?.(next);\n  }, []);\n\n  const { ref, isOpen, instant, setOpen } = useCurtain(\n    open,\n    defaultOpen,\n    handleChange,\n    trigger,\n    replay,\n    closeAfter,\n    loop,\n    duration,\n  );\n\n  const at = typeof origin === \"object\" ? origin : pick ? point : spots[0];\n\n  const reveal = (x: number, y: number) => {\n    clicked.current = true;\n    window.clearTimeout(timer.current);\n    setPoint({ x, y });\n    requestAnimationFrame(() => setOpen(true));\n  };\n\n  const vars = {\n    \"--hb-zy5-col\": color,\n    \"--hb-zy5-acc\": accent,\n    \"--hb-zy5-d\": `${duration}ms`,\n    \"--hb-zy5-x\": `${at.x.toFixed(2)}%`,\n    \"--hb-zy5-y\": `${at.y.toFixed(2)}%`,\n    ...style,\n  } as React.CSSProperties;\n\n  const interactive = pick && !isOpen;\n\n  return (\n    <>\n      <style href=\"hb-curtain-iris\" precedence=\"default\">{css}</style>\n      <div\n        ref={ref}\n        className={`hb-zy5 ${className}`}\n        style={vars}\n        data-open={isOpen}\n        data-instant={instant}\n        data-pick={pick}\n        role={interactive ? \"button\" : undefined}\n        tabIndex={interactive ? 0 : undefined}\n        aria-label={interactive ? \"Reveal content\" : undefined}\n        onPointerDown={(e) => {\n          onPointerDown?.(e);\n          if (!interactive || e.button !== 0) return;\n          const r = e.currentTarget.getBoundingClientRect();\n          if (!r.width || !r.height) return;\n          reveal(((e.clientX - r.left) / r.width) * 100, ((e.clientY - r.top) / r.height) * 100);\n        }}\n        onKeyDown={(e) => {\n          onKeyDown?.(e);\n          if (!interactive || (e.key !== \"Enter\" && e.key !== \" \")) return;\n          e.preventDefault();\n          reveal(50, 50);\n        }}\n        {...rest}\n      >\n        <div className=\"hb-zy5-k\" aria-hidden=\"true\">\n          <span className=\"hb-zy5-v\" />\n          <span className=\"hb-zy5-h\" />\n          <span className=\"hb-zy5-o\" />\n        </div>\n        <div className=\"hb-zy5-g\" aria-hidden=\"true\" />\n        <div className=\"hb-zy5-c\">\n          {children ?? (\n            <div className=\"hb-zy5-s\">\n              <small>Live from the observatory</small>\n              <strong>Saturn at opposition</strong>\n            </div>\n          )}\n        </div>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}