<script lang="ts">
import type { ActivityHistoryEntry } from '$lib/Data/AniList/activity';
import identity from '$stores/identity';
import type { Wrapped } from '$lib/Data/AniList/wrapped';
import proxy from '$lib/Utility/proxy';

export let wrapped: Wrapped;
export let year: number;
export let activities: ActivityHistoryEntry[];
export let useFullActivityHistory: boolean;
export let updateWidth: () => void;

const currentYear = new Date(Date.now()).getFullYear();
</script>

<div class="grid-item image-grid avatar-grid category top-category">
  <a href={`https://anilist.co/user/${$identity.name}`} target="_blank">
    <img src={proxy(wrapped.avatar.large)} alt="User Avatar" onload={updateWidth} />
  </a>
  <div>
    <div>
      <a href={`https://anilist.co/user/${$identity.name}`} target="_blank">
        <b>
          {$identity.name}
        </b>
      </a>
    </div>
    <div>
      Status Posts: {wrapped.activities.statusCount}
    </div>
    <div>
      Messages: {wrapped.activities.messageCount}
    </div>
    <div>
      Days Active: {#if year !== currentYear}
        ?/365
      {:else}
        {activities.length}/{useFullActivityHistory ? 365 : 189}
      {/if}
    </div>
  </div>
</div>
