@wormhole-foundation/wormhole-connect 0.3.9-beta.0-development → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/assets/{ccip-VZmm9Ynz.js → ccip-BM2KTJKS.js} +1 -1
  2. package/dist/assets/{cosmos-J21Kldym.js → cosmos-BX1BekzP.js} +1 -1
  3. package/dist/assets/{evm-CceEkY8D.js → evm-BXEmCPMX.js} +4 -4
  4. package/dist/assets/index-BvyW3wwj.js +3 -0
  5. package/dist/assets/index-CaMXNKLm.js +2 -0
  6. package/dist/assets/{index-IWZOuhzu.js → index-D0lqVeXm.js} +1 -1
  7. package/dist/assets/{index.es-BpbdjECw.js → index.es-DYz79wKC.js} +2 -2
  8. package/dist/assets/{solana-BHV_-eCx.js → solana-CAUt8JQI.js} +2 -2
  9. package/dist/assets/{solanaEmbed.esm-B9sWifH1.js → solanaEmbed.esm-H1FtxXdm.js} +1 -1
  10. package/dist/main.js +85 -85
  11. package/dist/src/routes/utils.d.ts.map +1 -1
  12. package/lib/{aptos-Di9E2_wp.js → aptos-BD9dLPo0.js} +1 -1
  13. package/lib/{aptos-CBux549u.mjs → aptos-BFfGA69R.mjs} +1 -1
  14. package/lib/{ccip-pyZLTcW7.js → ccip-BRt-YHc-.js} +1 -1
  15. package/lib/{ccip-BDLKT_93.mjs → ccip-DUFlgF1_.mjs} +1 -1
  16. package/lib/{cosmos-CdVnlqzd.js → cosmos-CQgiFVOc.js} +1 -1
  17. package/lib/{cosmos-C39_QwJ5.mjs → cosmos-adL_JGZ6.mjs} +2 -2
  18. package/lib/{evm-aN59q_R_.js → evm-Bl7undtj.js} +4 -4
  19. package/lib/{evm-B-YLcddr.mjs → evm-zMaXwqxg.mjs} +6 -6
  20. package/lib/{index-V_SPxmrQ.mjs → index-6_27Y5fq.mjs} +2 -2
  21. package/lib/{index-CiT2h5gE.js → index-Bgq8r33i.js} +1 -1
  22. package/lib/{index-BSkg4LjK.js → index-C8F998ax.js} +1 -1
  23. package/lib/index-Ci2FvrOh.js +1 -0
  24. package/lib/{index-C6Wvczhr.js → index-DTOQHhz5.js} +2 -2
  25. package/lib/{index-DL8L1ROt.mjs → index-DV6sNreL.mjs} +23 -22
  26. package/lib/{index-BkGesTg8.mjs → index-Da6eXxi9.mjs} +3 -3
  27. package/lib/{index-8_RCXn3f.js → index-U9aI6SMh.js} +1 -1
  28. package/lib/{index-b-1s4RBl.mjs → index-YvQiXdUE.mjs} +1 -1
  29. package/lib/{index-Dav5vlPz.mjs → index-jL8n_lZd.mjs} +2 -2
  30. package/lib/{index.es-BiFBfhQG.mjs → index.es--nOdm892.mjs} +1 -1
  31. package/lib/{index.es-C3-YBNbP.mjs → index.es-Bx6K8dMp.mjs} +4 -4
  32. package/lib/{index.es-ChPrRrlN.js → index.es-CM2UFhO6.js} +1 -1
  33. package/lib/{index.es-BQUa7Vv7.js → index.es-CnPkjyNd.js} +1 -1
  34. package/lib/{index.es-Bb_BiFnk.js → index.es-DLsJAPWM.js} +2 -2
  35. package/lib/{index.es-VnkPP7nS.mjs → index.es-DTpG_imm.mjs} +2 -2
  36. package/lib/index.js +1 -1
  37. package/lib/index.mjs +1 -1
  38. package/lib/{sei-BoQhh6Mb.js → sei-BvR89XbN.js} +1 -1
  39. package/lib/{sei-Hg6zXjFL.mjs → sei-C5tfWv0i.mjs} +1 -1
  40. package/lib/{solana-Depj19nP.js → solana-CRhTLHaG.js} +1 -1
  41. package/lib/{solana-DLUxtso2.mjs → solana-vzDc-ufj.mjs} +3 -3
  42. package/lib/{solanaEmbed.esm-13cDHD8t.js → solanaEmbed.esm-B7yFNTk4.js} +1 -1
  43. package/lib/{solanaEmbed.esm-C7fwNyMo.mjs → solanaEmbed.esm-DHYvoxHh.mjs} +2 -2
  44. package/lib/src/routes/utils.d.ts.map +1 -1
  45. package/lib/{sui-4jYajsRL.js → sui-DdAX-NLr.js} +1 -1
  46. package/lib/{sui-BMRM04YZ.mjs → sui-FUMrQjvP.mjs} +1 -1
  47. package/package.json +1 -1
  48. package/dist/assets/index-BGRtIcKb.js +0 -2
  49. package/dist/assets/index-By11uCvO.js +0 -3
  50. package/lib/index-DymMdCti.js +0 -1
