{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "airbnb-card",
  "type": "registry:ui",
  "title": "Airbnb Card",
  "description": "An Airbnb Card component for displaying a card with an image and text.",
  "files": [
    {
      "path": "src/registry/ui/airbnb-card.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport Image from \"next/image\";\nimport { ChevronLeft, ChevronRight, Heart, Star } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ListingImage = { src: string; alt: string };\n\nexport type ListingCardProps = Omit<React.ComponentProps<\"div\">, \"title\"> & {\n  images: ListingImage[];\n  title: React.ReactNode;\n  /** Secondary line, e.g. the location. */\n  subtitle?: React.ReactNode;\n  /** Extra details such as dates or the host line. */\n  meta?: React.ReactNode;\n  rating?: number;\n  reviewCount?: number;\n  /** Pre-formatted price, e.g. \"$250\". */\n  price: React.ReactNode;\n  /** Shown after the price, e.g. \"night\". */\n  priceSuffix?: React.ReactNode;\n  /** Shown over the top-left of the image, e.g. \"Superhost\". */\n  badge?: React.ReactNode;\n  favorite?: boolean;\n  defaultFavorite?: boolean;\n  onFavoriteChange?: (favorite: boolean) => void;\n  /** Accessible label for the favorite toggle. */\n  favoriteLabel?: string;\n  /** `sizes` passed to next/image for the carousel slides. */\n  imageSizes?: string;\n};\n\nconst navButton =\n  \"absolute top-1/2 z-10 flex size-8 -translate-y-1/2 items-center justify-center rounded-full border bg-background/90 text-foreground shadow-sm transition-opacity outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:opacity-100 disabled:hidden opacity-0 group-hover/media:opacity-100\";\n\nexport function ListingCard({\n  images,\n  title,\n  subtitle,\n  meta,\n  rating,\n  reviewCount,\n  price,\n  priceSuffix,\n  badge,\n  favorite,\n  defaultFavorite = false,\n  onFavoriteChange,\n  favoriteLabel = \"Save to wishlist\",\n  imageSizes = \"(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 100vw\",\n  className,\n  ...props\n}: ListingCardProps) {\n  const trackRef = useRef<HTMLDivElement>(null);\n  const [index, setIndex] = useState(0);\n  const [uncontrolledFavorite, setUncontrolledFavorite] = useState(defaultFavorite);\n  const isFavorite = favorite ?? uncontrolledFavorite;\n\n  const toggleFavorite = () => {\n    const next = !isFavorite;\n    if (favorite === undefined) setUncontrolledFavorite(next);\n    onFavoriteChange?.(next);\n  };\n\n  // Sync the active dot with the native scroll position (rAF-throttled).\n  useEffect(() => {\n    const track = trackRef.current;\n    if (!track) return;\n    let frame = 0;\n    const onScroll = () => {\n      cancelAnimationFrame(frame);\n      frame = requestAnimationFrame(() => {\n        const width = track.clientWidth || 1;\n        setIndex(Math.round(track.scrollLeft / width));\n      });\n    };\n    track.addEventListener(\"scroll\", onScroll, { passive: true });\n    return () => {\n      track.removeEventListener(\"scroll\", onScroll);\n      cancelAnimationFrame(frame);\n    };\n  }, []);\n\n  const scrollToIndex = (next: number) => {\n    const track = trackRef.current;\n    if (!track) return;\n    track.scrollTo({ left: next * track.clientWidth, behavior: \"smooth\" });\n  };\n\n  const count = images.length;\n\n  return (\n    <div data-slot=\"airbnb-card\" className={cn(\"w-full max-w-sm\", className)} {...props}>\n      <div className=\"group/media relative mb-3 aspect-square overflow-hidden rounded-xl bg-muted\">\n        <div\n          ref={trackRef}\n          className=\"flex size-full snap-x snap-mandatory overflow-x-auto overscroll-x-contain scroll-smooth [scrollbar-width:none] motion-reduce:scroll-auto [&::-webkit-scrollbar]:hidden\"\n        >\n          {images.map((image, i) => (\n            <div\n              key={image.src}\n              className=\"relative size-full shrink-0 snap-center\"\n              role=\"group\"\n              aria-roledescription=\"slide\"\n              aria-label={`${i + 1} of ${count}`}\n            >\n              <Image\n                src={image.src}\n                alt={image.alt}\n                fill\n                sizes={imageSizes}\n                className=\"object-cover\"\n              />\n            </div>\n          ))}\n        </div>\n\n        {/* Scrim keeps the overlaid controls legible on bright photos. */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-x-0 top-0 h-16 bg-gradient-to-b from-black/40 to-transparent\"\n        />\n\n        {badge && (\n          <div className=\"absolute top-3 left-3 rounded-md bg-background px-2 py-0.5 text-xs font-medium text-foreground shadow-sm\">\n            {badge}\n          </div>\n        )}\n\n        <button\n          type=\"button\"\n          aria-label={favoriteLabel}\n          aria-pressed={isFavorite}\n          onClick={toggleFavorite}\n          className=\"absolute top-2.5 right-2.5 z-10 flex size-9 items-center justify-center rounded-full text-white outline-none transition-transform hover:scale-110 focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none motion-reduce:hover:scale-100\"\n        >\n          <Heart\n            className={cn(\n              \"size-6 drop-shadow-sm\",\n              isFavorite && \"fill-current text-destructive\"\n            )}\n            strokeWidth={2}\n          />\n        </button>\n\n        {count > 1 && (\n          <>\n            <button\n              type=\"button\"\n              aria-label=\"Previous image\"\n              disabled={index === 0}\n              onClick={() => scrollToIndex(index - 1)}\n              className={cn(navButton, \"left-2\")}\n            >\n              <ChevronLeft className=\"size-4\" />\n            </button>\n            <button\n              type=\"button\"\n              aria-label=\"Next image\"\n              disabled={index === count - 1}\n              onClick={() => scrollToIndex(index + 1)}\n              className={cn(navButton, \"right-2\")}\n            >\n              <ChevronRight className=\"size-4\" />\n            </button>\n\n            <div\n              aria-hidden\n              className=\"pointer-events-none absolute bottom-3 left-1/2 flex -translate-x-1/2 gap-1.5\"\n            >\n              {images.map((image, i) => (\n                <span\n                  key={image.src}\n                  className={cn(\n                    \"size-1.5 rounded-full bg-white shadow-sm transition-opacity\",\n                    i === index ? \"opacity-100\" : \"opacity-60\"\n                  )}\n                />\n              ))}\n            </div>\n          </>\n        )}\n      </div>\n\n      <div className=\"space-y-0.5 text-sm\">\n        <div className=\"flex items-start justify-between gap-3\">\n          <h3 className=\"font-medium text-foreground\">{title}</h3>\n          {rating !== undefined && (\n            <p className=\"flex shrink-0 items-center gap-1 text-foreground\">\n              <Star aria-hidden className=\"size-3.5 fill-current\" />\n              <span>\n                <span className=\"sr-only\">Rated </span>\n                {rating}\n              </span>\n              {reviewCount !== undefined && (\n                <span className=\"text-muted-foreground\">\n                  ({reviewCount}\n                  <span className=\"sr-only\"> reviews</span>)\n                </span>\n              )}\n            </p>\n          )}\n        </div>\n        {subtitle && <p className=\"text-muted-foreground\">{subtitle}</p>}\n        {meta && <div className=\"text-muted-foreground\">{meta}</div>}\n        <p className=\"pt-1 text-foreground\">\n          <span className=\"font-semibold\">{price}</span>\n          {priceSuffix && <span> {priceSuffix}</span>}\n        </p>\n      </div>\n    </div>\n  );\n}\n\n/** @deprecated Use `ListingCard`. Kept for backwards compatibility. */\nexport const AirbnbListingCard = ListingCard;\nexport type ListingProps = ListingCardProps;\n"
    }
  ],
  "dependencies": [
    "lucide-react"
  ]
}
