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