<script lang="ts">
    import BookmarkList from '$lib/components/BookmarkList.svelte';

    let { data } = $props();
    const bookmarks = $derived(data.bookmarks);
</script>

{#if data.error}
    <p class="error" role="alert" data-testid="profile-bookmarks-error">
        Couldn't load bookmarks: {data.error}
    </p>
{:else if !data.authenticated}
    <p class="hint" data-testid="profile-bookmarks-signin">
        <a href="/login?next=/profile/bookmarks">Sign in</a> to see your bookmarks.
    </p>
{:else if bookmarks.length === 0}
    <p class="hint" data-testid="profile-bookmarks-empty">No bookmarks yet.</p>
{:else}
    <BookmarkList {bookmarks} testid="profile-bookmark-list" />
{/if}

<style>
    .hint {
        color: var(--text-muted);
    }
    .error {
        color: var(--danger);
    }
</style>
