255||(b=e.charCodeAt(N++))>255||(P=e.charCodeAt(N++))>255)throw new TypeError("invalid character found");u=d<<16|b<<8|P,v+=O[u>>18&63]+O[u>>12&63]+O[u>>6&63]+O[u&63]}return U?v.slice(0,U-3)+"===".substring(U):v},z=j?e=>btoa(e):m?e=>h.from(e,"binary").toString("base64"):L,K=m?e=>h.from(e).toString("base64"):e=>{let d=[];for(let b=0,P=e.length;bu?R(K(e)):K(e),Z=e=>{if(e.length<2){var u=e.charCodeAt(0);return u<128?e:u<2048?s(192|u>>>6)+s(128|u&63):s(224|u>>>12&15)+s(128|u>>>6&63)+s(128|u&63)}else{var u=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return s(240|u>>>18&7)+s(128|u>>>12&63)+s(128|u>>>6&63)+s(128|u&63)}},Q=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,H=e=>e.replace(Q,Z),J=m?e=>h.from(e,"utf8").toString("base64"):x?e=>K(x.encode(e)):e=>z(H(e)),M=(e,u=!1)=>u?R(J(e)):J(e),V=e=>M(e,!0),Y=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,k=e=>{switch(e.length){case 4:var u=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),d=u-65536;return s((d>>>10)+55296)+s((d&1023)+56320);case 3:return s((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return s((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},X=e=>e.replace(Y,k),$=e=>{if(e=e.replace(/\s+/g,""),!B.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let u,d="",b,P;for(let v=0;v>16&255):P===64?s(u>>16&255,u>>8&255):s(u>>16&255,u>>8&255,u&255);return d},G=C?e=>atob(F(e)):m?e=>h.from(e,"base64").toString("binary"):$,t=m?e=>S(h.from(e,"base64")):e=>S(G(e).split("").map(u=>u.charCodeAt(0))),r=e=>t(o(e)),n=m?e=>h.from(e,"base64").toString("utf8"):_?e=>_.decode(t(e)):e=>X(G(e)),o=e=>F(e.replace(/[-_]/g,u=>u=="-"?"+":"/")),i=e=>n(o(e)),a=e=>{if(typeof e!="string")return!1;const u=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(u)||!/[^\s0-9a-zA-Z\-_]/.test(u)},f=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),l=function(){const e=(u,d)=>Object.defineProperty(String.prototype,u,f(d));e("fromBase64",function(){return i(this)}),e("toBase64",function(u){return M(this,u)}),e("toBase64URI",function(){return M(this,!0)}),e("toBase64URL",function(){return M(this,!0)}),e("toUint8Array",function(){return r(this)})},w=function(){const e=(u,d)=>Object.defineProperty(Uint8Array.prototype,u,f(d));e("toBase64",function(u){return W(this,u)}),e("toBase64URI",function(){return W(this,!0)}),e("toBase64URL",function(){return W(this,!0)})},y={version:g,VERSION:A,atob:G,atobPolyfill:$,btoa:z,btoaPolyfill:L,fromBase64:i,toBase64:M,encode:M,encodeURI:V,encodeURL:V,utob:H,btou:X,decode:i,isValid:a,fromUint8Array:W,toUint8Array:r,extendString:l,extendUint8Array:w,extendBuiltins:()=>{l(),w()}}}}]);