<script lang="ts">
  export let prompt: string;
  export let images: string[] = [];
  export let correctIndex: number;
  export let onComplete: () => void;

  let selectedIndex = -1;

  const handleClick = (index: number) => {
    selectedIndex = index;

    if (index === correctIndex) setTimeout(onComplete, 500);
  };
</script>

<div class="container">
  <p class="big-text">{prompt}</p>

  {#each images as url, i}
    <a href={'#'} on:click={() => handleClick(i)}>
      <img
        src={url}
        alt="Option {i + 1}"
        style={selectedIndex === i
          ? i === correctIndex
            ? 'border: 3px solid var(--base0B)'
            : 'border: 3px solid var(--base0E)'
          : 'border: 3px solid transparent'}
      />
    </a>
  {/each}
</div>

<style>
  img {
    width: 33vh;
    cursor: pointer;
    object-fit: cover;
  }
</style>
