<script lang="ts">
	import User from "$lib/components/ui/User.svelte";
	import RepoCard from "$lib/components/repo/RepoCard.svelte";
	import TimelineCard from "./TimelineCard.svelte";
	import { relativeTime } from "$lib/format";
	import { toRepoCard, repoHref } from "./mappers";
	import type { StarEvent } from "$lib/api/lexicons/types/sh/tangled/feed/getTimeline";

	let { event, eventAt }: { event: StarEvent; eventAt: string } = $props();
</script>

<TimelineCard>
	{#snippet header()}
		<User handle={event.actor.handle} did={event.actor.did} />
		<span>starred</span>
		<a href={repoHref(event.repo)} class="text-foreground-default"
			>{event.repo.owner.handle}/{event.repo.slug}</a
		>
		<span class="text-foreground-subtle">{relativeTime(eventAt)}</span>
	{/snippet}

	<RepoCard
		repo={toRepoCard(event.repo)}
		border={false}
		shadow={false}
		background={false}
		padding="none"
	/>
</TimelineCard>
