<script lang="ts">
	import type { Media } from '$lib/AniList/media';
	import settings from '../../stores/settings';
	import * as wanakana from 'wanakana';

	export let media: Media;
</script>

{#if $settings.displayNativeTitles}
	{#if $settings.displayFurigana}
		<span title={media.title.english || media.title.romaji || media.title.native}>
			<ruby>
				{media.title.native}
				<rt>
					{wanakana.toKana(media.title.romaji)}
				</rt>
			</ruby>
		</span>
	{:else}
		<span title={media.title.english || media.title.romaji || media.title.native}>
			{media.title.native}
		</span>
	{/if}
{:else}
	<span title={media.title.native}>
		{media.title.english || media.title.romaji || media.title.native}
	</span>
{/if}
