<script>
	export let pairs;
</script>

{#if pairs.schedulePairs.length === 1}
	<div
		class="w-full m-2
		border-[1px] rounded-xl border-[var(--w-border)] dark:border-[var(--b-border)]
		{pairs.isCurrentPair ? 'bg-[var(--w-blue)] dark:bg-[var(--b-blue)]' : ''}
		"
	>
		<div
			class="border-b-[1px] border-[var(--w-border)] dark:border-[var(--b-border)]"
		>
			<h1 class="m-2 mb-1">
				{pairs.N}) {pairs.time.replace("-", " - ")}
			</h1>
		</div>
		<div class="p-2">
			<h1>
				{pairs.schedulePairs[0].subject}
			</h1>
			<h1>
				aud: {pairs.schedulePairs[0].aud}
			</h1>
			<a
				target="_blank"
				href="https://www.usue.ru/raspisanie/getteams/?prepod={pairs
					.schedulePairs[0].teacher}"
				class="underline"
			>
				{pairs.schedulePairs[0].teacher}
			</a>
			<h1>
				{pairs.schedulePairs[0].group}
			</h1>
		</div>
	</div>
{:else if pairs.schedulePairs.length > 1}
	{@const end_index = pairs.schedulePairs.length - 1}
	<div
		class="w-full m-2
		border-[1px] rounded-xl border-[var(--w-border)] dark:border-[var(--b-border)]
		{pairs.isCurrentPair ? 'bg-[var(--w-blue)] dark:bg-[var(--b-blue)]' : ''}
		"
	>
		<div class="border-b-2 border-[var(--border)]">
			<h1 class="m-2 mb-1">
				{pairs.N}) {pairs.time.replace("-", " - ")}
			</h1>
		</div>
		{#each pairs.schedulePairs as pair, i}
			<div
				class="p-2
				{i === end_index ? '' : 'border-b-[1px] border-[var(--border)]'}"
			>
				<h1>
					{pair.subject}
				</h1>
				<h1>
					aud: {pair.aud}
				</h1>
				<a
					target="_blank"
					href="https://www.usue.ru/raspisanie/getteams/?prepod={pair.teacher}"
					class="underline"
				>
					{pair.teacher}
				</a>
				<h1>
					{pair.group}
				</h1>
			</div>
		{/each}
	</div>
{/if}
