<template>

    <div class="relative shadow-2xl rounded-lg mt-4 p-2 border-t border-zinc-800 dark:bg-zinc-950">
        <img v-if="instance.logo" :src="useRuntimeConfig().public.MediaUrl + instance.logo" alt=""
            class="rounded-lg absolute size-20 left-2 -top-2">

        <img v-else-if="instance.activity.get_image" :src="useRuntimeConfig().public.MediaUrl + instance.activity.get_image"
            alt="" class="rounded-lg absolute size-20 left-2 -top-2">

        <UserProfile :user="instance.activity.user" />
        <!-- instance.activity info -->
        <div class="flex items-center mt-4 text-sm font-bold tracking-tight text-zinc-950 dark:text-white">
            <h5 class="">
                {{ instance.activity.title }}
            </h5>
            <NuxtLink :to="useRuntimeConfig().public.router.Link + instance.id">
                <svg @click="store.setLink(instance)" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
                    stroke-width="1.5" stroke="currentColor" class="size-6 mr-2 ">
                    <path stroke-linecap="round" stroke-linejoin="round"
                        d="M21 16.811c0 .864-.933 1.406-1.683.977l-7.108-4.061a1.125 1.125 0 0 1 0-1.954l7.108-4.061A1.125 1.125 0 0 1 21 8.689v8.122ZM11.25 16.811c0 .864-.933 1.406-1.683.977l-7.108-4.061a1.125 1.125 0 0 1 0-1.954l7.108-4.061a1.125 1.125 0 0 1 1.683.977v8.122Z" />
                </svg>
            </NuxtLink>
        </div>
        <div class="flex justify-between items-end mt-1">
            <a :href="instance.url"
                class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 h-7 focus:outline-none focus:ring-blue-300 font-medium rounded-md px-5 py-0.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">رفتن
                به پیوند
                <svg class="rtl:rotate-180 size-3 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
                    fill="none" viewBox="0 0 14 10">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        d="M1 5h12m0 0L9 1m4 4L9 9" />
                </svg>
            </a>
            <div class="flex flex-col items-end">
                <p class="mt-1 text-xs text-left font-normal text-zinc-500 dark:text-zinc-400">
                    {{ toPersianNumbers(instance.activity.persian_date) }}
                </p>
                <ActivityStatistics :instance="instance.activity" />
            </div>
        </div>
    </div>
</template>

<script setup>
import { useMaghaleStore } from '~/store'

const store = useMaghaleStore()
const { $toPersianNumbers } = useNuxtApp();
const toPersianNumbers = $toPersianNumbers;
const props = defineProps(['instance'])
const instance = props.instance
</script>