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

	export let title: MediaTitle;
</script>

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