//Librairies
import Api from '@scripts/api';
import Lang from '@scripts/lang';
import Projects from '@scripts/projects';
import User from '@scripts/user';
import { createApp, reactive } from 'vue';

//Main template
import App from './App';

//Style
import Css from '@styles/spot';

//App Configuration from PHP
const appConfig = JSON.parse(document.getElementById('app-config').textContent);

//Instances
const oProjects = new Projects(appConfig.projects);
const oUser = reactive(new User(appConfig.user, appConfig.consts.default_timezone));
const oLang = new Lang({translations: appConfig.consts.lang, prefix: appConfig.consts.lang_prefix});
const oApi = new Api({
	server: appConfig.consts.server,
	processPage: appConfig.consts.process_page,
	timezone: oUser.timezone,
	csrfToken: appConfig.consts.csrf_token,
	errorCode: appConfig.consts.error,
	lang: oLang
});

//Mount app
const oApp = createApp(App);
oApp.provide('appConfig', appConfig);
oApp.provide('api', oApi);
oApp.provide('lang', oLang);
oApp.provide('projects', oProjects);
oApp.provide('user', oUser);
oApp.mount('#container');
