PageSourceSearch

https://stream-vault-three.vercel.app/assets/index-Ca6BSJa5.js

js stream-vault-three.vercel.app collected 2026-10-03 07:48:48 UTC 133,225 bytes, 541 lines download raw bytes

1const Yt=a=>{if(typeof a=="object"&&a!==null){if(typeof Object.getPrototypeOf=="function"){const n=Object.getPrototypeOf(a);return n===Object.prototype||n===null}return Object.prototype.toString.call(a)==="[object Object]"}return!1},ht=(...a)=>a.reduce((n,u)=>{if(u===void 0)return n;if(Array.isArray(u))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(u).forEach(l=>{["__proto__","constructor","prototype"].includes(l)||(Array.isArray(n[l])&&Array.isArray(u[l])?n[l]=ht.options.mergeArrays?ht.options.uniqueArrayItems?Array.from(new Set(n[l].concat(u[l]))):[...n[l],...u[l]]:u[l]:Yt(n[l])&&Yt(u[l])?n[l]=ht(n[l],u[l]):!Yt(n[l])&&Yt(u[l])?n[l]=ht(u[l],void 0):n[l]=u[l]===void 0?ht.options.allowUndefinedOverrides?u[l]:n[l]:u[l])}),n},{}),pe={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};ht.options=pe;ht.withOptions=(a,...n)=>{ht.options=Object.assign(Object.assign({},pe),a);const u=ht(...n);return ht.options=pe,u};var hr=Object.defineProperty,dr=(a,n,u)=>n in a?hr(a,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[n]=u,M=(a,n,u)=>dr(a,typeof n!="symbol"?n+"":n,u),Vt=(a=21)=>crypto.getRandomValues(new Uint8Array(a)).reduce((n,u)=>(u&=63,u<36?n+=u.toString(36):u<62?n+=(u-26).toString(36).toUpperCase():u>62?n+="-":n+="_",n),""),pr={functionName:"getPermissions",permissions:[]},gr=()=>{},yr=["ACCESS_ADDRESS"],wr={functionName:"getActiveAddress",permissions:yr},mr=()=>{},br=["ACCESS_ALL_ADDRESSES"],vr={functionName:"getAllAddresses",permissions:br},Er=()=>{},Ar=["ACCESS_PUBLIC_KEY"],Tr={functionName:"getActivePublicKey",permissions:Ar},Sr=()=>{},Cr=["ACCESS_ALL_ADDRESSES"],_r={functionName:"getWalletNames",permissions:Cr},Nr=()=>{},Lr=["ACCESS_ARWEAVE_CONFIG"],kr={functionName:"getArweaveConfig",permissions:Lr},Rr=()=>{},Br=[],Or={functionName:"disconnect",permissions:Br},Ir=()=>{},xr=()=>{dispatchEvent(new CustomEvent("walletSwitch",{detail:{address:void 0}}))},Ur=[],Dr={functionName:"addToken",permissions:Ur},Pr=(a,n,u)=>(u&&typeof u!="string"&&(u=void 0,console.warn("Gateway is deprecated for tokens. Provide a DRE node instead.")),[a,n,u]),Mr=[],Wr={functionName:"isTokenAdded",permissions:Mr},$r=()=>{},Fr=[],jr={functionName:"connect",permissions:Fr},Hr=[{host:"arweave.net",port:443,protocol:"https"},{host:"ar-io.net",port:443,protocol:"https"},{host:"arweave.dev",port:443,protocol:"https"},{host:"g8way.io",port:443,protocol:"https"}],Gr=Hr[0];function qr(a){return a?new URL(a).host:""}var Kr=-42,Vr=-420,Lt,zr=/(\d+)x\d+/,Yr=2e3,Jr=1e3,se=(a,n=window.location.origin)=>{if(a)try{return new URL(a,n).href}catch{}},Qe=async(a,n={},u=Yr)=>{let l=new AbortController,i=setTimeout(()=>l.abort(),u);try{return await fetch(a,{...n,signal:l.signal})}finally{clearTimeout(i)}},Ee=a=>{var n;if(!((n=a.sizes)!=null&&n.value))return 0;let u=a.sizes.value.match(zr);return u?parseInt(u[1],10):0},Xr=async()=>{var a;let n=document.querySelector("link[rel='manifest']");if(!(n instanceof HTMLLinkElement))return;let u=se(n.href);if(u)try{let l=await Qe(u,{method:"GET",cache:"force-cache",credentials:"same-origin"});if(!l.ok)throw new Error(`Failed to fetch manifest: ${l.status}`);let i=await l.json();if(!((a=i.icons)!=null&&a.length))return;let d=i.icons.filter(o=>o==null?void 0:o.src);if(!d.length)return;let c=d.sort((o,w)=>{var b,A,T,x;let S=o.type==="image/svg+xml"||((b=o.src)==null?void 0:b.endsWith(".svg")),_=w.type==="image/svg+xml"||((A=w.src)==null?void 0:A.endsWith(".svg"));if(S&&!_)return-1;if(!S&&_)return 1;let O=parseInt(((T=o.sizes)==null?void 0:T.split("x")[0])||"0",10);return parseInt(((x=w.sizes)==null?void 0:x.split("x")[0])||"0",10)-O});return se(c[0].src,u)}catch(l){console.error("Error fetching web app manifest:",l)}},Zr=()=>{let a=["link[rel='icon'][type='image/svg+xml']","link[rel='icon']","link[rel='apple-touch-icon']","link[rel='apple-touch-icon-precomposed']","link[rel='shortcut icon']","img[alt*='logo']","img[src*='logo']"];for(let n of a){let u=document.querySelectorAll(n);if(!u.length)continue;let l=Array.from(u).filter(c=>c instanceof HTMLLinkElement&&c.href||c instanceof HTMLImageElement&&c.src);if(!l.length)continue;l.sort((c,o)=>c instanceof HTMLLinkElement&&o instanceof HTMLLinkElement?Ee(o)-Ee(c):0);let i=l[0],d;if(i instanceof HTMLLinkElement?d=se(i.href):i instanceof HTMLImageElement&&(d=se(i.src)),d)return d}},Qr=async()=>{let a=`${window.location.origin}/favicon.ico`;try{return(await Qe(a,{method:"HEAD"},Jr)).ok?a:void 0}catch{}};async function tn(){if(Lt)return Lt;try{let a=await Xr();if(a)return Lt=a,a;let n=Zr();if(n)return Lt=n,n;let u=await Qr();return Lt=u,u}catch(a){console.error("Error in getAppLogo:",a),Lt=void 0}}var en=async(a,n={},u)=>{if(!a||a.length===0)throw new Error("No permissions requested");
1if(!n.name){let l=document.title,i=qr(window.location.href);n.name=l.length<11?l:i}return n.logo||(n.logo=await tn()),[a,n,u]},rn=["SIGN_TRANSACTION"],nn={functionName:"sign",permissions:rn};function tr(a){let n=document.createElement("img"),u={x:0,y:0},l=`ar-coin-animation-${document.querySelectorAll(".ar-coing-animation").length}`,i=100;n.setAttribute("src",a),n.setAttribute("alt","a"),n.style.position="fixed",n.style.bottom="0",n.style.right=`${Math.floor(Math.random()*30)}px`,n.style.width="18px",n.style.zIndex="1000000",n.style.transition="all .23s ease",n.id=l,n.classList.add("ar-coing-animation"),document.body.appendChild(n);let d=setInterval(()=>{var c;if(i<0)return(c=document.querySelector(`#${l}`))==null||c.remove(),clearInterval(d);i-=6.5,u.x+=Math.floor(Math.random()*30)-10,u.y+=Math.floor(Math.random()*24),n.style.transform=`translate(-${u.x}px, -${u.y}px)`,n.style.opacity=`${i/100}`},100)}function an(a){return!!a&&typeof a=="object"&&a.hasOwnProperty("callID")&&a.hasOwnProperty("type")&&a.hasOwnProperty("data")}function er(a){return an(a)&&!!a.error}var on={NODE_ENV:"production"},{search:sn="",ancestorOrigins:Ae=[]}=typeof document<"u"?document.location:{},Ct=new URLSearchParams(sn),rr=Ae[Ae.length-1];function oe(){try{return typeof window<"u"&&(window.self!==window.top||!!rr)}catch{return!0}}var nr=on.NODE_ENV,ln={development:{DEFAULT_EMBEDDED_CLIENT_ID:"FREE_TRIAL",DEFAULT_EMBEDDED_SERVER_BASE_URL:"https://connect-api-dev.wander.app"},production:{DEFAULT_EMBEDDED_CLIENT_ID:"FREE_TRIAL",DEFAULT_EMBEDDED_SERVER_BASE_URL:"https://connect-api.wander.app"},test:{DEFAULT_EMBEDDED_CLIENT_ID:"FREE_TRIAL",DEFAULT_EMBEDDED_SERVER_BASE_URL:"https://connect-api-dev.wander.app"}},me=ln[nr];if(!me)throw new Error(`Missing ENV vars for NODE_ENV = "${nr}"`);var un="client-id",fn="theme",cn="ancestor-origin",hn="hide-be",dn="injected-be",pn="server-base-url",gn="skip-storage-access-warning";Ct.get(un)||me.DEFAULT_EMBEDDED_CLIENT_ID;Ct.get(fn);var yn=rr||Ct.get(cn);Ct.get(hn);Ct.get(dn);Ct.get(pn)||me.DEFAULT_EMBEDDED_SERVER_BASE_URL;Ct.get(gn);function ge(){return yn}var Mt={NODE_ENV:"production"},It=(a=>(a.API="API",a.AUTH="AUTH",a.CHUNKS="CHUNKS",a.EMBEDDED_FLOWS="EMBEDDED_FLOWS",a.GATEWAYS="GATEWAYS",a.MSG="MSG",a.ROUTING="ROUTING",a.SETUP="SETUP",a.WALLET_GENERATION="WALLET_GENERATION",a.SESSION="SESSION",a.STORAGE="STORAGE",a.AGENTS="AGENTS",a.TIERS="TIERS",a.TRANSAK="TRANSAK",a.FAIR_LAUNCH="FAIR_LAUNCH",a.TRANSACTIONS="TRANSACTIONS",a.EARN="EARN",a.SWAP="SWAP",a.ARNS="ARNS",a.ANALYTICS="ANALYTICS",a))(It||{}),wn={API:!1,AUTH:Mt.NODE_ENV==="development",CHUNKS:!1,EMBEDDED_FLOWS:!1,GATEWAYS:!1,MSG:!1,ROUTING:!1,SETUP:!1,WALLET_GENERATION:!1,SESSION:!1,STORAGE:!1,AGENTS:!1,TIERS:!1,TRANSAK:!1,FAIR_LAUNCH:!1,TRANSACTIONS:Mt.NODE_ENV==="development",EARN:!1,SWAP:Mt.NODE_ENV==="development",ARNS:Mt.NODE_ENV==="development",ANALYTICS:Mt.NODE_ENV==="development"};function mn(){let{pathname:a}=location;return a.includes("auth.html")?"color: yellow;":"color: inherit;"}function Gt(a,...n){if(!wn[a])return;let u=location.protocol==="chrome-extension:"?"":"[Wander] ";console.log(`${u}%c[${a}]`,mn(),...n)}var ar={},ir=null,or="",bn={auth_chunk:"background",event:"background",switch_wallet_event:"background",copy_address:"background"};function vn(a){ir=a.contentWindow,or=new URL(a.src).origin}var En=0;function An(a){let n=null,u="",{destination:l,messageId:i,data:d}=a;if(l==="background")oe()||(n=ir,u=or);else if(l.startsWith("content-script")){if(!oe())throw new Error('Can only send messages to the "content-script" (SDK) from the "background" (iframe context).');n=window.parent,u=ge()}else if(l.startsWith("web_accessible")&&!oe())throw new Error('Can only send messages to "web_accessible" (auth popup) from the "background" (iframe context).');return n&&u?async function(){return new Promise(async c=>{if(i==="event"||i==="switch_wallet_event"||i==="embedded_signOut"||i==="embedded_setTheme"||i==="embedded_navigate"){n.postMessage({id:Vt(),type:i,data:d},u);return}n.postMessage(d,u),window.addEventListener("message",o);async function o(w){let{data:b}=w;!d||typeof d!="object"||!b||typeof b!="object"||!("callID"in d)||d.callID!==b.callID||`${d.type}_result`===b.type&&(window.removeEventListener("message",o),c(b))}})}:async function(){let c=ar[i];if(!c){console.warn(`No listeners registered for ${i}.`);return}c.size>1&&console.warn(`${c.size} handlers found for ${i}. Only the first response will be returned.`);let o=Array.from(c).map(w=>
1w({id:"0",timestamp:Date.now(),sender:{tabId:Vr,context:bn[i]||null},data:d}));return await Promise.race(o)}}async function qt(a){let{destination:n,messageId:u}=a,l=parseInt(n.split("@")[1]||"0");if(isNaN(l))throw new Error("Unexpected NaN tabId");let i=En++,d=An(a);return new Promise(async c=>{Gt(It.MSG,`[${i}] Sending ${u} to ${n}`),d().then(o=>{Gt(It.MSG,`[${i}] ${u} sent`),c(o)})})}function Tn(){typeof window>"u"||window.addEventListener("message",async({origin:a,data:n})=>{if(!n||typeof n!="object"||a!==ge())return;let u=n.type;n.app==="wanderEmbedded"?u=n.type==="chunk"?"chunk":"api_call":n=n.data;let l=ar[u];if(!l){console.warn(`No listeners registered for ${u}.`);return}let i=Array.from(l).map(c=>c({id:Vt(),timestamp:Date.now(),data:n,sender:{tabId:Kr,context:"content-script"}})),d=await Promise.race(i);if(window.parent===null)throw new Error("Unexpected `null` parent Window.");window.parent.postMessage(d,ge())})}oe()&&Tn();function xt(a){return new Promise(async(n,u)=>{let l={app:"wanderEmbedded",version:"",callID:Vt(),type:"chunk",data:a},i=await qt({destination:"background",messageId:"chunk",data:l});
1if(er(i)||typeof i.data=="string")return u(i.data);n()})}function Sn(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var kt={},dt={},Wt={},Te;function sr(){if(Te)return Wt;Te=1,Wt.byteLength=o,Wt.toByteArray=b,Wt.fromByteArray=x;for(var a=[],n=[],u=typeof Uint8Array<"u"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,d=l.length;i<d;++i)a[i]=l[i],n[l.charCodeAt(i)]=i;n[45]=62,n[95]=63;function c(S){var _=S.length;if(_%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var O=S.indexOf("=");O===-1&&(O=_);var W=O===_?0:4-O%4;return[O,W]}function o(S){var _=c(S),O=_[0],W=_[1];return(O+W)*3/4-W}function w(S,_,O){return(_+O)*3/4-O}function b(S){var _,O=c(S),W=O[0],q=O[1],$=new u(w(S,W,q)),Y=0,Z=q>0?W-4:W,L;for(L=0;L<Z;L+=4)_=n[S.charCodeAt(L)]<<18|n[S.charCodeAt(L+1)]<<12|n[S.charCodeAt(L+2)]<<6|n[S.charCodeAt(L+3)],$[Y++]=_>>16&255,$[Y++]=_>>8&255,$[Y++]=_&255;return q===2&&(_=n[S.charCodeAt(L)]<<2|n[S.charCodeAt(L+1)]>>4,$[Y++]=_&255),q===1&&(_=n[S.charCodeAt(L)]<<10|n[S.charCodeAt(L+1)]<<4|n[S.charCodeAt(L+2)]>>2,$[Y++]=_>>8&255,$[Y++]=_&255),$}function A(S){return a[S>>18&63]+a[S>>12&63]+a[S>>6&63]+a[S&63]}function T(S,_,O){for(var W,q=[],$=_;$<O;$+=3)W=(S[$]<<16&16711680)+(S[$+1]<<8&65280)+(S[$+2]&255),q.push(A(W));return q.join("")}function x(S){for(var _,O=S.length,W=O%3,q=[],$=16383,Y=0,Z=O-W;Y<Z;Y+=$)q.push(T(S,Y,Y+$>Z?Z:Y+$));return W===1?(_=S[O-1],q.push(a[_>>2]+a[_<<4&63]+"==")):W===2&&(_=(S[O-2]<<8)+S[O-1],q.push(a[_>>10]+a[_>>4&63]+a[_<<2&63]+"=")),q.join("")}return Wt}var Se;function bt(){if(Se)return dt;
1Se=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.concatBuffers=n,dt.b64UrlToString=u,dt.bufferToString=l,dt.stringToBuffer=i,dt.stringToB64Url=d,dt.b64UrlToBuffer=c,dt.bufferTob64=o,dt.bufferTob64Url=w,dt.b64UrlEncode=b,dt.b64UrlDecode=A;let a=sr();function n(T){let x=0;for(let O=0;O<T.length;O++)x+=T[O].byteLength;let S=new Uint8Array(x),_=0;S.set(new Uint8Array(T[0]),_),_+=T[0].byteLength;for(let O=1;O<T.length;O++)S.set(new Uint8Array(T[O]),_),_+=T[O].byteLength;return S}function u(T){let x=c(T);return l(x)}function l(T){return new TextDecoder("utf-8",{fatal:!0}).decode(T)}function i(T){return new TextEncoder().encode(T)}function d(T){return w(i(T))}function c(T){return new Uint8Array(a.toByteArray(A(T)))}function o(T){return a.fromByteArray(new Uint8Array(T))}function w(T){return b(o(T))}function b(T){try{return T.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}catch(x){throw new Error("Failed to encode string",{cause:x})}}function A(T){try{T=T.replace(/\-/g,"+").replace(/\_/g,"/");let x;return T.length%4==0?x=0:x=4-T.length%4,T.concat("=".repeat(x))}catch(x){throw new Error("Failed to decode string",{cause:x})}}return dt}var Jt={},Xt={},Zt={},ye={exports:{}},Cn=ye.exports,Ce;function _n(){return Ce||(Ce=1,function(a){(function(n){var u,l=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,d=Math.floor,c="[BigNumber Error] ",o=c+"Number primitive has more than 15 significant digits: ",w=1e14,b=14,A=9007199254740991,T=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],x=1e7,S=1e9;function _(N){var k,P,H,B=I.prototype={constructor:I,toString:null,valueOf:null},z=new I(1),R=20,D=4,V=-7,X=21,nt=-1e7,lt=1e7,gt=!1,Et=1,wt=0,Q={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},tt="0123456789abcdefghijklmnopqrstuvwxyz",_t=!0;function I(f,p){var g,E,m,v,t,e,r,s,h=this;if(!(h instanceof I))return new I(f,p);if(p==null){if(f&&f._isBigNumber===!0){h.s=f.s,!f.c||f.e>lt?h.c=h.e=null:f.e<nt?h.c=[h.e=0]:(h.e=f.e,h.c=f.c.slice());return}if((e=typeof f=="number")&&f*0==0){if(h.s=1/f<0?(f=-f,-1):1,f===~~f){for(v=0,t=f;t>=10;t/=10,v++);v>lt?h.c=h.e=null:(h.e=v,h.c=[f]);return}s=String(f)}else{if(!l.test(s=String(f)))return H(h,s,e);h.s=s.charCodeAt(0)==45?(s=s.slice(1),-1):1}(v=s.indexOf("."))>-1&&(s=s.replace(".","")),(t=s.search(/e/i))>0?(v<0&&(v=t),v+=+s.slice(t+1),s=s.substring(0,t)):v<0&&(v=s.length)}else{if($(p,2,tt.length,"Base"),p==10&&_t)return h=new I(f),ot(h,R+h.e+1,D);if(s=String(f),e=typeof f=="number"){if(f*0!=0)return H(h,s,e,p);if(h.s=1/f<0?(s=s.slice(1),-1):1,I.DEBUG&&s.replace(/^0\.0*|\./,"").length>15)throw Error(o+f)}else h.s=s.charCodeAt(0)===45?(s=s.slice(1),-1):1;for(g=tt.slice(0,p),v=t=0,r=s.length;t<r;t++)if(g.indexOf(E=s.charAt(t))<0){if(E=="."){if(t>v){v=r;continue}}else if(!m&&(s==s.toUpperCase()&&(s=s.toLowerCase())||s==s.toLowerCase()&&(s=s.toUpperCase()))){m=!0,t=-1,v=0;continue}return H(h,String(f),e,p)}e=!1,s=P(s,p,10,h.s),(v=s.indexOf("."))>-1?s=s.replace(".",""):v=s.length}for(t=0;s.charCodeAt(t)===48;t++);for(r=s.length;s.charCodeAt(--r)===48;);if(s=s.slice(t,++r)){if(r-=t,e&&I.DEBUG&&r>15&&(f>A||f!==d(f)))throw Error(o+h.s*f);if((v=v-t-1)>lt)h.c=h.e=null;else if(v<nt)h.c=[h.e=0];else{if(h.e=v,h.c=[],t=(v+1)%b,v<0&&(t+=b),t<r){for(t&&h.c.push(+s.slice(0,t)),r-=b;t<r;)h.c.push(+s.slice(t,t+=b));t=b-(s=s.slice(t)).length}else t-=r;for(;t--;s+="0");h.c.push(+s)}}else h.c=[h.e=0]}I.clone=_,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(f){var p,g;if(f!=null)if(typeof f=="object"){if(f.hasOwnProperty(p="DECIMAL_PLACES")&&(g=f[p],$(g,0,S,p),R=g),f.hasOwnProperty(p="ROUNDING_MODE")&&(g=f[p],$(g,0,8,p),D=g),f.hasOwnProperty(p="EXPONENTIAL_AT")&&(g=f[p],g&&g.pop?($(g[0],-S,0,p),$(g[1],0,S,p),V=g[0],X=g[1]):($(g,-S,S,p),V=-(X=g<0?-g:g))),f.hasOwnProperty(p="RANGE"))if(g=f[p],g&&g.pop)$(g[0],-S,-1,p),$(g[1],1,S,p),nt=g[0],lt=g[1];else if($(g,-S,S,p),g)nt=-(lt=g<0?-g:g);else throw Error(c+p+" cannot be zero: "+g);if(f.hasOwnProperty(p="CRYPTO"))if(g=f[p],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))gt=g;else throw gt=!g,Error(c+"crypto unavailable");else gt=g;else throw Error(c+p+" not true or false: "+g);if(f.hasOwnProperty(p="MODULO_MODE")&&(g=f[p],$(g,0,9,p),Et=g),f.hasOwnProperty(p="POW_PRECISION")&&(g=f[p],$(g,0,S,p),wt=g),f.hasOwnProperty(p="FORMAT"))if(g=f[p],typeof g=="object")Q=g;else throw Error(c+p+" not an object: "+g);if(f.hasOwnProperty(p="ALPHABET"))if(g=f[p],typeof g=="string"&&!/^.?$|[+\-.\
vendor: 7,375 bytes, line 1
1s]|(.).*\1/.test(g))_t=g.slice(0,10)=="0123456789",tt=g;else throw Error(c+p+" invalid: "+g)}else throw Error(c+"Object expected: "+f);return{DECIMAL_PLACES:R,ROUNDING_MODE:D,EXPONENTIAL_AT:[V,X],RANGE:[nt,lt],CRYPTO:gt,MODULO_MODE:Et,POW_PRECISION:wt,FORMAT:Q,ALPHABET:tt}},I.isBigNumber=function(f){if(!f||f._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var p,g,E=f.c,m=f.e,v=f.s;t:if({}.toString.call(E)=="[object Array]"){if((v===1||v===-1)&&m>=-S&&m<=S&&m===d(m)){if(E[0]===0){if(m===0&&E.length===1)return!0;break t}if(p=(m+1)%b,p<1&&(p+=b),String(E[0]).length==p){for(p=0;p<E.length;p++)if(g=E[p],g<0||g>=w||g!==d(g))break t;if(g!==0)return!0}}}else if(E===null&&m===null&&(v===null||v===1||v===-1))return!0;throw Error(c+"Invalid BigNumber: "+f)},I.maximum=I.max=function(){return zt(arguments,-1)},I.minimum=I.min=function(){return zt(arguments,1)},I.random=function(){var f=9007199254740992,p=Math.random()*f&2097151?function(){return d(Math.random()*f)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(g){var E,m,v,t,e,r=0,s=[],h=new I(z);if(g==null?g=R:$(g,0,S),t=i(g/b),gt)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(t*=2));r<t;)e=E[r]*131072+(E[r+1]>>>11),e>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),E[r]=m[0],E[r+1]=m[1]):(s.push(e%1e14),r+=2);r=t/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(t*=7);r<t;)e=(E[r]&31)*281474976710656+E[r+1]*1099511627776+E[r+2]*4294967296+E[r+3]*16777216+(E[r+4]<<16)+(E[r+5]<<8)+E[r+6],e>=9e15?crypto.randomBytes(7).copy(E,r):(s.push(e%1e14),r+=7);r=t/7}else throw gt=!1,Error(c+"crypto unavailable");if(!gt)for(;r<t;)e=p(),e<9e15&&(s[r++]=e%1e14);for(t=s[--r],g%=b,t&&g&&(e=T[b-g],s[r]=d(t/e)*e);s[r]===0;s.pop(),r--);if(r<0)s=[v=0];else{for(v=-1;s[0]===0;s.splice(0,1),v-=b);for(r=1,e=s[0];e>=10;e/=10,r++);r<b&&(v-=b-r)}return h.e=v,h.c=s,h}}(),I.sum=function(){for(var f=1,p=arguments,g=new I(p[0]);f<p.length;)g=g.plus(p[f++]);return g},P=function(){var f="0123456789";function p(g,E,m,v){for(var t,e=[0],r,s=0,h=g.length;s<h;){for(r=e.length;r--;e[r]*=E);for(e[0]+=v.indexOf(g.charAt(s++)),t=0;t<e.length;t++)e[t]>m-1&&(e[t+1]==null&&(e[t+1]=0),e[t+1]+=e[t]/m|0,e[t]%=m)}return e.reverse()}return function(g,E,m,v,t){var e,r,s,h,y,C,U,F,G=g.indexOf("."),K=R,j=D;for(G>=0&&(h=wt,wt=0,g=g.replace(".",""),F=new I(E),C=F.pow(g.length-G),wt=h,F.c=p(L(W(C.c),C.e,"0"),10,m,f),F.e=F.c.length),U=p(g,E,m,t?(e=tt,f):(e=f,tt)),s=h=U.length;U[--h]==0;U.pop());if(!U[0])return e.charAt(0);if(G<0?--s:(C.c=U,C.e=s,C.s=v,C=k(C,F,K,j,m),U=C.c,y=C.r,s=C.e),r=s+K+1,G=U[r],h=m/2,y=y||r<0||U[r+1]!=null,y=j<4?(G!=null||y)&&(j==0||j==(C.s<0?3:2)):G>h||G==h&&(j==4||y||j==6&&U[r-1]&1||j==(C.s<0?8:7)),r<1||!U[0])g=y?L(e.charAt(1),-K,e.charAt(0)):e.charAt(0);else{if(U.length=r,y)for(--m;++U[--r]>m;)U[r]=0,r||(++s,U=[1].concat(U));for(h=U.length;!U[--h];);for(G=0,g="";G<=h;g+=e.charAt(U[G++]));g=L(g,s,e.charAt(0))}return g}}(),k=function(){function f(E,m,v){var t,e,r,s,h=0,y=E.length,C=m%x,U=m/x|0;for(E=E.slice();y--;)r=E[y]%x,s=E[y]/x|0,t=U*r+s*C,e=C*r+t%x*x+h,h=(e/v|0)+(t/x|0)+U*s,E[y]=e%v;return h&&(E=[h].concat(E)),E}function p(E,m,v,t){var e,r;if(v!=t)r=v>t?1:-1;else for(e=r=0;e<v;e++)if(E[e]!=m[e]){r=E[e]>m[e]?1:-1;break}return r}function g(E,m,v,t){for(var e=0;v--;)E[v]-=e,e=E[v]<m[v]?1:0,E[v]=e*t+E[v]-m[v];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,m,v,t,e){var r,s,h,y,C,U,F,G,K,j,J,at,At,fe,ce,mt,Pt,pt=E.s==m.s?1:-1,ut=E.c,et=m.c;if(!ut||!ut[0]||!et||!et[0])return new I(!E.s||!m.s||(ut?et&&ut[0]==et[0]:!et)?NaN:ut&&ut[0]==0||!et?pt*0:pt/0);for(G=new I(pt),K=G.c=[],s=E.e-m.e,pt=v+s+1,e||(e=w,s=O(E.e/b)-O(m.e/b),pt=pt/b|0),h=0;et[h]==(ut[h]||0);h++);if(et[h]>(ut[h]||0)&&s--,pt<0)K.push(1),y=!0;else{for(fe=ut.length,mt=et.length,h=0,pt+=2,C=d(e/(et[0]+1)),C>1&&(et=f(et,C,e),ut=f(ut,C,e),mt=et.length,fe=ut.length),At=mt,j=ut.slice(0,mt),J=j.length;J<mt;j[J++]=0);Pt=et.slice(),Pt=[0].concat(Pt),ce=et[0],et[1]>=e/2&&ce++;do{if(C=0,r=p(et,j,mt,J),r<0){if(at=j[0],mt!=J&&(at=at*e+(j[1]||0)),C=d(at/ce),C>1)for(C>=e&&(C=e-1),U=f(et,C,e),F=U.length,J=j.length;p(U,j,F,J)==1;)C--,g(U,mt<F?Pt:et,F,e),F=U.length,r=1;else C==0&&(r=C=1),U=et.slice(),F=U.length;if(F<J&&(U=[0].concat(U)),g(j,U,J,e),J=j.length,r==-1)for(;p(et,j,mt,J)<1;)C++,g(j,mt<J?Pt:et,J,e),J=j.length}else r===0&&(C++,j=[0]);K[h++]=C,j[0]?j[J++]=ut[At]||0:(j=[ut[At]],J=1)}while((At++<fe||j[0]!=null)&&pt--);y=j[0]!=null,K[0]||K.splice(0,1)}if(e==w){for(h=1,pt=K[0];pt>=10;pt/=10,h++);ot(G,v+(G.e=h+s*b-1)+1,t,y)}else G.e=s,G.r=+y;return G}}();function Nt(f,p,g,E){var m,v,t,e,r;if(g==null?g=D:$(g,0,8),!f.c)return f.toString();if(m=f.c[0],t=f.e,p==null)r=W(f.c),r=E==1||E==2&&(t<=V||t>=X)?Z(r,t):L(r,t,"0");else if(f=ot(new I(f),p,g),v=f.e,r=W(f.c),e=r.length,E==1||E==2&&(p<=v||v<=V)){for(;e<p;r+="0",e++);r=Z(r,v)}else if(p-=t+(E===2&&v>t),r=L(r,v,"0"),v+1>e){if(--p>0)for(r+=".";p--;r+="0");}else if(p+=v-e,p>0)for(v+1==e&&(r+=".");p--;r+="0");return f.s<0&&m?"-"+r:r}function zt(f,p){for(var g,E,m=1,v=new I(f[0]);m<f.length;m++)E=new I(f[m]),(!E.s||(g=q(v,E))===p||g===0&&v.s===p)&&(v=E);return v}function Dt(f,p,g){for(var E=1,m=p.length;!p[--m];p.pop());for(m=p[0];m>=10;m/=10,E++);return(g=E+g*b-1)>lt?f.c=f.e=null:g<nt?f.c=[f.e=0]:(f.e=g,f.c=p),f}H=function(){var f=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,g=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(v,t,e,r){var s,h=e?t:t.replace(m,"");if(E.test(h))v.s=isNaN(h)?null:h<0?-1:1;else{if(!e&&(h=h.replace(f,function(y,C,U){return s=(U=U.toLowerCase())=="x"?16:U=="b"?2:8,!r||r==s?C:y}),r&&(s=r,h=h.replace(p,"$1").replace(g,"0.$1")),t!=h))return new I(h,s);if(I.DEBUG)throw Error(c+"Not a"+(r?" base "+r:"")+" number: "+t);v.s=null}v.c=v.e=null}}();function ot(f,p,g,E){var m,v,t,e,r,s,h,y=f.c,C=T;if(y){t:{for(m=1,e=y[0];e>=10;e/=10,m++);if(v=p-m,v<0)v+=b,t=p,r=y[s=0],h=d(r/C[m-t-1]%10);else if(s=i((v+1)/b),s>=y.length)if(E){for(;y.length<=s;y.push(0));r=h=0,m=1,v%=b,t=v-b+1}else break t;else{for(r=e=y[s],m=1;e>=10;e/=10,m++);v%=b,t=v-b+m,h=t<0?0:d(r/C[m-t-1]%10)}if(E=E||p<0||y[s+1]!=null||(t<0?r:r%C[m-t-1]),E=g<4?(h||E)&&(g==0||g==(f.s<0?3:2)):h>5||h==5&&(g==4||E||g==6&&(v>0?t>0?r/C[m-t]:0:y[s-1])%10&1||g==(f.s<0?8:7)),p<1||!y[0])return y.length=0,E?(p-=f.e+1,y[0]=C[(b-p%b)%b],f.e=-p||0):y[0]=f.e=0,f;if(v==0?(y.length=s,e=1,s--):(y.length=s+1,e=C[b-v],y[s]=t>0?d(r/C[m-t]%C[t])*e:0),E)for(;;)if(s==0){for(v=1,t=y[0];t>=10;t/=10,v++);for(t=y[0]+=e,e=1;t>=10;t/=10,e++);v!=e&&(f.e++,y[0]==w&&(y[0]=1));break}else{if(y[s]+=e,y[s]!=w)break;y[s--]=0,e=1}for(v=y.length;y[--v]===0;y.pop());}f.e>lt?f.c=f.e=null:f.e<nt&&(f.c=[f.e=0])}return f}function yt(f){var p,g=f.e;return g===null?f.toString():(p=W(f.c),p=g<=V||g>=X?Z(p,g):L(p,g,"0"),f.s<0?"-"+p:p)}return B.absoluteValue=B.abs=function(){var f=new I(this);return f.s<0&&(f.s=1),f},B.comparedTo=function(f,p){return q(this,new I(f,p))},B.decimalPlaces=B.dp=function(f,p){var g,E,m,v=this;if(f!=null)return $(f,0,S),p==null?p=D:$(p,0,8),ot(new I(v),f+v.e+1,p);if(!(g=v.c))return null;if(E=((m=g.length-1)-O(this.e/b))*b,m=g[m])for(;m%10==0;m/=10,E--);return E<0&&(E=0),E},B.dividedBy=B.div=function(f,p){return k(this,new I(f,p),R,D)},B.dividedToIntegerBy=B.idiv=function(f,p){return k(this,new I(f,p),0,1)},B.exponentiatedBy=B.pow=function(f,p){var g,E,m,v,t,e,r,s,h,y=this;
vendor: 4,148 bytes, line 1
1if(f=new I(f),f.c&&!f.isInteger())throw Error(c+"Exponent not an integer: "+yt(f));if(p!=null&&(p=new I(p)),e=f.e>14,!y.c||!y.c[0]||y.c[0]==1&&!y.e&&y.c.length==1||!f.c||!f.c[0])return h=new I(Math.pow(+yt(y),e?f.s*(2-Y(f)):+yt(f))),p?h.mod(p):h;if(r=f.s<0,p){if(p.c?!p.c[0]:!p.s)return new I(NaN);E=!r&&y.isInteger()&&p.isInteger(),E&&(y=y.mod(p))}else{if(f.e>9&&(y.e>0||y.e<-1||(y.e==0?y.c[0]>1||e&&y.c[1]>=24e7:y.c[0]<8e13||e&&y.c[0]<=9999975e7)))return v=y.s<0&&Y(f)?-0:0,y.e>-1&&(v=1/v),new I(r?1/v:v);wt&&(v=i(wt/b+2))}for(e?(g=new I(.5),r&&(f.s=1),s=Y(f)):(m=Math.abs(+yt(f)),s=m%2),h=new I(z);;){if(s){if(h=h.times(y),!h.c)break;v?h.c.length>v&&(h.c.length=v):E&&(h=h.mod(p))}if(m){if(m=d(m/2),m===0)break;s=m%2}else if(f=f.times(g),ot(f,f.e+1,1),f.e>14)s=Y(f);else{if(m=+yt(f),m===0)break;s=m%2}y=y.times(y),v?y.c&&y.c.length>v&&(y.c.length=v):E&&(y=y.mod(p))}return E?h:(r&&(h=z.div(h)),p?h.mod(p):v?ot(h,wt,D,t):h)},B.integerValue=function(f){var p=new I(this);return f==null?f=D:$(f,0,8),ot(p,p.e+1,f)},B.isEqualTo=B.eq=function(f,p){return q(this,new I(f,p))===0},B.isFinite=function(){return!!this.c},B.isGreaterThan=B.gt=function(f,p){return q(this,new I(f,p))>0},B.isGreaterThanOrEqualTo=B.gte=function(f,p){return(p=q(this,new I(f,p)))===1||p===0},B.isInteger=function(){return!!this.c&&O(this.e/b)>this.c.length-2},B.isLessThan=B.lt=function(f,p){return q(this,new I(f,p))<0},B.isLessThanOrEqualTo=B.lte=function(f,p){return(p=q(this,new I(f,p)))===-1||p===0},B.isNaN=function(){return!this.s},B.isNegative=function(){return this.s<0},B.isPositive=function(){return this.s>0},B.isZero=function(){return!!this.c&&this.c[0]==0},B.minus=function(f,p){var g,E,m,v,t=this,e=t.s;if(f=new I(f,p),p=f.s,!e||!p)return new I(NaN);if(e!=p)return f.s=-p,t.plus(f);var r=t.e/b,s=f.e/b,h=t.c,y=f.c;if(!r||!s){if(!h||!y)return h?(f.s=-p,f):new I(y?t:NaN);if(!h[0]||!y[0])return y[0]?(f.s=-p,f):new I(h[0]?t:D==3?-0:0)}if(r=O(r),s=O(s),h=h.slice(),e=r-s){for((v=e<0)?(e=-e,m=h):(s=r,m=y),m.reverse(),p=e;p--;m.push(0));m.reverse()}else for(E=(v=(e=h.length)<(p=y.length))?e:p,e=p=0;p<E;p++)if(h[p]!=y[p]){v=h[p]<y[p];break}if(v&&(m=h,h=y,y=m,f.s=-f.s),p=(E=y.length)-(g=h.length),p>0)for(;p--;h[g++]=0);for(p=w-1;E>e;){if(h[--E]<y[E]){for(g=E;g&&!h[--g];h[g]=p);--h[g],h[E]+=w}h[E]-=y[E]}for(;h[0]==0;h.splice(0,1),--s);return h[0]?Dt(f,h,s):(f.s=D==3?-1:1,f.c=[f.e=0],f)},B.modulo=B.mod=function(f,p){var g,E,m=this;return f=new I(f,p),!m.c||!f.s||f.c&&!f.c[0]?new I(NaN):!f.c||m.c&&!m.c[0]?new I(m):(Et==9?(E=f.s,f.s=1,g=k(m,f,0,3),f.s=E,g.s*=E):g=k(m,f,0,Et),f=m.minus(g.times(f)),!f.c[0]&&Et==1&&(f.s=m.s),f)},B.multipliedBy=B.times=function(f,p){var g,E,m,v,t,e,r,s,h,y,C,U,F,G,K,j=this,J=j.c,at=(f=new I(f,p)).c;if(!J||!at||!J[0]||!at[0])return!j.s||!f.s||J&&!J[0]&&!at||at&&!at[0]&&!J?f.c=f.e=f.s=null:(f.s*=j.s,!J||!at?f.c=f.e=null:(f.c=[0],f.e=0)),f;for(E=O(j.e/b)+O(f.e/b),f.s*=j.s,r=J.length,y=at.length,r<y&&(F=J,J=at,at=F,m=r,r=y,y=m),m=r+y,F=[];m--;F.push(0));for(G=w,K=x,m=y;--m>=0;){for(g=0,C=at[m]%K,U=at[m]/K|0,t=r,v=m+t;v>m;)s=J[--t]%K,h=J[t]/K|0,e=U*s+h*C,s=C*s+e%K*K+F[v]+g,g=(s/G|0)+(e/K|0)+U*h,F[v--]=s%G;F[v]=g}return g?++E:F.splice(0,1),Dt(f,F,E)},B.negated=function(){var f=new I(this);return f.s=-f.s||null,f},B.plus=function(f,p){var g,E=this,m=E.s;if(f=new I(f,p),p=f.s,!m||!p)return new I(NaN);if(m!=p)return f.s=-p,E.minus(f);var v=E.e/b,t=f.e/b,e=E.c,r=f.c;if(!v||!t){if(!e||!r)return new I(m/0);if(!e[0]||!r[0])return r[0]?f:new I(e[0]?E:m*0)}if(v=O(v),t=O(t),e=e.slice(),m=v-t){for(m>0?(t=v,g=r):(m=-m,g=e),g.reverse();m--;g.push(0));g.reverse()}for(m=e.length,p=r.length,m-p<0&&(g=r,r=e,e=g,p=m),m=0;p;)m=(e[--p]=e[p]+r[p]+m)/w|0,e[p]=w===e[p]?0:e[p]%w;return m&&(e=[m].concat(e),++t),Dt(f,e,t)},B.precision=B.sd=function(f,p){var g,E,m,v=this;if(f!=null&&f!==!!f)return $(f,1,S),p==null?p=D:$(p,0,8),ot(new I(v),f,p);if(!(g=v.c))return null;if(m=g.length-1,E=m*b+1,m=g[m]){for(;m%10==0;m/=10,E--);for(m=g[0];m>=10;m/=10,E++);}return f&&v.e+1>E&&(E=v.e+1),E},B.shiftedBy=function(f){return $(f,-A,A),this.times("1e"+f)},B.squareRoot=B.sqrt=function(){var f,p,g,E,m,v=this,t=v.c,e=v.s,r=v.e,s=R+4,h=new I("0.5");
vendor: 4,200 bytes, line 1
1if(e!==1||!t||!t[0])return new I(!e||e<0&&(!t||t[0])?NaN:t?v:1/0);if(e=Math.sqrt(+yt(v)),e==0||e==1/0?(p=W(t),(p.length+r)%2==0&&(p+="0"),e=Math.sqrt(+p),r=O((r+1)/2)-(r<0||r%2),e==1/0?p="5e"+r:(p=e.toExponential(),p=p.slice(0,p.indexOf("e")+1)+r),g=new I(p)):g=new I(e+""),g.c[0]){for(r=g.e,e=r+s,e<3&&(e=0);;)if(m=g,g=h.times(m.plus(k(v,m,s,1))),W(m.c).slice(0,e)===(p=W(g.c)).slice(0,e))if(g.e<r&&--e,p=p.slice(e-3,e+1),p=="9999"||!E&&p=="4999"){if(!E&&(ot(m,m.e+R+2,0),m.times(m).eq(v))){g=m;break}s+=4,e+=4,E=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(ot(g,g.e+R+2,1),f=!g.times(g).eq(v));break}}return ot(g,g.e+R+1,D,f)},B.toExponential=function(f,p){return f!=null&&($(f,0,S),f++),Nt(this,f,p,1)},B.toFixed=function(f,p){return f!=null&&($(f,0,S),f=f+this.e+1),Nt(this,f,p)},B.toFormat=function(f,p,g){var E,m=this;if(g==null)f!=null&&p&&typeof p=="object"?(g=p,p=null):f&&typeof f=="object"?(g=f,f=p=null):g=Q;else if(typeof g!="object")throw Error(c+"Argument not an object: "+g);if(E=m.toFixed(f,p),m.c){var v,t=E.split("."),e=+g.groupSize,r=+g.secondaryGroupSize,s=g.groupSeparator||"",h=t[0],y=t[1],C=m.s<0,U=C?h.slice(1):h,F=U.length;if(r&&(v=e,e=r,r=v,F-=v),e>0&&F>0){for(v=F%e||e,h=U.substr(0,v);v<F;v+=e)h+=s+U.substr(v,e);r>0&&(h+=s+U.slice(v)),C&&(h="-"+h)}E=y?h+(g.decimalSeparator||"")+((r=+g.fractionGroupSize)?y.replace(new RegExp("\\d{"+r+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):y):h}return(g.prefix||"")+E+(g.suffix||"")},B.toFraction=function(f){var p,g,E,m,v,t,e,r,s,h,y,C,U=this,F=U.c;if(f!=null&&(e=new I(f),!e.isInteger()&&(e.c||e.s!==1)||e.lt(z)))throw Error(c+"Argument "+(e.isInteger()?"out of range: ":"not an integer: ")+yt(e));if(!F)return new I(U);for(p=new I(z),s=g=new I(z),E=r=new I(z),C=W(F),v=p.e=C.length-U.e-1,p.c[0]=T[(t=v%b)<0?b+t:t],f=!f||e.comparedTo(p)>0?v>0?p:s:e,t=lt,lt=1/0,e=new I(C),r.c[0]=0;h=k(e,p,0,1),m=g.plus(h.times(E)),m.comparedTo(f)!=1;)g=E,E=m,s=r.plus(h.times(m=s)),r=m,p=e.minus(h.times(m=p)),e=m;return m=k(f.minus(g),E,0,1),r=r.plus(m.times(s)),g=g.plus(m.times(E)),r.s=s.s=U.s,v=v*2,y=k(s,E,v,D).minus(U).abs().comparedTo(k(r,g,v,D).minus(U).abs())<1?[s,E]:[r,g],lt=t,y},B.toNumber=function(){return+yt(this)},B.toPrecision=function(f,p){return f!=null&&$(f,1,S),Nt(this,f,p,2)},B.toString=function(f){var p,g=this,E=g.s,m=g.e;return m===null?E?(p="Infinity",E<0&&(p="-"+p)):p="NaN":(f==null?p=m<=V||m>=X?Z(W(g.c),m):L(W(g.c),m,"0"):f===10&&_t?(g=ot(new I(g),R+m+1,D),p=L(W(g.c),g.e,"0")):($(f,2,tt.length,"Base"),p=P(L(W(g.c),m,"0"),10,f,E,!0)),E<0&&g.c[0]&&(p="-"+p)),p},B.valueOf=B.toJSON=function(){return yt(this)},B._isBigNumber=!0,N!=null&&I.set(N),I}function O(N){var k=N|0;return N>0||N===k?k:k-1}function W(N){for(var k,P,H=1,B=N.length,z=N[0]+"";H<B;){for(k=N[H++]+"",P=b-k.length;P--;k="0"+k);z+=k}for(B=z.length;z.charCodeAt(--B)===48;);return z.slice(0,B+1||1)}function q(N,k){var P,H,B=N.c,z=k.c,R=N.s,D=k.s,V=N.e,X=k.e;if(!R||!D)return null;if(P=B&&!B[0],H=z&&!z[0],P||H)return P?H?0:-D:R;if(R!=D)return R;if(P=R<0,H=V==X,!B||!z)return H?0:!B^P?1:-1;if(!H)return V>X^P?1:-1;for(D=(V=B.length)<(X=z.length)?V:X,R=0;R<D;R++)if(B[R]!=z[R])return B[R]>z[R]^P?1:-1;return V==X?0:V>X^P?1:-1}function $(N,k,P,H){if(N<k||N>P||N!==d(N))throw Error(c+(H||"Argument")+(typeof N=="number"?N<k||N>P?" out of range: ":" not an integer: ":" not a primitive number: ")+String(N))}function Y(N){var k=N.c.length-1;return O(N.e/b)==k&&N.c[k]%2!=0}function Z(N,k){return(N.length>1?N.charAt(0)+"."+N.slice(1):N)+(k<0?"e":"e+")+k}function L(N,k,P){var H,B;if(k<0){for(B=P+".";++k;B+=P);N=B+N}else if(H=N.length,++k>H){for(B=P,k-=H;--k;B+=P);N+=B}else k<H&&(N=N.slice(0,k)+"."+N.slice(k));return N}u=_(),u.default=u.BigNumber=u,a.exports?a.exports=u:(n||(n=typeof self<"u"&&self?self:window),n.BigNumber=u)})(Cn)}(ye)),ye.exports}var _e;function Nn(){if(_e)return Zt;_e=1,Object.defineProperty(Zt,"__esModule",{value:!0});let a=_n();class n{constructor(){M(this,"BigNum"),this.BigNum=(l,i)=>{let d=a.BigNumber.clone({DECIMAL_PLACES:i});return new d(l)}}winstonToAr(l,{formatted:i=!1,decimals:d=12,trim:c=!0}={}){let o=this.stringToBigNum(l,d).shiftedBy(-12);return i?o.toFormat(d):o.toFixed(d)}arToWinston(l,{formatted:i=!1}
1={}){let d=this.stringToBigNum(l).shiftedBy(12);return i?d.toFormat():d.toFixed(0)}compare(l,i){let d=this.stringToBigNum(l),c=this.stringToBigNum(i);return d.comparedTo(c)}isEqual(l,i){return this.compare(l,i)===0}isLessThan(l,i){let d=this.stringToBigNum(l),c=this.stringToBigNum(i);return d.isLessThan(c)}isGreaterThan(l,i){let d=this.stringToBigNum(l),c=this.stringToBigNum(i);return d.isGreaterThan(c)}add(l,i){let d=this.stringToBigNum(l);return this.stringToBigNum(i),d.plus(i).toFixed(0)}sub(l,i){let d=this.stringToBigNum(l);return this.stringToBigNum(i),d.minus(i).toFixed(0)}stringToBigNum(l,i=12){return this.BigNum(l,i)}}return Zt.default=n,Zt}var Qt={},Ne;function Ln(){if(Ne)return Qt;Ne=1,Object.defineProperty(Qt,"__esModule",{value:!0});class a{constructor(i){M(this,"METHOD_GET","GET"),M(this,"METHOD_POST","POST"),M(this,"config"),this.applyConfig(i)}applyConfig(i){this.config=this.mergeDefaults(i)}getConfig(){return this.config}mergeDefaults(i){let d=i.protocol||"http",c=i.port||(d==="https"?443:80);return{host:i.host||"127.0.0.1",protocol:d,port:c,timeout:i.timeout||2e4,logging:i.logging||!1,logger:i.logger||console.log,network:i.network}}async get(i,d){return await this.request(i,{...d,method:this.METHOD_GET})}async post(i,d,c){var o;let w=new Headers((c==null?void 0:c.headers)||{});return(o=w.get("content-type"))!=null&&o.includes("application/json")||w.append("content-type","application/json"),w.append("accept","application/json, text/plain, */*"),await this.request(i,{...c,method:this.METHOD_POST,body:typeof d!="string"?JSON.stringify(d):d,headers:w})}async request(i,d){var c;let o=new Headers((d==null?void 0:d.headers)||{}),w=`${this.config.protocol}://${this.config.host}:${this.config.port}`,b=d==null?void 0:d.responseType;d==null||delete d.responseType,i.startsWith("/")&&(i=i.slice(1)),this.config.network&&o.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${w}/${i}`);let A=await fetch(`${w}/${i}`,{...d||{},headers:o});this.config.logging&&this.config.logger(`Response:   ${A.url} - ${A.status}`);let T=A.headers.get("content-type"),x=(c=T==null?void 0:T.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i))==null?void 0:c[1],S=A,_=async()=>{if(x)try{S.data=new TextDecoder(x).decode(await A.arrayBuffer())}catch{S.data=await A.text()}else S.data=await A.text()};if(b==="arraybuffer")S.data=await A.arrayBuffer();else if(b==="text")await _();else if(b==="webstream")S.data=n(A.body);else try{let O=await A.clone().json();typeof O!="object"?await _():S.data=await A.json(),O=null}catch{await _()}return S}}Qt.default=a;let n=l=>{let i=l;return typeof i[Symbol.asyncIterator]>"u"&&(i[Symbol.asyncIterator]=u(l)),i},u=function(l){return async function*(){let i=l.getReader();try{for(;;){let{done:d,value:c}=await i.read();if(d)return;yield c}}finally{i.releaseLock()}}};return Qt}var te={},Le;function kn(){if(Le)return te;Le=1,Object.defineProperty(te,"__esModule",{value:!0});let a=bt();class n{constructor(){if(M(this,"keyLength",4096),M(this,"publicExponent",65537),M(this,"hashAlgorithm","sha256"),M(this,"driver"),!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let l=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),i=await this.driver.exportKey("jwk",l.privateKey);return{kty:i.kty,e:i.e,n:i.n,d:i.d,p:i.p,q:i.q,dp:i.dp,dq:i.dq,qi:i.qi}}async sign(l,i,{saltLength:d}={}){let c=await this.driver.sign({name:"RSA-PSS",saltLength:d??32},await this.jwkToCryptoKey(l),i);return new Uint8Array(c)}async hash(l,i="SHA-256"){let d=await this.driver.digest(i,l);return new Uint8Array(d)}async verify(l,i,d){let c={kty:"RSA",e:"AQAB",n:l},o=await this.jwkToPublicCryptoKey(c),w=await this.driver.digest("SHA-256",i),b=await this.driver.verify({name:"RSA-PSS",saltLength:0},o,d,i),A=await this.driver.verify({name:"RSA-PSS",saltLength:32},o,d,i),T=Math.ceil((o.algorithm.modulusLength-1)/8)-w.byteLength-2,x=await this.driver.verify({name:"RSA-PSS",saltLength:T},o,d,i),S=b||A||x;if(!S){let _={algorithm:o.algorithm.name,modulusLength:o.algorithm.modulusLength,keyUsages:o.usages,saltLengthsAttempted:`0, 32, ${T}`};console.warn(`Transaction Verification Failed! 
2`,`Details: ${JSON.stringify(_,null,2)} 
3`,"N.B. ArweaveJS is only guaranteed to verify txs created using ArweaveJS.")}return S}async jwkToCryptoKey(l){return this.driver.importKey("jwk",l,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(l){return this.driver.importKey("jwk",l,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let l=crypto==null?void 0:crypto.subtle;return l===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(i=>typeof l[i]=="function")}async encrypt(l,i,d){let c=await this.driver.importKey("raw",typeof i=="string"?a.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:d?a.stringToBuffer(d):a.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=new Uint8Array(16);crypto.getRandomValues(w);let b=await this.driver.encrypt({name:"AES-CBC",iv:w},o,l);return a.concatBuffers([w,b])}async decrypt(l,i,d){let c=await this.driver.importKey("raw",typeof i=="string"?a.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:d?a.stringToBuffer(d):a.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},c,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),w=l.slice(0,16),b=await this.driver.decrypt({
3name:"AES-CBC",iv:w},o,l.slice(16));return a.concatBuffers([b])}}return te.default=n,te}var ee={},ke;function Rn(){if(ke)return ee;ke=1,Object.defineProperty(ee,"__esModule",{value:!0});class a{constructor(u){M(this,"api"),this.api=u}getInfo(){return this.api.get("info").then(u=>u.data)}getPeers(){return this.api.get("peers").then(u=>u.data)}}return ee.default=a,ee}var re={},$t={},Re;function ue(){if(Re)return $t;Re=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.getError=n;class a extends Error{constructor(l,i={}){var d=(...c)=>(super(...c),M(this,"type"),M(this,"response"),this);i.message?d(i.message):d(),this.type=l,this.response=i.response}getType(){return this.type}}$t.default=a;function n(u){let l=u.data;if(typeof u.data=="string")try{l=JSON.parse(u.data)}catch{}if(u.data instanceof ArrayBuffer||u.data instanceof Uint8Array)try{l=JSON.parse(l.toString())}catch{}return l?l.error||l:u.statusText||"unknown"}return $t}var Ft={},Be={},he={},Oe;function Bn(){return Oe||(Oe=1,he.read=function(a,n,u,l,i){var d,c,o=i*8-l-1,w=(1<<o)-1,b=w>>1,A=-7,T=u?i-1:0,x=u?-1:1,S=a[n+T];for(T+=x,d=S&(1<<-A)-1,S>>=-A,A+=o;A>0;d=d*256+a[n+T],T+=x,A-=8);for(c=d&(1<<-A)-1,d>>=-A,A+=l;A>0;c=c*256+a[n+T],T+=x,A-=8);if(d===0)d=1-b;else{if(d===w)return c?NaN:(S?-1:1)*(1/0);c=c+Math.pow(2,l),d=d-b}return(S?-1:1)*c*Math.pow(2,d-l)},he.write=function(a,n,u,l,i,d){var c,o,w,b=d*8-i-1,A=(1<<b)-1,T=A>>1,x=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=l?0:d-1,_=l?1:-1,O=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(o=isNaN(n)?1:0,c=A):(c=Math.floor(Math.log(n)/Math.LN2),n*(w=Math.pow(2,-c))<1&&(c--,w*=2),c+T>=1?n+=x/w:n+=x*Math.pow(2,1-T),n*w>=2&&(c++,w/=2),c+T>=A?(o=0,c=A):c+T>=1?(o=(n*w-1)*Math.pow(2,i),c=c+T):(o=n*Math.pow(2,T-1)*Math.pow(2,i),c=0));i>=8;a[u+S]=o&255,S+=_,o/=256,i-=8);for(c=c<<i|o,b+=i;b>0;a[u+S]=c&255,S+=_,c/=256,b-=8);a[u+S-_]|=O*128}),he}var Ie;function On(){return Ie||(Ie=1,function(a){var n=sr(),u=Bn(),l=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;a.Buffer=o,a.SlowBuffer=$,a.INSPECT_MAX_BYTES=50;var i=2147483647;a.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=d(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function d(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function c(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return T(t)}return w(t,e,r)}o.poolSize=8192;function w(t,e,r){if(typeof t=="string")return x(t,e);if(ArrayBuffer.isView(t))return _(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(E(t,ArrayBuffer)||t&&E(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(E(t,SharedArrayBuffer)||t&&E(t.buffer,SharedArrayBuffer)))return O(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var s=t.valueOf&&t.valueOf();if(s!=null&&s!==t)return o.from(s,e,r);var h=W(t);if(h)return h;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return o.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}o.from=function(t,e,r){return w(t,e,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function b(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');
vendor: 4,631 bytes, line 3
3if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function A(t,e,r){return b(t),t<=0?c(t):e!==void 0?typeof r=="string"?c(t).fill(e,r):c(t).fill(e):c(t)}o.alloc=function(t,e,r){return A(t,e,r)};function T(t){return b(t),c(t<0?0:q(t)|0)}o.allocUnsafe=function(t){return T(t)},o.allocUnsafeSlow=function(t){return T(t)};function x(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=Y(t,e)|0,s=c(r),h=s.write(t,e);return h!==r&&(s=s.slice(0,h)),s}function S(t){for(var e=t.length<0?0:q(t.length)|0,r=c(e),s=0;s<e;s+=1)r[s]=t[s]&255;return r}function _(t){if(E(t,Uint8Array)){var e=new Uint8Array(t);return O(e.buffer,e.byteOffset,e.byteLength)}return S(t)}function O(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var s;return e===void 0&&r===void 0?s=new Uint8Array(t):r===void 0?s=new Uint8Array(t,e):s=new Uint8Array(t,e,r),Object.setPrototypeOf(s,o.prototype),s}function W(t){if(o.isBuffer(t)){var e=q(t.length)|0,r=c(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||m(t.length)?c(0):S(t);if(t.type==="Buffer"&&Array.isArray(t.data))return S(t.data)}function q(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return t|0}function $(t){return+t!=t&&(t=0),o.alloc(+t)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,e){if(E(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),E(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,s=e.length,h=0,y=Math.min(r,s);h<y;++h)if(t[h]!==e[h]){r=t[h],s=e[h];break}return r<s?-1:s<r?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var s=o.allocUnsafe(e),h=0;for(r=0;r<t.length;++r){var y=t[r];if(E(y,Uint8Array))h+y.length>s.length?o.from(y).copy(s,h):Uint8Array.prototype.set.call(s,y,h);else if(o.isBuffer(y))y.copy(s,h);else throw new TypeError('"list" argument must be an Array of Buffers');h+=y.length}return s};function Y(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||E(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&r===0)return 0;for(var h=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ot(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return p(t).length;default:if(h)return s?-1:ot(t).length;e=(""+e).toLowerCase(),h=!0}}o.byteLength=Y;function Z(t,e,r){var s=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Et(this,e,r);case"utf8":case"utf-8":return V(this,e,r);case"ascii":return lt(this,e,r);case"latin1":case"binary":return gt(this,e,r);case"base64":return D(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wt(this,e,r);default:if(s)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),s=!0}}o.prototype._isBuffer=!0;function L(t,e,r){var s=t[e];t[e]=t[r],t[r]=s}o.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)L(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)L(this,e,e+3),L(this,e+1,e+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)L(this,e,e+7),L(this,e+1,e+6),L(this,e+2,e+5),L(this,e+3,e+4);return this},o.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?V(this,0,t):Z.apply(this,arguments)}
vendor: 11,843 bytes, line 3
3,o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){var t="",e=a.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},l&&(o.prototype[l]=o.prototype.inspect),o.prototype.compare=function(t,e,r,s,h){if(E(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),s===void 0&&(s=0),h===void 0&&(h=this.length),e<0||r>t.length||s<0||h>this.length)throw new RangeError("out of range index");if(s>=h&&e>=r)return 0;if(s>=h)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,s>>>=0,h>>>=0,this===t)return 0;for(var y=h-s,C=r-e,U=Math.min(y,C),F=this.slice(s,h),G=t.slice(e,r),K=0;K<U;++K)if(F[K]!==G[K]){y=F[K],C=G[K];break}return y<C?-1:C<y?1:0};function N(t,e,r,s,h){if(t.length===0)return-1;if(typeof r=="string"?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,m(r)&&(r=h?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(h)return-1;r=t.length-1}else if(r<0)if(h)r=0;else return-1;if(typeof e=="string"&&(e=o.from(e,s)),o.isBuffer(e))return e.length===0?-1:k(t,e,r,s,h);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?h?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):k(t,[e],r,s,h);throw new TypeError("val must be string, number or Buffer")}function k(t,e,r,s,h){var y=1,C=t.length,U=e.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(t.length<2||e.length<2)return-1;y=2,C/=2,U/=2,r/=2}function F(at,At){return y===1?at[At]:at.readUInt16BE(At*y)}var G;if(h){var K=-1;for(G=r;G<C;G++)if(F(t,G)===F(e,K===-1?0:G-K)){if(K===-1&&(K=G),G-K+1===U)return K*y}else K!==-1&&(G-=G-K),K=-1}else for(r+U>C&&(r=C-U),G=r;G>=0;G--){for(var j=!0,J=0;J<U;J++)if(F(t,G+J)!==F(e,J)){j=!1;break}if(j)return G}return-1}o.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1},o.prototype.indexOf=function(t,e,r){return N(this,t,e,r,!0)},o.prototype.lastIndexOf=function(t,e,r){return N(this,t,e,r,!1)};function P(t,e,r,s){r=Number(r)||0;var h=t.length-r;s?(s=Number(s),s>h&&(s=h)):s=h;var y=e.length;s>y/2&&(s=y/2);for(var C=0;C<s;++C){var U=parseInt(e.substr(C*2,2),16);if(m(U))return C;t[r+C]=U}return C}function H(t,e,r,s){return g(ot(e,t.length-r),t,r,s)}function B(t,e,r,s){return g(yt(e),t,r,s)}function z(t,e,r,s){return g(p(e),t,r,s)}function R(t,e,r,s){return g(f(e,t.length-r),t,r,s)}o.prototype.write=function(t,e,r,s){if(e===void 0)s="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")s=e,r=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(r)?(r=r>>>0,s===void 0&&(s="utf8")):(s=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var h=this.length-e;if((r===void 0||r>h)&&(r=h),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var y=!1;;)switch(s){case"hex":return P(this,t,e,r);case"utf8":case"utf-8":return H(this,t,e,r);case"ascii":case"latin1":case"binary":return B(this,t,e,r);case"base64":return z(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,e,r);default:if(y)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),y=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function D(t,e,r){return e===0&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function V(t,e,r){r=Math.min(t.length,r);for(var s=[],h=e;h<r;){var y=t[h],C=null,U=y>239?4:y>223?3:y>191?2:1;if(h+U<=r){var F,G,K,j;switch(U){case 1:y<128&&(C=y);break;case 2:F=t[h+1],(F&192)===128&&(j=(y&31)<<6|F&63,j>127&&(C=j));break;case 3:F=t[h+1],G=t[h+2],(F&192)===128&&(G&192)===128&&(j=(y&15)<<12|(F&63)<<6|G&63,j>2047&&(j<55296||j>57343)&&(C=j));break;case 4:F=t[h+1],G=t[h+2],K=t[h+3],(F&192)===128&&(G&192)===128&&(K&192)===128&&(j=(y&15)<<18|(F&63)<<12|(G&63)<<6|K&63,j>65535&&j<1114112&&(C=j))}}C===null?(C=65533,U=1):C>65535&&(C-=65536,s.push(C>>>10&1023|55296),C=56320|C&1023),s.push(C),h+=U}return nt(s)}var X=4096;function nt(t){var e=t.length;if(e<=X)return String.fromCharCode.apply(String,t);for(var r="",s=0;s<e;)r+=String.fromCharCode.apply(String,t.slice(s,s+=X));return r}function lt(t,e,r){var s="";r=Math.min(t.length,r);for(var h=e;h<r;++h)s+=String.fromCharCode(t[h]&127);return s}function gt(t,e,r){var s="";r=Math.min(t.length,r);for(var h=e;h<r;++h)s+=String.fromCharCode(t[h]);return s}function Et(t,e,r){var s=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>s)&&(r=s);for(var h="",y=e;y<r;++y)h+=v[t[y]];return h}function wt(t,e,r){for(var s=t.slice(e,r),h="",y=0;y<s.length-1;y+=2)h+=String.fromCharCode(s[y]+s[y+1]*256);return h}o.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var s=this.subarray(t,e);return Object.setPrototypeOf(s,o.prototype),s};function Q(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||Q(t,e,this.length);for(var s=this[t],h=1,y=0;++y<e&&(h*=256);)s+=this[t+y]*h;return s},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||Q(t,e,this.length);for(var s=this[t+--e],h=1;e>0&&(h*=256);)s+=this[t+--e]*h;return s},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t=t>>>0,e||Q(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Q(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Q(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Q(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Q(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||Q(t,e,this.length);for(var s=this[t],h=1,y=0;++y<e&&(h*=256);)s+=this[t+y]*h;return h*=128,s>=h&&(s-=Math.pow(2,8*e)),s},o.prototype.readIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||Q(t,e,this.length);for(var s=e,h=1,y=this[t+--s];s>0&&(h*=256);)y+=this[t+--s]*h;return h*=128,y>=h&&(y-=Math.pow(2,8*e)),y},o.prototype.readInt8=function(t,e){return t=t>>>0,e||Q(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){t=t>>>0,e||Q(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r},o.prototype.readInt16BE=function(t,e){t=t>>>0,e||Q(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r},o.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Q(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Q(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Q(t,4,this.length),u.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Q(t,4,this.length),u.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Q(t,8,this.length),u.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Q(t,8,this.length),u.read(this,t,!1,52,8)};function tt(t,e,r,s,h,y){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>h||e<y)throw new RangeError('"value" argument is out of bounds');if(r+s>t.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,r,s){if(t=+t,e=e>>>0,r=r>>>0,!s){var h=Math.pow(2,8*r)-1;tt(this,t,e,r,h,0)}var y=1,C=0;for(this[e]=t&255;++C<r&&(y*=256);)this[e+C]=t/y&255;return e+r},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,r,s){if(t=+t,e=e>>>0,r=r>>>0,!s){var h=Math.pow(2,8*r)-1;tt(this,t,e,r,h,0)}var y=r-1,C=1;for(this[e+y]=t&255;--y>=0&&(C*=256);)this[e+y]=t/C&255;return e+r},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,1,255,0),this[e]=t&255,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},o.prototype.writeIntLE=function(t,e,r,s){if(t=+t,e=e>>>0,!s){var h=Math.pow(2,8*r-1);tt(this,t,e,r,h-1,-h)}var y=0,C=1,U=0;for(this[e]=t&255;++y<r&&(C*=256);)t<0&&U===0&&this[e+y-1]!==0&&(U=1),this[e+y]=(t/C>>0)-U&255;return e+r},o.prototype.writeIntBE=function(t,e,r,s){if(t=+t,e=e>>>0,!s){var h=Math.pow(2,8*r-1);tt(this,t,e,r,h-1,-h)}var y=r-1,C=1,U=0;for(this[e+y]=t&255;--y>=0&&(C*=256);)t<0&&U===0&&this[e+y+1]!==0&&(U=1),this[e+y]=(t/C>>0)-U&255;return e+r},o.prototype.writeInt8=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},o.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},o.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||tt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function _t(t,e,r,s,h,y){if(r+s>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,s,h){return e=+e,r=r>>>0,h||_t(t,e,r,4),u.write(t,e,r,s,23,4),r+4}o.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},o.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)};function Nt(t,e,r,s,h){return e=+e,r=r>>>0,h||_t(t,e,r,8),u.write(t,e,r,s,52,8),r+8}o.prototype.writeDoubleLE=function(t,e,r){return Nt(this,t,e,!0,r)},o.prototype.writeDoubleBE=function(t,e,r){return Nt(this,t,e,!1,r)},o.prototype.copy=function(t,e,r,s){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!s&&s!==0&&(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<r&&(s=r),s===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-r&&(s=t.length-e+r);var h=s-r;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,r,s):Uint8Array.prototype.set.call(t,this.subarray(r,s),e),h},o.prototype.fill=function(t,e,r,s){if(typeof t=="string"){if(typeof e=="string"?(s=e,e=0,r=this.length):typeof r=="string"&&(s=r,r=this.length),s!==void 0&&typeof s!="str
3ing")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!o.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(t.length===1){var h=t.charCodeAt(0);(s==="utf8"&&h<128||s==="latin1")&&(t=h)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var y;if(typeof t=="number")for(y=e;y<r;++y)this[y]=t;else{var C=o.isBuffer(t)?t:o.from(t,s),U=C.length;if(U===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(y=0;y<r-e;++y)this[y+e]=C[y%U]}return this};var zt=/[^+/0-9A-Za-z-_]/g;function Dt(t){if(t=t.split("=")[0],t=t.trim().replace(zt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ot(t,e){e=e||1/0;for(var r,s=t.length,h=null,y=[],C=0;C<s;++C){if(r=t.charCodeAt(C),r>55295&&r<57344){if(!h){if(r>56319){(e-=3)>-1&&y.push(239,191,189);continue}else if(C+1===s){(e-=3)>-1&&y.push(239,191,189);continue}h=r;continue}if(r<56320){(e-=3)>-1&&y.push(239,191,189),h=r;continue}r=(h-55296<<10|r-56320)+65536}else h&&(e-=3)>-1&&y.push(239,191,189);if(h=null,r<128){if((e-=1)<0)break;y.push(r)}else if(r<2048){if((e-=2)<0)break;y.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;y.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;y.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return y}function yt(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function f(t,e){for(var r,s,h,y=[],C=0;C<t.length&&!((e-=2)<0);++C)r=t.charCodeAt(C),s=r>>8,h=r%256,y.push(h),y.push(s);return y}function p(t){return n.toByteArray(Dt(t))}function g(t,e,r,s){for(var h=0;h<s&&!(h+r>=e.length||h>=t.length);++h)e[h+r]=t[h];return h}function E(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function m(t){return t!==t}var v=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var s=r*16,h=0;h<16;++h)e[s+h]=t[r]+t[h];return e}()}(Be)),Be}var xe=On();(function(a){function n(){var l=this||self;return delete a.prototype.__magic__,l}if(typeof globalThis=="object")return globalThis;if(this)return n();a.defineProperty(a.prototype,"__magic__",{configurable:!0,get:n});var u=__magic__;return u})(Object);var Ue={},De;function lr(){return De||(De=1,function(a){Object.defineProperty(a,"__esModule",{value:!0}),a.arrayCompare=a.MIN_CHUNK_SIZE=a.MAX_CHUNK_SIZE=void 0,a.chunkData=d,a.generateLeaves=c,a.computeRootHash=o,a.generateTree=w,a.generateTransactionChunks=b,a.buildLayers=A,a.generateProofs=T,a.arrayFlatten=S,a.intToBuffer=W,a.bufferToInt=q,a.validatePath=Y,a.debug=Z;let n=le(),u=bt();a.MAX_CHUNK_SIZE=256*1024,a.MIN_CHUNK_SIZE=32*1024;let l=32,i=32;async function d(L){let N=[],k=L,P=0;for(;k.byteLength>=a.MAX_CHUNK_SIZE;){let H=a.MAX_CHUNK_SIZE,B=k.byteLength-a.MAX_CHUNK_SIZE;B>0&&B<a.MIN_CHUNK_SIZE&&(H=Math.ceil(k.byteLength/2));let z=k.slice(0,H),R=await n.default.crypto.hash(z);P+=z.byteLength,N.push({dataHash:R,minByteRange:P-z.byteLength,maxByteRange:P}),k=k.slice(H)}return N.push({dataHash:await n.default.crypto.hash(k),minByteRange:P,maxByteRange:P+k.byteLength}),N}async function c(L){return Promise.all(L.map(async({dataHash:N,minByteRange:k,maxByteRange:P})=>({type:"leaf",id:await O(await Promise.all([O(N),O(W(P))])),dataHash:N,minByteRange:k,maxByteRange:P})))}async function o(L){return(await w(L)).id}async function w(L){return await A(await c(await d(L)))}async function b(L){let N=await d(L),k=await c(N),P=await A(k),H=await T(P),B=N.slice(-1)[0];return B.maxByteRange-B.minByteRange===0&&(N.splice(N.length-1,1),H.splice(H.length-1,1)),{data_root:P.id,chunks:N,proofs:H}}async function A(L,N=0){if(L.length<2)return L[0];let k=[];for(let P=0;P<L.length;P+=2)k.push(await _(L[P],L[P+1]));return A(k,N+1)}function T(L){let N=x(L);return Array.isArray(N)?S(N):[N]}function x(L,N=new Uint8Array,k=0){if(L.type=="leaf")return{offset:L.maxByteRange-1,proof:(0,u.concatBuffers)([N,L.dataHash,W(L.maxByteRange)])};if(L.type=="branch"){let P=(0,u.concatBuffers)([N,L.leftChild.id,L.rightChild.id,W(L.byteRange)]);return[x(L.leftChild,P,k+1),x(L.rightChild,P,k+1)]}throw new Error("Unexpected node type")}function S(L){let N=[];
3return L.forEach(k=>{Array.isArray(k)?N.push(...S(k)):N.push(k)}),N}async function _(L,N){return N?{type:"branch",id:await O([await O(L.id),await O(N.id),await O(W(L.maxByteRange))]),byteRange:L.maxByteRange,maxByteRange:N.maxByteRange,leftChild:L,rightChild:N}:L}async function O(L){return Array.isArray(L)&&(L=n.default.utils.concatBuffers(L)),new Uint8Array(await n.default.crypto.hash(L))}function W(L){let N=new Uint8Array(l);for(var k=N.length-1;k>=0;k--){var P=L%256;N[k]=P,L=(L-P)/256}return N}function q(L){let N=0;for(var k=0;k<L.length;k++)N*=256,N+=L[k];return N}let $=(L,N)=>L.every((k,P)=>N[P]===k);a.arrayCompare=$;async function Y(L,N,k,P,H){if(P<=0)return!1;if(N>=P)return Y(L,0,P-1,P,H);if(N<0)return Y(L,0,0,P,H);if(H.length==i+l){let nt=H.slice(0,i),lt=H.slice(nt.length,nt.length+l),gt=await O([await O(nt),await O(lt)]);return(0,a.arrayCompare)(L,gt)?{offset:P-1,leftBound:k,rightBound:P,chunkSize:P-k}:!1}let B=H.slice(0,i),z=H.slice(B.length,B.length+i),R=H.slice(B.length+z.length,B.length+z.length+l),D=q(R),V=H.slice(B.length+z.length+R.length),X=await O([await O(B),await O(z),await O(R)]);return(0,a.arrayCompare)(L,X)?N<D?await Y(B,N,k,Math.min(P,D),V):await Y(z,N,Math.max(k,D),P,V):!1}async function Z(L,N=""){if(L.byteLength<1)return N;let k=L.slice(0,i),P=L.slice(k.length,k.length+i),H=L.slice(k.length+P.length,k.length+P.length+l),B=q(H),z=L.slice(k.length+P.length+H.length),R=await O([await O(k),await O(P),await O(H)]),D=`${N}
4${JSON.stringify(xe.Buffer.from(k))},${JSON.stringify(xe.Buffer.from(P))},${B} => ${JSON.stringify(R)}`;return Z(z,D)}}(Ue)),Ue}var Pe;function In(){if(Pe)return Ft;Pe=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.TransactionUploader=void 0;let a=be(),n=bt(),u=ue(),l=lr(),i=1,d=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"],c=1e3*40;class o{constructor(b,A){if(M(this,"api"),M(this,"chunkIndex",0),M(this,"txPosted",!1),M(this,"transaction"),M(this,"lastRequestTimeEnd",0),M(this,"totalErrors",0),M(this,"data"),M(this,"lastResponseStatus",0),M(this,"lastResponseError",""),this.api=b,!A.id)throw new Error("Transaction is not signed");if(!A.chunks)throw new Error("Transaction chunks not prepared");this.data=A.data,this.transaction=new a.default(Object.assign({},A,{data:new Uint8Array(0)}))}get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}async uploadChunk(b){if(this.isComplete)throw new Error("Upload is already complete");if(this.lastResponseError!==""?this.totalErrors++:this.totalErrors=0,this.totalErrors===100)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let A=this.lastResponseError===""?0:Math.max(this.lastRequestTimeEnd+c-Date.now(),c);if(A>0&&(A=A-A*Math.random()*.3,await new Promise(S=>setTimeout(S,A))),this.lastResponseError="",!this.txPosted){await this.postTransaction();return}b&&(this.chunkIndex=b);let T=this.transaction.getChunk(b||this.chunkIndex,this.data);if(!await(0,l.validatePath)(this.transaction.chunks.data_root,parseInt(T.offset),0,parseInt(T.data_size),n.b64UrlToBuffer(T.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);let x=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch(S=>(console.error(S.message),{status:-1,data:{error:S.message}}));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=x.status,this.lastResponseStatus==200)this.chunkIndex++;else if(this.lastResponseError=(0,u.getError)(x),d.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(b,A,T){if(!A||typeof A.chunkIndex!="number"||typeof A.transaction!="object")throw new Error("Serialized object does not match expected format.");var x=new a.default(A.transaction);x.chunks||await x.prepareChunks(T);let S=new o(b,x);if(S.chunkIndex=A.chunkIndex,S.lastRequestTimeEnd=A.lastRequestTimeEnd,S.lastResponseError=A.lastResponseError,S.lastResponseStatus=A.lastResponseStatus,S.txPosted=A.txPosted,S.data=T,S.transaction.data_root!==A.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return S}static async fromTransactionId(b,A){let T=await b.get(`tx/${A}`);if(T.status!==200)throw new Error(`Tx ${A} not found: ${T.status}`);let x=T.data;return x.data=new Uint8Array(0),{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:x}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=i){this.transaction.data=this.data;let A=await this.api.post("tx",this.transaction).catch(T=>(console.error(T),{status:-1,data:{error:T.message}}));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=A.status,this.transaction.data=new Uint8Array(0),A.status>=200&&A.status<300){this.txPosted=!0,this.chunkIndex=i;return}throw this.lastResponseError=(0,u.getError)(A),new Error(`Unable to upload transaction: ${A.status}, ${this.lastResponseError}`)}let b=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=b.status,!(b.status>=200&&b.status<300))throw this.lastResponseError=(0,u.getError)(b),new Error(`Unable to upload transaction: ${b.status}, ${this.lastResponseError}`);this.txPosted=!0}}return Ft.TransactionUploader=o,Ft}var Me;function xn(){if(Me)return re;
4Me=1,Object.defineProperty(re,"__esModule",{value:!0});let a=ue(),n=be(),u=bt(),l=In();class i{constructor(c,o,w){M(this,"api"),M(this,"crypto"),M(this,"chunks"),this.api=c,this.crypto=o,this.chunks=w}async getTransactionAnchor(){let c=await this.api.get("tx_anchor");if(!c.data.match(/^[a-z0-9_-]{43,}/i)||!c.ok)throw new Error(`Could not getTransactionAnchor. Received: ${c.data}. Status: ${c.status}, ${c.statusText}`);return c.data}async getPrice(c,o){let w=o?`price/${c}/${o}`:`price/${c}`,b=await this.api.get(w);if(!/^\d+$/.test(b.data)||!b.ok)throw new Error(`Could not getPrice. Received: ${b.data}. Status: ${b.status}, ${b.statusText}`);return b.data}async get(c){let o=await this.api.get(`tx/${c}`);if(o.status==200){let w=parseInt(o.data.data_size);if(o.data.format>=2&&w>0&&w<=1024*1024*12){let b=await this.getData(c);return new n.default({...o.data,data:b})}return new n.default({...o.data,format:o.data.format||1})}throw o.status==404?new a.default("TX_NOT_FOUND"):o.status==410?new a.default("TX_FAILED"):new a.default("TX_INVALID")}fromRaw(c){return new n.default(c)}async search(c,o){return this.api.post("arql",{op:"equals",expr1:c,expr2:o}).then(w=>w.data?w.data:[])}getStatus(c){return this.api.get(`tx/${c}/status`).then(o=>o.status==200?{status:200,confirmed:o.data}:{status:o.status,confirmed:null})}async getData(c,o){let w;try{w=await this.chunks.downloadChunkedData(c)}catch(b){console.error(`Error while trying to download chunked data for ${c}`),console.error(b)}if(!w){console.warn(`Falling back to gateway cache for ${c}`);try{let{data:b,ok:A,status:T,statusText:x}=await this.api.get(`/${c}`,{responseType:"arraybuffer"});if(!A)throw new Error("Bad http status code",{cause:{status:T,statusText:x}});w=b}catch(b){console.error(`Error while trying to download contiguous data from gateway cache for ${c}`),console.error(b)}}if(!w)throw new Error(`${c} data was not found!`);return o&&o.decode&&!o.string?w:o&&o.decode&&o.string?u.bufferToString(w):u.bufferTob64Url(w)}async sign(c,o,w){let b=typeof o=="object"&&(T=>{let x=!0;return["n","e","d","p","q","dp","dq","qi"].map(S=>!(S in T)&&(x=!1)),x})(o),A=typeof arweaveWallet=="object";if(!b&&!A)throw new Error("No valid JWK or external wallet found to sign transaction.");if(b){c.setOwner(o.n);let T=await c.getSignatureData(),x=await this.crypto.sign(o,T,w),S=await this.crypto.hash(x);c.setSignature({id:u.bufferTob64Url(S),owner:o.n,signature:u.bufferTob64Url(x)})}else if(A){try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}let T=await arweaveWallet.sign(c,w);c.setSignature({id:T.id,owner:T.owner,reward:T.reward,tags:T.tags,signature:T.signature})}else throw new Error("An error occurred while signing. Check wallet is valid")}async verify(c){let o=await c.getSignatureData(),w=c.get("signature",{decode:!0,string:!1}),b=u.bufferTob64Url(await this.crypto.hash(w));if(c.id!==b)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(c.owner,o,w)}async post(c){if(typeof c=="string"?c=new n.default(JSON.parse(c)):typeof c.readInt32BE=="function"?c=new n.default(JSON.parse(c.toString())):typeof c=="object"&&!(c instanceof n.default)&&(c=new n.default(c)),!(c instanceof n.default))throw new Error("Mu
4st be Transaction object");c.chunks||await c.prepareChunks(c.data);let o=await this.getUploader(c,c.data);try{for(;!o.isComplete;)await o.uploadChunk()}catch(w){if(o.lastResponseStatus>0)return{status:o.lastResponseStatus,statusText:o.lastResponseError,data:{error:o.lastResponseError}};throw w}return{status:200,statusText:"OK",data:{}}}async getUploader(c,o){let w;if(o instanceof ArrayBuffer&&(o=new Uint8Array(o)),c instanceof n.default){if(o||(o=c.data),!(o instanceof Uint8Array))throw new Error("Data format is invalid");c.chunks||await c.prepareChunks(o),w=new l.TransactionUploader(this.api,c),(!w.data||w.data.length===0)&&(w.data=o)}else{if(typeof c=="string"&&(c=await l.TransactionUploader.fromTransactionId(this.api,c)),!o||!(o instanceof Uint8Array))throw new Error("Must provide data when resuming upload");w=await l.TransactionUploader.fromSerialized(this.api,c,o)}return w}async*upload(c,o){let w=await this.getUploader(c,o);for(;!w.isComplete;)await w.uploadChunk(),yield w;return w}}return re.default=i,re}var ne={},We;function Un(){if(We)return ne;We=1,Object.defineProperty(ne,"__esModule",{value:!0});let a=bt();class n{constructor(l,i){M(this,"api"),M(this,"crypto"),this.api=l,this.crypto=i}getBalance(l){return this.api.get(`wallet/${l}/balance`).then(i=>i.data)}getLastTransactionID(l){return this.api.get(`wallet/${l}/last_tx`).then(i=>i.data)}generate(){return this.crypto.generateJWK()}async jwkToAddress(l){return!l||l==="use_wallet"?this.getAddress():this.getAddress(l)}async getAddress(l){if(!l||l==="use_wallet"){try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}else return this.ownerToAddress(l.n)}async ownerToAddress(l){return a.bufferTob64Url(await this.crypto.hash(a.b64UrlToBuffer(l)))}}return ne.default=n,ne}var Rt={},$e;function Dn(){if($e)return Rt;
4$e=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.SiloResource=void 0;let a=bt();class n{constructor(i,d,c){M(this,"api"),M(this,"crypto"),M(this,"transactions"),this.api=i,this.crypto=d,this.transactions=c}async get(i){if(!i)throw new Error("No Silo URI specified");let d=await this.parseUri(i),c=await this.transactions.search("Silo-Name",d.getAccessKey());if(c.length==0)throw new Error(`No data could be found for the Silo URI: ${i}`);let o=await this.transactions.get(c[0]);if(!o)throw new Error(`No data could be found for the Silo URI: ${i}`);let w=o.get("data",{decode:!0,string:!1});return this.crypto.decrypt(w,d.getEncryptionKey())}async readTransactionData(i,d){if(!d)throw new Error("No Silo URI specified");let c=await this.parseUri(d),o=i.get("data",{decode:!0,string:!1});return this.crypto.decrypt(o,c.getEncryptionKey())}async parseUri(i){let d=i.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!d)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");let c=d[1],o=Math.pow(2,parseInt(d[2])),w=await this.hash(a.stringToBuffer(c),o),b=a.bufferTob64(w.slice(0,15)),A=await this.hash(w.slice(16,31),1);return new u(i,b,A)}async hash(i,d){let c=await this.crypto.hash(i);for(let o=0;o<d-1;o++)c=await this.crypto.hash(c);return c}}Rt.default=n;class u{constructor(i,d,c){M(this,"uri"),M(this,"accessKey"),M(this,"encryptionKey"),this.uri=i,this.accessKey=d,this.encryptionKey=c}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}return Rt.SiloResource=u,Rt}var ae={},Fe;function Pn(){if(Fe)return ae;Fe=1,Object.defineProperty(ae,"__esModule",{value:!0});let a=ue(),n=bt();class u{constructor(i){M(this,"api"),this.api=i}async getTransactionOffset(i){let d=await this.api.get(`tx/${i}/offset`);if(d.status===200)return d.data;throw new Error(`Unable to get transaction offset: ${(0,a.getError)(d)}`)}async getChunk(i){let d=await this.api.get(`chunk/${i}`);if(d.status===200)return d.data;throw new Error(`Unable to get chunk: ${(0,a.getError)(d)}`)}async getChunkData(i){let d=await this.getChunk(i);return n.b64UrlToBuffer(d.chunk)}firstChunkOffset(i){return parseInt(i.offset)-parseInt(i.size)+1}async downloadChunkedData(i){let d=await this.getTransactionOffset(i),c=parseInt(d.size),o=parseInt(d.offset)-c+1,w=new Uint8Array(c),b=0;for(;b<c;){this.api.config.logging&&console.log(`[chunk] ${b}/${c}`);let A;try{A=await this.getChunkData(o+b)}catch{console.error(`[chunk] Failed to fetch chunk at offset ${o+b}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(A)w.set(A,b),b+=A.length;else throw new Error(`Couldn't complete data download at ${b}/${c}`)}return w}}return ae.default=u,ae}var ie={},je;function Mn(){if(je)return ie;je=1,Object.defineProperty(ie,"__esModule",{value:!0});let a=ue(),n=class we{constructor(i,d){M(this,"api"),M(this,"network"),this.api=i,this.network=d}async get(i){let d=await this.api.get(`${we.HASH_ENDPOINT}${i}`);if(d.status===200)return d.data;throw d.status===404?new a.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${d}`)}async getByHeight(i){let d=await this.api.get(`${we.HEIGHT_ENDPOINT}${i}`);if(d.status===200)return d.data;throw d.status===404?new a.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${d}`)}async getCurrent(){let{current:i}=await this.network.getInfo();return await this.get(i)}};M(n,"HASH_ENDPOINT","block/hash/"),M(n,"HEIGHT_ENDPOINT","block/height/");let u=n;return ie.default=u,ie}var He;function le(){if(He)return Xt;He=1,Object.defineProperty(Xt,"__esModule",{value:!0});let a=Nn(),n=Ln(),u=kn(),l=Rn(),i=xn(),d=Un(),c=be(),o=bt(),w=Dn(),b=Pn(),A=Mn(),T=class Ht{constructor(_){M(this,"api"),M(this,"wallets"),M(this,"transactions"),M(this,"network"),M(this,"blocks"),M(this,"ar"),M(this,"silo"),M(this,"chunks"),this.api=new n.default(_),this.wallets=new d.default(this.api,Ht.crypto),this.chunks=new b.default(this.api),this.transactions=new i.default(this.api,Ht.crypto,this.chunks),this.silo=new w.default(this.api,this.crypto,this.transactions),this.network=new l.default(this.api),this.blocks=new A.default(this.api,this.network),this.ar=new a.default}get crypto(){return Ht.crypto}get utils(){return Ht.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(_,O){let W={};if(Object.assign(W,_),!_.data&&!(_.target&&_.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(_.owner==null&&O&&O!=="use_wallet"&&(W.owner=O.n),_.last_tx==null&&(W.last_tx=await this.transactions.getTransactionAnchor()),typeof _.data=="str
4ing"&&(_.data=o.stringToBuffer(_.data)),_.data instanceof ArrayBuffer&&(_.data=new Uint8Array(_.data)),_.data&&!(_.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(_.reward==null){let $=_.data?_.data.byteLength:0;W.reward=await this.transactions.getPrice($,W.target)}W.data_root="",W.data_size=_.data?_.data.byteLength.toString():"0",W.data=_.data||new Uint8Array(0);let q=new c.default(W);return await q.getSignatureData(),q}async createSiloTransaction(_,O,W){let q={};if(Object.assign(q,_),!_.data)throw new Error("Silo transactions must have a 'data' value");if(!W)throw new Error("No Silo URI specified.");if(_.target||_.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(_.owner==null){if(!O||!O.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");q.owner=O.n}_.last_tx==null&&(q.last_tx=await this.transactions.getTransactionAnchor());let $=await this.silo.parseUri(W);if(typeof _.data=="string"){let Z=await this.crypto.encrypt(o.stringToBuffer(_.data),$.getEncryptionKey());q.reward=await this.transactions.getPrice(Z.byteLength),q.data=o.bufferTob64Url(Z)}if(_.data instanceof Uint8Array){let Z=await this.crypto.encrypt(_.data,$.getEncryptionKey());q.reward=await this.transactions.getPrice(Z.byteLength),q.data=o.bufferTob64Url(Z)}let Y=new c.default(q);return Y.addTag("Silo-Name",$.getAccessKey()),Y.addTag("Silo-Version","0.1.0"),Y}arql(_){return this.api.post("/arql",_).then(O=>O.data||[])}};M(T,"init"),M(T,"crypto",new u.default),M(T,"utils",o);let x=T;return Xt.default=x,Xt}var Ge;function Wn(){if(Ge)return Jt;Ge=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.default=n;let a=le();async function n(l){if(Array.isArray(l)){let c=a.default.utils.concatBuffers([a.default.utils.stringToBuffer("list"),a.default.utils.stringToBuffer(l.length.toString())]);return await u(l,await a.default.crypto.hash(c,"SHA-384"))}let i=a.default.utils.concatBuffers([a.default.utils.stringToBuffer("blob"),a.default.utils.stringToBuffer(l.byteLength.toString())]),d=a.default.utils.concatBuffers([await a.default.crypto.hash(i,"SHA-384"),await a.default.crypto.hash(l,"SHA-384")]);return await a.default.crypto.hash(d,"SHA-384")}async function u(l,i){if(l.length<1)return i;let d=a.default.utils.concatBuffers([i,await n(l[0])]),c=await a.default.crypto.hash(d,"SHA-384");return await u(l.slice(1),c)}return Jt}var qe;function be(){if(qe)return kt;qe=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.Tag=void 0;let a=bt(),n=Wn(),u=lr();class l{get(o,w){if(!Object.getOwnPropertyNames(this).includes(o))throw new Error(`Field "${o}" is not a property of the Arweave Transaction class.`);if(this[o]instanceof Uint8Array)return w&&w.decode&&w.string?a.bufferToString(this[o]):w&&w.decode&&!w.string?this[o]:a.bufferTob64Url(this[o]);if(this[o]instanceof Array){if((w==null?void 0:w.decode)!==void 0||(w==null?void 0:w.string)!==void 0)throw o==="tags"&&console.warn(`Did you mean to use 'transaction["tags"]' ?`),new Error("Cannot decode or stringify an array.");return this[o]}return w&&w.decode==!0?w&&w.string?a.b64UrlToString(this[o]):a.b64UrlToBuffer(this[o]):this[o]}}class i extends l{constructor(o,w,b=!1){super(),M(this,"name"),M(this,"value"),this.name=o,this.value=w}}kt.Tag=i;class d extends l{constructor(o={}){super(),M(this,"format",2),M(this,"id",""),M(this,"last_tx",""),M(this,"owner",""),M(this,"tags",[]),M(this,"target",""),M(this,"quantity","0"),M(this,"data_size","0"),M(this,"data",new Uint8Array),M(this,"data_root",""),M(this,"reward","0"),M(this,"signature",""),M(this,"chunks"),Object.assign(this,o),typeof this.data=="string"&&(this.data=a.b64UrlToBuffer(this.data)),o.tags&&(this.tags=o.tags.map(w=>new i(w.name,w.value)))}addTag(o,w){this.tags.push(new i(a.stringToB64Url(o),a.stringToB64Url(w)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:a.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(o){this.owner=o}setSignature({id:o,owner:w,reward:b,tags:A,signature:T}){this.id=o,this.owner=w,b&&(this.reward=b),A&&(this.tags=A),this.signature=T}async prepareChunks(o){!this.chunks&&o.byteLength>0&&(this.chunks=await(0,u.generateTransactionChunks)(o),this.data_root=a.bufferTob64Url(this.chunks.data_root)),!this.chunks&&o.byteLength===0&&(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(o,w){if(!this.chunks)throw new Error("Chunks have not been prepared");let b=this.chunks.proofs[o],A=this.chunks.chunks[o];return{data_root:this.data_root,data_size:this.data_size,data_path:a.bufferTob64Url(b.proof),offset:b.offset.toString(),chunk:a.bufferTob64Url(w.slice(A.minByteRange,A.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let o=this.tags.reduce((b,A)=>a.concatBuffers([b,A.get("name",{decode:!0,string:!1}),A.get("value",{decode:!0,string:!1})]),new Uint8Array);return a.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),a.stringToBuffer(this.quantity),a.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),o]);case 2:this.data_root||await this.prepareChunks(this.data);let w=this.tags.map(b=>[b.get("name",{decode:!0,string:!1}),b.get("value",{decode:!0,string:!1})]);return await(0,n.default)([a.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),a.stringToBuffer(this.quantity),a.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),w,a.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}return kt.default=d,kt}var de=5e5,Ke="1.40.5",Bt={},jt={},Ve;function $n(){if(Ve)return jt;
4Ve=1,Object.defineProperty(jt,"__esModule",{value:!0}),jt.getDefaultConfig=void 0;let a=(l,i)=>{let d=/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,c=i.split("."),o=c[c.length-1],w=["localhost","[::1]"];return w.includes(i)||l=="file"||w.includes(o)||!!i.match(d)||!!o.match(d)},n=l=>{let i=l.charAt(0)==="[",d=/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;return!!l.match(d)||i},u=(l,i)=>{if(a(l,i))return{protocol:"https",host:"arweave.net",port:443};if(!n(i)){let d=i.split(".");if(d.length>=3){d.shift();let c=d.join(".");return{protocol:l,host:c}}}return{protocol:l,host:i}};return jt.getDefaultConfig=u,jt}var ze;function Fn(){return ze||(ze=1,function(a){var n=Bt&&Bt.__createBinding||(Object.create?function(d,c,o,w){w===void 0&&(w=o);var b=Object.getOwnPropertyDescriptor(c,o);(!b||("get"in b?!c.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return c[o]}}),Object.defineProperty(d,w,b)}:function(d,c,o,w){w===void 0&&(w=o),d[w]=c[o]}),u=Bt&&Bt.__exportStar||function(d,c){for(var o in d)o!=="default"&&!Object.prototype.hasOwnProperty.call(c,o)&&n(c,d,o)};Object.defineProperty(a,"__esModule",{value:!0});let l=le(),i=$n();l.default.init=function(d={}){let c={host:"arweave.net",port:443,protocol:"https"};if(typeof location!="object"||!location.protocol||!location.hostname)return new l.default({...d,...c});let o=location.protocol.replace(":",""),w=location.hostname,b=location.port?parseInt(location.port):o=="https"?443:80,A=(0,i.getDefaultConfig)(o,w),T=d.protocol||A.protocol,x=d.host||A.host,S=d.port||A.port||b;return new l.default({...d,host:x,protocol:T,port:S})},typeof globalThis=="object"?globalThis.Arweave=l.default:typeof self=="object"&&(self.Arweave=l.default),u(le(),a),a.default=l.default}(Bt)),Bt}var jn=Fn(),ve=Sn(jn),Hn=new ve(Gr);function ur(a){let n=Vt(),u=a.tags.map((i,d)=>({collectionID:n,type:"tag",index:d,value:i})),l=[];if(typeof a.data=="string")try{a.data=Hn.utils.b64UrlToBuffer(a.data)}catch{}for(let i=0;i<Math.ceil(a.data.length/de);i++){let d=i*de,c=a.data.slice(d,d+de);l.push({collectionID:n,type:"data",index:i+u.length,value:Array.from(c)})}return{transaction:{...a,data:void 0,tags:void 0},tagChunks:u,dataChunks:l,chunkCollectionID:n}}var Gn=async(a,n)=>{let{transaction:u,dataChunks:l,tagChunks:i,chunkCollectionID:d}=ur(a);try{await xt({collectionID:d,type:"start",index:-1})}catch(c){throw new Error(`Failed to initiate transaction chunk stream: 
5${c}`)}for(let c of l)try{await xt(c)}catch(o){throw new Error(`Error while sending a data chunk of collection "${d}": 
6${o}`)}for(let c of i)try{await xt(c)}catch(o){throw new Error(`Error while sending a tag chunk for tx from chunk collection "${d}": 
7${o}`)}return[u,n,d]},qn=(a,n,[u])=>{if(!a)throw new Error("No transaction returned");let l=new ve({host:"arweave.net",port:443,protocol:"https"}).transactions.fromRaw({...a.transaction,tags:[...u.tags||[],...a.transaction.tags||[]],data:u.data});if(a.arConfetti)for(let i=0;i<8;i++)setTimeout(()=>tr(a.arConfetti),i*150);return l},Kn=["DISPATCH"],Vn={functionName:"dispatch",permissions:Kn},zn=async(a,n)=>{let{transaction:u,dataChunks:l,tagChunks:i,chunkCollectionID:d}=ur(a);try{await xt({collectionID:d,type:"start",index:-1})}catch(c){throw new Error(`Failed to initiate dispatch chunk stream: 
8${c}`)}for(let c of l)try{await xt(c)}catch(o){throw new Error(`Error while sending a data (dispatch) chunk of collection "${d}": 
9${o}`)}for(let c of i)try{await xt(c)}catch(o){throw new Error(`Error while sending a tag chunk for tx from chunk collection "${d}": 
10${o}`)}return[u,d,n]},Yn=a=>{if(a.arConfetti)for(let n=0;n<8;n++)setTimeout(()=>tr(a.arConfetti),n*150);return a.res},Jn=["ENCRYPT"],Xn={functionName:"encrypt",permissions:Jn},Zn=(a,n)=>(n.algorithm&&console.warn(`[Wander] YOU'RE USING DEPRECATED PARAMS FOR "encrypt()". Please check the documentation.
11https://github.com/wanderwallet/Wander#encryptdata-options-promiseuint8array`),[typeof a=="string"?a:new Uint8Array(a),n]),Qn=a=>new Uint8Array(Object.values(a)),ta=["DECRYPT"],ea={functionName:"decrypt",permissions:ta},ra=(a,n)=>(n.algorithm&&console.warn(`[Wander] YOU'RE USING DEPRECATED PARAMS FOR "decrypt()". Please check the documentation.
12https://github.com/wanderwallet/Wander#decryptdata-options-promisestring`),[new Uint8Array(a),n]),na=a=>new Uint8Array(Object.values(a)),aa=["SIGNATURE"],ia={functionName:"signature",permissions:aa},oa=(a,n)=>(console.warn(`Warning: The signature API is deprecated and it will be removed.
13Visit https://docs.wander.app/api/signature for alternatives.`),[Object.values(a),n]),sa=a=>new Uint8Array(a),la=["SIGNATURE"],ua={functionName:"signMessage",permissions:la},Ye={},Je;function fa(){return Je||(Je=1,function(a){Object.defineProperty(a,"__esModule",{value:!0}),a.check=a.isPromise=a.isInstanceOf=a.isOneOfType=a.isOneOf=a.isOptionOfType=a.isArrayOfType=a.isRecordOfType=a.isArray=a.isRecordWithKeys=a.isRecord=a.isDate=a.isString=a.isNumber=a.isBoolean=a.isExactly=a.isNotVoid=a.isNotUndefined=a.isNotNull=a.isNever=a.isUnknown=a.safeJsonParse=a.setBaseAssert=a.assert=a.defaultAssert=void 0;let n=R=>`expected to be ${R}`,u=(R,D)=>
13{if(!R)throw new TypeError(D)};a.defaultAssert=u;let l=a.defaultAssert,i=(R,D)=>l(R,D);a.assert=i;function d(R){R&&(l=R)}a.setBaseAssert=d;let c=R=>JSON.parse(R);a.safeJsonParse=c;function o(R){return!0}a.isUnknown=o;function w(R,D=n("unreachable")){throw new TypeError(D)}a.isNever=w;function b(R,D=n("not null")){(0,a.assert)(R!==null,D)}a.isNotNull=b;function A(R,D=n("not undefined")){(0,a.assert)(R!==void 0,D)}a.isNotUndefined=A;function T(R,D=n("neither null nor undefined")){(0,a.assert)(R!=null,D)}a.isNotVoid=T;function x(R,D,V=n(`exactly ${D}`)){(0,a.assert)(R===D,V)}a.isExactly=x;function S(R,D=n("a boolean")){(0,a.assert)(typeof R=="boolean",D)}a.isBoolean=S;function _(R,D=n("a number")){(0,a.assert)(typeof R=="number",D)}a.isNumber=_;function O(R,D=n("a string")){(0,a.assert)(typeof R=="string",D)}a.isString=O;function W(R,D=n("a Date")){(0,a.assert)(R instanceof Date,D)}a.isDate=W;function q(R,D=n("a record")){(0,a.assert)(typeof R=="object",D),b(R,D);for(let V of Object.keys(R))O(V,D)}a.isRecord=q;function $(R,D,V=n(`a record with keys ${D.join(", ")}`)){q(R,V);for(let X of D)A(R[X])}a.isRecordWithKeys=$;function Y(R,D=n("an array")){(0,a.assert)(Array.isArray(R),D)}a.isArray=Y;function Z(R,D,V=n("a record of given type"),X=n("of given type")){q(R,V);for(let nt of Object.values(R))D(nt,X)}a.isRecordOfType=Z;function L(R,D,V=n("an array of given type"),X=n("of given type")){Y(R,V);for(let nt of R)D(nt,X)}a.isArrayOfType=L;function N(R,D,V=n("option of given type")){R!==void 0&&D(R,V)}a.isOptionOfType=N;function k(R,D,V=n(`one of ${D.join(", ")}`)){(0,a.assert)(D.includes(R),V)}a.isOneOf=k;function P(R,D,V=n("one of type"),X){for(let nt of D)try{nt(R,X);return}catch{}throw new TypeError(V)}a.isOneOfType=P;function H(R,D,V=n("an instance of given constructor")){(0,a.assert)(R instanceof D,V)}a.isInstanceOf=H;function B(R,D=n("a promise")){H(R,Promise,D)}a.isPromise=B;function z(R){return D=>{try{return R(D),!0}catch{return!1}}}a.check=z}(Ye)),Ye}var Xe=fa();function Ut(a){Xe.isNotUndefined("Data has to be defined."),Xe.assert(ArrayBuffer.isView(a),"Input is not an ArrayBuffer.")}var ca=(a,n)=>(Ut(a),[Object.values(a),n]),ha=a=>new Uint8Array(a),da=["ACCESS_ADDRESS"],pa={functionName:"subscription",permissions:da},ga=a=>{let n=["arweaveAccountAddress","applicationName","subscriptionName","subscriptionFeeAmount","recurringPaymentFrequency","subscriptionManagementUrl","subscriptionEndDate"];for(let l of n)if(a[l]===void 0)throw new Error(`Missing required field: ${l}`);let u=[...n,"applicationIcon"];return Object.keys(a).forEach(l=>{if(!u.includes(l))throw new Error(`Unexpected extra field: ${l}`)}),[{...a,applicationIcon:a.applicationIcon}]},ya=["SIGNATURE"],wa={functionName:"privateHash",permissions:ya},ma=(a,n)=>(Ut(a),[Object.values(a),n]),ba=a=>new Uint8Array(a),va=["SIGNATURE"],Ea={functionName:"verifyMessage",permissions:va},Aa=(a,n,u,l)=>(Ut(a),typeof n=="string"&&(n=ve.utils.b64UrlToBuffer(n)),Ut(n),[Object.values(a),Object.values(n),u,l]),Ta=["SIGN_TRANSACTION"],Sa={functionName:"batchSignDataItem",permissions:Ta},Ca=200*1024,_a=async(a,n)=>{if(!Array.isArray(a))throw new Error("Input must be an array of data items");if(a.reduce((u,l)=>{let i=typeof l.data=="string"?new TextEncoder().encode(l.data).length:l.data.length;return u+i},0)>Ca)throw new Error("Total size of data items exceeds 200 KB");return[a.map(u=>{let l;return typeof u.data!="string"?(Ut(u.data),l={...u,data:Array.from(u.data)}):l={...u,data:Array.from(new TextEncoder().encode(u.data))},l}),n]},Na=a=>a.map(n=>new Uint8Array(n).buffer),La=["SIGN_TRANSACTION"],ka={functionName:"signDataItem",permissions:La},Ra=async(a,n)=>{let u;return typeof a.data!="string"?(Ut(a.data),u={...a,data:Array.from(a.data)}):u={...a,data:Array.from(new TextEncoder().encode(a.data))},[u,n]},Ba=a=>new Uint8Array(a).buffer,Oa=["ACCESS_TOKENS"],Ia={functionName:"userTokens",permissions:Oa},xa=()=>{},Ua=["ACCESS_TOKENS"],Da={functionName:"tokenBalance",permissions:Ua},Pa=a=>[a],Ma=["ACCESS_ADDRESS"],Wa={functionName:"getWanderTierInfo",permissions:Ma},$a=()=>{},Fa=[{...pr,function:gr},{...wr,function:mr},{...vr,function:Er},{...Tr,function:Sr},{..._r,function:Nr},{...kr,function:Rr},{...Or,function:Ir,finalizer:xr},{...jr,function:en},{...nn,function:Gn,finalizer:qn},{...Vn,function:zn,finalizer:Yn},{...Xn,function:Zn,finalizer:Qn},{...ea,function:ra,finalizer:na},{...ia,function:oa,finalizer:sa},{...Dr,function:Pr},{...Wr,function:$r},{...ua,function:ca,finalizer:ha},{...wa,function:ma,finalizer:ba},{...Ea,function:Aa}
13,{...ka,function:Ra,finalizer:Ba},{...pa,function:ga},{...Ia,function:xa},{...Da,function:Pa},{...Sa,function:_a,finalizer:Na},{...Wa,function:$a}];function ja(a){return{all:a=a||new Map,on:function(n,u){var l=a.get(n);l?l.push(u):a.set(n,[u])},off:function(n,u){var l=a.get(n);l&&(u?l.splice(l.indexOf(u)>>>0,1):a.set(n,[]))},emit:function(n,u){var l=a.get(n);l&&l.slice().map(function(i){i(u)}),(l=a.get("*"))&&l.slice().map(function(i){i(n,u)})}}}function Ha(a=window){if(Gt(It.SETUP,"injectWanderConnectWalletAPI()"),!(a instanceof HTMLIFrameElement))throw new Error("Target for Wander Embedded must be an IFRAME element.");vn(a);let n=ja(),u={walletName:"Wander Connect",walletVersion:Ke,events:n};for(let i of Fa)u[i.functionName]=(...d)=>l(i,d);async function l(i,d){return new Promise(async(c,o)=>{let w=typeof i=="string"?i:i.functionName,b=typeof i=="string"?d:await i.function(...d),A=Vt(),T={app:"wanderEmbedded",version:Ke,callID:A,type:`api_${w}`,data:{params:b}};Gt(It.API,`${T.type} (${T.callID})...`);let x=await qt({destination:"background",messageId:T.type==="chunk"?"chunk":"api_call",data:T});if(Gt(It.API,`${T.type} (${T.callID}) =`,x),er(x))return o(x.data);let S=typeof i=="string"?null:i.finalizer;if(S)try{let _=await S(x.data,b,d);_&&(x.data=_)}catch(_){o(_);return}c(x.data)})}window.arweaveWallet=u}var Ga=({wanderLogo:a,i18n:n,showLabel:u,showBalance:l,customStyles:i,cssVariableKeys:d=[]})=>`
14<style>
15
16  @media (prefers-color-scheme: light) {
17    :host {
18      ${d.map(c=>`--${c}: var(--${c}Light);`).join(`
19`)}
20    }
21  }
22
23  @media (prefers-color-scheme: dark) {
24    :host {
25      ${d.map(c=>`--${c}: var(--${c}Dark);`).join(`
26`)}
27    }
28  }
29
30  .button {
31    position: relative;
32    display: flex;
33    align-items: center;
34    gap: var(--gapInside);
35    outline: none;
36    user-select: none;
37    cursor: pointer;
38    min-width: var(--minWidth);
39    min-height: var(--minHeight);
40    z-index: 0;
41    padding: var(--padding);
42    font: var(--font);
43    color: var(--color);
44    background: transparent;
45    border: none;
46    border-radius: var(--borderRadius);
47  }
48
49  .button::before {
50    content: "";
51    position: absolute;
52    inset: 0;
53    background: var(--background);
54    border: var(--borderWidth) solid var(--borderColor);
55    border-radius: var(--borderRadius);
56    box-shadow: var(--boxShadow);
57    z-index: -1;
58    transition: transform linear 50ms;
59  }
60
61  .button::after {
62    content: "";
63    position: absolute;
64    right: calc(4px + var(--borderWidth));
65    bottom: calc(4px + var(--borderWidth));
66    border-radius: 32px;
67    height: 22px;
68    width: 22px;
69    transform: translate(50%, 50%) scale(1);
70  }
71
72  .button:hover .wanderLogo {
73    animation: sail 3s infinite;
74  }
75
76  .button:active::before {
77    transform: scale(0.95);
78  }
79
80  .wanderLogo {
81    width: 32px;
82    aspect-ratio: 1;
83    transition: transform linear 50ms;
84  }
85
86  .label {
87  }
88
89  .label[hidden],
90  .label:empty:not(.isLoading) {
91    display: none;
92  }
93
94  .label.isLoading {
95    background: currentColor;
96    width: 64px;
97    height: 12px;
98    border-radius: 6px;
99    animation: blink-opacity 3s infinite;
100  }
101
102  .balance {
103    filter: blur(0px);
104    transition: filter linear 300ms;
105    display: none;
106  }
107
108  .label:empty:not(.isLoading) + .balance:not([hidden]) {
109    display: block;
110  }
111
112  .balance:empty {
113    background: currentColor;
114    width: 64px;
115    height: 12px;
116    border-radius: 6px;
117    animation: blink-opacity 3s infinite;
118  }
119
120  .balance.isHidden {
121    filter: blur(6px);
122  }
123
124  .indicator,
125  .notifications {
126    position: absolute;
127    right: calc(4px + var(--borderWidth));
128    bottom: calc(4px + var(--borderWidth));
129    border-radius: 32px;
130    transition: transform linear 150ms, background linear 150ms;
131    pointer-events: none;
132  }
133
134  .indicator {
135    width: 8px;
136    height: 8px;
137    z-index: 8;
138    background: #CCC;
139    transform: translate(50%, 50%);
140  }
141
142  .indicator.isLoading {
143    animation: blink-indicator 3s infinite;
144  }
145
146  .notifications {
147    background: red;
148    color: white;
149    font-size: 12px;
150    font-weight: bold;
151    min-height: 22px;
152    min-width: 22px;
153    text-align: center;
154    display: flex;
155    align-items: center;
156    justify-content: center;
157    z-index: 10;
158    transform: translate(50%, 50%) scale(1);
159  }
160
161  .isConnected + .indicator {
162    /* TODO: Add CSS var */
163    background: #56C980;
164  }
165
166  .notifications:empty {
167    transform: translate(50%, 50%) scale(0);
168  }
169
170  @keyframes sail {
171    0% {
172      transform: rotate(-10deg) translate(0, 1px);
173    }
174    50% {
175      transform: rotate(10deg) translate(0, -1px);
176    }
177    100% {
178      transform: rotate(-10deg) translate(0, 1px);
179    }
180  }
181
182  @keyframes blink-opacity {
183    0%, 100% {
184      opacity: 0.5;
185    }
186    50% {
187      opacity: 0.25;
188    }
189  }
190
191  @keyframes blink-indicator {
192    0%, 100% {
193      background: #CCC;
194    }
195    50% {
196      background: #56C980;
197    }
198  }
199
200  ${i}
201</style>
202
203<button class="button">
204
205  <svg
206    class="wanderLogo"
207    ${a==="none"?"hidden":""}
208    viewBox="0 0 257 121"
209    fill="none"
210    xmlns="http://www.w3.org/2000/svg">
211
212    <path d="M177.235 60.5134L131.532 2.56198C129.607 0.0634354 127.719 -0.344614 125.651 2.33897L79.8771 60.4191L124.181 100.462L128.483 8.72145L132.785 100.462L177.235 60.5134Z"
213      fill="${a==="text-color"?"currentColor":"url(#gradient1)"}"
214      fill-rule="evenodd"
215      clip-rule="evenodd" />
216    <path d="M209.689 120.406L256.138 21.2852C257.135 19.114 254.755 16.9443 252.685 18.1364L183.231 58.0562L138.086 108.914L209.689 120.406Z"
217      fill="${a==="text-color"?"currentColor":"url(#gradient2)"}" />
218    <path d="M47.211 120.406L0.762138 21.2853C-0.234245 19.1141 2.14523 16.9445 4.21552 18.1365L73.6694 58.0564L118.814 108.914L47.211 120.406Z"
219      fill="${a==="text-color"?"currentColor":"url(#gradient3)"}" />
220
221    <defs>
222      <linearGradient
223        id="gradient1"
224        x1="128.213"
225        y1="100.462"
226        x2="128.213"
227        y2="0.5"
228        gradientUnits="userSpaceOnUse">
229        <stop stop-color="#6B57F9"/>
230        <stop offset="1" stop-color="#9787FF"/>
231      </linearGradient>
232
233      <linearGradient
234        id="gradient2"
235        x1="156.561"
236        y1="80.0762"
237        x2="218.926"
238        y2="115.502"
239        gradientUnits="userSpaceOnUse">
240        <stop stop-color="#6B57F9"/>
241        <stop offset="1" stop-color="#9787FF"/>
242      </linearGradient>
243
244      <linearGradient
245        id="gradient3"
246        x1="100.34"
247        y1="80.0764"
248        x2="37.9744"
249        y2="115.502"
250        gradientUnits="userSpaceOnUse">
251        <stop stop-color="#6B57F9"/>
252        <stop offset="1" stop-color="#9787FF"/>
253      </linearGradient>
254    </defs>
255  </svg>
256
257  <span class="label" ${u?"":"hidden"}></span>
258  <span class="balance" ${l?"":"hidden"} title="${n.loadingBalance}"></span>
259</button>
260
261<span class="indicator"></span>
262<span class="notifications"></span>
263`;function fr(a){return!!(a&&typeof a=="object"&&("light"in a||"dark"in a))}function vt(a,n,u=""){for(let l in n){let i=`--${l}${u}`,d=n[l];typeof d=="string"?a.style.setProperty(i,d):typeof d=="number"&&a.style.setProperty(i,`${d}px`)}}function Kt(a,n,u){!n||Object.keys(n).length===0||(fr(n)?u==="system"?(vt(a,n.light,"Light"),vt(a,n.dark,"Dark")):u==="dark"?(vt(a,n.dark,"Light"),vt(a,n.dark,"Dark")):(vt(a,n.light,"Light"),vt(a,n.light,"Dark")):(vt(a,n,"Light"),vt(a,n,"Dark")))}function cr(a,n,u,l){let i=u,d=l;return a&&Object.keys(a).length>0&&(fr(a)?(i=ht(i,(a==null?void 0:a.light)||{}),d=ht(l,(a==null?void 0:a.dark)||{})):n==="dark"?d=ht(l,a||{}):i=ht(i,a||{})),{light:i,dark:d}}var Ot=["system","light","dark"],Tt=class st{constructor(n={}){var i,d;this.variant=null,this.status={};let u=cr(n.cssVars,n.theme,st.DEFAULT_LIGHT_CSS_VARS,st.DEFAULT_DARK_CSS_VARS);this.config={parent:n.parent||st.DEFAULT_CONFIG.parent,id:n.id||st.DEFAULT_CONFIG.id,theme:n.theme||st.DEFAULT_CONFIG.theme,cssVars:u,customStyles:n.customStyles||st.DEFAULT_CONFIG.customStyles,position:n.position||(n.parent?"static":st.DEFAULT_CONFIG.position),wanderLogo:n.wanderLogo||st.DEFAULT_CONFIG.wanderLogo,label:n.label??st.DEFAULT_CONFIG.label,balance:n.balance===!1?!1:{balanceOf:(n.balance===!0?null:(i=n.balance)==null?void 0:i.balanceOf)??st.DEFAULT_CONFIG.balance.balanceOf,currency:(n.balance===!0?null:(d=n.balance)==null?void 0:d.currency)??st.DEFAULT_CONFIG.balance.currency},notifications:n.notifications||st.DEFAULT_CONFIG.notifications,i18n:n.i18n||st.DEFAULT_CONFIG.i18n};let l=st.initializeButton(this.config);this.parent=this.config.parent,this.host=l.host,this.button=l.button,this.wanderLogo=l.wanderLogo,this.label=l.label,this.balance=l.balance,this.indicator=l.indicator,this.notifications=l.notifications}static initializeButton(n){let u=document.createElement("div");u.id=n.id;let l=u.attachShadow({mode:"open"}),i=document.createElement("template");i.innerHTML=Ga({wanderLogo:n.wanderLogo,i18n:n.i18n,showLabel:n.label,showBalance:!!n.balance,customStyles:n.customStyles,cssVariableKeys:Object.keys(st.DEFAULT_LIGHT_CSS_VARS)}),Kt(u,n.cssVars,n.theme),l.appendChild(i.content);let d=l.querySelector(".button"),c=l.querySelector(".wanderLogo"),o=l.querySelector(".label"),w=l.querySelector(".balance"),b=l.querySelector(".indicator"),A=l.querySelector(".notifications");
263if(!d||!c||!o||!w||!b||!A)throw new Error("Missing elements");if(n.position==="static")u.style.position="relative";else{let[T,x]=n.position.split("-");u.style.position="fixed",u.style.zIndex="var(--zIndex)",u.style[T]="var(--gapY)",u.style[x]="var(--gapX)"}return u.style.transition="opacity linear 150ms",u.style.opacity="0",setTimeout(()=>{u.style.opacity="1"}),o.textContent=n.i18n.signIn,n.balance===!1&&w.setAttribute("hidden","true"),{host:u,button:d,wanderLogo:c,label:o,balance:w,indicator:b,notifications:A}}getElements(){return{parent:this.parent,host:this.host,button:this.button,wanderLogo:this.wanderLogo,label:this.label,balance:this.balance,indicator:this.indicator,notifications:this.notifications}}setBalance(n){this.balance.getAttribute("hidden")||(this.balance.textContent=n.formattedBalance,this.balance.removeAttribute("title"),n.amount===null?this.balance.classList.add("isHidden"):this.balance.classList.remove("isHidden"))}setNotifications(n){let{notifications:u,i18n:l}=this.config;u!=="off"&&(n?typeof n=="string"?(this.notifications.textContent="!",this.button.title=l[n],this.label.textContent=""):(this.notifications.textContent=u==="counter"?`${n}`:"!",this.button.removeAttribute("title"),this.label.textContent=l.reviewRequests):(this.notifications.textContent="",this.button.removeAttribute("title"),this.label.textContent=""))}setVariant(n){this.variant=n,this.button.dataset.variant=n,n==="loading"?(this.indicator.classList.add("isLoading"),this.label.classList.add("isLoading"),this.label.textContent="",this.label.title=this.config.i18n.loading):(this.indicator.classList.remove("isLoading"),this.label.classList.remove("isLoading"),n==="onboarding"?(this.label.textContent="Wander",this.label.title=this.config.i18n.completeSignUp):n==="authenticated"?(this.label.textContent="",this.label.removeAttribute("title")):(this.label.textContent=this.config.i18n.signIn,this.label.removeAttribute("title"),this.balance.textContent=""))}setStatus(n){this.status[n]=!0,this.button.classList.add(n)}unsetStatus(n){this.status[n]=!1,this.button.classList.remove(n)}setTheme(n){Kt(this.host,this.config.cssVars,n)}destroy(){var n;(n=this.host)==null||n.remove()}};Tt.DEFAULT_LIGHT_CSS_VARS={gapX:16,gapY:16,gapInside:12,minWidth:0,minHeight:0,zIndex:"9999",padding:"12px 20px 12px 16px",font:"16px monospace",background:"white",color:"black",borderWidth:2,borderColor:"white",borderRadius:128,boxShadow:"0 0 32px 0px rgba(0, 0, 0, 0.25)",logoBackground:"",logoBorderWidth:"",logoBorderColor:"",logoBorderRadius:"",notificationsBackground:"",notificationsBorderWidth:"",notificationsBorderColor:"",notificationsBorderRadius:"",notificationsBoxShadow:"",notificationsPadding:""},Tt.DEFAULT_DARK_CSS_VARS={...Tt.DEFAULT_LIGHT_CSS_VARS,background:"black",color:"white",borderColor:"black",logoBackground:"",logoBorderWidth:"",logoBorderColor:"",logoBorderRadius:"",notificationsBackground:"",notificationsBorderWidth:"",notificationsBorderColor:"",notificationsBorderRadius:"",notificationsBoxShadow:"",notificationsPadding:""},Tt.DEFAULT_CONFIG={id:"wanderConnectButtonHost",theme:"system",cssVars:{light:Tt.DEFAULT_LIGHT_CSS_VARS,dark:Tt.DEFAULT_DARK_CSS_VARS},customStyles:"",parent:typeof document<"u"?document.body:null,position:"bottom-right",wanderLogo:"default",label:!0,balance:{balanceOf:"total",currency:"auto"},notifications:"counter",i18n:{loading:"Loading",loadingBalance:"Loading balance",completeSignUp:"Complete sign up",signIn:"Sign in",reviewRequests:"Review requests",backupNeeded:"Backup needed",unexpectedError:"Unexpected error"}};var qa=Tt,Ka=({customStyles:a,cssVariableKeys:n=[]})=>`
264  <style>
265
266    @media (prefers-color-scheme: light) {
267      :host {
268        ${n.map(u=>`--${u}: var(--${u}Light);`).join(`
269`)}
270      }
271    }
272
273    @media (prefers-color-scheme: dark) {
274      :host {
275        ${n.map(u=>`--${u}: var(--${u}Dark);`).join(`
276`)}
277      }
278    }
279
280    /* Base backdrop styles */
281
282    .backdrop {
283      position: fixed;
284      z-index: calc(var(--zIndex) + 1);
285      inset: 0;
286      background: var(--backdropBackground);
287      backdrop-filter: var(--backdropBackdropFilter);
288      padding: var(--backdropPadding);
289      transition:
290        display linear 150ms allow-discrete,
291        background linear 230ms,
292        opacity linear 150ms;
293      display: none;
294      opacity: 0;
295    }
296
297    .backdrop.show {
298      display: block;
299      opacity: 1;
300
301      @starting-style {
302        opacity: 0;
303      }
304    }
305
306    /* Iframe wrapper styles */
307
308    .iframe-wrapper {
309      position: fixed;
310      z-index: calc(var(--zIndex, 9999) + 3);
311      background: var(--background);
312      border: var(--borderWidth) solid var(--borderColor);
313      border-radius: var(--borderRadius);
314      box-shadow: var(--boxShadow);
315      width: calc(var(--preferredWidth) + 2 * var(--borderWidth));
316      height: min(calc(var(--preferredHeight) + 2 * var(--borderWidth)), 800px);
317      min-width: calc(400px + 2 * var(--borderWidth));
318      min-height: calc(400px + 2 * var(--borderWidth));
319      max-width: calc(100dvw - 2 * var(--backdropPadding));
320      max-height: calc(100dvh - 2 * var(--backdropPadding));
321      box-sizing: border-box;
322      overflow: hidden;
323      transition:
324        display linear 150ms allow-discrete,
325        background linear 230ms,
326        border linear 230ms,
327        opacity linear 150ms;
328      display: none;
329      opacity: 0;
330    }
331
332    .iframe-wrapper.show {
333      display: block;
334      opacity: 1;
335
336      @starting-style {
337        opacity: 0;
338      }
339    }
340
341    /* Base iframe styles */
342    .iframe {
343      position: absolute;
344      display: block;
345      border: none;
346      width: 100%;
347      height: 100%;
348    }
349
350    /* Half layout image styles */
351
352    .half-image {
353      position: fixed;
354      width: calc(50vw - 2 * var(--backdropPadding, 0px));
355      z-index: calc(var(--zIndex) + 2);
356      opacity: 0;
357      transition: opacity 300ms ease-in-out;
358      pointer-events: none;
359      top: 50%;
360      transform: translateY(-50%);
361      display: none;
362
363    }
364
365    .half-image.show {
366      opacity: 1;
367    }
368
369    /* Position-specific styles for half-image */
370
371    .half-image[data-position="left"] {
372      left: 0;
373    }
374
375    .half-image[data-position="right"] {
376      right: 0;
377    }
378
379    /* Mobile styles */
380
381    @media (max-width: 540px) {
382      .backdrop {
383        padding: var(--mobilePadding, 0);
384      }
385
386      .iframe-wrapper {
387        inset: var(--mobilePadding, 0);
388        width: calc(100dvw - 2 * var(--mobilePadding, 0));
389        height: var(--mobileHeight, 100dvh);
390        min-width: calc(100dvw - 2 * var(--mobilePadding, 0));
391        min-height: var(--mobileHeight, 100dvh);
392        max-width: calc(100dvw - 2 * var(--mobilePadding, 0));
393        max-height: var(--mobileHeight, 100dvh);
394        border-width: var(--mobileBorderWidth, 0);
395        border-color: var(--mobileBorderColor, rgba(0, 0, 0, .125));
396        border-radius: var(--mobileBorderRadius, 0);
397        box-shadow: var(--mobileBoxShadow, none);
398        transform: none;
399      }
400
401      .half-image {
402        display: none;
403      }
404
405      .iframe-wrapper[data-expand-on-mobile="true"] {
406        inset: 0;
407        width: 100dvw;
408        height: 100dvh;
409        min-width: 100dvw;
410        min-height: 100dvh;
411        max-width: 100dvw;
412        max-height: 100dvh;
413        border: none;
414        border-radius: 0;
415        box-shadow: none;
416      }
417    }
418
419    /* Popup specific styles */
420
421    .iframe-wrapper[data-layout="popup"] {
422      transition:
423        display linear 150ms allow-discrete,
424        opacity linear 150ms,
425        height ease-in-out 150ms;
426    }
427
428    .iframe-wrapper[data-layout="popup"][data-position="top-left"] {
429      top: var(--backdropPadding);
430      left: var(--backdropPadding);
431    }
432
433    .iframe-wrapper[data-layout="popup"][data-position="top-right"] {
434      top: var(--backdropPadding);
435      right: var(--backdropPadding);
436    }
437
438    .iframe-wrapper[data-layout="popup"][data-position="bottom-left"] {
439      bottom: var(--backdropPadding);
440      left: var(--backdropPadding);
441    }
442
443    .iframe-wrapper[data-layout="popup"][data-position="bottom-right"] {
444      bottom: var(--backdropPadding);
445      right: var(--backdropPadding);
446    }
447
448    /* Modal specific styles */
449
450    .iframe-wrapper[data-layout="modal"] {
451      top: 50%;
452      left: 50%;
453      transform: translate(-50%, -50%);
454      transition:
455        display linear 150ms allow-discrete,
456        background linear 230ms,
457        border linear 230ms,
458        opacity linear 150ms,
459        height ease-in-out 150ms;
460    }
461
462    /* Sidebar specific styles */
463
464    .iframe-wrapper[data-layout="sidebar"] {
465      opacity: 1;
466      transition:
467        display linear 150ms allow-discrete,
468        background linear 230ms,
469        border linear 230ms,
470        transform linear 150ms;
471    }
472
473    /* Half specific styles */
474
475    .iframe-wrapper[data-layout="half"] {
476      transition:
477        display linear 150ms allow-discrete,
478        background linear 230ms,
479        border linear 230ms,
480        opacity linear 150ms;
481    }
482
483    /* Right position - Sidebar & Half */
484
485    .iframe-wrapper[data-layout="sidebar"][data-position="right"],
486    .iframe-wrapper[data-layout="half"][data-position="right"] {
487      top: var(--backdropPadding, 0);
488      right: var(--backdropPadding, 0);
489      border-width: 0;
490    }
491
492    /* Left position - Sidebar & Half */
493
494    .iframe-wrapper[data-layout="sidebar"][data-position="left"],
495    .iframe-wrapper[data-layout="half"][data-position="left"] {
496      top: var(--backdropPadding, 0);
497      left: var(--backdropPadding, 0);
498      border-width: 0;
499    }
500
501    /* Hide transform states - Sidebar */
502
503    .iframe-wrapper[data-layout="sidebar"][data-position="right"]:not(.show) {
504      transform: translate(calc(100% + var(--backdropPadding) + 32px), 0);
505    }
506
507    .iframe-wrapper[data-layout="sidebar"][data-position="left"]:not(.show) {
508      transform: translate(calc(-100% - var(--backdropPadding) - 32px), 0);
509    }
510
511    /* Show transform state - Sidebar */
512
513    .iframe-wrapper[data-layout="sidebar"].show {
514      transform: translate(0, 0);
515    }
516
517    /* Expanded styles */
518
519    .iframe-wrapper[data-layout="sidebar"][data-expanded="true"],
520    .iframe-wrapper[data-layout="half"][data-expanded="true"] {
521      top: 0;
522      height: var(--preferredHeight);
523      max-height: var(--preferredHeight);
524      border-radius: 0;
525    }
526
527    .iframe-wrapper[data-layout="sidebar"][data-expanded="true"][data-position="right"],
528    .iframe-wrapper[data-layout="half"][data-expanded="true"][data-position="right"] {
529      right: 0;
530      border-width: 0 0 0 var(--borderWidth);
531    }
532
533    .iframe-wrapper[data-layout="sidebar"][data-expanded="true"][data-position="left"],
534    .iframe-wrapper[data-layout="half"][data-expanded="true"][data-position="left"] {
535      left: 0;
536      border-width: 0 var(--borderWidth) 0 0;
537    }
538
539    ${a}
540  </style>
541`,Va=["modal","popup","sidebar","half"];function za(a){return!!(a&&typeof a=="object"&&"type"in a&&Va.includes(a.type))}var it=class rt{constructor(n,u={}){this.imageBaseUrl=null,this.currentLayoutType=null,this.isOpen=!1,this.layoutCssVars={};let l=cr(u.cssVars,u.theme,rt.DEFAULT_LIGHT_CSS_VARS,rt.DEFAULT_DARK_CSS_VARS),i=u.routeLayout,d=null;if(typeof i=="string"||za(i)){let o=rt.getLayoutConfig(i);d={default:o,auth:rt.DEFAULT_CONFIG.routeLayout.auth,account:rt.DEFAULT_CONFIG.routeLayout.auth,settings:o,"auth-request":o}}else{let o=i!=null&&i.default?rt.getLayoutConfig(i==null?void 0:i.default):rt.DEFAULT_CONFIG.routeLayout.default,w=i!=null&&i.auth?rt.getLayoutConfig(i==null?void 0:i.auth):rt.DEFAULT_CONFIG.routeLayout.auth;d={default:o,auth:w,account:i!=null&&i.account?rt.getLayoutConfig(i.account):w,settings:i!=null&&i.settings?rt.getLayoutConfig(i.settings):o,"auth-request":i!=null&&i["auth-request"]?rt.getLayoutConfig(i["auth-request"]):o}}this.config={id:u.id||rt.DEFAULT_CONFIG.id,theme:u.theme||rt.DEFAULT_CONFIG.theme,cssVars:l,customStyles:u.customStyles||rt.DEFAULT_CONFIG.customStyles,routeLayout:d,clickOutsideBehavior:u.clickOutsideBehavior||rt.DEFAULT_CONFIG.clickOutsideBehavior},this.imageBaseUrl=new URL(n).origin;let c=rt.initializeIframe(n,this.config);this.host=c.host,this.backdrop=c.backdrop,this.wrapper=c.wrapper,this.iframe=c.iframe,this.halfImage=c.halfImage,this.resize({routeType:"auth",preferredLayoutType:d.auth.type,height:0})}getRouteImageUrl(n){return!n||!rt.ALLOWED_IMG_PATHS.has(n)?null:`${this.imageBaseUrl}/assets/routes/${n}`}static getLayoutConfig(n){return typeof n=="object"?n:{type:n}}static initializeIframe(n,u){let l=document.createElement("div");l.id=u.id;let i=l.attachShadow({mode:"open"}),d=document.createElement("template");d.innerHTML=Ka({customStyles:u.customStyles,cssVariableKeys:Object.keys(rt.DEFAULT_LIGHT_CSS_VARS)}),Kt(l,u.cssVars,u.theme),i.appendChild(d.content);let c=document.createElement("div");c.className="backdrop";let o=document.createElement("div");o.className="iframe-wrapper";let w=document.createElement("iframe");w.className="iframe",w.allow="camera *;",w.src=n,o.appendChild(w);let b=document.createElement("img");return b.className="half-image",i.appendChild(o),i.appendChild(c),i.appendChild(b),{iframe:w,host:l,backdrop:c,wrapper:o,halfImage:b}}getElements(){return{host:this.host,backdrop:this.backdrop,wrapper:this.wrapper,iframe:this.iframe,halfImage:this.halfImage}}show(){var n;this.isOpen=!0,this.backdrop.classList.add("show"),this.wrapper.classList.add("show"),(n=this.iframe.contentWindow)==null||n.focus(),this.currentLayoutType==="half"&&this.halfImage.src&&this.halfImage.classList.add("show")}hide(){var n;this.isOpen=!1,this.backdrop.classList.remove("show"),this.wrapper.classList.remove("show"),(n=document.activeElement)==null||n.blur(),this.halfImage.classList.remove("show")}resize(n){let{config:u,wrapper:l}=this,i=u.routeLayout[n.routeType],d=i.type;this.currentLayoutType=d,d!=="half"&&(this.halfImage.style.display="none",this.halfImage.classList.remove("show")),l.dataset.layout=d,l.dataset.position="",l.dataset.expanded="",l.dataset.expandOnMobile=i.expandOnMobile!==!1?"true":"false";let c={};switch(i.type){case"modal":{c.preferredWidth=i.fixedWidth||n.width||"",c.preferredHeight=i.fixedHeight||n.height||"";break}case"popup":{l.dataset.position=i.position||"bottom-right",c.preferredWidth=i.fixedWidth||n.width||"",c.preferredHeight=i.fixedHeight||n.height||"";break}case"sidebar":{l.dataset.position=i.position||"right",l.dataset.expanded=i.expanded?"true":"false",i.expanded&&(c.backdropPadding=0),c.preferredWidth=i.fixedWidth||n.width||"",c.preferredHeight="calc(100dvh - 2 * var(--backdropPadding, 0))";break}case"half":{let o=l.dataset.position=i.position||"right";l.dataset.expanded=i.expanded?"true":"false",i.expanded&&(c.backdropPadding=0),c.preferredWidth="calc(50vw - 2 * var(--backdropPadding, 0))",c.preferredHeight="calc(100dvh - 2 * var(--backdropPadding, 0))",this.halfImage.dataset.position=o==="left"?"right":"left",this.halfImage.dataset.expanded=i.expanded?"true":"false";let w=this.getRouteImageUrl(`${n.routeType}.png`);this.isOpen&&w?(this.halfImage.src=w,this.halfImage.style.display="block",this.halfImage.classList.add("show")):(this.halfImage.style.display="none",this.halfImage.classList.remove("show"));break}}this.host.removeAttribute("style"),this.layoutCssVars=c,this.setTheme(this.config.theme)}setTheme(n){Kt(this.host,this.config.cssVars,n),Kt(this.host,this.layoutCssVars)}destroy(){var n;(n=this.host)==null||n.remove()}};it.DEFAULT_LIGHT_CSS_VARS={background:"white",borderWidth:2,borderColor:"rgba(0, 0, 0, .125)",borderRadius:24,boxShadow:"0 0 16px 0 rgba(0, 0, 0, 0.125)",zIndex:"9999",preferredWidth:400,preferredHeight:400,contentPadding:0,contentMaxWidth:600,contentMaxHeight:"100dvh",backdropBackgroun
541d:"rgba(255, 255, 255, .0625)",backdropBackdropFilter:"blur(12px)",backdropPadding:8,mobilePadding:0,mobileHeight:0,mobileBorderRadius:24,mobileBorderWidth:0,mobileBorderColor:"transparent",mobileBoxShadow:"none"},it.DEFAULT_DARK_CSS_VARS={...it.DEFAULT_LIGHT_CSS_VARS,background:"black"},it.DEFAULT_CONFIG={id:"wanderConnectIframeHost",theme:"system",cssVars:{light:it.DEFAULT_LIGHT_CSS_VARS,dark:it.DEFAULT_DARK_CSS_VARS},customStyles:"",routeLayout:{default:it.getLayoutConfig("popup"),auth:it.getLayoutConfig("modal"),account:it.getLayoutConfig("modal"),settings:it.getLayoutConfig("popup"),"auth-request":it.getLayoutConfig("popup")},clickOutsideBehavior:!0},it.IMAGE_EXTENSIONS=["png","webp"],it.DEFAULT_ROUTE_TYPES=["default","auth","account","auth-request","settings"],it.ALLOWED_IMG_PATHS=new Set(it.DEFAULT_ROUTE_TYPES.flatMap(a=>it.IMAGE_EXTENSIONS.map(n=>`${a}.${n}`)));var Ya=it,Ja=["loading","onboarding","authenticated","not-authenticated"];function Xa(a){return!a||typeof a!="object"||!("id"in a&&"type"in a&&"data"in a)||a.type!=="event"?!1:typeof a.data.name=="string"}function Za(a){if(!a||typeof a!="object"||!("id"in a&&"type"in a&&"data"in a)||a.type!=="switch_wallet_event")return!1;let n=a.data;return n===null||typeof n=="string"}function Qa(a){if(!a||typeof a!="object"||!("id"in a&&"type"in a&&"data"in a))return!1;switch(a.type){case"embedded_auth":{let n=a.data;return!n||typeof n!="object"?!1:n.authType==="NATIVE_WALLET"?n.authStatus===null&&n.userDetails===null:n.authStatus==="not-authenticated"?n.authType===null&&n.userDetails===null:!!n.authType&&Ja.includes(n.authStatus)&&(n.userDetails===null||!!n.userDetails&&typeof n.userDetails=="object")}case"embedded_backup":{let n=a.data;return!!(n&&typeof n=="object"&&typeof n.backupsNeeded=="number"&&(typeof n.backupMessage>"u"||typeof n.backupMessage=="string"))}case"embedded_open":case"embedded_close":return!0;case"embedded_resize":{let n=a.data;return!!(n&&typeof n=="object"&&typeof n.routeType=="string"&&typeof n.preferredLayoutType=="string"&&typeof n.height=="number")}case"embedded_balance":{let n=a.data;return!!(n&&typeof n=="object"&&(n.amount===null||typeof n.amount=="number")&&(n.currency===null||typeof n.currency=="string")&&typeof n.formattedBalance=="string")}case"embedded_request":{let n=a.data;return!!(n&&typeof n=="object"&&typeof n.pendingRequests=="number")}default:return!1}}var ti="client-id",ei="theme",ri="ancestor-origin",ni="hide-be",ai="injected-be",ii="server-base-url",oi="skip-storage-access-warning";function si({baseURL:a,clientId:n,theme:u,hideBE:l,injectedBE:i,baseServerURL:d,skipStorageAccessWarning:c}){let o=new URL(a),{searchParams:w}=o;return w.set(ti,n),w.set(ei,u),w.set(ri,window.location.origin),l&&w.set(ni,"1"),i&&w.set(ai,"1"),d&&w.set(ii,d),c&&w.set(oi,"1"),o.toString()}var Ze=typeof structuredClone=="function"?structuredClone:function(a){return JSON.parse(JSON.stringify(a))},ft=()=>{},St=class ct{constructor(n){var l;if(this.onAuth=ft,this.onBackup=ft,this.onOpen=ft,this.onClose=ft,this.onResize=ft,this.onBalance=ft,this.onRequest=ft,this.signOutMethodCallback=ft,this.buttonComponent=null,this.iframeC
541omponent=null,this.iframeRef=null,this.openReason=null,this.allowOpeningAutomatically=!0,this.hasIndependentIframeTheme=!1,this.hasIndependentButtonTheme=!1,this.setThemeTimeoutID=0,this.authInfo={authType:null,authStatus:"not-authenticated",userDetails:null},this.routeConfig=null,this.backupInfo=null,this.balanceInfo=null,this.pendingRequests=0,this.isWalletReady=!1,this.isBrowserWalletEnabled=!1,this.windowArweaveWallet=null,ct.instance)throw new Error("WanderEmbedded instance already exists. Make sure you call `instance.destroy()` before instantiating it again.");ct.instance=this,this.onAuth=n.onAuth??ft,this.onBackup=n.onBackup??ft,this.onOpen=n.onOpen??ft,this.onClose=n.onClose??ft,this.onResize=n.onResize??ft,this.onBalance=n.onBalance??ft,this.onRequest=n.onRequest??ft;let u=ht({clientId:"",iframe:{clickOutsideBehavior:!0},button:!0,skipStorageAccessWarning:!1},n||{});if(u.clientId!=="FREE_TRIAL")throw new Error(`The clientId option is required and must be set to "FREE_TRIAL". This will change in the future, when you'll be required to register your app(s) to get a valid client ID.`);try{let i=JSON.parse(localStorage.getItem(ct.AUTH_STATE_LS_KEY)||"null");i&&(this.authInfo={authType:i.authType||null,authStatus:"loading",userDetails:i.userDetails||null})}catch(i){console.warn("Error parsing last authentication state:",i)}try{this.isBrowserWalletEnabled=localStorage.getItem(ct.BROWSER_WALLET_ENABLED_KEY)==="true"}catch(i){console.warn("Error parsing last native wallet enabled:",i)}if(this.initializeComponents(u),!this.iframeRef)throw new Error("Error creating iframe");this.handleMessage=this.handleMessage.bind(this),window.addEventListener("message",this.handleMessage),window.arweaveWallet&&((l=window.arweaveWallet)==null?void 0:l.walletName)!==ct.WANDER_CONNECT_WALLET_NAME&&(this.windowArweaveWallet=window.arweaveWallet),this.injectWanderConnectWalletAPI(this.iframeRef)}injectWanderConnectWalletAPI(n){var u;this.isBrowserWalletEnabled||((u=window.arweaveWallet)==null?void 0:u.walletName)===ct.WANDER_CONNECT_WALLET_NAME||(this.isWalletReady=!1,Ha(n))}restoreBrowserWalletAPI(){var n;!this.isBrowserWalletEnabled||((n=window.arweaveWallet)==null?void 0:n.walletName)!==ct.WANDER_CONNECT_WALLET_NAME||(this.isWalletReady=!1,window.arweaveWallet=this.windowArweaveWallet)}async dispatchWalletLoadedEvents(){var l,i,d;if(this.isBrowserWalletEnabled||this.isWalletReady)return;this.isWalletReady=!0;let n=await window.arweaveWallet.getPermissions().catch(()=>[]);dispatchEvent(new CustomEvent("arweaveWalletLoaded",{detail:{permissions:n}})),n.length>0?(l=this.buttonComponent)==null||l.setStatus("isConnected"):(i=this.buttonComponent)==null||i.unsetStatus("isConnected");let u=(d=window.arweaveWallet)==null?void 0:d.events;if(u&&n.length>0){u.emit("connect",null);let[c,o]=await Promise.all([window.arweaveWallet.getActiveAddress().catch(()=>""),window.arweaveWallet.getAllAddresses().catch(()=>[])]);u.emit("activeAddress",c),u.emit("addresses",o)}}initializeComponents(n){let{clientId:u,baseURL:l=ct.DEFAULT_IFRAME_SRC,theme:i=ct.DEFAULT_THEME,hideBE:d,baseServerURL:c,skipStorageAccessWarning:o}=n,w=n.iframe instanceof HTMLElement?n.iframe:Ze(n.iframe||{}),b=null;n.button===!0?b={}:n.button&&(b={...Ze({...n.button,parent:null}),parent:n.button.parent});let A=si({baseURL:l,clientId:u,theme:i,hideBE:d,injectedBE:this.isBrowserWalletEnabled,baseServerURL:c,skipStorageAccessWarning:o});if(w instanceof HTMLElement)w.src&&w.src!==A&&console.warn(`Replacing iframe.src ("${w.src}") with ${A}`),w.src=A,this.iframeRef=w;else{w.theme&&(this.hasIndependentIframeTheme=!0),w.theme||(w.theme=i),this.iframeC
541omponent=new Ya(A,w);let T=this.iframeComponent.getElements();this.iframeRef=T.iframe,w!=null&&w.clickOutsideBehavior&&T.backdrop.addEventListener("click",()=>{this.close()})}if(b){b.theme&&(this.hasIndependentButtonTheme=!0),b.theme||(b.theme=i),this.buttonComponent=new qa(b),this.buttonComponent.setVariant(this.authInfo.authStatus||"not-authenticated");let T=this.buttonComponent.getElements();T.parent.appendChild(T.host),this.handleButtonClick=this.handleButtonClick.bind(this),T.button.addEventListener("click",this.handleButtonClick)}this.iframeComponent&&document.body.appendChild(this.iframeComponent.getElements().host)}async handleMessage(n){var l,i,d,c,o,w,b;let u=n.data;if(!(!this.iframeRef||n.origin!==new URL(this.iframeRef.src).origin)){if(Xa(u)&&this.isWalletReady){u.data.name==="permissions"&&u.data.value.length>0||u.data.name==="connect"?(l=this.buttonComponent)==null||l.setStatus("isConnected"):(u.data.name==="permissions"&&u.data.value.length===0||u.data.name==="disconnect")&&((i=this.buttonComponent)==null||i.unsetStatus("isConnected"));let A=(d=window.arweaveWallet)==null?void 0:d.events;A&&A.emit(u.data.name,u.data.value);return}if(Za(u)){dispatchEvent(new CustomEvent("walletSwitch",{detail:{address:u.data}}));return}if(Qa(u))switch(u.type){case"embedded_auth":let A=u.data,{authType:T,authStatus:x}=A;if(this.authInfo=A,x==="not-authenticated")localStorage.removeItem(ct.AUTH_STATE_LS_KEY);else try{localStorage.setItem(ct.AUTH_STATE_LS_KEY,JSON.stringify(A))}catch($){console.warn("Error storing last authentication state:",$)}T==="NATIVE_WALLET"?(this.isBrowserWalletEnabled=!0,localStorage.setItem(ct.BROWSER_WALLET_ENABLED_KEY,"true"),this._close(),this.restoreBrowserWalletAPI()):(T&&(this.isBrowserWalletEnabled=!1,localStorage.removeItem(ct.BROWSER_WALLET_ENABLED_KEY)),this.injectWanderConnectWalletAPI(this.iframeRef),x==="authenticated"?this.dispatchWalletLoadedEvents():x==="not-authenticated"&&(this.backupInfo=null,this.balanceInfo=null,this.pendingRequests=0,this.isWalletReady=!1,(c=this.buttonComponent)==null||c.unsetStatus("isConnected"),this.updateButtonNotification()),(o=this.buttonComponent)==null||o.setVariant(x)),this.isBrowserWalletEnabled?this.onAuth({authType:"NATIVE_WALLET",authStatus:null,userDetails:null}):this.onAuth(A),A.authStatus==="not-authenticated"&&this.signOutMethodCallback();break;case"embedded_backup":let S=u.data;this.backupInfo=S.backupsNeeded===0?null:S,this.updateButtonNotification(),this.onBackup(S);break;case"embedded_open":this._open("embedded_open");break;case"embedded_close":this._close();break;case"embedded_resize":let _=u.data;(w=this.iframeComponent)==null||w.resize(_),this.onResize(_);break;case"embedded_balance":let O=u.data;this.balanceInfo=O,(b=this.buttonComponent)==null||b.setBalance(O),this.onBalance(O);break;case"embedded_request":let{pendingRequests:W,hasNewConnectRequest:q}=u.data;this.pendingRequests=W,W>0&&(this.shouldOpenAutomatically||q)?this._open("embedded_request"):W===0&&this.shouldCloseAutomatically&&this._close(!0),this.updateButtonNotification(),this.onRequest(u.data);break}}}handleButtonClick(){this.isOpen?this.close():this.open(this.backupInfo?"backup":void 0)}updateButtonNotification(){let{buttonComponent:n,pendingRequests:u,backupInfo:l}=this;n&&(u>0?n.setNotifications(u):l&&l.backupsNeeded>0?n.setNotifications("backupNeeded"):n.setNotifications(null))}_open(n,u){var l,i;!this.iframeComponent&&!this.buttonComponent&&console.warn("Wander Embedded's iframe and button has been created manually"),u&&qt({destination:"background",messageId:"embedded_navigate",data:u}),this.isOpen||(this.openReason??(this.openReason=n),(l=this.buttonComponent)==null||l.setStatus("isOpen"),(i=this.iframeComponent)==null||i.show()),this.onOpen()}open(n){this._open("manually",n)}_close(n=!1){var u,l;!this.iframeComponent&&!this.buttonComponent&&console.warn("Wander Embedded's iframe and button has been created manually"),this.isOpen&&(this.openReason=null,this.allowOpeningAutomatically=this.pendingRequests===0?!0:n,(u=this.buttonComponent)==null||u.unsetStatus("isOpen"),(l=this.iframeC
541omponent)==null||l.hide()),this.onClose()}close(){this._close()}signOut(){if(this.authInfo.authStatus==="not-authenticated"||this.authInfo.authStatus==="loading")throw new Error("The user is not authenticated");return new Promise((n,u)=>{let{iframeRef:l}=this,i=l==null?void 0:l.contentWindow;if(!l||!i){u(new Error("Missing Wander Connect iframe"));return}qt({destination:"background",messageId:"embedded_signOut",data:void 0}),this.signOutMethodCallback=n})}setTheme(n){if(!Ot.includes(n))throw new Error(`${n} is not a valid theme. Use: ${Ot.join(", ")}`);qt({destination:"background",messageId:"embedded_setTheme",data:n}),window.clearTimeout(this.setThemeTimeoutID),this.setThemeTimeoutID=window.setTimeout(()=>{!this.hasIndependentIframeTheme&&this.iframeComponent&&this.iframeComponent.setTheme(n),!this.hasIndependentButtonTheme&&this.buttonComponent&&this.buttonComponent.setTheme(n)},230)}setIframeTheme(n){var u;if(!Ot.includes(n))throw new Error(`${n} is not a valid theme. Use: ${Ot.join(", ")}`);(u=this.iframeComponent)==null||u.setTheme(n)}setButtonTheme(n){var u;if(!Ot.includes(n))throw new Error(`${n} is not a valid theme. Use: ${Ot.join(", ")}`);(u=this.buttonComponent)==null||u.setTheme(n)}destroy(){window.removeEventListener("message",this.handleMessage),window.removeEventListener("click",this.handleButtonClick),this.iframeC
541omponent&&this.iframeComponent.destroy(),this.buttonComponent&&this.buttonComponent.destroy(),ct.instance=null,delete window.arweaveWallet,this.windowArweaveWallet&&(window.arweaveWallet=this.windowArweaveWallet)}get shouldOpenAutomatically(){return this.openReason===null&&this.allowOpeningAutomatically}get shouldCloseAutomatically(){return this.openReason==="embedded_request"}get isOpen(){return this.openReason!==null}get width(){var n;return(n=this.routeConfig)==null?void 0:n.width}get height(){var n;return(n=this.routeConfig)==null?void 0:n.height}};St.instance=null,St.WANDER_CONNECT_WALLET_NAME="Wander Connect",St.AUTH_STATE_LS_KEY="WANDER_CONNECT_AUTH_STATE",St.BROWSER_WALLET_ENABLED_KEY="WANDER_CONNECT_BROWSER_WALLET_ENABLED",St.DEFAULT_IFRAME_SRC="https://connect.wander.app/",St.DEFAULT_THEME="system";var li=St;/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */export{li as WanderConnect};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.