import type { GalleryImage } from "@/types/components/imageGallery"
import type { ImageVaultAsset } from "@/types/components/imageVault"
import type { ApiImage } from "@/types/hotel"

function mapApiImageToGalleryImage(apiImage: ApiImage): GalleryImage {
  return {
    src: apiImage.imageSizes.medium,
    alt:
      apiImage.metaData.altText ||
      apiImage.metaData.altText_En ||
      apiImage.metaData.title,
    caption: apiImage.metaData.title,
    smallSrc: apiImage.imageSizes.small,
  }
}

export function mapApiImagesToGalleryImages(
  apiImages: ApiImage[]
): GalleryImage[] {
  return apiImages.map(mapApiImageToGalleryImage)
}

function mapImageVaultImageToGalleryImage(
  imageVaultImage: ImageVaultAsset
): GalleryImage {
  return {
    src: imageVaultImage.url,
    alt: imageVaultImage.meta.alt || imageVaultImage.meta.caption || "",
    caption: imageVaultImage.meta.caption,
  }
}

export function mapImageVaultImagesToGalleryImages(
  imageVaultImages: ImageVaultAsset[]
): GalleryImage[] {
  return imageVaultImages.map(mapImageVaultImageToGalleryImage)
}