@@ -0,0 +1,3 @@
1
+ import{q as P,b2 as Ye,d as Z,b3 as Ze,aJ as it}from"../main.js";var Je={},Qe={exports:{}},je={};(function(o){o.fetch=n(P.fetch)&&n(P.ReadableStream),o.writableStream=n(P.WritableStream),o.abortController=n(P.AbortController);var r;function h(){if(r!==void 0)return r;if(P.XMLHttpRequest){r=new P.XMLHttpRequest;try{r.open("GET",P.XDomainRequest?"/":"https://example.com")}catch{r=null}}else r=null;return r}function f(g){var u=h();if(!u)return!1;try{return u.responseType=g,u.responseType===g}catch{}return!1}o.arraybuffer=o.fetch||f("arraybuffer"),o.msstream=!o.fetch&&f("ms-stream"),o.mozchunkedarraybuffer=!o.fetch&&f("moz-chunked-arraybuffer"),o.overrideMimeType=o.fetch||(h()?n(h().overrideMimeType):!1);function n(g){return typeof g=="function"}r=null})(je);var xe={},Ke=je,ft=Ze,et=Ye(),Ae=xe.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},$e=xe.IncomingMessage=function(o,r,h,f){var n=this;if(et.Readable.call(n),n._mode=h,n.headers={},n.rawHeaders=[],n.trailers={},n.rawTrailers=[],n.on("end",function(){Z.process.nextTick(function(){n.emit("close")})}),h==="fetch"){let C=function(){u.read().then(function(m){if(!n._destroyed){if(f(m.done),m.done){n.push(null);return}n.push(Z.Buffer.from(m.value)),C()}}).catch(function(m){f(!0),n._destroyed||n.emit("error",m)})};if(n._fetchResponse=r,n.url=r.url,n.statusCode=r.status,n.statusMessage=r.statusText,r.headers.forEach(function(m,A){n.headers[A.toLowerCase()]=m,n.rawHeaders.push(A,m)}),Ke.writableStream){var g=new WritableStream({write:function(m){return f(!1),new Promise(function(A,te){n._destroyed?te():n.push(Z.Buffer.from(m))?A():n._resumeFetch=A})},close:function(){f(!0),n._destroyed||n.push(null)},abort:function(m){f(!0),n._destroyed||n.emit("error",m)}});try{r.body.pipeTo(g).catch(function(m){f(!0),n._destroyed||n.emit("error",m)});return}catch{}}var u=r.body.getReader();C()}else{n._xhr=o,n._pos=0,n.url=o.responseURL,n.statusCode=o.status,n.statusMessage=o.statusText;var a=o.getAllResponseHeaders().split(/\r?\n/);if(a.forEach(function(C){var m=C.match(/^([^:]+):\s*(.*)/);if(m){var A=m[1].toLowerCase();A==="set-cookie"?(n.headers[A]===void 0&&(n.headers[A]=[]),n.headers[A].push(m[2])):n.headers[A]!==void 0?n.headers[A]+=", "+m[2]:n.headers[A]=m[2],n.rawHeaders.push(m[1],m[2])}}),n._charset="x-user-defined",!Ke.overrideMimeType){var v=n.rawHeaders["mime-type"];if(v){var T=v.match(/;\s*charset=([^;])(;|$)/);T&&(n._charset=T[1].toLowerCase())}n._charset||(n._charset="utf-8")}}};ft($e,et.Readable);$e.prototype._read=function(){var o=this,r=o._resumeFetch;r&&(o._resumeFetch=null,r())};$e.prototype._onXHRProgress=function(o){var r=this,h=r._xhr,f=null;switch(r._mode){case"text":if(f=h.responseText,f.length>r._pos){var n=f.substr(r._pos);if(r._charset==="x-user-defined"){for(var g=Z.Buffer.alloc(n.length),u=0;u<n.length;u++)g[u]=n.charCodeAt(u)&255;r.push(g)}else r.push(n,r._charset);r._pos=f.length}break;case"arraybuffer":if(h.readyState!==Ae.DONE||!h.response)break;f=h.response,r.push(Z.Buffer.from(new Uint8Array(f)));break;case"moz-chunked-arraybuffer":if(f=h.response,h.readyState!==Ae.LOADING||!f)break;r.push(Z.Buffer.from(new Uint8Array(f)));break;case"ms-stream":if(f=h.response,h.readyState!==Ae.LOADING)break;var a=new P.MSStreamReader;a.onprogress=function(){a.result.byteLength>r._pos&&(r.push(Z.Buffer.from(new Uint8Array(a.result.slice(r._pos)))),r._pos=a.result.byteLength)},a.onload=function(){o(!0),r.push(null)},a.readAsArrayBuffer(f);break}r._xhr.readyState===Ae.DONE&&r._mode!=="ms-stream"&&(o(!0),r.push(null))};var he=je,ht=Ze,tt=xe,ke=Ye(),ut=tt.IncomingMessage,Ve=tt.readyStates;function ct(o,r){return he.fetch&&r?"fetch":he.mozchunkedarraybuffer?"moz-chunked-arraybuffer":he.msstream?"ms-stream":he.arraybuffer&&o?"arraybuffer":"text"}var S=Qe.exports=function(o){var r=this;ke.Writable.call(r),r._opts=o,r._body=[],r._headers={},o.auth&&r.setHeader("Authorization","Basic "+Z.Buffer.from(o.auth).toString("base64")),Object.keys(o.headers).forEach(function(n){r.setHeader(n,o.headers[n])});var h,f=!0;if(o.mode==="disable-fetch"||"requestTimeout"in o&&!he.abortController)f=!1,h=!0;else if(o.mode==="prefer-streaming")h=!1;else if(o.mode==="allow-wrong-content-type")h=!he.overrideMimeType;else if(!o.mode||o.mode==="default"||o.mode==="prefer-fast")h=!0;else throw new Error("Invalid value for opts.mode");r._mode=ct(h,f),r._fetchTimer=null,r._socketTimeout=null,r._socketTimer=null,r.on("finish",function(){r._onFinish()})};ht(S,ke.Writable);S.prototype.setHeader=function(o,r){var h=this,f=o.toLowerCase();pt.indexOf(f)===-1&&(h._headers[f]={name:o,value:r})};S.prototype.getHeader=function(o){var r=this._headers[o.toLowerCase()];return r?r.value:null};S.prototype.removeHeader=function(o){var r=this;delete r._headers[o.toLowerCase()]};S.prototype._onFinish=function(){var o=this;if(!o._destroyed){var r=o._opts;"timeout"in r&&r.timeout!==0&&o.setTimeout(r.timeout);var h=o._headers,f=null;r.method!=="GET"&&r.method!=="HEAD"&&(f=new Blob(o._body,{type:(h["content-type"]||{}).value||""}));var n=[];if(Object.keys(h).forEach(function(v){var T=h[v].name,C=h[v].value;Array.isArray(C)?C.forEach(function(m){n.push([T,m])}):n.push([T,C])}),o._mode==="fetch"){var g=null;if(he.abortController){var u=new AbortController;g=u.signal,o._fetchAbortController=u,"requestTimeout"in r&&r.requestTimeout!==0&&(o._fetchTimer=P.setTimeout(function(){o.emit("requestTimeout"),o._fetchAbortController&&o._fetchAbortController.abort()},r.requestTimeout))}P.fetch(o._opts.url,{method:o._opts.method,headers:n,body:f||void 0,mode:"cors",credentials:r.withCredentials?"include":"same-origin",signal:g}).then(function(v){o._fetchResponse=v,o._resetTimers(!1),o._connect()},function(v){o._resetTimers(!0),o._destroyed||o.emit("error",v)})}else{var a=o._xhr=new P.XMLHttpRequest;try{a.open(o._opts.method,o._opts.url,!0)}catch(v){Z.process.nextTick(function(){o.emit("error",v)});return}"responseType"in a&&(a.responseType=o._mode),"withCredentials"in a&&(a.withCredentials=!!r.withCredentials),o._mode==="text"&&"overrideMimeType"in a&&a.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in r&&(a.timeout=r.requestTimeout,a.ontimeout=function(){o.emit("requestTimeout")}),n.forEach(function(v){a.setRequestHeader(v[0],v[1])}),o._response=null,a.onreadystatechange=function(){switch(a.readyState){case Ve.LOADING:case Ve.DONE:o._onXHRProgress();break}},o._mode==="moz-chunked-arraybuffer"&&(a.onprogress=function(){o._onXHRProgress()}),a.onerror=function(){o._destroyed||(o._resetTimers(!0),o.emit("error",new Error("XHR error")))};try{a.send(f)}catch(v){Z.process.nextTick(function(){o.emit("error",v)});return}}}};function lt(o){try{var r=o.status;return r!==null&&r!==0}catch{return!1}}S.prototype._onXHRProgress=function(){var o=this;o._resetTimers(!1),!(!lt(o._xhr)||o._destroyed)&&(o._response||o._connect(),o._response._onXHRProgress(o._resetTimers.bind(o)))};S.prototype._connect=function(){var o=this;o._destroyed||(o._response=new ut(o._xhr,o._fetchResponse,o._mode,o._resetTimers.bind(o)),o._response.on("error",function(r){o.emit("error",r)}),o.emit("response",o._response))};S.prototype._write=function(o,r,h){var f=this;f._body.push(o),h()};S.prototype._resetTimers=function(o){var r=this;P.clearTimeout(r._socketTimer),r._socketTimer=null,o?(P.clearTimeout(r._fetchTimer),r._fetchTimer=null):r._socketTimeout&&(r._socketTimer=P.setTimeout(function(){r.emit("timeout")},r._socketTimeout))};S.prototype.abort=S.prototype.destroy=function(o){var r=this;r._destroyed=!0,r._resetTimers(!0),r._response&&(r._response._destroyed=!0),r._xhr?r._xhr.abort():r._fetchAbortController&&r._fetchAbortController.abort(),o&&r.emit("error",o)};S.prototype.end=function(o,r,h){var f=this;typeof o=="function"&&(h=o,o=void 0),ke.Writable.prototype.end.call(f,o,r,h)};S.prototype.setTimeout=function(o,r){var h=this;r&&h.once("timeout",r),h._socketTimeout=o,h._resetTimers(!1)};S.prototype.flushHeaders=function(){};S.prototype.setNoDelay=function(){};S.prototype.setSocketKeepAlive=function(){};var pt=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],dt=Qe.exports,mt=yt,vt=Object.prototype.hasOwnProperty;function yt(){for(var o={},r=0;r<arguments.length;r++){var h=arguments[r];for(var f in h)vt.call(h,f)&&(o[f]=h[f])}return o}var gt={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},He={exports:{}},qe={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */qe.exports;(function(o,r){(function(h){var f=r&&!r.nodeType&&r,n=o&&!o.nodeType&&o,g=typeof P=="object"&&P;(g.global===g||g.window===g||g.self===g)&&(h=g);var u,a=2147483647,v=36,T=1,C=26,m=38,A=700,te=72,ae=128,I="-",Oe=/^xn--/,Ee=/[^\x20-\x7E]/,Ue=/[\x2E\u3002\uFF0E\uFF61]/g,Le={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pe=v-T,M=Math.floor,re=String.fromCharCode,ie;function J(i){throw new RangeError(Le[i])}function de(i,p){for(var y=i.length,b=[];y--;)b[y]=p(i[y]);return b}function be(i,p){var y=i.split("@"),b="";y.length>1&&(b=y[0]+"@",i=y[1]),i=i.replace(Ue,".");var w=i.split("."),U=de(w,p).join(".");return b+U}function Te(i){for(var p=[],y=0,b=i.length,w,U;y<b;)w=i.charCodeAt(y++),w>=55296&&w<=56319&&y<b?(U=i.charCodeAt(y++),(U&64512)==56320?p.push(((w&1023)<<10)+(U&1023)+65536):(p.push(w),y--)):p.push(w);return p}function ue(i){return de(i,function(p){var y="";return p>65535&&(p-=65536,y+=re(p>>>10&1023|55296),p=56320|p&1023),y+=re(p),y}).join("")}function oe(i){return i-48<10?i-22:i-65<26?i-65:i-97<26?i-97:v}function ce(i,p){return i+22+75*(i<26)-((p!=0)<<5)}function ne(i,p,y){var b=0;for(i=y?M(i/A):i>>1,i+=M(i/p);i>pe*C>>1;b+=v)i=M(i/pe);return M(b+(pe+1)*i/(i+m))}function we(i){var p=[],y=i.length,b,w=0,U=ae,q=te,R,N,B,G,L,H,k,W,Q;for(R=i.lastIndexOf(I),R<0&&(R=0),N=0;N<R;++N)i.charCodeAt(N)>=128&&J("not-basic"),p.push(i.charCodeAt(N));for(B=R>0?R+1:0;B<y;){for(G=w,L=1,H=v;B>=y&&J("invalid-input"),k=oe(i.charCodeAt(B++)),(k>=v||k>M((a-w)/L))&&J("overflow"),w+=k*L,W=H<=q?T:H>=q+C?C:H-q,!(k<W);H+=v)Q=v-W,L>M(a/Q)&&J("overflow"),L*=Q;b=p.length+1,q=ne(w-G,b,G==0),M(w/b)>a-U&&J("overflow"),U+=M(w/b),w%=b,p.splice(w++,0,U)}return ue(p)}function Re(i){var p,y,b,w,U,q,R,N,B,G,L,H=[],k,W,Q,me;for(i=Te(i),k=i.length,p=ae,y=0,U=te,q=0;q<k;++q)L=i[q],L<128&&H.push(re(L));for(b=w=H.length,w&&H.push(I);b<k;){for(R=a,q=0;q<k;++q)L=i[q],L>=p&&L<R&&(R=L);for(W=b+1,R-p>M((a-y)/W)&&J("overflow"),y+=(R-p)*W,p=R,q=0;q<k;++q)if(L=i[q],L<p&&++y>a&&J("overflow"),L==p){for(N=y,B=v;G=B<=U?T:B>=U+C?C:B-U,!(N<G);B+=v)me=N-G,Q=v-G,H.push(re(ce(G+me%Q,0))),N=M(me/Q);H.push(re(ce(N,0))),U=ne(y,W,b==w),y=0,++b}++y,++p}return H.join("")}function Pe(i){return be(i,function(p){return Oe.test(p)?we(p.slice(4).toLowerCase()):p})}function Se(i){return be(i,function(p){return Ee.test(p)?"xn--"+Re(p):p})}if(u={version:"1.4.1",ucs2:{decode:Te,encode:ue},decode:we,encode:Re,toASCII:Se,toUnicode:Pe},f&&n)if(o.exports==f)n.exports=u;else for(ie in u)u.hasOwnProperty(ie)&&(f[ie]=u[ie]);else h.punycode=u})(P)})(qe,qe.exports);var _t=qe.exports;(function(o,r){Object.defineProperty(r,"__esModule",{value:!0});var h=_t,f=it;function n(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var g=n(h),u=n(f),a={isString:function(e){return typeof e=="string"},isObject:function(e){return typeof e=="object"&&e!==null},isNull:function(e){return e===null},isNullOrUndefined:function(e){return e==null}},v=g.default,T=a,C=ne,m=Re,A=Pe,te=we,ae=I;function I(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Oe=/^([a-z0-9.+-]+:)/i,Ee=/:[0-9]*$/,Ue=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Le=["<",">",'"',"`"," ","\r",`
2
+ `," "],pe=["{","}","|","\\","^","`"].concat(Le),M=["'"].concat(pe),re=["%","/","?",";","#"].concat(M),ie=["/","?","#"],J=255,de=/^[+a-z0-9A-Z_-]{0,63}$/,be=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Te={javascript:!0,"javascript:":!0},ue={javascript:!0,"javascript:":!0},oe={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},ce=u.default;function ne(e,s,t){if(e&&T.isObject(e)&&e instanceof I)return e;var l=new I;return l.parse(e,s,t),l}I.prototype.parse=function(e,s,t){if(!T.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var l=e.indexOf("?"),_=l!==-1&&l<e.indexOf("#")?"?":"#",D=e.split(_),j=/\\/g;D[0]=D[0].replace(j,"/"),e=D.join(_);var c=e;if(c=c.trim(),!t&&e.split("#").length===1){var K=Ue.exec(c);if(K)return this.path=c,this.href=c,this.pathname=K[1],K[2]?(this.search=K[2],s?this.query=ce.parse(this.search.substr(1)):this.query=this.search.substr(1)):s&&(this.search="",this.query={}),this}var x=Oe.exec(c);if(x){x=x[0];var fe=x.toLowerCase();this.protocol=fe,c=c.substr(x.length)}if(t||x||c.match(/^\/\/[^@\/]+@[^@\/]+/)){var ve=c.substr(0,2)==="//";ve&&!(x&&ue[x])&&(c=c.substr(2),this.slashes=!0)}if(!ue[x]&&(ve||x&&!oe[x])){for(var F=-1,O=0;O<ie.length;O++){var ee=c.indexOf(ie[O]);ee!==-1&&(F===-1||ee<F)&&(F=ee)}var ye,$;F===-1?$=c.lastIndexOf("@"):$=c.lastIndexOf("@",F),$!==-1&&(ye=c.slice(0,$),c=c.slice($+1),this.auth=decodeURIComponent(ye)),F=-1;for(var O=0;O<re.length;O++){var ee=c.indexOf(re[O]);ee!==-1&&(F===-1||ee<F)&&(F=ee)}F===-1&&(F=c.length),this.host=c.slice(0,F),c=c.slice(F),this.parseHost(),this.hostname=this.hostname||"";var ge=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!ge)for(var d=this.hostname.split(/\./),O=0,E=d.length;O<E;O++){var V=d[O];if(V&&!V.match(de)){for(var z="",X=0,Ie=V.length;X<Ie;X++)V.charCodeAt(X)>127?z+="x":z+=V[X];if(!z.match(de)){var se=d.slice(0,O),Y=d.slice(O+1),le=V.match(be);le&&(se.push(le[1]),Y.unshift(le[2])),Y.length&&(c="/"+Y.join(".")+c),this.hostname=se.join(".");break}}}this.hostname.length>J?this.hostname="":this.hostname=this.hostname.toLowerCase(),ge||(this.hostname=v.toASCII(this.hostname));var Fe=this.port?":"+this.port:"",st=this.hostname||"";this.host=st+Fe,this.href+=this.host,ge&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),c[0]!=="/"&&(c="/"+c))}if(!Te[fe])for(var O=0,E=M.length;O<E;O++){var _e=M[O];if(c.indexOf(_e)!==-1){var Me=encodeURIComponent(_e);Me===_e&&(Me=escape(_e)),c=c.split(_e).join(Me)}}var Ne=c.indexOf("#");Ne!==-1&&(this.hash=c.substr(Ne),c=c.slice(0,Ne));var Ce=c.indexOf("?");if(Ce!==-1?(this.search=c.substr(Ce),this.query=c.substr(Ce+1),s&&(this.query=ce.parse(this.query)),c=c.slice(0,Ce)):s&&(this.search="",this.query={}),c&&(this.pathname=c),oe[fe]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var Fe=this.pathname||"",at=this.search||"";this.path=Fe+at}return this.href=this.format(),this};function we(e){return T.isString(e)&&(e=ne(e)),e instanceof I?e.format():I.prototype.format.call(e)}I.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var s=this.protocol||"",t=this.pathname||"",l=this.hash||"",_=!1,D="";this.host?_=e+this.host:this.hostname&&(_=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(_+=":"+this.port)),this.query&&T.isObject(this.query)&&Object.keys(this.query).length&&(D=ce.stringify(this.query));var j=this.search||D&&"?"+D||"";return s&&s.substr(-1)!==":"&&(s+=":"),this.slashes||(!s||oe[s])&&_!==!1?(_="//"+(_||""),t&&t.charAt(0)!=="/"&&(t="/"+t)):_||(_=""),l&&l.charAt(0)!=="#"&&(l="#"+l),j&&j.charAt(0)!=="?"&&(j="?"+j),t=t.replace(/[?#]/g,function(c){return encodeURIComponent(c)}),j=j.replace("#","%23"),s+_+t+j+l};function Re(e,s){return ne(e,!1,!0).resolve(s)}I.prototype.resolve=function(e){return this.resolveObject(ne(e,!1,!0)).format()};function Pe(e,s){return e?ne(e,!1,!0).resolveObject(s):s}I.prototype.resolveObject=function(e){if(T.isString(e)){var s=new I;s.parse(e,!1,!0),e=s}for(var t=new I,l=Object.keys(this),_=0;_<l.length;_++){var D=l[_];t[D]=this[D]}if(t.hash=e.hash,e.href==="")return t.href=t.format(),t;if(e.slashes&&!e.protocol){for(var j=Object.keys(e),c=0;c<j.length;c++){var K=j[c];K!=="protocol"&&(t[K]=e[K])}return oe[t.protocol]&&t.hostname&&!t.pathname&&(t.path=t.pathname="/"),t.href=t.format(),t}if(e.protocol&&e.protocol!==t.protocol){if(!oe[e.protocol]){for(var x=Object.keys(e),fe=0;fe<x.length;fe++){var ve=x[fe];t[ve]=e[ve]}return t.href=t.format(),t}if(t.protocol=e.protocol,!e.host&&!ue[e.protocol]){for(var E=(e.pathname||"").split("/");E.length&&!(e.host=E.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),E[0]!==""&&E.unshift(""),E.length<2&&E.unshift(""),t.pathname=E.join("/")}else t.pathname=e.pathname;if(t.search=e.search,t.query=e.query,t.host=e.host||"",t.auth=e.auth,t.hostname=e.hostname||e.host,t.port=e.port,t.pathname||t.search){var F=t.pathname||"",O=t.search||"";t.path=F+O}return t.slashes=t.slashes||e.slashes,t.href=t.format(),t}var ee=t.pathname&&t.pathname.charAt(0)==="/",ye=e.host||e.pathname&&e.pathname.charAt(0)==="/",$=ye||ee||t.host&&e.pathname,ge=$,d=t.pathname&&t.pathname.split("/")||[],E=e.pathname&&e.pathname.split("/")||[],V=t.protocol&&!oe[t.protocol];if(V&&(t.hostname="",t.port=null,t.host&&(d[0]===""?d[0]=t.host:d.unshift(t.host)),t.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(E[0]===""?E[0]=e.host:E.unshift(e.host)),e.host=null),$=$&&(E[0]===""||d[0]==="")),ye)t.host=e.host||e.host===""?e.host:t.host,t.hostname=e.hostname||e.hostname===""?e.hostname:t.hostname,t.search=e.search,t.query=e.query,d=E;else if(E.length)d||(d=[]),d.pop(),d=d.concat(E),t.search=e.search,t.query=e.query;else if(!T.isNullOrUndefined(e.search)){if(V){t.hostname=t.host=d.shift();var z=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;z&&(t.auth=z.shift(),t.host=t.hostname=z.shift())}return t.search=e.search,t.query=e.query,(!T.isNull(t.pathname)||!T.isNull(t.search))&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.href=t.format(),t}if(!d.length)return t.pathname=null,t.search?t.path="/"+t.search:t.path=null,t.href=t.format(),t;for(var X=d.slice(-1)[0],Ie=(t.host||e.host||d.length>1)&&(X==="."||X==="..")||X==="",se=0,Y=d.length;Y>=0;Y--)X=d[Y],X==="."?d.splice(Y,1):X===".."?(d.splice(Y,1),se++):se&&(d.splice(Y,1),se--);if(!$&&!ge)for(;se--;se)d.unshift("..");$&&d[0]!==""&&(!d[0]||d[0].charAt(0)!=="/")&&d.unshift(""),Ie&&d.join("/").substr(-1)!=="/"&&d.push("");var le=d[0]===""||d[0]&&d[0].charAt(0)==="/";if(V){t.hostname=t.host=le?"":d.length?d.shift():"";var z=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;z&&(t.auth=z.shift(),t.host=t.hostname=z.shift())}return $=$||t.host&&d.length,$&&!le&&d.unshift(""),d.length?t.pathname=d.join("/"):(t.pathname=null,t.path=null),(!T.isNull(t.pathname)||!T.isNull(t.search))&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.auth=e.auth||t.auth,t.slashes=t.slashes||e.slashes,t.href=t.format(),t},I.prototype.parseHost=function(){var e=this.host,s=Ee.exec(e);s&&(s=s[0],s!==":"&&(this.port=s.substr(1)),e=e.substr(0,e.length-s.length)),e&&(this.hostname=e)};function Se(e,s){for(var t=0,l=e.length-1;l>=0;l--){var _=e[l];_==="."?e.splice(l,1):_===".."?(e.splice(l,1),t++):t&&(e.splice(l,1),t--)}if(s)for(;t--;t)e.unshift("..");return e}function i(){for(var e="",s=!1,t=arguments.length-1;t>=-1&&!s;t--){var l=t>=0?arguments[t]:"/";if(typeof l!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!l)continue;e=l+"/"+e,s=l.charAt(0)==="/"}return e=Se(p(e.split("/"),function(_){return!!_}),!s).join("/"),(s?"/":"")+e||"."}function p(e,s){if(e.filter)return e.filter(s);for(var t=[],l=0;l<e.length;l++)s(e[l],l,e)&&t.push(e[l]);return t}var y=function(e){function s(){var l=this||self;return delete e.prototype.__magic__,l}if(typeof globalThis=="object")return globalThis;if(this)return s();e.defineProperty(e.prototype,"__magic__",{configurable:!0,get:s});var t=__magic__;return t}(Object),b=te,w=C,U=m,q=ae,R=y.URL,N=y.URLSearchParams,B=/%/g,G=/\\/g,L=/\n/g,H=/\r/g,k=/\t/g,W=47;function Q(e){var s=e??null;return!!(s!==null&&(s!=null&&s.href)&&(s!=null&&s.origin))}function me(e){if(e.hostname!=="")throw new TypeError('File URL host must be "localhost" or empty on browser');for(var s=e.pathname,t=0;t<s.length;t++)if(s[t]==="%"){var l=s.codePointAt(t+2)|32;if(s[t+1]==="2"&&l===102)throw new TypeError("File URL path must not include encoded / characters")}return decodeURIComponent(s)}function nt(e){return e.includes("%")&&(e=e.replace(B,"%25")),e.includes("\\")&&(e=e.replace(G,"%5C")),e.includes(`
3
+ `)&&(e=e.replace(L,"%0A")),e.includes("\r")&&(e=e.replace(H,"%0D")),e.includes(" ")&&(e=e.replace(k,"%09")),e}var De=function(s){if(typeof s>"u")throw new TypeError('The "domain" argument must be specified');return new R("http://"+s).hostname},Be=function(s){if(typeof s>"u")throw new TypeError('The "domain" argument must be specified');return new R("http://"+s).hostname},Ge=function(s){var t=new R("file://"),l=i(s),_=s.charCodeAt(s.length-1);return _===W&&l[l.length-1]!=="/"&&(l+="/"),t.pathname=nt(l),t},ze=function(s){if(!Q(s)&&typeof s!="string")throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof s+" ("+s+")");var t=new R(s);if(t.protocol!=="file:")throw new TypeError("The URL must be of scheme file");return me(t)},Xe=function(s,t){var l,_,D;if(t===void 0&&(t={}),!(s instanceof R))return b(s);if(typeof t!="object"||t===null)throw new TypeError('The "options" argument must be of type object.');var j=(l=t.auth)!=null?l:!0,c=(_=t.fragment)!=null?_:!0,K=(D=t.search)!=null?D:!0,x=new R(s.toString());return j||(x.username="",x.password=""),c||(x.hash=""),K||(x.search=""),x.toString()},We={format:Xe,parse:w,resolve:U,resolveObject:A,Url:q,URL:R,URLSearchParams:N,domainToASCII:De,domainToUnicode:Be,pathToFileURL:Ge,fileURLToPath:ze};r.URL=R,r.URLSearchParams=N,r.Url=q,r.default=We,r.domainToASCII=De,r.domainToUnicode=Be,r.fileURLToPath=ze,r.format=Xe,r.parse=w,r.pathToFileURL=Ge,r.resolve=U,r.resolveObject=A,r=o.exports=We})(He,He.exports);var rt=He.exports;(function(o){var r=dt,h=xe,f=mt,n=gt,g=rt,u=o;u.request=function(a,v){typeof a=="string"?a=g.parse(a):a=f(a);var T=P.location.protocol.search(/^https?:$/)===-1?"http:":"",C=a.protocol||T,m=a.hostname||a.host,A=a.port,te=a.path||"/";m&&m.indexOf(":")!==-1&&(m="["+m+"]"),a.url=(m?C+"//"+m:"")+(A?":"+A:"")+te,a.method=(a.method||"GET").toUpperCase(),a.headers=a.headers||{};var ae=new r(a);return v&&ae.on("response",v),ae},u.get=function(v,T){var C=u.request(v,T);return C.end(),C},u.ClientRequest=r,u.IncomingMessage=h.IncomingMessage,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.globalAgent=new u.Agent,u.STATUS_CODES=n,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]})(Je);var ot={exports:{}};(function(o){var r=Je,h=rt,f=o.exports;for(var n in r)r.hasOwnProperty(n)&&(f[n]=r[n]);f.request=function(u,a){return u=g(u),r.request.call(this,u,a)},f.get=function(u,a){return u=g(u),r.get.call(this,u,a)};function g(u){if(typeof u=="string"&&(u=h.parse(u)),u.protocol||(u.protocol="https:"),u.protocol!=="https:")throw new Error('Protocol "'+u.protocol+'" not supported. Expected "https:"');return u}})(ot);var Tt=ot.exports;export{Tt as h,Je as s,rt as u};
@@ -0,0 +1,2 @@
1
+ const __vite__fileDeps=["assets/index-D0lqVeXm.js","assets/dijkstra-D_NXgYpA.js","main.js","main.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
2
+ import{_ as fe}from"../main.js";const me=Symbol(),ee=Object.getPrototypeOf,G=new WeakMap,ge=e=>e&&(G.has(e)?G.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),he=e=>ge(e)&&e[me]||null,te=(e,t=!0)=>{G.set(e,t)};var z={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1,REACT_APP_CONNECT_VERSION:"0.3.9"};const q=e=>typeof e=="object"&&e!==null,A=new WeakMap,x=new WeakSet,be=(e=Object.is,t=(n,h)=>new Proxy(n,h),s=n=>q(n)&&!x.has(n)&&(Array.isArray(n)||!(Symbol.iterator in n))&&!(n instanceof WeakMap)&&!(n instanceof WeakSet)&&!(n instanceof Error)&&!(n instanceof Number)&&!(n instanceof Date)&&!(n instanceof String)&&!(n instanceof RegExp)&&!(n instanceof ArrayBuffer),r=n=>{switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n}},l=new WeakMap,c=(n,h,I=r)=>{const y=l.get(n);if((y==null?void 0:y[0])===h)return y[1];const v=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return te(v,!0),l.set(n,[h,v]),Reflect.ownKeys(n).forEach(S=>{if(Object.getOwnPropertyDescriptor(v,S))return;const L=Reflect.get(n,S),M={value:L,enumerable:!0,configurable:!0};if(x.has(L))te(L,!1);else if(L instanceof Promise)delete M.value,M.get=()=>I(L);else if(A.has(L)){const[b,H]=A.get(L);M.value=c(b,H(),I)}Object.defineProperty(v,S,M)}),Object.preventExtensions(v)},m=new WeakMap,f=[1,1],W=n=>{if(!q(n))throw new Error("object required");const h=m.get(n);if(h)return h;let I=f[0];const y=new Set,v=(a,i=++f[0])=>{I!==i&&(I=i,y.forEach(o=>o(a,i)))};let S=f[1];const L=(a=++f[1])=>(S!==a&&!y.size&&(S=a,b.forEach(([i])=>{const o=i[1](a);o>I&&(I=o)})),I),M=a=>(i,o)=>{const g=[...i];g[1]=[a,...g[1]],v(g,o)},b=new Map,H=(a,i)=>{if((z?"production":void 0)!=="production"&&b.has(a))throw new Error("prop listener already exists");if(y.size){const o=i[3](M(a));b.set(a,[i,o])}else b.set(a,[i])},Z=a=>{var i;const o=b.get(a);o&&(b.delete(a),(i=o[1])==null||i.call(o))},ue=a=>(y.add(a),y.size===1&&b.forEach(([o,g],_)=>{if((z?"production":void 0)!=="production"&&g)throw new Error("remove already exists");const R=o[3](M(_));b.set(_,[o,R])}),()=>{y.delete(a),y.size===0&&b.forEach(([o,g],_)=>{g&&(g(),b.set(_,[o]))})}),J=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),$=t(J,{deleteProperty(a,i){const o=Reflect.get(a,i);Z(i);const g=Reflect.deleteProperty(a,i);return g&&v(["delete",[i],o]),g},set(a,i,o,g){const _=Reflect.has(a,i),R=Reflect.get(a,i,g);if(_&&(e(R,o)||m.has(o)&&e(R,m.get(o))))return!0;Z(i),q(o)&&(o=he(o)||o);let V=o;if(o instanceof Promise)o.then(C=>{o.status="fulfilled",o.value=C,v(["resolve",[i],C])}).catch(C=>{o.status="rejected",o.reason=C,v(["reject",[i],C])});else{!A.has(o)&&s(o)&&(V=W(o));const C=!x.has(V)&&A.get(V);C&&H(i,C)}return Reflect.set(a,i,V,g),v(["set",[i],o,R]),!0}});m.set(n,$);const pe=[J,L,c,ue];return A.set($,pe),Reflect.ownKeys(n).forEach(a=>{const i=Object.getOwnPropertyDescriptor(n,a);"value"in i&&($[a]=n[a],delete i.value,delete i.writable),Object.defineProperty(J,a,i)}),$})=>[W,A,x,e,t,s,r,l,c,m,f],[ye]=be();function j(e={}){return ye(e)}function D(e,t,s){const r=A.get(e);(z?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let l;const c=[],m=r[3];let f=!1;const n=m(h=>{if(c.push(h),s){t(c.splice(0));return}l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,n()}}function ve(e,t){const s=A.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,l,c]=s;return c(r,l(),t)}const d=j({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:d,subscribe(e){return D(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},p={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return p.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return p.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(p.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!p.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(p.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(p.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),u=j({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:u,subscribe(e){return D(u.events,()=>e(ve(u.events[u.events.length-1])))},initialize(){u.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(u.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){u.connectedWalletId=e},click(e){if(u.enabled){const t={type:"CLICK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},track(e){if(u.enabled){const t={type:"TRACK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},view(e){if(u.enabled){const t={type:"VIEW",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}}},E=j({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:E,subscribe(e){return D(E,()=>e(E))},setChains(e){E.chains=e},setWalletConnectUri(e){E.walletConnectUri=e},setIsCustomDesktop(e){E.isCustomDesktop=e},setIsCustomMobile(e){E.isCustomMobile=e},setIsDataLoaded(e){E.isDataLoaded=e},setIsUiLoaded(e){E.isUiLoaded=e},setIsAuth(e){E.isAuth=e}},B=j({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),N={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),p.setModalVersionInStorage(),Object.assign(B,e)}};var Ee=Object.defineProperty,se=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Oe.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Le.call(t,s)&&ne(e,s,t[s]);return e};const Q="https://explorer-api.walletconnect.com",X="wcm",Y="js-2.6.2";async function K(e,t){const s=We({sdkType:X,sdkVersion:Y},t),r=new URL(e,Q);return r.searchParams.append("projectId",N.state.projectId),Object.entries(s).forEach(([l,c])=>{c&&r.searchParams.append(l,String(c))}),(await fetch(r)).json()}const U={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${Q}/w3m/v1/getWalletImage/${e}?projectId=${N.state.projectId}&sdkType=${X}&sdkVersion=${Y}`},getAssetImageUrl(e){return`${Q}/w3m/v1/getAssetImage/${e}?projectId=${N.state.projectId}&sdkType=${X}&sdkVersion=${Y}`}};var Ce=Object.defineProperty,oe=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Me=(e,t)=>{for(var s in t||(t={}))Ae.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))je.call(t,s)&&re(e,s,t[s]);return e};const ie=p.isMobile(),O=j({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Te={state:O,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=N.state;if(e==="NONE"||t==="ALL"&&!e)return O.recomendedWallets;if(p.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await U.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const f=e.indexOf(c.id),W=e.indexOf(m.id);return f-W}),O.recomendedWallets=l}else{const{chains:s,isAuth:r}=w.state,l=s==null?void 0:s.join(","),c=p.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:p.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ie?await U.getMobileListings(m):await U.getDesktopListings(m);O.recomendedWallets=Object.values(f)}return O.recomendedWallets},async getWallets(e){const t=Me({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=N.state,{recomendedWallets:l}=O;if(r==="ALL")return O.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):p.isArray(s)&&(t.excludedIds=s.join(",")),p.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:f,total:W}=ie?await U.getMobileListings(t):await U.getDesktopListings(t),n=Object.values(f),h=m?"search":"wallets";return O[h]={listings:[...O[h].listings,...n],total:W,page:c??1},{listings:n,total:W}},getWalletImageUrl(e){return U.getWalletImageUrl(e)},getAssetImageUrl(e){return U.getAssetImageUrl(e)},resetSearch(){O.search={listings:[],total:0,page:1}}},k=j({open:!1}),F={state:k,subscribe(e){return D(k,()=>e(k))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=w.state;if(p.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&r)k.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),k.open=!0,t())},200)}})},close(){k.open=!1}};var Ue=Object.defineProperty,ae=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Se=(e,t)=>{for(var s in t||(t={}))Pe.call(t,s)&&le(e,s,t[s]);if(ae)for(var s of ae(t))De.call(t,s)&&le(e,s,t[s]);return e};function _e(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const T=j({themeMode:_e()?"dark":"light"}),ce={state:T,subscribe(e){return D(T,()=>e(T))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(T.themeMode=t),s&&(T.themeVariables=Se({},s))}},P=j({open:!1,message:"",variant:"success"}),$e={state:P,subscribe(e){return D(P,()=>e(P))},openToast(e,t){P.open=!0,P.message=e,P.variant=t},closeToast(){P.open=!1}};class ke{constructor(t){this.openModal=F.open,this.closeModal=F.close,this.subscribeModal=F.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),N.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await fe(()=>import("./index-D0lqVeXm.js"),__vite__mapDeps([0,1,2,3]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:ke},Symbol.toStringTag,{value:"Module"}));export{Ie as R,de as T,p as a,Ve as i,ce as n,$e as o,w as p,F as s,Te as t,N as y};
@@ -1,4 +1,4 @@
1
- import{n as _t,s as ce,T as N,t as U,a as C,o as ot,R as Bo,p as q,y as gt}from"./index-BGRtIcKb.js";import{d as Do}from"./dijkstra-D_NXgYpA.js";import"../main.js";var Uo=function(t){for(var r=[],n=t.length,o=0;o<n;o++){var i=t.charCodeAt(o);if(i>=55296&&i<=56319&&n>o+1){var s=t.charCodeAt(o+1);s>=56320&&s<=57343&&(i=(i-55296)*1024+s-56320+65536,o+=1)}if(i<128){r.push(i);continue}if(i<2048){r.push(i>>6|192),r.push(i&63|128);continue}if(i<55296||i>=57344&&i<65536){r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128);continue}if(i>=65536&&i<=1114111){r.push(i>>18|240),r.push(i>>12&63|128),r.push(i>>6&63|128),r.push(i&63|128);continue}r.push(239,191,189)}return new Uint8Array(r).buffer};/**
1
+ import{n as _t,s as ce,T as N,t as U,a as C,o as ot,R as Bo,p as q,y as gt}from"./index-CaMXNKLm.js";import{d as Do}from"./dijkstra-D_NXgYpA.js";import"../main.js";var Uo=function(t){for(var r=[],n=t.length,o=0;o<n;o++){var i=t.charCodeAt(o);if(i>=55296&&i<=56319&&n>o+1){var s=t.charCodeAt(o+1);s>=56320&&s<=57343&&(i=(i-55296)*1024+s-56320+65536,o+=1)}if(i<128){r.push(i);continue}if(i<2048){r.push(i>>6|192),r.push(i&63|128);continue}if(i<55296||i>=57344&&i<65536){r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128);continue}if(i>=65536&&i<=1114111){r.push(i>>18|240),r.push(i>>12&63|128),r.push(i>>6&63|128),r.push(i&63|128);continue}r.push(239,191,189)}return new Uint8Array(r).buffer};/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1,4 +1,4 @@
1
- const __vite__fileDeps=["assets/index-BGRtIcKb.js","main.js","main.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
1
+ const __vite__fileDeps=["assets/index-CaMXNKLm.js","main.js","main.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
2
2
  import{q as Jv,g as Qv,aY as eu,d as Mo,aZ as Vv,_ as Kv}from"../main.js";import{U as Xi,k as Or,e as Ir,B as Zv,o as ru,S as Qi,v as Yv,a as Xv}from"./index.es-uF2MhMD8.js";import{i as Bo,f as tg,p as eg,c as Lo,a as rg,o as ng,Q as ig,J as Ie}from"./index.es-DJroPFoU.js";var ts={exports:{}};(function(b,s){var i=typeof self<"u"?self:Jv,f=function(){function P(){this.fetch=!1,this.DOMException=i.DOMException}return P.prototype=i,new P}();(function(P){(function(O){var L={searchParams:"URLSearchParams"in P,iterable:"Symbol"in P&&"iterator"in Symbol,blob:"FileReader"in P&&"Blob"in P&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in P,arrayBuffer:"ArrayBuffer"in P};function ot(v){return v&&DataView.prototype.isPrototypeOf(v)}if(L.arrayBuffer)var it=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],lt=ArrayBuffer.isView||function(v){return v&&it.indexOf(Object.prototype.toString.call(v))>-1};function nt(v){if(typeof v!="string"&&(v=String(v)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(v))throw new TypeError("Invalid character in header field name");return v.toLowerCase()}function pt(v){return typeof v!="string"&&(v=String(v)),v}function ut(v){var E={next:function(){var R=v.shift();return{done:R===void 0,value:R}}};return L.iterable&&(E[Symbol.iterator]=function(){return E}),E}function G(v){this.map={},v instanceof G?v.forEach(function(E,R){this.append(R,E)},this):Array.isArray(v)?v.forEach(function(E){this.append(E[0],E[1])},this):v&&Object.getOwnPropertyNames(v).forEach(function(E){this.append(E,v[E])},this)}G.prototype.append=function(v,E){v=nt(v),E=pt(E);var R=this.map[v];this.map[v]=R?R+", "+E:E},G.prototype.delete=function(v){delete this.map[nt(v)]},G.prototype.get=function(v){return v=nt(v),this.has(v)?this.map[v]:null},G.prototype.has=function(v){return this.map.hasOwnProperty(nt(v))},G.prototype.set=function(v,E){this.map[nt(v)]=pt(E)},G.prototype.forEach=function(v,E){for(var R in this.map)this.map.hasOwnProperty(R)&&v.call(E,this.map[R],R,this)},G.prototype.keys=function(){var v=[];return this.forEach(function(E,R){v.push(R)}),ut(v)},G.prototype.values=function(){var v=[];return this.forEach(function(E){v.push(E)}),ut(v)},G.prototype.entries=function(){var v=[];return this.forEach(function(E,R){v.push([R,E])}),ut(v)},L.iterable&&(G.prototype[Symbol.iterator]=G.prototype.entries);function pe(v){if(v.bodyUsed)return Promise.reject(new TypeError("Already read"));v.bodyUsed=!0}function _t(v){return new Promise(function(E,R){v.onload=function(){E(v.result)},v.onerror=function(){R(v.error)}})}function Xt(v){var E=new FileReader,R=_t(E);return E.readAsArrayBuffer(v),R}function jr(v){var E=new FileReader,R=_t(E);return E.readAsText(v),R}function $t(v){for(var E=new Uint8Array(v),R=new Array(E.length),K=0;K<E.length;K++)R[K]=String.fromCharCode(E[K]);return R.join("")}function te(v){if(v.slice)return v.slice(0);var E=new Uint8Array(v.byteLength);return E.set(new Uint8Array(v)),E.buffer}function It(){return this.bodyUsed=!1,this._initBody=function(v){this._bodyInit=v,v?typeof v=="string"?this._bodyText=v:L.blob&&Blob.prototype.isPrototypeOf(v)?this._bodyBlob=v:L.formData&&FormData.prototype.isPrototypeOf(v)?this._bodyFormData=v:L.searchParams&&URLSearchParams.prototype.isPrototypeOf(v)?this._bodyText=v.toString():L.arrayBuffer&&L.blob&&ot(v)?(this._bodyArrayBuffer=te(v.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):L.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(v)||lt(v))?this._bodyArrayBuffer=te(v):this._bodyText=v=Object.prototype.toString.call(v):this._bodyText="",this.headers.get("content-type")||(typeof v=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):L.searchParams&&URLSearchParams.prototype.isPrototypeOf(v)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},L.blob&&(this.blob=function(){var v=pe(this);if(v)return v;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?pe(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(Xt)}),this.text=function(){var v=pe(this);if(v)return v;if(this._bodyBlob)return jr(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve($t(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},L.formData&&(this.formData=function(){return this.text().then(Xe)}),this.json=function(){return this.text().then(JSON.parse)},this}var de=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function Ut(v){var E=v.toUpperCase();return de.indexOf(E)>-1?E:v}function At(v,E){E=E||{};var R=E.body;if(v instanceof At){if(v.bodyUsed)throw new TypeError("Already read");this.url=v.url,this.credentials=v.credentials,E.headers||(this.headers=new G(v.headers)),this.method=v.method,this.mode=v.mode,this.signal=v.signal,!R&&v._bodyInit!=null&&(R=v._bodyInit,v.bodyUsed=!0)}else this.url=String(v);if(this.credentials=E.credentials||this.credentials||"same-origin",(E.headers||!this.headers)&&(this.headers=new G(E.headers)),this.method=Ut(E.method||this.method||"GET"),this.mode=E.mode||this.mode||null,this.signal=E.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&R)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(R)}At.prototype.clone=function(){return new At(this,{body:this._bodyInit})};function Xe(v){var E=new FormData;return v.trim().split("&").forEach(function(R){if(R){var K=R.split("="),J=K.shift().replace(/\+/g," "),U=K.join("=").replace(/\+/g," ");E.append(decodeURIComponent(J),decodeURIComponent(U))}}),E}function In(v){var E=new G,R=v.replace(/\r?\n[\t ]+/g," ");return R.split(/\r?\n/).forEach(function(K){var J=K.split(":"),U=J.shift().trim();if(U){var ee=J.join(":").trim();E.append(U,ee)}}),E}It.call(At.prototype);function Rt(v,E){E||(E={}),this.type="default",this.status=E.status===void 0?200:E.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in E?E.statusText:"OK",this.headers=new G(E.headers),this.url=E.url||"",this._initBody(v)}It.call(Rt.prototype),Rt.prototype.clone=function(){return new Rt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new G(this.headers),url:this.url})},Rt.error=function(){var v=new Rt(null,{status:0,statusText:""});return v.type="error",v};var An=[301,302,303,307,308];Rt.redirect=function(v,E){if(An.indexOf(E)===-1)throw new RangeError("Invalid status code");return new Rt(null,{status:E,headers:{location:v}})},O.DOMException=P.DOMException;try{new O.DOMException}catch{O.DOMException=function(E,R){this.message=E,this.name=R;var K=Error(E);this.stack=K.stack},O.DOMException.prototype=Object.create(Error.prototype),O.DOMException.prototype.constructor=O.DOMException}function tr(v,E){return new Promise(function(R,K){var J=new At(v,E);if(J.signal&&J.signal.aborted)return K(new O.DOMException("Aborted","AbortError"));var U=new XMLHttpRequest;function ee(){U.abort()}U.onload=function(){var dt={status:U.status,statusText:U.statusText,headers:In(U.getAllResponseHeaders()||"")};dt.url="responseURL"in U?U.responseURL:dt.headers.get("X-Request-URL");var er="response"in U?U.response:U.responseText;R(new Rt(er,dt))},U.onerror=function(){K(new TypeError("Network request failed"))},U.ontimeout=function(){K(new TypeError("Network request failed"))},U.onabort=function(){K(new O.DOMException("Aborted","AbortError"))},U.open(J.method,J.url,!0),J.credentials==="include"?U.withCredentials=!0:J.credentials==="omit"&&(U.withCredentials=!1),"responseType"in U&&L.blob&&(U.responseType="blob"),J.headers.forEach(function(dt,er){U.setRequestHeader(er,dt)}),J.signal&&(J.signal.addEventListener("abort",ee),U.onreadystatechange=function(){U.readyState===4&&J.signal.removeEventListener("abort",ee)}),U.send(typeof J._bodyInit>"u"?null:J._bodyInit)})}return tr.polyfill=!0,P.fetch||(P.fetch=tr,P.Headers=G,P.Request=At,P.Response=Rt),O.Headers=G,O.Request=At,O.Response=Rt,O.fetch=tr,Object.defineProperty(O,"__esModule",{value:!0}),O})({})})(f),f.fetch.ponyfill=!0,delete f.fetch.polyfill;var g=f;s=g.fetch,s.default=g.fetch,s.fetch=g.fetch,s.Headers=g.Headers,s.Request=g.Request,s.Response=g.Response,b.exports=s})(ts,ts.exports);var sg=ts.exports;const No=Qv(sg),ag=b=>JSON.stringify(b,(s,i)=>typeof i=="bigint"?i.toString()+"n":i),og=b=>{const s=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,i=b.replace(s,'$1"$2n"$3');return JSON.parse(i,(f,g)=>typeof g=="string"&&g.match(/^\d+n$/)?BigInt(g.substring(0,g.length-1)):g)};function ug(b){if(typeof b!="string")throw new Error(`Cannot safe json parse value of type ${typeof b}`);try{return og(b)}catch{return b}}function Fo(b){return typeof b=="string"?b:ag(b)||""}const cg={Accept:"application/json","Content-Type":"application/json"},hg="POST",Uo={headers:cg,method:hg},zo=10;class Ae{constructor(s,i=!1){if(this.url=s,this.disableProviderPing=i,this.events=new eu.EventEmitter,this.isAvailable=!1,this.registering=!1,!Bo(s))throw new Error(`Provided URL is not compatible with HTTP connection: ${s}`);this.url=s,this.disableProviderPing=i}get connected(){return this.isAvailable}get connecting(){return this.registering}on(s,i){this.events.on(s,i)}once(s,i){this.events.once(s,i)}off(s,i){this.events.off(s,i)}removeListener(s,i){this.events.removeListener(s,i)}async open(s=this.url){await this.register(s)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(s,i){this.isAvailable||await this.register();try{const f=Fo(s),P=await(await No(this.url,Object.assign(Object.assign({},Uo),{body:f}))).json();this.onPayload({data:P})}catch(f){this.onError(s.id,f)}}async register(s=this.url){if(!Bo(s))throw new Error(`Provided URL is not compatible with HTTP connection: ${s}`);if(this.registering){const i=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=i||this.events.listenerCount("open")>=i)&&this.events.setMaxListeners(i+1),new Promise((f,g)=>{this.events.once("register_error",P=>{this.resetMaxListeners(),g(P)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return g(new Error("HTTP connection is missing or invalid"));f()})})}this.url=s,this.registering=!0;try{if(!this.disableProviderPing){const i=Fo({id:1,jsonrpc:"2.0",method:"test",params:[]});await No(s,Object.assign(Object.assign({},Uo),{body:i}))}this.onOpen()}catch(i){const f=this.parseError(i);throw this.events.emit("register_error",f),this.onClose(),f}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(s){if(typeof s.data>"u")return;const i=typeof s.data=="string"?ug(s.data):s.data;this.events.emit("payload",i)}onError(s,i){const f=this.parseError(i),g=f.message||f.toString(),P=tg(s,g);this.events.emit("payload",P)}parseError(s,i=this.url){return eg(s,i,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>zo&&this.events.setMaxListeners(zo)}}const Wo="error",fg="wss://relay.walletconnect.com",lg="wc",pg="universal_provider",Go=`${lg}@2:${pg}:`,dg="https://rpc.walletconnect.com/v1/",le={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Cr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Mo.global<"u"?Mo.global:typeof self<"u"?self:{},es={exports:{}};/**
3
3
  * @license
4
4
  * Lodash <https://lodash.com/>
@@ -25,4 +25,4 @@ __p += '`),B&&(w+=`' +
25
25
  function print() { __p += __j.call(arguments, '') }
26
26
  `:`;
27
27
  `)+w+`return __p
28
- }`;var H=Ho(function(){return N(u,A+"return "+w).apply(i,c)});if(H.source=w,ki(H))throw H;return H}function tv(t){return F(t).toLowerCase()}function ev(t){return F(t).toUpperCase()}function rv(t,e,r){if(t=F(t),t&&(r||e===i))return Us(t);if(!t||!(e=xt(e)))return t;var n=Gt(t),a=Gt(e),u=zs(n,a),c=Ws(n,a)+1;return Pe(n,u,c).join("")}function nv(t,e,r){if(t=F(t),t&&(r||e===i))return t.slice(0,Js(t)+1);if(!t||!(e=xt(e)))return t;var n=Gt(t),a=Ws(n,Gt(e))+1;return Pe(n,0,a).join("")}function iv(t,e,r){if(t=F(t),t&&(r||e===i))return t.replace(kn,"");if(!t||!(e=xt(e)))return t;var n=Gt(t),a=zs(n,Gt(e));return Pe(n,a).join("")}function sv(t,e){var r=In,n=Rt;if(X(e)){var a="separator"in e?e.separator:a;r="length"in e?$(e.length):r,n="omission"in e?xt(e.omission):n}t=F(t);var u=t.length;if(Ne(t)){var c=Gt(t);u=c.length}if(r>=u)return t;var h=r-Fe(n);if(h<1)return n;var p=c?Pe(c,0,h).join(""):t.slice(0,h);if(a===i)return p+n;if(c&&(h+=p.length-h),Mi(a)){if(t.slice(h).search(a)){var m,y=p;for(a.global||(a=ti(a.source,F(fs.exec(a))+"g")),a.lastIndex=0;m=a.exec(y);)var w=m.index;p=p.slice(0,w===i?h:w)}}else if(t.indexOf(xt(a),h)!=h){var C=p.lastIndexOf(a);C>-1&&(p=p.slice(0,C))}return p+n}function av(t){return t=F(t),t&&gu.test(t)?t.replace(us,Rc):t}var ov=Ve(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Ni=Ha("toUpperCase");function Ro(t,e,r){return t=F(t),e=r?i:e,e===i?xc(t)?kc(t):wc(t):t.match(e)||[]}var Ho=q(function(t,e){try{return Ot(t,i,e)}catch(r){return ki(r)?r:new D(r)}}),uv=oe(function(t,e){return qt(e,function(r){r=Yt(r),se(t,r,Hi(t[r],t))}),t});function cv(t){var e=t==null?0:t.length,r=j();return t=e?Z(t,function(n){if(typeof n[1]!="function")throw new kt(O);return[r(n[0]),n[1]]}):[],q(function(n){for(var a=-1;++a<e;){var u=t[a];if(Ot(u[0],this,n))return Ot(u[1],this,n)}})}function hv(t){return Rh(Bt(t,nt))}function Fi(t){return function(){return t}}function fv(t,e){return t==null||t!==t?e:t}var lv=ka(),pv=ka(!0);function Ct(t){return t}function Ui(t){return pa(typeof t=="function"?t:Bt(t,nt))}function dv(t){return va(Bt(t,nt))}function vv(t,e){return ga(t,Bt(e,nt))}var gv=q(function(t,e){return function(r){return _r(r,t,e)}}),_v=q(function(t,e){return function(r){return _r(t,r,e)}});function zi(t,e,r){var n=ct(e),a=en(e,n);r==null&&!(X(e)&&(a.length||!n.length))&&(r=e,e=t,t=this,a=en(e,ct(e)));var u=!(X(r)&&"chain"in r)||!!r.chain,c=ce(t);return qt(a,function(h){var p=e[h];t[h]=p,c&&(t.prototype[h]=function(){var m=this.__chain__;if(u||m){var y=t(this.__wrapped__),w=y.__actions__=bt(this.__actions__);return w.push({func:p,args:arguments,thisArg:t}),y.__chain__=m,y}return p.apply(t,ge([this.value()],arguments))})}),t}function mv(){return ht._===this&&(ht._=Uc),this}function Wi(){}function yv(t){return t=$(t),q(function(e){return _a(e,t)})}var wv=Pi(Z),bv=Pi(Ms),Pv=Pi(Jn);function qo(t){return xi(t)?Qn(Yt(t)):Zh(t)}function Ev(t){return function(e){return t==null?i:Te(t,e)}}var Cv=Ba(),Iv=Ba(!0);function Gi(){return[]}function Ji(){return!1}function Av(){return{}}function Ov(){return""}function jv(){return!0}function xv(t,e){if(t=$(t),t<1||t>J)return[];var r=dt,n=vt(t,dt);e=j(e),t-=dt;for(var a=Zn(n,e);++r<t;)e(r);return a}function Sv(t){return T(t)?Z(t,Yt):St(t)?[t]:bt(eo(F(t)))}function Dv(t){var e=++Nc;return F(t)+e}var Tv=un(function(t,e){return t+e},0),$v=Ei("ceil"),Rv=un(function(t,e){return t/e},1),Hv=Ei("floor");function qv(t){return t&&t.length?tn(t,Ct,ui):i}function kv(t,e){return t&&t.length?tn(t,j(e,2),ui):i}function Mv(t){return Ns(t,Ct)}function Bv(t,e){return Ns(t,j(e,2))}function Lv(t){return t&&t.length?tn(t,Ct,li):i}function Nv(t,e){return t&&t.length?tn(t,j(e,2),li):i}var Fv=un(function(t,e){return t*e},1),Uv=Ei("round"),zv=un(function(t,e){return t-e},0);function Wv(t){return t&&t.length?Kn(t,Ct):0}function Gv(t,e){return t&&t.length?Kn(t,j(e,2)):0}return o.after=dp,o.ary=lo,o.assign=ed,o.assignIn=Oo,o.assignInWith=bn,o.assignWith=rd,o.at=nd,o.before=po,o.bind=Hi,o.bindAll=uv,o.bindKey=vo,o.castArray=Ap,o.chain=co,o.chunk=Hf,o.compact=qf,o.concat=kf,o.cond=cv,o.conforms=hv,o.constant=Fi,o.countBy=Wl,o.create=id,o.curry=go,o.curryRight=_o,o.debounce=mo,o.defaults=sd,o.defaultsDeep=ad,o.defer=vp,o.delay=gp,o.difference=Mf,o.differenceBy=Bf,o.differenceWith=Lf,o.drop=Nf,o.dropRight=Ff,o.dropRightWhile=Uf,o.dropWhile=zf,o.fill=Wf,o.filter=Jl,o.flatMap=Kl,o.flatMapDeep=Zl,o.flatMapDepth=Yl,o.flatten=so,o.flattenDeep=Gf,o.flattenDepth=Jf,o.flip=_p,o.flow=lv,o.flowRight=pv,o.fromPairs=Qf,o.functions=pd,o.functionsIn=dd,o.groupBy=Xl,o.initial=Kf,o.intersection=Zf,o.intersectionBy=Yf,o.intersectionWith=Xf,o.invert=gd,o.invertBy=_d,o.invokeMap=ep,o.iteratee=Ui,o.keyBy=rp,o.keys=ct,o.keysIn=Et,o.map=vn,o.mapKeys=yd,o.mapValues=wd,o.matches=dv,o.matchesProperty=vv,o.memoize=_n,o.merge=bd,o.mergeWith=jo,o.method=gv,o.methodOf=_v,o.mixin=zi,o.negate=mn,o.nthArg=yv,o.omit=Pd,o.omitBy=Ed,o.once=mp,o.orderBy=np,o.over=wv,o.overArgs=yp,o.overEvery=bv,o.overSome=Pv,o.partial=qi,o.partialRight=yo,o.partition=ip,o.pick=Cd,o.pickBy=xo,o.property=qo,o.propertyOf=Ev,o.pull=nl,o.pullAll=oo,o.pullAllBy=il,o.pullAllWith=sl,o.pullAt=al,o.range=Cv,o.rangeRight=Iv,o.rearg=wp,o.reject=op,o.remove=ol,o.rest=bp,o.reverse=$i,o.sampleSize=cp,o.set=Ad,o.setWith=Od,o.shuffle=hp,o.slice=ul,o.sortBy=pp,o.sortedUniq=vl,o.sortedUniqBy=gl,o.split=Kd,o.spread=Pp,o.tail=_l,o.take=ml,o.takeRight=yl,o.takeRightWhile=wl,o.takeWhile=bl,o.tap=ql,o.throttle=Ep,o.thru=dn,o.toArray=Co,o.toPairs=So,o.toPairsIn=Do,o.toPath=Sv,o.toPlainObject=Ao,o.transform=jd,o.unary=Cp,o.union=Pl,o.unionBy=El,o.unionWith=Cl,o.uniq=Il,o.uniqBy=Al,o.uniqWith=Ol,o.unset=xd,o.unzip=Ri,o.unzipWith=uo,o.update=Sd,o.updateWith=Dd,o.values=Ye,o.valuesIn=Td,o.without=jl,o.words=Ro,o.wrap=Ip,o.xor=xl,o.xorBy=Sl,o.xorWith=Dl,o.zip=Tl,o.zipObject=$l,o.zipObjectDeep=Rl,o.zipWith=Hl,o.entries=So,o.entriesIn=Do,o.extend=Oo,o.extendWith=bn,zi(o,o),o.add=Tv,o.attempt=Ho,o.camelCase=qd,o.capitalize=To,o.ceil=$v,o.clamp=$d,o.clone=Op,o.cloneDeep=xp,o.cloneDeepWith=Sp,o.cloneWith=jp,o.conformsTo=Dp,o.deburr=$o,o.defaultTo=fv,o.divide=Rv,o.endsWith=kd,o.eq=Qt,o.escape=Md,o.escapeRegExp=Bd,o.every=Gl,o.find=Ql,o.findIndex=no,o.findKey=od,o.findLast=Vl,o.findLastIndex=io,o.findLastKey=ud,o.floor=Hv,o.forEach=ho,o.forEachRight=fo,o.forIn=cd,o.forInRight=hd,o.forOwn=fd,o.forOwnRight=ld,o.get=Bi,o.gt=Tp,o.gte=$p,o.has=vd,o.hasIn=Li,o.head=ao,o.identity=Ct,o.includes=tp,o.indexOf=Vf,o.inRange=Rd,o.invoke=md,o.isArguments=He,o.isArray=T,o.isArrayBuffer=Rp,o.isArrayLike=Pt,o.isArrayLikeObject=et,o.isBoolean=Hp,o.isBuffer=Ee,o.isDate=qp,o.isElement=kp,o.isEmpty=Mp,o.isEqual=Bp,o.isEqualWith=Lp,o.isError=ki,o.isFinite=Np,o.isFunction=ce,o.isInteger=wo,o.isLength=yn,o.isMap=bo,o.isMatch=Fp,o.isMatchWith=Up,o.isNaN=zp,o.isNative=Wp,o.isNil=Jp,o.isNull=Gp,o.isNumber=Po,o.isObject=X,o.isObjectLike=tt,o.isPlainObject=Er,o.isRegExp=Mi,o.isSafeInteger=Qp,o.isSet=Eo,o.isString=wn,o.isSymbol=St,o.isTypedArray=Ze,o.isUndefined=Vp,o.isWeakMap=Kp,o.isWeakSet=Zp,o.join=tl,o.kebabCase=Ld,o.last=Nt,o.lastIndexOf=el,o.lowerCase=Nd,o.lowerFirst=Fd,o.lt=Yp,o.lte=Xp,o.max=qv,o.maxBy=kv,o.mean=Mv,o.meanBy=Bv,o.min=Lv,o.minBy=Nv,o.stubArray=Gi,o.stubFalse=Ji,o.stubObject=Av,o.stubString=Ov,o.stubTrue=jv,o.multiply=Fv,o.nth=rl,o.noConflict=mv,o.noop=Wi,o.now=gn,o.pad=Ud,o.padEnd=zd,o.padStart=Wd,o.parseInt=Gd,o.random=Hd,o.reduce=sp,o.reduceRight=ap,o.repeat=Jd,o.replace=Qd,o.result=Id,o.round=Uv,o.runInContext=l,o.sample=up,o.size=fp,o.snakeCase=Vd,o.some=lp,o.sortedIndex=cl,o.sortedIndexBy=hl,o.sortedIndexOf=fl,o.sortedLastIndex=ll,o.sortedLastIndexBy=pl,o.sortedLastIndexOf=dl,o.startCase=Zd,o.startsWith=Yd,o.subtract=zv,o.sum=Wv,o.sumBy=Gv,o.template=Xd,o.times=xv,o.toFinite=he,o.toInteger=$,o.toLength=Io,o.toLower=tv,o.toNumber=Ft,o.toSafeInteger=td,o.toString=F,o.toUpper=ev,o.trim=rv,o.trimEnd=nv,o.trimStart=iv,o.truncate=sv,o.unescape=av,o.uniqueId=Dv,o.upperCase=ov,o.upperFirst=Ni,o.each=ho,o.eachRight=fo,o.first=ao,zi(o,function(){var t={};return Kt(o,function(e,r){z.call(o.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),o.VERSION=f,qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){o[t].placeholder=o}),qt(["drop","take"],function(t,e){M.prototype[t]=function(r){r=r===i?1:at($(r),0);var n=this.__filtered__&&!e?new M(this):this.clone();return n.__filtered__?n.__takeCount__=vt(r,n.__takeCount__):n.__views__.push({size:vt(r,dt),type:t+(n.__dir__<0?"Right":"")}),n},M.prototype[t+"Right"]=function(r){return this.reverse()[t](r).reverse()}}),qt(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==v||r==R;M.prototype[t]=function(a){var u=this.clone();return u.__iteratees__.push({iteratee:j(a,3),type:r}),u.__filtered__=u.__filtered__||n,u}}),qt(["head","last"],function(t,e){var r="take"+(e?"Right":"");M.prototype[t]=function(){return this[r](1).value()[0]}}),qt(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");M.prototype[t]=function(){return this.__filtered__?new M(this):this[r](1)}}),M.prototype.compact=function(){return this.filter(Ct)},M.prototype.find=function(t){return this.filter(t).head()},M.prototype.findLast=function(t){return this.reverse().find(t)},M.prototype.invokeMap=q(function(t,e){return typeof t=="function"?new M(this):this.map(function(r){return _r(r,t,e)})}),M.prototype.reject=function(t){return this.filter(mn(j(t)))},M.prototype.slice=function(t,e){t=$(t);var r=this;return r.__filtered__&&(t>0||e<0)?new M(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==i&&(e=$(e),r=e<0?r.dropRight(-e):r.take(e-t)),r)},M.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},M.prototype.toArray=function(){return this.take(dt)},Kt(M.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),a=o[n?"take"+(e=="last"?"Right":""):e],u=n||/^find/.test(e);a&&(o.prototype[e]=function(){var c=this.__wrapped__,h=n?[1]:arguments,p=c instanceof M,m=h[0],y=p||T(c),w=function(k){var B=a.apply(o,ge([k],h));return n&&C?B[0]:B};y&&r&&typeof m=="function"&&m.length!=1&&(p=y=!1);var C=this.__chain__,A=!!this.__actions__.length,x=u&&!C,H=p&&!A;if(!u&&y){c=H?c:new M(this);var S=t.apply(c,h);return S.__actions__.push({func:dn,args:[w],thisArg:i}),new Mt(S,C)}return x&&H?t.apply(this,h):(S=this.thru(w),x?n?S.value()[0]:S.value():S)})}),qt(["pop","push","shift","sort","splice","unshift"],function(t){var e=Br[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);o.prototype[t]=function(){var a=arguments;if(n&&!this.__chain__){var u=this.value();return e.apply(T(u)?u:[],a)}return this[r](function(c){return e.apply(T(c)?c:[],a)})}}),Kt(M.prototype,function(t,e){var r=o[e];if(r){var n=r.name+"";z.call(Ge,n)||(Ge[n]=[]),Ge[n].push({name:e,func:r})}}),Ge[on(i,Xt).name]=[{name:"wrapper",func:i}],M.prototype.clone=sh,M.prototype.reverse=ah,M.prototype.value=oh,o.prototype.at=kl,o.prototype.chain=Ml,o.prototype.commit=Bl,o.prototype.next=Ll,o.prototype.plant=Fl,o.prototype.reverse=Ul,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=zl,o.prototype.first=o.prototype.head,hr&&(o.prototype[hr]=Nl),o},Ue=Mc();Oe?((Oe.exports=Ue)._=Ue,Un._=Ue):ht._=Ue}).call(Cr)})(es,es.exports);var vg=Object.defineProperty,gg=Object.defineProperties,_g=Object.getOwnPropertyDescriptors,Jo=Object.getOwnPropertySymbols,mg=Object.prototype.hasOwnProperty,yg=Object.prototype.propertyIsEnumerable,Qo=(b,s,i)=>s in b?vg(b,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[s]=i,Pn=(b,s)=>{for(var i in s||(s={}))mg.call(s,i)&&Qo(b,i,s[i]);if(Jo)for(var i of Jo(s))yg.call(s,i)&&Qo(b,i,s[i]);return b},wg=(b,s)=>gg(b,_g(s));function Ce(b,s,i){var f;const g=Yv(b);return((f=s.rpcMap)==null?void 0:f[g.reference])||`${dg}?chainId=${g.namespace}:${g.reference}&projectId=${i}`}function qe(b){return b.includes(":")?b.split(":")[1]:b}function nu(b){return b.map(s=>`${s.split(":")[0]}:${s.split(":")[1]}`)}function bg(b,s){const i=Object.keys(s.namespaces).filter(g=>g.includes(b));if(!i.length)return[];const f=[];return i.forEach(g=>{const P=s.namespaces[g].accounts;f.push(...P)}),f}function Pg(b={},s={}){const i=Vo(b),f=Vo(s);return es.exports.merge(i,f)}function Vo(b){var s,i,f,g;const P={};if(!Zv(b))return P;for(const[O,L]of Object.entries(b)){const ot=ru(O)?[O]:L.chains,it=L.methods||[],lt=L.events||[],nt=L.rpcMap||{},pt=Ir(O);P[pt]=wg(Pn(Pn({},P[pt]),L),{chains:Qi(ot,(s=P[pt])==null?void 0:s.chains),methods:Qi(it,(i=P[pt])==null?void 0:i.methods),events:Qi(lt,(f=P[pt])==null?void 0:f.events),rpcMap:Pn(Pn({},nt),(g=P[pt])==null?void 0:g.rpcMap)})}return P}function Eg(b){return b.includes(":")?b.split(":")[2]:b}function Cg(b){const s={};for(const[i,f]of Object.entries(b)){const g=f.methods||[],P=f.events||[],O=f.accounts||[],L=ru(i)?[i]:f.chains?f.chains:nu(f.accounts);s[i]={chains:L,methods:g,events:P,accounts:O}}return s}function Vi(b){return typeof b=="number"?b:b.includes("0x")?parseInt(b,16):b.includes(":")?Number(b.split(":")[1]):Number(b)}const iu={},Y=b=>iu[b],Ki=(b,s)=>{iu[b]=s};class Ig{constructor(s){this.name="polkadot",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getAccounts(){const s=this.namespace.accounts;return s?s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Ag{constructor(s){this.name="eip155",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(s){switch(s.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(s);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(s.request.method)?await this.client.request(s):this.getHttpProvider().request(s.request)}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(parseInt(s),i),this.chainId=parseInt(s),this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}createHttpProvider(s,i){const f=i||Ce(`${this.name}:${s}`,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=parseInt(qe(i));s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const s=this.chainId,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}async handleSwitchChain(s){var i,f;let g=s.request.params?(i=s.request.params[0])==null?void 0:i.chainId:"0x0";g=g.startsWith("0x")?g:`0x${g}`;const P=parseInt(g,16);if(this.isChainApproved(P))this.setDefaultChain(`${P}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:s.topic,request:{method:s.request.method,params:[{chainId:g}]},chainId:(f=this.namespace.chains)==null?void 0:f[0]}),this.setDefaultChain(`${P}`);else throw new Error(`Failed to switch to chain 'eip155:${P}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(s){return this.namespace.chains.includes(`${this.name}:${s}`)}}class Og{constructor(s){this.name="solana",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class jg{constructor(s){this.name="cosmos",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class xg{constructor(s){this.name="cip34",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{const f=this.getCardanoRPCUrl(i),g=qe(i);s[g]=this.createHttpProvider(g,f)}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}getCardanoRPCUrl(s){const i=this.namespace.rpcMap;if(i)return i[s]}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||this.getCardanoRPCUrl(s);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Sg{constructor(s){this.name="elrond",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Dg{constructor(s){this.name="multiversx",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Tg{constructor(s){this.name="near",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){if(this.chainId=s,!this.httpProviders[s]){const f=i||Ce(`${this.name}:${s}`,this.namespace);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);this.setHttpProvider(s,f)}this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const s=this.namespace.accounts;return s?s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;s[i]=this.createHttpProvider(i,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace);return typeof f>"u"?void 0:new Ie(new Ae(f,Y("disableProviderPing")))}}var $g=Object.defineProperty,Rg=Object.defineProperties,Hg=Object.getOwnPropertyDescriptors,Ko=Object.getOwnPropertySymbols,qg=Object.prototype.hasOwnProperty,kg=Object.prototype.propertyIsEnumerable,Zo=(b,s,i)=>s in b?$g(b,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[s]=i,En=(b,s)=>{for(var i in s||(s={}))qg.call(s,i)&&Zo(b,i,s[i]);if(Ko)for(var i of Ko(s))kg.call(s,i)&&Zo(b,i,s[i]);return b},Zi=(b,s)=>Rg(b,Hg(s));class is{constructor(s){this.events=new Vv,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=s,this.logger=typeof(s==null?void 0:s.logger)<"u"&&typeof(s==null?void 0:s.logger)!="string"?s.logger:Lo.pino(Lo.getDefaultLoggerOptions({level:(s==null?void 0:s.logger)||Wo})),this.disableProviderPing=(s==null?void 0:s.disableProviderPing)||!1}static async init(s){const i=new is(s);return await i.initialize(),i}async request(s,i){const[f,g]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(f).request({request:En({},s),chainId:`${f}:${g}`,topic:this.session.topic})}sendAsync(s,i,f){const g=new Date().getTime();this.request(s,f).then(P=>i(null,rg(g,P))).catch(P=>i(P,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var s;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(s=this.session)==null?void 0:s.topic,reason:Xi("USER_DISCONNECTED")}),await this.cleanup()}async connect(s){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(s),await this.cleanupPendingPairings(),!s.skipPairing)return await this.pair(s.pairingTopic)}on(s,i){this.events.on(s,i)}once(s,i){this.events.once(s,i)}removeListener(s,i){this.events.removeListener(s,i)}off(s,i){this.events.off(s,i)}get isWalletConnect(){return!0}async pair(s){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:f,approval:g}=await this.client.connect({pairingTopic:s,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});f&&(this.uri=f,this.events.emit("display_uri",f)),await g().then(P=>{this.session=P,this.namespaces||(this.namespaces=Cg(P.namespaces),this.persist("namespaces",this.namespaces))}).catch(P=>{if(P.message!==ng)throw P;i++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(s,i){try{if(!this.session)return;const[f,g]=this.validateChain(s);this.getProvider(f).setDefaultChain(g,i)}catch(f){if(!/Please call connect/.test(f.message))throw f}}async cleanupPendingPairings(s={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(Or(i)){for(const f of i)s.deletePairings?this.client.core.expirer.set(f.topic,0):await this.client.core.relayer.subscriber.unsubscribe(f.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const s=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[s]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await ig.init({logger:this.providerOpts.logger||Wo,relayUrl:this.providerOpts.relayUrl||fg,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const s=[...new Set(Object.keys(this.session.namespaces).map(i=>Ir(i)))];Ki("client",this.client),Ki("events",this.events),Ki("disableProviderPing",this.disableProviderPing),s.forEach(i=>{if(!this.session)return;const f=bg(i,this.session),g=nu(f),P=Pg(this.namespaces,this.optionalNamespaces),O=Zi(En({},P[i]),{accounts:f,chains:g});switch(i){case"eip155":this.rpcProviders[i]=new Ag({namespace:O});break;case"solana":this.rpcProviders[i]=new Og({namespace:O});break;case"cosmos":this.rpcProviders[i]=new jg({namespace:O});break;case"polkadot":this.rpcProviders[i]=new Ig({namespace:O});break;case"cip34":this.rpcProviders[i]=new xg({namespace:O});break;case"elrond":this.rpcProviders[i]=new Sg({namespace:O});break;case"multiversx":this.rpcProviders[i]=new Dg({namespace:O});break;case"near":this.rpcProviders[i]=new Tg({namespace:O});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",s=>{this.events.emit("session_ping",s)}),this.client.on("session_event",s=>{const{params:i}=s,{event:f}=i;if(f.name==="accountsChanged"){const g=f.data;g&&Or(g)&&this.events.emit("accountsChanged",g.map(Eg))}else if(f.name==="chainChanged"){const g=i.chainId,P=i.event.data,O=Ir(g),L=Vi(g)!==Vi(P)?`${O}:${Vi(P)}`:g;this.onChainChanged(L)}else this.events.emit(f.name,f.data);this.events.emit("session_event",s)}),this.client.on("session_update",({topic:s,params:i})=>{var f;const{namespaces:g}=i,P=(f=this.client)==null?void 0:f.session.get(s);this.session=Zi(En({},P),{namespaces:g}),this.onSessionUpdate(),this.events.emit("session_update",{topic:s,params:i})}),this.client.on("session_delete",async s=>{await this.cleanup(),this.events.emit("session_delete",s),this.events.emit("disconnect",Zi(En({},Xi("USER_DISCONNECTED")),{data:s.topic}))}),this.on(le.DEFAULT_CHAIN_CHANGED,s=>{this.onChainChanged(s,!0)})}getProvider(s){if(!this.rpcProviders[s])throw new Error(`Provider not found: ${s}`);return this.rpcProviders[s]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(s=>{var i;this.getProvider(s).updateNamespace((i=this.session)==null?void 0:i.namespaces[s])})}setNamespaces(s){const{namespaces:i,optionalNamespaces:f,sessionProperties:g}=s;i&&Object.keys(i).length&&(this.namespaces=i),f&&Object.keys(f).length&&(this.optionalNamespaces=f),this.sessionProperties=g,this.persist("namespaces",i),this.persist("optionalNamespaces",f)}validateChain(s){const[i,f]=(s==null?void 0:s.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[i,f];if(i&&!Object.keys(this.namespaces||{}).map(O=>Ir(O)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&f)return[i,f];const g=Ir(Object.keys(this.namespaces)[0]),P=this.rpcProviders[g].getDefaultChain();return[g,P]}async requestAccounts(){const[s]=this.validateChain();return await this.getProvider(s).requestAccounts()}onChainChanged(s,i=!1){var f;if(!this.namespaces)return;const[g,P]=this.validateChain(s);i||this.getProvider(g).setDefaultChain(P),((f=this.namespaces[g])!=null?f:this.namespaces[`${g}:${P}`]).defaultChain=P,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",P)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(s,i){this.client.core.storage.setItem(`${Go}/${s}`,i)}async getFromStore(s){return await this.client.core.storage.getItem(`${Go}/${s}`)}}const Mg=is,Bg="wc",Lg="ethereum_provider",Ng=`${Bg}@2:${Lg}:`,Fg="https://rpc.walletconnect.com/v1/",rs=["eth_sendTransaction","personal_sign"],Ug=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],ns=["chainChanged","accountsChanged"],zg=["chainChanged","accountsChanged","message","disconnect","connect"];var Wg=Object.defineProperty,Gg=Object.defineProperties,Jg=Object.getOwnPropertyDescriptors,Yo=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,Xo=(b,s,i)=>s in b?Wg(b,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[s]=i,Ar=(b,s)=>{for(var i in s||(s={}))Qg.call(s,i)&&Xo(b,i,s[i]);if(Yo)for(var i of Yo(s))Vg.call(s,i)&&Xo(b,i,s[i]);return b},tu=(b,s)=>Gg(b,Jg(s));function Cn(b){return Number(b[0].split(":")[1])}function Yi(b){return`0x${b.toString(16)}`}function Kg(b){const{chains:s,optionalChains:i,methods:f,optionalMethods:g,events:P,optionalEvents:O,rpcMap:L}=b;if(!Or(s))throw new Error("Invalid chains");const ot={chains:s,methods:f||rs,events:P||ns,rpcMap:Ar({},s.length?{[Cn(s)]:L[Cn(s)]}:{})},it=P==null?void 0:P.filter(ut=>!ns.includes(ut)),lt=f==null?void 0:f.filter(ut=>!rs.includes(ut));if(!i&&!O&&!g&&!(it!=null&&it.length)&&!(lt!=null&&lt.length))return{required:s.length?ot:void 0};const nt=(it==null?void 0:it.length)&&(lt==null?void 0:lt.length)||!i,pt={chains:[...new Set(nt?ot.chains.concat(i||[]):i)],methods:[...new Set(ot.methods.concat(g!=null&&g.length?g:Ug))],events:[...new Set(ot.events.concat(O!=null&&O.length?O:zg))],rpcMap:L};return{required:s.length?ot:void 0,optional:i.length?pt:void 0}}class ss{constructor(){this.events=new eu.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=Ng,this.on=(s,i)=>(this.events.on(s,i),this),this.once=(s,i)=>(this.events.once(s,i),this),this.removeListener=(s,i)=>(this.events.removeListener(s,i),this),this.off=(s,i)=>(this.events.off(s,i),this),this.parseAccount=s=>this.isCompatibleChainId(s)?this.parseAccountId(s).address:s,this.signer={},this.rpc={}}static async init(s){const i=new ss;return await i.initialize(s),i}async request(s){return await this.signer.request(s,this.formatChainId(this.chainId))}sendAsync(s,i){this.signer.sendAsync(s,i,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(s){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(s);const{required:i,optional:f}=Kg(this.rpc);try{const g=await new Promise(async(O,L)=>{var ot;this.rpc.showQrModal&&((ot=this.modal)==null||ot.subscribeModal(it=>{!it.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),L(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(tu(Ar({namespaces:Ar({},i&&{[this.namespace]:i})},f&&{optionalNamespaces:{[this.namespace]:f}}),{pairingTopic:s==null?void 0:s.pairingTopic})).then(it=>{O(it)}).catch(it=>{L(new Error(it.message))})});if(!g)return;const P=Xv(g.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:P),this.setAccounts(P),this.events.emit("connect",{chainId:Yi(this.chainId)})}catch(g){throw this.signer.logger.error(g),g}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",s=>{const{params:i}=s,{event:f}=i;f.name==="accountsChanged"?(this.accounts=this.parseAccounts(f.data),this.events.emit("accountsChanged",this.accounts)):f.name==="chainChanged"?this.setChainId(this.formatChainId(f.data)):this.events.emit(f.name,f.data),this.events.emit("session_event",s)}),this.signer.on("chainChanged",s=>{const i=parseInt(s);this.chainId=i,this.events.emit("chainChanged",Yi(this.chainId)),this.persist()}),this.signer.on("session_update",s=>{this.events.emit("session_update",s)}),this.signer.on("session_delete",s=>{this.reset(),this.events.emit("session_delete",s),this.events.emit("disconnect",tu(Ar({},Xi("USER_DISCONNECTED")),{data:s.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",s=>{var i,f;this.rpc.showQrModal&&((i=this.modal)==null||i.closeModal(),(f=this.modal)==null||f.openModal({uri:s})),this.events.emit("display_uri",s)})}switchEthereumChain(s){this.request({method:"wallet_switchEthereumChain",params:[{chainId:s.toString(16)}]})}isCompatibleChainId(s){return typeof s=="string"?s.startsWith(`${this.namespace}:`):!1}formatChainId(s){return`${this.namespace}:${s}`}parseChainId(s){return Number(s.split(":")[1])}setChainIds(s){const i=s.filter(f=>this.isCompatibleChainId(f)).map(f=>this.parseChainId(f));i.length&&(this.chainId=i[0],this.events.emit("chainChanged",Yi(this.chainId)),this.persist())}setChainId(s){if(this.isCompatibleChainId(s)){const i=this.parseChainId(s);this.chainId=i,this.switchEthereumChain(i)}}parseAccountId(s){const[i,f,g]=s.split(":");return{chainId:`${i}:${f}`,address:g}}setAccounts(s){this.accounts=s.filter(i=>this.parseChainId(this.parseAccountId(i).chainId)===this.chainId).map(i=>this.parseAccountId(i).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(s){var i,f;const g=(i=s==null?void 0:s.chains)!=null?i:[],P=(f=s==null?void 0:s.optionalChains)!=null?f:[],O=g.concat(P);if(!O.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const L=g.length?(s==null?void 0:s.methods)||rs:[],ot=g.length?(s==null?void 0:s.events)||ns:[],it=(s==null?void 0:s.optionalMethods)||[],lt=(s==null?void 0:s.optionalEvents)||[],nt=(s==null?void 0:s.rpcMap)||this.buildRpcMap(O,s.projectId),pt=(s==null?void 0:s.qrModalOptions)||void 0;return{chains:g==null?void 0:g.map(ut=>this.formatChainId(ut)),optionalChains:P.map(ut=>this.formatChainId(ut)),methods:L,events:ot,optionalMethods:it,optionalEvents:lt,rpcMap:nt,showQrModal:!!(s!=null&&s.showQrModal),qrModalOptions:pt,projectId:s.projectId,metadata:s.metadata}}buildRpcMap(s,i){const f={};return s.forEach(g=>{f[g]=this.getRpcUrl(g,i)}),f}async initialize(s){if(this.rpc=this.getRpcConfig(s),this.chainId=this.rpc.chains.length?Cn(this.rpc.chains):Cn(this.rpc.optionalChains),this.signer=await Mg.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:s.disableProviderPing,relayUrl:s.relayUrl,storageOptions:s.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let i;try{const{WalletConnectModal:f}=await Kv(()=>import("./index-BGRtIcKb.js").then(g=>g.i),__vite__mapDeps([0,1,2]));i=f}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(i)try{this.modal=new i(Ar({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(f){throw this.signer.logger.error(f),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(s){if(!s)return;const{chains:i,optionalChains:f,rpcMap:g}=s;i&&Or(i)&&(this.rpc.chains=i.map(P=>this.formatChainId(P)),i.forEach(P=>{this.rpc.rpcMap[P]=(g==null?void 0:g[P])||this.getRpcUrl(P)})),f&&Or(f)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=f==null?void 0:f.map(P=>this.formatChainId(P)),f.forEach(P=>{this.rpc.rpcMap[P]=(g==null?void 0:g[P])||this.getRpcUrl(P)}))}getRpcUrl(s,i){var f;return((f=this.rpc.rpcMap)==null?void 0:f[s])||`${Fg}?chainId=eip155:${s}&projectId=${i||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const s=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),i=this.session.namespaces[`${this.namespace}:${s}`]?this.session.namespaces[`${this.namespace}:${s}`]:this.session.namespaces[this.namespace];this.setChainIds(s?[this.formatChainId(s)]:i==null?void 0:i.accounts),this.setAccounts(i==null?void 0:i.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(s){return typeof s=="string"||s instanceof String?[this.parseAccount(s)]:s.map(i=>this.parseAccount(i))}}const t0=ss;export{t0 as EthereumProvider,zg as OPTIONAL_EVENTS,Ug as OPTIONAL_METHODS,ns as REQUIRED_EVENTS,rs as REQUIRED_METHODS,ss as default};
28
+ }`;var H=Ho(function(){return N(u,A+"return "+w).apply(i,c)});if(H.source=w,ki(H))throw H;return H}function tv(t){return F(t).toLowerCase()}function ev(t){return F(t).toUpperCase()}function rv(t,e,r){if(t=F(t),t&&(r||e===i))return Us(t);if(!t||!(e=xt(e)))return t;var n=Gt(t),a=Gt(e),u=zs(n,a),c=Ws(n,a)+1;return Pe(n,u,c).join("")}function nv(t,e,r){if(t=F(t),t&&(r||e===i))return t.slice(0,Js(t)+1);if(!t||!(e=xt(e)))return t;var n=Gt(t),a=Ws(n,Gt(e))+1;return Pe(n,0,a).join("")}function iv(t,e,r){if(t=F(t),t&&(r||e===i))return t.replace(kn,"");if(!t||!(e=xt(e)))return t;var n=Gt(t),a=zs(n,Gt(e));return Pe(n,a).join("")}function sv(t,e){var r=In,n=Rt;if(X(e)){var a="separator"in e?e.separator:a;r="length"in e?$(e.length):r,n="omission"in e?xt(e.omission):n}t=F(t);var u=t.length;if(Ne(t)){var c=Gt(t);u=c.length}if(r>=u)return t;var h=r-Fe(n);if(h<1)return n;var p=c?Pe(c,0,h).join(""):t.slice(0,h);if(a===i)return p+n;if(c&&(h+=p.length-h),Mi(a)){if(t.slice(h).search(a)){var m,y=p;for(a.global||(a=ti(a.source,F(fs.exec(a))+"g")),a.lastIndex=0;m=a.exec(y);)var w=m.index;p=p.slice(0,w===i?h:w)}}else if(t.indexOf(xt(a),h)!=h){var C=p.lastIndexOf(a);C>-1&&(p=p.slice(0,C))}return p+n}function av(t){return t=F(t),t&&gu.test(t)?t.replace(us,Rc):t}var ov=Ve(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Ni=Ha("toUpperCase");function Ro(t,e,r){return t=F(t),e=r?i:e,e===i?xc(t)?kc(t):wc(t):t.match(e)||[]}var Ho=q(function(t,e){try{return Ot(t,i,e)}catch(r){return ki(r)?r:new D(r)}}),uv=oe(function(t,e){return qt(e,function(r){r=Yt(r),se(t,r,Hi(t[r],t))}),t});function cv(t){var e=t==null?0:t.length,r=j();return t=e?Z(t,function(n){if(typeof n[1]!="function")throw new kt(O);return[r(n[0]),n[1]]}):[],q(function(n){for(var a=-1;++a<e;){var u=t[a];if(Ot(u[0],this,n))return Ot(u[1],this,n)}})}function hv(t){return Rh(Bt(t,nt))}function Fi(t){return function(){return t}}function fv(t,e){return t==null||t!==t?e:t}var lv=ka(),pv=ka(!0);function Ct(t){return t}function Ui(t){return pa(typeof t=="function"?t:Bt(t,nt))}function dv(t){return va(Bt(t,nt))}function vv(t,e){return ga(t,Bt(e,nt))}var gv=q(function(t,e){return function(r){return _r(r,t,e)}}),_v=q(function(t,e){return function(r){return _r(t,r,e)}});function zi(t,e,r){var n=ct(e),a=en(e,n);r==null&&!(X(e)&&(a.length||!n.length))&&(r=e,e=t,t=this,a=en(e,ct(e)));var u=!(X(r)&&"chain"in r)||!!r.chain,c=ce(t);return qt(a,function(h){var p=e[h];t[h]=p,c&&(t.prototype[h]=function(){var m=this.__chain__;if(u||m){var y=t(this.__wrapped__),w=y.__actions__=bt(this.__actions__);return w.push({func:p,args:arguments,thisArg:t}),y.__chain__=m,y}return p.apply(t,ge([this.value()],arguments))})}),t}function mv(){return ht._===this&&(ht._=Uc),this}function Wi(){}function yv(t){return t=$(t),q(function(e){return _a(e,t)})}var wv=Pi(Z),bv=Pi(Ms),Pv=Pi(Jn);function qo(t){return xi(t)?Qn(Yt(t)):Zh(t)}function Ev(t){return function(e){return t==null?i:Te(t,e)}}var Cv=Ba(),Iv=Ba(!0);function Gi(){return[]}function Ji(){return!1}function Av(){return{}}function Ov(){return""}function jv(){return!0}function xv(t,e){if(t=$(t),t<1||t>J)return[];var r=dt,n=vt(t,dt);e=j(e),t-=dt;for(var a=Zn(n,e);++r<t;)e(r);return a}function Sv(t){return T(t)?Z(t,Yt):St(t)?[t]:bt(eo(F(t)))}function Dv(t){var e=++Nc;return F(t)+e}var Tv=un(function(t,e){return t+e},0),$v=Ei("ceil"),Rv=un(function(t,e){return t/e},1),Hv=Ei("floor");function qv(t){return t&&t.length?tn(t,Ct,ui):i}function kv(t,e){return t&&t.length?tn(t,j(e,2),ui):i}function Mv(t){return Ns(t,Ct)}function Bv(t,e){return Ns(t,j(e,2))}function Lv(t){return t&&t.length?tn(t,Ct,li):i}function Nv(t,e){return t&&t.length?tn(t,j(e,2),li):i}var Fv=un(function(t,e){return t*e},1),Uv=Ei("round"),zv=un(function(t,e){return t-e},0);function Wv(t){return t&&t.length?Kn(t,Ct):0}function Gv(t,e){return t&&t.length?Kn(t,j(e,2)):0}return o.after=dp,o.ary=lo,o.assign=ed,o.assignIn=Oo,o.assignInWith=bn,o.assignWith=rd,o.at=nd,o.before=po,o.bind=Hi,o.bindAll=uv,o.bindKey=vo,o.castArray=Ap,o.chain=co,o.chunk=Hf,o.compact=qf,o.concat=kf,o.cond=cv,o.conforms=hv,o.constant=Fi,o.countBy=Wl,o.create=id,o.curry=go,o.curryRight=_o,o.debounce=mo,o.defaults=sd,o.defaultsDeep=ad,o.defer=vp,o.delay=gp,o.difference=Mf,o.differenceBy=Bf,o.differenceWith=Lf,o.drop=Nf,o.dropRight=Ff,o.dropRightWhile=Uf,o.dropWhile=zf,o.fill=Wf,o.filter=Jl,o.flatMap=Kl,o.flatMapDeep=Zl,o.flatMapDepth=Yl,o.flatten=so,o.flattenDeep=Gf,o.flattenDepth=Jf,o.flip=_p,o.flow=lv,o.flowRight=pv,o.fromPairs=Qf,o.functions=pd,o.functionsIn=dd,o.groupBy=Xl,o.initial=Kf,o.intersection=Zf,o.intersectionBy=Yf,o.intersectionWith=Xf,o.invert=gd,o.invertBy=_d,o.invokeMap=ep,o.iteratee=Ui,o.keyBy=rp,o.keys=ct,o.keysIn=Et,o.map=vn,o.mapKeys=yd,o.mapValues=wd,o.matches=dv,o.matchesProperty=vv,o.memoize=_n,o.merge=bd,o.mergeWith=jo,o.method=gv,o.methodOf=_v,o.mixin=zi,o.negate=mn,o.nthArg=yv,o.omit=Pd,o.omitBy=Ed,o.once=mp,o.orderBy=np,o.over=wv,o.overArgs=yp,o.overEvery=bv,o.overSome=Pv,o.partial=qi,o.partialRight=yo,o.partition=ip,o.pick=Cd,o.pickBy=xo,o.property=qo,o.propertyOf=Ev,o.pull=nl,o.pullAll=oo,o.pullAllBy=il,o.pullAllWith=sl,o.pullAt=al,o.range=Cv,o.rangeRight=Iv,o.rearg=wp,o.reject=op,o.remove=ol,o.rest=bp,o.reverse=$i,o.sampleSize=cp,o.set=Ad,o.setWith=Od,o.shuffle=hp,o.slice=ul,o.sortBy=pp,o.sortedUniq=vl,o.sortedUniqBy=gl,o.split=Kd,o.spread=Pp,o.tail=_l,o.take=ml,o.takeRight=yl,o.takeRightWhile=wl,o.takeWhile=bl,o.tap=ql,o.throttle=Ep,o.thru=dn,o.toArray=Co,o.toPairs=So,o.toPairsIn=Do,o.toPath=Sv,o.toPlainObject=Ao,o.transform=jd,o.unary=Cp,o.union=Pl,o.unionBy=El,o.unionWith=Cl,o.uniq=Il,o.uniqBy=Al,o.uniqWith=Ol,o.unset=xd,o.unzip=Ri,o.unzipWith=uo,o.update=Sd,o.updateWith=Dd,o.values=Ye,o.valuesIn=Td,o.without=jl,o.words=Ro,o.wrap=Ip,o.xor=xl,o.xorBy=Sl,o.xorWith=Dl,o.zip=Tl,o.zipObject=$l,o.zipObjectDeep=Rl,o.zipWith=Hl,o.entries=So,o.entriesIn=Do,o.extend=Oo,o.extendWith=bn,zi(o,o),o.add=Tv,o.attempt=Ho,o.camelCase=qd,o.capitalize=To,o.ceil=$v,o.clamp=$d,o.clone=Op,o.cloneDeep=xp,o.cloneDeepWith=Sp,o.cloneWith=jp,o.conformsTo=Dp,o.deburr=$o,o.defaultTo=fv,o.divide=Rv,o.endsWith=kd,o.eq=Qt,o.escape=Md,o.escapeRegExp=Bd,o.every=Gl,o.find=Ql,o.findIndex=no,o.findKey=od,o.findLast=Vl,o.findLastIndex=io,o.findLastKey=ud,o.floor=Hv,o.forEach=ho,o.forEachRight=fo,o.forIn=cd,o.forInRight=hd,o.forOwn=fd,o.forOwnRight=ld,o.get=Bi,o.gt=Tp,o.gte=$p,o.has=vd,o.hasIn=Li,o.head=ao,o.identity=Ct,o.includes=tp,o.indexOf=Vf,o.inRange=Rd,o.invoke=md,o.isArguments=He,o.isArray=T,o.isArrayBuffer=Rp,o.isArrayLike=Pt,o.isArrayLikeObject=et,o.isBoolean=Hp,o.isBuffer=Ee,o.isDate=qp,o.isElement=kp,o.isEmpty=Mp,o.isEqual=Bp,o.isEqualWith=Lp,o.isError=ki,o.isFinite=Np,o.isFunction=ce,o.isInteger=wo,o.isLength=yn,o.isMap=bo,o.isMatch=Fp,o.isMatchWith=Up,o.isNaN=zp,o.isNative=Wp,o.isNil=Jp,o.isNull=Gp,o.isNumber=Po,o.isObject=X,o.isObjectLike=tt,o.isPlainObject=Er,o.isRegExp=Mi,o.isSafeInteger=Qp,o.isSet=Eo,o.isString=wn,o.isSymbol=St,o.isTypedArray=Ze,o.isUndefined=Vp,o.isWeakMap=Kp,o.isWeakSet=Zp,o.join=tl,o.kebabCase=Ld,o.last=Nt,o.lastIndexOf=el,o.lowerCase=Nd,o.lowerFirst=Fd,o.lt=Yp,o.lte=Xp,o.max=qv,o.maxBy=kv,o.mean=Mv,o.meanBy=Bv,o.min=Lv,o.minBy=Nv,o.stubArray=Gi,o.stubFalse=Ji,o.stubObject=Av,o.stubString=Ov,o.stubTrue=jv,o.multiply=Fv,o.nth=rl,o.noConflict=mv,o.noop=Wi,o.now=gn,o.pad=Ud,o.padEnd=zd,o.padStart=Wd,o.parseInt=Gd,o.random=Hd,o.reduce=sp,o.reduceRight=ap,o.repeat=Jd,o.replace=Qd,o.result=Id,o.round=Uv,o.runInContext=l,o.sample=up,o.size=fp,o.snakeCase=Vd,o.some=lp,o.sortedIndex=cl,o.sortedIndexBy=hl,o.sortedIndexOf=fl,o.sortedLastIndex=ll,o.sortedLastIndexBy=pl,o.sortedLastIndexOf=dl,o.startCase=Zd,o.startsWith=Yd,o.subtract=zv,o.sum=Wv,o.sumBy=Gv,o.template=Xd,o.times=xv,o.toFinite=he,o.toInteger=$,o.toLength=Io,o.toLower=tv,o.toNumber=Ft,o.toSafeInteger=td,o.toString=F,o.toUpper=ev,o.trim=rv,o.trimEnd=nv,o.trimStart=iv,o.truncate=sv,o.unescape=av,o.uniqueId=Dv,o.upperCase=ov,o.upperFirst=Ni,o.each=ho,o.eachRight=fo,o.first=ao,zi(o,function(){var t={};return Kt(o,function(e,r){z.call(o.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),o.VERSION=f,qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){o[t].placeholder=o}),qt(["drop","take"],function(t,e){M.prototype[t]=function(r){r=r===i?1:at($(r),0);var n=this.__filtered__&&!e?new M(this):this.clone();return n.__filtered__?n.__takeCount__=vt(r,n.__takeCount__):n.__views__.push({size:vt(r,dt),type:t+(n.__dir__<0?"Right":"")}),n},M.prototype[t+"Right"]=function(r){return this.reverse()[t](r).reverse()}}),qt(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==v||r==R;M.prototype[t]=function(a){var u=this.clone();return u.__iteratees__.push({iteratee:j(a,3),type:r}),u.__filtered__=u.__filtered__||n,u}}),qt(["head","last"],function(t,e){var r="take"+(e?"Right":"");M.prototype[t]=function(){return this[r](1).value()[0]}}),qt(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");M.prototype[t]=function(){return this.__filtered__?new M(this):this[r](1)}}),M.prototype.compact=function(){return this.filter(Ct)},M.prototype.find=function(t){return this.filter(t).head()},M.prototype.findLast=function(t){return this.reverse().find(t)},M.prototype.invokeMap=q(function(t,e){return typeof t=="function"?new M(this):this.map(function(r){return _r(r,t,e)})}),M.prototype.reject=function(t){return this.filter(mn(j(t)))},M.prototype.slice=function(t,e){t=$(t);var r=this;return r.__filtered__&&(t>0||e<0)?new M(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==i&&(e=$(e),r=e<0?r.dropRight(-e):r.take(e-t)),r)},M.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},M.prototype.toArray=function(){return this.take(dt)},Kt(M.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),a=o[n?"take"+(e=="last"?"Right":""):e],u=n||/^find/.test(e);a&&(o.prototype[e]=function(){var c=this.__wrapped__,h=n?[1]:arguments,p=c instanceof M,m=h[0],y=p||T(c),w=function(k){var B=a.apply(o,ge([k],h));return n&&C?B[0]:B};y&&r&&typeof m=="function"&&m.length!=1&&(p=y=!1);var C=this.__chain__,A=!!this.__actions__.length,x=u&&!C,H=p&&!A;if(!u&&y){c=H?c:new M(this);var S=t.apply(c,h);return S.__actions__.push({func:dn,args:[w],thisArg:i}),new Mt(S,C)}return x&&H?t.apply(this,h):(S=this.thru(w),x?n?S.value()[0]:S.value():S)})}),qt(["pop","push","shift","sort","splice","unshift"],function(t){var e=Br[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);o.prototype[t]=function(){var a=arguments;if(n&&!this.__chain__){var u=this.value();return e.apply(T(u)?u:[],a)}return this[r](function(c){return e.apply(T(c)?c:[],a)})}}),Kt(M.prototype,function(t,e){var r=o[e];if(r){var n=r.name+"";z.call(Ge,n)||(Ge[n]=[]),Ge[n].push({name:e,func:r})}}),Ge[on(i,Xt).name]=[{name:"wrapper",func:i}],M.prototype.clone=sh,M.prototype.reverse=ah,M.prototype.value=oh,o.prototype.at=kl,o.prototype.chain=Ml,o.prototype.commit=Bl,o.prototype.next=Ll,o.prototype.plant=Fl,o.prototype.reverse=Ul,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=zl,o.prototype.first=o.prototype.head,hr&&(o.prototype[hr]=Nl),o},Ue=Mc();Oe?((Oe.exports=Ue)._=Ue,Un._=Ue):ht._=Ue}).call(Cr)})(es,es.exports);var vg=Object.defineProperty,gg=Object.defineProperties,_g=Object.getOwnPropertyDescriptors,Jo=Object.getOwnPropertySymbols,mg=Object.prototype.hasOwnProperty,yg=Object.prototype.propertyIsEnumerable,Qo=(b,s,i)=>s in b?vg(b,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[s]=i,Pn=(b,s)=>{for(var i in s||(s={}))mg.call(s,i)&&Qo(b,i,s[i]);if(Jo)for(var i of Jo(s))yg.call(s,i)&&Qo(b,i,s[i]);return b},wg=(b,s)=>gg(b,_g(s));function Ce(b,s,i){var f;const g=Yv(b);return((f=s.rpcMap)==null?void 0:f[g.reference])||`${dg}?chainId=${g.namespace}:${g.reference}&projectId=${i}`}function qe(b){return b.includes(":")?b.split(":")[1]:b}function nu(b){return b.map(s=>`${s.split(":")[0]}:${s.split(":")[1]}`)}function bg(b,s){const i=Object.keys(s.namespaces).filter(g=>g.includes(b));if(!i.length)return[];const f=[];return i.forEach(g=>{const P=s.namespaces[g].accounts;f.push(...P)}),f}function Pg(b={},s={}){const i=Vo(b),f=Vo(s);return es.exports.merge(i,f)}function Vo(b){var s,i,f,g;const P={};if(!Zv(b))return P;for(const[O,L]of Object.entries(b)){const ot=ru(O)?[O]:L.chains,it=L.methods||[],lt=L.events||[],nt=L.rpcMap||{},pt=Ir(O);P[pt]=wg(Pn(Pn({},P[pt]),L),{chains:Qi(ot,(s=P[pt])==null?void 0:s.chains),methods:Qi(it,(i=P[pt])==null?void 0:i.methods),events:Qi(lt,(f=P[pt])==null?void 0:f.events),rpcMap:Pn(Pn({},nt),(g=P[pt])==null?void 0:g.rpcMap)})}return P}function Eg(b){return b.includes(":")?b.split(":")[2]:b}function Cg(b){const s={};for(const[i,f]of Object.entries(b)){const g=f.methods||[],P=f.events||[],O=f.accounts||[],L=ru(i)?[i]:f.chains?f.chains:nu(f.accounts);s[i]={chains:L,methods:g,events:P,accounts:O}}return s}function Vi(b){return typeof b=="number"?b:b.includes("0x")?parseInt(b,16):b.includes(":")?Number(b.split(":")[1]):Number(b)}const iu={},Y=b=>iu[b],Ki=(b,s)=>{iu[b]=s};class Ig{constructor(s){this.name="polkadot",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getAccounts(){const s=this.namespace.accounts;return s?s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Ag{constructor(s){this.name="eip155",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(s){switch(s.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(s);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(s.request.method)?await this.client.request(s):this.getHttpProvider().request(s.request)}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(parseInt(s),i),this.chainId=parseInt(s),this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}createHttpProvider(s,i){const f=i||Ce(`${this.name}:${s}`,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=parseInt(qe(i));s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const s=this.chainId,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}async handleSwitchChain(s){var i,f;let g=s.request.params?(i=s.request.params[0])==null?void 0:i.chainId:"0x0";g=g.startsWith("0x")?g:`0x${g}`;const P=parseInt(g,16);if(this.isChainApproved(P))this.setDefaultChain(`${P}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:s.topic,request:{method:s.request.method,params:[{chainId:g}]},chainId:(f=this.namespace.chains)==null?void 0:f[0]}),this.setDefaultChain(`${P}`);else throw new Error(`Failed to switch to chain 'eip155:${P}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(s){return this.namespace.chains.includes(`${this.name}:${s}`)}}class Og{constructor(s){this.name="solana",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class jg{constructor(s){this.name="cosmos",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class xg{constructor(s){this.name="cip34",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{const f=this.getCardanoRPCUrl(i),g=qe(i);s[g]=this.createHttpProvider(g,f)}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}getCardanoRPCUrl(s){const i=this.namespace.rpcMap;if(i)return i[s]}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||this.getCardanoRPCUrl(s);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Sg{constructor(s){this.name="elrond",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Dg{constructor(s){this.name="multiversx",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){this.httpProviders[s]||this.setHttpProvider(s,i),this.chainId=s,this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}getAccounts(){const s=this.namespace.accounts;return s?[...new Set(s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;const g=qe(i);s[g]=this.createHttpProvider(g,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace,this.client.core.projectId);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);return new Ie(new Ae(f,Y("disableProviderPing")))}}class Tg{constructor(s){this.name="near",this.namespace=s.namespace,this.events=Y("events"),this.client=Y("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(s){this.namespace=Object.assign(this.namespace,s)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const s=this.namespace.chains[0];if(!s)throw new Error("ChainId not found");return s.split(":")[1]}request(s){return this.namespace.methods.includes(s.request.method)?this.client.request(s):this.getHttpProvider().request(s.request)}setDefaultChain(s,i){if(this.chainId=s,!this.httpProviders[s]){const f=i||Ce(`${this.name}:${s}`,this.namespace);if(!f)throw new Error(`No RPC url provided for chainId: ${s}`);this.setHttpProvider(s,f)}this.events.emit(le.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const s=this.namespace.accounts;return s?s.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const s={};return this.namespace.chains.forEach(i=>{var f;s[i]=this.createHttpProvider(i,(f=this.namespace.rpcMap)==null?void 0:f[i])}),s}getHttpProvider(){const s=`${this.name}:${this.chainId}`,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${s} not found`);return i}setHttpProvider(s,i){const f=this.createHttpProvider(s,i);f&&(this.httpProviders[s]=f)}createHttpProvider(s,i){const f=i||Ce(s,this.namespace);return typeof f>"u"?void 0:new Ie(new Ae(f,Y("disableProviderPing")))}}var $g=Object.defineProperty,Rg=Object.defineProperties,Hg=Object.getOwnPropertyDescriptors,Ko=Object.getOwnPropertySymbols,qg=Object.prototype.hasOwnProperty,kg=Object.prototype.propertyIsEnumerable,Zo=(b,s,i)=>s in b?$g(b,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[s]=i,En=(b,s)=>{for(var i in s||(s={}))qg.call(s,i)&&Zo(b,i,s[i]);if(Ko)for(var i of Ko(s))kg.call(s,i)&&Zo(b,i,s[i]);return b},Zi=(b,s)=>Rg(b,Hg(s));class is{constructor(s){this.events=new Vv,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=s,this.logger=typeof(s==null?void 0:s.logger)<"u"&&typeof(s==null?void 0:s.logger)!="string"?s.logger:Lo.pino(Lo.getDefaultLoggerOptions({level:(s==null?void 0:s.logger)||Wo})),this.disableProviderPing=(s==null?void 0:s.disableProviderPing)||!1}static async init(s){const i=new is(s);return await i.initialize(),i}async request(s,i){const[f,g]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(f).request({request:En({},s),chainId:`${f}:${g}`,topic:this.session.topic})}sendAsync(s,i,f){const g=new Date().getTime();this.request(s,f).then(P=>i(null,rg(g,P))).catch(P=>i(P,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var s;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(s=this.session)==null?void 0:s.topic,reason:Xi("USER_DISCONNECTED")}),await this.cleanup()}async connect(s){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(s),await this.cleanupPendingPairings(),!s.skipPairing)return await this.pair(s.pairingTopic)}on(s,i){this.events.on(s,i)}once(s,i){this.events.once(s,i)}removeListener(s,i){this.events.removeListener(s,i)}off(s,i){this.events.off(s,i)}get isWalletConnect(){return!0}async pair(s){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:f,approval:g}=await this.client.connect({pairingTopic:s,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});f&&(this.uri=f,this.events.emit("display_uri",f)),await g().then(P=>{this.session=P,this.namespaces||(this.namespaces=Cg(P.namespaces),this.persist("namespaces",this.namespaces))}).catch(P=>{if(P.message!==ng)throw P;i++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(s,i){try{if(!this.session)return;const[f,g]=this.validateChain(s);this.getProvider(f).setDefaultChain(g,i)}catch(f){if(!/Please call connect/.test(f.message))throw f}}async cleanupPendingPairings(s={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(Or(i)){for(const f of i)s.deletePairings?this.client.core.expirer.set(f.topic,0):await this.client.core.relayer.subscriber.unsubscribe(f.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const s=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[s]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await ig.init({logger:this.providerOpts.logger||Wo,relayUrl:this.providerOpts.relayUrl||fg,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const s=[...new Set(Object.keys(this.session.namespaces).map(i=>Ir(i)))];Ki("client",this.client),Ki("events",this.events),Ki("disableProviderPing",this.disableProviderPing),s.forEach(i=>{if(!this.session)return;const f=bg(i,this.session),g=nu(f),P=Pg(this.namespaces,this.optionalNamespaces),O=Zi(En({},P[i]),{accounts:f,chains:g});switch(i){case"eip155":this.rpcProviders[i]=new Ag({namespace:O});break;case"solana":this.rpcProviders[i]=new Og({namespace:O});break;case"cosmos":this.rpcProviders[i]=new jg({namespace:O});break;case"polkadot":this.rpcProviders[i]=new Ig({namespace:O});break;case"cip34":this.rpcProviders[i]=new xg({namespace:O});break;case"elrond":this.rpcProviders[i]=new Sg({namespace:O});break;case"multiversx":this.rpcProviders[i]=new Dg({namespace:O});break;case"near":this.rpcProviders[i]=new Tg({namespace:O});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",s=>{this.events.emit("session_ping",s)}),this.client.on("session_event",s=>{const{params:i}=s,{event:f}=i;if(f.name==="accountsChanged"){const g=f.data;g&&Or(g)&&this.events.emit("accountsChanged",g.map(Eg))}else if(f.name==="chainChanged"){const g=i.chainId,P=i.event.data,O=Ir(g),L=Vi(g)!==Vi(P)?`${O}:${Vi(P)}`:g;this.onChainChanged(L)}else this.events.emit(f.name,f.data);this.events.emit("session_event",s)}),this.client.on("session_update",({topic:s,params:i})=>{var f;const{namespaces:g}=i,P=(f=this.client)==null?void 0:f.session.get(s);this.session=Zi(En({},P),{namespaces:g}),this.onSessionUpdate(),this.events.emit("session_update",{topic:s,params:i})}),this.client.on("session_delete",async s=>{await this.cleanup(),this.events.emit("session_delete",s),this.events.emit("disconnect",Zi(En({},Xi("USER_DISCONNECTED")),{data:s.topic}))}),this.on(le.DEFAULT_CHAIN_CHANGED,s=>{this.onChainChanged(s,!0)})}getProvider(s){if(!this.rpcProviders[s])throw new Error(`Provider not found: ${s}`);return this.rpcProviders[s]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(s=>{var i;this.getProvider(s).updateNamespace((i=this.session)==null?void 0:i.namespaces[s])})}setNamespaces(s){const{namespaces:i,optionalNamespaces:f,sessionProperties:g}=s;i&&Object.keys(i).length&&(this.namespaces=i),f&&Object.keys(f).length&&(this.optionalNamespaces=f),this.sessionProperties=g,this.persist("namespaces",i),this.persist("optionalNamespaces",f)}validateChain(s){const[i,f]=(s==null?void 0:s.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[i,f];if(i&&!Object.keys(this.namespaces||{}).map(O=>Ir(O)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&f)return[i,f];const g=Ir(Object.keys(this.namespaces)[0]),P=this.rpcProviders[g].getDefaultChain();return[g,P]}async requestAccounts(){const[s]=this.validateChain();return await this.getProvider(s).requestAccounts()}onChainChanged(s,i=!1){var f;if(!this.namespaces)return;const[g,P]=this.validateChain(s);i||this.getProvider(g).setDefaultChain(P),((f=this.namespaces[g])!=null?f:this.namespaces[`${g}:${P}`]).defaultChain=P,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",P)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(s,i){this.client.core.storage.setItem(`${Go}/${s}`,i)}async getFromStore(s){return await this.client.core.storage.getItem(`${Go}/${s}`)}}const Mg=is,Bg="wc",Lg="ethereum_provider",Ng=`${Bg}@2:${Lg}:`,Fg="https://rpc.walletconnect.com/v1/",rs=["eth_sendTransaction","personal_sign"],Ug=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],ns=["chainChanged","accountsChanged"],zg=["chainChanged","accountsChanged","message","disconnect","connect"];var Wg=Object.defineProperty,Gg=Object.defineProperties,Jg=Object.getOwnPropertyDescriptors,Yo=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,Xo=(b,s,i)=>s in b?Wg(b,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[s]=i,Ar=(b,s)=>{for(var i in s||(s={}))Qg.call(s,i)&&Xo(b,i,s[i]);if(Yo)for(var i of Yo(s))Vg.call(s,i)&&Xo(b,i,s[i]);return b},tu=(b,s)=>Gg(b,Jg(s));function Cn(b){return Number(b[0].split(":")[1])}function Yi(b){return`0x${b.toString(16)}`}function Kg(b){const{chains:s,optionalChains:i,methods:f,optionalMethods:g,events:P,optionalEvents:O,rpcMap:L}=b;if(!Or(s))throw new Error("Invalid chains");const ot={chains:s,methods:f||rs,events:P||ns,rpcMap:Ar({},s.length?{[Cn(s)]:L[Cn(s)]}:{})},it=P==null?void 0:P.filter(ut=>!ns.includes(ut)),lt=f==null?void 0:f.filter(ut=>!rs.includes(ut));if(!i&&!O&&!g&&!(it!=null&&it.length)&&!(lt!=null&&lt.length))return{required:s.length?ot:void 0};const nt=(it==null?void 0:it.length)&&(lt==null?void 0:lt.length)||!i,pt={chains:[...new Set(nt?ot.chains.concat(i||[]):i)],methods:[...new Set(ot.methods.concat(g!=null&&g.length?g:Ug))],events:[...new Set(ot.events.concat(O!=null&&O.length?O:zg))],rpcMap:L};return{required:s.length?ot:void 0,optional:i.length?pt:void 0}}class ss{constructor(){this.events=new eu.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=Ng,this.on=(s,i)=>(this.events.on(s,i),this),this.once=(s,i)=>(this.events.once(s,i),this),this.removeListener=(s,i)=>(this.events.removeListener(s,i),this),this.off=(s,i)=>(this.events.off(s,i),this),this.parseAccount=s=>this.isCompatibleChainId(s)?this.parseAccountId(s).address:s,this.signer={},this.rpc={}}static async init(s){const i=new ss;return await i.initialize(s),i}async request(s){return await this.signer.request(s,this.formatChainId(this.chainId))}sendAsync(s,i){this.signer.sendAsync(s,i,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(s){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(s);const{required:i,optional:f}=Kg(this.rpc);try{const g=await new Promise(async(O,L)=>{var ot;this.rpc.showQrModal&&((ot=this.modal)==null||ot.subscribeModal(it=>{!it.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),L(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(tu(Ar({namespaces:Ar({},i&&{[this.namespace]:i})},f&&{optionalNamespaces:{[this.namespace]:f}}),{pairingTopic:s==null?void 0:s.pairingTopic})).then(it=>{O(it)}).catch(it=>{L(new Error(it.message))})});if(!g)return;const P=Xv(g.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:P),this.setAccounts(P),this.events.emit("connect",{chainId:Yi(this.chainId)})}catch(g){throw this.signer.logger.error(g),g}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",s=>{const{params:i}=s,{event:f}=i;f.name==="accountsChanged"?(this.accounts=this.parseAccounts(f.data),this.events.emit("accountsChanged",this.accounts)):f.name==="chainChanged"?this.setChainId(this.formatChainId(f.data)):this.events.emit(f.name,f.data),this.events.emit("session_event",s)}),this.signer.on("chainChanged",s=>{const i=parseInt(s);this.chainId=i,this.events.emit("chainChanged",Yi(this.chainId)),this.persist()}),this.signer.on("session_update",s=>{this.events.emit("session_update",s)}),this.signer.on("session_delete",s=>{this.reset(),this.events.emit("session_delete",s),this.events.emit("disconnect",tu(Ar({},Xi("USER_DISCONNECTED")),{data:s.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",s=>{var i,f;this.rpc.showQrModal&&((i=this.modal)==null||i.closeModal(),(f=this.modal)==null||f.openModal({uri:s})),this.events.emit("display_uri",s)})}switchEthereumChain(s){this.request({method:"wallet_switchEthereumChain",params:[{chainId:s.toString(16)}]})}isCompatibleChainId(s){return typeof s=="string"?s.startsWith(`${this.namespace}:`):!1}formatChainId(s){return`${this.namespace}:${s}`}parseChainId(s){return Number(s.split(":")[1])}setChainIds(s){const i=s.filter(f=>this.isCompatibleChainId(f)).map(f=>this.parseChainId(f));i.length&&(this.chainId=i[0],this.events.emit("chainChanged",Yi(this.chainId)),this.persist())}setChainId(s){if(this.isCompatibleChainId(s)){const i=this.parseChainId(s);this.chainId=i,this.switchEthereumChain(i)}}parseAccountId(s){const[i,f,g]=s.split(":");return{chainId:`${i}:${f}`,address:g}}setAccounts(s){this.accounts=s.filter(i=>this.parseChainId(this.parseAccountId(i).chainId)===this.chainId).map(i=>this.parseAccountId(i).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(s){var i,f;const g=(i=s==null?void 0:s.chains)!=null?i:[],P=(f=s==null?void 0:s.optionalChains)!=null?f:[],O=g.concat(P);if(!O.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const L=g.length?(s==null?void 0:s.methods)||rs:[],ot=g.length?(s==null?void 0:s.events)||ns:[],it=(s==null?void 0:s.optionalMethods)||[],lt=(s==null?void 0:s.optionalEvents)||[],nt=(s==null?void 0:s.rpcMap)||this.buildRpcMap(O,s.projectId),pt=(s==null?void 0:s.qrModalOptions)||void 0;return{chains:g==null?void 0:g.map(ut=>this.formatChainId(ut)),optionalChains:P.map(ut=>this.formatChainId(ut)),methods:L,events:ot,optionalMethods:it,optionalEvents:lt,rpcMap:nt,showQrModal:!!(s!=null&&s.showQrModal),qrModalOptions:pt,projectId:s.projectId,metadata:s.metadata}}buildRpcMap(s,i){const f={};return s.forEach(g=>{f[g]=this.getRpcUrl(g,i)}),f}async initialize(s){if(this.rpc=this.getRpcConfig(s),this.chainId=this.rpc.chains.length?Cn(this.rpc.chains):Cn(this.rpc.optionalChains),this.signer=await Mg.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:s.disableProviderPing,relayUrl:s.relayUrl,storageOptions:s.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let i;try{const{WalletConnectModal:f}=await Kv(()=>import("./index-CaMXNKLm.js").then(g=>g.i),__vite__mapDeps([0,1,2]));i=f}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(i)try{this.modal=new i(Ar({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(f){throw this.signer.logger.error(f),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(s){if(!s)return;const{chains:i,optionalChains:f,rpcMap:g}=s;i&&Or(i)&&(this.rpc.chains=i.map(P=>this.formatChainId(P)),i.forEach(P=>{this.rpc.rpcMap[P]=(g==null?void 0:g[P])||this.getRpcUrl(P)})),f&&Or(f)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=f==null?void 0:f.map(P=>this.formatChainId(P)),f.forEach(P=>{this.rpc.rpcMap[P]=(g==null?void 0:g[P])||this.getRpcUrl(P)}))}getRpcUrl(s,i){var f;return((f=this.rpc.rpcMap)==null?void 0:f[s])||`${Fg}?chainId=eip155:${s}&projectId=${i||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const s=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),i=this.session.namespaces[`${this.namespace}:${s}`]?this.session.namespaces[`${this.namespace}:${s}`]:this.session.namespaces[this.namespace];this.setChainIds(s?[this.formatChainId(s)]:i==null?void 0:i.accounts),this.setAccounts(i==null?void 0:i.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(s){return typeof s=="string"||s instanceof String?[this.parseAccount(s)]:s.map(i=>this.parseAccount(i))}}const t0=ss;export{t0 as EthereumProvider,zg as OPTIONAL_EVENTS,Ug as OPTIONAL_METHODS,ns as REQUIRED_EVENTS,rs as REQUIRED_METHODS,ss as default};