function toBase64(input: string) {
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var fromCharCode = String.fromCharCode;
var cb_utob = function (c: any) {
if (c.length < 2) {
var cc: any = c.charCodeAt(0);
return cc < 128 ? c : cc < 2048 ? (fromCharCode(192 | (cc >>> 6)) + fromCharCode(128 | (cc & 63))) : (fromCharCode(224 | ((cc >>> 12) & 15)) + fromCharCode(128 | ((cc >>> 6) & 63)) + fromCharCode(128 | (cc & 63)))
} else {
var cc: any = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
return (fromCharCode(240 | ((cc >>> 18) & 7)) + fromCharCode(128 | ((cc >>> 12) & 63)) + fromCharCode(128 | ((cc >>> 6) & 63)) + fromCharCode(128 | (cc & 63)))
}
};
var _encode = function (u: any) {
return btoa(utob(String(u)))
};
var mkUriSafe = function (b64: any) {
return b64.replace(/[+\/]/g, function (m0: any) {
return m0 == "+" ? "-" : "_"
}).replace(/=/g, "")
};
var encode = function (u: any,) {
return _encode(u) // mkUriSafe(_encode(u)) ||
};
var utob = function (u: any) {
return u.replace(re_utob, cb_utob)
};
return encode(input)
}