<script setup lang="ts">
import ContentManager from './components/managers/ContentManager.vue';
import ToastManager from './components/managers/ToastManager.vue';
import WindowManager from './components/managers/WindowManager.vue';

import { CreateWindow } from '@/services/Windows'
import { GetUser, HasAdmin } from './services/User';
import TooltipManager from './components/managers/TooltipManager.vue';

async function start(){
  if(GetUser()){
    CreateWindow('main_menu');
    return;
  }

  if(await HasAdmin()){
    CreateWindow('login');
  } else {
    CreateWindow('register', {firstTime: true});
  }
  // DisplayToast('aqua', 'All plugins loaded successfully');
}

useHead({
  title: 'Dragonroll',
  meta: [
    { name: 'description', content: 'Dragonroll is a free and open-source tabletop RPG virtual tabletop. It allows you to play your favorite pen-and-paper RPGs online with your friends, with features like character sheets, dice rolling, maps, tokens, and more.' },
    { name: 'keywords', content: 'virtual tabletop, vtt, online rpg, pen-and-paper rpg, dungeons and dragons, pathfinder, roll20 alternative' },
    { name: 'author', content: 'Aran Roig' },
  ],
})

onMounted(() => {
  setupTheme();
  setTheme('dark');
  start();
})
</script>

<template>
  <div class="viewer">
    <ToastManager></ToastManager>
    <TooltipManager></TooltipManager>
    <WindowManager></WindowManager>
    <ContentManager></ContentManager>
    <!-- Managers -->
  </div>
</template>

<style scoped>
.viewer {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
}
</style>