<script lang="ts">
    import {onMount} from "svelte";
    import {userStore} from "./helperFunctions/userStore"
    import Router from "svelte-spa-router"
    import Home from "./routes/Home.svelte";
    import {wrap} from "svelte-spa-router/wrap";
    import Spinner from "./helperComponents/Spinner.svelte";
    import Header from "./helperComponents/Header.svelte";

    onMount(async () => {
        await userStore.checkProvider('anilist')
        await userStore.checkProvider('mal')
        await userStore.checkProvider('simkl')
    })
</script>

{#if $userStore.anilist.isLoggedIn}
    <Header />
    <Router routes={{
        '/': Home,
        '/anime/:id': wrap({
            asyncComponent: () => import('./routes/AnimeRoutePage.svelte'),
            loadingComponent: Spinner
        }),
        // '*': "Not Found"
    }} />
{/if}
