!(function (window) {
    var env = {};
    window.env = env;
    checkPlatform(env);
    var isCN = checkIsChinese();
    initTitle(isCN);

    function initTitle(isCN) {
        document.title = isCN ? "杏聆荟" : "Flyinsono";
    }

    function checkPlatform(target) {
        // injectWinTest();
        var shell = window["FisShellApi"];
        if (shell) {
            target.platform = 'shell';
            shell.getPlatformName().then(function (res) {
                target.platform = res;
            });
        } else {
            target.platform = 'Web';
        }
    }
    /// inject `FisShellApi` for debug
    function injectWinTest() {
        window["FisShellApi"] = {
            writeLog: async (text) => {
                console.log(text);
            },
            getPlatformName: async () => "Win",
            setTitle: async (title) => {
                console.log(`Set title - ${title}`);
            },
        };
    }

    function checkIsChinese() {
        var lang = navigator.language.split('-')[0].toLocaleLowerCase();
        return lang === 'zh';
    }
})(window);