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