, enc3, enc4;
        let base64Index = 0, byteIndex = 0;
        while (base64Index < input.length) {
            // Process 4 characters at a time. Map to the 6-bit key value.
            enc1 = key.indexOf(input[base64Index++]);
            enc2 = key.indexOf(input[base64Index++]);
            enc3 = key.indexOf(input[base64Index++]);
            enc4 = key.indexOf(input[base64Index++]);
            // Transform 6-bit to 8-bit
            // eg. Converts 111111-000000-111111-000000 => 11111100-00001111-11000000
            bytes[byteIndex++] += ((enc1 << 2) | (enc2 >> 4));
            if (enc3 != 64) {
                bytes[byteIndex++] += (((enc2 & 15) << 4) | (enc3 >> 2));
            }
            if (enc4 != 64) {
                bytes[byteIndex++] += (((enc3 & 3) << 6) | enc4);
            }
        }
        return utf8ToString(bytes);
    }
    Base64.decodeToString = decodeToString;
    // Decode UTF-8 to javascript string
    function utf8ToString(bytes) {
        var result = "";
        let i = 0;
        let c1 = 0, c2 = 0, c3 = 0, c4 = 0;
        while (i < bytes.length) {
            c1 = bytes[i++];
            // Code Points 0x80 and above are pushed to binary and encoded as bytes.
            if (c1 > 127) {
                if ((c1 > 191) && (c1 < 224)) {
                    if (i >= bytes.length) {
                        throw 'utf8ToString: Invalid 2-byte sequence.';
                    }
                    c2 = bytes[i++];
                    c1 = ((c1 & 31) << 6) | (c2 & 63);
                }
                else if (c1 > 223 && c1 < 240) {
                    if (i + 1 >= bytes.length) {
                        throw 'utf8ToString: Invalid 3-byte sequence.';
                    }
                    c2 = bytes[i++];
                    c3 = bytes[i++];
                    c1 = ((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63);
                }
                else if (c1 > 239 && c1 < 248) {
                    if (i + 2 >= bytes.length) {
                        throw 'utf8ToString: Invalid 4-byte sequence.';
                    }
                    c2 = bytes[i++];
                    c3 = bytes[i++];
                    c4 = bytes[i++];
                    c1 = (c1 & 7) << 18 | (c2 & 63) << 12 | (c3 & 63) << 6 | c4 & 63;
                }
                else {
                    throw 'utf8ToString: Unknown multibyte sequence';
                }
            }
            if (c1 <= 0xffff) {
                result += String.fromCharCode(c1);
            }
            else if (c1 <= 0x10ffff) {
                c1 -= 0x10000;
                result += String.fromCharCode(c1 >> 10 | 0xd800);
                result += String.fromCharCode(c1 & 0x3FF | 0xdc00);
            }
            else {
                throw 'utf8ToString: Largest UTF8 Code point reached.';
            }
        }
        return result;
    }
})(Base64 || (Base64 = {}));
class LoggingChannel {
    constructor(project) {
        project("Windows.Foundation.Diagnostics");
        this.loggingChannel = new Windows.Foundation.Diagnostics.LoggingChannel("Microsoft.Windows.SmartScreen", new Windows.Foundation.Diagnostics.LoggingChannelOptions("4f50731a-89cf-4782-b3e0-dce8c90476ba"), "39bd9805-3945-4878-aecc-096a23369f68");
    }
    logException(exception, context) {
        let fields = new Windows.Foundation.Diagnostics.LoggingFields();
        fields.addString("name", $.get(exception, "name", ""));
        fields.addString("message", $.get(exception, "message", ""));
        fields.addString("stack", $.get(exception, "stack", ""));
        fields.addString("context", context ? context : "");
        this.loggingChannel.logEvent("Exception", fields, Windows.Foundation.Diagnostics.LoggingLevel.Error, new Windows.Foundation.Diagnostics.LoggingOptions(0x400000000000));
    }
    logInfo(event) {
        this.loggingChannel.logEvent(event.name, event.fields, Windows.Foundation.Diagnostics.LoggingLevel.Information, new Windows.Foundation.Diagno