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