import ButtonLink from "@/components/ButtonLink"
import Image from "@/components/Image"
import Body from "@/components/TempDesignSystem/Text/Body"

import Subtitle from "../Text/Subtitle"
import TeaserCardSidepeek from "./Sidepeek"
import { teaserCardVariants } from "./variants"

import styles from "./teaserCard.module.css"

import type { TeaserCardProps } from "@/types/components/teaserCard"

export default function TeaserCard({
  title,
  description,
  primaryButton,
  secondaryButton,
  sidePeekButton,
  sidePeekContent,
  image,
  intent,
  alwaysStack = false,
  className,
}: TeaserCardProps) {
  const classNames = teaserCardVariants({ intent, alwaysStack, className })

  return (
    <article className={classNames}>
      {image && (
        <div className={styles.imageContainer}>
          <Image
            src={image.url}
            alt={image.meta?.alt || ""}
            className={styles.image}
            focalPoint={image.focalPoint}
            fill
          />
        </div>
      )}
      <div className={styles.content}>
        <Subtitle textAlign="left" type="two" color="black">
          {title}
        </Subtitle>
        <Body color="black">{description}</Body>
        {sidePeekButton && sidePeekContent ? (
          <TeaserCardSidepeek
            button={sidePeekButton}
            sidePeekContent={sidePeekContent}
          />
        ) : (
          <div className={styles.ctaContainer}>
            {primaryButton && (
              <ButtonLink
                variant="Tertiary"
                color="Primary"
                size="Small"
                typography="Body/Supporting text (caption)/smBold"
                className={styles.ctaButton}
                href={primaryButton.href}
                target={primaryButton.openInNewTab ? "_blank" : undefined}
              >
                {primaryButton.title}
              </ButtonLink>
            )}
            {secondaryButton && (
              <ButtonLink
                variant="Secondary"
                color="Primary"
                size="Small"
                typography="Body/Supporting text (caption)/smBold"
                className={styles.ctaButton}
                href={secondaryButton.href}
                target={secondaryButton.openInNewTab ? "_blank" : undefined}
              >
                {secondaryButton.title}
              </ButtonLink>
            )}
          </div>
        )}
      </div>
    </article>
  )
}
