{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "aspect-ratio",
  "title": "Aspect Ratio",
  "description": "A container that locks its content to a fixed width/height ratio (a preset like video or square, or a custom number), auto-fitting a single image or video child.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/aspect-ratio/aspect-ratio.tsx",
      "content": "\"use client\";\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 AspectRatioPreset = \"square\" | \"video\" | \"portrait\" | \"wide\" | \"golden\";\nexport type AspectRatioObjectFit = \"cover\" | \"contain\" | \"fill\" | \"none\";\n\nexport interface AspectRatioProps {\n  /** width / height, e.g. 16 / 9. Overrides `preset` when given. */\n  ratio?: number;\n  preset?: AspectRatioPreset;\n  children?: React.ReactNode;\n  /** Applied automatically to a single <img> or <video> child. */\n  objectFit?: AspectRatioObjectFit;\n  radius?: number;\n  bordered?: boolean;\n  theme?: \"dark\" | \"light\";\n  width?: number | string;\n  className?: string;\n}\n\nconst PRESETS: Record<AspectRatioPreset, number> = {\n  square: 1,\n  video: 16 / 9,\n  portrait: 3 / 4,\n  wide: 21 / 9,\n  golden: 1.618,\n};\n\nconst PALETTES = {\n  dark: { bg: \"rgba(255,255,255,0.04)\", border: \"rgba(255,255,255,0.1)\" },\n  light: { bg: \"rgba(10,10,10,0.03)\", border: \"rgba(10,10,10,0.1)\" },\n};\n\nfunction isMediaElement(node: React.ReactNode): node is React.ReactElement<{ className?: string }> {\n  return React.isValidElement(node) && (node.type === \"img\" || node.type === \"video\");\n}\n\nexport function AspectRatio({\n  ratio,\n  preset = \"video\",\n  children,\n  objectFit = \"cover\",\n  radius = 12,\n  bordered = false,\n  theme = \"dark\",\n  width,\n  className,\n}: AspectRatioProps) {\n  const p = PALETTES[theme];\n  const resolvedRatio = ratio ?? PRESETS[preset];\n\n  const content = isMediaElement(children)\n    ? React.cloneElement(children, {\n        className: cn(\"block h-full w-full\", `object-${objectFit}`, children.props.className),\n      })\n    : children;\n\n  return (\n    <div\n      className={cn(\"relative flex items-center justify-center overflow-hidden\", className)}\n      style={{\n        width,\n        maxWidth: \"100%\",\n        aspectRatio: resolvedRatio,\n        borderRadius: radius,\n        background: children ? undefined : p.bg,\n        border: bordered ? `1px solid ${p.border}` : undefined,\n      }}\n    >\n      {content}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}