import { createApp } from 'vue'
import './main.scss'
import App from './App.vue'
import { setGameData } from '@/composables/useCef'

const app = createApp(App);
app.mount('#app');

declare const cef: any;

if (typeof cef !== 'undefined') {
    cef.on("browser:execute", (query: string) => eval(query));

    cef.emit("game:hud:setComponentVisible", "interface", false);
    cef.emit("game:data:pollPlayerStats", true, 50);
    cef.on("game:data:playerStats", (hp: number, max_hp: number, arm: number, breath: number, wanted: number, weapon: number, ammo: number, max_ammo: number, money: number, speed: number) => {
        setGameData({
            health: hp,
            maxHealth: max_hp,
            armor: arm,
            breath: breath*100,
            weapon: weapon,
            ammo: ammo,
            maxammo: max_ammo-ammo,
            wanted: wanted,
            money: money,
            speed: speed*1.5,
        });
    });
}