import { createApp } from "vue";
import App           from "./App.vue";
import axios         from "axios";
import vueAxios      from "vue-axios";
import {createRouter, createWebHashHistory} from "vue-router";
import routes        from "./routes";
import store         from "./store";
import vuetify       from "./plugins/vuetify";
import { loadFonts } from "./plugins/webfontloader";
import i18n          from "./plugins/i18n";

loadFonts();

const router = createRouter({
    history: createWebHashHistory(), //createWebHistory(),
    routes
});
const app = createApp(App);

/**
 * Audio player statuses
 */
app.config.globalProperties.statuses = {
    "stopped": 0,
    "paused":  1,
    "playing": 2
};

/**
 * App tabs
 */
 app.config.globalProperties.tabs = {
    "authors": 0,
    "books":   1,
    "book":    2
};

app.config.globalProperties.defaultBackground = "img/library1080.webp";

fetch(process.env.BASE_URL + "data/config.json")
    .then((response) => response.json())
    .then((config) => {
        app.config.globalProperties.appConfig = config
        app
            .use(vueAxios, axios)
            .use(vuetify)
            .use(i18n)
            .use(router)
            .use(routes)
            .use(store)
            .mount("#app")
    });
