<script lang="ts">
	import type { Media } from '$lib/AniList/media';
	import type { SubsPleaseEpisode } from '../Anime/Airing/Subtitled/subsPlease';

	export let hovering = false;
	export let hoveredItem: SubsPleaseEpisode | null = null;
	export let hoveredMedia: Media | null = null;
	export let imageStyle = '';
	export let width = 250;
</script>

{#if hovering}
	<img
		class="hover-image show"
		src={hoveredMedia
			? hoveredMedia.coverImage.extraLarge
			: `https://subsplease.org${hoveredItem?.image_url}`}
		alt="Media Cover"
		style={`width: ${width}px; ${imageStyle}`}
	/>
{/if}

<style>
	.hover-image {
		position: fixed;
		z-index: 1000;
		height: auto;
		display: none;
		border-radius: 3px;
	}

	.show {
		display: block;
	}
</style>
