magic-sdk 31.2.0 → 31.2.1-canary.31f8e48.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.
Files changed (2) hide show
  1. package/dist/magic.js +2 -2
  2. package/package.json +3 -3
package/dist/magic.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var Magic=(()=>{var yi=Object.create;var nt=Object.defineProperty;var gi=Object.getOwnPropertyDescriptor;var Ei=Object.getOwnPropertyNames;var _i=Object.getPrototypeOf,Ii=Object.prototype.hasOwnProperty;var Ye=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Er=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),_r=(e,t)=>{for(var r in t)nt(e,r,{get:t[r],enumerable:!0})},Ir=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ei(t))!Ii.call(e,a)&&a!==r&&nt(e,a,{get:()=>t[a],enumerable:!(i=gi(t,a))||i.enumerable});return e};var wr=(e,t,r)=>(r=e!=null?yi(_i(e)):{},Ir(t||!e||!e.__esModule?nt(r,"default",{value:e,enumerable:!0}):r,e)),wi=e=>Ir(nt({},"__esModule",{value:!0}),e);var _n=Er((En,Qt)=>{"use strict";(function(e){if(typeof En=="object"&&typeof Qt<"u")Qt.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function i(a,s,p){function h(y,O){if(!s[y]){if(!a[y]){var E=typeof Ye=="function"&&Ye;if(!O&&E)return E(y,!0);if(w)return w(y,!0);var N=new Error("Cannot find module '"+y+"'");throw N.code="MODULE_NOT_FOUND",N}var D=s[y]={exports:{}};a[y][0].call(D.exports,function(F){var L=a[y][1][F];return h(L||F)},D,D.exports,i,a,s,p)}return s[y].exports}for(var w=typeof Ye=="function"&&Ye,v=0;v<p.length;v++)h(p[v]);return h}({1:[function(i,a,s){(function(p){"use strict";var h=p.MutationObserver||p.WebKitMutationObserver,w;if(h){var v=0,y=new h(F),O=p.document.createTextNode("");y.observe(O,{characterData:!0}),w=function(){O.data=v=++v%2}}else if(!p.setImmediate&&typeof p.MessageChannel<"u"){var E=new p.MessageChannel;E.port1.onmessage=F,w=function(){E.port2.postMessage(0)}}else"document"in p&&"onreadystatechange"in p.document.createElement("script")?w=function(){var W=p.document.createElement("script");W.onreadystatechange=function(){F(),W.onreadystatechange=null,W.parentNode.removeChild(W),W=null},p.document.documentElement.appendChild(W)}:w=function(){setTimeout(F,0)};var N,D=[];function F(){N=!0;for(var W,J,$=D.length;$;){for(J=D,D=[],W=-1;++W<$;)J[W]();$=D.length}N=!1}a.exports=L;function L(W){D.push(W)===1&&!N&&w()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,a,s){"use strict";var p=i(1);function h(){}var w={},v=["REJECTED"],y=["FULFILLED"],O=["PENDING"];a.exports=E;function E(A){if(typeof A!="function")throw new TypeError("resolver must be a function");this.state=O,this.queue=[],this.outcome=void 0,A!==h&&L(this,A)}E.prototype.catch=function(A){return this.then(null,A)},E.prototype.then=function(A,B){if(typeof A!="function"&&this.state===y||typeof B!="function"&&this.state===v)return this;var x=new this.constructor(h);if(this.state!==O){var H=this.state===y?A:B;D(x,H,this.outcome)}else this.queue.push(new N(x,A,B));return x};function N(A,B,x){this.promise=A,typeof B=="function"&&(this.onFulfilled=B,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}N.prototype.callFulfilled=function(A){w.resolve(this.promise,A)},N.prototype.otherCallFulfilled=function(A){D(this.promise,this.onFulfilled,A)},N.prototype.callRejected=function(A){w.reject(this.promise,A)},N.prototype.otherCallRejected=function(A){D(this.promise,this.onRejected,A)};function D(A,B,x){p(function(){var H;try{H=B(x)}catch(Q){return w.reject(A,Q)}H===A?w.reject(A,new TypeError("Cannot resolve promise with itself")):w.resolve(A,H)})}w.resolve=function(A,B){var x=W(F,B);if(x.status==="error")return w.reject(A,x.value);var H=x.value;if(H)L(A,H);else{A.state=y,A.outcome=B;for(var Q=-1,ne=A.queue.length;++Q<ne;)A.queue[Q].callFulfilled(B)}return A},w.reject=function(A,B){A.state=v,A.outcome=B;for(var x=-1,H=A.queue.length;++x<H;)A.queue[x].callRejected(B);return A};function F(A){var B=A&&A.then;if(A&&(typeof A=="object"||typeof A=="function")&&typeof B=="function")return function(){B.apply(A,arguments)}}function L(A,B){var x=!1;function H(se){x||(x=!0,w.reject(A,se))}function Q(se){x||(x=!0,w.resolve(A,se))}function ne(){B(Q,H)}var oe=W(ne);oe.status==="error"&&H(oe.value)}function W(A,B){var x={};try{x.value=A(B),x.status="success"}catch(H){x.status="error",x.value=H}return x}E.resolve=J;function J(A){return A instanceof this?A:w.resolve(new this(h),A)}E.reject=$;function $(A){var B=new this(h);return w.reject(B,A)}E.all=_e;function _e(A){var B=this;if(Object.prototype.toString.call(A)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=A.length,H=!1;if(!x)return this.resolve([]);for(var Q=new Array(x),ne=0,oe=-1,se=new this(h);++oe<x;)fe(A[oe],oe);return se;function fe(Le,f){B.resolve(Le).then(_,function(S){H||(H=!0,w.reject(se,S))});function _(S){Q[f]=S,++ne===x&&!H&&(H=!0,w.resolve(se,Q))}}}E.race=re;function re(A){var B=this;if(Object.prototype.toString.call(A)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=A.length,H=!1;if(!x)return this.resolve([]);for(var Q=-1,ne=new this(h);++Q<x;)oe(A[Q]);return ne;function oe(se){B.resolve(se).then(function(fe){H||(H=!0,w.resolve(ne,fe))},function(fe){H||(H=!0,w.reject(ne,fe))})}}},{1:1}],3:[function(i,a,s){(function(p){"use strict";typeof p.Promise!="function"&&(p.Promise=i(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(i,a,s){"use strict";var p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function h(n,c){if(!(n instanceof c))throw new TypeError("Cannot call a class as a function")}function w(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var v=w();function y(){try{if(!v||!v.open)return!1;var n=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),c=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!n||c)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function O(n,c){n=n||[],c=c||{};try{return new Blob(n,c)}catch(l){if(l.name!=="TypeError")throw l;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,u=new o,d=0;d<n.length;d+=1)u.append(n[d]);return u.getBlob(c.type)}}typeof Promise>"u"&&i(3);var E=Promise;function N(n,c){c&&n.then(function(o){c(null,o)},function(o){c(o)})}function D(n,c,o){typeof c=="function"&&n.then(c),typeof o=="function"&&n.catch(o)}function F(n){return typeof n!="string"&&(console.warn(n+" used as a key, but it is not a string."),n=String(n)),n}function L(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var W="local-forage-detect-blob-support",J=void 0,$={},_e=Object.prototype.toString,re="readonly",A="readwrite";function B(n){for(var c=n.length,o=new ArrayBuffer(c),u=new Uint8Array(o),d=0;d<c;d++)u[d]=n.charCodeAt(d);return o}function x(n){return new E(function(c){var o=n.transaction(W,A),u=O([""]);o.objectStore(W).put(u,"key"),o.onabort=function(d){d.preventDefault(),d.stopPropagation(),c(!1)},o.oncomplete=function(){var d=navigator.userAgent.match(/Chrome\/(\d+)/),l=navigator.userAgent.match(/Edge\//);c(l||!d||parseInt(d[1],10)>=43)}}).catch(function(){return!1})}function H(n){return typeof J=="boolean"?E.resolve(J):x(n).then(function(c){return J=c,J})}function Q(n){var c=$[n.name],o={};o.promise=new E(function(u,d){o.resolve=u,o.reject=d}),c.deferredOperations.push(o),c.dbReady?c.dbReady=c.dbReady.then(function(){return o.promise}):c.dbReady=o.promise}function ne(n){var c=$[n.name],o=c.deferredOperations.pop();if(o)return o.resolve(),o.promise}function oe(n,c){var o=$[n.name],u=o.deferredOperations.pop();if(u)return u.reject(c),u.promise}function se(n,c){return new E(function(o,u){if($[n.name]=$[n.name]||Z(),n.db)if(c)Q(n),n.db.close();else return o(n.db);var d=[n.name];c&&d.push(n.version);var l=v.open.apply(v,d);c&&(l.onupgradeneeded=function(m){var g=l.result;try{g.createObjectStore(n.storeName),m.oldVersion<=1&&g.createObjectStore(W)}catch(I){if(I.name==="ConstraintError")console.warn('The database "'+n.name+'" has been upgraded from version '+m.oldVersion+" to version "+m.newVersion+', but the storage "'+n.storeName+'" already exists.');else throw I}}),l.onerror=function(m){m.preventDefault(),u(l.error)},l.onsuccess=function(){var m=l.result;m.onversionchange=function(g){g.target.close()},o(m),ne(n)}})}function fe(n){return se(n,!1)}function Le(n){return se(n,!0)}function f(n,c){if(!n.db)return!0;var o=!n.db.objectStoreNames.contains(n.storeName),u=n.version<n.db.version,d=n.version>n.db.version;if(u&&(n.version!==c&&console.warn('The database "'+n.name+`" can't be downgraded from version `+n.db.version+" to version "+n.version+"."),n.version=n.db.version),d||o){if(o){var l=n.db.version+1;l>n.version&&(n.version=l)}return!0}return!1}function _(n){return new E(function(c,o){var u=new FileReader;u.onerror=o,u.onloadend=function(d){var l=btoa(d.target.result||"");c({__local_forage_encoded_blob:!0,data:l,type:n.type})},u.readAsBinaryString(n)})}function S(n){var c=B(atob(n.data));return O([c],{type:n.type})}function C(n){return n&&n.__local_forage_encoded_blob}function P(n){var c=this,o=c._initReady().then(function(){var u=$[c._dbInfo.name];if(u&&u.dbReady)return u.dbReady});return D(o,n,n),o}function U(n){Q(n);for(var c=$[n.name],o=c.forages,u=0;u<o.length;u++){var d=o[u];d._dbInfo.db&&(d._dbInfo.db.close(),d._dbInfo.db=null)}return n.db=null,fe(n).then(function(l){return n.db=l,f(n)?Le(n):l}).then(function(l){n.db=c.db=l;for(var m=0;m<o.length;m++)o[m]._dbInfo.db=l}).catch(function(l){throw oe(n,l),l})}function V(n,c,o,u){u===void 0&&(u=1);try{var d=n.db.transaction(n.storeName,c);o(null,d)}catch(l){if(u>0&&(!n.db||l.name==="InvalidStateError"||l.name==="NotFoundError"))return E.resolve().then(function(){if(!n.db||l.name==="NotFoundError"&&!n.db.objectStoreNames.contains(n.storeName)&&n.version<=n.db.version)return n.db&&(n.version=n.db.version+1),Le(n)}).then(function(){return U(n).then(function(){V(n,c,o,u-1)})}).catch(o);o(l)}}function Z(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function $e(n){var c=this,o={db:null};if(n)for(var u in n)o[u]=n[u];var d=$[o.name];d||(d=Z(),$[o.name]=d),d.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=P);var l=[];function m(){return E.resolve()}for(var g=0;g<d.forages.length;g++){var I=d.forages[g];I!==c&&l.push(I._initReady().catch(m))}var R=d.forages.slice(0);return E.all(l).then(function(){return o.db=d.db,fe(o)}).then(function(b){return o.db=b,f(o,c._defaultConfig.version)?Le(o):b}).then(function(b){o.db=d.db=b,c._dbInfo=o;for(var T=0;T<R.length;T++){var k=R[T];k!==c&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function Ce(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){V(o._dbInfo,re,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=I.get(n);R.onsuccess=function(){var b=R.result;b===void 0&&(b=null),C(b)&&(b=S(b)),d(b)},R.onerror=function(){l(R.error)}}catch(b){l(b)}})}).catch(l)});return N(u,c),u}function He(n,c){var o=this,u=new E(function(d,l){o.ready().then(function(){V(o._dbInfo,re,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=I.openCursor(),b=1;R.onsuccess=function(){var T=R.result;if(T){var k=T.value;C(k)&&(k=S(k));var j=n(k,T.key,b++);j!==void 0?d(j):T.continue()}else d()},R.onerror=function(){l(R.error)}}catch(T){l(T)}})}).catch(l)});return N(u,c),u}function Rn(n,c,o){var u=this;n=F(n);var d=new E(function(l,m){var g;u.ready().then(function(){return g=u._dbInfo,_e.call(c)==="[object Blob]"?H(g.db).then(function(I){return I?c:_(c)}):c}).then(function(I){V(u._dbInfo,A,function(R,b){if(R)return m(R);try{var T=b.objectStore(u._dbInfo.storeName);I===null&&(I=void 0);var k=T.put(I,n);b.oncomplete=function(){I===void 0&&(I=null),l(I)},b.onabort=b.onerror=function(){var j=k.error?k.error:k.transaction.error;m(j)}}catch(j){m(j)}})}).catch(m)});return N(d,o),d}function bn(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){V(o._dbInfo,A,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=I.delete(n);g.oncomplete=function(){d()},g.onerror=function(){l(R.error)},g.onabort=function(){var b=R.error?R.error:R.transaction.error;l(b)}}catch(b){l(b)}})}).catch(l)});return N(u,c),u}function Sn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){V(c._dbInfo,A,function(l,m){if(l)return d(l);try{var g=m.objectStore(c._dbInfo.storeName),I=g.clear();m.oncomplete=function(){u()},m.onabort=m.onerror=function(){var R=I.error?I.error:I.transaction.error;d(R)}}catch(R){d(R)}})}).catch(d)});return N(o,n),o}function An(n){var c=this,o=new E(function(u,d){c.ready().then(function(){V(c._dbInfo,re,function(l,m){if(l)return d(l);try{var g=m.objectStore(c._dbInfo.storeName),I=g.count();I.onsuccess=function(){u(I.result)},I.onerror=function(){d(I.error)}}catch(R){d(R)}})}).catch(d)});return N(o,n),o}function On(n,c){var o=this,u=new E(function(d,l){if(n<0){d(null);return}o.ready().then(function(){V(o._dbInfo,re,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=!1,b=I.openKeyCursor();b.onsuccess=function(){var T=b.result;if(!T){d(null);return}n===0||R?d(T.key):(R=!0,T.advance(n))},b.onerror=function(){l(b.error)}}catch(T){l(T)}})}).catch(l)});return N(u,c),u}function Nn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){V(c._dbInfo,re,function(l,m){if(l)return d(l);try{var g=m.objectStore(c._dbInfo.storeName),I=g.openKeyCursor(),R=[];I.onsuccess=function(){var b=I.result;if(!b){u(R);return}R.push(b.key),b.continue()},I.onerror=function(){d(I.error)}}catch(b){d(b)}})}).catch(d)});return N(o,n),o}function Tn(n,c){c=L.apply(this,arguments);var o=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||o.name,n.storeName=n.storeName||o.storeName);var u=this,d;if(!n.name)d=E.reject("Invalid arguments");else{var l=n.name===o.name&&u._dbInfo.db,m=l?E.resolve(u._dbInfo.db):fe(n).then(function(g){var I=$[n.name],R=I.forages;I.db=g;for(var b=0;b<R.length;b++)R[b]._dbInfo.db=g;return g});n.storeName?d=m.then(function(g){if(g.objectStoreNames.contains(n.storeName)){var I=g.version+1;Q(n);var R=$[n.name],b=R.forages;g.close();for(var T=0;T<b.length;T++){var k=b[T];k._dbInfo.db=null,k._dbInfo.version=I}var j=new E(function(q,z){var X=v.open(n.name,I);X.onerror=function(le){var Ke=X.result;Ke.close(),z(le)},X.onupgradeneeded=function(){var le=X.result;le.deleteObjectStore(n.storeName)},X.onsuccess=function(){var le=X.result;le.close(),q(le)}});return j.then(function(q){R.db=q;for(var z=0;z<b.length;z++){var X=b[z];X._dbInfo.db=q,ne(X._dbInfo)}}).catch(function(q){throw(oe(n,q)||E.resolve()).catch(function(){}),q})}}):d=m.then(function(g){Q(n);var I=$[n.name],R=I.forages;g.close();for(var b=0;b<R.length;b++){var T=R[b];T._dbInfo.db=null}var k=new E(function(j,q){var z=v.deleteDatabase(n.name);z.onerror=function(){var X=z.result;X&&X.close(),q(z.error)},z.onblocked=function(){console.warn('dropInstance blocked for database "'+n.name+'" until all open connections are closed')},z.onsuccess=function(){var X=z.result;X&&X.close(),j(X)}});return k.then(function(j){I.db=j;for(var q=0;q<R.length;q++){var z=R[q];ne(z._dbInfo)}}).catch(function(j){throw(oe(n,j)||E.resolve()).catch(function(){}),j})})}return N(d,c),d}var Mn={_driver:"asyncStorage",_initStorage:$e,_support:y(),iterate:He,getItem:Ce,setItem:Rn,removeItem:bn,clear:Sn,length:An,key:On,keys:Nn,dropInstance:Tn};function Ln(){return typeof openDatabase=="function"}var Ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cn="~~local_forage_type~",er=/^~~local_forage_type~([^~]+)~/,tt="__lfsc__:",_t=tt.length,It="arbf",wt="blob",tr="si08",rr="ui08",nr="uic8",ir="si16",ar="si32",or="ur16",sr="ui32",cr="fl32",lr="fl64",ur=_t+It.length,dr=Object.prototype.toString;function fr(n){var c=n.length*.75,o=n.length,u,d=0,l,m,g,I;n[n.length-1]==="="&&(c--,n[n.length-2]==="="&&c--);var R=new ArrayBuffer(c),b=new Uint8Array(R);for(u=0;u<o;u+=4)l=Ie.indexOf(n[u]),m=Ie.indexOf(n[u+1]),g=Ie.indexOf(n[u+2]),I=Ie.indexOf(n[u+3]),b[d++]=l<<2|m>>4,b[d++]=(m&15)<<4|g>>2,b[d++]=(g&3)<<6|I&63;return R}function Rt(n){var c=new Uint8Array(n),o="",u;for(u=0;u<c.length;u+=3)o+=Ie[c[u]>>2],o+=Ie[(c[u]&3)<<4|c[u+1]>>4],o+=Ie[(c[u+1]&15)<<2|c[u+2]>>6],o+=Ie[c[u+2]&63];return c.length%3===2?o=o.substring(0,o.length-1)+"=":c.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function Pn(n,c){var o="";if(n&&(o=dr.call(n)),n&&(o==="[object ArrayBuffer]"||n.buffer&&dr.call(n.buffer)==="[object ArrayBuffer]")){var u,d=tt;n instanceof ArrayBuffer?(u=n,d+=It):(u=n.buffer,o==="[object Int8Array]"?d+=tr:o==="[object Uint8Array]"?d+=rr:o==="[object Uint8ClampedArray]"?d+=nr:o==="[object Int16Array]"?d+=ir:o==="[object Uint16Array]"?d+=or:o==="[object Int32Array]"?d+=ar:o==="[object Uint32Array]"?d+=sr:o==="[object Float32Array]"?d+=cr:o==="[object Float64Array]"?d+=lr:c(new Error("Failed to get type for BinaryArray"))),c(d+Rt(u))}else if(o==="[object Blob]"){var l=new FileReader;l.onload=function(){var m=Cn+n.type+"~"+Rt(this.result);c(tt+wt+m)},l.readAsArrayBuffer(n)}else try{c(JSON.stringify(n))}catch(m){console.error("Couldn't convert value into a JSON string: ",n),c(null,m)}}function Dn(n){if(n.substring(0,_t)!==tt)return JSON.parse(n);var c=n.substring(ur),o=n.substring(_t,ur),u;if(o===wt&&er.test(c)){var d=c.match(er);u=d[1],c=c.substring(d[0].length)}var l=fr(c);switch(o){case It:return l;case wt:return O([l],{type:u});case tr:return new Int8Array(l);case rr:return new Uint8Array(l);case nr:return new Uint8ClampedArray(l);case ir:return new Int16Array(l);case or:return new Uint16Array(l);case ar:return new Int32Array(l);case sr:return new Uint32Array(l);case cr:return new Float32Array(l);case lr:return new Float64Array(l);default:throw new Error("Unkown type: "+o)}}var bt={serialize:Pn,deserialize:Dn,stringToBuffer:fr,bufferToString:Rt};function hr(n,c,o,u){n.executeSql("CREATE TABLE IF NOT EXISTS "+c.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,u)}function $n(n){var c=this,o={db:null};if(n)for(var u in n)o[u]=typeof n[u]!="string"?n[u].toString():n[u];var d=new E(function(l,m){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(g){return m(g)}o.db.transaction(function(g){hr(g,o,function(){c._dbInfo=o,l()},function(I,R){m(R)})},m)});return o.serializer=bt,d}function we(n,c,o,u,d,l){n.executeSql(o,u,d,function(m,g){g.code===g.SYNTAX_ERR?m.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[c.storeName],function(I,R){R.rows.length?l(I,g):hr(I,c,function(){I.executeSql(o,u,d,l)},l)},l):l(m,g)},l)}function Un(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"SELECT * FROM "+m.storeName+" WHERE key = ? LIMIT 1",[n],function(I,R){var b=R.rows.length?R.rows.item(0).value:null;b&&(b=m.serializer.deserialize(b)),d(b)},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function xn(n,c){var o=this,u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"SELECT * FROM "+m.storeName,[],function(I,R){for(var b=R.rows,T=b.length,k=0;k<T;k++){var j=b.item(k),q=j.value;if(q&&(q=m.serializer.deserialize(q)),q=n(q,j.key,k+1),q!==void 0){d(q);return}}d()},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function mr(n,c,o,u){var d=this;n=F(n);var l=new E(function(m,g){d.ready().then(function(){c===void 0&&(c=null);var I=c,R=d._dbInfo;R.serializer.serialize(c,function(b,T){T?g(T):R.db.transaction(function(k){we(k,R,"INSERT OR REPLACE INTO "+R.storeName+" (key, value) VALUES (?, ?)",[n,b],function(){m(I)},function(j,q){g(q)})},function(k){if(k.code===k.QUOTA_ERR){if(u>0){m(mr.apply(d,[n,I,o,u-1]));return}g(k)}})})}).catch(g)});return N(l,o),l}function Fn(n,c,o){return mr.apply(this,[n,c,o,1])}function kn(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"DELETE FROM "+m.storeName+" WHERE key = ?",[n],function(){d()},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function Wn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){var l=c._dbInfo;l.db.transaction(function(m){we(m,l,"DELETE FROM "+l.storeName,[],function(){u()},function(g,I){d(I)})})}).catch(d)});return N(o,n),o}function Bn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){var l=c._dbInfo;l.db.transaction(function(m){we(m,l,"SELECT COUNT(key) as c FROM "+l.storeName,[],function(g,I){var R=I.rows.item(0).c;u(R)},function(g,I){d(I)})})}).catch(d)});return N(o,n),o}function Gn(n,c){var o=this,u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"SELECT key FROM "+m.storeName+" WHERE id = ? LIMIT 1",[n+1],function(I,R){var b=R.rows.length?R.rows.item(0).key:null;d(b)},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function Vn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){var l=c._dbInfo;l.db.transaction(function(m){we(m,l,"SELECT key FROM "+l.storeName,[],function(g,I){for(var R=[],b=0;b<I.rows.length;b++)R.push(I.rows.item(b).key);u(R)},function(g,I){d(I)})})}).catch(d)});return N(o,n),o}function jn(n){return new E(function(c,o){n.transaction(function(u){u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(d,l){for(var m=[],g=0;g<l.rows.length;g++)m.push(l.rows.item(g).name);c({db:n,storeNames:m})},function(d,l){o(l)})},function(u){o(u)})})}function Hn(n,c){c=L.apply(this,arguments);var o=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||o.name,n.storeName=n.storeName||o.storeName);var u=this,d;return n.name?d=new E(function(l){var m;n.name===o.name?m=u._dbInfo.db:m=openDatabase(n.name,"","",0),n.storeName?l({db:m,storeNames:[n.storeName]}):l(jn(m))}).then(function(l){return new E(function(m,g){l.db.transaction(function(I){function R(j){return new E(function(q,z){I.executeSql("DROP TABLE IF EXISTS "+j,[],function(){q()},function(X,le){z(le)})})}for(var b=[],T=0,k=l.storeNames.length;T<k;T++)b.push(R(l.storeNames[T]));E.all(b).then(function(){m()}).catch(function(j){g(j)})},function(I){g(I)})})}):d=E.reject("Invalid arguments"),N(d,c),d}var qn={_driver:"webSQLStorage",_initStorage:$n,_support:Ln(),iterate:xn,getItem:Un,setItem:Fn,removeItem:kn,clear:Wn,length:Bn,key:Gn,keys:Vn,dropInstance:Hn};function Kn(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function pr(n,c){var o=n.name+"/";return n.storeName!==c.storeName&&(o+=n.storeName+"/"),o}function Yn(){var n="_localforage_support_test";try{return localStorage.setItem(n,!0),localStorage.removeItem(n),!1}catch{return!0}}function Xn(){return!Yn()||localStorage.length>0}function zn(n){var c=this,o={};if(n)for(var u in n)o[u]=n[u];return o.keyPrefix=pr(n,c._defaultConfig),Xn()?(c._dbInfo=o,o.serializer=bt,E.resolve()):E.reject()}function Jn(n){var c=this,o=c.ready().then(function(){for(var u=c._dbInfo.keyPrefix,d=localStorage.length-1;d>=0;d--){var l=localStorage.key(d);l.indexOf(u)===0&&localStorage.removeItem(l)}});return N(o,n),o}function Qn(n,c){var o=this;n=F(n);var u=o.ready().then(function(){var d=o._dbInfo,l=localStorage.getItem(d.keyPrefix+n);return l&&(l=d.serializer.deserialize(l)),l});return N(u,c),u}function Zn(n,c){var o=this,u=o.ready().then(function(){for(var d=o._dbInfo,l=d.keyPrefix,m=l.length,g=localStorage.length,I=1,R=0;R<g;R++){var b=localStorage.key(R);if(b.indexOf(l)===0){var T=localStorage.getItem(b);if(T&&(T=d.serializer.deserialize(T)),T=n(T,b.substring(m),I++),T!==void 0)return T}}});return N(u,c),u}function ei(n,c){var o=this,u=o.ready().then(function(){var d=o._dbInfo,l;try{l=localStorage.key(n)}catch{l=null}return l&&(l=l.substring(d.keyPrefix.length)),l});return N(u,c),u}function ti(n){var c=this,o=c.ready().then(function(){for(var u=c._dbInfo,d=localStorage.length,l=[],m=0;m<d;m++){var g=localStorage.key(m);g.indexOf(u.keyPrefix)===0&&l.push(g.substring(u.keyPrefix.length))}return l});return N(o,n),o}function ri(n){var c=this,o=c.keys().then(function(u){return u.length});return N(o,n),o}function ni(n,c){var o=this;n=F(n);var u=o.ready().then(function(){var d=o._dbInfo;localStorage.removeItem(d.keyPrefix+n)});return N(u,c),u}function ii(n,c,o){var u=this;n=F(n);var d=u.ready().then(function(){c===void 0&&(c=null);var l=c;return new E(function(m,g){var I=u._dbInfo;I.serializer.serialize(c,function(R,b){if(b)g(b);else try{localStorage.setItem(I.keyPrefix+n,R),m(l)}catch(T){(T.name==="QuotaExceededError"||T.name==="NS_ERROR_DOM_QUOTA_REACHED")&&g(T),g(T)}})})});return N(d,o),d}function ai(n,c){if(c=L.apply(this,arguments),n=typeof n!="function"&&n||{},!n.name){var o=this.config();n.name=n.name||o.name,n.storeName=n.storeName||o.storeName}var u=this,d;return n.name?d=new E(function(l){n.storeName?l(pr(n,u._defaultConfig)):l(n.name+"/")}).then(function(l){for(var m=localStorage.length-1;m>=0;m--){var g=localStorage.key(m);g.indexOf(l)===0&&localStorage.removeItem(g)}}):d=E.reject("Invalid arguments"),N(d,c),d}var oi={_driver:"localStorageWrapper",_initStorage:zn,_support:Kn(),iterate:Zn,getItem:Qn,setItem:ii,removeItem:ni,clear:Jn,length:ri,key:ei,keys:ti,dropInstance:ai},si=function(c,o){return c===o||typeof c=="number"&&typeof o=="number"&&isNaN(c)&&isNaN(o)},ci=function(c,o){for(var u=c.length,d=0;d<u;){if(si(c[d],o))return!0;d++}return!1},vr=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"},qe={},yr={},Ue={INDEXEDDB:Mn,WEBSQL:qn,LOCALSTORAGE:oi},li=[Ue.INDEXEDDB._driver,Ue.WEBSQL._driver,Ue.LOCALSTORAGE._driver],rt=["dropInstance"],St=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(rt),ui={description:"",driver:li.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function di(n,c){n[c]=function(){var o=arguments;return n.ready().then(function(){return n[c].apply(n,o)})}}function At(){for(var n=1;n<arguments.length;n++){var c=arguments[n];if(c)for(var o in c)c.hasOwnProperty(o)&&(vr(c[o])?arguments[0][o]=c[o].slice():arguments[0][o]=c[o])}return arguments[0]}var fi=function(){function n(c){h(this,n);for(var o in Ue)if(Ue.hasOwnProperty(o)){var u=Ue[o],d=u._driver;this[o]=d,qe[d]||this.defineDriver(u)}this._defaultConfig=At({},ui),this._config=At({},this._defaultConfig,c),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return n.prototype.config=function(o){if((typeof o>"u"?"undefined":p(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var u in o){if(u==="storeName"&&(o[u]=o[u].replace(/\W/g,"_")),u==="version"&&typeof o[u]!="number")return new Error("Database version must be a number.");this._config[u]=o[u]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},n.prototype.defineDriver=function(o,u,d){var l=new E(function(m,g){try{var I=o._driver,R=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){g(R);return}for(var b=St.concat("_initStorage"),T=0,k=b.length;T<k;T++){var j=b[T],q=!ci(rt,j);if((q||o[j])&&typeof o[j]!="function"){g(R);return}}var z=function(){for(var Ke=function(pi){return function(){var vi=new Error("Method "+pi+" is not implemented by the current driver"),gr=E.reject(vi);return N(gr,arguments[arguments.length-1]),gr}},Ot=0,mi=rt.length;Ot<mi;Ot++){var Nt=rt[Ot];o[Nt]||(o[Nt]=Ke(Nt))}};z();var X=function(Ke){qe[I]&&console.info("Redefining LocalForage driver: "+I),qe[I]=o,yr[I]=Ke,m()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(X,g):X(!!o._support):X(!0)}catch(le){g(le)}});return D(l,u,d),l},n.prototype.driver=function(){return this._driver||null},n.prototype.getDriver=function(o,u,d){var l=qe[o]?E.resolve(qe[o]):E.reject(new Error("Driver not found."));return D(l,u,d),l},n.prototype.getSerializer=function(o){var u=E.resolve(bt);return D(u,o),u},n.prototype.ready=function(o){var u=this,d=u._driverSet.then(function(){return u._ready===null&&(u._ready=u._initDriver()),u._ready});return D(d,o,o),d},n.prototype.setDriver=function(o,u,d){var l=this;vr(o)||(o=[o]);var m=this._getSupportedDrivers(o);function g(){l._config.driver=l.driver()}function I(T){return l._extend(T),g(),l._ready=l._initStorage(l._config),l._ready}function R(T){return function(){var k=0;function j(){for(;k<T.length;){var q=T[k];return k++,l._dbInfo=null,l._ready=null,l.getDriver(q).then(I).catch(j)}g();var z=new Error("No available storage method found.");return l._driverSet=E.reject(z),l._driverSet}return j()}}var b=this._driverSet!==null?this._driverSet.catch(function(){return E.resolve()}):E.resolve();return this._driverSet=b.then(function(){var T=m[0];return l._dbInfo=null,l._ready=null,l.getDriver(T).then(function(k){l._driver=k._driver,g(),l._wrapLibraryMethodsWithReady(),l._initDriver=R(m)})}).catch(function(){g();var T=new Error("No available storage method found.");return l._driverSet=E.reject(T),l._driverSet}),D(this._driverSet,u,d),this._driverSet},n.prototype.supports=function(o){return!!yr[o]},n.prototype._extend=function(o){At(this,o)},n.prototype._getSupportedDrivers=function(o){for(var u=[],d=0,l=o.length;d<l;d++){var m=o[d];this.supports(m)&&u.push(m)}return u},n.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,u=St.length;o<u;o++)di(this,St[o])},n.prototype.createInstance=function(o){return new n(o)},n}(),hi=new fi;a.exports=hi},{3:3}]},{},[4])(4)})});var wn=Er((yt,In)=>{"use strict";(function(e,t){typeof yt=="object"&&typeof In<"u"?t(yt):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],t):t(e.LocalforageDriverMemory={})})(typeof self<"u"?self:yt,function(e){"use strict";var t="localforage-driver-memory";function r(f){var _=typeof Symbol=="function"&&f[Symbol.iterator],S=0;return _?_.call(f):{next:function(){return f&&S>=f.length&&(f=void 0),{value:f&&f[S++],done:!f}}}}function i(f,_){f=f||[],_=_||{};try{return new Blob(f,_)}catch(U){if(U.name!=="TypeError")throw U;for(var S=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,C=new S,P=0;P<f.length;P+=1)C.append(f[P]);return C.getBlob(_.type)}}var a=/^~~local_forage_type~([^~]+)~/,s=9,p=s+4,h=Object.prototype.toString;function w(f){var _=f.length*.75,S=f.length;f[f.length-1]==="="&&(_--,f[f.length-2]==="="&&_--);for(var C=new ArrayBuffer(_),P=new Uint8Array(C),U=0,V=0;U<S;U+=4){var Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U]),$e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U+1]),Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U+2]),He="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U+3]);P[V++]=Z<<2|$e>>4,P[V++]=($e&15)<<4|Ce>>2,P[V++]=(Ce&3)<<6|He&63}return C}function v(f){for(var _=new Uint8Array(f),S="",C=0;C<_.length;C+=3)S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[_[C]>>2],S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(_[C]&3)<<4|_[C+1]>>4],S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(_[C+1]&15)<<2|_[C+2]>>6],S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[_[C+2]&63];return _.length%3===2?S=S.substring(0,S.length-1)+"=":_.length%3===1&&(S=S.substring(0,S.length-2)+"=="),S}function y(f,_){var S="";if(f&&(S=h.call(f)),f&&(S==="[object ArrayBuffer]"||f.buffer&&h.call(f.buffer)==="[object ArrayBuffer]")){var C=void 0,P="__lfsc__:";f instanceof ArrayBuffer?(C=f,P+="arbf"):(C=f.buffer,S==="[object Int8Array]"?P+="si08":S==="[object Uint8Array]"?P+="ui08":S==="[object Uint8ClampedArray]"?P+="uic8":S==="[object Int16Array]"?P+="si16":S==="[object Uint16Array]"?P+="ur16":S==="[object Int32Array]"?P+="si32":S==="[object Uint32Array]"?P+="ui32":S==="[object Float32Array]"?P+="fl32":S==="[object Float64Array]"?P+="fl64":_(new Error("Failed to get type for BinaryArray"))),_(P+v(C))}else if(S==="[object Blob]"){var U=new FileReader;U.onload=function(){var V="~~local_forage_type~"+f.type+"~"+v(this.result);_("__lfsc__:blob"+V)},U.readAsArrayBuffer(f)}else try{_(JSON.stringify(f))}catch(V){console.error("Couldn't convert value into a JSON string: ",f),_(null,V)}}function O(f){if(f.substring(0,s)!=="__lfsc__:")return JSON.parse(f);var _=f.substring(p),S=f.substring(s,p),C;if(S==="blob"&&a.test(_)){var P=_.match(a);C=P[1],_=_.substring(P[0].length)}var U=w(_);switch(S){case"arbf":return U;case"blob":return i([U],{type:C});case"si08":return new Int8Array(U);case"ui08":return new Uint8Array(U);case"uic8":return new Uint8ClampedArray(U);case"si16":return new Int16Array(U);case"ur16":return new Uint16Array(U);case"si32":return new Int32Array(U);case"ui32":return new Uint32Array(U);case"fl32":return new Float32Array(U);case"fl64":return new Float64Array(U);default:throw new Error("Unkown type: "+S)}}function E(f){var _,S;if(f===null||typeof f!="object"||"isActiveClone"in f)return f;var C=f instanceof Date?new Date(f):f.constructor();try{for(var P=r(Object.keys(f)),U=P.next();!U.done;U=P.next()){var V=U.value;Object.prototype.hasOwnProperty.call(f,V)&&(f.isActiveClone=null,C[V]=E(f[V]),delete f.isActiveClone)}}catch(Z){_={error:Z}}finally{try{U&&!U.done&&(S=P.return)&&S.call(P)}finally{if(_)throw _.error}}return C}function N(f,_){return(f.name||_.name)+"/"+(f.storeName||_.storeName)+"/"}function D(f,_){_&&f.then(function(S){_(null,S)},function(S){_(S)})}function F(){for(var f=[],_=0;_<arguments.length;_++)f[_]=arguments[_];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function L(f,_){var S=this;if(_=F.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var C=this.config();f.name=f.name||C.name,f.storeName=f.storeName||C.storeName}var P;return f.name?P=new Promise(function(U){f.storeName?U(N(f,S._defaultConfig)):U(f.name+"/")}):P=Promise.reject("Invalid arguments"),{promise:P,callback:_}}function W(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}var J={bufferToString:v,deserialize:O,serialize:y,stringToBuffer:w},$={},_e=function(){function f(_){this.kp=_,this.data={}}return f.resolve=function(_){return $[_]||($[_]=new f(_)),$[_]},f.prototype.clear=function(){this.data={}},f.prototype.drop=function(){this.clear(),delete $[this.kp]},f.prototype.get=function(_){return this.data[_]},f.prototype.key=function(_){return this.keys()[_]},f.prototype.keys=function(){return Object.keys(this.data)},f.prototype.rm=function(_){delete this.data[_]},f.prototype.set=function(_,S){this.data[_]=S},f}();function re(f){var _=f?E(f):{},S=N(_,this._defaultConfig),C=_e.resolve(S);return this._dbInfo=_,this._dbInfo.serializer=J,this._dbInfo.keyPrefix=S,this._dbInfo.mStore=C,Promise.resolve()}function A(f){var _=this,S=this.ready().then(function(){_._dbInfo.mStore.clear()});return D(S,f),S}function B(f,_){var S=L.apply(this,arguments),C=S.promise,P=S.callback,U=C.then(function(V){_e.resolve(V).drop()});return D(U,P),C}function x(f,_){var S=this;f=W(f);var C=this.ready().then(function(){var P=S._dbInfo.mStore.get(f);return P==null?null:S._dbInfo.serializer.deserialize(P)});return D(C,_),C}function H(f,_){var S=this,C=this.ready().then(function(){for(var P=S._dbInfo.mStore,U=P.keys(),V=0;V<U.length;V++){var Z=P.get(U[V]);if(Z&&(Z=S._dbInfo.serializer.deserialize(Z)),Z=f(Z,U[V],V+1),Z!==void 0)return Z}});return D(C,_),C}function Q(f,_){var S=this,C=this.ready().then(function(){var P;try{P=S._dbInfo.mStore.key(f),P===void 0&&(P=null)}catch{P=null}return P});return D(C,_),C}function ne(f){var _=this,S=this.ready().then(function(){return _._dbInfo.mStore.keys()});return D(S,f),S}function oe(f){var _=this.keys().then(function(S){return S.length});return D(_,f),_}function se(f,_){var S=this;f=W(f);var C=this.ready().then(function(){S._dbInfo.mStore.rm(f)});return D(C,_),C}function fe(f,_,S){var C=this;f=W(f);var P=this.ready().then(function(){_===void 0&&(_=null);var U=_;return new Promise(function(V,Z){C._dbInfo.serializer.serialize(_,function($e,Ce){if(Ce)Z(Ce);else try{C._dbInfo.mStore.set(f,$e),V(U)}catch(He){Z(He)}})})});return D(P,S),P}var Le=!0;e._support=Le,e._driver=t,e._initStorage=re,e.clear=A,e.dropInstance=B,e.getItem=x,e.iterate=H,e.key=Q,e.keys=ne,e.length=oe,e.removeItem=se,e.setItem=fe,Object.defineProperty(e,"__esModule",{value:!0})})});var Fo={};_r(Fo,{default:()=>xo});var Jt={};_r(Jt,{Extension:()=>Lo,MagicExtensionError:()=>Vr,MagicExtensionWarning:()=>$t,MagicRPCError:()=>ft,MagicSDKError:()=>De,MagicSDKWarning:()=>je,MultichainExtension:()=>Co,SDKBase:()=>Xt,STORE_KEY_PRIVATE_KEY:()=>vt,STORE_KEY_PUBLIC_JWK:()=>Qe,TypedEmitter:()=>un,ViewController:()=>zt,clearKeys:()=>rn,createDeprecationWarning:()=>Qr,createDuplicateIframeWarning:()=>Wt,createExtensionNotInitializedError:()=>Kr,createIncompatibleExtensionsError:()=>Yr,createInvalidArgumentError:()=>Xr,createJwt:()=>nn,createMalformedResponseError:()=>qr,createMissingApiKeyError:()=>Hr,createModalNotReadyError:()=>pt,createPromiEvent:()=>me,createPromise:()=>jt,createReactNativeEndpointConfigurationWarning:()=>Jr,createSDK:()=>kt,createSynchronousWeb3MethodWarning:()=>zr,createTypedEmitter:()=>Vt,createURL:()=>Ge,decodeJSON:()=>Fr,encodeJSON:()=>Ft,getPayloadId:()=>Bt,isEmpty:()=>Je,isJsonRpcErrorCode:()=>Wr,isJsonRpcRequestPayload:()=>Va,isJsonRpcResponsePayload:()=>kr,isMagicPayloadMethod:()=>ja,isMajorVersionAtLeast:()=>hn,isPromiEvent:()=>fn,isWebCryptoSupported:()=>et,storage:()=>Gt,uuid:()=>en});var Re=(e=>(e.MissingApiKey="MISSING_API_KEY",e.ModalNotReady="MODAL_NOT_READY",e.ConnectionLost="CONNECTION_WAS_LOST",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e))(Re||{}),be=(e=>(e.SyncWeb3Method="SYNC_WEB3_METHOD",e.DuplicateIframe="DUPLICATE_IFRAME",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT",e))(be||{}),Pe=(e=>(e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",e[e.MagicLinkExpired=-10001]="MagicLinkExpired",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.MagicLinkInvalidRedirectURL=-10006]="MagicLinkInvalidRedirectURL",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.UpdateEmailFailed=-10004]="UpdateEmailFailed",e[e.UserRequestEditEmail=-10005]="UserRequestEditEmail",e[e.InactiveRecipient=-10010]="InactiveRecipient",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e[e.DpopInvalidated=-10019]="DpopInvalidated",e))(Pe||{}),ge=(e=>(e.PROVIDER="magic_3pw_provider",e.ADDRESS="magic_3pw_address",e.CHAIN_ID="magic_3pw_chainId",e))(ge||{}),Ri=(e=>(e.WalletConnected="wallet_connected",e.WalletRejected="wallet_rejected",e.Web3ModalSelected="web3modal_selected",e))(Ri||{}),M=(e=>(e.LoginWithSms="magic_auth_login_with_sms",e.LoginWithEmailOTP="magic_auth_login_with_email_otp",e.LoginWithMagicLink="magic_auth_login_with_magic_link",e.LoginWithCredential="magic_auth_login_with_credential",e.SetAuthorizationToken="magic_auth_set_authorization_token",e.GetIdToken="magic_auth_get_id_token",e.GenerateIdToken="magic_auth_generate_id_token",e.GetMetadata="magic_auth_get_metadata",e.IsLoggedIn="magic_is_logged_in",e.Logout="magic_auth_logout",e.UpdateEmail="magic_auth_update_email",e.UserSettings="magic_auth_settings",e.UserSettingsTestMode="magic_auth_settings_testing_mode",e.LoginWithSmsTestMode="magic_auth_login_with_sms_testing_mode",e.LoginWithEmailOTPTestMode="magic_auth_login_with_email_otp_testing_mode",e.LoginWithMagicLinkTestMode="magic_login_with_magic_link_testing_mode",e.LoginWithCredentialTestMode="magic_auth_login_with_credential_testing_mode",e.GetIdTokenTestMode="magic_auth_get_id_token_testing_mode",e.GenerateIdTokenTestMode="magic_auth_generate_id_token_testing_mode",e.GetMetadataTestMode="magic_auth_get_metadata_testing_mode",e.IsLoggedInTestMode="magic_auth_is_logged_in_testing_mode",e.LogoutTestMode="magic_auth_logout_testing_mode",e.UpdateEmailTestMode="magic_auth_update_email_testing_mode",e.IntermediaryEvent="magic_intermediary_event",e.RequestAccounts="eth_requestAccounts",e.GetInfo="magic_get_info",e.ShowUI="magic_wallet",e.NFTPurchase="magic_nft_purchase",e.NFTCheckout="magic_nft_checkout",e.NFTTransfer="magic_nft_transfer",e.RequestUserInfoWithUI="mc_request_user_info",e.Disconnect="mc_disconnect",e.RecoverAccount="magic_auth_recover_account",e.RecoverAccountTestMode="magic_auth_recover_account_testing_mode",e.MagicBoxHeartBeat="magic_box_heart_beat",e.AutoConnect="mc_auto_connect",e.Login="mc_login",e.EncryptV1="magic_auth_encrypt_v1",e.DecryptV1="magic_auth_decrypt_v1",e.ShowNFTs="magic_show_nfts",e.ShowOnRamp="magic_show_fiat_onramp",e.ShowSendTokensUI="magic_show_send_tokens_ui",e.ShowAddress="magic_show_address",e.ShowBalances="magic_show_balances",e.SendGaslessTransaction="eth_sendGaslessTransaction",e.RevealPK="magic_reveal_key",e.EnableMFA="magic_auth_enable_mfa_flow",e.DisableMFA="magic_auth_disable_mfa_flow",e.GetMultichainPublicAddress="magic_get_multichain_public_address",e))(M||{}),Rr=["magic_intermediary_event","magic_nft_checkout","mc_login"],he=(e=>(e.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",e.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",e.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",e.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",e.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT",e.MAGIC_MG_BOX_SEND_RECEIPT="MAGIC_MG_BOX_SEND_RECEIPT",e.MAGIC_SEND_PRODUCT_ANNOUNCEMENT="MAGIC_SEND_PRODUCT_ANNOUNCEMENT",e.MAGIC_PONG="MAGIC_PONG",e.MAGIC_POPUP_RESPONSE="MAGIC_POPUP_RESPONSE",e.MAGIC_POPUP_OAUTH_VERIFY_RESPONSE="MAGIC_POPUP_OAUTH_VERIFY_RESPONSE",e))(he||{}),Se=(e=>(e.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST",e.MAGIC_PING="MAGIC_PING",e))(Se||{}),bi=(e=>(e.UpdateEmail="update-email",e.MFA="mfa",e.Recovery="recovery",e))(bi||{}),Si=(e=>(e.Retry="retry",e))(Si||{}),Ai=(e=>(e.EmailSent="email-sent",e.EmailNotDeliverable="email-not-deliverable",e))(Ai||{}),ue=(e=>(e.VerifyEmailOtp="verify-email-otp",e.VerifyMFACode="verify-mfa-code",e.LostDevice="lost-device",e.VerifyRecoveryCode="verify-recovery-code",e.Cancel="cancel",e))(ue||{}),xe=(e=>(e.VerifySmsOtp="verify-sms-otp",e.Cancel="cancel",e.Retry="retry",e))(xe||{}),Oi=(e=>(e.SmsOTPSent="sms-otp-sent",e.InvalidSmsOtp="invalid-sms-otp",e.ExpiredSmsOtp="expired-sms-otp",e))(Oi||{}),Ni=(e=>(e.EmailOTPSent="email-otp-sent",e.InvalidEmailOtp="invalid-email-otp",e.InvalidMfaOtp="invalid-mfa-otp",e.ExpiredEmailOtp="expired-email-otp",e.MfaSentHandle="mfa-sent-handle",e.RecoveryCodeSentHandle="recovery-code-sent-handle",e.InvalidRecoveryCode="invalid-recovery-code",e.RecoveryCodeSuccess="recovery-code-success",e.LoginThrottled="login-throttled",e))(Ni||{}),it=(e=>(e.Retry="device-retry",e))(it||{}),Ti=(e=>(e.DeviceApproved="device-approved",e.DeviceNeedsApproval="device-needs-approval",e.DeviceVerificationLinkExpired="device-verification-link-expired",e.DeviceVerificationEmailSent="device-verification-email-sent",e))(Ti||{}),ce=(e=>(e.Retry="Recency/auth-factor-retry",e.Cancel="Recency/auth-factor-verification-cancel",e.VerifyEmailOtp="Recency/auth-factor-verify-email-otp",e.VerifyMFACode="Recency/verify-mfa-code",e))(ce||{}),Mi=(e=>(e.PrimaryAuthFactorNeedsVerification="Recency/auth-factor-needs-verification",e.PrimaryAuthFactorVerified="Recency/auth-factor-verified",e.InvalidEmailOtp="Recency/auth-factor-invalid-email-otp",e.EmailExpired="Recency/auth-factor-verification-email-expired",e.EmailSent="Recency/auth-factor-verification-email-sent",e.EmailNotDeliverable="Recency/auth-factor-verification-email-not-deliverable",e))(Mi||{}),ie=(e=>(e.RetryWithNewEmail="UpdateEmail/retry-with-new-email",e.Cancel="UpdateEmail/new-email-verification-cancel",e.VerifyEmailOtp="UpdateEmail/new-email-verify-otp",e))(ie||{}),Li=(e=>(e.NewAuthFactorNeedsVerification="UpdateEmail/new-email-needs-verification",e.EmailUpdated="UpdateEmail/email-updated",e.InvalidEmailOtp="UpdateEmail/new-email-invalid-email-otp",e.EmailExpired="UpdateEmail/new-email-verification-email-expired",e.EmailSent="UpdateEmail/new-email-verification-email-sent",e.EmailNotDeliverable="UpdateEmail/new-email-verification-email-not-deliverable",e.InvalidEmail="UpdateEmail/new-email-invalid",e.EmailAlreadyExists="UpdateEmail/new-email-already-exists",e))(Li||{}),Ci=(e=>(e.IDTokenCreated="Auth/id-token-created",e))(Ci||{}),Pi=(e=>(e.Cancel="Farcaster/cancel",e))(Pi||{}),Di=(e=>(e.MFASecretGenerated="mfa-secret-generated",e.InvalidMFAOtp="invalid-mfa-otp",e.MFARecoveryCodes="mfa-recovery-codes",e))(Di||{}),Fe=(e=>(e.VerifyMFACode="verify-mfa-code",e.Cancel="cancel-mfa-setup",e))(Fe||{}),$i=(e=>(e.MFACodeRequested="mfa-code-requested",e.InvalidMFAOtp="invalid-mfa-otp",e.InvalidRecoveryCode="invalid-recovery-code",e))($i||{}),Ae=(e=>(e.VerifyMFACode="verify-mfa-code",e.LostDevice="lost-device",e.Cancel="cancel-mfa-disable",e))(Ae||{}),Ui=(e=>(e.Harmony="HARMONY",e))(Ui||{}),Tt=(e=>(e.ClosedByUser="closed-by-user",e))(Tt||{}),Mt=(e=>(e.ClosedByUser="closed-by-user-on-received",e))(Mt||{}),xi=(e=>(e.EnterNewPhoneNumber="enter-new-phone-number",e.EnterOtpCode="enter-otp-code",e.RecoveryFactorAlreadyExists="recovery-factor-already-exists",e.MalformedPhoneNumber="malformed-phone-number",e.InvalidOtpCode="invalid-otp-code",e.RecoveryFactorUpdated="recovery-factor-updated",e.RecoveryFactorDeleted="recovery-factor-deleted",e))(xi||{}),pe=(e=>(e.SendNewPhoneNumber="send-new-phone-number",e.SendOtpCode="send-otp-code",e.Cancel="cancel",e.StartEditPhoneNumber="start-edit-phone-number",e))(pe||{}),Fi=(e=>(e.PhoneNumber="phone_number",e))(Fi||{}),ki=(e=>(e.SmsOtpSent="sms-otp-sent",e.LoginThrottled="login-throttled",e.InvalidSmsOtp="invalid-sms-otp",e.SmsVerified="sms-verified",e.AccountRecovered="account-recovered",e.UpdateEmailRequired="update-email-required",e))(ki||{}),ve=(e=>(e.Cancel="cancel",e.VerifyOtp="verify-otp-code",e.ResendSms="resend-sms-otp",e.UpdateEmail="update-email",e))(ve||{}),ke=(e=>(e.Success="nft-checkout-success",e.Failure="nft-checkout-failure",e.Initiated="nft-checkout-initiated",e.Disconnect="disconnect",e))(ke||{}),Wi=(e=>(e.WalletInfoFetched="Wallet/wallet-info-fetched",e))(Wi||{}),Bi=(e=>(e.CloseMagicWindow="close-magic-window",e))(Bi||{}),Gi=(e=>(e.PopupUrl="popup-url",e))(Gi||{}),Vi=(e=>(e.PopupEvent="popup-event",e.Cancel="cancel",e))(Vi||{});var ji=Object.create,Ut=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,qi=Object.getOwnPropertyNames,Ki=Object.getPrototypeOf,Yi=Object.prototype.hasOwnProperty,Xi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zi=(e,t)=>{for(var r in t)Ut(e,r,{get:t[r],enumerable:!0})},Ji=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of qi(t))!Yi.call(e,a)&&a!==r&&Ut(e,a,{get:()=>t[a],enumerable:!(i=Hi(t,a))||i.enumerable});return e},Qi=(e,t,r)=>(r=e!=null?ji(Ki(e)):{},Ji(t||!e||!e.__esModule?Ut(r,"default",{value:e,enumerable:!0}):r,e)),Zi=Xi((e,t)=>{"use strict";var r=Object.prototype.hasOwnProperty,i="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(i=!1));function s(v,y,O){this.fn=v,this.context=y,this.once=O||!1}function p(v,y,O,E,N){if(typeof O!="function")throw new TypeError("The listener must be a function");var D=new s(O,E||v,N),F=i?i+y:y;return v._events[F]?v._events[F].fn?v._events[F]=[v._events[F],D]:v._events[F].push(D):(v._events[F]=D,v._eventsCount++),v}function h(v,y){--v._eventsCount===0?v._events=new a:delete v._events[y]}function w(){this._events=new a,this._eventsCount=0}w.prototype.eventNames=function(){var v=[],y,O;if(this._eventsCount===0)return v;for(O in y=this._events)r.call(y,O)&&v.push(i?O.slice(1):O);return Object.getOwnPropertySymbols?v.concat(Object.getOwnPropertySymbols(y)):v},w.prototype.listeners=function(v){var y=i?i+v:v,O=this._events[y];if(!O)return[];if(O.fn)return[O.fn];for(var E=0,N=O.length,D=new Array(N);E<N;E++)D[E]=O[E].fn;return D},w.prototype.listenerCount=function(v){var y=i?i+v:v,O=this._events[y];return O?O.fn?1:O.length:0},w.prototype.emit=function(v,y,O,E,N,D){var F=i?i+v:v;if(!this._events[F])return!1;var L=this._events[F],W=arguments.length,J,$;if(L.fn){switch(L.once&&this.removeListener(v,L.fn,void 0,!0),W){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,y),!0;case 3:return L.fn.call(L.context,y,O),!0;case 4:return L.fn.call(L.context,y,O,E),!0;case 5:return L.fn.call(L.context,y,O,E,N),!0;case 6:return L.fn.call(L.context,y,O,E,N,D),!0}for($=1,J=new Array(W-1);$<W;$++)J[$-1]=arguments[$];L.fn.apply(L.context,J)}else{var _e=L.length,re;for($=0;$<_e;$++)switch(L[$].once&&this.removeListener(v,L[$].fn,void 0,!0),W){case 1:L[$].fn.call(L[$].context);break;case 2:L[$].fn.call(L[$].context,y);break;case 3:L[$].fn.call(L[$].context,y,O);break;case 4:L[$].fn.call(L[$].context,y,O,E);break;default:if(!J)for(re=1,J=new Array(W-1);re<W;re++)J[re-1]=arguments[re];L[$].fn.apply(L[$].context,J)}}return!0},w.prototype.on=function(v,y,O){return p(this,v,y,O,!1)},w.prototype.once=function(v,y,O){return p(this,v,y,O,!0)},w.prototype.removeListener=function(v,y,O,E){var N=i?i+v:v;if(!this._events[N])return this;if(!y)return h(this,N),this;var D=this._events[N];if(D.fn)D.fn===y&&(!E||D.once)&&(!O||D.context===O)&&h(this,N);else{for(var F=0,L=[],W=D.length;F<W;F++)(D[F].fn!==y||E&&!D[F].once||O&&D[F].context!==O)&&L.push(D[F]);L.length?this._events[N]=L.length===1?L[0]:L:h(this,N)}return this},w.prototype.removeAllListeners=function(v){var y;return v?(y=i?i+v:v,this._events[y]&&h(this,y)):(this._events=new a,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=i,w.EventEmitter=w,typeof t<"u"&&(t.exports=w)});function ea(e){let t={exports:{}};return e(t,t.exports),t.exports}var ta=Number.MAX_SAFE_INTEGER||9007199254740991,xt={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:ta,MAX_SAFE_COMPONENT_LENGTH:16},ra=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{},K=ra,Ze=ea(function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:r}=xt,i=(t=e.exports={}).re=[],a=t.src=[],s=t.t={},p=0,h=(w,v,y)=>{let O=p++;K(O,v),s[w]=O,a[O]=v,i[O]=new RegExp(v,y?"g":void 0)};h("NUMERICIDENTIFIER","0|[1-9]\\d*"),h("NUMERICIDENTIFIERLOOSE","[0-9]+"),h("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),h("MAINVERSION",`(${a[s.NUMERICIDENTIFIER]})\\.(${a[s.NUMERICIDENTIFIER]})\\.(${a[s.NUMERICIDENTIFIER]})`),h("MAINVERSIONLOOSE",`(${a[s.NUMERICIDENTIFIERLOOSE]})\\.(${a[s.NUMERICIDENTIFIERLOOSE]})\\.(${a[s.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASEIDENTIFIER",`(?:${a[s.NUMERICIDENTIFIER]}|${a[s.NONNUMERICIDENTIFIER]})`),h("PRERELEASEIDENTIFIERLOOSE",`(?:${a[s.NUMERICIDENTIFIERLOOSE]}|${a[s.NONNUMERICIDENTIFIER]})`),h("PRERELEASE",`(?:-(${a[s.PRERELEASEIDENTIFIER]}(?:\\.${a[s.PRERELEASEIDENTIFIER]})*))`),h("PRERELEASELOOSE",`(?:-?(${a[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${a[s.PRERELEASEIDENTIFIERLOOSE]})*))`),h("BUILDIDENTIFIER","[0-9A-Za-z-]+"),h("BUILD",`(?:\\+(${a[s.BUILDIDENTIFIER]}(?:\\.${a[s.BUILDIDENTIFIER]})*))`),h("FULLPLAIN",`v?${a[s.MAINVERSION]}${a[s.PRERELEASE]}?${a[s.BUILD]}?`),h("FULL",`^${a[s.FULLPLAIN]}$`),h("LOOSEPLAIN",`[v=\\s]*${a[s.MAINVERSIONLOOSE]}${a[s.PRERELEASELOOSE]}?${a[s.BUILD]}?`),h("LOOSE",`^${a[s.LOOSEPLAIN]}$`),h("GTLT","((?:<|>)?=?)"),h("XRANGEIDENTIFIERLOOSE",`${a[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h("XRANGEIDENTIFIER",`${a[s.NUMERICIDENTIFIER]}|x|X|\\*`),h("XRANGEPLAIN",`[v=\\s]*(${a[s.XRANGEIDENTIFIER]})(?:\\.(${a[s.XRANGEIDENTIFIER]})(?:\\.(${a[s.XRANGEIDENTIFIER]})(?:${a[s.PRERELEASE]})?${a[s.BUILD]}?)?)?`),h("XRANGEPLAINLOOSE",`[v=\\s]*(${a[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${a[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${a[s.XRANGEIDENTIFIERLOOSE]})(?:${a[s.PRERELEASELOOSE]})?${a[s.BUILD]}?)?)?`),h("XRANGE",`^${a[s.GTLT]}\\s*${a[s.XRANGEPLAIN]}$`),h("XRANGELOOSE",`^${a[s.GTLT]}\\s*${a[s.XRANGEPLAINLOOSE]}$`),h("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),h("COERCERTL",a[s.COERCE],!0),h("LONETILDE","(?:~>?)"),h("TILDETRIM",`(\\s*)${a[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",h("TILDE",`^${a[s.LONETILDE]}${a[s.XRANGEPLAIN]}$`),h("TILDELOOSE",`^${a[s.LONETILDE]}${a[s.XRANGEPLAINLOOSE]}$`),h("LONECARET","(?:\\^)"),h("CARETTRIM",`(\\s*)${a[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",h("CARET",`^${a[s.LONECARET]}${a[s.XRANGEPLAIN]}$`),h("CARETLOOSE",`^${a[s.LONECARET]}${a[s.XRANGEPLAINLOOSE]}$`),h("COMPARATORLOOSE",`^${a[s.GTLT]}\\s*(${a[s.LOOSEPLAIN]})$|^$`),h("COMPARATOR",`^${a[s.GTLT]}\\s*(${a[s.FULLPLAIN]})$|^$`),h("COMPARATORTRIM",`(\\s*)${a[s.GTLT]}\\s*(${a[s.LOOSEPLAIN]}|${a[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",h("HYPHENRANGE",`^\\s*(${a[s.XRANGEPLAIN]})\\s+-\\s+(${a[s.XRANGEPLAIN]})\\s*$`),h("HYPHENRANGELOOSE",`^\\s*(${a[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${a[s.XRANGEPLAINLOOSE]})\\s*$`),h("STAR","(<|>)?=?\\s*\\*"),h("GTE0","^\\s*>=\\s*0.0.0\\s*$"),h("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),br=/^[0-9]+$/,xr=(e,t)=>{let r=br.test(e),i=br.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1},na=(e,t)=>xr(t,e),ia={compareIdentifiers:xr,rcompareIdentifiers:na},{MAX_LENGTH:Sr,MAX_SAFE_INTEGER:at}=xt,{re:Ar,t:Or}=Ze,{compareIdentifiers:Xe}=ia,Ne=class ye{constructor(t,r){if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),t instanceof ye){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>Sr)throw new TypeError(`version is longer than ${Sr} characters`);K("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let i=t.trim().match(r.loose?Ar[Or.LOOSE]:Ar[Or.FULL]);if(!i)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>at||this.major<0)throw new TypeError("Invalid major version");if(this.minor>at||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>at||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(a=>{if(/^[0-9]+$/.test(a)){let s=+a;if(s>=0&&s<at)return s}return a}):this.prerelease=[],this.build=i[5]?i[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(t){if(K("SemVer.compare",this.version,this.options,t),!(t instanceof ye)){if(typeof t=="string"&&t===this.version)return 0;t=new ye(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof ye||(t=new ye(t,this.options)),Xe(this.major,t.major)||Xe(this.minor,t.minor)||Xe(this.patch,t.patch)}comparePre(t){if(t instanceof ye||(t=new ye(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let i=this.prerelease[r],a=t.prerelease[r];if(K("prerelease compare",r,i,a),i===void 0&&a===void 0)return 0;if(a===void 0)return 1;if(i===void 0)return-1;if(i!==a)return Xe(i,a)}while(++r)}compareBuild(t){t instanceof ye||(t=new ye(t,this.options));let r=0;do{let i=this.build[r],a=t.build[r];if(K("prerelease compare",r,i,a),i===void 0&&a===void 0)return 0;if(a===void 0)return 1;if(i===void 0)return-1;if(i!==a)return Xe(i,a)}while(++r)}inc(t,r){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r),this.inc("pre",r);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 i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);i===-1&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},aa=(e,t,r)=>new Ne(e,r).compare(new Ne(t,r)),Ve=aa,oa=(e,t,r)=>Ve(e,t,r)===0,sa=oa,ca=(e,t,r)=>Ve(e,t,r)!==0,la=ca,ua=(e,t,r)=>Ve(e,t,r)>0,da=ua,fa=(e,t,r)=>Ve(e,t,r)>=0,ha=fa,ma=(e,t,r)=>Ve(e,t,r)<0,pa=ma,va=(e,t,r)=>Ve(e,t,r)<=0,ya=va,ga=(e,t,r,i)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return sa(e,r,i);case"!=":return la(e,r,i);case">":return da(e,r,i);case">=":return ha(e,r,i);case"<":return pa(e,r,i);case"<=":return ya(e,r,i);default:throw new TypeError(`Invalid operator: ${t}`)}},Lt=ga,ze=Symbol("SemVer ANY"),Ct=class Pt{static get ANY(){return ze}constructor(t,r){if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),t instanceof Pt){if(t.loose===!!r.loose)return t;t=t.value}K("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===ze?this.value="":this.value=this.operator+this.semver.version,K("comp",this)}parse(t){let r=this.options.loose?Nr[Tr.COMPARATORLOOSE]:Nr[Tr.COMPARATOR],i=t.match(r);if(!i)throw new TypeError(`Invalid comparator: ${t}`);this.operator=i[1]!==void 0?i[1]:"",this.operator==="="&&(this.operator=""),i[2]?this.semver=new Ne(i[2],this.options.loose):this.semver=ze}toString(){return this.value}test(t){if(K("Comparator.test",t,this.options.loose),this.semver===ze||t===ze)return!0;if(typeof t=="string")try{t=new Ne(t,this.options)}catch{return!1}return Lt(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof Pt))throw new TypeError("a Comparator is required");if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),this.operator==="")return this.value===""||new Dt(t.value,r).test(this.value);if(t.operator==="")return t.value===""||new Dt(this.value,r).test(t.semver);let i=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),a=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,p=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),h=Lt(this.semver,"<",t.semver,r)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),w=Lt(this.semver,">",t.semver,r)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return i||a||s&&p||h||w}},{re:Nr,t:Tr}=Ze,Dt=class ut{constructor(t,r){if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),t instanceof ut)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new ut(t.raw,r);if(t instanceof Ct)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(i=>this.parseRange(i.trim())).filter(i=>i.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:r}=this.options;t=t.trim();let i=r?te[ee.HYPHENRANGELOOSE]:te[ee.HYPHENRANGE];t=t.replace(i,La(this.options.includePrerelease)),K("hyphen replace",t),t=t.replace(te[ee.COMPARATORTRIM],Ea),K("comparator trim",t,te[ee.COMPARATORTRIM]),t=(t=(t=t.replace(te[ee.TILDETRIM],_a)).replace(te[ee.CARETTRIM],Ia)).split(/\s+/).join(" ");let a=r?te[ee.COMPARATORLOOSE]:te[ee.COMPARATOR];return t.split(" ").map(s=>wa(s,this.options)).join(" ").split(/\s+/).map(s=>Ma(s,this.options)).filter(this.options.loose?s=>!!s.match(a):()=>!0).map(s=>new Ct(s,this.options))}intersects(t,r){if(!(t instanceof ut))throw new TypeError("a Range is required");return this.set.some(i=>Mr(i,r)&&t.set.some(a=>Mr(a,r)&&i.every(s=>a.every(p=>s.intersects(p,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new Ne(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(Ca(this.set[r],t,this.options))return!0;return!1}},{re:te,t:ee,comparatorTrimReplace:Ea,tildeTrimReplace:_a,caretTrimReplace:Ia}=Ze,Mr=(e,t)=>{let r=!0,i=e.slice(),a=i.pop();for(;r&&i.length;)r=i.every(s=>a.intersects(s,t)),a=i.pop();return r},wa=(e,t)=>(K("comp",e,t),e=Sa(e,t),K("caret",e),e=Ra(e,t),K("tildes",e),e=Oa(e,t),K("xrange",e),e=Ta(e,t),K("stars",e),e),ae=e=>!e||e.toLowerCase()==="x"||e==="*",Ra=(e,t)=>e.trim().split(/\s+/).map(r=>ba(r,t)).join(" "),ba=(e,t)=>{let r=t.loose?te[ee.TILDELOOSE]:te[ee.TILDE];return e.replace(r,(i,a,s,p,h)=>{let w;return K("tilde",e,i,a,s,p,h),ae(a)?w="":ae(s)?w=`>=${a}.0.0 <${+a+1}.0.0-0`:ae(p)?w=`>=${a}.${s}.0 <${a}.${+s+1}.0-0`:h?(K("replaceTilde pr",h),w=`>=${a}.${s}.${p}-${h} <${a}.${+s+1}.0-0`):w=`>=${a}.${s}.${p} <${a}.${+s+1}.0-0`,K("tilde return",w),w})},Sa=(e,t)=>e.trim().split(/\s+/).map(r=>Aa(r,t)).join(" "),Aa=(e,t)=>{K("caret",e,t);let r=t.loose?te[ee.CARETLOOSE]:te[ee.CARET],i=t.includePrerelease?"-0":"";return e.replace(r,(a,s,p,h,w)=>{let v;return K("caret",e,a,s,p,h,w),ae(s)?v="":ae(p)?v=`>=${s}.0.0${i} <${+s+1}.0.0-0`:ae(h)?v=s==="0"?`>=${s}.${p}.0${i} <${s}.${+p+1}.0-0`:`>=${s}.${p}.0${i} <${+s+1}.0.0-0`:w?(K("replaceCaret pr",w),v=s==="0"?p==="0"?`>=${s}.${p}.${h}-${w} <${s}.${p}.${+h+1}-0`:`>=${s}.${p}.${h}-${w} <${s}.${+p+1}.0-0`:`>=${s}.${p}.${h}-${w} <${+s+1}.0.0-0`):(K("no pr"),v=s==="0"?p==="0"?`>=${s}.${p}.${h}${i} <${s}.${p}.${+h+1}-0`:`>=${s}.${p}.${h}${i} <${s}.${+p+1}.0-0`:`>=${s}.${p}.${h} <${+s+1}.0.0-0`),K("caret return",v),v})},Oa=(e,t)=>(K("replaceXRanges",e,t),e.split(/\s+/).map(r=>Na(r,t)).join(" ")),Na=(e,t)=>{e=e.trim();let r=t.loose?te[ee.XRANGELOOSE]:te[ee.XRANGE];return e.replace(r,(i,a,s,p,h,w)=>{K("xRange",e,i,a,s,p,h,w);let v=ae(s),y=v||ae(p),O=y||ae(h),E=O;return a==="="&&E&&(a=""),w=t.includePrerelease?"-0":"",v?i=a===">"||a==="<"?"<0.0.0-0":"*":a&&E?(y&&(p=0),h=0,a===">"?(a=">=",y?(s=+s+1,p=0,h=0):(p=+p+1,h=0)):a==="<="&&(a="<",y?s=+s+1:p=+p+1),a==="<"&&(w="-0"),i=`${a+s}.${p}.${h}${w}`):y?i=`>=${s}.0.0${w} <${+s+1}.0.0-0`:O&&(i=`>=${s}.${p}.0${w} <${s}.${+p+1}.0-0`),K("xRange return",i),i})},Ta=(e,t)=>(K("replaceStars",e,t),e.trim().replace(te[ee.STAR],"")),Ma=(e,t)=>(K("replaceGTE0",e,t),e.trim().replace(te[t.includePrerelease?ee.GTE0PRE:ee.GTE0],"")),La=e=>(t,r,i,a,s,p,h,w,v,y,O,E,N)=>`${r=ae(i)?"":ae(a)?`>=${i}.0.0${e?"-0":""}`:ae(s)?`>=${i}.${a}.0${e?"-0":""}`:p?`>=${r}`:`>=${r}${e?"-0":""}`} ${w=ae(v)?"":ae(y)?`<${+v+1}.0.0-0`:ae(O)?`<${v}.${+y+1}.0-0`:E?`<=${v}.${y}.${O}-${E}`:e?`<${v}.${y}.${+O+1}-0`:`<=${w}`}`.trim(),Ca=(e,t,r)=>{for(let i=0;i<e.length;i++)if(!e[i].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let i=0;i<e.length;i++)if(K(e[i].semver),e[i].semver!==Ct.ANY&&e[i].semver.prerelease.length>0){let a=e[i].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0},Pa=(e,t,r)=>{try{t=new Dt(t,r)}catch{return!1}return t.test(e)},{MAX_LENGTH:Da}=xt,{re:Lr,t:Cr}=Ze,$a=(e,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof Ne)return e;if(typeof e!="string"||e.length>Da||!(t.loose?Lr[Cr.LOOSE]:Lr[Cr.FULL]).test(e))return null;try{return new Ne(e,t)}catch{return null}},Ua=$a,{re:ot,t:st}=Ze,xa=(e,t)=>{if(e instanceof Ne)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;let r=null;if((t=t||{}).rtl){let i;for(;(i=ot[st.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),ot[st.COERCERTL].lastIndex=i.index+i[1].length+i[2].length;ot[st.COERCERTL].lastIndex=-1}else r=e.match(ot[st.COERCE]);return r===null?null:Ua(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)};function Fa(e){return String.fromCharCode(parseInt(e.slice(1),16))}function ka(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function Wa(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,Fa))}function Ba(e){return decodeURIComponent(Array.from(atob(e),ka).join(""))}function Ft(e){return Wa(JSON.stringify(e))}function Fr(e){return JSON.parse(Ba(e))}function Ee(e){return typeof e>"u"}function Ga(e){return e===null}function mt(e){return Ga(e)||Ee(e)}function Va(e){return mt(e)?!1:!Ee(e.jsonrpc)&&!Ee(e.id)&&!Ee(e.method)&&!Ee(e.params)}function kr(e){return mt(e)?!1:!Ee(e.jsonrpc)&&!Ee(e.id)&&(!Ee(e.result)||!Ee(e.error))}function ja(e){return mt(e)?!1:typeof e=="string"&&Object.values(M).includes(e)}function Wr(e){return mt(e)?!1:typeof e=="number"&&Object.values(Pe).includes(e)}function Je(e){if(!e)return!0;for(let t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var Y={};function kt(e,t){return Object.assign(Y,t),e}var Ha={"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"},De=class Br extends Error{constructor(t,r){super(`Magic SDK Error: [${t}] ${r}`),this.code=t,this.rawMessage=r,Object.setPrototypeOf(this,Br.prototype)}__proto__=Error},ft=class Gr extends Error{__proto__=Error;code;rawMessage;data;constructor(t){super();let r=Number(t?.code);this.rawMessage=t?.message||"Internal error",this.code=Wr(r)?r:Pe.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=t?.data||void 0,Object.setPrototypeOf(this,Gr.prototype)}},je=class{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}message;log(){console.warn(this.message)}},Vr=class jr extends Error{constructor(t,r,i,a){super(`Magic Extension Error (${t.name}): [${r}] ${i}`),this.code=r,this.rawMessage=i,this.data=a,Object.setPrototypeOf(this,jr.prototype)}__proto__=Error},$t=class{constructor(e,t,r){this.code=t,this.rawMessage=r,this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}message;log(){console.warn(this.message)}};function Hr(){return new De(Re.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function pt(){return new De(Re.ModalNotReady,"Modal is not ready")}function qr(){return new De(Re.MalformedResponse,"Response from the Magic iframe is malformed.")}function Kr(e){return new De(Re.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function Yr(e){let t=`Some extensions are incompatible with \`${Y.sdkName}@${Y.version}\`:`;return e.filter(r=>typeof r.compat<"u"&&r.compat!==null).forEach(r=>{let i=r.compat[Y.sdkName];typeof i=="string"?t+=`
1
+ "use strict";var Magic=(()=>{var yi=Object.create;var nt=Object.defineProperty;var gi=Object.getOwnPropertyDescriptor;var Ei=Object.getOwnPropertyNames;var _i=Object.getPrototypeOf,Ii=Object.prototype.hasOwnProperty;var Ye=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Er=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),_r=(e,t)=>{for(var r in t)nt(e,r,{get:t[r],enumerable:!0})},Ir=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ei(t))!Ii.call(e,a)&&a!==r&&nt(e,a,{get:()=>t[a],enumerable:!(i=gi(t,a))||i.enumerable});return e};var wr=(e,t,r)=>(r=e!=null?yi(_i(e)):{},Ir(t||!e||!e.__esModule?nt(r,"default",{value:e,enumerable:!0}):r,e)),wi=e=>Ir(nt({},"__esModule",{value:!0}),e);var _n=Er((En,Qt)=>{"use strict";(function(e){if(typeof En=="object"&&typeof Qt<"u")Qt.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function i(a,s,p){function h(y,O){if(!s[y]){if(!a[y]){var E=typeof Ye=="function"&&Ye;if(!O&&E)return E(y,!0);if(w)return w(y,!0);var N=new Error("Cannot find module '"+y+"'");throw N.code="MODULE_NOT_FOUND",N}var D=s[y]={exports:{}};a[y][0].call(D.exports,function(F){var L=a[y][1][F];return h(L||F)},D,D.exports,i,a,s,p)}return s[y].exports}for(var w=typeof Ye=="function"&&Ye,v=0;v<p.length;v++)h(p[v]);return h}({1:[function(i,a,s){(function(p){"use strict";var h=p.MutationObserver||p.WebKitMutationObserver,w;if(h){var v=0,y=new h(F),O=p.document.createTextNode("");y.observe(O,{characterData:!0}),w=function(){O.data=v=++v%2}}else if(!p.setImmediate&&typeof p.MessageChannel<"u"){var E=new p.MessageChannel;E.port1.onmessage=F,w=function(){E.port2.postMessage(0)}}else"document"in p&&"onreadystatechange"in p.document.createElement("script")?w=function(){var W=p.document.createElement("script");W.onreadystatechange=function(){F(),W.onreadystatechange=null,W.parentNode.removeChild(W),W=null},p.document.documentElement.appendChild(W)}:w=function(){setTimeout(F,0)};var N,D=[];function F(){N=!0;for(var W,J,$=D.length;$;){for(J=D,D=[],W=-1;++W<$;)J[W]();$=D.length}N=!1}a.exports=L;function L(W){D.push(W)===1&&!N&&w()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(i,a,s){"use strict";var p=i(1);function h(){}var w={},v=["REJECTED"],y=["FULFILLED"],O=["PENDING"];a.exports=E;function E(A){if(typeof A!="function")throw new TypeError("resolver must be a function");this.state=O,this.queue=[],this.outcome=void 0,A!==h&&L(this,A)}E.prototype.catch=function(A){return this.then(null,A)},E.prototype.then=function(A,B){if(typeof A!="function"&&this.state===y||typeof B!="function"&&this.state===v)return this;var x=new this.constructor(h);if(this.state!==O){var H=this.state===y?A:B;D(x,H,this.outcome)}else this.queue.push(new N(x,A,B));return x};function N(A,B,x){this.promise=A,typeof B=="function"&&(this.onFulfilled=B,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}N.prototype.callFulfilled=function(A){w.resolve(this.promise,A)},N.prototype.otherCallFulfilled=function(A){D(this.promise,this.onFulfilled,A)},N.prototype.callRejected=function(A){w.reject(this.promise,A)},N.prototype.otherCallRejected=function(A){D(this.promise,this.onRejected,A)};function D(A,B,x){p(function(){var H;try{H=B(x)}catch(Q){return w.reject(A,Q)}H===A?w.reject(A,new TypeError("Cannot resolve promise with itself")):w.resolve(A,H)})}w.resolve=function(A,B){var x=W(F,B);if(x.status==="error")return w.reject(A,x.value);var H=x.value;if(H)L(A,H);else{A.state=y,A.outcome=B;for(var Q=-1,ne=A.queue.length;++Q<ne;)A.queue[Q].callFulfilled(B)}return A},w.reject=function(A,B){A.state=v,A.outcome=B;for(var x=-1,H=A.queue.length;++x<H;)A.queue[x].callRejected(B);return A};function F(A){var B=A&&A.then;if(A&&(typeof A=="object"||typeof A=="function")&&typeof B=="function")return function(){B.apply(A,arguments)}}function L(A,B){var x=!1;function H(se){x||(x=!0,w.reject(A,se))}function Q(se){x||(x=!0,w.resolve(A,se))}function ne(){B(Q,H)}var oe=W(ne);oe.status==="error"&&H(oe.value)}function W(A,B){var x={};try{x.value=A(B),x.status="success"}catch(H){x.status="error",x.value=H}return x}E.resolve=J;function J(A){return A instanceof this?A:w.resolve(new this(h),A)}E.reject=$;function $(A){var B=new this(h);return w.reject(B,A)}E.all=_e;function _e(A){var B=this;if(Object.prototype.toString.call(A)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=A.length,H=!1;if(!x)return this.resolve([]);for(var Q=new Array(x),ne=0,oe=-1,se=new this(h);++oe<x;)fe(A[oe],oe);return se;function fe(Le,f){B.resolve(Le).then(_,function(S){H||(H=!0,w.reject(se,S))});function _(S){Q[f]=S,++ne===x&&!H&&(H=!0,w.resolve(se,Q))}}}E.race=re;function re(A){var B=this;if(Object.prototype.toString.call(A)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=A.length,H=!1;if(!x)return this.resolve([]);for(var Q=-1,ne=new this(h);++Q<x;)oe(A[Q]);return ne;function oe(se){B.resolve(se).then(function(fe){H||(H=!0,w.resolve(ne,fe))},function(fe){H||(H=!0,w.reject(ne,fe))})}}},{1:1}],3:[function(i,a,s){(function(p){"use strict";typeof p.Promise!="function"&&(p.Promise=i(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(i,a,s){"use strict";var p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function h(n,c){if(!(n instanceof c))throw new TypeError("Cannot call a class as a function")}function w(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var v=w();function y(){try{if(!v||!v.open)return!1;var n=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),c=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!n||c)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function O(n,c){n=n||[],c=c||{};try{return new Blob(n,c)}catch(l){if(l.name!=="TypeError")throw l;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,u=new o,d=0;d<n.length;d+=1)u.append(n[d]);return u.getBlob(c.type)}}typeof Promise>"u"&&i(3);var E=Promise;function N(n,c){c&&n.then(function(o){c(null,o)},function(o){c(o)})}function D(n,c,o){typeof c=="function"&&n.then(c),typeof o=="function"&&n.catch(o)}function F(n){return typeof n!="string"&&(console.warn(n+" used as a key, but it is not a string."),n=String(n)),n}function L(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var W="local-forage-detect-blob-support",J=void 0,$={},_e=Object.prototype.toString,re="readonly",A="readwrite";function B(n){for(var c=n.length,o=new ArrayBuffer(c),u=new Uint8Array(o),d=0;d<c;d++)u[d]=n.charCodeAt(d);return o}function x(n){return new E(function(c){var o=n.transaction(W,A),u=O([""]);o.objectStore(W).put(u,"key"),o.onabort=function(d){d.preventDefault(),d.stopPropagation(),c(!1)},o.oncomplete=function(){var d=navigator.userAgent.match(/Chrome\/(\d+)/),l=navigator.userAgent.match(/Edge\//);c(l||!d||parseInt(d[1],10)>=43)}}).catch(function(){return!1})}function H(n){return typeof J=="boolean"?E.resolve(J):x(n).then(function(c){return J=c,J})}function Q(n){var c=$[n.name],o={};o.promise=new E(function(u,d){o.resolve=u,o.reject=d}),c.deferredOperations.push(o),c.dbReady?c.dbReady=c.dbReady.then(function(){return o.promise}):c.dbReady=o.promise}function ne(n){var c=$[n.name],o=c.deferredOperations.pop();if(o)return o.resolve(),o.promise}function oe(n,c){var o=$[n.name],u=o.deferredOperations.pop();if(u)return u.reject(c),u.promise}function se(n,c){return new E(function(o,u){if($[n.name]=$[n.name]||Z(),n.db)if(c)Q(n),n.db.close();else return o(n.db);var d=[n.name];c&&d.push(n.version);var l=v.open.apply(v,d);c&&(l.onupgradeneeded=function(m){var g=l.result;try{g.createObjectStore(n.storeName),m.oldVersion<=1&&g.createObjectStore(W)}catch(I){if(I.name==="ConstraintError")console.warn('The database "'+n.name+'" has been upgraded from version '+m.oldVersion+" to version "+m.newVersion+', but the storage "'+n.storeName+'" already exists.');else throw I}}),l.onerror=function(m){m.preventDefault(),u(l.error)},l.onsuccess=function(){var m=l.result;m.onversionchange=function(g){g.target.close()},o(m),ne(n)}})}function fe(n){return se(n,!1)}function Le(n){return se(n,!0)}function f(n,c){if(!n.db)return!0;var o=!n.db.objectStoreNames.contains(n.storeName),u=n.version<n.db.version,d=n.version>n.db.version;if(u&&(n.version!==c&&console.warn('The database "'+n.name+`" can't be downgraded from version `+n.db.version+" to version "+n.version+"."),n.version=n.db.version),d||o){if(o){var l=n.db.version+1;l>n.version&&(n.version=l)}return!0}return!1}function _(n){return new E(function(c,o){var u=new FileReader;u.onerror=o,u.onloadend=function(d){var l=btoa(d.target.result||"");c({__local_forage_encoded_blob:!0,data:l,type:n.type})},u.readAsBinaryString(n)})}function S(n){var c=B(atob(n.data));return O([c],{type:n.type})}function C(n){return n&&n.__local_forage_encoded_blob}function P(n){var c=this,o=c._initReady().then(function(){var u=$[c._dbInfo.name];if(u&&u.dbReady)return u.dbReady});return D(o,n,n),o}function U(n){Q(n);for(var c=$[n.name],o=c.forages,u=0;u<o.length;u++){var d=o[u];d._dbInfo.db&&(d._dbInfo.db.close(),d._dbInfo.db=null)}return n.db=null,fe(n).then(function(l){return n.db=l,f(n)?Le(n):l}).then(function(l){n.db=c.db=l;for(var m=0;m<o.length;m++)o[m]._dbInfo.db=l}).catch(function(l){throw oe(n,l),l})}function V(n,c,o,u){u===void 0&&(u=1);try{var d=n.db.transaction(n.storeName,c);o(null,d)}catch(l){if(u>0&&(!n.db||l.name==="InvalidStateError"||l.name==="NotFoundError"))return E.resolve().then(function(){if(!n.db||l.name==="NotFoundError"&&!n.db.objectStoreNames.contains(n.storeName)&&n.version<=n.db.version)return n.db&&(n.version=n.db.version+1),Le(n)}).then(function(){return U(n).then(function(){V(n,c,o,u-1)})}).catch(o);o(l)}}function Z(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function $e(n){var c=this,o={db:null};if(n)for(var u in n)o[u]=n[u];var d=$[o.name];d||(d=Z(),$[o.name]=d),d.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=P);var l=[];function m(){return E.resolve()}for(var g=0;g<d.forages.length;g++){var I=d.forages[g];I!==c&&l.push(I._initReady().catch(m))}var R=d.forages.slice(0);return E.all(l).then(function(){return o.db=d.db,fe(o)}).then(function(b){return o.db=b,f(o,c._defaultConfig.version)?Le(o):b}).then(function(b){o.db=d.db=b,c._dbInfo=o;for(var T=0;T<R.length;T++){var k=R[T];k!==c&&(k._dbInfo.db=o.db,k._dbInfo.version=o.version)}})}function Ce(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){V(o._dbInfo,re,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=I.get(n);R.onsuccess=function(){var b=R.result;b===void 0&&(b=null),C(b)&&(b=S(b)),d(b)},R.onerror=function(){l(R.error)}}catch(b){l(b)}})}).catch(l)});return N(u,c),u}function He(n,c){var o=this,u=new E(function(d,l){o.ready().then(function(){V(o._dbInfo,re,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=I.openCursor(),b=1;R.onsuccess=function(){var T=R.result;if(T){var k=T.value;C(k)&&(k=S(k));var j=n(k,T.key,b++);j!==void 0?d(j):T.continue()}else d()},R.onerror=function(){l(R.error)}}catch(T){l(T)}})}).catch(l)});return N(u,c),u}function Rn(n,c,o){var u=this;n=F(n);var d=new E(function(l,m){var g;u.ready().then(function(){return g=u._dbInfo,_e.call(c)==="[object Blob]"?H(g.db).then(function(I){return I?c:_(c)}):c}).then(function(I){V(u._dbInfo,A,function(R,b){if(R)return m(R);try{var T=b.objectStore(u._dbInfo.storeName);I===null&&(I=void 0);var k=T.put(I,n);b.oncomplete=function(){I===void 0&&(I=null),l(I)},b.onabort=b.onerror=function(){var j=k.error?k.error:k.transaction.error;m(j)}}catch(j){m(j)}})}).catch(m)});return N(d,o),d}function bn(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){V(o._dbInfo,A,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=I.delete(n);g.oncomplete=function(){d()},g.onerror=function(){l(R.error)},g.onabort=function(){var b=R.error?R.error:R.transaction.error;l(b)}}catch(b){l(b)}})}).catch(l)});return N(u,c),u}function Sn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){V(c._dbInfo,A,function(l,m){if(l)return d(l);try{var g=m.objectStore(c._dbInfo.storeName),I=g.clear();m.oncomplete=function(){u()},m.onabort=m.onerror=function(){var R=I.error?I.error:I.transaction.error;d(R)}}catch(R){d(R)}})}).catch(d)});return N(o,n),o}function An(n){var c=this,o=new E(function(u,d){c.ready().then(function(){V(c._dbInfo,re,function(l,m){if(l)return d(l);try{var g=m.objectStore(c._dbInfo.storeName),I=g.count();I.onsuccess=function(){u(I.result)},I.onerror=function(){d(I.error)}}catch(R){d(R)}})}).catch(d)});return N(o,n),o}function On(n,c){var o=this,u=new E(function(d,l){if(n<0){d(null);return}o.ready().then(function(){V(o._dbInfo,re,function(m,g){if(m)return l(m);try{var I=g.objectStore(o._dbInfo.storeName),R=!1,b=I.openKeyCursor();b.onsuccess=function(){var T=b.result;if(!T){d(null);return}n===0||R?d(T.key):(R=!0,T.advance(n))},b.onerror=function(){l(b.error)}}catch(T){l(T)}})}).catch(l)});return N(u,c),u}function Nn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){V(c._dbInfo,re,function(l,m){if(l)return d(l);try{var g=m.objectStore(c._dbInfo.storeName),I=g.openKeyCursor(),R=[];I.onsuccess=function(){var b=I.result;if(!b){u(R);return}R.push(b.key),b.continue()},I.onerror=function(){d(I.error)}}catch(b){d(b)}})}).catch(d)});return N(o,n),o}function Tn(n,c){c=L.apply(this,arguments);var o=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||o.name,n.storeName=n.storeName||o.storeName);var u=this,d;if(!n.name)d=E.reject("Invalid arguments");else{var l=n.name===o.name&&u._dbInfo.db,m=l?E.resolve(u._dbInfo.db):fe(n).then(function(g){var I=$[n.name],R=I.forages;I.db=g;for(var b=0;b<R.length;b++)R[b]._dbInfo.db=g;return g});n.storeName?d=m.then(function(g){if(g.objectStoreNames.contains(n.storeName)){var I=g.version+1;Q(n);var R=$[n.name],b=R.forages;g.close();for(var T=0;T<b.length;T++){var k=b[T];k._dbInfo.db=null,k._dbInfo.version=I}var j=new E(function(q,z){var X=v.open(n.name,I);X.onerror=function(le){var Ke=X.result;Ke.close(),z(le)},X.onupgradeneeded=function(){var le=X.result;le.deleteObjectStore(n.storeName)},X.onsuccess=function(){var le=X.result;le.close(),q(le)}});return j.then(function(q){R.db=q;for(var z=0;z<b.length;z++){var X=b[z];X._dbInfo.db=q,ne(X._dbInfo)}}).catch(function(q){throw(oe(n,q)||E.resolve()).catch(function(){}),q})}}):d=m.then(function(g){Q(n);var I=$[n.name],R=I.forages;g.close();for(var b=0;b<R.length;b++){var T=R[b];T._dbInfo.db=null}var k=new E(function(j,q){var z=v.deleteDatabase(n.name);z.onerror=function(){var X=z.result;X&&X.close(),q(z.error)},z.onblocked=function(){console.warn('dropInstance blocked for database "'+n.name+'" until all open connections are closed')},z.onsuccess=function(){var X=z.result;X&&X.close(),j(X)}});return k.then(function(j){I.db=j;for(var q=0;q<R.length;q++){var z=R[q];ne(z._dbInfo)}}).catch(function(j){throw(oe(n,j)||E.resolve()).catch(function(){}),j})})}return N(d,c),d}var Mn={_driver:"asyncStorage",_initStorage:$e,_support:y(),iterate:He,getItem:Ce,setItem:Rn,removeItem:bn,clear:Sn,length:An,key:On,keys:Nn,dropInstance:Tn};function Ln(){return typeof openDatabase=="function"}var Ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cn="~~local_forage_type~",er=/^~~local_forage_type~([^~]+)~/,tt="__lfsc__:",_t=tt.length,It="arbf",wt="blob",tr="si08",rr="ui08",nr="uic8",ir="si16",ar="si32",or="ur16",sr="ui32",cr="fl32",lr="fl64",ur=_t+It.length,dr=Object.prototype.toString;function fr(n){var c=n.length*.75,o=n.length,u,d=0,l,m,g,I;n[n.length-1]==="="&&(c--,n[n.length-2]==="="&&c--);var R=new ArrayBuffer(c),b=new Uint8Array(R);for(u=0;u<o;u+=4)l=Ie.indexOf(n[u]),m=Ie.indexOf(n[u+1]),g=Ie.indexOf(n[u+2]),I=Ie.indexOf(n[u+3]),b[d++]=l<<2|m>>4,b[d++]=(m&15)<<4|g>>2,b[d++]=(g&3)<<6|I&63;return R}function Rt(n){var c=new Uint8Array(n),o="",u;for(u=0;u<c.length;u+=3)o+=Ie[c[u]>>2],o+=Ie[(c[u]&3)<<4|c[u+1]>>4],o+=Ie[(c[u+1]&15)<<2|c[u+2]>>6],o+=Ie[c[u+2]&63];return c.length%3===2?o=o.substring(0,o.length-1)+"=":c.length%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function Pn(n,c){var o="";if(n&&(o=dr.call(n)),n&&(o==="[object ArrayBuffer]"||n.buffer&&dr.call(n.buffer)==="[object ArrayBuffer]")){var u,d=tt;n instanceof ArrayBuffer?(u=n,d+=It):(u=n.buffer,o==="[object Int8Array]"?d+=tr:o==="[object Uint8Array]"?d+=rr:o==="[object Uint8ClampedArray]"?d+=nr:o==="[object Int16Array]"?d+=ir:o==="[object Uint16Array]"?d+=or:o==="[object Int32Array]"?d+=ar:o==="[object Uint32Array]"?d+=sr:o==="[object Float32Array]"?d+=cr:o==="[object Float64Array]"?d+=lr:c(new Error("Failed to get type for BinaryArray"))),c(d+Rt(u))}else if(o==="[object Blob]"){var l=new FileReader;l.onload=function(){var m=Cn+n.type+"~"+Rt(this.result);c(tt+wt+m)},l.readAsArrayBuffer(n)}else try{c(JSON.stringify(n))}catch(m){console.error("Couldn't convert value into a JSON string: ",n),c(null,m)}}function Dn(n){if(n.substring(0,_t)!==tt)return JSON.parse(n);var c=n.substring(ur),o=n.substring(_t,ur),u;if(o===wt&&er.test(c)){var d=c.match(er);u=d[1],c=c.substring(d[0].length)}var l=fr(c);switch(o){case It:return l;case wt:return O([l],{type:u});case tr:return new Int8Array(l);case rr:return new Uint8Array(l);case nr:return new Uint8ClampedArray(l);case ir:return new Int16Array(l);case or:return new Uint16Array(l);case ar:return new Int32Array(l);case sr:return new Uint32Array(l);case cr:return new Float32Array(l);case lr:return new Float64Array(l);default:throw new Error("Unkown type: "+o)}}var bt={serialize:Pn,deserialize:Dn,stringToBuffer:fr,bufferToString:Rt};function hr(n,c,o,u){n.executeSql("CREATE TABLE IF NOT EXISTS "+c.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],o,u)}function $n(n){var c=this,o={db:null};if(n)for(var u in n)o[u]=typeof n[u]!="string"?n[u].toString():n[u];var d=new E(function(l,m){try{o.db=openDatabase(o.name,String(o.version),o.description,o.size)}catch(g){return m(g)}o.db.transaction(function(g){hr(g,o,function(){c._dbInfo=o,l()},function(I,R){m(R)})},m)});return o.serializer=bt,d}function we(n,c,o,u,d,l){n.executeSql(o,u,d,function(m,g){g.code===g.SYNTAX_ERR?m.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[c.storeName],function(I,R){R.rows.length?l(I,g):hr(I,c,function(){I.executeSql(o,u,d,l)},l)},l):l(m,g)},l)}function Un(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"SELECT * FROM "+m.storeName+" WHERE key = ? LIMIT 1",[n],function(I,R){var b=R.rows.length?R.rows.item(0).value:null;b&&(b=m.serializer.deserialize(b)),d(b)},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function xn(n,c){var o=this,u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"SELECT * FROM "+m.storeName,[],function(I,R){for(var b=R.rows,T=b.length,k=0;k<T;k++){var j=b.item(k),q=j.value;if(q&&(q=m.serializer.deserialize(q)),q=n(q,j.key,k+1),q!==void 0){d(q);return}}d()},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function mr(n,c,o,u){var d=this;n=F(n);var l=new E(function(m,g){d.ready().then(function(){c===void 0&&(c=null);var I=c,R=d._dbInfo;R.serializer.serialize(c,function(b,T){T?g(T):R.db.transaction(function(k){we(k,R,"INSERT OR REPLACE INTO "+R.storeName+" (key, value) VALUES (?, ?)",[n,b],function(){m(I)},function(j,q){g(q)})},function(k){if(k.code===k.QUOTA_ERR){if(u>0){m(mr.apply(d,[n,I,o,u-1]));return}g(k)}})})}).catch(g)});return N(l,o),l}function Fn(n,c,o){return mr.apply(this,[n,c,o,1])}function kn(n,c){var o=this;n=F(n);var u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"DELETE FROM "+m.storeName+" WHERE key = ?",[n],function(){d()},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function Wn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){var l=c._dbInfo;l.db.transaction(function(m){we(m,l,"DELETE FROM "+l.storeName,[],function(){u()},function(g,I){d(I)})})}).catch(d)});return N(o,n),o}function Bn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){var l=c._dbInfo;l.db.transaction(function(m){we(m,l,"SELECT COUNT(key) as c FROM "+l.storeName,[],function(g,I){var R=I.rows.item(0).c;u(R)},function(g,I){d(I)})})}).catch(d)});return N(o,n),o}function Gn(n,c){var o=this,u=new E(function(d,l){o.ready().then(function(){var m=o._dbInfo;m.db.transaction(function(g){we(g,m,"SELECT key FROM "+m.storeName+" WHERE id = ? LIMIT 1",[n+1],function(I,R){var b=R.rows.length?R.rows.item(0).key:null;d(b)},function(I,R){l(R)})})}).catch(l)});return N(u,c),u}function Vn(n){var c=this,o=new E(function(u,d){c.ready().then(function(){var l=c._dbInfo;l.db.transaction(function(m){we(m,l,"SELECT key FROM "+l.storeName,[],function(g,I){for(var R=[],b=0;b<I.rows.length;b++)R.push(I.rows.item(b).key);u(R)},function(g,I){d(I)})})}).catch(d)});return N(o,n),o}function jn(n){return new E(function(c,o){n.transaction(function(u){u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(d,l){for(var m=[],g=0;g<l.rows.length;g++)m.push(l.rows.item(g).name);c({db:n,storeNames:m})},function(d,l){o(l)})},function(u){o(u)})})}function Hn(n,c){c=L.apply(this,arguments);var o=this.config();n=typeof n!="function"&&n||{},n.name||(n.name=n.name||o.name,n.storeName=n.storeName||o.storeName);var u=this,d;return n.name?d=new E(function(l){var m;n.name===o.name?m=u._dbInfo.db:m=openDatabase(n.name,"","",0),n.storeName?l({db:m,storeNames:[n.storeName]}):l(jn(m))}).then(function(l){return new E(function(m,g){l.db.transaction(function(I){function R(j){return new E(function(q,z){I.executeSql("DROP TABLE IF EXISTS "+j,[],function(){q()},function(X,le){z(le)})})}for(var b=[],T=0,k=l.storeNames.length;T<k;T++)b.push(R(l.storeNames[T]));E.all(b).then(function(){m()}).catch(function(j){g(j)})},function(I){g(I)})})}):d=E.reject("Invalid arguments"),N(d,c),d}var qn={_driver:"webSQLStorage",_initStorage:$n,_support:Ln(),iterate:xn,getItem:Un,setItem:Fn,removeItem:kn,clear:Wn,length:Bn,key:Gn,keys:Vn,dropInstance:Hn};function Kn(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function pr(n,c){var o=n.name+"/";return n.storeName!==c.storeName&&(o+=n.storeName+"/"),o}function Yn(){var n="_localforage_support_test";try{return localStorage.setItem(n,!0),localStorage.removeItem(n),!1}catch{return!0}}function Xn(){return!Yn()||localStorage.length>0}function zn(n){var c=this,o={};if(n)for(var u in n)o[u]=n[u];return o.keyPrefix=pr(n,c._defaultConfig),Xn()?(c._dbInfo=o,o.serializer=bt,E.resolve()):E.reject()}function Jn(n){var c=this,o=c.ready().then(function(){for(var u=c._dbInfo.keyPrefix,d=localStorage.length-1;d>=0;d--){var l=localStorage.key(d);l.indexOf(u)===0&&localStorage.removeItem(l)}});return N(o,n),o}function Qn(n,c){var o=this;n=F(n);var u=o.ready().then(function(){var d=o._dbInfo,l=localStorage.getItem(d.keyPrefix+n);return l&&(l=d.serializer.deserialize(l)),l});return N(u,c),u}function Zn(n,c){var o=this,u=o.ready().then(function(){for(var d=o._dbInfo,l=d.keyPrefix,m=l.length,g=localStorage.length,I=1,R=0;R<g;R++){var b=localStorage.key(R);if(b.indexOf(l)===0){var T=localStorage.getItem(b);if(T&&(T=d.serializer.deserialize(T)),T=n(T,b.substring(m),I++),T!==void 0)return T}}});return N(u,c),u}function ei(n,c){var o=this,u=o.ready().then(function(){var d=o._dbInfo,l;try{l=localStorage.key(n)}catch{l=null}return l&&(l=l.substring(d.keyPrefix.length)),l});return N(u,c),u}function ti(n){var c=this,o=c.ready().then(function(){for(var u=c._dbInfo,d=localStorage.length,l=[],m=0;m<d;m++){var g=localStorage.key(m);g.indexOf(u.keyPrefix)===0&&l.push(g.substring(u.keyPrefix.length))}return l});return N(o,n),o}function ri(n){var c=this,o=c.keys().then(function(u){return u.length});return N(o,n),o}function ni(n,c){var o=this;n=F(n);var u=o.ready().then(function(){var d=o._dbInfo;localStorage.removeItem(d.keyPrefix+n)});return N(u,c),u}function ii(n,c,o){var u=this;n=F(n);var d=u.ready().then(function(){c===void 0&&(c=null);var l=c;return new E(function(m,g){var I=u._dbInfo;I.serializer.serialize(c,function(R,b){if(b)g(b);else try{localStorage.setItem(I.keyPrefix+n,R),m(l)}catch(T){(T.name==="QuotaExceededError"||T.name==="NS_ERROR_DOM_QUOTA_REACHED")&&g(T),g(T)}})})});return N(d,o),d}function ai(n,c){if(c=L.apply(this,arguments),n=typeof n!="function"&&n||{},!n.name){var o=this.config();n.name=n.name||o.name,n.storeName=n.storeName||o.storeName}var u=this,d;return n.name?d=new E(function(l){n.storeName?l(pr(n,u._defaultConfig)):l(n.name+"/")}).then(function(l){for(var m=localStorage.length-1;m>=0;m--){var g=localStorage.key(m);g.indexOf(l)===0&&localStorage.removeItem(g)}}):d=E.reject("Invalid arguments"),N(d,c),d}var oi={_driver:"localStorageWrapper",_initStorage:zn,_support:Kn(),iterate:Zn,getItem:Qn,setItem:ii,removeItem:ni,clear:Jn,length:ri,key:ei,keys:ti,dropInstance:ai},si=function(c,o){return c===o||typeof c=="number"&&typeof o=="number"&&isNaN(c)&&isNaN(o)},ci=function(c,o){for(var u=c.length,d=0;d<u;){if(si(c[d],o))return!0;d++}return!1},vr=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"},qe={},yr={},Ue={INDEXEDDB:Mn,WEBSQL:qn,LOCALSTORAGE:oi},li=[Ue.INDEXEDDB._driver,Ue.WEBSQL._driver,Ue.LOCALSTORAGE._driver],rt=["dropInstance"],St=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(rt),ui={description:"",driver:li.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function di(n,c){n[c]=function(){var o=arguments;return n.ready().then(function(){return n[c].apply(n,o)})}}function At(){for(var n=1;n<arguments.length;n++){var c=arguments[n];if(c)for(var o in c)c.hasOwnProperty(o)&&(vr(c[o])?arguments[0][o]=c[o].slice():arguments[0][o]=c[o])}return arguments[0]}var fi=function(){function n(c){h(this,n);for(var o in Ue)if(Ue.hasOwnProperty(o)){var u=Ue[o],d=u._driver;this[o]=d,qe[d]||this.defineDriver(u)}this._defaultConfig=At({},ui),this._config=At({},this._defaultConfig,c),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return n.prototype.config=function(o){if((typeof o>"u"?"undefined":p(o))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var u in o){if(u==="storeName"&&(o[u]=o[u].replace(/\W/g,"_")),u==="version"&&typeof o[u]!="number")return new Error("Database version must be a number.");this._config[u]=o[u]}return"driver"in o&&o.driver?this.setDriver(this._config.driver):!0}else return typeof o=="string"?this._config[o]:this._config},n.prototype.defineDriver=function(o,u,d){var l=new E(function(m,g){try{var I=o._driver,R=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!o._driver){g(R);return}for(var b=St.concat("_initStorage"),T=0,k=b.length;T<k;T++){var j=b[T],q=!ci(rt,j);if((q||o[j])&&typeof o[j]!="function"){g(R);return}}var z=function(){for(var Ke=function(pi){return function(){var vi=new Error("Method "+pi+" is not implemented by the current driver"),gr=E.reject(vi);return N(gr,arguments[arguments.length-1]),gr}},Ot=0,mi=rt.length;Ot<mi;Ot++){var Nt=rt[Ot];o[Nt]||(o[Nt]=Ke(Nt))}};z();var X=function(Ke){qe[I]&&console.info("Redefining LocalForage driver: "+I),qe[I]=o,yr[I]=Ke,m()};"_support"in o?o._support&&typeof o._support=="function"?o._support().then(X,g):X(!!o._support):X(!0)}catch(le){g(le)}});return D(l,u,d),l},n.prototype.driver=function(){return this._driver||null},n.prototype.getDriver=function(o,u,d){var l=qe[o]?E.resolve(qe[o]):E.reject(new Error("Driver not found."));return D(l,u,d),l},n.prototype.getSerializer=function(o){var u=E.resolve(bt);return D(u,o),u},n.prototype.ready=function(o){var u=this,d=u._driverSet.then(function(){return u._ready===null&&(u._ready=u._initDriver()),u._ready});return D(d,o,o),d},n.prototype.setDriver=function(o,u,d){var l=this;vr(o)||(o=[o]);var m=this._getSupportedDrivers(o);function g(){l._config.driver=l.driver()}function I(T){return l._extend(T),g(),l._ready=l._initStorage(l._config),l._ready}function R(T){return function(){var k=0;function j(){for(;k<T.length;){var q=T[k];return k++,l._dbInfo=null,l._ready=null,l.getDriver(q).then(I).catch(j)}g();var z=new Error("No available storage method found.");return l._driverSet=E.reject(z),l._driverSet}return j()}}var b=this._driverSet!==null?this._driverSet.catch(function(){return E.resolve()}):E.resolve();return this._driverSet=b.then(function(){var T=m[0];return l._dbInfo=null,l._ready=null,l.getDriver(T).then(function(k){l._driver=k._driver,g(),l._wrapLibraryMethodsWithReady(),l._initDriver=R(m)})}).catch(function(){g();var T=new Error("No available storage method found.");return l._driverSet=E.reject(T),l._driverSet}),D(this._driverSet,u,d),this._driverSet},n.prototype.supports=function(o){return!!yr[o]},n.prototype._extend=function(o){At(this,o)},n.prototype._getSupportedDrivers=function(o){for(var u=[],d=0,l=o.length;d<l;d++){var m=o[d];this.supports(m)&&u.push(m)}return u},n.prototype._wrapLibraryMethodsWithReady=function(){for(var o=0,u=St.length;o<u;o++)di(this,St[o])},n.prototype.createInstance=function(o){return new n(o)},n}(),hi=new fi;a.exports=hi},{3:3}]},{},[4])(4)})});var wn=Er((yt,In)=>{"use strict";(function(e,t){typeof yt=="object"&&typeof In<"u"?t(yt):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],t):t(e.LocalforageDriverMemory={})})(typeof self<"u"?self:yt,function(e){"use strict";var t="localforage-driver-memory";function r(f){var _=typeof Symbol=="function"&&f[Symbol.iterator],S=0;return _?_.call(f):{next:function(){return f&&S>=f.length&&(f=void 0),{value:f&&f[S++],done:!f}}}}function i(f,_){f=f||[],_=_||{};try{return new Blob(f,_)}catch(U){if(U.name!=="TypeError")throw U;for(var S=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,C=new S,P=0;P<f.length;P+=1)C.append(f[P]);return C.getBlob(_.type)}}var a=/^~~local_forage_type~([^~]+)~/,s=9,p=s+4,h=Object.prototype.toString;function w(f){var _=f.length*.75,S=f.length;f[f.length-1]==="="&&(_--,f[f.length-2]==="="&&_--);for(var C=new ArrayBuffer(_),P=new Uint8Array(C),U=0,V=0;U<S;U+=4){var Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U]),$e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U+1]),Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U+2]),He="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[U+3]);P[V++]=Z<<2|$e>>4,P[V++]=($e&15)<<4|Ce>>2,P[V++]=(Ce&3)<<6|He&63}return C}function v(f){for(var _=new Uint8Array(f),S="",C=0;C<_.length;C+=3)S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[_[C]>>2],S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(_[C]&3)<<4|_[C+1]>>4],S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(_[C+1]&15)<<2|_[C+2]>>6],S+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[_[C+2]&63];return _.length%3===2?S=S.substring(0,S.length-1)+"=":_.length%3===1&&(S=S.substring(0,S.length-2)+"=="),S}function y(f,_){var S="";if(f&&(S=h.call(f)),f&&(S==="[object ArrayBuffer]"||f.buffer&&h.call(f.buffer)==="[object ArrayBuffer]")){var C=void 0,P="__lfsc__:";f instanceof ArrayBuffer?(C=f,P+="arbf"):(C=f.buffer,S==="[object Int8Array]"?P+="si08":S==="[object Uint8Array]"?P+="ui08":S==="[object Uint8ClampedArray]"?P+="uic8":S==="[object Int16Array]"?P+="si16":S==="[object Uint16Array]"?P+="ur16":S==="[object Int32Array]"?P+="si32":S==="[object Uint32Array]"?P+="ui32":S==="[object Float32Array]"?P+="fl32":S==="[object Float64Array]"?P+="fl64":_(new Error("Failed to get type for BinaryArray"))),_(P+v(C))}else if(S==="[object Blob]"){var U=new FileReader;U.onload=function(){var V="~~local_forage_type~"+f.type+"~"+v(this.result);_("__lfsc__:blob"+V)},U.readAsArrayBuffer(f)}else try{_(JSON.stringify(f))}catch(V){console.error("Couldn't convert value into a JSON string: ",f),_(null,V)}}function O(f){if(f.substring(0,s)!=="__lfsc__:")return JSON.parse(f);var _=f.substring(p),S=f.substring(s,p),C;if(S==="blob"&&a.test(_)){var P=_.match(a);C=P[1],_=_.substring(P[0].length)}var U=w(_);switch(S){case"arbf":return U;case"blob":return i([U],{type:C});case"si08":return new Int8Array(U);case"ui08":return new Uint8Array(U);case"uic8":return new Uint8ClampedArray(U);case"si16":return new Int16Array(U);case"ur16":return new Uint16Array(U);case"si32":return new Int32Array(U);case"ui32":return new Uint32Array(U);case"fl32":return new Float32Array(U);case"fl64":return new Float64Array(U);default:throw new Error("Unkown type: "+S)}}function E(f){var _,S;if(f===null||typeof f!="object"||"isActiveClone"in f)return f;var C=f instanceof Date?new Date(f):f.constructor();try{for(var P=r(Object.keys(f)),U=P.next();!U.done;U=P.next()){var V=U.value;Object.prototype.hasOwnProperty.call(f,V)&&(f.isActiveClone=null,C[V]=E(f[V]),delete f.isActiveClone)}}catch(Z){_={error:Z}}finally{try{U&&!U.done&&(S=P.return)&&S.call(P)}finally{if(_)throw _.error}}return C}function N(f,_){return(f.name||_.name)+"/"+(f.storeName||_.storeName)+"/"}function D(f,_){_&&f.then(function(S){_(null,S)},function(S){_(S)})}function F(){for(var f=[],_=0;_<arguments.length;_++)f[_]=arguments[_];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function L(f,_){var S=this;if(_=F.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var C=this.config();f.name=f.name||C.name,f.storeName=f.storeName||C.storeName}var P;return f.name?P=new Promise(function(U){f.storeName?U(N(f,S._defaultConfig)):U(f.name+"/")}):P=Promise.reject("Invalid arguments"),{promise:P,callback:_}}function W(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}var J={bufferToString:v,deserialize:O,serialize:y,stringToBuffer:w},$={},_e=function(){function f(_){this.kp=_,this.data={}}return f.resolve=function(_){return $[_]||($[_]=new f(_)),$[_]},f.prototype.clear=function(){this.data={}},f.prototype.drop=function(){this.clear(),delete $[this.kp]},f.prototype.get=function(_){return this.data[_]},f.prototype.key=function(_){return this.keys()[_]},f.prototype.keys=function(){return Object.keys(this.data)},f.prototype.rm=function(_){delete this.data[_]},f.prototype.set=function(_,S){this.data[_]=S},f}();function re(f){var _=f?E(f):{},S=N(_,this._defaultConfig),C=_e.resolve(S);return this._dbInfo=_,this._dbInfo.serializer=J,this._dbInfo.keyPrefix=S,this._dbInfo.mStore=C,Promise.resolve()}function A(f){var _=this,S=this.ready().then(function(){_._dbInfo.mStore.clear()});return D(S,f),S}function B(f,_){var S=L.apply(this,arguments),C=S.promise,P=S.callback,U=C.then(function(V){_e.resolve(V).drop()});return D(U,P),C}function x(f,_){var S=this;f=W(f);var C=this.ready().then(function(){var P=S._dbInfo.mStore.get(f);return P==null?null:S._dbInfo.serializer.deserialize(P)});return D(C,_),C}function H(f,_){var S=this,C=this.ready().then(function(){for(var P=S._dbInfo.mStore,U=P.keys(),V=0;V<U.length;V++){var Z=P.get(U[V]);if(Z&&(Z=S._dbInfo.serializer.deserialize(Z)),Z=f(Z,U[V],V+1),Z!==void 0)return Z}});return D(C,_),C}function Q(f,_){var S=this,C=this.ready().then(function(){var P;try{P=S._dbInfo.mStore.key(f),P===void 0&&(P=null)}catch{P=null}return P});return D(C,_),C}function ne(f){var _=this,S=this.ready().then(function(){return _._dbInfo.mStore.keys()});return D(S,f),S}function oe(f){var _=this.keys().then(function(S){return S.length});return D(_,f),_}function se(f,_){var S=this;f=W(f);var C=this.ready().then(function(){S._dbInfo.mStore.rm(f)});return D(C,_),C}function fe(f,_,S){var C=this;f=W(f);var P=this.ready().then(function(){_===void 0&&(_=null);var U=_;return new Promise(function(V,Z){C._dbInfo.serializer.serialize(_,function($e,Ce){if(Ce)Z(Ce);else try{C._dbInfo.mStore.set(f,$e),V(U)}catch(He){Z(He)}})})});return D(P,S),P}var Le=!0;e._support=Le,e._driver=t,e._initStorage=re,e.clear=A,e.dropInstance=B,e.getItem=x,e.iterate=H,e.key=Q,e.keys=ne,e.length=oe,e.removeItem=se,e.setItem=fe,Object.defineProperty(e,"__esModule",{value:!0})})});var ko={};_r(ko,{default:()=>Fo});var Jt={};_r(Jt,{Extension:()=>Co,MagicExtensionError:()=>Vr,MagicExtensionWarning:()=>$t,MagicRPCError:()=>ft,MagicSDKError:()=>De,MagicSDKWarning:()=>je,MultichainExtension:()=>Po,SDKBase:()=>Xt,STORE_KEY_PRIVATE_KEY:()=>vt,STORE_KEY_PUBLIC_JWK:()=>Qe,TypedEmitter:()=>un,ViewController:()=>zt,clearKeys:()=>rn,createDeprecationWarning:()=>Qr,createDuplicateIframeWarning:()=>Wt,createExtensionNotInitializedError:()=>Kr,createIncompatibleExtensionsError:()=>Yr,createInvalidArgumentError:()=>Xr,createJwt:()=>nn,createMalformedResponseError:()=>qr,createMissingApiKeyError:()=>Hr,createModalNotReadyError:()=>pt,createPromiEvent:()=>me,createPromise:()=>jt,createReactNativeEndpointConfigurationWarning:()=>Jr,createSDK:()=>kt,createSynchronousWeb3MethodWarning:()=>zr,createTypedEmitter:()=>Vt,createURL:()=>Ge,decodeJSON:()=>Fr,encodeJSON:()=>Ft,getPayloadId:()=>Bt,isEmpty:()=>Je,isJsonRpcErrorCode:()=>Wr,isJsonRpcRequestPayload:()=>Va,isJsonRpcResponsePayload:()=>kr,isMagicPayloadMethod:()=>ja,isMajorVersionAtLeast:()=>hn,isPromiEvent:()=>fn,isWebCryptoSupported:()=>et,storage:()=>Gt,uuid:()=>en});var Re=(e=>(e.MissingApiKey="MISSING_API_KEY",e.ModalNotReady="MODAL_NOT_READY",e.ConnectionLost="CONNECTION_WAS_LOST",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e))(Re||{}),be=(e=>(e.SyncWeb3Method="SYNC_WEB3_METHOD",e.DuplicateIframe="DUPLICATE_IFRAME",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT",e))(be||{}),Pe=(e=>(e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",e[e.MagicLinkExpired=-10001]="MagicLinkExpired",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.MagicLinkInvalidRedirectURL=-10006]="MagicLinkInvalidRedirectURL",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.UpdateEmailFailed=-10004]="UpdateEmailFailed",e[e.UserRequestEditEmail=-10005]="UserRequestEditEmail",e[e.InactiveRecipient=-10010]="InactiveRecipient",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e[e.DpopInvalidated=-10019]="DpopInvalidated",e))(Pe||{}),ge=(e=>(e.PROVIDER="magic_3pw_provider",e.ADDRESS="magic_3pw_address",e.CHAIN_ID="magic_3pw_chainId",e))(ge||{}),Ri=(e=>(e.WalletConnected="wallet_connected",e.WalletRejected="wallet_rejected",e.Web3ModalSelected="web3modal_selected",e))(Ri||{}),M=(e=>(e.LoginWithSms="magic_auth_login_with_sms",e.LoginWithEmailOTP="magic_auth_login_with_email_otp",e.LoginWithMagicLink="magic_auth_login_with_magic_link",e.LoginWithCredential="magic_auth_login_with_credential",e.SetAuthorizationToken="magic_auth_set_authorization_token",e.GetIdToken="magic_auth_get_id_token",e.GenerateIdToken="magic_auth_generate_id_token",e.GetMetadata="magic_auth_get_metadata",e.IsLoggedIn="magic_is_logged_in",e.Logout="magic_auth_logout",e.UpdateEmail="magic_auth_update_email",e.UserSettings="magic_auth_settings",e.UserSettingsTestMode="magic_auth_settings_testing_mode",e.LoginWithSmsTestMode="magic_auth_login_with_sms_testing_mode",e.LoginWithEmailOTPTestMode="magic_auth_login_with_email_otp_testing_mode",e.LoginWithMagicLinkTestMode="magic_login_with_magic_link_testing_mode",e.LoginWithCredentialTestMode="magic_auth_login_with_credential_testing_mode",e.GetIdTokenTestMode="magic_auth_get_id_token_testing_mode",e.GenerateIdTokenTestMode="magic_auth_generate_id_token_testing_mode",e.GetMetadataTestMode="magic_auth_get_metadata_testing_mode",e.IsLoggedInTestMode="magic_auth_is_logged_in_testing_mode",e.LogoutTestMode="magic_auth_logout_testing_mode",e.UpdateEmailTestMode="magic_auth_update_email_testing_mode",e.IntermediaryEvent="magic_intermediary_event",e.RequestAccounts="eth_requestAccounts",e.GetInfo="magic_get_info",e.ShowUI="magic_wallet",e.NFTPurchase="magic_nft_purchase",e.NFTCheckout="magic_nft_checkout",e.NFTTransfer="magic_nft_transfer",e.RequestUserInfoWithUI="mc_request_user_info",e.Disconnect="mc_disconnect",e.RecoverAccount="magic_auth_recover_account",e.RecoverAccountTestMode="magic_auth_recover_account_testing_mode",e.MagicBoxHeartBeat="magic_box_heart_beat",e.AutoConnect="mc_auto_connect",e.Login="mc_login",e.EncryptV1="magic_auth_encrypt_v1",e.DecryptV1="magic_auth_decrypt_v1",e.ShowNFTs="magic_show_nfts",e.ShowOnRamp="magic_show_fiat_onramp",e.ShowSendTokensUI="magic_show_send_tokens_ui",e.ShowAddress="magic_show_address",e.ShowBalances="magic_show_balances",e.SendGaslessTransaction="eth_sendGaslessTransaction",e.RevealPK="magic_reveal_key",e.EnableMFA="magic_auth_enable_mfa_flow",e.DisableMFA="magic_auth_disable_mfa_flow",e.GetMultichainPublicAddress="magic_get_multichain_public_address",e))(M||{}),Rr=["magic_intermediary_event","magic_nft_checkout","mc_login"],he=(e=>(e.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",e.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",e.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",e.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",e.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT",e.MAGIC_MG_BOX_SEND_RECEIPT="MAGIC_MG_BOX_SEND_RECEIPT",e.MAGIC_SEND_PRODUCT_ANNOUNCEMENT="MAGIC_SEND_PRODUCT_ANNOUNCEMENT",e.MAGIC_PONG="MAGIC_PONG",e.MAGIC_POPUP_RESPONSE="MAGIC_POPUP_RESPONSE",e.MAGIC_POPUP_OAUTH_VERIFY_RESPONSE="MAGIC_POPUP_OAUTH_VERIFY_RESPONSE",e))(he||{}),Se=(e=>(e.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST",e.MAGIC_PING="MAGIC_PING",e))(Se||{}),bi=(e=>(e.UpdateEmail="update-email",e.MFA="mfa",e.Recovery="recovery",e))(bi||{}),Si=(e=>(e.Retry="retry",e))(Si||{}),Ai=(e=>(e.EmailSent="email-sent",e.EmailNotDeliverable="email-not-deliverable",e))(Ai||{}),ue=(e=>(e.VerifyEmailOtp="verify-email-otp",e.VerifyMFACode="verify-mfa-code",e.LostDevice="lost-device",e.VerifyRecoveryCode="verify-recovery-code",e.Cancel="cancel",e))(ue||{}),xe=(e=>(e.VerifySmsOtp="verify-sms-otp",e.Cancel="cancel",e.Retry="retry",e))(xe||{}),Oi=(e=>(e.SmsOTPSent="sms-otp-sent",e.InvalidSmsOtp="invalid-sms-otp",e.ExpiredSmsOtp="expired-sms-otp",e))(Oi||{}),Ni=(e=>(e.EmailOTPSent="email-otp-sent",e.InvalidEmailOtp="invalid-email-otp",e.InvalidMfaOtp="invalid-mfa-otp",e.ExpiredEmailOtp="expired-email-otp",e.MfaSentHandle="mfa-sent-handle",e.RecoveryCodeSentHandle="recovery-code-sent-handle",e.InvalidRecoveryCode="invalid-recovery-code",e.RecoveryCodeSuccess="recovery-code-success",e.LoginThrottled="login-throttled",e))(Ni||{}),it=(e=>(e.Retry="device-retry",e))(it||{}),Ti=(e=>(e.DeviceApproved="device-approved",e.DeviceNeedsApproval="device-needs-approval",e.DeviceVerificationLinkExpired="device-verification-link-expired",e.DeviceVerificationEmailSent="device-verification-email-sent",e))(Ti||{}),ce=(e=>(e.Retry="Recency/auth-factor-retry",e.Cancel="Recency/auth-factor-verification-cancel",e.VerifyEmailOtp="Recency/auth-factor-verify-email-otp",e.VerifyMFACode="Recency/verify-mfa-code",e))(ce||{}),Mi=(e=>(e.PrimaryAuthFactorNeedsVerification="Recency/auth-factor-needs-verification",e.PrimaryAuthFactorVerified="Recency/auth-factor-verified",e.InvalidEmailOtp="Recency/auth-factor-invalid-email-otp",e.EmailExpired="Recency/auth-factor-verification-email-expired",e.EmailSent="Recency/auth-factor-verification-email-sent",e.EmailNotDeliverable="Recency/auth-factor-verification-email-not-deliverable",e))(Mi||{}),ie=(e=>(e.RetryWithNewEmail="UpdateEmail/retry-with-new-email",e.Cancel="UpdateEmail/new-email-verification-cancel",e.VerifyEmailOtp="UpdateEmail/new-email-verify-otp",e))(ie||{}),Li=(e=>(e.NewAuthFactorNeedsVerification="UpdateEmail/new-email-needs-verification",e.EmailUpdated="UpdateEmail/email-updated",e.InvalidEmailOtp="UpdateEmail/new-email-invalid-email-otp",e.EmailExpired="UpdateEmail/new-email-verification-email-expired",e.EmailSent="UpdateEmail/new-email-verification-email-sent",e.EmailNotDeliverable="UpdateEmail/new-email-verification-email-not-deliverable",e.InvalidEmail="UpdateEmail/new-email-invalid",e.EmailAlreadyExists="UpdateEmail/new-email-already-exists",e))(Li||{}),Ci=(e=>(e.IDTokenCreated="Auth/id-token-created",e))(Ci||{}),Pi=(e=>(e.Cancel="Farcaster/cancel",e))(Pi||{}),Di=(e=>(e.MFASecretGenerated="mfa-secret-generated",e.InvalidMFAOtp="invalid-mfa-otp",e.MFARecoveryCodes="mfa-recovery-codes",e))(Di||{}),Fe=(e=>(e.VerifyMFACode="verify-mfa-code",e.Cancel="cancel-mfa-setup",e))(Fe||{}),$i=(e=>(e.MFACodeRequested="mfa-code-requested",e.InvalidMFAOtp="invalid-mfa-otp",e.InvalidRecoveryCode="invalid-recovery-code",e))($i||{}),Ae=(e=>(e.VerifyMFACode="verify-mfa-code",e.LostDevice="lost-device",e.Cancel="cancel-mfa-disable",e))(Ae||{}),Ui=(e=>(e.Harmony="HARMONY",e))(Ui||{}),Tt=(e=>(e.ClosedByUser="closed-by-user",e))(Tt||{}),Mt=(e=>(e.ClosedByUser="closed-by-user-on-received",e))(Mt||{}),xi=(e=>(e.EnterNewPhoneNumber="enter-new-phone-number",e.EnterOtpCode="enter-otp-code",e.RecoveryFactorAlreadyExists="recovery-factor-already-exists",e.MalformedPhoneNumber="malformed-phone-number",e.InvalidOtpCode="invalid-otp-code",e.RecoveryFactorUpdated="recovery-factor-updated",e.RecoveryFactorDeleted="recovery-factor-deleted",e))(xi||{}),pe=(e=>(e.SendNewPhoneNumber="send-new-phone-number",e.SendOtpCode="send-otp-code",e.Cancel="cancel",e.StartEditPhoneNumber="start-edit-phone-number",e))(pe||{}),Fi=(e=>(e.PhoneNumber="phone_number",e))(Fi||{}),ki=(e=>(e.SmsOtpSent="sms-otp-sent",e.LoginThrottled="login-throttled",e.InvalidSmsOtp="invalid-sms-otp",e.SmsVerified="sms-verified",e.AccountRecovered="account-recovered",e.UpdateEmailRequired="update-email-required",e))(ki||{}),ve=(e=>(e.Cancel="cancel",e.VerifyOtp="verify-otp-code",e.ResendSms="resend-sms-otp",e.UpdateEmail="update-email",e))(ve||{}),ke=(e=>(e.Success="nft-checkout-success",e.Failure="nft-checkout-failure",e.Initiated="nft-checkout-initiated",e.Disconnect="disconnect",e))(ke||{}),Wi=(e=>(e.WalletInfoFetched="Wallet/wallet-info-fetched",e))(Wi||{}),Bi=(e=>(e.CloseMagicWindow="close-magic-window",e))(Bi||{}),Gi=(e=>(e.PopupUrl="popup-url",e))(Gi||{}),Vi=(e=>(e.PopupEvent="popup-event",e.Cancel="cancel",e))(Vi||{});var ji=Object.create,Ut=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,qi=Object.getOwnPropertyNames,Ki=Object.getPrototypeOf,Yi=Object.prototype.hasOwnProperty,Xi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zi=(e,t)=>{for(var r in t)Ut(e,r,{get:t[r],enumerable:!0})},Ji=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of qi(t))!Yi.call(e,a)&&a!==r&&Ut(e,a,{get:()=>t[a],enumerable:!(i=Hi(t,a))||i.enumerable});return e},Qi=(e,t,r)=>(r=e!=null?ji(Ki(e)):{},Ji(t||!e||!e.__esModule?Ut(r,"default",{value:e,enumerable:!0}):r,e)),Zi=Xi((e,t)=>{"use strict";var r=Object.prototype.hasOwnProperty,i="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(i=!1));function s(v,y,O){this.fn=v,this.context=y,this.once=O||!1}function p(v,y,O,E,N){if(typeof O!="function")throw new TypeError("The listener must be a function");var D=new s(O,E||v,N),F=i?i+y:y;return v._events[F]?v._events[F].fn?v._events[F]=[v._events[F],D]:v._events[F].push(D):(v._events[F]=D,v._eventsCount++),v}function h(v,y){--v._eventsCount===0?v._events=new a:delete v._events[y]}function w(){this._events=new a,this._eventsCount=0}w.prototype.eventNames=function(){var v=[],y,O;if(this._eventsCount===0)return v;for(O in y=this._events)r.call(y,O)&&v.push(i?O.slice(1):O);return Object.getOwnPropertySymbols?v.concat(Object.getOwnPropertySymbols(y)):v},w.prototype.listeners=function(v){var y=i?i+v:v,O=this._events[y];if(!O)return[];if(O.fn)return[O.fn];for(var E=0,N=O.length,D=new Array(N);E<N;E++)D[E]=O[E].fn;return D},w.prototype.listenerCount=function(v){var y=i?i+v:v,O=this._events[y];return O?O.fn?1:O.length:0},w.prototype.emit=function(v,y,O,E,N,D){var F=i?i+v:v;if(!this._events[F])return!1;var L=this._events[F],W=arguments.length,J,$;if(L.fn){switch(L.once&&this.removeListener(v,L.fn,void 0,!0),W){case 1:return L.fn.call(L.context),!0;case 2:return L.fn.call(L.context,y),!0;case 3:return L.fn.call(L.context,y,O),!0;case 4:return L.fn.call(L.context,y,O,E),!0;case 5:return L.fn.call(L.context,y,O,E,N),!0;case 6:return L.fn.call(L.context,y,O,E,N,D),!0}for($=1,J=new Array(W-1);$<W;$++)J[$-1]=arguments[$];L.fn.apply(L.context,J)}else{var _e=L.length,re;for($=0;$<_e;$++)switch(L[$].once&&this.removeListener(v,L[$].fn,void 0,!0),W){case 1:L[$].fn.call(L[$].context);break;case 2:L[$].fn.call(L[$].context,y);break;case 3:L[$].fn.call(L[$].context,y,O);break;case 4:L[$].fn.call(L[$].context,y,O,E);break;default:if(!J)for(re=1,J=new Array(W-1);re<W;re++)J[re-1]=arguments[re];L[$].fn.apply(L[$].context,J)}}return!0},w.prototype.on=function(v,y,O){return p(this,v,y,O,!1)},w.prototype.once=function(v,y,O){return p(this,v,y,O,!0)},w.prototype.removeListener=function(v,y,O,E){var N=i?i+v:v;if(!this._events[N])return this;if(!y)return h(this,N),this;var D=this._events[N];if(D.fn)D.fn===y&&(!E||D.once)&&(!O||D.context===O)&&h(this,N);else{for(var F=0,L=[],W=D.length;F<W;F++)(D[F].fn!==y||E&&!D[F].once||O&&D[F].context!==O)&&L.push(D[F]);L.length?this._events[N]=L.length===1?L[0]:L:h(this,N)}return this},w.prototype.removeAllListeners=function(v){var y;return v?(y=i?i+v:v,this._events[y]&&h(this,y)):(this._events=new a,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=i,w.EventEmitter=w,typeof t<"u"&&(t.exports=w)});function ea(e){let t={exports:{}};return e(t,t.exports),t.exports}var ta=Number.MAX_SAFE_INTEGER||9007199254740991,xt={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:ta,MAX_SAFE_COMPONENT_LENGTH:16},ra=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{},K=ra,Ze=ea(function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:r}=xt,i=(t=e.exports={}).re=[],a=t.src=[],s=t.t={},p=0,h=(w,v,y)=>{let O=p++;K(O,v),s[w]=O,a[O]=v,i[O]=new RegExp(v,y?"g":void 0)};h("NUMERICIDENTIFIER","0|[1-9]\\d*"),h("NUMERICIDENTIFIERLOOSE","[0-9]+"),h("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),h("MAINVERSION",`(${a[s.NUMERICIDENTIFIER]})\\.(${a[s.NUMERICIDENTIFIER]})\\.(${a[s.NUMERICIDENTIFIER]})`),h("MAINVERSIONLOOSE",`(${a[s.NUMERICIDENTIFIERLOOSE]})\\.(${a[s.NUMERICIDENTIFIERLOOSE]})\\.(${a[s.NUMERICIDENTIFIERLOOSE]})`),h("PRERELEASEIDENTIFIER",`(?:${a[s.NUMERICIDENTIFIER]}|${a[s.NONNUMERICIDENTIFIER]})`),h("PRERELEASEIDENTIFIERLOOSE",`(?:${a[s.NUMERICIDENTIFIERLOOSE]}|${a[s.NONNUMERICIDENTIFIER]})`),h("PRERELEASE",`(?:-(${a[s.PRERELEASEIDENTIFIER]}(?:\\.${a[s.PRERELEASEIDENTIFIER]})*))`),h("PRERELEASELOOSE",`(?:-?(${a[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${a[s.PRERELEASEIDENTIFIERLOOSE]})*))`),h("BUILDIDENTIFIER","[0-9A-Za-z-]+"),h("BUILD",`(?:\\+(${a[s.BUILDIDENTIFIER]}(?:\\.${a[s.BUILDIDENTIFIER]})*))`),h("FULLPLAIN",`v?${a[s.MAINVERSION]}${a[s.PRERELEASE]}?${a[s.BUILD]}?`),h("FULL",`^${a[s.FULLPLAIN]}$`),h("LOOSEPLAIN",`[v=\\s]*${a[s.MAINVERSIONLOOSE]}${a[s.PRERELEASELOOSE]}?${a[s.BUILD]}?`),h("LOOSE",`^${a[s.LOOSEPLAIN]}$`),h("GTLT","((?:<|>)?=?)"),h("XRANGEIDENTIFIERLOOSE",`${a[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h("XRANGEIDENTIFIER",`${a[s.NUMERICIDENTIFIER]}|x|X|\\*`),h("XRANGEPLAIN",`[v=\\s]*(${a[s.XRANGEIDENTIFIER]})(?:\\.(${a[s.XRANGEIDENTIFIER]})(?:\\.(${a[s.XRANGEIDENTIFIER]})(?:${a[s.PRERELEASE]})?${a[s.BUILD]}?)?)?`),h("XRANGEPLAINLOOSE",`[v=\\s]*(${a[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${a[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${a[s.XRANGEIDENTIFIERLOOSE]})(?:${a[s.PRERELEASELOOSE]})?${a[s.BUILD]}?)?)?`),h("XRANGE",`^${a[s.GTLT]}\\s*${a[s.XRANGEPLAIN]}$`),h("XRANGELOOSE",`^${a[s.GTLT]}\\s*${a[s.XRANGEPLAINLOOSE]}$`),h("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),h("COERCERTL",a[s.COERCE],!0),h("LONETILDE","(?:~>?)"),h("TILDETRIM",`(\\s*)${a[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",h("TILDE",`^${a[s.LONETILDE]}${a[s.XRANGEPLAIN]}$`),h("TILDELOOSE",`^${a[s.LONETILDE]}${a[s.XRANGEPLAINLOOSE]}$`),h("LONECARET","(?:\\^)"),h("CARETTRIM",`(\\s*)${a[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",h("CARET",`^${a[s.LONECARET]}${a[s.XRANGEPLAIN]}$`),h("CARETLOOSE",`^${a[s.LONECARET]}${a[s.XRANGEPLAINLOOSE]}$`),h("COMPARATORLOOSE",`^${a[s.GTLT]}\\s*(${a[s.LOOSEPLAIN]})$|^$`),h("COMPARATOR",`^${a[s.GTLT]}\\s*(${a[s.FULLPLAIN]})$|^$`),h("COMPARATORTRIM",`(\\s*)${a[s.GTLT]}\\s*(${a[s.LOOSEPLAIN]}|${a[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",h("HYPHENRANGE",`^\\s*(${a[s.XRANGEPLAIN]})\\s+-\\s+(${a[s.XRANGEPLAIN]})\\s*$`),h("HYPHENRANGELOOSE",`^\\s*(${a[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${a[s.XRANGEPLAINLOOSE]})\\s*$`),h("STAR","(<|>)?=?\\s*\\*"),h("GTE0","^\\s*>=\\s*0.0.0\\s*$"),h("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),br=/^[0-9]+$/,xr=(e,t)=>{let r=br.test(e),i=br.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1},na=(e,t)=>xr(t,e),ia={compareIdentifiers:xr,rcompareIdentifiers:na},{MAX_LENGTH:Sr,MAX_SAFE_INTEGER:at}=xt,{re:Ar,t:Or}=Ze,{compareIdentifiers:Xe}=ia,Ne=class ye{constructor(t,r){if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),t instanceof ye){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>Sr)throw new TypeError(`version is longer than ${Sr} characters`);K("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let i=t.trim().match(r.loose?Ar[Or.LOOSE]:Ar[Or.FULL]);if(!i)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>at||this.major<0)throw new TypeError("Invalid major version");if(this.minor>at||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>at||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(a=>{if(/^[0-9]+$/.test(a)){let s=+a;if(s>=0&&s<at)return s}return a}):this.prerelease=[],this.build=i[5]?i[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(t){if(K("SemVer.compare",this.version,this.options,t),!(t instanceof ye)){if(typeof t=="string"&&t===this.version)return 0;t=new ye(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof ye||(t=new ye(t,this.options)),Xe(this.major,t.major)||Xe(this.minor,t.minor)||Xe(this.patch,t.patch)}comparePre(t){if(t instanceof ye||(t=new ye(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let i=this.prerelease[r],a=t.prerelease[r];if(K("prerelease compare",r,i,a),i===void 0&&a===void 0)return 0;if(a===void 0)return 1;if(i===void 0)return-1;if(i!==a)return Xe(i,a)}while(++r)}compareBuild(t){t instanceof ye||(t=new ye(t,this.options));let r=0;do{let i=this.build[r],a=t.build[r];if(K("prerelease compare",r,i,a),i===void 0&&a===void 0)return 0;if(a===void 0)return 1;if(i===void 0)return-1;if(i!==a)return Xe(i,a)}while(++r)}inc(t,r){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r),this.inc("pre",r);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 i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);i===-1&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},aa=(e,t,r)=>new Ne(e,r).compare(new Ne(t,r)),Ve=aa,oa=(e,t,r)=>Ve(e,t,r)===0,sa=oa,ca=(e,t,r)=>Ve(e,t,r)!==0,la=ca,ua=(e,t,r)=>Ve(e,t,r)>0,da=ua,fa=(e,t,r)=>Ve(e,t,r)>=0,ha=fa,ma=(e,t,r)=>Ve(e,t,r)<0,pa=ma,va=(e,t,r)=>Ve(e,t,r)<=0,ya=va,ga=(e,t,r,i)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return sa(e,r,i);case"!=":return la(e,r,i);case">":return da(e,r,i);case">=":return ha(e,r,i);case"<":return pa(e,r,i);case"<=":return ya(e,r,i);default:throw new TypeError(`Invalid operator: ${t}`)}},Lt=ga,ze=Symbol("SemVer ANY"),Ct=class Pt{static get ANY(){return ze}constructor(t,r){if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),t instanceof Pt){if(t.loose===!!r.loose)return t;t=t.value}K("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===ze?this.value="":this.value=this.operator+this.semver.version,K("comp",this)}parse(t){let r=this.options.loose?Nr[Tr.COMPARATORLOOSE]:Nr[Tr.COMPARATOR],i=t.match(r);if(!i)throw new TypeError(`Invalid comparator: ${t}`);this.operator=i[1]!==void 0?i[1]:"",this.operator==="="&&(this.operator=""),i[2]?this.semver=new Ne(i[2],this.options.loose):this.semver=ze}toString(){return this.value}test(t){if(K("Comparator.test",t,this.options.loose),this.semver===ze||t===ze)return!0;if(typeof t=="string")try{t=new Ne(t,this.options)}catch{return!1}return Lt(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof Pt))throw new TypeError("a Comparator is required");if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),this.operator==="")return this.value===""||new Dt(t.value,r).test(this.value);if(t.operator==="")return t.value===""||new Dt(this.value,r).test(t.semver);let i=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),a=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,p=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),h=Lt(this.semver,"<",t.semver,r)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),w=Lt(this.semver,">",t.semver,r)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return i||a||s&&p||h||w}},{re:Nr,t:Tr}=Ze,Dt=class ut{constructor(t,r){if(r&&typeof r=="object"||(r={loose:!!r,includePrerelease:!1}),t instanceof ut)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new ut(t.raw,r);if(t instanceof Ct)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(i=>this.parseRange(i.trim())).filter(i=>i.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:r}=this.options;t=t.trim();let i=r?te[ee.HYPHENRANGELOOSE]:te[ee.HYPHENRANGE];t=t.replace(i,La(this.options.includePrerelease)),K("hyphen replace",t),t=t.replace(te[ee.COMPARATORTRIM],Ea),K("comparator trim",t,te[ee.COMPARATORTRIM]),t=(t=(t=t.replace(te[ee.TILDETRIM],_a)).replace(te[ee.CARETTRIM],Ia)).split(/\s+/).join(" ");let a=r?te[ee.COMPARATORLOOSE]:te[ee.COMPARATOR];return t.split(" ").map(s=>wa(s,this.options)).join(" ").split(/\s+/).map(s=>Ma(s,this.options)).filter(this.options.loose?s=>!!s.match(a):()=>!0).map(s=>new Ct(s,this.options))}intersects(t,r){if(!(t instanceof ut))throw new TypeError("a Range is required");return this.set.some(i=>Mr(i,r)&&t.set.some(a=>Mr(a,r)&&i.every(s=>a.every(p=>s.intersects(p,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new Ne(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(Ca(this.set[r],t,this.options))return!0;return!1}},{re:te,t:ee,comparatorTrimReplace:Ea,tildeTrimReplace:_a,caretTrimReplace:Ia}=Ze,Mr=(e,t)=>{let r=!0,i=e.slice(),a=i.pop();for(;r&&i.length;)r=i.every(s=>a.intersects(s,t)),a=i.pop();return r},wa=(e,t)=>(K("comp",e,t),e=Sa(e,t),K("caret",e),e=Ra(e,t),K("tildes",e),e=Oa(e,t),K("xrange",e),e=Ta(e,t),K("stars",e),e),ae=e=>!e||e.toLowerCase()==="x"||e==="*",Ra=(e,t)=>e.trim().split(/\s+/).map(r=>ba(r,t)).join(" "),ba=(e,t)=>{let r=t.loose?te[ee.TILDELOOSE]:te[ee.TILDE];return e.replace(r,(i,a,s,p,h)=>{let w;return K("tilde",e,i,a,s,p,h),ae(a)?w="":ae(s)?w=`>=${a}.0.0 <${+a+1}.0.0-0`:ae(p)?w=`>=${a}.${s}.0 <${a}.${+s+1}.0-0`:h?(K("replaceTilde pr",h),w=`>=${a}.${s}.${p}-${h} <${a}.${+s+1}.0-0`):w=`>=${a}.${s}.${p} <${a}.${+s+1}.0-0`,K("tilde return",w),w})},Sa=(e,t)=>e.trim().split(/\s+/).map(r=>Aa(r,t)).join(" "),Aa=(e,t)=>{K("caret",e,t);let r=t.loose?te[ee.CARETLOOSE]:te[ee.CARET],i=t.includePrerelease?"-0":"";return e.replace(r,(a,s,p,h,w)=>{let v;return K("caret",e,a,s,p,h,w),ae(s)?v="":ae(p)?v=`>=${s}.0.0${i} <${+s+1}.0.0-0`:ae(h)?v=s==="0"?`>=${s}.${p}.0${i} <${s}.${+p+1}.0-0`:`>=${s}.${p}.0${i} <${+s+1}.0.0-0`:w?(K("replaceCaret pr",w),v=s==="0"?p==="0"?`>=${s}.${p}.${h}-${w} <${s}.${p}.${+h+1}-0`:`>=${s}.${p}.${h}-${w} <${s}.${+p+1}.0-0`:`>=${s}.${p}.${h}-${w} <${+s+1}.0.0-0`):(K("no pr"),v=s==="0"?p==="0"?`>=${s}.${p}.${h}${i} <${s}.${p}.${+h+1}-0`:`>=${s}.${p}.${h}${i} <${s}.${+p+1}.0-0`:`>=${s}.${p}.${h} <${+s+1}.0.0-0`),K("caret return",v),v})},Oa=(e,t)=>(K("replaceXRanges",e,t),e.split(/\s+/).map(r=>Na(r,t)).join(" ")),Na=(e,t)=>{e=e.trim();let r=t.loose?te[ee.XRANGELOOSE]:te[ee.XRANGE];return e.replace(r,(i,a,s,p,h,w)=>{K("xRange",e,i,a,s,p,h,w);let v=ae(s),y=v||ae(p),O=y||ae(h),E=O;return a==="="&&E&&(a=""),w=t.includePrerelease?"-0":"",v?i=a===">"||a==="<"?"<0.0.0-0":"*":a&&E?(y&&(p=0),h=0,a===">"?(a=">=",y?(s=+s+1,p=0,h=0):(p=+p+1,h=0)):a==="<="&&(a="<",y?s=+s+1:p=+p+1),a==="<"&&(w="-0"),i=`${a+s}.${p}.${h}${w}`):y?i=`>=${s}.0.0${w} <${+s+1}.0.0-0`:O&&(i=`>=${s}.${p}.0${w} <${s}.${+p+1}.0-0`),K("xRange return",i),i})},Ta=(e,t)=>(K("replaceStars",e,t),e.trim().replace(te[ee.STAR],"")),Ma=(e,t)=>(K("replaceGTE0",e,t),e.trim().replace(te[t.includePrerelease?ee.GTE0PRE:ee.GTE0],"")),La=e=>(t,r,i,a,s,p,h,w,v,y,O,E,N)=>`${r=ae(i)?"":ae(a)?`>=${i}.0.0${e?"-0":""}`:ae(s)?`>=${i}.${a}.0${e?"-0":""}`:p?`>=${r}`:`>=${r}${e?"-0":""}`} ${w=ae(v)?"":ae(y)?`<${+v+1}.0.0-0`:ae(O)?`<${v}.${+y+1}.0-0`:E?`<=${v}.${y}.${O}-${E}`:e?`<${v}.${y}.${+O+1}-0`:`<=${w}`}`.trim(),Ca=(e,t,r)=>{for(let i=0;i<e.length;i++)if(!e[i].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let i=0;i<e.length;i++)if(K(e[i].semver),e[i].semver!==Ct.ANY&&e[i].semver.prerelease.length>0){let a=e[i].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0},Pa=(e,t,r)=>{try{t=new Dt(t,r)}catch{return!1}return t.test(e)},{MAX_LENGTH:Da}=xt,{re:Lr,t:Cr}=Ze,$a=(e,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof Ne)return e;if(typeof e!="string"||e.length>Da||!(t.loose?Lr[Cr.LOOSE]:Lr[Cr.FULL]).test(e))return null;try{return new Ne(e,t)}catch{return null}},Ua=$a,{re:ot,t:st}=Ze,xa=(e,t)=>{if(e instanceof Ne)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;let r=null;if((t=t||{}).rtl){let i;for(;(i=ot[st.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),ot[st.COERCERTL].lastIndex=i.index+i[1].length+i[2].length;ot[st.COERCERTL].lastIndex=-1}else r=e.match(ot[st.COERCE]);return r===null?null:Ua(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)};function Fa(e){return String.fromCharCode(parseInt(e.slice(1),16))}function ka(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function Wa(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,Fa))}function Ba(e){return decodeURIComponent(Array.from(atob(e),ka).join(""))}function Ft(e){return Wa(JSON.stringify(e))}function Fr(e){return JSON.parse(Ba(e))}function Ee(e){return typeof e>"u"}function Ga(e){return e===null}function mt(e){return Ga(e)||Ee(e)}function Va(e){return mt(e)?!1:!Ee(e.jsonrpc)&&!Ee(e.id)&&!Ee(e.method)&&!Ee(e.params)}function kr(e){return mt(e)?!1:!Ee(e.jsonrpc)&&!Ee(e.id)&&(!Ee(e.result)||!Ee(e.error))}function ja(e){return mt(e)?!1:typeof e=="string"&&Object.values(M).includes(e)}function Wr(e){return mt(e)?!1:typeof e=="number"&&Object.values(Pe).includes(e)}function Je(e){if(!e)return!0;for(let t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var Y={};function kt(e,t){return Object.assign(Y,t),e}var Ha={"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"},De=class Br extends Error{constructor(t,r){super(`Magic SDK Error: [${t}] ${r}`),this.code=t,this.rawMessage=r,Object.setPrototypeOf(this,Br.prototype)}__proto__=Error},ft=class Gr extends Error{__proto__=Error;code;rawMessage;data;constructor(t){super();let r=Number(t?.code);this.rawMessage=t?.message||"Internal error",this.code=Wr(r)?r:Pe.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=t?.data||void 0,Object.setPrototypeOf(this,Gr.prototype)}},je=class{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}message;log(){console.warn(this.message)}},Vr=class jr extends Error{constructor(t,r,i,a){super(`Magic Extension Error (${t.name}): [${r}] ${i}`),this.code=r,this.rawMessage=i,this.data=a,Object.setPrototypeOf(this,jr.prototype)}__proto__=Error},$t=class{constructor(e,t,r){this.code=t,this.rawMessage=r,this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}message;log(){console.warn(this.message)}};function Hr(){return new De(Re.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function pt(){return new De(Re.ModalNotReady,"Modal is not ready")}function qr(){return new De(Re.MalformedResponse,"Response from the Magic iframe is malformed.")}function Kr(e){return new De(Re.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function Yr(e){let t=`Some extensions are incompatible with \`${Y.sdkName}@${Y.version}\`:`;return e.filter(r=>typeof r.compat<"u"&&r.compat!==null).forEach(r=>{let i=r.compat[Y.sdkName];typeof i=="string"?t+=`
2
2
  - Extension \`${r.name}\` supports version(s) \`${i}\``:i||(t+=`
3
3
  - Extension \`${r.name}\` does not support ${Y.platform} environments.`)}),new De(Re.IncompatibleExtensions,t)}function Xr(e){let t=r=>{let i=r+1,a=i%10,s=i%100;return a===1&&s!==11?`${i}st`:a===2&&s!==12?`${i}nd`:a===3&&s!==13?`${i}rd`:`${i}th`};return new De(Re.InvalidArgument,`Invalid ${t(e.argument)} argument given to \`${e.procedure}\`.
4
4
  Expected: \`${e.expected}\`
5
- Received: \`${e.received}\``)}function Wt(){return new je(be.DuplicateIframe,"Duplicate iframes found.")}function zr(){return new je(be.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 Jr(){return new je(be.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 \`${Y.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Qr(e){let{method:t,removalVersions:r,useInstead:i}=e,a=r[Y.sdkName],s=i?` Use \`${i}\` instead.`:"",p=`\`${t}\` will be removed from \`${Y.sdkName}\` in version \`${a}\`.${s}`;return new je(be.DeprecationNotice,p)}function*qa(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var Ka=qa();function Bt(){return Ka.next().value}var Gt={};zi(Gt,{clear:()=>Ya,getItem:()=>de,iterate:()=>Zr,key:()=>za,keys:()=>Ja,length:()=>Xa,removeItem:()=>Be,setItem:()=>Oe});var ct;function Te(e){return async(...t)=>(ct||(ct=await Y.configureStorage()),await ct.ready(),ct[e](...t))}var de=Te("getItem"),Oe=Te("setItem"),Be=Te("removeItem"),Ya=Te("clear"),Xa=Te("length"),za=Te("key"),Ja=Te("keys"),Zr=Te("iterate");function en(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&191|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var vt="STORE_KEY_PRIVATE_KEY",Qe="STORE_KEY_PUBLIC_JWK",tn="ECDSA",Qa="P-256",Za={name:tn,namedCurve:Qa};function et(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function rn(){Be(Qe),Be(vt)}async function nn(){let e=await eo();if(!e){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=await de(vt);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let i={iat:Math.floor(new Date().getTime()/1e3),jti:en()},a={protected:Pr(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:e})),claims:Pr(JSON.stringify(i))},s=ro(`${a.protected}.${a.claims}`),p={name:tn,hash:{name:"SHA-256"}},h=io(new Uint8Array(await t.sign(p,r,s)));return`${a.protected}.${a.claims}.${h}`}async function eo(){if(!et()){console.info("webcrypto is not supported");return}return await de(Qe)||await to(),de(Qe)}async function to(){let{subtle:e}=window.crypto,t=await e.generateKey(Za,!1,["sign"]),r=await e.exportKey("jwk",t.publicKey);await Oe(vt,t.privateKey),await Oe(Qe,r)}function Pr(e){return an(no(e))}function ro(e){return new TextEncoder().encode(e)}function an(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function no(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function io(e){let t="";return e.forEach(r=>{t+=String.fromCharCode(r)}),an(t)}var on=Symbol("Payload pre-processed by Magic SDK");function sn(e){return Object.defineProperty(e,on,{value:!0,enumerable:!1}),e}function ao(e){return!!e[on]}function ht(e){return ao(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=Bt(),e.method=e.method??"noop",e.params=e.params??[],sn(e)),e}function G(e,t=[]){return sn({params:t,method:e,jsonrpc:"2.0",id:Bt()})}var cn=class ln{_jsonrpc;_id;_result;_error;constructor(t){t instanceof ln?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):kr(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return this._error?.code===Pe.DpopInvalidated&&rn(),typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},oo=Qi(Zi()),un=class extends oo.default{};function Vt(){let e=new un;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...i)=>(e[t].apply(e,i),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var dn=Symbol("isPromiEvent");function fn(e){return!!e[dn]}function me(e){let t=jt(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:i}=Vt(),a=Symbol("Promise.then"),s=Symbol("Promise.catch"),p=Symbol("Promise.finally"),h=(y,O)=>(...E)=>{let N=O[y].apply(O,E);return w(N)},w=y=>Object.assign(y,{[dn]:!0,[a]:y[a]||y.then,[s]:y[s]||y.catch,[p]:y[p]||y.finally,then:h(a,y),catch:h(s,y),finally:h(p,y),on:i("on",y),once:i("once",y),addListener:i("addListener",y),off:i("off",y),removeListener:i("removeListener",y),removeAllListeners:i("removeAllListeners",y),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),v=w(t.then(y=>(v.emit("done",y),v.emit("settled"),y),y=>{throw v.emit("error",y),v.emit("settled"),y}));return v.on(Mt.ClosedByUser,()=>{v.emit(Tt.ClosedByUser)}),v}function jt(e){return new Promise((t,r)=>{let i=e(t,r);Promise.resolve(i).catch(r)})}var Me=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){if(this.sdk.thirdPartyWallets.isConnected&&!Rr.includes(e.method))return me((a,s)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(a).catch(s)});let t=this.overlay.post(Se.MAGIC_HANDLE_REQUEST,ht(e)),r=me((a,s)=>{t.then(p=>{if(i(),p.hasError)s(new ft(p.payload.error));else if(p.hasResult)a(p.payload.result);else throw qr()}).catch(p=>{i(),s(p)})}),i=this.overlay.on(he.MAGIC_HANDLE_EVENT,a=>{let{response:s}=a.data;if(s.id===e.id&&s.result?.event){let{event:p,params:h=[]}=s.result;r.emit(p,...h)}});return r}createIntermediaryEvent(e,t){return r=>{let i=G(M.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(i)}}};function hn(e,t){let[r]=e.split(".").map(Number);return r>=t}var so={"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"},co=class extends Me{loginWithMagicLink(e){let t=Y.sdkName==="@magic-sdk/react-native"||Y.sdkName==="@magic-sdk/react-native-bare"||Y.sdkName==="@magic-sdk/react-native-expo";if(t&&hn(Y.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&Qr({method:"auth.loginWithMagicLink()",removalVersions:so,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:i=!0,redirectURI:a,overrides:s,lifespan:p}=e,h=G(this.sdk.testMode?M.LoginWithMagicLinkTestMode:M.LoginWithMagicLink,[{email:r,showUI:i,redirectURI:a,overrides:s,lifespan:p}]);return this.request(h)}loginWithSMS(e){let{phoneNumber:t,showUI:r=!0,lifespan:i}=e,a=G(this.sdk.testMode?M.LoginWithSmsTestMode:M.LoginWithSms,[{phoneNumber:t,showUI:r,lifespan:i}]),s=this.request(a);return!r&&s&&(s.on(xe.VerifySmsOtp,p=>{this.createIntermediaryEvent(xe.VerifySmsOtp,a.id)(p)}),s.on(xe.Cancel,()=>{this.createIntermediaryEvent(xe.Cancel,a.id)()})),s}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}=e,p=G(this.sdk.testMode?M.LoginWithEmailOTPTestMode:M.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}]),h=this.request(p);return!i&&h&&h.on(it.Retry,()=>{this.createIntermediaryEvent(it.Retry,p.id)()}),!r&&h&&(h.on(ue.VerifyEmailOtp,w=>{this.createIntermediaryEvent(ue.VerifyEmailOtp,p.id)(w)}),h.on(ue.VerifyMFACode,w=>{this.createIntermediaryEvent(ue.VerifyMFACode,p.id)(w)}),h.on(ue.LostDevice,()=>{this.createIntermediaryEvent(ue.LostDevice,p.id)()}),h.on(ue.VerifyRecoveryCode,w=>{this.createIntermediaryEvent(ue.VerifyRecoveryCode,p.id)(w)}),h.on(ue.Cancel,()=>{this.createIntermediaryEvent(ue.Cancel,p.id)()})),h}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:r}=e||{},i=t??"";if(!t&&Y.platform==="web"){i=window.location.search;let s=window.location.origin+window.location.pathname;window.history.replaceState(null,"",s)}let a=G(this.sdk.testMode?M.LoginWithCredentialTestMode:M.LoginWithCredential,[i,r]);return this.request(a)}setAuthorizationToken(e){let t=G(M.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,i=G(this.sdk.testMode?M.UpdateEmailTestMode:M.UpdateEmail,[{email:t,showUI:r}]),a=this.request(i);return r||(a.on(ce.Retry,()=>{this.createIntermediaryEvent(ce.Retry,i.id)()}),a.on(ce.Cancel,()=>{this.createIntermediaryEvent(ce.Cancel,i.id)()}),a.on(ce.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,i.id)(s)}),a.on(ce.VerifyMFACode,s=>{this.createIntermediaryEvent(ce.VerifyMFACode,i.id)(s)}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}},Ht="ds",qt="ek",Kt="iv",Yt="AES-GCM",lo=256;async function mn(){let e=[];await Zr((t,r,i)=>{r.startsWith(`${Ht}_`)&&e.push(r)});for(let t of e)await Be(t)}function pn(e){let t="",r=new Uint8Array(e),i=r.byteLength;for(let a=0;a<i;a++)t+=String.fromCharCode(r[a]);return window.btoa(t)}function vn(e){let t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let a=0;a<r;a++)i[a]=t.charCodeAt(a);return i.buffer}async function uo(){if(!et()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return await de(Kt)||e.getRandomValues(new Uint8Array(12))}async function fo(){if(!et()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return await de(qt)||await e.generateKey({name:Yt,length:lo},!1,["encrypt","decrypt"])}async function ho(e,t){let r=await uo(),i=await fo();if(!r||!i||!e)return;let a=vn(e),{subtle:s}=window.crypto,p=await s.encrypt({name:Yt,iv:r},i,a),h=pn(p);await Oe(`${Ht}_${t}`,h),await Oe(qt,i),await Oe(Kt,r)}async function mo(e){let t=await de(`${Ht}_${e}`),r=await de(Kt),i=await de(qt);if(!r||!t||!i||!et())return;let{subtle:a}=window.crypto,s=await a.decrypt({name:Yt,iv:r},i,vn(t));return pn(s)}function Ge(e,t){return t?new URL(e,t):new URL(e)}var po=class extends Me{getIdToken(e){let t=G(this.sdk.testMode?M.GetIdTokenTestMode:M.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=G(this.sdk.testMode?M.GenerateIdTokenTestMode:M.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=G(M.GetInfo,[]);return this.request(e)}isLoggedIn(){return me(async(e,t)=>{try{let r=!1;this.sdk.useStorageCache&&(r=await de(this.localForageIsLoggedInKey)==="true",r&&e(!0));let i=G(this.sdk.testMode?M.IsLoggedInTestMode:M.IsLoggedIn),a=await this.request(i);this.sdk.useStorageCache&&(a?Oe(this.localForageIsLoggedInKey,!0):Be(this.localForageIsLoggedInKey),r&&!a&&this.emitUserLoggedOut(!0)),e(a)}catch(r){t(r)}})}logout(){return Be(this.localForageIsLoggedInKey),mn(),me(async(e,t)=>{try{let r=G(this.sdk.testMode?M.LogoutTestMode:M.Logout),i=await this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(i),e(i)}catch(r){t(r)}})}requestInfoWithUI(e){let t=G(M.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},r=G(this.sdk.testMode?M.UserSettingsTestMode:M.UserSettings,[e]),i=this.request(r);return!t&&i&&(i.on(pe.SendNewPhoneNumber,a=>{this.createIntermediaryEvent(pe.SendNewPhoneNumber,r.id)(a)}),i.on(pe.SendOtpCode,a=>{this.createIntermediaryEvent(pe.SendOtpCode,r.id)(a)}),i.on(pe.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(pe.StartEditPhoneNumber,r.id)()}),i.on(pe.Cancel,()=>{this.createIntermediaryEvent(pe.Cancel,r.id)()}),i.on(ce.VerifyEmailOtp,a=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,r.id)(a)})),i}recoverAccount(e){let{email:t,showUI:r}=e,i=G(this.sdk.testMode?M.RecoverAccountTestMode:M.RecoverAccount,[{email:t,showUI:r}]),a=this.request(i);return!r&&a&&(a.on(ve.Cancel,()=>{this.createIntermediaryEvent(ve.Cancel,i.id)()}),a.on(ve.ResendSms,()=>{this.createIntermediaryEvent(ve.ResendSms,i.id)()}),a.on(ve.VerifyOtp,s=>{this.createIntermediaryEvent(ve.VerifyOtp,i.id)(s)}),a.on(ve.UpdateEmail,s=>{this.createIntermediaryEvent(ve.UpdateEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}revealEVMPrivateKey(){let e=G(M.RevealPK,[{chain:"ETH"}]);return this.request(e)}revealPrivateKey(){throw new Error("revealPrivateKey() has been decommissioned. For EVM chains, use `user.revealEVMPrivateKey()` instead. For non-EVM chains, use `[extension].revealPrivateKey()` instead.")}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:t=!0}=e,r=G(M.EnableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Fe.VerifyMFACode,a=>{this.createIntermediaryEvent(Fe.VerifyMFACode,r.id)(a)}),i.on(Fe.Cancel,()=>{this.createIntermediaryEvent(Fe.Cancel,r.id)()})),i}disableMFA(e){let{showUI:t=!0}=e,r=G(M.DisableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Ae.VerifyMFACode,a=>{this.createIntermediaryEvent(Ae.VerifyMFACode,r.id)(a)}),i.on(Ae.LostDevice,a=>{this.createIntermediaryEvent(Ae.LostDevice,r.id)(a)}),i.on(Ae.Cancel,()=>{this.createIntermediaryEvent(Ae.Cancel,r.id)()})),i}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]},vo=class extends Me{connectWithUI(e){let t=me(async(r,i)=>{try{let a=G(M.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),s=this.request(a);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:h,callback:w})=>{s.on(h,()=>w(a.id))}),s.on("id-token-created",h=>{t.emit("id-token-created",h)});let p=await s;p.error&&i(p),r(p)}catch(a){i(a)}});return t}showUI(e){return this.request(G(M.ShowUI,[e]))}showAddress(){return this.request(G(M.ShowAddress))}showSendTokensUI(){return this.request(G(M.ShowSendTokensUI))}showOnRamp(){return this.request(G(M.ShowOnRamp))}showNFTs(){return this.request(G(M.ShowNFTs))}showBalances(){return this.request(G(M.ShowBalances))}sendGaslessTransaction(e,t){return this.request(G(M.SendGaslessTransaction,[e,t]))}},yo=class extends Me{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(ge.PROVIDER),localStorage.removeItem(ge.ADDRESS),localStorage.removeItem(ge.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===M.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===M.GetInfo)return this.getInfo(e);if(e.method===M.IsLoggedIn)return this.isLoggedIn(e);if(e.method===M.Logout)return this.logout(e);switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalGetInfo();default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(ge.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"web3modal":return this.web3modalLogout();default:return super.request(e)}}web3modalRequest(e){return me((t,r)=>{this.sdk.web3modal.modal.getWalletProvider().request(e).then(t).catch(r)})}web3modalIsLoggedIn(){return me(e=>{let t=this.sdk.web3modal.modal.getStatus();if(t==="connected"&&e(!0),t==="disconnected"&&(this.resetThirdPartyWalletState(),e(!1)),t==="reconnecting"){let r=this.sdk.web3modal.modal.subscribeProvider(({status:i})=>{i==="connected"&&(r(),e(!0)),i==="disconnected"&&(r(),this.resetThirdPartyWalletState(),e(!1))})}})}formatWeb3modalGetInfoResponse(){let e=this.sdk.web3modal.modal.getWalletInfo()?.name,t=this.sdk.web3modal.modal.getAddress();return{publicAddress:t,email:null,issuer:`did:ethr:${t}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],walletType:e||"web3modal",firstLoginAt:null}}web3modalGetInfo(){return me((e,t)=>{let r=this.sdk.web3modal.modal.getStatus();if(r==="connected"&&e(this.formatWeb3modalGetInfoResponse()),r==="disconnected"&&(this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access.")),r==="reconnecting"){let i=this.sdk.web3modal.modal.subscribeProvider(({status:a})=>{a==="connected"&&(i(),e(this.formatWeb3modalGetInfoResponse())),a==="disconnected"&&(i(),this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return me(async e=>{try{await this.sdk.web3modal.modal.disconnect()}catch(t){console.error(t)}e(!0)})}},{createBoundEmitterMethod:lt,createChainingEmitterMethod:We}=Vt(),go=class extends Me{isMagic=!0;sendAsync(e,t){if(!t)throw Xr({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e))this.overlay.post(Se.MAGIC_HANDLE_REQUEST,e.map(r=>{let i=ht(r);return this.prefixPayloadMethodForTestMode(i),i})).then(r=>{t(null,r.map(i=>({...i.payload,error:i.hasError?new ft(i.payload.error):null})))});else{let r=ht(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(Se.MAGIC_HANDLE_REQUEST,r).then(i=>{t(i.hasError?new ft(i.payload.error):null,i.payload)})}}send(e,t){if(typeof e=="string"){let i=G(e,Array.isArray(t)?t:[]);return this.request(i)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let r=zr();return r.log(),new cn(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=G(M.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}on=We("on",this);once=We("once",this);addListener=We("addListener",this);off=We("off",this);removeListener=We("removeListener",this);removeAllListeners=We("removeAllListeners",this);emit=lt("emit");eventNames=lt("eventNames");listeners=lt("listeners");listenerCount=lt("listenerCount")},Eo=class extends Me{purchase(e){let t=G(M.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,r=G(M.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),i=this.request(r);return t&&(i.on(ke.Initiated,async a=>{try{let s=await this.request({method:"eth_sendTransaction",params:[a]});this.createIntermediaryEvent(ke.Success,r.id)(s)}catch{this.createIntermediaryEvent(ke.Failure,r.id)()}}),i.on(ke.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),i.emit("disconnect")})),i}transfer(e){let t=G(M.NFTTransfer,[e]);return this.request(t)}};function Dr(e){return e.compat&&e.compat[Y.sdkName]!=null?typeof e.compat[Y.sdkName]=="string"?Pa(xa(Y.version),e.compat[Y.sdkName]):!!e.compat[Y.sdkName]:!0}function _o(e,t,r){return!t&&!r?`${e}_eth_mainnet`:r?`${e}_${JSON.stringify(r)}`:t?typeof t=="string"?`${e}_eth_${t}`:`${e}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${e}_unknown`}function Io(e){let t=e?.extensions??[],r={},i=[];if(Array.isArray(t)?t.forEach(a=>{Dr(a)?(a.init(this),a.name&&(this[a.name]=a),Je(a.config)||(r[a.name]=a.config)):i.push(a)}):Object.keys(t).forEach(a=>{if(Dr(t[a])){t[a].init(this);let s=t[a];this[a]=s,Je(s.config)||(r[t[a].name]=s.config)}else i.push(t[a])}),i.length)throw Yr(i);return r}var Xt=class dt{constructor(t,r){if(this.apiKey=t,!t)throw Hr();Y.platform==="react-native"&&r?.endpoint&&Jr().log();let{defaultEndpoint:i,version:a}=Y;this.testMode=!!r?.testMode,this.useStorageCache=!!r?.useStorageCache,this.endpoint=Ge(r?.endpoint??i).origin,this.auth=new co(this),this.user=new po(this),this.wallet=new vo(this),this.nft=new Eo(this),this.thirdPartyWallets=new yo(this),this.rpcProvider=new go(this);let s=Io.call(this,r);this.parameters=Ft({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:r?.network,host:Ge(this.endpoint).host,sdk:Ha[Y.sdkName],version:a,ext:Je(s)?void 0:s,locale:r?.locale||"en_US",authConfig:r?.authConfig?{...r.authConfig}:void 0,...Y.bundleId?{bundleId:Y.bundleId}:{},meta:r?.meta}),this.networkHash=_o(this.apiKey,r?.network,Je(s)?void 0:s),r?.deferPreload||this.preload()}static __overlays__=new Map;endpoint;parameters;networkHash;testMode;useStorageCache;auth;user;wallet;nft;thirdPartyWallets;rpcProvider;get overlay(){if(!dt.__overlays__.has(this.parameters)){let t=new Y.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),dt.__overlays__.set(this.parameters,t)}return dt.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};function wo(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function Ro(e,t){let r=t.data.response?.id,i=wo(e,r);if(r&&i){let a=new cn(i).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:r,response:a}}return{}}async function bo(e,t,r){let i=await de("rt"),a;if(Y.platform==="web")try{a=await de("jwt")??await nn()}catch(h){console.error("webcrypto error",h)}let s={msgType:e,payload:t};a&&(s.jwt=a),a&&i&&(s.rt=i);let p=await mo(r);return p&&(s.deviceShare=p),s}async function So(e){e.data.rt&&await Oe("rt",e.data.rt)}function Ao(e,t){let r=null;return function(...i){r&&clearTimeout(r),r=setTimeout(()=>{e(...i)},t)}}var Oo=1e3,yn=60*Oo,$r=5*yn,No=60*yn,zt=class{constructor(e,t,r){this.endpoint=e,this.parameters=t,this.networkHash=r,this.listen()}isReadyForRequest=!1;messageHandlers=new Set;isConnectedToInternet=!0;lastPongTime=null;heartbeatIntervalTimer=null;heartbeatDebounce=Ao(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},No);async post(e,t){return jt(async(r,i)=>{if(!this.isConnectedToInternet){let v=pt();i(v)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let a=[],s=Array.isArray(t)?t.map(v=>v.id):[],p=await bo(`${e}-${this.parameters}`,t,this.networkHash);await this._post(p);let h=v=>y=>{let{id:O,response:E}=Ro(t,y);if(So(y),E?.payload.error?.message==="User denied account access.")mn();else if(y.data.deviceShare){let{deviceShare:N}=y.data;ho(N,this.networkHash)}O&&E&&Array.isArray(t)&&s.includes(O)?(a.push(E),a.length===t.length&&(v(),r(a))):O&&E&&!Array.isArray(t)&&O===t.id&&(v(),r(E))},w=this.on(he.MAGIC_HANDLE_RESPONSE,h(()=>w()))})}on(e,t){let r=t.bind(window),i=a=>{a.data.msgType===`${e}-${this.parameters}`&&r(a)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(he.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(he.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(he.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(he.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new je(be.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let r={msgType:`${Se.MAGIC_PING}-${this.parameters}`,payload:[]};await this._post(r)};this.heartbeatIntervalTimer=setInterval(async()=>{if(this.lastPongTime){if(Date.now()-this.lastPongTime>$r*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}await t(),e=!1},$r)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}},Ur=["request","overlay","sdk"];function To(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==Me.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var Mo=class extends Me{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:me,isPromiEvent:fn,encodeJSON:Ft,decodeJSON:Fr,createJsonRpcRequestPayload:G,standardizeJsonRpcRequestPayload:ht,storage:Gt};constructor(){super(void 0);let e=[this,...To(this)];Ur.forEach(t=>{let r=e.map(p=>Object.getOwnPropertyDescriptor(p,t)),i=r.findIndex(p=>!!p),a=i>0,s=r[i];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:a}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Kr(t)}}))})}init(e){this.__is_initialized__||(Ur.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:i}=this.__sdk_access_field_descriptors__.get(t);i?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:i}=e,a=i?` Use \`${i}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${a}`;return new $t(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new $t(this,e,t)}createError(e,t,r){return new Vr(this,e,t,r)}},gn=class extends Mo{},Lo=class{static Internal=gn},Co=class extends gn{constructor(e){super(),this.config=e,this.chain=e.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(M.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(M.RevealPK,[{chain:this.chain}]))}};var Et=wr(_n()),Zt=wr(wn());var Po={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function Do(e){for(let[t,r]of Object.entries(Po))e.style[t]=r}function $o(e){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(r=>r.src.includes(e))}var gt=class extends zt{activeElement=null;iframe;relayerSrc=Ge(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(t=>{let r=()=>{if($o(encodeURIComponent(this.parameters)))Wt().log();else{let i=document.createElement("iframe");i.classList.add("magic-iframe"),i.dataset.magicIframeLabel=Ge(this.endpoint).host,i.title="Secure Modal",i.src=this.relayerSrc,i.allow="clipboard-read; clipboard-write",Do(i),document.body.appendChild(i),t(i)}};["loaded","interactive","complete"].includes(document.readyState)?r():window.addEventListener("load",r,!1)}),this.iframe.then(t=>{t instanceof HTMLIFrameElement&&t.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",t=>{if(t.origin===this.endpoint&&t.data.msgType&&(t.data.msgType.includes(he.MAGIC_PONG)&&(this.lastPongTime=Date.now()),t.data&&this.messageHandlers.size)){t.data.response=t.data.response??{},this.stopHeartBeat();for(let r of this.messageHandlers.values())r(t)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let t=await this.iframe;t.style.display="block",t.style.zIndex="2147483647",t.style.opacity="1",this.activeElement=document.activeElement,t.focus()}async hideOverlay(){let t=await this.iframe;t.style.display="none",t.style.zIndex="-1",t.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(t){let r=await this.iframe;if(r&&r.contentWindow)r.contentWindow.postMessage(t,this.endpoint);else throw pt()}async checkRelayerExistsInDOM(){let t=await this.iframe;return!t||!t.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(i=>i.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let t=await this.iframe;if(this.stopHeartBeat(),!t){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!t.contentWindow){document.body.appendChild(t),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}t&&(t.src=this.relayerSrc)}};var Uo=Object.assign(kt(Xt,{platform:"web",sdkName:"magic-sdk",version:"31.2.0",defaultEndpoint:"https://auth.magic.link/",ViewController:gt,configureStorage:async()=>{let e=Et.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await e.defineDriver(Zt),await e.setDriver([Et.default.INDEXEDDB,Et.default.LOCALSTORAGE,Zt._driver]),e}}),{...Jt}),xo=Uo;return wi(Fo);})();
5
+ Received: \`${e.received}\``)}function Wt(){return new je(be.DuplicateIframe,"Duplicate iframes found.")}function zr(){return new je(be.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 Jr(){return new je(be.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 \`${Y.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Qr(e){let{method:t,removalVersions:r,useInstead:i}=e,a=r[Y.sdkName],s=i?` Use \`${i}\` instead.`:"",p=`\`${t}\` will be removed from \`${Y.sdkName}\` in version \`${a}\`.${s}`;return new je(be.DeprecationNotice,p)}function*qa(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var Ka=qa();function Ya(){return Math.floor(Math.random()*1e5)+1}function Bt(){return Y.sdkName==="@magic-sdk/react-native-bare"||Y.sdkName==="@magic-sdk/react-native-expo"?Ya():Ka.next().value}var Gt={};zi(Gt,{clear:()=>Xa,getItem:()=>de,iterate:()=>Zr,key:()=>Ja,keys:()=>Qa,length:()=>za,removeItem:()=>Be,setItem:()=>Oe});var ct;function Te(e){return async(...t)=>(ct||(ct=await Y.configureStorage()),await ct.ready(),ct[e](...t))}var de=Te("getItem"),Oe=Te("setItem"),Be=Te("removeItem"),Xa=Te("clear"),za=Te("length"),Ja=Te("key"),Qa=Te("keys"),Zr=Te("iterate");function en(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&191|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var vt="STORE_KEY_PRIVATE_KEY",Qe="STORE_KEY_PUBLIC_JWK",tn="ECDSA",Za="P-256",eo={name:tn,namedCurve:Za};function et(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function rn(){Be(Qe),Be(vt)}async function nn(){let e=await to();if(!e){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=await de(vt);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let i={iat:Math.floor(new Date().getTime()/1e3),jti:en()},a={protected:Pr(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:e})),claims:Pr(JSON.stringify(i))},s=no(`${a.protected}.${a.claims}`),p={name:tn,hash:{name:"SHA-256"}},h=ao(new Uint8Array(await t.sign(p,r,s)));return`${a.protected}.${a.claims}.${h}`}async function to(){if(!et()){console.info("webcrypto is not supported");return}return await de(Qe)||await ro(),de(Qe)}async function ro(){let{subtle:e}=window.crypto,t=await e.generateKey(eo,!1,["sign"]),r=await e.exportKey("jwk",t.publicKey);await Oe(vt,t.privateKey),await Oe(Qe,r)}function Pr(e){return an(io(e))}function no(e){return new TextEncoder().encode(e)}function an(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function io(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function ao(e){let t="";return e.forEach(r=>{t+=String.fromCharCode(r)}),an(t)}var on=Symbol("Payload pre-processed by Magic SDK");function sn(e){return Object.defineProperty(e,on,{value:!0,enumerable:!1}),e}function oo(e){return!!e[on]}function ht(e){return oo(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=Bt(),e.method=e.method??"noop",e.params=e.params??[],sn(e)),e}function G(e,t=[]){return sn({params:t,method:e,jsonrpc:"2.0",id:Bt()})}var cn=class ln{_jsonrpc;_id;_result;_error;constructor(t){t instanceof ln?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):kr(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return this._error?.code===Pe.DpopInvalidated&&rn(),typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},so=Qi(Zi()),un=class extends so.default{};function Vt(){let e=new un;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...i)=>(e[t].apply(e,i),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var dn=Symbol("isPromiEvent");function fn(e){return!!e[dn]}function me(e){let t=jt(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:i}=Vt(),a=Symbol("Promise.then"),s=Symbol("Promise.catch"),p=Symbol("Promise.finally"),h=(y,O)=>(...E)=>{let N=O[y].apply(O,E);return w(N)},w=y=>Object.assign(y,{[dn]:!0,[a]:y[a]||y.then,[s]:y[s]||y.catch,[p]:y[p]||y.finally,then:h(a,y),catch:h(s,y),finally:h(p,y),on:i("on",y),once:i("once",y),addListener:i("addListener",y),off:i("off",y),removeListener:i("removeListener",y),removeAllListeners:i("removeAllListeners",y),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),v=w(t.then(y=>(v.emit("done",y),v.emit("settled"),y),y=>{throw v.emit("error",y),v.emit("settled"),y}));return v.on(Mt.ClosedByUser,()=>{v.emit(Tt.ClosedByUser)}),v}function jt(e){return new Promise((t,r)=>{let i=e(t,r);Promise.resolve(i).catch(r)})}var Me=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){if(this.sdk.thirdPartyWallets.isConnected&&!Rr.includes(e.method))return me((a,s)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(a).catch(s)});let t=this.overlay.post(Se.MAGIC_HANDLE_REQUEST,ht(e)),r=me((a,s)=>{t.then(p=>{if(i(),p.hasError)s(new ft(p.payload.error));else if(p.hasResult)a(p.payload.result);else throw qr()}).catch(p=>{i(),s(p)})}),i=this.overlay.on(he.MAGIC_HANDLE_EVENT,a=>{let{response:s}=a.data;if(s.id===e.id&&s.result?.event){let{event:p,params:h=[]}=s.result;r.emit(p,...h)}});return r}createIntermediaryEvent(e,t){return r=>{let i=G(M.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(i)}}};function hn(e,t){let[r]=e.split(".").map(Number);return r>=t}var co={"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"},lo=class extends Me{loginWithMagicLink(e){let t=Y.sdkName==="@magic-sdk/react-native"||Y.sdkName==="@magic-sdk/react-native-bare"||Y.sdkName==="@magic-sdk/react-native-expo";if(t&&hn(Y.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&Qr({method:"auth.loginWithMagicLink()",removalVersions:co,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:i=!0,redirectURI:a,overrides:s,lifespan:p}=e,h=G(this.sdk.testMode?M.LoginWithMagicLinkTestMode:M.LoginWithMagicLink,[{email:r,showUI:i,redirectURI:a,overrides:s,lifespan:p}]);return this.request(h)}loginWithSMS(e){let{phoneNumber:t,showUI:r=!0,lifespan:i}=e,a=G(this.sdk.testMode?M.LoginWithSmsTestMode:M.LoginWithSms,[{phoneNumber:t,showUI:r,lifespan:i}]),s=this.request(a);return!r&&s&&(s.on(xe.VerifySmsOtp,p=>{this.createIntermediaryEvent(xe.VerifySmsOtp,a.id)(p)}),s.on(xe.Cancel,()=>{this.createIntermediaryEvent(xe.Cancel,a.id)()})),s}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}=e,p=G(this.sdk.testMode?M.LoginWithEmailOTPTestMode:M.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}]),h=this.request(p);return!i&&h&&h.on(it.Retry,()=>{this.createIntermediaryEvent(it.Retry,p.id)()}),!r&&h&&(h.on(ue.VerifyEmailOtp,w=>{this.createIntermediaryEvent(ue.VerifyEmailOtp,p.id)(w)}),h.on(ue.VerifyMFACode,w=>{this.createIntermediaryEvent(ue.VerifyMFACode,p.id)(w)}),h.on(ue.LostDevice,()=>{this.createIntermediaryEvent(ue.LostDevice,p.id)()}),h.on(ue.VerifyRecoveryCode,w=>{this.createIntermediaryEvent(ue.VerifyRecoveryCode,p.id)(w)}),h.on(ue.Cancel,()=>{this.createIntermediaryEvent(ue.Cancel,p.id)()})),h}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:r}=e||{},i=t??"";if(!t&&Y.platform==="web"){i=window.location.search;let s=window.location.origin+window.location.pathname;window.history.replaceState(null,"",s)}let a=G(this.sdk.testMode?M.LoginWithCredentialTestMode:M.LoginWithCredential,[i,r]);return this.request(a)}setAuthorizationToken(e){let t=G(M.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,i=G(this.sdk.testMode?M.UpdateEmailTestMode:M.UpdateEmail,[{email:t,showUI:r}]),a=this.request(i);return r||(a.on(ce.Retry,()=>{this.createIntermediaryEvent(ce.Retry,i.id)()}),a.on(ce.Cancel,()=>{this.createIntermediaryEvent(ce.Cancel,i.id)()}),a.on(ce.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,i.id)(s)}),a.on(ce.VerifyMFACode,s=>{this.createIntermediaryEvent(ce.VerifyMFACode,i.id)(s)}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}},Ht="ds",qt="ek",Kt="iv",Yt="AES-GCM",uo=256;async function mn(){let e=[];await Zr((t,r,i)=>{r.startsWith(`${Ht}_`)&&e.push(r)});for(let t of e)await Be(t)}function pn(e){let t="",r=new Uint8Array(e),i=r.byteLength;for(let a=0;a<i;a++)t+=String.fromCharCode(r[a]);return window.btoa(t)}function vn(e){let t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let a=0;a<r;a++)i[a]=t.charCodeAt(a);return i.buffer}async function fo(){if(!et()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return await de(Kt)||e.getRandomValues(new Uint8Array(12))}async function ho(){if(!et()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return await de(qt)||await e.generateKey({name:Yt,length:uo},!1,["encrypt","decrypt"])}async function mo(e,t){let r=await fo(),i=await ho();if(!r||!i||!e)return;let a=vn(e),{subtle:s}=window.crypto,p=await s.encrypt({name:Yt,iv:r},i,a),h=pn(p);await Oe(`${Ht}_${t}`,h),await Oe(qt,i),await Oe(Kt,r)}async function po(e){let t=await de(`${Ht}_${e}`),r=await de(Kt),i=await de(qt);if(!r||!t||!i||!et())return;let{subtle:a}=window.crypto,s=await a.decrypt({name:Yt,iv:r},i,vn(t));return pn(s)}function Ge(e,t){return t?new URL(e,t):new URL(e)}var vo=class extends Me{getIdToken(e){let t=G(this.sdk.testMode?M.GetIdTokenTestMode:M.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=G(this.sdk.testMode?M.GenerateIdTokenTestMode:M.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=G(M.GetInfo,[]);return this.request(e)}isLoggedIn(){return me(async(e,t)=>{try{let r=!1;this.sdk.useStorageCache&&(r=await de(this.localForageIsLoggedInKey)==="true",r&&e(!0));let i=G(this.sdk.testMode?M.IsLoggedInTestMode:M.IsLoggedIn),a=await this.request(i);this.sdk.useStorageCache&&(a?Oe(this.localForageIsLoggedInKey,!0):Be(this.localForageIsLoggedInKey),r&&!a&&this.emitUserLoggedOut(!0)),e(a)}catch(r){t(r)}})}logout(){return Be(this.localForageIsLoggedInKey),mn(),me(async(e,t)=>{try{let r=G(this.sdk.testMode?M.LogoutTestMode:M.Logout),i=await this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(i),e(i)}catch(r){t(r)}})}requestInfoWithUI(e){let t=G(M.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},r=G(this.sdk.testMode?M.UserSettingsTestMode:M.UserSettings,[e]),i=this.request(r);return!t&&i&&(i.on(pe.SendNewPhoneNumber,a=>{this.createIntermediaryEvent(pe.SendNewPhoneNumber,r.id)(a)}),i.on(pe.SendOtpCode,a=>{this.createIntermediaryEvent(pe.SendOtpCode,r.id)(a)}),i.on(pe.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(pe.StartEditPhoneNumber,r.id)()}),i.on(pe.Cancel,()=>{this.createIntermediaryEvent(pe.Cancel,r.id)()}),i.on(ce.VerifyEmailOtp,a=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,r.id)(a)})),i}recoverAccount(e){let{email:t,showUI:r}=e,i=G(this.sdk.testMode?M.RecoverAccountTestMode:M.RecoverAccount,[{email:t,showUI:r}]),a=this.request(i);return!r&&a&&(a.on(ve.Cancel,()=>{this.createIntermediaryEvent(ve.Cancel,i.id)()}),a.on(ve.ResendSms,()=>{this.createIntermediaryEvent(ve.ResendSms,i.id)()}),a.on(ve.VerifyOtp,s=>{this.createIntermediaryEvent(ve.VerifyOtp,i.id)(s)}),a.on(ve.UpdateEmail,s=>{this.createIntermediaryEvent(ve.UpdateEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}revealEVMPrivateKey(){let e=G(M.RevealPK,[{chain:"ETH"}]);return this.request(e)}revealPrivateKey(){throw new Error("revealPrivateKey() has been decommissioned. For EVM chains, use `user.revealEVMPrivateKey()` instead. For non-EVM chains, use `[extension].revealPrivateKey()` instead.")}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:t=!0}=e,r=G(M.EnableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Fe.VerifyMFACode,a=>{this.createIntermediaryEvent(Fe.VerifyMFACode,r.id)(a)}),i.on(Fe.Cancel,()=>{this.createIntermediaryEvent(Fe.Cancel,r.id)()})),i}disableMFA(e){let{showUI:t=!0}=e,r=G(M.DisableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Ae.VerifyMFACode,a=>{this.createIntermediaryEvent(Ae.VerifyMFACode,r.id)(a)}),i.on(Ae.LostDevice,a=>{this.createIntermediaryEvent(Ae.LostDevice,r.id)(a)}),i.on(Ae.Cancel,()=>{this.createIntermediaryEvent(Ae.Cancel,r.id)()})),i}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]},yo=class extends Me{connectWithUI(e){let t=me(async(r,i)=>{try{let a=G(M.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),s=this.request(a);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:h,callback:w})=>{s.on(h,()=>w(a.id))}),s.on("id-token-created",h=>{t.emit("id-token-created",h)});let p=await s;p.error&&i(p),r(p)}catch(a){i(a)}});return t}showUI(e){return this.request(G(M.ShowUI,[e]))}showAddress(){return this.request(G(M.ShowAddress))}showSendTokensUI(){return this.request(G(M.ShowSendTokensUI))}showOnRamp(){return this.request(G(M.ShowOnRamp))}showNFTs(){return this.request(G(M.ShowNFTs))}showBalances(){return this.request(G(M.ShowBalances))}sendGaslessTransaction(e,t){return this.request(G(M.SendGaslessTransaction,[e,t]))}},go=class extends Me{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(ge.PROVIDER),localStorage.removeItem(ge.ADDRESS),localStorage.removeItem(ge.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===M.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===M.GetInfo)return this.getInfo(e);if(e.method===M.IsLoggedIn)return this.isLoggedIn(e);if(e.method===M.Logout)return this.logout(e);switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalGetInfo();default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(ge.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"web3modal":return this.web3modalLogout();default:return super.request(e)}}web3modalRequest(e){return me((t,r)=>{this.sdk.web3modal.modal.getWalletProvider().request(e).then(t).catch(r)})}web3modalIsLoggedIn(){return me(e=>{let t=this.sdk.web3modal.modal.getStatus();if(t==="connected"&&e(!0),t==="disconnected"&&(this.resetThirdPartyWalletState(),e(!1)),t==="reconnecting"){let r=this.sdk.web3modal.modal.subscribeProvider(({status:i})=>{i==="connected"&&(r(),e(!0)),i==="disconnected"&&(r(),this.resetThirdPartyWalletState(),e(!1))})}})}formatWeb3modalGetInfoResponse(){let e=this.sdk.web3modal.modal.getWalletInfo()?.name,t=this.sdk.web3modal.modal.getAddress();return{publicAddress:t,email:null,issuer:`did:ethr:${t}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],walletType:e||"web3modal",firstLoginAt:null}}web3modalGetInfo(){return me((e,t)=>{let r=this.sdk.web3modal.modal.getStatus();if(r==="connected"&&e(this.formatWeb3modalGetInfoResponse()),r==="disconnected"&&(this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access.")),r==="reconnecting"){let i=this.sdk.web3modal.modal.subscribeProvider(({status:a})=>{a==="connected"&&(i(),e(this.formatWeb3modalGetInfoResponse())),a==="disconnected"&&(i(),this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return me(async e=>{try{await this.sdk.web3modal.modal.disconnect()}catch(t){console.error(t)}e(!0)})}},{createBoundEmitterMethod:lt,createChainingEmitterMethod:We}=Vt(),Eo=class extends Me{isMagic=!0;sendAsync(e,t){if(!t)throw Xr({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e))this.overlay.post(Se.MAGIC_HANDLE_REQUEST,e.map(r=>{let i=ht(r);return this.prefixPayloadMethodForTestMode(i),i})).then(r=>{t(null,r.map(i=>({...i.payload,error:i.hasError?new ft(i.payload.error):null})))});else{let r=ht(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(Se.MAGIC_HANDLE_REQUEST,r).then(i=>{t(i.hasError?new ft(i.payload.error):null,i.payload)})}}send(e,t){if(typeof e=="string"){let i=G(e,Array.isArray(t)?t:[]);return this.request(i)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let r=zr();return r.log(),new cn(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=G(M.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}on=We("on",this);once=We("once",this);addListener=We("addListener",this);off=We("off",this);removeListener=We("removeListener",this);removeAllListeners=We("removeAllListeners",this);emit=lt("emit");eventNames=lt("eventNames");listeners=lt("listeners");listenerCount=lt("listenerCount")},_o=class extends Me{purchase(e){let t=G(M.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,r=G(M.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),i=this.request(r);return t&&(i.on(ke.Initiated,async a=>{try{let s=await this.request({method:"eth_sendTransaction",params:[a]});this.createIntermediaryEvent(ke.Success,r.id)(s)}catch{this.createIntermediaryEvent(ke.Failure,r.id)()}}),i.on(ke.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),i.emit("disconnect")})),i}transfer(e){let t=G(M.NFTTransfer,[e]);return this.request(t)}};function Dr(e){return e.compat&&e.compat[Y.sdkName]!=null?typeof e.compat[Y.sdkName]=="string"?Pa(xa(Y.version),e.compat[Y.sdkName]):!!e.compat[Y.sdkName]:!0}function Io(e,t,r){return!t&&!r?`${e}_eth_mainnet`:r?`${e}_${JSON.stringify(r)}`:t?typeof t=="string"?`${e}_eth_${t}`:`${e}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${e}_unknown`}function wo(e){let t=e?.extensions??[],r={},i=[];if(Array.isArray(t)?t.forEach(a=>{Dr(a)?(a.init(this),a.name&&(this[a.name]=a),Je(a.config)||(r[a.name]=a.config)):i.push(a)}):Object.keys(t).forEach(a=>{if(Dr(t[a])){t[a].init(this);let s=t[a];this[a]=s,Je(s.config)||(r[t[a].name]=s.config)}else i.push(t[a])}),i.length)throw Yr(i);return r}var Xt=class dt{constructor(t,r){if(this.apiKey=t,!t)throw Hr();Y.platform==="react-native"&&r?.endpoint&&Jr().log();let{defaultEndpoint:i,version:a}=Y;this.testMode=!!r?.testMode,this.useStorageCache=!!r?.useStorageCache,this.endpoint=Ge(r?.endpoint??i).origin,this.auth=new lo(this),this.user=new vo(this),this.wallet=new yo(this),this.nft=new _o(this),this.thirdPartyWallets=new go(this),this.rpcProvider=new Eo(this);let s=wo.call(this,r);this.parameters=Ft({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:r?.network,host:Ge(this.endpoint).host,sdk:Ha[Y.sdkName],version:a,ext:Je(s)?void 0:s,locale:r?.locale||"en_US",authConfig:r?.authConfig?{...r.authConfig}:void 0,...Y.bundleId?{bundleId:Y.bundleId}:{},meta:r?.meta}),this.networkHash=Io(this.apiKey,r?.network,Je(s)?void 0:s),r?.deferPreload||this.preload()}static __overlays__=new Map;endpoint;parameters;networkHash;testMode;useStorageCache;auth;user;wallet;nft;thirdPartyWallets;rpcProvider;get overlay(){if(!dt.__overlays__.has(this.parameters)){let t=new Y.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),dt.__overlays__.set(this.parameters,t)}return dt.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};function Ro(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function bo(e,t){let r=t.data.response?.id,i=Ro(e,r);if(r&&i){let a=new cn(i).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:r,response:a}}return{}}async function So(e,t,r){let i=await de("rt"),a;if(Y.platform==="web")try{a=await de("jwt")??await nn()}catch(h){console.error("webcrypto error",h)}let s={msgType:e,payload:t};a&&(s.jwt=a),a&&i&&(s.rt=i);let p=await po(r);return p&&(s.deviceShare=p),s}async function Ao(e){e.data.rt&&await Oe("rt",e.data.rt)}function Oo(e,t){let r=null;return function(...i){r&&clearTimeout(r),r=setTimeout(()=>{e(...i)},t)}}var No=1e3,yn=60*No,$r=5*yn,To=60*yn,zt=class{constructor(e,t,r){this.endpoint=e,this.parameters=t,this.networkHash=r,this.listen()}isReadyForRequest=!1;messageHandlers=new Set;isConnectedToInternet=!0;lastPongTime=null;heartbeatIntervalTimer=null;heartbeatDebounce=Oo(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},To);async post(e,t){return jt(async(r,i)=>{if(!this.isConnectedToInternet){let v=pt();i(v)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let a=[],s=Array.isArray(t)?t.map(v=>v.id):[],p=await So(`${e}-${this.parameters}`,t,this.networkHash);await this._post(p);let h=v=>y=>{let{id:O,response:E}=bo(t,y);if(Ao(y),E?.payload.error?.message==="User denied account access.")mn();else if(y.data.deviceShare){let{deviceShare:N}=y.data;mo(N,this.networkHash)}O&&E&&Array.isArray(t)&&s.includes(O)?(a.push(E),a.length===t.length&&(v(),r(a))):O&&E&&!Array.isArray(t)&&O===t.id&&(v(),r(E))},w=this.on(he.MAGIC_HANDLE_RESPONSE,h(()=>w()))})}on(e,t){let r=t.bind(window),i=a=>{a.data.msgType===`${e}-${this.parameters}`&&r(a)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(he.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(he.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(he.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(he.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new je(be.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let r={msgType:`${Se.MAGIC_PING}-${this.parameters}`,payload:[]};await this._post(r)};this.heartbeatIntervalTimer=setInterval(async()=>{if(this.lastPongTime){if(Date.now()-this.lastPongTime>$r*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}await t(),e=!1},$r)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}},Ur=["request","overlay","sdk"];function Mo(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==Me.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var Lo=class extends Me{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:me,isPromiEvent:fn,encodeJSON:Ft,decodeJSON:Fr,createJsonRpcRequestPayload:G,standardizeJsonRpcRequestPayload:ht,storage:Gt};constructor(){super(void 0);let e=[this,...Mo(this)];Ur.forEach(t=>{let r=e.map(p=>Object.getOwnPropertyDescriptor(p,t)),i=r.findIndex(p=>!!p),a=i>0,s=r[i];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:a}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Kr(t)}}))})}init(e){this.__is_initialized__||(Ur.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:i}=this.__sdk_access_field_descriptors__.get(t);i?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:i}=e,a=i?` Use \`${i}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${a}`;return new $t(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new $t(this,e,t)}createError(e,t,r){return new Vr(this,e,t,r)}},gn=class extends Lo{},Co=class{static Internal=gn},Po=class extends gn{constructor(e){super(),this.config=e,this.chain=e.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(M.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(M.RevealPK,[{chain:this.chain}]))}};var Et=wr(_n()),Zt=wr(wn());var Do={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function $o(e){for(let[t,r]of Object.entries(Do))e.style[t]=r}function Uo(e){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(r=>r.src.includes(e))}var gt=class extends zt{activeElement=null;iframe;relayerSrc=Ge(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(t=>{let r=()=>{if(Uo(encodeURIComponent(this.parameters)))Wt().log();else{let i=document.createElement("iframe");i.classList.add("magic-iframe"),i.dataset.magicIframeLabel=Ge(this.endpoint).host,i.title="Secure Modal",i.src=this.relayerSrc,i.allow="clipboard-read; clipboard-write",$o(i),document.body.appendChild(i),t(i)}};["loaded","interactive","complete"].includes(document.readyState)?r():window.addEventListener("load",r,!1)}),this.iframe.then(t=>{t instanceof HTMLIFrameElement&&t.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",t=>{if(t.origin===this.endpoint&&t.data.msgType&&(t.data.msgType.includes(he.MAGIC_PONG)&&(this.lastPongTime=Date.now()),t.data&&this.messageHandlers.size)){t.data.response=t.data.response??{},this.stopHeartBeat();for(let r of this.messageHandlers.values())r(t)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let t=await this.iframe;t.style.display="block",t.style.zIndex="2147483647",t.style.opacity="1",this.activeElement=document.activeElement,t.focus()}async hideOverlay(){let t=await this.iframe;t.style.display="none",t.style.zIndex="-1",t.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(t){let r=await this.iframe;if(r&&r.contentWindow)r.contentWindow.postMessage(t,this.endpoint);else throw pt()}async checkRelayerExistsInDOM(){let t=await this.iframe;return!t||!t.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(i=>i.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let t=await this.iframe;if(this.stopHeartBeat(),!t){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!t.contentWindow){document.body.appendChild(t),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}t&&(t.src=this.relayerSrc)}};var xo=Object.assign(kt(Xt,{platform:"web",sdkName:"magic-sdk",version:"31.2.0",defaultEndpoint:"https://auth.magic.link/",ViewController:gt,configureStorage:async()=>{let e=Et.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await e.defineDriver(Zt),await e.setDriver([Et.default.INDEXEDDB,Et.default.LOCALSTORAGE,Zt._driver]),e}}),{...Jt}),Fo=xo;return wi(ko);})();
6
6
  if (Magic && Magic.default != null) { Magic = Object.assign(Magic.default, Magic); delete Magic.default; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-sdk",
3
- "version": "31.2.0",
3
+ "version": "31.2.1-canary.31f8e48.0",
4
4
  "description": "Passwordless authentication for the web.",
5
5
  "author": "Magic Labs <team@magic.link> (https://magic.link/)",
6
6
  "license": "MIT",
@@ -29,9 +29,9 @@
29
29
  ]
30
30
  },
31
31
  "dependencies": {
32
- "@magic-sdk/provider": "^31.2.0",
32
+ "@magic-sdk/provider": "31.2.1-canary.31f8e48.0",
33
33
  "@magic-sdk/types": "^25.2.0",
34
34
  "localforage": "^1.7.4"
35
35
  },
36
- "gitHead": "03fc97720800add4f98474ca6649991b694b43b3"
36
+ "gitHead": "31f8e4827840c0d06c75d773f113b40ab4d6254e"
37
37
  }