#buildvars

(function() {
    var isCompatible = (function() {
        if(navigator.userAgent.indexOf('MSIE') >= 0)
            return false;
        if(navigator.userAgent.indexOf('Trident/') >= 0)
            return false;

        if(!('Blob' in window) || !('prototype' in window.Blob)
            || window.Blob.prototype.constructor.name !== 'Blob')
            return false;

        if(!('AudioContext' in window) && !('webkitAudioContext' in window))
            return false;

        if(!('URL' in window) || !('createObjectURL' in window.URL)
            || window.URL.prototype.constructor.name !== 'URL')
            return false;

        if(!('localStorage' in window))
            return false;
        try {
            var testVar = 'test';
            localStorage.setItem(testVar, testVar);
            if(localStorage.getItem(testVar) !== testVar)
                throw '';
            localStorage.removeItem(testVar);
        } catch(e) {
            return false;
        }

        try {
            // this is eval'd to allow a parse exception to be thrown without cancelling the entire script
            eval('for(const i of ["a", "b"]); let obj; obj?.test(); obj ??= {};');
        } catch(e) {
            return false;
        }

        return true;
    })();

    if(isCompatible) {
        (function(script) {
            script.src = MAMI_MAIN_JS;
            script.type = 'text/javascript';
            script.charset = 'utf-8';
            document.body.appendChild(script);
        })(document.createElement('script'));
    } else location.assign(window.AMI_URL);
})();
