{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "image-mask-reveal",
  "title": "Image Mask Reveal",
  "description": "An image that unveils itself through a moving mask — a circle opening from where the pointer came in, falling blinds, a cascade of tiles, a diagonal wipe or a parting curtain — on hover or as it scrolls into view, settling from a slight zoom.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/image-mask-reveal/image-mask-reveal.tsx",
      "content": "\"use client\";\n/* eslint-disable @next/next/no-img-element -- Registry components work in any React app. */\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type MaskVariant = \"circle\" | \"blinds\" | \"tiles\" | \"diagonal\" | \"curtain\";\n\nexport interface ImageMaskRevealProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"title\"> {\n  src: string;\n  alt?: string;\n  variant?: MaskVariant;\n  /** \"view\" reveals once when it scrolls into sight; \"hover\" reveals while the pointer (or focus) is on it. */\n  trigger?: \"view\" | \"hover\";\n  /** Colour of the cover the image is revealed from. */\n  cover?: string;\n  /** Optional caption shown over the cover and slid away as the image appears. */\n  title?: string;\n  meta?: string;\n  duration?: number;\n  /** Width / height. */\n  aspectRatio?: number;\n  radius?: number;\n  href?: string;\n}\n\nconst EASE = \"cubic-bezier(.7,0,.2,1)\";\nconst STRIPS = 7;\nconst TILES = 5;\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nexport function ImageMaskReveal({\n  src,\n  alt = \"\",\n  variant = \"circle\",\n  trigger = \"view\",\n  cover = \"#161616\",\n  title,\n  meta,\n  duration = 1000,\n  aspectRatio = 4 / 5,\n  radius = 16,\n  href,\n  className,\n  style,\n  ...props\n}: ImageMaskRevealProps) {\n  const reduce = useReducedMotion();\n  const ref = React.useRef<HTMLDivElement>(null);\n  const [open, setOpen] = React.useState(false);\n  // The circle grows from wherever the pointer came in (hover), or from the centre.\n  const [origin, setOrigin] = React.useState({ x: 50, y: 50 });\n\n  React.useEffect(() => {\n    if (trigger !== \"view\") return;\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting) {\n          setOpen(true);\n          observer.disconnect();\n        }\n      },\n      { threshold: 0.35 },\n    );\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [trigger]);\n\n  const shown = open || reduce;\n  const ms = reduce ? 0 : duration;\n  const setFrom = (event: React.PointerEvent) => {\n    const r = event.currentTarget.getBoundingClientRect();\n    setOrigin({ x: ((event.clientX - r.left) / r.width) * 100, y: ((event.clientY - r.top) / r.height) * 100 });\n  };\n  const hoverProps =\n    trigger === \"hover\"\n      ? {\n          onPointerEnter: (event: React.PointerEvent) => {\n            setFrom(event);\n            setOpen(true);\n          },\n          onPointerLeave: (event: React.PointerEvent) => {\n            // A finger lifting also \"leaves\": on touch, a tap reveals and it stays revealed.\n            if (event.pointerType === \"touch\") return;\n            setFrom(event);\n            setOpen(false);\n          },\n          onFocus: () => {\n            setOrigin({ x: 50, y: 50 });\n            setOpen(true);\n          },\n          onBlur: () => setOpen(false),\n        }\n      : {};\n\n  // Image clip for the clip-path variants; the strip/tile variants reveal by shrinking a cover instead.\n  let clip: string | undefined;\n  if (variant === \"circle\") clip = shown ? `circle(150% at ${origin.x}% ${origin.y}%)` : `circle(0% at ${origin.x}% ${origin.y}%)`;\n  else if (variant === \"diagonal\") clip = shown ? \"polygon(0 0, 200% 0, 0 200%)\" : \"polygon(0 0, 0 0, 0 0)\";\n  else if (variant === \"curtain\") clip = shown ? \"inset(0 0% 0 0%)\" : \"inset(0 50% 0 50%)\";\n\n  const Root = href ? \"a\" : \"div\";\n  return (\n    <div ref={ref} className={cn(\"relative w-full\", className)} style={{ aspectRatio, ...style }} {...props}>\n      <Root\n        {...(href ? { href } : trigger === \"hover\" ? { tabIndex: 0 } : {})}\n        {...hoverProps}\n        aria-label={title ? `${title}${meta ? `, ${meta}` : \"\"}` : undefined}\n        className=\"group/mask absolute inset-0 block overflow-hidden outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n        style={{ borderRadius: radius, background: cover, [\"--tw-ring-color\" as string]: \"#f4f4f2\", [\"--tw-ring-offset-color\" as string]: \"#0a0a0a\" }}\n      >\n        <img\n          src={src}\n          alt={alt}\n          draggable={false}\n          className=\"absolute inset-0 h-full w-full object-cover\"\n          style={{\n            clipPath: clip,\n            transform: shown ? \"scale(1)\" : \"scale(1.15)\",\n            transition: `clip-path ${ms}ms ${EASE}, transform ${ms * 1.4}ms cubic-bezier(.16,1,.3,1)`,\n          }}\n        />\n\n        {variant === \"blinds\" && (\n          <div aria-hidden=\"true\" className=\"absolute inset-0 flex flex-col\">\n            {Array.from({ length: STRIPS }, (_, i) => (\n              <span\n                key={i}\n                className=\"block flex-1 origin-top\"\n                style={{ background: cover, transform: shown ? \"scaleY(0)\" : \"scaleY(1.02)\", transition: `transform ${ms * 0.7}ms ${EASE} ${shown ? i * (ms / 14) : (STRIPS - 1 - i) * (ms / 20)}ms` }}\n              />\n            ))}\n          </div>\n        )}\n        {variant === \"tiles\" && (\n          <div aria-hidden=\"true\" className=\"absolute inset-0 grid\" style={{ gridTemplateColumns: `repeat(${TILES}, 1fr)`, gridTemplateRows: `repeat(${Math.round(TILES / aspectRatio)}, 1fr)` }}>\n            {Array.from({ length: TILES * Math.round(TILES / aspectRatio) }, (_, i) => {\n              const x = i % TILES;\n              const y = Math.floor(i / TILES);\n              const order = x + y;\n              return (\n                <span\n                  key={i}\n                  className=\"block\"\n                  style={{ background: cover, transform: shown ? \"scale(0)\" : \"scale(1.04)\", transition: `transform ${ms * 0.55}ms ${EASE} ${order * (ms / 16)}ms` }}\n                />\n              );\n            })}\n          </div>\n        )}\n\n        {(title || meta) && (\n          <div className=\"pointer-events-none absolute inset-x-0 bottom-0 p-4 text-white\">\n            <div aria-hidden=\"true\" className=\"absolute inset-0 bg-gradient-to-t from-black/60 to-transparent transition-opacity\" style={{ opacity: shown ? 1 : 0, transitionDuration: `${ms}ms` }} />\n            {title && <p className=\"relative text-[16px] leading-tight font-medium\">{title}</p>}\n            {meta && <p className=\"relative mt-0.5 font-mono text-[10.5px] text-white/70\">{meta}</p>}\n          </div>\n        )}\n      </Root>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}