import { defineStore } from "pinia";
export const useApplicationStore = defineStore("application", {
    state: () => ({
        showSettings: false,
        showMenu: false,
        language: null,
        settings: {
            sound: {
                muted: false,
                master: 100,
                game: 100,
                ambient: 100,
                music: 100
            }
        }
    }),
    actions: {
        init() {
            if (this.language == null) {
                let language = navigator.language.slice(0,2) || navigator.userLanguage.slice(0,2)
                if (language == 'ua' || language == 'ru') {
                    language = 'ru'
                } else {
                    language = 'en'
                }
                this.language = language
            }
        },
        async openSettings() {
            this.showSettings = true
        },
        async closeSettings() {
            this.showSettings = false
        },
        async openMenu() {
            this.showMenu = true
        },
        async closeMenu() {
            this.showMenu = false
        }
    },
    persist: true,
})
