import Image from "next/image";
import { isUploadAssetPath } from "@/lib/image-url";

type Props = {
  src: string;
  alt: string;
};

export function WaffleMenuImage({ src, alt }: Props) {
  if (src.startsWith("http://") || src.startsWith("https://")) {
    return (
      // eslint-disable-next-line @next/next/no-img-element -- URLs externes arbitraires
      <img
        src={src}
        alt={alt}
        className="h-full w-full object-cover"
        loading="lazy"
        referrerPolicy="no-referrer"
      />
    );
  }

  return (
    <Image
      src={src}
      alt={alt}
      fill
      unoptimized={isUploadAssetPath(src)}
      className="object-cover"
      sizes="(max-width: 640px) 100vw, 50vw"
    />
  );
}
