@magic-sdk/provider 29.0.6-canary.872.14229698017.0 → 29.0.6-canary.873.14250540163.0

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.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var Xt=Object.create;var re=Object.defineProperty,Yt=Object.defineProperties,zt=Object.getOwnPropertyDescriptor,Qt=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,er=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable;var lt=(r,e,t)=>e in r?re(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,W=(r,e)=>{for(var t in e||(e={}))dt.call(e,t)&&lt(r,t,e[t]);if(ct)for(var t of ct(e))tr.call(e,t)&&lt(r,t,e[t]);return r},X=(r,e)=>Yt(r,Qt(e));var rr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ut=(r,e)=>{for(var t in e)re(r,t,{get:e[t],enumerable:!0})},pt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zt(e))!dt.call(r,i)&&i!==t&&re(r,i,{get:()=>e[i],enumerable:!(n=zt(e,i))||n.enumerable});return r};var nr=(r,e,t)=>(t=r!=null?Xt(er(r)):{},pt(e||!r||!r.__esModule?re(t,"default",{value:r,enumerable:!0}):t,r)),sr=r=>pt(re({},"__esModule",{value:!0}),r);var E=(r,e,t)=>new Promise((n,i)=>{var s=c=>{try{a(t.next(c))}catch(d){i(d)}},o=c=>{try{a(t.throw(c))}catch(d){i(d)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((t=t.apply(r,e)).next())});var Ct=rr((Un,Xe)=>{"use strict";var Qr=Object.prototype.hasOwnProperty,M="~";function ae(){}Object.create&&(ae.prototype=Object.create(null),new ae().__proto__||(M=!1));function Zr(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Nt(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Zr(t,n||r,i),o=M?M+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Re(r,e){--r._eventsCount===0?r._events=new ae:delete r._events[e]}function b(){this._events=new ae,this._eventsCount=0}b.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Qr.call(t,n)&&e.push(M?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};b.prototype.listeners=function(e){var t=M?M+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};b.prototype.listenerCount=function(e){var t=M?M+e:e,n=this._events[t];return n?n.fn?1:n.length:0};b.prototype.emit=function(e,t,n,i,s,o){var a=M?M+e:e;if(!this._events[a])return!1;var c=this._events[a],d=arguments.length,u,h;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,o),!0}for(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];c.fn.apply(c.context,u)}else{var S=c.length,T;for(h=0;h<S;h++)switch(c[h].once&&this.removeListener(e,c[h].fn,void 0,!0),d){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,t);break;case 3:c[h].fn.call(c[h].context,t,n);break;case 4:c[h].fn.call(c[h].context,t,n,i);break;default:if(!u)for(T=1,u=new Array(d-1);T<d;T++)u[T-1]=arguments[T];c[h].fn.apply(c[h].context,u)}}return!0};b.prototype.on=function(e,t,n){return Nt(this,e,t,n,!1)};b.prototype.once=function(e,t,n){return Nt(this,e,t,n,!0)};b.prototype.removeListener=function(e,t,n,i){var s=M?M+e:e;if(!this._events[s])return this;if(!t)return Re(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Re(this,s);else{for(var a=0,c=[],d=o.length;a<d;a++)(o[a].fn!==t||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:Re(this,s)}return this};b.prototype.removeAllListeners=function(e){var t;return e?(t=M?M+e:e,this._events[t]&&Re(this,t)):(this._events=new ae,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=M;b.EventEmitter=b;typeof Xe<"u"&&(Xe.exports=b)});var bn={};ut(bn,{Extension:()=>B,MagicExtensionError:()=>V,MagicExtensionWarning:()=>Q,MagicRPCError:()=>L,MagicSDKError:()=>$,MagicSDKWarning:()=>D,SDKBase:()=>ue,STORE_KEY_PRIVATE_KEY:()=>we,STORE_KEY_PUBLIC_JWK:()=>le,TypedEmitter:()=>ve,ViewController:()=>Oe,clearKeys:()=>cn,createDeprecationWarning:()=>He,createDuplicateIframeWarning:()=>Hr,createExtensionNotInitializedError:()=>Ge,createIncompatibleExtensionsError:()=>Ke,createInvalidArgumentError:()=>je,createJwt:()=>et,createMalformedResponseError:()=>Je,createMissingApiKeyError:()=>Fe,createModalNotReadyError:()=>We,createPromiEvent:()=>P,createPromise:()=>Ie,createReactNativeEndpointConfigurationWarning:()=>Ve,createSDK:()=>wt,createSynchronousWeb3MethodWarning:()=>Be,createTypedEmitter:()=>ce,createURL:()=>Me,decodeJSON:()=>De,encodeJSON:()=>oe,getPayloadId:()=>ye,isEmpty:()=>z,isJsonRpcErrorCode:()=>Ue,isJsonRpcRequestPayload:()=>Br,isJsonRpcResponsePayload:()=>qe,isMagicPayloadMethod:()=>Vr,isMajorVersionAtLeast:()=>ze,isPromiEvent:()=>Ye,isWebCryptoSupported:()=>ee,storage:()=>Z,uuid:()=>Ze});module.exports=sr(bn);function ir(r){let e={exports:{}};return r(e,e.exports),e.exports}var or=Number.MAX_SAFE_INTEGER||9007199254740991;var ke={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:or,MAX_SAFE_COMPONENT_LENGTH:16},ar=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{},g=ar,ie=ir(function(r,e){let{MAX_SAFE_COMPONENT_LENGTH:t}=ke,n=(e=r.exports={}).re=[],i=e.src=[],s=e.t={},o=0,a=(c,d,u)=>{let h=o++;g(h,d),s[c]=h,i[h]=d,n[h]=new RegExp(d,u?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${i[s.NUMERICIDENTIFIER]})\\.(${i[s.NUMERICIDENTIFIER]})\\.(${i[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${i[s.NUMERICIDENTIFIERLOOSE]})\\.(${i[s.NUMERICIDENTIFIERLOOSE]})\\.(${i[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${i[s.NUMERICIDENTIFIER]}|${i[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${i[s.NUMERICIDENTIFIERLOOSE]}|${i[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${i[s.PRERELEASEIDENTIFIER]}(?:\\.${i[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${i[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${i[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${i[s.BUILDIDENTIFIER]}(?:\\.${i[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${i[s.MAINVERSION]}${i[s.PRERELEASE]}?${i[s.BUILD]}?`),a("FULL",`^${i[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${i[s.MAINVERSIONLOOSE]}${i[s.PRERELEASELOOSE]}?${i[s.BUILD]}?`),a("LOOSE",`^${i[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${i[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${i[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${i[s.XRANGEIDENTIFIER]})(?:\\.(${i[s.XRANGEIDENTIFIER]})(?:\\.(${i[s.XRANGEIDENTIFIER]})(?:${i[s.PRERELEASE]})?${i[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${i[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[s.XRANGEIDENTIFIERLOOSE]})(?:${i[s.PRERELEASELOOSE]})?${i[s.BUILD]}?)?)?`),a("XRANGE",`^${i[s.GTLT]}\\s*${i[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${i[s.GTLT]}\\s*${i[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),a("COERCERTL",i[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${i[s.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",a("TILDE",`^${i[s.LONETILDE]}${i[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${i[s.LONETILDE]}${i[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${i[s.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",a("CARET",`^${i[s.LONECARET]}${i[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${i[s.LONECARET]}${i[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${i[s.GTLT]}\\s*(${i[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${i[s.GTLT]}\\s*(${i[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${i[s.GTLT]}\\s*(${i[s.LOOSEPLAIN]}|${i[s.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${i[s.XRANGEPLAIN]})\\s+-\\s+(${i[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${i[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${i[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),ht=/^[0-9]+$/,It=(r,e)=>{let t=ht.test(r),n=ht.test(e);return t&&n&&(r=+r,e=+e),r===e?0:t&&!n?-1:n&&!t?1:r<e?-1:1},cr=(r,e)=>It(e,r),lr={compareIdentifiers:It,rcompareIdentifiers:cr},{MAX_LENGTH:mt,MAX_SAFE_INTEGER:he}=ke,{re:Et,t:ft}=ie,{compareIdentifiers:ne}=lr,y=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof y){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>mt)throw new TypeError(`version is longer than ${mt} characters`);g("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let n=e.trim().match(t.loose?Et[ft.LOOSE]:Et[ft.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>he||this.major<0)throw new TypeError("Invalid major version");if(this.minor>he||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>he||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let s=+i;if(s>=0&&s<he)return s}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(g("SemVer.compare",this.version,this.options,e),!(e instanceof y)){if(typeof e=="string"&&e===this.version)return 0;e=new y(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof y||(e=new y(e,this.options)),ne(this.major,e.major)||ne(this.minor,e.minor)||ne(this.patch,e.patch)}comparePre(e){if(e instanceof y||(e=new y(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let n=this.prerelease[t],i=e.prerelease[t];if(g("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n!==i)return ne(n,i)}while(++t)}compareBuild(e){e instanceof y||(e=new y(e,this.options));let t=0;do{let n=this.build[t],i=e.build[t];if(g("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n!==i)return ne(n,i)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);break;case"major":this.minor===0&&this.patch===0&&this.prerelease.length!==0||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":this.patch===0&&this.prerelease.length!==0||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let n=this.prerelease.length;for(;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);n===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},dr=(r,e,t)=>new y(r,t).compare(new y(e,t)),Y=dr,ur=(r,e,t)=>Y(r,e,t)===0,pr=ur,hr=(r,e,t)=>Y(r,e,t)!==0,mr=hr,Er=(r,e,t)=>Y(r,e,t)>0,fr=Er,gr=(r,e,t)=>Y(r,e,t)>=0,yr=gr,Rr=(r,e,t)=>Y(r,e,t)<0,vr=Rr,Tr=(r,e,t)=>Y(r,e,t)<=0,Ir=Tr,br=(r,e,t,n)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return pr(r,t,n);case"!=":return mr(r,t,n);case">":return fr(r,t,n);case">=":return yr(r,t,n);case"<":return vr(r,t,n);case"<=":return Ir(r,t,n);default:throw new TypeError(`Invalid operator: ${e}`)}},_e=br,se=Symbol("SemVer ANY"),J=class{static get ANY(){return se}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof J){if(e.loose===!!t.loose)return e;e=e.value}g("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===se?this.value="":this.value=this.operator+this.semver.version,g("comp",this)}parse(e){let t=this.options.loose?gt[yt.COMPARATORLOOSE]:gt[yt.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new y(n[2],this.options.loose):this.semver=se}toString(){return this.value}test(e){if(g("Comparator.test",e,this.options.loose),this.semver===se||e===se)return!0;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}return _e(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof J))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new _(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new _(this.value,t).test(e.semver);let n=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),i=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),s=this.semver.version===e.semver.version,o=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),a=_e(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),c=_e(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return n||i||s&&o||a||c}},{re:gt,t:yt}=ie,_=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof _)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new _(e.raw,t);if(e instanceof J)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let n=t?I[R.HYPHENRANGELOOSE]:I[R.HYPHENRANGE];e=e.replace(n,kr(this.options.includePrerelease)),g("hyphen replace",e),e=e.replace(I[R.COMPARATORTRIM],Pr),g("comparator trim",e,I[R.COMPARATORTRIM]),e=(e=(e=e.replace(I[R.TILDETRIM],wr)).replace(I[R.CARETTRIM],xr)).split(/\s+/).join(" ");let i=t?I[R.COMPARATORLOOSE]:I[R.COMPARATOR];return e.split(" ").map(s=>Mr(s,this.options)).join(" ").split(/\s+/).map(s=>_r(s,this.options)).filter(this.options.loose?s=>!!s.match(i):()=>!0).map(s=>new J(s,this.options))}intersects(e,t){if(!(e instanceof _))throw new TypeError("a Range is required");return this.set.some(n=>Rt(n,t)&&e.set.some(i=>Rt(i,t)&&n.every(s=>i.every(o=>s.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(Dr(this.set[t],e,this.options))return!0;return!1}},{re:I,t:R,comparatorTrimReplace:Pr,tildeTrimReplace:wr,caretTrimReplace:xr}=ie,Rt=(r,e)=>{let t=!0,n=r.slice(),i=n.pop();for(;t&&n.length;)t=n.every(s=>i.intersects(s,e)),i=n.pop();return t},Mr=(r,e)=>(g("comp",r,e),r=Cr(r,e),g("caret",r),r=Sr(r,e),g("tildes",r),r=$r(r,e),g("xrange",r),r=Or(r,e),g("stars",r),r),x=r=>!r||r.toLowerCase()==="x"||r==="*",Sr=(r,e)=>r.trim().split(/\s+/).map(t=>Nr(t,e)).join(" "),Nr=(r,e)=>{let t=e.loose?I[R.TILDELOOSE]:I[R.TILDE];return r.replace(t,(n,i,s,o,a)=>{let c;return g("tilde",r,n,i,s,o,a),x(i)?c="":x(s)?c=`>=${i}.0.0 <${+i+1}.0.0-0`:x(o)?c=`>=${i}.${s}.0 <${i}.${+s+1}.0-0`:a?(g("replaceTilde pr",a),c=`>=${i}.${s}.${o}-${a} <${i}.${+s+1}.0-0`):c=`>=${i}.${s}.${o} <${i}.${+s+1}.0-0`,g("tilde return",c),c})},Cr=(r,e)=>r.trim().split(/\s+/).map(t=>Ar(t,e)).join(" "),Ar=(r,e)=>{g("caret",r,e);let t=e.loose?I[R.CARETLOOSE]:I[R.CARET],n=e.includePrerelease?"-0":"";return r.replace(t,(i,s,o,a,c)=>{let d;return g("caret",r,i,s,o,a,c),x(s)?d="":x(o)?d=`>=${s}.0.0${n} <${+s+1}.0.0-0`:x(a)?d=s==="0"?`>=${s}.${o}.0${n} <${s}.${+o+1}.0-0`:`>=${s}.${o}.0${n} <${+s+1}.0.0-0`:c?(g("replaceCaret pr",c),d=s==="0"?o==="0"?`>=${s}.${o}.${a}-${c} <${s}.${o}.${+a+1}-0`:`>=${s}.${o}.${a}-${c} <${s}.${+o+1}.0-0`:`>=${s}.${o}.${a}-${c} <${+s+1}.0.0-0`):(g("no pr"),d=s==="0"?o==="0"?`>=${s}.${o}.${a}${n} <${s}.${o}.${+a+1}-0`:`>=${s}.${o}.${a}${n} <${s}.${+o+1}.0-0`:`>=${s}.${o}.${a} <${+s+1}.0.0-0`),g("caret return",d),d})},$r=(r,e)=>(g("replaceXRanges",r,e),r.split(/\s+/).map(t=>Lr(t,e)).join(" ")),Lr=(r,e)=>{r=r.trim();let t=e.loose?I[R.XRANGELOOSE]:I[R.XRANGE];return r.replace(t,(n,i,s,o,a,c)=>{g("xRange",r,n,i,s,o,a,c);let d=x(s),u=d||x(o),h=u||x(a),S=h;return i==="="&&S&&(i=""),c=e.includePrerelease?"-0":"",d?n=i===">"||i==="<"?"<0.0.0-0":"*":i&&S?(u&&(o=0),a=0,i===">"?(i=">=",u?(s=+s+1,o=0,a=0):(o=+o+1,a=0)):i==="<="&&(i="<",u?s=+s+1:o=+o+1),i==="<"&&(c="-0"),n=`${i+s}.${o}.${a}${c}`):u?n=`>=${s}.0.0${c} <${+s+1}.0.0-0`:h&&(n=`>=${s}.${o}.0${c} <${s}.${+o+1}.0-0`),g("xRange return",n),n})},Or=(r,e)=>(g("replaceStars",r,e),r.trim().replace(I[R.STAR],"")),_r=(r,e)=>(g("replaceGTE0",r,e),r.trim().replace(I[e.includePrerelease?R.GTE0PRE:R.GTE0],"")),kr=r=>(e,t,n,i,s,o,a,c,d,u,h,S,T)=>`${t=x(n)?"":x(i)?`>=${n}.0.0${r?"-0":""}`:x(s)?`>=${n}.${i}.0${r?"-0":""}`:o?`>=${t}`:`>=${t}${r?"-0":""}`} ${c=x(d)?"":x(u)?`<${+d+1}.0.0-0`:x(h)?`<${d}.${+u+1}.0-0`:S?`<=${d}.${u}.${h}-${S}`:r?`<${d}.${u}.${+h+1}-0`:`<=${c}`}`.trim(),Dr=(r,e,t)=>{for(let n=0;n<r.length;n++)if(!r[n].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let n=0;n<r.length;n++)if(g(r[n].semver),r[n].semver!==J.ANY&&r[n].semver.prerelease.length>0){let i=r[n].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0},bt=(r,e,t)=>{try{e=new _(e,t)}catch(n){return!1}return e.test(r)};var{MAX_LENGTH:qr}=ke,{re:vt,t:Tt}=ie,Ur=(r,e)=>{if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),r instanceof y)return r;if(typeof r!="string"||r.length>qr||!(e.loose?vt[Tt.LOOSE]:vt[Tt.FULL]).test(r))return null;try{return new y(r,e)}catch(t){return null}},Fr=Ur,{re:me,t:Ee}=ie,Pt=(r,e)=>{if(r instanceof y)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;let t=null;if((e=e||{}).rtl){let n;for(;(n=me[Ee.COERCERTL].exec(r))&&(!t||t.index+t[0].length!==r.length);)t&&n.index+n[0].length===t.index+t[0].length||(t=n),me[Ee.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;me[Ee.COERCERTL].lastIndex=-1}else t=r.match(me[Ee.COERCE]);return t===null?null:Fr(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};function Wr(r){return String.fromCharCode(parseInt(r.slice(1),16))}function Jr(r){return`%${`00${r.charCodeAt(0).toString(16)}`.slice(-2)}`}function Gr(r){return btoa(encodeURIComponent(r).replace(/%[0-9A-F]{2}/g,Wr))}function Kr(r){return decodeURIComponent(Array.from(atob(r),Jr).join(""))}function oe(r){return Gr(JSON.stringify(r))}function De(r){return JSON.parse(Kr(r))}var N=require("@magic-sdk/types");var fe=require("@magic-sdk/types");function k(r){return typeof r=="undefined"}function jr(r){return r===null}function ge(r){return jr(r)||k(r)}function Br(r){return ge(r)?!1:!k(r.jsonrpc)&&!k(r.id)&&!k(r.method)&&!k(r.params)}function qe(r){return ge(r)?!1:!k(r.jsonrpc)&&!k(r.id)&&(!k(r.result)||!k(r.error))}function Vr(r){return ge(r)?!1:typeof r=="string"&&Object.values(fe.MagicPayloadMethod).includes(r)}function Ue(r){return ge(r)?!1:typeof r=="number"&&Object.values(fe.RPCErrorCode).includes(r)}function z(r){if(!r)return!0;for(let e in r)if(Object.hasOwnProperty.call(r,e))return!1;return!0}var f={};function wt(r,e){return Object.assign(f,e),r}var xt={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"};var $=class extends Error{constructor(t,n){super(`Magic SDK Error: [${t}] ${n}`);this.code=t;this.rawMessage=n;this.__proto__=Error;Object.setPrototypeOf(this,$.prototype)}},L=class extends Error{constructor(t){super();this.__proto__=Error;let n=Number(t==null?void 0:t.code);this.rawMessage=(t==null?void 0:t.message)||"Internal error",this.code=Ue(n)?n:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(t==null?void 0:t.data)||void 0,Object.setPrototypeOf(this,L.prototype)}},D=class{constructor(e,t){this.code=e;this.rawMessage=t;this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},V=class extends Error{constructor(t,n,i,s){super(`Magic Extension Error (${t.name}): [${n}] ${i}`);this.code=n;this.rawMessage=i;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,V.prototype)}},Q=class{constructor(e,t,n){this.code=t;this.rawMessage=n;this.message=`Magic Extension Warning (${e.name}): [${t}] ${n}`}log(){console.warn(this.message)}};function Fe(){return new $(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function We(){return new $(N.SDKErrorCode.ModalNotReady,"Modal is not ready")}function Je(){return new $(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ge(r){return new $(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${r}\` can be accessed. Do not invoke \`Extension.${r}\` inside an extension constructor.`)}function Ke(r){let e=`Some extensions are incompatible with \`${f.sdkName}@${f.version}\`:`;return r.filter(t=>typeof t.compat!="undefined"&&t.compat!==null).forEach(t=>{let n=t.compat[f.sdkName];typeof n=="string"?e+=`
1
+ "use strict";var Xt=Object.create;var re=Object.defineProperty,zt=Object.defineProperties,Yt=Object.getOwnPropertyDescriptor,Qt=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,er=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable;var lt=(r,e,t)=>e in r?re(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,W=(r,e)=>{for(var t in e||(e={}))dt.call(e,t)&&lt(r,t,e[t]);if(ct)for(var t of ct(e))tr.call(e,t)&&lt(r,t,e[t]);return r},X=(r,e)=>zt(r,Qt(e));var rr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ut=(r,e)=>{for(var t in e)re(r,t,{get:e[t],enumerable:!0})},pt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zt(e))!dt.call(r,i)&&i!==t&&re(r,i,{get:()=>e[i],enumerable:!(n=Yt(e,i))||n.enumerable});return r};var nr=(r,e,t)=>(t=r!=null?Xt(er(r)):{},pt(e||!r||!r.__esModule?re(t,"default",{value:r,enumerable:!0}):t,r)),sr=r=>pt(re({},"__esModule",{value:!0}),r);var E=(r,e,t)=>new Promise((n,i)=>{var s=c=>{try{a(t.next(c))}catch(d){i(d)}},o=c=>{try{a(t.throw(c))}catch(d){i(d)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((t=t.apply(r,e)).next())});var Ct=rr((Un,Xe)=>{"use strict";var Qr=Object.prototype.hasOwnProperty,M="~";function ae(){}Object.create&&(ae.prototype=Object.create(null),new ae().__proto__||(M=!1));function Zr(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Nt(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Zr(t,n||r,i),o=M?M+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function Re(r,e){--r._eventsCount===0?r._events=new ae:delete r._events[e]}function b(){this._events=new ae,this._eventsCount=0}b.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Qr.call(t,n)&&e.push(M?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};b.prototype.listeners=function(e){var t=M?M+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};b.prototype.listenerCount=function(e){var t=M?M+e:e,n=this._events[t];return n?n.fn?1:n.length:0};b.prototype.emit=function(e,t,n,i,s,o){var a=M?M+e:e;if(!this._events[a])return!1;var c=this._events[a],d=arguments.length,u,m;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,o),!0}for(m=1,u=new Array(d-1);m<d;m++)u[m-1]=arguments[m];c.fn.apply(c.context,u)}else{var S=c.length,T;for(m=0;m<S;m++)switch(c[m].once&&this.removeListener(e,c[m].fn,void 0,!0),d){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,t);break;case 3:c[m].fn.call(c[m].context,t,n);break;case 4:c[m].fn.call(c[m].context,t,n,i);break;default:if(!u)for(T=1,u=new Array(d-1);T<d;T++)u[T-1]=arguments[T];c[m].fn.apply(c[m].context,u)}}return!0};b.prototype.on=function(e,t,n){return Nt(this,e,t,n,!1)};b.prototype.once=function(e,t,n){return Nt(this,e,t,n,!0)};b.prototype.removeListener=function(e,t,n,i){var s=M?M+e:e;if(!this._events[s])return this;if(!t)return Re(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&Re(this,s);else{for(var a=0,c=[],d=o.length;a<d;a++)(o[a].fn!==t||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:Re(this,s)}return this};b.prototype.removeAllListeners=function(e){var t;return e?(t=M?M+e:e,this._events[t]&&Re(this,t)):(this._events=new ae,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=M;b.EventEmitter=b;typeof Xe<"u"&&(Xe.exports=b)});var bn={};ut(bn,{Extension:()=>B,MagicExtensionError:()=>V,MagicExtensionWarning:()=>Q,MagicRPCError:()=>L,MagicSDKError:()=>$,MagicSDKWarning:()=>D,SDKBase:()=>ue,STORE_KEY_PRIVATE_KEY:()=>we,STORE_KEY_PUBLIC_JWK:()=>le,TypedEmitter:()=>ve,ViewController:()=>Oe,clearKeys:()=>cn,createDeprecationWarning:()=>He,createDuplicateIframeWarning:()=>Hr,createExtensionNotInitializedError:()=>Ge,createIncompatibleExtensionsError:()=>Ke,createInvalidArgumentError:()=>je,createJwt:()=>et,createMalformedResponseError:()=>Je,createMissingApiKeyError:()=>Fe,createModalNotReadyError:()=>We,createPromiEvent:()=>P,createPromise:()=>Ie,createReactNativeEndpointConfigurationWarning:()=>Ve,createSDK:()=>wt,createSynchronousWeb3MethodWarning:()=>Be,createTypedEmitter:()=>ce,createURL:()=>Me,decodeJSON:()=>De,encodeJSON:()=>oe,getPayloadId:()=>ye,isEmpty:()=>Y,isJsonRpcErrorCode:()=>Ue,isJsonRpcRequestPayload:()=>Br,isJsonRpcResponsePayload:()=>qe,isMagicPayloadMethod:()=>Vr,isMajorVersionAtLeast:()=>Ye,isPromiEvent:()=>ze,isWebCryptoSupported:()=>ee,storage:()=>Z,uuid:()=>Ze});module.exports=sr(bn);function ir(r){let e={exports:{}};return r(e,e.exports),e.exports}var or=Number.MAX_SAFE_INTEGER||9007199254740991;var ke={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:or,MAX_SAFE_COMPONENT_LENGTH:16},ar=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{},g=ar,ie=ir(function(r,e){let{MAX_SAFE_COMPONENT_LENGTH:t}=ke,n=(e=r.exports={}).re=[],i=e.src=[],s=e.t={},o=0,a=(c,d,u)=>{let m=o++;g(m,d),s[c]=m,i[m]=d,n[m]=new RegExp(d,u?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${i[s.NUMERICIDENTIFIER]})\\.(${i[s.NUMERICIDENTIFIER]})\\.(${i[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${i[s.NUMERICIDENTIFIERLOOSE]})\\.(${i[s.NUMERICIDENTIFIERLOOSE]})\\.(${i[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${i[s.NUMERICIDENTIFIER]}|${i[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${i[s.NUMERICIDENTIFIERLOOSE]}|${i[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${i[s.PRERELEASEIDENTIFIER]}(?:\\.${i[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${i[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${i[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${i[s.BUILDIDENTIFIER]}(?:\\.${i[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${i[s.MAINVERSION]}${i[s.PRERELEASE]}?${i[s.BUILD]}?`),a("FULL",`^${i[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${i[s.MAINVERSIONLOOSE]}${i[s.PRERELEASELOOSE]}?${i[s.BUILD]}?`),a("LOOSE",`^${i[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${i[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${i[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${i[s.XRANGEIDENTIFIER]})(?:\\.(${i[s.XRANGEIDENTIFIER]})(?:\\.(${i[s.XRANGEIDENTIFIER]})(?:${i[s.PRERELEASE]})?${i[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${i[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[s.XRANGEIDENTIFIERLOOSE]})(?:${i[s.PRERELEASELOOSE]})?${i[s.BUILD]}?)?)?`),a("XRANGE",`^${i[s.GTLT]}\\s*${i[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${i[s.GTLT]}\\s*${i[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),a("COERCERTL",i[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${i[s.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",a("TILDE",`^${i[s.LONETILDE]}${i[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${i[s.LONETILDE]}${i[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${i[s.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",a("CARET",`^${i[s.LONECARET]}${i[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${i[s.LONECARET]}${i[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${i[s.GTLT]}\\s*(${i[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${i[s.GTLT]}\\s*(${i[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${i[s.GTLT]}\\s*(${i[s.LOOSEPLAIN]}|${i[s.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${i[s.XRANGEPLAIN]})\\s+-\\s+(${i[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${i[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${i[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),mt=/^[0-9]+$/,It=(r,e)=>{let t=mt.test(r),n=mt.test(e);return t&&n&&(r=+r,e=+e),r===e?0:t&&!n?-1:n&&!t?1:r<e?-1:1},cr=(r,e)=>It(e,r),lr={compareIdentifiers:It,rcompareIdentifiers:cr},{MAX_LENGTH:ht,MAX_SAFE_INTEGER:me}=ke,{re:Et,t:ft}=ie,{compareIdentifiers:ne}=lr,y=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof y){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>ht)throw new TypeError(`version is longer than ${ht} characters`);g("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let n=e.trim().match(t.loose?Et[ft.LOOSE]:Et[ft.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let s=+i;if(s>=0&&s<me)return s}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(g("SemVer.compare",this.version,this.options,e),!(e instanceof y)){if(typeof e=="string"&&e===this.version)return 0;e=new y(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof y||(e=new y(e,this.options)),ne(this.major,e.major)||ne(this.minor,e.minor)||ne(this.patch,e.patch)}comparePre(e){if(e instanceof y||(e=new y(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let n=this.prerelease[t],i=e.prerelease[t];if(g("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n!==i)return ne(n,i)}while(++t)}compareBuild(e){e instanceof y||(e=new y(e,this.options));let t=0;do{let n=this.build[t],i=e.build[t];if(g("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n!==i)return ne(n,i)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);break;case"major":this.minor===0&&this.patch===0&&this.prerelease.length!==0||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":this.patch===0&&this.prerelease.length!==0||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let n=this.prerelease.length;for(;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);n===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},dr=(r,e,t)=>new y(r,t).compare(new y(e,t)),z=dr,ur=(r,e,t)=>z(r,e,t)===0,pr=ur,mr=(r,e,t)=>z(r,e,t)!==0,hr=mr,Er=(r,e,t)=>z(r,e,t)>0,fr=Er,gr=(r,e,t)=>z(r,e,t)>=0,yr=gr,Rr=(r,e,t)=>z(r,e,t)<0,vr=Rr,Tr=(r,e,t)=>z(r,e,t)<=0,Ir=Tr,br=(r,e,t,n)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return pr(r,t,n);case"!=":return hr(r,t,n);case">":return fr(r,t,n);case">=":return yr(r,t,n);case"<":return vr(r,t,n);case"<=":return Ir(r,t,n);default:throw new TypeError(`Invalid operator: ${e}`)}},_e=br,se=Symbol("SemVer ANY"),J=class{static get ANY(){return se}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof J){if(e.loose===!!t.loose)return e;e=e.value}g("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===se?this.value="":this.value=this.operator+this.semver.version,g("comp",this)}parse(e){let t=this.options.loose?gt[yt.COMPARATORLOOSE]:gt[yt.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new y(n[2],this.options.loose):this.semver=se}toString(){return this.value}test(e){if(g("Comparator.test",e,this.options.loose),this.semver===se||e===se)return!0;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}return _e(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof J))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new _(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new _(this.value,t).test(e.semver);let n=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),i=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),s=this.semver.version===e.semver.version,o=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),a=_e(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),c=_e(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return n||i||s&&o||a||c}},{re:gt,t:yt}=ie,_=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof _)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new _(e.raw,t);if(e instanceof J)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let n=t?I[R.HYPHENRANGELOOSE]:I[R.HYPHENRANGE];e=e.replace(n,kr(this.options.includePrerelease)),g("hyphen replace",e),e=e.replace(I[R.COMPARATORTRIM],Pr),g("comparator trim",e,I[R.COMPARATORTRIM]),e=(e=(e=e.replace(I[R.TILDETRIM],wr)).replace(I[R.CARETTRIM],xr)).split(/\s+/).join(" ");let i=t?I[R.COMPARATORLOOSE]:I[R.COMPARATOR];return e.split(" ").map(s=>Mr(s,this.options)).join(" ").split(/\s+/).map(s=>_r(s,this.options)).filter(this.options.loose?s=>!!s.match(i):()=>!0).map(s=>new J(s,this.options))}intersects(e,t){if(!(e instanceof _))throw new TypeError("a Range is required");return this.set.some(n=>Rt(n,t)&&e.set.some(i=>Rt(i,t)&&n.every(s=>i.every(o=>s.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new y(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(Dr(this.set[t],e,this.options))return!0;return!1}},{re:I,t:R,comparatorTrimReplace:Pr,tildeTrimReplace:wr,caretTrimReplace:xr}=ie,Rt=(r,e)=>{let t=!0,n=r.slice(),i=n.pop();for(;t&&n.length;)t=n.every(s=>i.intersects(s,e)),i=n.pop();return t},Mr=(r,e)=>(g("comp",r,e),r=Cr(r,e),g("caret",r),r=Sr(r,e),g("tildes",r),r=$r(r,e),g("xrange",r),r=Or(r,e),g("stars",r),r),x=r=>!r||r.toLowerCase()==="x"||r==="*",Sr=(r,e)=>r.trim().split(/\s+/).map(t=>Nr(t,e)).join(" "),Nr=(r,e)=>{let t=e.loose?I[R.TILDELOOSE]:I[R.TILDE];return r.replace(t,(n,i,s,o,a)=>{let c;return g("tilde",r,n,i,s,o,a),x(i)?c="":x(s)?c=`>=${i}.0.0 <${+i+1}.0.0-0`:x(o)?c=`>=${i}.${s}.0 <${i}.${+s+1}.0-0`:a?(g("replaceTilde pr",a),c=`>=${i}.${s}.${o}-${a} <${i}.${+s+1}.0-0`):c=`>=${i}.${s}.${o} <${i}.${+s+1}.0-0`,g("tilde return",c),c})},Cr=(r,e)=>r.trim().split(/\s+/).map(t=>Ar(t,e)).join(" "),Ar=(r,e)=>{g("caret",r,e);let t=e.loose?I[R.CARETLOOSE]:I[R.CARET],n=e.includePrerelease?"-0":"";return r.replace(t,(i,s,o,a,c)=>{let d;return g("caret",r,i,s,o,a,c),x(s)?d="":x(o)?d=`>=${s}.0.0${n} <${+s+1}.0.0-0`:x(a)?d=s==="0"?`>=${s}.${o}.0${n} <${s}.${+o+1}.0-0`:`>=${s}.${o}.0${n} <${+s+1}.0.0-0`:c?(g("replaceCaret pr",c),d=s==="0"?o==="0"?`>=${s}.${o}.${a}-${c} <${s}.${o}.${+a+1}-0`:`>=${s}.${o}.${a}-${c} <${s}.${+o+1}.0-0`:`>=${s}.${o}.${a}-${c} <${+s+1}.0.0-0`):(g("no pr"),d=s==="0"?o==="0"?`>=${s}.${o}.${a}${n} <${s}.${o}.${+a+1}-0`:`>=${s}.${o}.${a}${n} <${s}.${+o+1}.0-0`:`>=${s}.${o}.${a} <${+s+1}.0.0-0`),g("caret return",d),d})},$r=(r,e)=>(g("replaceXRanges",r,e),r.split(/\s+/).map(t=>Lr(t,e)).join(" ")),Lr=(r,e)=>{r=r.trim();let t=e.loose?I[R.XRANGELOOSE]:I[R.XRANGE];return r.replace(t,(n,i,s,o,a,c)=>{g("xRange",r,n,i,s,o,a,c);let d=x(s),u=d||x(o),m=u||x(a),S=m;return i==="="&&S&&(i=""),c=e.includePrerelease?"-0":"",d?n=i===">"||i==="<"?"<0.0.0-0":"*":i&&S?(u&&(o=0),a=0,i===">"?(i=">=",u?(s=+s+1,o=0,a=0):(o=+o+1,a=0)):i==="<="&&(i="<",u?s=+s+1:o=+o+1),i==="<"&&(c="-0"),n=`${i+s}.${o}.${a}${c}`):u?n=`>=${s}.0.0${c} <${+s+1}.0.0-0`:m&&(n=`>=${s}.${o}.0${c} <${s}.${+o+1}.0-0`),g("xRange return",n),n})},Or=(r,e)=>(g("replaceStars",r,e),r.trim().replace(I[R.STAR],"")),_r=(r,e)=>(g("replaceGTE0",r,e),r.trim().replace(I[e.includePrerelease?R.GTE0PRE:R.GTE0],"")),kr=r=>(e,t,n,i,s,o,a,c,d,u,m,S,T)=>`${t=x(n)?"":x(i)?`>=${n}.0.0${r?"-0":""}`:x(s)?`>=${n}.${i}.0${r?"-0":""}`:o?`>=${t}`:`>=${t}${r?"-0":""}`} ${c=x(d)?"":x(u)?`<${+d+1}.0.0-0`:x(m)?`<${d}.${+u+1}.0-0`:S?`<=${d}.${u}.${m}-${S}`:r?`<${d}.${u}.${+m+1}-0`:`<=${c}`}`.trim(),Dr=(r,e,t)=>{for(let n=0;n<r.length;n++)if(!r[n].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let n=0;n<r.length;n++)if(g(r[n].semver),r[n].semver!==J.ANY&&r[n].semver.prerelease.length>0){let i=r[n].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0},bt=(r,e,t)=>{try{e=new _(e,t)}catch(n){return!1}return e.test(r)};var{MAX_LENGTH:qr}=ke,{re:vt,t:Tt}=ie,Ur=(r,e)=>{if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),r instanceof y)return r;if(typeof r!="string"||r.length>qr||!(e.loose?vt[Tt.LOOSE]:vt[Tt.FULL]).test(r))return null;try{return new y(r,e)}catch(t){return null}},Fr=Ur,{re:he,t:Ee}=ie,Pt=(r,e)=>{if(r instanceof y)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;let t=null;if((e=e||{}).rtl){let n;for(;(n=he[Ee.COERCERTL].exec(r))&&(!t||t.index+t[0].length!==r.length);)t&&n.index+n[0].length===t.index+t[0].length||(t=n),he[Ee.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;he[Ee.COERCERTL].lastIndex=-1}else t=r.match(he[Ee.COERCE]);return t===null?null:Fr(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)};function Wr(r){return String.fromCharCode(parseInt(r.slice(1),16))}function Jr(r){return`%${`00${r.charCodeAt(0).toString(16)}`.slice(-2)}`}function Gr(r){return btoa(encodeURIComponent(r).replace(/%[0-9A-F]{2}/g,Wr))}function Kr(r){return decodeURIComponent(Array.from(atob(r),Jr).join(""))}function oe(r){return Gr(JSON.stringify(r))}function De(r){return JSON.parse(Kr(r))}var N=require("@magic-sdk/types");var fe=require("@magic-sdk/types");function k(r){return typeof r=="undefined"}function jr(r){return r===null}function ge(r){return jr(r)||k(r)}function Br(r){return ge(r)?!1:!k(r.jsonrpc)&&!k(r.id)&&!k(r.method)&&!k(r.params)}function qe(r){return ge(r)?!1:!k(r.jsonrpc)&&!k(r.id)&&(!k(r.result)||!k(r.error))}function Vr(r){return ge(r)?!1:typeof r=="string"&&Object.values(fe.MagicPayloadMethod).includes(r)}function Ue(r){return ge(r)?!1:typeof r=="number"&&Object.values(fe.RPCErrorCode).includes(r)}function Y(r){if(!r)return!0;for(let e in r)if(Object.hasOwnProperty.call(r,e))return!1;return!0}var f={};function wt(r,e){return Object.assign(f,e),r}var xt={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"};var $=class extends Error{constructor(t,n){super(`Magic SDK Error: [${t}] ${n}`);this.code=t;this.rawMessage=n;this.__proto__=Error;Object.setPrototypeOf(this,$.prototype)}},L=class extends Error{constructor(t){super();this.__proto__=Error;let n=Number(t==null?void 0:t.code);this.rawMessage=(t==null?void 0:t.message)||"Internal error",this.code=Ue(n)?n:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(t==null?void 0:t.data)||void 0,Object.setPrototypeOf(this,L.prototype)}},D=class{constructor(e,t){this.code=e;this.rawMessage=t;this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},V=class extends Error{constructor(t,n,i,s){super(`Magic Extension Error (${t.name}): [${n}] ${i}`);this.code=n;this.rawMessage=i;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,V.prototype)}},Q=class{constructor(e,t,n){this.code=t;this.rawMessage=n;this.message=`Magic Extension Warning (${e.name}): [${t}] ${n}`}log(){console.warn(this.message)}};function Fe(){return new $(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function We(){return new $(N.SDKErrorCode.ModalNotReady,"Modal is not ready")}function Je(){return new $(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ge(r){return new $(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${r}\` can be accessed. Do not invoke \`Extension.${r}\` inside an extension constructor.`)}function Ke(r){let e=`Some extensions are incompatible with \`${f.sdkName}@${f.version}\`:`;return r.filter(t=>typeof t.compat!="undefined"&&t.compat!==null).forEach(t=>{let n=t.compat[f.sdkName];typeof n=="string"?e+=`
2
2
  - Extension \`${t.name}\` supports version(s) \`${n}\``:n||(e+=`
3
3
  - Extension \`${t.name}\` does not support ${f.platform} environments.`)}),new $(N.SDKErrorCode.IncompatibleExtensions,e)}function je(r){let e=t=>{let n=t+1,i=n%10,s=n%100;return i===1&&s!==11?`${n}st`:i===2&&s!==12?`${n}nd`:i===3&&s!==13?`${n}rd`:`${n}th`};return new $(N.SDKErrorCode.InvalidArgument,`Invalid ${e(r.argument)} argument given to \`${r.procedure}\`.
4
4
  Expected: \`${r.expected}\`
5
- Received: \`${r.received}\``)}function Hr(){return new D(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Be(){return new D(N.SDKWarningCode.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Ve(){return new D(N.SDKWarningCode.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${f.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function He(r){let{method:e,removalVersions:t,useInstead:n}=r,i=t[f.sdkName],s=n?` Use \`${n}\` instead.`:"",o=`\`${e}\` will be removed from \`${f.sdkName}\` in version \`${i}\`.${s}`;return new D(N.SDKWarningCode.DeprecationNotice,o)}var p=require("@magic-sdk/types");var K=require("@magic-sdk/types");function*Xr(){let r=0;for(;;)r<Number.MAX_SAFE_INTEGER?yield++r:r=0}var Yr=Xr();function ye(){return Yr.next().value}var Mt=Symbol("Payload pre-processed by Magic SDK");function St(r){return Object.defineProperty(r,Mt,{value:!0,enumerable:!1}),r}function zr(r){return!!r[Mt]}function H(r){var e,t,n;return zr(r)||(r.jsonrpc=(e=r.jsonrpc)!=null?e:"2.0",r.id=ye(),r.method=(t=r.method)!=null?t:"noop",r.params=(n=r.params)!=null?n:[],St(r)),r}function m(r,e=[]){return St({params:e,method:r,jsonrpc:"2.0",id:ye()})}var G=class{constructor(e){e instanceof G?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):qe(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var Te=require("@magic-sdk/types");var At=nr(Ct()),ve=class extends At.default{};function ce(){let r=new ve;return{emitter:r,createChainingEmitterMethod:(n,i)=>(...s)=>(r[n].apply(r,s),i),createBoundEmitterMethod:n=>(...i)=>r[n].apply(r,i)}}var $t=Symbol("isPromiEvent");function Ye(r){return!!r[$t]}function P(r){let e=Ie(r),{createBoundEmitterMethod:t,createChainingEmitterMethod:n}=ce(),i=Symbol("Promise.then"),s=Symbol("Promise.catch"),o=Symbol("Promise.finally"),a=(u,h)=>(...S)=>{let T=h[u].apply(h,S);return c(T)},c=u=>Object.assign(u,{[$t]:!0,[i]:u[i]||u.then,[s]:u[s]||u.catch,[o]:u[o]||u.finally,then:a(i,u),catch:a(s,u),finally:a(o,u),on:n("on",u),once:n("once",u),addListener:n("addListener",u),off:n("off",u),removeListener:n("removeListener",u),removeAllListeners:n("removeAllListeners",u),emit:t("emit"),eventNames:t("eventNames"),listeners:t("listeners"),listenerCount:t("listenerCount")}),d=c(e.then(u=>(d.emit("done",u),d.emit("settled"),u),u=>{throw d.emit("error",u),d.emit("settled"),u}));return d.on(Te.UserEventsOnReceived.ClosedByUser,()=>{d.emit(Te.UserEventsEmit.ClosedByUser)}),d}function Ie(r){return new Promise((e,t)=>{let n=r(e,t);Promise.resolve(n).catch(t)})}var v=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){if(this.sdk.thirdPartyWallets.isConnected&&!K.routeToMagicMethods.includes(e.method))return P((o,a)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(o).catch(a)});let t=this.overlay.post(K.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,H(e)),n=P((s,o)=>{t.then(a=>{if(i(),a.hasError)o(new L(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Je()}).catch(a=>{i(),o(a)})}),i=this.overlay.on(K.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var a;let{response:o}=s.data;if(o.id===e.id&&((a=o.result)==null?void 0:a.event)){let{event:c,params:d=[]}=o.result;n.emit(c,...d)}});return n}createIntermediaryEvent(e,t){return i=>{let s=m(K.MagicPayloadMethod.IntermediaryEvent,[{payloadId:t,eventType:e,args:i}]);this.request(s)}}};function ze(r,e){let[t]=r.split(".").map(Number);return t>=e}var en={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},be=class extends v{loginWithMagicLink(e){let t=f.sdkName==="@magic-sdk/react-native"||f.sdkName==="@magic-sdk/react-native-bare"||f.sdkName==="@magic-sdk/react-native-expo";if(t&&ze(f.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&He({method:"auth.loginWithMagicLink()",removalVersions:en,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:n,showUI:i=!0,redirectURI:s,overrides:o,lifespan:a}=e,c=m(this.sdk.testMode?p.MagicPayloadMethod.LoginWithMagicLinkTestMode:p.MagicPayloadMethod.LoginWithMagicLink,[{email:n,showUI:i,redirectURI:s,overrides:o,lifespan:a}]);return this.request(c)}loginWithSMS(e){let{phoneNumber:t,showUI:n=!0,lifespan:i}=e,s=m(this.sdk.testMode?p.MagicPayloadMethod.LoginWithSmsTestMode:p.MagicPayloadMethod.LoginWithSms,[{phoneNumber:t,showUI:n,lifespan:i}]),o=this.request(s);return!n&&o&&(o.on(p.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(p.LoginWithSmsOTPEventEmit.VerifySmsOtp,s.id)(a)}),o.on(p.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.LoginWithSmsOTPEventEmit.Cancel,s.id)()})),o}loginWithEmailOTP(e){let{email:t,showUI:n,deviceCheckUI:i,overrides:s,lifespan:o}=e,a=m(this.sdk.testMode?p.MagicPayloadMethod.LoginWithEmailOTPTestMode:p.MagicPayloadMethod.LoginWithEmailOTP,[{email:t,showUI:n,deviceCheckUI:i,overrides:s,lifespan:o}]),c=this.request(a);return!i&&c&&c.on(p.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(p.DeviceVerificationEventEmit.Retry,a.id)()}),!n&&c&&(c.on(p.LoginWithEmailOTPEventEmit.VerifyEmailOtp,d=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(d)}),c.on(p.LoginWithEmailOTPEventEmit.VerifyMFACode,d=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(d)}),c.on(p.LoginWithEmailOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.LostDevice,a.id)()}),c.on(p.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,d=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,a.id)(d)}),c.on(p.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:n}=e||{},i=t!=null?t:"";if(!t&&f.platform==="web"){i=window.location.search;let o=window.location.origin+window.location.pathname;window.history.replaceState(null,"",o)}let s=m(this.sdk.testMode?p.MagicPayloadMethod.LoginWithCredentialTestMode:p.MagicPayloadMethod.LoginWithCredential,[i,n]);return this.request(s)}setAuthorizationToken(e){let t=m(p.MagicPayloadMethod.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:n=!0}=e,i=m(this.sdk.testMode?p.MagicPayloadMethod.UpdateEmailTestMode:p.MagicPayloadMethod.UpdateEmail,[{email:t,showUI:n}]),s=this.request(i);return n||(s.on(p.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.Retry,i.id)()}),s.on(p.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.Cancel,i.id)()}),s.on(p.RecencyCheckEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.VerifyEmailOtp,i.id)(o)}),s.on(p.RecencyCheckEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.VerifyMFACode,i.id)(o)}),s.on(p.UpdateEmailEventEmit.RetryWithNewEmail,o=>{this.createIntermediaryEvent(p.UpdateEmailEventEmit.RetryWithNewEmail,i.id)(o)}),s.on(p.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.UpdateEmailEventEmit.Cancel,i.id)()}),s.on(p.UpdateEmailEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(p.UpdateEmailEventEmit.VerifyEmailOtp,i.id)(o)})),s}};var l=require("@magic-sdk/types");var Z={};ut(Z,{clear:()=>tn,getItem:()=>w,iterate:()=>Qe,key:()=>nn,keys:()=>sn,length:()=>rn,removeItem:()=>q,setItem:()=>A});var Pe;function j(r){return(...e)=>E(this,null,function*(){return Pe||(Pe=yield f.configureStorage()),yield Pe.ready(),Pe[r](...e)})}var w=j("getItem"),A=j("setItem"),q=j("removeItem"),tn=j("clear"),rn=j("length"),nn=j("key"),sn=j("keys"),Qe=j("iterate");function Ze(){let r=window.crypto.getRandomValues(new Uint8Array(16));r[6]=r[6]&15|64,r[8]=r[8]&191|128;let e="";return e+=r[0].toString(16),e+=r[1].toString(16),e+=r[2].toString(16),e+=r[3].toString(16),e+="-",e+=r[4].toString(16),e+=r[5].toString(16),e+="-",e+=r[6].toString(16),e+=r[7].toString(16),e+="-",e+=r[8].toString(16),e+=r[9].toString(16),e+="-",e+=r[10].toString(16),e+=r[11].toString(16),e+=r[12].toString(16),e+=r[13].toString(16),e+=r[14].toString(16),e+=r[15].toString(16),e}var we="STORE_KEY_PRIVATE_KEY",le="STORE_KEY_PUBLIC_JWK",Ot="ECDSA",on="P-256",an={name:Ot,namedCurve:on};function ee(){let r=typeof window!="undefined"&&!!window.crypto,e=r&&!!window.crypto.subtle;return r&&e}function cn(){q(le),q(we)}function et(){return E(this,null,function*(){let r=yield ln();if(!r){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:e}=window.crypto,t=yield w(we);if(!t||!e){console.info("unable to find private key or webcrypto unsupported");return}let n={iat:Math.floor(new Date().getTime()/1e3),jti:Ze()},i={typ:"dpop+jwt",alg:"ES256",jwk:r},s={protected:Lt(JSON.stringify(i)),claims:Lt(JSON.stringify(n))},o=un(`${s.protected}.${s.claims}`),a={name:Ot,hash:{name:"SHA-256"}},c=hn(new Uint8Array(yield e.sign(a,t,o)));return`${s.protected}.${s.claims}.${c}`})}function ln(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}return(yield w(le))||(yield dn()),w(le)})}function dn(){return E(this,null,function*(){let{subtle:r}=window.crypto,e=yield r.generateKey(an,!1,["sign"]),t=yield r.exportKey("jwk",e.publicKey);yield A(we,e.privateKey),yield A(le,t)})}function Lt(r){return _t(pn(r))}function un(r){return new TextEncoder().encode(r)}function _t(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function pn(r){return encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(n,16)))}function hn(r){let e="";return r.forEach(t=>{e+=String.fromCharCode(t)}),_t(e)}var tt="ds",rt="ek",nt="iv",st="AES-GCM",mn=256;function xe(){return E(this,null,function*(){let r=[];yield Qe((e,t,n)=>{t.startsWith(`${tt}_`)&&r.push(t)});for(let e of r)yield q(e)})}function kt(r){let e="",t=new Uint8Array(r),n=t.byteLength;for(let i=0;i<n;i++)e+=String.fromCharCode(t[i]);return window.btoa(e)}function Dt(r){let e=window.atob(r),t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}function En(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{crypto:r}=window,e=yield w(nt);return e||r.getRandomValues(new Uint8Array(12))})}function fn(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{subtle:r}=window.crypto,e=yield w(rt);return e||(yield r.generateKey({name:st,length:mn},!1,["encrypt","decrypt"]))})}function qt(r,e){return E(this,null,function*(){let t=yield En(),n=yield fn();if(!t||!n||!r)return;let i=Dt(r),{subtle:s}=window.crypto,o=yield s.encrypt({name:st,iv:t},n,i),a=kt(o);yield A(`${tt}_${e}`,a),yield A(rt,n),yield A(nt,t)})}function Ut(r){return E(this,null,function*(){let e=yield w(`${tt}_${r}`),t=yield w(nt),n=yield w(rt);if(!t||!e||!n||!ee())return;let{subtle:i}=window.crypto,s=yield i.decrypt({name:st,iv:t},n,Dt(e));return kt(s)})}function Me(r,e){return e?new URL(r,e):new URL(r)}var Se=class extends v{constructor(){super(...arguments);this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(t){let n=m(this.sdk.testMode?l.MagicPayloadMethod.GetIdTokenTestMode:l.MagicPayloadMethod.GetIdToken,[t]);return this.request(n)}generateIdToken(t){let n=m(this.sdk.testMode?l.MagicPayloadMethod.GenerateIdTokenTestMode:l.MagicPayloadMethod.GenerateIdToken,[t]);return this.request(n)}getInfo(){let t=m(l.MagicPayloadMethod.GetInfo,[]);return this.request(t)}isLoggedIn(){return P((t,n)=>E(this,null,function*(){try{let i=!1;this.sdk.useStorageCache&&(i=(yield w(this.localForageIsLoggedInKey))==="true",i&&t(!0));let s=m(this.sdk.testMode?l.MagicPayloadMethod.IsLoggedInTestMode:l.MagicPayloadMethod.IsLoggedIn),o=yield this.request(s);this.sdk.useStorageCache&&(o?A(this.localForageIsLoggedInKey,!0):q(this.localForageIsLoggedInKey),i&&!o&&this.emitUserLoggedOut(!0)),t(o)}catch(i){n(i)}}))}logout(){return q(this.localForageIsLoggedInKey),xe(),P((t,n)=>E(this,null,function*(){try{let i=m(this.sdk.testMode?l.MagicPayloadMethod.LogoutTestMode:l.MagicPayloadMethod.Logout),s=yield this.request(i);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),t(s)}catch(i){n(i)}}))}requestInfoWithUI(t){let n=m(l.MagicPayloadMethod.RequestUserInfoWithUI,t?[t]:[]);return this.request(n)}showSettings(t){let{showUI:n=!0}=t||{},i=m(this.sdk.testMode?l.MagicPayloadMethod.UserSettingsTestMode:l.MagicPayloadMethod.UserSettings,[t]),s=this.request(i);return!n&&s&&(s.on(l.RecoveryFactorEventEmit.SendNewPhoneNumber,o=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendNewPhoneNumber,i.id)(o)}),s.on(l.RecoveryFactorEventEmit.SendOtpCode,o=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendOtpCode,i.id)(o)}),s.on(l.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.StartEditPhoneNumber,i.id)()}),s.on(l.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.Cancel,i.id)()}),s.on(l.RecencyCheckEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(l.RecencyCheckEventEmit.VerifyEmailOtp,i.id)(o)})),s}recoverAccount(t){let{email:n,showUI:i}=t,s=m(this.sdk.testMode?l.MagicPayloadMethod.RecoverAccountTestMode:l.MagicPayloadMethod.RecoverAccount,[{email:n,showUI:i}]),o=this.request(s);return!i&&o&&(o.on(l.RecoverAccountEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.Cancel,s.id)()}),o.on(l.RecoverAccountEventEmit.ResendSms,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.ResendSms,s.id)()}),o.on(l.RecoverAccountEventEmit.VerifyOtp,a=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.VerifyOtp,s.id)(a)}),o.on(l.RecoverAccountEventEmit.UpdateEmail,a=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.UpdateEmail,s.id)(a)}),o.on(l.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.Cancel,s.id)()}),o.on(l.UpdateEmailEventEmit.RetryWithNewEmail,a=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.RetryWithNewEmail,s.id)(a)}),o.on(l.UpdateEmailEventEmit.VerifyEmailOtp,a=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.VerifyEmailOtp,s.id)(a)})),o}revealPrivateKey(){let t=m(l.MagicPayloadMethod.RevealPK);return this.request(t)}onUserLoggedOut(t){this.userLoggedOutCallbacks.push(t)}enableMFA(t){let{showUI:n=!0}=t,i=m(l.MagicPayloadMethod.EnableMFA,[{showUI:n}]),s=this.request(i);return!n&&s&&(s.on(l.EnableMFAEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.VerifyMFACode,i.id)(o)}),s.on(l.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.Cancel,i.id)()})),s}disableMFA(t){let{showUI:n=!0}=t,i=m(l.MagicPayloadMethod.DisableMFA,[{showUI:n}]),s=this.request(i);return!n&&s&&(s.on(l.DisableMFAEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.VerifyMFACode,i.id)(o)}),s.on(l.DisableMFAEventEmit.LostDevice,o=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.LostDevice,i.id)(o)}),s.on(l.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.Cancel,i.id)()})),s}emitUserLoggedOut(t){this.userLoggedOutCallbacks.forEach(n=>{n(t)})}};var U=require("@magic-sdk/types");var Ne=class extends v{connectWithUI(e){let t=P((n,i)=>E(this,null,function*(){try{let s=m(U.MagicPayloadMethod.Login,[W({enabledWallets:this.sdk.thirdPartyWallets.enabledWallets},e)]),o=this.request(s);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:c,callback:d})=>{o.on(c,()=>d(s.id))}),o.on("id-token-created",c=>{t.emit("id-token-created",c)});let a=yield o;a.error&&i(a),n(a)}catch(s){i(s)}}));return t}showUI(e){return this.request(m(U.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(m(U.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(m(U.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(m(U.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(m(U.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(m(U.MagicPayloadMethod.ShowBalances))}sendGaslessTransaction(e,t){return this.request(m(U.MagicPayloadMethod.SendGaslessTransaction,[e,t]))}};var C=require("@magic-sdk/types");var Ce=class extends v{constructor(){super(...arguments);this.eventListeners=[];this.enabledWallets={};this.isConnected=!1}resetThirdPartyWalletState(){localStorage.removeItem(C.LocalStorageKeys.PROVIDER),localStorage.removeItem(C.LocalStorageKeys.ADDRESS),localStorage.removeItem(C.LocalStorageKeys.CHAIN_ID),this.isConnected=!1}requestOverride(t){if(t.method===C.MagicPayloadMethod.Login)return this.resetThirdPartyWalletState(),super.request(t);if(t.method===C.MagicPayloadMethod.GetInfo)return this.getInfo(t);if(t.method===C.MagicPayloadMethod.IsLoggedIn)return this.isLoggedIn(t);if(t.method===C.MagicPayloadMethod.Logout)return this.logout(t);switch(localStorage.getItem(C.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalRequest(t);default:return this.resetThirdPartyWalletState(),super.request(t)}}isLoggedIn(t){switch(localStorage.getItem(C.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();default:return this.resetThirdPartyWalletState(),super.request(t)}}getInfo(t){switch(localStorage.getItem(C.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalGetInfo();default:return this.resetThirdPartyWalletState(),super.request(t)}}logout(t){let n=localStorage.getItem(C.LocalStorageKeys.PROVIDER);switch(this.resetThirdPartyWalletState(),n){case"web3modal":return this.web3modalLogout();default:return super.request(t)}}web3modalRequest(t){return P((n,i)=>{this.sdk.web3modal.modal.getWalletProvider().request(t).then(n).catch(i)})}web3modalIsLoggedIn(){return P(t=>{let n=this.sdk.web3modal.modal.getStatus();if(n==="connected"&&t(!0),n==="disconnected"&&(this.resetThirdPartyWalletState(),t(!1)),n==="reconnecting"){let i=this.sdk.web3modal.modal.subscribeProvider(({status:s})=>{s==="connected"&&(i(),t(!0)),s==="disconnected"&&(i(),this.resetThirdPartyWalletState(),t(!1))})}})}formatWeb3modalGetInfoResponse(){var i;let t=(i=this.sdk.web3modal.modal.getWalletInfo())==null?void 0:i.name,n=this.sdk.web3modal.modal.getAddress();return{publicAddress:n,email:null,issuer:`did:ethr:${n}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],walletType:t||"web3modal"}}web3modalGetInfo(){return P((t,n)=>{let i=this.sdk.web3modal.modal.getStatus();if(i==="connected"&&t(this.formatWeb3modalGetInfoResponse()),i==="disconnected"&&(this.resetThirdPartyWalletState(),n("Magic RPC Error: [-32603] Internal error: User denied account access.")),i==="reconnecting"){let s=this.sdk.web3modal.modal.subscribeProvider(({status:o})=>{o==="connected"&&(s(),t(this.formatWeb3modalGetInfoResponse())),o==="disconnected"&&(s(),this.resetThirdPartyWalletState(),n("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return P(t=>E(this,null,function*(){try{yield this.sdk.web3modal.modal.disconnect()}catch(n){console.error(n)}t(!0)}))}};var de=require("@magic-sdk/types");var{createBoundEmitterMethod:Ae,createChainingEmitterMethod:te}=ce(),$e=class extends v{constructor(){super(...arguments);this.isMagic=!0;this.on=te("on",this);this.once=te("once",this);this.addListener=te("addListener",this);this.off=te("off",this);this.removeListener=te("removeListener",this);this.removeAllListeners=te("removeAllListeners",this);this.emit=Ae("emit");this.eventNames=Ae("eventNames");this.listeners=Ae("listeners");this.listenerCount=Ae("listenerCount")}sendAsync(t,n){if(!n)throw je({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:n===null?"null":typeof n});if(Array.isArray(t))this.overlay.post(de.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,t.map(i=>{let s=H(i);return this.prefixPayloadMethodForTestMode(s),s})).then(i=>{n(null,i.map(s=>X(W({},s.payload),{error:s.hasError?new L(s.payload.error):null})))});else{let i=H(t);this.prefixPayloadMethodForTestMode(i),this.overlay.post(de.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,i).then(s=>{n(s.hasError?new L(s.payload.error):null,s.payload)})}}send(t,n){if(typeof t=="string"){let s=m(t,Array.isArray(n)?n:[]);return this.request(s)}if(Array.isArray(t)||!!n){this.sendAsync(t,n);return}let i=Be();return i.log(),new G(t).applyError({code:-32603,message:i.rawMessage}).payload}enable(){let t=m(de.MagicPayloadMethod.Login);return this.request(t)}request(t){return this.prefixPayloadMethodForTestMode(t),super.request(t)}prefixPayloadMethodForTestMode(t){let n="testMode/eth/";this.sdk.testMode&&(t.method=`${n}${t.method}`)}};var Ft=["request","overlay","sdk"];function gn(r){let e=Object.getPrototypeOf(r),t=[e];for(;e!==v.prototype;)e=Object.getPrototypeOf(e),t.push(e);return t}var it=class extends v{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:P,isPromiEvent:Ye,encodeJSON:oe,decodeJSON:De,createJsonRpcRequestPayload:m,standardizeJsonRpcRequestPayload:H,storage:Z};let t=[this,...gn(this)];Ft.forEach(n=>{let i=t.map(c=>Object.getOwnPropertyDescriptor(c,n)),s=i.findIndex(c=>Boolean(c)),o=s>0,a=i[s];a&&(this.__sdk_access_field_descriptors__.set(n,{descriptor:a,isPrototypeField:o}),Object.defineProperty(this,n,{configurable:!0,get:()=>{throw Ge(n)}}))})}init(t){this.__is_initialized__||(Ft.forEach(n=>{if(this.__sdk_access_field_descriptors__.has(n)){let{descriptor:i,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(n);s?delete this[n]:Object.defineProperty(this,n,i)}}),this.sdk=t,this.__is_initialized__=!0)}createDeprecationWarning(t){let{method:n,removalVersion:i,useInstead:s}=t,o=s?` Use \`${s}\` instead.`:"",a=`\`${n}\` will be removed from this Extension in version \`${i}\`.${o}`;return new Q(this,"DEPRECATION_NOTICE",a)}createWarning(t,n){return new Q(this,t,n)}createError(t,n,i){return new V(this,t,n,i)}},ot=class extends it{},B=class{};B.Internal=ot;var F=require("@magic-sdk/types");var Le=class extends v{purchase(e){let t=m(F.MagicPayloadMethod.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,n=m(F.MagicPayloadMethod.NFTCheckout,[X(W({},e),{walletProvider:t?"web3modal":"magic"})]),i=this.request(n);return t&&(i.on(F.NftCheckoutIntermediaryEvents.Initiated,s=>E(this,null,function*(){try{let o=yield this.request({method:"eth_sendTransaction",params:[s]});this.createIntermediaryEvent(F.NftCheckoutIntermediaryEvents.Success,n.id)(o)}catch(o){this.createIntermediaryEvent(F.NftCheckoutIntermediaryEvents.Failure,n.id)()}})),i.on(F.NftCheckoutIntermediaryEvents.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),i.emit("disconnect")})),i}transfer(e){let t=m(F.MagicPayloadMethod.NFTTransfer,[e]);return this.request(t)}};function Wt(r){return r.compat&&r.compat[f.sdkName]!=null?typeof r.compat[f.sdkName]=="string"?bt(Pt(f.version),r.compat[f.sdkName]):!!r.compat[f.sdkName]:!0}function yn(r,e,t){return!e&&!t?`${r}_eth_mainnet`:t?`${r}_${JSON.stringify(t)}`:e?typeof e=="string"?`${r}_eth_${e}`:`${r}_${e.rpcUrl}_${e.chainId}_${e.chainType}`:`${r}_unknown`}function Rn(r){var i;let e=(i=r==null?void 0:r.extensions)!=null?i:[],t={},n=[];if(Array.isArray(e)?e.forEach(s=>{Wt(s)?(s.init(this),s.name&&(this[s.name]=s),s instanceof B.Internal&&(z(s.config)||(t[s.name]=s.config))):n.push(s)}):Object.keys(e).forEach(s=>{if(Wt(e[s])){e[s].init(this);let o=e[s];this[s]=o,o instanceof B.Internal&&(z(o.config)||(t[e[s].name]=o.config))}else n.push(e[s])}),n.length)throw Ke(n);return t}var pe=class{constructor(e,t){this.apiKey=e;var o;if(!e)throw Fe();f.platform==="react-native"&&(t==null?void 0:t.endpoint)&&Ve().log();let{defaultEndpoint:n,version:i}=f;this.testMode=!!(t!=null&&t.testMode),this.useStorageCache=!!(t!=null&&t.useStorageCache),this.endpoint=Me((o=t==null?void 0:t.endpoint)!=null?o:n).origin,this.auth=new be(this),this.user=new Se(this),this.wallet=new Ne(this),this.nft=new Le(this),this.thirdPartyWallets=new Ce(this),this.rpcProvider=new $e(this);let s=Rn.call(this,t);this.parameters=oe(X(W({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:t==null?void 0:t.network,host:Me(this.endpoint).host,sdk:xt[f.sdkName],version:i,ext:z(s)?void 0:s,locale:(t==null?void 0:t.locale)||"en_US"},f.bundleId?{bundleId:f.bundleId}:{}),{meta:t==null?void 0:t.meta})),this.networkHash=yn(this.apiKey,t==null?void 0:t.network,z(s)?void 0:s),t!=null&&t.deferPreload||this.preload()}get overlay(){if(!pe.__overlays__.has(this.parameters)){let e=new f.ViewController(this.endpoint,this.parameters,this.networkHash);e.init(),pe.__overlays__.set(this.parameters,e)}return pe.__overlays__.get(this.parameters)}preload(){return E(this,null,function*(){yield this.overlay.waitForReady()})}},ue=pe;ue.__overlays__=new Map;var O=require("@magic-sdk/types");function vn(r,e){return e&&Array.isArray(r)?r.find(t=>t.id===e):r}function Jt(r,e){var i;let t=(i=e.data.response)==null?void 0:i.id,n=vn(r,t);if(t&&n){let s=new G(n).applyResult(e.data.response.result).applyError(e.data.response.error);return{id:t,response:s}}return{}}function Gt(r,e,t){return E(this,null,function*(){var a;let n=yield w("rt"),i;if(f.platform==="web")try{i=(a=yield w("jwt"))!=null?a:yield et()}catch(c){console.error("webcrypto error",c)}let s={msgType:r,payload:e};i&&(s.jwt=i),i&&n&&(s.rt=n);let o=yield Ut(t);return o&&(s.deviceShare=o),s})}function Kt(r){return E(this,null,function*(){!r.data.rt||(yield A("rt",r.data.rt))})}function jt(r,e){let t=null;return function(...n){t&&clearTimeout(t),t=setTimeout(()=>{r(...n)},e)}}var Tn=1e3,Vt=60*Tn,Bt=5*Vt,In=60*Vt,Oe=class{constructor(e,t,n){this.endpoint=e;this.parameters=t;this.networkHash=n;this.isReadyForRequest=!1;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.lastPongTime=null;this.heartbeatIntervalTimer=null;this.heartbeatDebounce=jt(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},In);this.listen()}post(e,t){return E(this,null,function*(){return Ie((n,i)=>E(this,null,function*(){if(console.log("isConnectedToInternet",this.isConnectedToInternet),!this.isConnectedToInternet){let u=We();i(u)}console.log("checkRelayerExistsInDOM",this.checkRelayerExistsInDOM()),(yield this.checkRelayerExistsInDOM())||(this.isReadyForRequest=!1,yield this.reloadRelayer()),console.log("isReadyForRequest",this.isReadyForRequest),this.isReadyForRequest||(yield this.waitForReady());let s=[],o=Array.isArray(t)?t.map(u=>u.id):[],a=yield Gt(`${e}-${this.parameters}`,t,this.networkHash);yield this._post(a);let c=u=>h=>{var at;let{id:S,response:T}=Jt(t,h);if(Kt(h),((at=T==null?void 0:T.payload.error)==null?void 0:at.message)==="User denied account access.")xe();else if(h.data.deviceShare){let{deviceShare:Ht}=h.data;qt(Ht,this.networkHash)}S&&T&&Array.isArray(t)&&o.includes(S)?(s.push(T),s.length===t.length&&(u(),n(s))):S&&T&&!Array.isArray(t)&&S===t.id&&(u(),n(T))},d=this.on(O.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>d()))}))})}on(e,t){console.log(window,"window");let n=t.bind(window),i=s=>{s.data.msgType===`${e}-${this.parameters}`&&n(s)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(O.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{console.log("OVERLAY_READY"),this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(O.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(O.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(O.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new D(O.SDKWarningCode.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=()=>E(this,null,function*(){let n={msgType:`${O.MagicOutgoingWindowMessage.MAGIC_PING}-${this.parameters}`,payload:[]};yield this._post(n)});this.heartbeatIntervalTimer=setInterval(()=>E(this,null,function*(){if(this.lastPongTime){if(Date.now()-this.lastPongTime>Bt*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}yield t(),e=!1}),Bt)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};
5
+ Received: \`${r.received}\``)}function Hr(){return new D(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Be(){return new D(N.SDKWarningCode.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Ve(){return new D(N.SDKWarningCode.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${f.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function He(r){let{method:e,removalVersions:t,useInstead:n}=r,i=t[f.sdkName],s=n?` Use \`${n}\` instead.`:"",o=`\`${e}\` will be removed from \`${f.sdkName}\` in version \`${i}\`.${s}`;return new D(N.SDKWarningCode.DeprecationNotice,o)}var p=require("@magic-sdk/types");var K=require("@magic-sdk/types");function*Xr(){let r=0;for(;;)r<Number.MAX_SAFE_INTEGER?yield++r:r=0}var zr=Xr();function ye(){return zr.next().value}var Mt=Symbol("Payload pre-processed by Magic SDK");function St(r){return Object.defineProperty(r,Mt,{value:!0,enumerable:!1}),r}function Yr(r){return!!r[Mt]}function H(r){var e,t,n;return Yr(r)||(r.jsonrpc=(e=r.jsonrpc)!=null?e:"2.0",r.id=ye(),r.method=(t=r.method)!=null?t:"noop",r.params=(n=r.params)!=null?n:[],St(r)),r}function h(r,e=[]){return St({params:e,method:r,jsonrpc:"2.0",id:ye()})}var G=class{constructor(e){e instanceof G?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):qe(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var Te=require("@magic-sdk/types");var At=nr(Ct()),ve=class extends At.default{};function ce(){let r=new ve;return{emitter:r,createChainingEmitterMethod:(n,i)=>(...s)=>(r[n].apply(r,s),i),createBoundEmitterMethod:n=>(...i)=>r[n].apply(r,i)}}var $t=Symbol("isPromiEvent");function ze(r){return!!r[$t]}function P(r){let e=Ie(r),{createBoundEmitterMethod:t,createChainingEmitterMethod:n}=ce(),i=Symbol("Promise.then"),s=Symbol("Promise.catch"),o=Symbol("Promise.finally"),a=(u,m)=>(...S)=>{let T=m[u].apply(m,S);return c(T)},c=u=>Object.assign(u,{[$t]:!0,[i]:u[i]||u.then,[s]:u[s]||u.catch,[o]:u[o]||u.finally,then:a(i,u),catch:a(s,u),finally:a(o,u),on:n("on",u),once:n("once",u),addListener:n("addListener",u),off:n("off",u),removeListener:n("removeListener",u),removeAllListeners:n("removeAllListeners",u),emit:t("emit"),eventNames:t("eventNames"),listeners:t("listeners"),listenerCount:t("listenerCount")}),d=c(e.then(u=>(d.emit("done",u),d.emit("settled"),u),u=>{throw d.emit("error",u),d.emit("settled"),u}));return d.on(Te.UserEventsOnReceived.ClosedByUser,()=>{d.emit(Te.UserEventsEmit.ClosedByUser)}),d}function Ie(r){return new Promise((e,t)=>{let n=r(e,t);Promise.resolve(n).catch(t)})}var v=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){if(this.sdk.thirdPartyWallets.isConnected&&!K.routeToMagicMethods.includes(e.method))return P((o,a)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(o).catch(a)});let t=this.overlay.post(K.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,H(e)),n=P((s,o)=>{t.then(a=>{if(i(),a.hasError)o(new L(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Je()}).catch(a=>{i(),o(a)})}),i=this.overlay.on(K.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var a;let{response:o}=s.data;if(o.id===e.id&&((a=o.result)==null?void 0:a.event)){let{event:c,params:d=[]}=o.result;n.emit(c,...d)}});return n}createIntermediaryEvent(e,t){return i=>{let s=h(K.MagicPayloadMethod.IntermediaryEvent,[{payloadId:t,eventType:e,args:i}]);this.request(s)}}};function Ye(r,e){let[t]=r.split(".").map(Number);return t>=e}var en={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},be=class extends v{loginWithMagicLink(e){let t=f.sdkName==="@magic-sdk/react-native"||f.sdkName==="@magic-sdk/react-native-bare"||f.sdkName==="@magic-sdk/react-native-expo";if(t&&Ye(f.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&He({method:"auth.loginWithMagicLink()",removalVersions:en,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:n,showUI:i=!0,redirectURI:s,overrides:o,lifespan:a}=e,c=h(this.sdk.testMode?p.MagicPayloadMethod.LoginWithMagicLinkTestMode:p.MagicPayloadMethod.LoginWithMagicLink,[{email:n,showUI:i,redirectURI:s,overrides:o,lifespan:a}]);return this.request(c)}loginWithSMS(e){let{phoneNumber:t,showUI:n=!0,lifespan:i}=e,s=h(this.sdk.testMode?p.MagicPayloadMethod.LoginWithSmsTestMode:p.MagicPayloadMethod.LoginWithSms,[{phoneNumber:t,showUI:n,lifespan:i}]),o=this.request(s);return!n&&o&&(o.on(p.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(p.LoginWithSmsOTPEventEmit.VerifySmsOtp,s.id)(a)}),o.on(p.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.LoginWithSmsOTPEventEmit.Cancel,s.id)()})),o}loginWithEmailOTP(e){let{email:t,showUI:n,deviceCheckUI:i,overrides:s,lifespan:o}=e,a=h(this.sdk.testMode?p.MagicPayloadMethod.LoginWithEmailOTPTestMode:p.MagicPayloadMethod.LoginWithEmailOTP,[{email:t,showUI:n,deviceCheckUI:i,overrides:s,lifespan:o}]),c=this.request(a);return!i&&c&&c.on(p.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(p.DeviceVerificationEventEmit.Retry,a.id)()}),!n&&c&&(c.on(p.LoginWithEmailOTPEventEmit.VerifyEmailOtp,d=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(d)}),c.on(p.LoginWithEmailOTPEventEmit.VerifyMFACode,d=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(d)}),c.on(p.LoginWithEmailOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.LostDevice,a.id)()}),c.on(p.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,d=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,a.id)(d)}),c.on(p.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:n}=e||{},i=t!=null?t:"";if(!t&&f.platform==="web"){i=window.location.search;let o=window.location.origin+window.location.pathname;window.history.replaceState(null,"",o)}let s=h(this.sdk.testMode?p.MagicPayloadMethod.LoginWithCredentialTestMode:p.MagicPayloadMethod.LoginWithCredential,[i,n]);return this.request(s)}setAuthorizationToken(e){let t=h(p.MagicPayloadMethod.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:n=!0}=e,i=h(this.sdk.testMode?p.MagicPayloadMethod.UpdateEmailTestMode:p.MagicPayloadMethod.UpdateEmail,[{email:t,showUI:n}]),s=this.request(i);return n||(s.on(p.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.Retry,i.id)()}),s.on(p.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.Cancel,i.id)()}),s.on(p.RecencyCheckEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.VerifyEmailOtp,i.id)(o)}),s.on(p.RecencyCheckEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.VerifyMFACode,i.id)(o)}),s.on(p.UpdateEmailEventEmit.RetryWithNewEmail,o=>{this.createIntermediaryEvent(p.UpdateEmailEventEmit.RetryWithNewEmail,i.id)(o)}),s.on(p.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.UpdateEmailEventEmit.Cancel,i.id)()}),s.on(p.UpdateEmailEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(p.UpdateEmailEventEmit.VerifyEmailOtp,i.id)(o)})),s}};var l=require("@magic-sdk/types");var Z={};ut(Z,{clear:()=>tn,getItem:()=>w,iterate:()=>Qe,key:()=>nn,keys:()=>sn,length:()=>rn,removeItem:()=>q,setItem:()=>A});var Pe;function j(r){return(...e)=>E(this,null,function*(){return Pe||(Pe=yield f.configureStorage()),yield Pe.ready(),Pe[r](...e)})}var w=j("getItem"),A=j("setItem"),q=j("removeItem"),tn=j("clear"),rn=j("length"),nn=j("key"),sn=j("keys"),Qe=j("iterate");function Ze(){let r=window.crypto.getRandomValues(new Uint8Array(16));r[6]=r[6]&15|64,r[8]=r[8]&191|128;let e="";return e+=r[0].toString(16),e+=r[1].toString(16),e+=r[2].toString(16),e+=r[3].toString(16),e+="-",e+=r[4].toString(16),e+=r[5].toString(16),e+="-",e+=r[6].toString(16),e+=r[7].toString(16),e+="-",e+=r[8].toString(16),e+=r[9].toString(16),e+="-",e+=r[10].toString(16),e+=r[11].toString(16),e+=r[12].toString(16),e+=r[13].toString(16),e+=r[14].toString(16),e+=r[15].toString(16),e}var we="STORE_KEY_PRIVATE_KEY",le="STORE_KEY_PUBLIC_JWK",Ot="ECDSA",on="P-256",an={name:Ot,namedCurve:on};function ee(){let r=typeof window!="undefined"&&!!window.crypto,e=r&&!!window.crypto.subtle;return r&&e}function cn(){q(le),q(we)}function et(){return E(this,null,function*(){let r=yield ln();if(!r){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:e}=window.crypto,t=yield w(we);if(!t||!e){console.info("unable to find private key or webcrypto unsupported");return}let n={iat:Math.floor(new Date().getTime()/1e3),jti:Ze()},i={typ:"dpop+jwt",alg:"ES256",jwk:r},s={protected:Lt(JSON.stringify(i)),claims:Lt(JSON.stringify(n))},o=un(`${s.protected}.${s.claims}`),a={name:Ot,hash:{name:"SHA-256"}},c=mn(new Uint8Array(yield e.sign(a,t,o)));return`${s.protected}.${s.claims}.${c}`})}function ln(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}return(yield w(le))||(yield dn()),w(le)})}function dn(){return E(this,null,function*(){let{subtle:r}=window.crypto,e=yield r.generateKey(an,!1,["sign"]),t=yield r.exportKey("jwk",e.publicKey);yield A(we,e.privateKey),yield A(le,t)})}function Lt(r){return _t(pn(r))}function un(r){return new TextEncoder().encode(r)}function _t(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function pn(r){return encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(n,16)))}function mn(r){let e="";return r.forEach(t=>{e+=String.fromCharCode(t)}),_t(e)}var tt="ds",rt="ek",nt="iv",st="AES-GCM",hn=256;function xe(){return E(this,null,function*(){let r=[];yield Qe((e,t,n)=>{t.startsWith(`${tt}_`)&&r.push(t)});for(let e of r)yield q(e)})}function kt(r){let e="",t=new Uint8Array(r),n=t.byteLength;for(let i=0;i<n;i++)e+=String.fromCharCode(t[i]);return window.btoa(e)}function Dt(r){let e=window.atob(r),t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}function En(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{crypto:r}=window,e=yield w(nt);return e||r.getRandomValues(new Uint8Array(12))})}function fn(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{subtle:r}=window.crypto,e=yield w(rt);return e||(yield r.generateKey({name:st,length:hn},!1,["encrypt","decrypt"]))})}function qt(r,e){return E(this,null,function*(){let t=yield En(),n=yield fn();if(!t||!n||!r)return;let i=Dt(r),{subtle:s}=window.crypto,o=yield s.encrypt({name:st,iv:t},n,i),a=kt(o);yield A(`${tt}_${e}`,a),yield A(rt,n),yield A(nt,t)})}function Ut(r){return E(this,null,function*(){let e=yield w(`${tt}_${r}`),t=yield w(nt),n=yield w(rt);if(!t||!e||!n||!ee())return;let{subtle:i}=window.crypto,s=yield i.decrypt({name:st,iv:t},n,Dt(e));return kt(s)})}function Me(r,e){return e?new URL(r,e):new URL(r)}var Se=class extends v{constructor(){super(...arguments);this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(t){let n=h(this.sdk.testMode?l.MagicPayloadMethod.GetIdTokenTestMode:l.MagicPayloadMethod.GetIdToken,[t]);return this.request(n)}generateIdToken(t){let n=h(this.sdk.testMode?l.MagicPayloadMethod.GenerateIdTokenTestMode:l.MagicPayloadMethod.GenerateIdToken,[t]);return this.request(n)}getInfo(){let t=h(l.MagicPayloadMethod.GetInfo,[]);return this.request(t)}isLoggedIn(){return P((t,n)=>E(this,null,function*(){try{let i=!1;this.sdk.useStorageCache&&(i=(yield w(this.localForageIsLoggedInKey))==="true",i&&t(!0));let s=h(this.sdk.testMode?l.MagicPayloadMethod.IsLoggedInTestMode:l.MagicPayloadMethod.IsLoggedIn),o=yield this.request(s);this.sdk.useStorageCache&&(o?A(this.localForageIsLoggedInKey,!0):q(this.localForageIsLoggedInKey),i&&!o&&this.emitUserLoggedOut(!0)),t(o)}catch(i){n(i)}}))}logout(){return q(this.localForageIsLoggedInKey),xe(),P((t,n)=>E(this,null,function*(){try{let i=h(this.sdk.testMode?l.MagicPayloadMethod.LogoutTestMode:l.MagicPayloadMethod.Logout),s=yield this.request(i);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),t(s)}catch(i){n(i)}}))}requestInfoWithUI(t){let n=h(l.MagicPayloadMethod.RequestUserInfoWithUI,t?[t]:[]);return this.request(n)}showSettings(t){let{showUI:n=!0}=t||{},i=h(this.sdk.testMode?l.MagicPayloadMethod.UserSettingsTestMode:l.MagicPayloadMethod.UserSettings,[t]),s=this.request(i);return!n&&s&&(s.on(l.RecoveryFactorEventEmit.SendNewPhoneNumber,o=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendNewPhoneNumber,i.id)(o)}),s.on(l.RecoveryFactorEventEmit.SendOtpCode,o=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.SendOtpCode,i.id)(o)}),s.on(l.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.StartEditPhoneNumber,i.id)()}),s.on(l.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoveryFactorEventEmit.Cancel,i.id)()}),s.on(l.RecencyCheckEventEmit.VerifyEmailOtp,o=>{this.createIntermediaryEvent(l.RecencyCheckEventEmit.VerifyEmailOtp,i.id)(o)})),s}recoverAccount(t){let{email:n,showUI:i}=t,s=h(this.sdk.testMode?l.MagicPayloadMethod.RecoverAccountTestMode:l.MagicPayloadMethod.RecoverAccount,[{email:n,showUI:i}]),o=this.request(s);return!i&&o&&(o.on(l.RecoverAccountEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.Cancel,s.id)()}),o.on(l.RecoverAccountEventEmit.ResendSms,()=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.ResendSms,s.id)()}),o.on(l.RecoverAccountEventEmit.VerifyOtp,a=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.VerifyOtp,s.id)(a)}),o.on(l.RecoverAccountEventEmit.UpdateEmail,a=>{this.createIntermediaryEvent(l.RecoverAccountEventEmit.UpdateEmail,s.id)(a)}),o.on(l.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.Cancel,s.id)()}),o.on(l.UpdateEmailEventEmit.RetryWithNewEmail,a=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.RetryWithNewEmail,s.id)(a)}),o.on(l.UpdateEmailEventEmit.VerifyEmailOtp,a=>{this.createIntermediaryEvent(l.UpdateEmailEventEmit.VerifyEmailOtp,s.id)(a)})),o}revealPrivateKey(){let t=h(l.MagicPayloadMethod.RevealPK);return this.request(t)}onUserLoggedOut(t){this.userLoggedOutCallbacks.push(t)}enableMFA(t){let{showUI:n=!0}=t,i=h(l.MagicPayloadMethod.EnableMFA,[{showUI:n}]),s=this.request(i);return!n&&s&&(s.on(l.EnableMFAEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.VerifyMFACode,i.id)(o)}),s.on(l.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.EnableMFAEventEmit.Cancel,i.id)()})),s}disableMFA(t){let{showUI:n=!0}=t,i=h(l.MagicPayloadMethod.DisableMFA,[{showUI:n}]),s=this.request(i);return!n&&s&&(s.on(l.DisableMFAEventEmit.VerifyMFACode,o=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.VerifyMFACode,i.id)(o)}),s.on(l.DisableMFAEventEmit.LostDevice,o=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.LostDevice,i.id)(o)}),s.on(l.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(l.DisableMFAEventEmit.Cancel,i.id)()})),s}emitUserLoggedOut(t){this.userLoggedOutCallbacks.forEach(n=>{n(t)})}};var U=require("@magic-sdk/types");var Ne=class extends v{connectWithUI(e){let t=P((n,i)=>E(this,null,function*(){try{let s=h(U.MagicPayloadMethod.Login,[W({enabledWallets:this.sdk.thirdPartyWallets.enabledWallets},e)]),o=this.request(s);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:c,callback:d})=>{o.on(c,()=>d(s.id))}),o.on("id-token-created",c=>{t.emit("id-token-created",c)});let a=yield o;a.error&&i(a),n(a)}catch(s){i(s)}}));return t}showUI(e){return this.request(h(U.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(h(U.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(h(U.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(h(U.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(h(U.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(h(U.MagicPayloadMethod.ShowBalances))}sendGaslessTransaction(e,t){return this.request(h(U.MagicPayloadMethod.SendGaslessTransaction,[e,t]))}};var C=require("@magic-sdk/types");var Ce=class extends v{constructor(){super(...arguments);this.eventListeners=[];this.enabledWallets={};this.isConnected=!1}resetThirdPartyWalletState(){localStorage.removeItem(C.LocalStorageKeys.PROVIDER),localStorage.removeItem(C.LocalStorageKeys.ADDRESS),localStorage.removeItem(C.LocalStorageKeys.CHAIN_ID),this.isConnected=!1}requestOverride(t){if(t.method===C.MagicPayloadMethod.Login)return this.resetThirdPartyWalletState(),super.request(t);if(t.method===C.MagicPayloadMethod.GetInfo)return this.getInfo(t);if(t.method===C.MagicPayloadMethod.IsLoggedIn)return this.isLoggedIn(t);if(t.method===C.MagicPayloadMethod.Logout)return this.logout(t);switch(localStorage.getItem(C.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalRequest(t);default:return this.resetThirdPartyWalletState(),super.request(t)}}isLoggedIn(t){switch(localStorage.getItem(C.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();default:return this.resetThirdPartyWalletState(),super.request(t)}}getInfo(t){switch(localStorage.getItem(C.LocalStorageKeys.PROVIDER)){case"web3modal":return this.web3modalGetInfo();default:return this.resetThirdPartyWalletState(),super.request(t)}}logout(t){let n=localStorage.getItem(C.LocalStorageKeys.PROVIDER);switch(this.resetThirdPartyWalletState(),n){case"web3modal":return this.web3modalLogout();default:return super.request(t)}}web3modalRequest(t){return P((n,i)=>{this.sdk.web3modal.modal.getWalletProvider().request(t).then(n).catch(i)})}web3modalIsLoggedIn(){return P(t=>{let n=this.sdk.web3modal.modal.getStatus();if(n==="connected"&&t(!0),n==="disconnected"&&(this.resetThirdPartyWalletState(),t(!1)),n==="reconnecting"){let i=this.sdk.web3modal.modal.subscribeProvider(({status:s})=>{s==="connected"&&(i(),t(!0)),s==="disconnected"&&(i(),this.resetThirdPartyWalletState(),t(!1))})}})}formatWeb3modalGetInfoResponse(){var i;let t=(i=this.sdk.web3modal.modal.getWalletInfo())==null?void 0:i.name,n=this.sdk.web3modal.modal.getAddress();return{publicAddress:n,email:null,issuer:`did:ethr:${n}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],walletType:t||"web3modal"}}web3modalGetInfo(){return P((t,n)=>{let i=this.sdk.web3modal.modal.getStatus();if(i==="connected"&&t(this.formatWeb3modalGetInfoResponse()),i==="disconnected"&&(this.resetThirdPartyWalletState(),n("Magic RPC Error: [-32603] Internal error: User denied account access.")),i==="reconnecting"){let s=this.sdk.web3modal.modal.subscribeProvider(({status:o})=>{o==="connected"&&(s(),t(this.formatWeb3modalGetInfoResponse())),o==="disconnected"&&(s(),this.resetThirdPartyWalletState(),n("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return P(t=>E(this,null,function*(){try{yield this.sdk.web3modal.modal.disconnect()}catch(n){console.error(n)}t(!0)}))}};var de=require("@magic-sdk/types");var{createBoundEmitterMethod:Ae,createChainingEmitterMethod:te}=ce(),$e=class extends v{constructor(){super(...arguments);this.isMagic=!0;this.on=te("on",this);this.once=te("once",this);this.addListener=te("addListener",this);this.off=te("off",this);this.removeListener=te("removeListener",this);this.removeAllListeners=te("removeAllListeners",this);this.emit=Ae("emit");this.eventNames=Ae("eventNames");this.listeners=Ae("listeners");this.listenerCount=Ae("listenerCount")}sendAsync(t,n){if(!n)throw je({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:n===null?"null":typeof n});if(Array.isArray(t))this.overlay.post(de.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,t.map(i=>{let s=H(i);return this.prefixPayloadMethodForTestMode(s),s})).then(i=>{n(null,i.map(s=>X(W({},s.payload),{error:s.hasError?new L(s.payload.error):null})))});else{let i=H(t);this.prefixPayloadMethodForTestMode(i),this.overlay.post(de.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,i).then(s=>{n(s.hasError?new L(s.payload.error):null,s.payload)})}}send(t,n){if(typeof t=="string"){let s=h(t,Array.isArray(n)?n:[]);return this.request(s)}if(Array.isArray(t)||!!n){this.sendAsync(t,n);return}let i=Be();return i.log(),new G(t).applyError({code:-32603,message:i.rawMessage}).payload}enable(){let t=h(de.MagicPayloadMethod.Login);return this.request(t)}request(t){return this.prefixPayloadMethodForTestMode(t),super.request(t)}prefixPayloadMethodForTestMode(t){let n="testMode/eth/";this.sdk.testMode&&(t.method=`${n}${t.method}`)}};var Ft=["request","overlay","sdk"];function gn(r){let e=Object.getPrototypeOf(r),t=[e];for(;e!==v.prototype;)e=Object.getPrototypeOf(e),t.push(e);return t}var it=class extends v{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:P,isPromiEvent:ze,encodeJSON:oe,decodeJSON:De,createJsonRpcRequestPayload:h,standardizeJsonRpcRequestPayload:H,storage:Z};let t=[this,...gn(this)];Ft.forEach(n=>{let i=t.map(c=>Object.getOwnPropertyDescriptor(c,n)),s=i.findIndex(c=>Boolean(c)),o=s>0,a=i[s];a&&(this.__sdk_access_field_descriptors__.set(n,{descriptor:a,isPrototypeField:o}),Object.defineProperty(this,n,{configurable:!0,get:()=>{throw Ge(n)}}))})}init(t){this.__is_initialized__||(Ft.forEach(n=>{if(this.__sdk_access_field_descriptors__.has(n)){let{descriptor:i,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(n);s?delete this[n]:Object.defineProperty(this,n,i)}}),this.sdk=t,this.__is_initialized__=!0)}createDeprecationWarning(t){let{method:n,removalVersion:i,useInstead:s}=t,o=s?` Use \`${s}\` instead.`:"",a=`\`${n}\` will be removed from this Extension in version \`${i}\`.${o}`;return new Q(this,"DEPRECATION_NOTICE",a)}createWarning(t,n){return new Q(this,t,n)}createError(t,n,i){return new V(this,t,n,i)}},ot=class extends it{},B=class{};B.Internal=ot;var F=require("@magic-sdk/types");var Le=class extends v{purchase(e){let t=h(F.MagicPayloadMethod.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,n=h(F.MagicPayloadMethod.NFTCheckout,[X(W({},e),{walletProvider:t?"web3modal":"magic"})]),i=this.request(n);return t&&(i.on(F.NftCheckoutIntermediaryEvents.Initiated,s=>E(this,null,function*(){try{let o=yield this.request({method:"eth_sendTransaction",params:[s]});this.createIntermediaryEvent(F.NftCheckoutIntermediaryEvents.Success,n.id)(o)}catch(o){this.createIntermediaryEvent(F.NftCheckoutIntermediaryEvents.Failure,n.id)()}})),i.on(F.NftCheckoutIntermediaryEvents.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),i.emit("disconnect")})),i}transfer(e){let t=h(F.MagicPayloadMethod.NFTTransfer,[e]);return this.request(t)}};function Wt(r){return r.compat&&r.compat[f.sdkName]!=null?typeof r.compat[f.sdkName]=="string"?bt(Pt(f.version),r.compat[f.sdkName]):!!r.compat[f.sdkName]:!0}function yn(r,e,t){return!e&&!t?`${r}_eth_mainnet`:t?`${r}_${JSON.stringify(t)}`:e?typeof e=="string"?`${r}_eth_${e}`:`${r}_${e.rpcUrl}_${e.chainId}_${e.chainType}`:`${r}_unknown`}function Rn(r){var i;let e=(i=r==null?void 0:r.extensions)!=null?i:[],t={},n=[];if(Array.isArray(e)?e.forEach(s=>{Wt(s)?(s.init(this),s.name&&(this[s.name]=s),s instanceof B.Internal&&(Y(s.config)||(t[s.name]=s.config))):n.push(s)}):Object.keys(e).forEach(s=>{if(Wt(e[s])){e[s].init(this);let o=e[s];this[s]=o,o instanceof B.Internal&&(Y(o.config)||(t[e[s].name]=o.config))}else n.push(e[s])}),n.length)throw Ke(n);return t}var pe=class{constructor(e,t){this.apiKey=e;var o;if(!e)throw Fe();f.platform==="react-native"&&(t==null?void 0:t.endpoint)&&Ve().log();let{defaultEndpoint:n,version:i}=f;this.testMode=!!(t!=null&&t.testMode),this.useStorageCache=!!(t!=null&&t.useStorageCache),this.endpoint=Me((o=t==null?void 0:t.endpoint)!=null?o:n).origin,this.auth=new be(this),this.user=new Se(this),this.wallet=new Ne(this),this.nft=new Le(this),this.thirdPartyWallets=new Ce(this),this.rpcProvider=new $e(this);let s=Rn.call(this,t);this.parameters=oe(X(W({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:t==null?void 0:t.network,host:Me(this.endpoint).host,sdk:xt[f.sdkName],version:i,ext:Y(s)?void 0:s,locale:(t==null?void 0:t.locale)||"en_US"},f.bundleId?{bundleId:f.bundleId}:{}),{meta:t==null?void 0:t.meta})),this.networkHash=yn(this.apiKey,t==null?void 0:t.network,Y(s)?void 0:s),t!=null&&t.deferPreload||this.preload()}get overlay(){if(!pe.__overlays__.has(this.parameters)){let e=new f.ViewController(this.endpoint,this.parameters,this.networkHash);e.init(),pe.__overlays__.set(this.parameters,e)}return pe.__overlays__.get(this.parameters)}preload(){return E(this,null,function*(){yield this.overlay.waitForReady()})}},ue=pe;ue.__overlays__=new Map;var O=require("@magic-sdk/types");function vn(r,e){return e&&Array.isArray(r)?r.find(t=>t.id===e):r}function Jt(r,e){var i;let t=(i=e.data.response)==null?void 0:i.id,n=vn(r,t);if(t&&n){let s=new G(n).applyResult(e.data.response.result).applyError(e.data.response.error);return{id:t,response:s}}return{}}function Gt(r,e,t){return E(this,null,function*(){var a;let n=yield w("rt"),i;if(f.platform==="web")try{i=(a=yield w("jwt"))!=null?a:yield et()}catch(c){console.error("webcrypto error",c)}let s={msgType:r,payload:e};i&&(s.jwt=i),i&&n&&(s.rt=n);let o=yield Ut(t);return o&&(s.deviceShare=o),s})}function Kt(r){return E(this,null,function*(){!r.data.rt||(yield A("rt",r.data.rt))})}function jt(r,e){let t=null;return function(...n){t&&clearTimeout(t),t=setTimeout(()=>{r(...n)},e)}}var Tn=1e3,Vt=60*Tn,Bt=5*Vt,In=60*Vt,Oe=class{constructor(e,t,n){this.endpoint=e;this.parameters=t;this.networkHash=n;this.isReadyForRequest=!1;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.lastPongTime=null;this.heartbeatIntervalTimer=null;this.heartbeatDebounce=jt(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},In);this.listen()}post(e,t){return E(this,null,function*(){return Ie((n,i)=>E(this,null,function*(){if(!this.isConnectedToInternet){let u=We();i(u)}(yield this.checkRelayerExistsInDOM())||(this.isReadyForRequest=!1,yield this.reloadRelayer()),this.isReadyForRequest||(yield this.waitForReady());let s=[],o=Array.isArray(t)?t.map(u=>u.id):[],a=yield Gt(`${e}-${this.parameters}`,t,this.networkHash);yield this._post(a);let c=u=>m=>{var at;let{id:S,response:T}=Jt(t,m);if(Kt(m),((at=T==null?void 0:T.payload.error)==null?void 0:at.message)==="User denied account access.")xe();else if(m.data.deviceShare){let{deviceShare:Ht}=m.data;qt(Ht,this.networkHash)}S&&T&&Array.isArray(t)&&o.includes(S)?(s.push(T),s.length===t.length&&(u(),n(s))):S&&T&&!Array.isArray(t)&&S===t.id&&(u(),n(T))},d=this.on(O.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>d()))}))})}on(e,t){let n=t.bind(window),i=s=>{s.data.msgType===`${e}-${this.parameters}`&&n(s)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(O.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(O.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(O.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(O.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new D(O.SDKWarningCode.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=()=>E(this,null,function*(){let n={msgType:`${O.MagicOutgoingWindowMessage.MAGIC_PING}-${this.parameters}`,payload:[]};yield this._post(n)});this.heartbeatIntervalTimer=setInterval(()=>E(this,null,function*(){if(this.lastPongTime){if(Date.now()-this.lastPongTime>Bt*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}yield t(),e=!1}),Bt)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}};
6
6
  //# sourceMappingURL=index.js.map