magic-sdk 29.0.2 → 29.0.3-canary.865.14093363024.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +3 -3
- package/dist/es/index.mjs +1 -1
- package/dist/es/index.mjs.map +3 -3
- package/dist/magic.js +3 -3
- package/dist/types/iframe-controller.d.ts +3 -13
- package/package.json +4 -4
package/dist/es/index.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var kr=Object.create;var $e=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var ve=(g=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(g,{get:(T,p)=>(typeof require!="undefined"?require:T)[p]}):g)(function(g){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+g+'" is not supported')});var Je=(g,T)=>()=>(T||g((T={exports:{}}).exports,T),T.exports);var ot=(g,T,p,D)=>{if(T&&typeof T=="object"||typeof T=="function")for(let R of rt(T))!nt.call(g,R)&&R!==p&&$e(g,R,{get:()=>T[R],enumerable:!(D=et(T,R))||D.enumerable});return g};var Ze=(g,T,p)=>(p=g!=null?kr(tt(g)):{},ot(T||!g||!g.__esModule?$e(p,"default",{value:g,enumerable:!0}):p,g));var re=(g,T,p)=>new Promise((D,R)=>{var X=S=>{try{z(p.next(S))}catch(M){R(M)}},P=S=>{try{z(p.throw(S))}catch(M){R(M)}},z=S=>S.done?D(S.value):Promise.resolve(S.value).then(X,P);z((p=p.apply(g,T)).next())});var ke=Je((qe,De)=>{(function(g){if(typeof qe=="object"&&typeof De<"u")De.exports=g();else if(typeof define=="function"&&define.amd)define([],g);else{var T;typeof window<"u"?T=window:typeof global<"u"?T=global:typeof self<"u"?T=self:T=this,T.localforage=g()}})(function(){var g,T,p;return function D(R,X,P){function z(K,J){if(!X[K]){if(!R[K]){var m=typeof ve=="function"&&ve;if(!J&&m)return m(K,!0);if(S)return S(K,!0);var I=new Error("Cannot find module '"+K+"'");throw I.code="MODULE_NOT_FOUND",I}var x=X[K]={exports:{}};R[K][0].call(x.exports,function(W){var Z=R[K][1][W];return z(Z||W)},x,x.exports,D,R,X,P)}return X[K].exports}for(var S=typeof ve=="function"&&ve,M=0;M<P.length;M++)z(P[M]);return z}({1:[function(D,R,X){(function(P){"use strict";var z=P.MutationObserver||P.WebKitMutationObserver,S;if(z){var M=0,K=new z(W),J=P.document.createTextNode("");K.observe(J,{characterData:!0}),S=function(){J.data=M=++M%2}}else if(!P.setImmediate&&typeof P.MessageChannel<"u"){var m=new P.MessageChannel;m.port1.onmessage=W,S=function(){m.port2.postMessage(0)}}else"document"in P&&"onreadystatechange"in P.document.createElement("script")?S=function(){var F=P.document.createElement("script");F.onreadystatechange=function(){W(),F.onreadystatechange=null,F.parentNode.removeChild(F),F=null},P.document.documentElement.appendChild(F)}:S=function(){setTimeout(W,0)};var I,x=[];function W(){I=!0;for(var F,k,U=x.length;U;){for(k=x,x=[],F=-1;++F<U;)k[F]();U=x.length}I=!1}R.exports=Z;function Z(F){x.push(F)===1&&!I&&S()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(D,R,X){"use strict";var P=D(1);function z(){}var S={},M=["REJECTED"],K=["FULFILLED"],J=["PENDING"];R.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==z&&Z(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,N){if(typeof h!="function"&&this.state===K||typeof N!="function"&&this.state===M)return this;var E=new this.constructor(z);if(this.state!==J){var C=this.state===K?h:N;x(E,C,this.outcome)}else this.queue.push(new I(E,h,N));return E};function I(h,N,E){this.promise=h,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(h){S.resolve(this.promise,h)},I.prototype.otherCallFulfilled=function(h){x(this.promise,this.onFulfilled,h)},I.prototype.callRejected=function(h){S.reject(this.promise,h)},I.prototype.otherCallRejected=function(h){x(this.promise,this.onRejected,h)};function x(h,N,E){P(function(){var C;try{C=N(E)}catch(G){return S.reject(h,G)}C===h?S.reject(h,new TypeError("Cannot resolve promise with itself")):S.resolve(h,C)})}S.resolve=function(h,N){var E=F(W,N);if(E.status==="error")return S.reject(h,E.value);var C=E.value;if(C)Z(h,C);else{h.state=K,h.outcome=N;for(var G=-1,j=h.queue.length;++G<j;)h.queue[G].callFulfilled(N)}return h},S.reject=function(h,N){h.state=M,h.outcome=N;for(var E=-1,C=h.queue.length;++E<C;)h.queue[E].callRejected(N);return h};function W(h){var N=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof N=="function")return function(){N.apply(h,arguments)}}function Z(h,N){var E=!1;function C($){E||(E=!0,S.reject(h,$))}function G($){E||(E=!0,S.resolve(h,$))}function j(){N(G,C)}var Q=F(j);Q.status==="error"&&C(Q.value)}function F(h,N){var E={};try{E.value=h(N),E.status="success"}catch(C){E.status="error",E.value=C}return E}m.resolve=k;function k(h){return h instanceof this?h:S.resolve(new this(z),h)}m.reject=U;function U(h){var N=new this(z);return S.reject(N,h)}m.all=fe;function fe(h){var N=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,C=!1;if(!E)return this.resolve([]);for(var G=new Array(E),j=0,Q=-1,$=new this(z);++Q<E;)ee(h[Q],Q);return $;function ee(ie,a){N.resolve(ie).then(u,function(v){C||(C=!0,S.reject($,v))});function u(v){G[a]=v,++j===E&&!C&&(C=!0,S.resolve($,G))}}}m.race=te;function te(h){var N=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,C=!1;if(!E)return this.resolve([]);for(var G=-1,j=new this(z);++G<E;)Q(h[G]);return j;function Q($){N.resolve($).then(function(ee){C||(C=!0,S.resolve(j,ee))},function(ee){C||(C=!0,S.reject(j,ee))})}}},{1:1}],3:[function(D,R,X){(function(P){"use strict";typeof P.Promise!="function"&&(P.Promise=D(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(D,R,X){"use strict";var P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(){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 M=S();function K(){try{if(!M||!M.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function J(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&D(3);var m=Promise;function I(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function x(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function W(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function Z(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var F="local-forage-detect-blob-support",k=void 0,U={},fe=Object.prototype.toString,te="readonly",h="readwrite";function N(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new m(function(t){var r=e.transaction(F,h),o=J([""]);r.objectStore(F).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function C(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(t){return k=t,k})}function G(e){var t=U[e.name],r={};r.promise=new m(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function j(e){var t=U[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function Q(e,t){var r=U[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function $(e,t){return new m(function(r,o){if(U[e.name]=U[e.name]||V(),e.db)if(t)G(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=M.open.apply(M,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(F)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),j(e)}})}function ee(e){return $(e,!1)}function ie(e){return $(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=N(atob(e.data));return J([t],{type:e.type})}function b(e){return e&&e.__local_forage_encoded_blob}function _(e){var t=this,r=t._initReady().then(function(){var o=U[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return x(r,e,e),r}function w(e){G(e);for(var t=U[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?ie(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw Q(e,n),n})}function B(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ie(e)}).then(function(){return w(e).then(function(){B(e,t,r,o-1)})}).catch(r);r(n)}}function V(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function se(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=U[r.name];i||(i=V(),U[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=_);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return r.db=i.db,ee(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?ie(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var y=0;y<l.length;y++){var A=l[y];A!==t&&(A._dbInfo.db=r.db,A._dbInfo.version=r.version)}})}function ae(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){B(r._dbInfo,te,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),b(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return I(o,t),o}function ce(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){B(r._dbInfo,te,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var y=l.result;if(y){var A=y.value;b(A)&&(A=v(A));var O=e(A,y.key,d++);O!==void 0?i(O):y.continue()}else i()},l.onerror=function(){n(l.error)}}catch(y){n(y)}})}).catch(n)});return I(o,t),o}function ir(e,t,r){var o=this;e=W(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,fe.call(t)==="[object Blob]"?C(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){B(o._dbInfo,h,function(l,d){if(l)return f(l);try{var y=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var A=y.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var O=A.error?A.error:A.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return I(i,r),i}function ar(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){B(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return I(o,t),o}function fr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){B(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return I(r,e),r}function sr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){B(t._dbInfo,te,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return I(r,e),r}function ur(e,t){var r=this,o=new m(function(i,n){if(e<0){i(null);return}r.ready().then(function(){B(r._dbInfo,te,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var y=d.result;if(!y){i(null);return}e===0||l?i(y.key):(l=!0,y.advance(e))},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return I(o,t),o}function cr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){B(t._dbInfo,te,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return I(r,e),r}function lr(e,t){t=Z.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=U[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(!!s.objectStoreNames.contains(e.storeName)){var c=s.version+1;G(e);var l=U[e.name],d=l.forages;s.close();for(var y=0;y<d.length;y++){var A=d[y];A._dbInfo.db=null,A._dbInfo.version=c}var O=new m(function(L,H){var Y=M.open(e.name,c);Y.onerror=function(q){var de=Y.result;de.close(),H(q)},Y.onupgradeneeded=function(){var q=Y.result;q.deleteObjectStore(e.storeName)},Y.onsuccess=function(){var q=Y.result;q.close(),L(q)}});return O.then(function(L){l.db=L;for(var H=0;H<d.length;H++){var Y=d[H];Y._dbInfo.db=L,j(Y._dbInfo)}}).catch(function(L){throw(Q(e,L)||m.resolve()).catch(function(){}),L})}}):i=f.then(function(s){G(e);var c=U[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var y=l[d];y._dbInfo.db=null}var A=new m(function(O,L){var H=M.deleteDatabase(e.name);H.onerror=function(){var Y=H.result;Y&&Y.close(),L(H.error)},H.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},H.onsuccess=function(){var Y=H.result;Y&&Y.close(),O(Y)}});return A.then(function(O){c.db=O;for(var L=0;L<l.length;L++){var H=l[L];j(H._dbInfo)}}).catch(function(O){throw(Q(e,O)||m.resolve()).catch(function(){}),O})})}return I(i,t),i}var dr={_driver:"asyncStorage",_initStorage:se,_support:K(),iterate:ce,getItem:ae,setItem:ir,removeItem:ar,clear:fr,length:sr,key:ur,keys:cr,dropInstance:lr};function vr(){return typeof openDatabase=="function"}var ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hr="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,he="__lfsc__:",be=he.length,_e="arbf",Ie="blob",xe="si08",Oe="ui08",Ce="uic8",Le="si16",Pe="si32",Me="ur16",Fe="ui32",Ue="fl32",ze="fl64",We=be+_e.length,Ye=Object.prototype.toString;function He(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=ne.indexOf(e[o]),f=ne.indexOf(e[o+1]),s=ne.indexOf(e[o+2]),c=ne.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=ne[t[o]>>2],r+=ne[(t[o]&3)<<4|t[o+1]>>4],r+=ne[(t[o+1]&15)<<2|t[o+2]>>6],r+=ne[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function mr(e,t){var r="";if(e&&(r=Ye.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Ye.call(e.buffer)==="[object ArrayBuffer]")){var o,i=he;e instanceof ArrayBuffer?(o=e,i+=_e):(o=e.buffer,r==="[object Int8Array]"?i+=xe:r==="[object Uint8Array]"?i+=Oe:r==="[object Uint8ClampedArray]"?i+=Ce:r==="[object Int16Array]"?i+=Le:r==="[object Uint16Array]"?i+=Me:r==="[object Int32Array]"?i+=Pe:r==="[object Uint32Array]"?i+=Fe:r==="[object Float32Array]"?i+=Ue:r==="[object Float64Array]"?i+=ze:t(new Error("Failed to get type for BinaryArray"))),t(i+we(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=hr+e.type+"~"+we(this.result);t(he+Ie+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function yr(e){if(e.substring(0,be)!==he)return JSON.parse(e);var t=e.substring(We),r=e.substring(be,We),o;if(r===Ie&&Be.test(t)){var i=t.match(Be);o=i[1],t=t.substring(i[0].length)}var n=He(t);switch(r){case _e:return n;case Ie:return J([n],{type:o});case xe:return new Int8Array(n);case Oe:return new Uint8Array(n);case Ce:return new Uint8ClampedArray(n);case Le:return new Int16Array(n);case Me:return new Uint16Array(n);case Pe:return new Int32Array(n);case Fe:return new Uint32Array(n);case Ue:return new Float32Array(n);case ze:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ee={serialize:mr,deserialize:yr,stringToBuffer:He,bufferToString:we};function Ke(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function pr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new m(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Ke(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=Ee,i}function oe(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function gr(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){oe(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return I(o,t),o}function br(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){oe(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,y=d.length,A=0;A<y;A++){var O=d.item(A),L=O.value;if(L&&(L=f.serializer.deserialize(L)),L=e(L,O.key,A+1),L!==void 0){i(L);return}}i()},function(c,l){n(l)})})}).catch(n)});return I(o,t),o}function Ge(e,t,r,o){var i=this;e=W(e);var n=new m(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,y){y?s(y):l.db.transaction(function(A){oe(A,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(O,L){s(L)})},function(A){if(A.code===A.QUOTA_ERR){if(o>0){f(Ge.apply(i,[e,c,r,o-1]));return}s(A)}})})}).catch(s)});return I(n,r),n}function _r(e,t,r){return Ge.apply(this,[e,t,r,1])}function Ir(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){oe(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return I(o,t),o}function wr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){oe(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return I(r,e),r}function Er(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){oe(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return I(r,e),r}function Sr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){oe(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return I(o,t),o}function Ar(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){oe(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return I(r,e),r}function Tr(e){return new m(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Rr(e,t){t=Z.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new m(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Tr(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(O){return new m(function(L,H){c.executeSql("DROP TABLE IF EXISTS "+O,[],function(){L()},function(Y,q){H(q)})})}for(var d=[],y=0,A=n.storeNames.length;y<A;y++)d.push(l(n.storeNames[y]));m.all(d).then(function(){f()}).catch(function(O){s(O)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),I(i,t),i}var Dr={_driver:"webSQLStorage",_initStorage:pr,_support:vr(),iterate:br,getItem:gr,setItem:_r,removeItem:Ir,clear:wr,length:Er,key:Sr,keys:Ar,dropInstance:Rr};function Nr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Br(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function xr(){return!Br()||localStorage.length>0}function Or(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ve(e,t._defaultConfig),xr()?(t._dbInfo=r,r.serializer=Ee,m.resolve()):m.reject()}function Cr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return I(r,e),r}function Lr(e,t){var r=this;e=W(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return I(o,t),o}function Pr(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var y=localStorage.getItem(d);if(y&&(y=i.serializer.deserialize(y)),y=e(y,d.substring(f),c++),y!==void 0)return y}}});return I(o,t),o}function Mr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return I(o,t),o}function Fr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return I(r,e),r}function Ur(e){var t=this,r=t.keys().then(function(o){return o.length});return I(r,e),r}function zr(e,t){var r=this;e=W(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return I(o,t),o}function Wr(e,t,r){var o=this;e=W(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(y){(y.name==="QuotaExceededError"||y.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(y),s(y)}})})});return I(i,r),i}function Yr(e,t){if(t=Z.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new m(function(n){e.storeName?n(Ve(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),I(i,t),i}var Hr={_driver:"localStorageWrapper",_initStorage:Or,_support:Nr(),iterate:Pr,getItem:Lr,setItem:Wr,removeItem:zr,clear:Cr,length:Ur,key:Mr,keys:Fr,dropInstance:Yr},Kr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Gr=function(t,r){for(var o=t.length,i=0;i<o;){if(Kr(t[i],r))return!0;i++}return!1},je=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},le={},Xe={},ue={INDEXEDDB:dr,WEBSQL:Dr,LOCALSTORAGE:Hr},Vr=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],me=["dropInstance"],Se=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(me),jr={description:"",driver:Vr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Xr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Ae(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(je(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Qr=function(){function e(t){z(this,e);for(var r in ue)if(ue.hasOwnProperty(r)){var o=ue[r],i=o._driver;this[r]=i,le[i]||this.defineDriver(o)}this._defaultConfig=Ae({},jr),this._config=Ae({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":P(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new m(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Se.concat("_initStorage"),y=0,A=d.length;y<A;y++){var O=d[y],L=!Gr(me,O);if((L||r[O])&&typeof r[O]!="function"){s(l);return}}var H=function(){for(var de=function(Zr){return function(){var qr=new Error("Method "+Zr+" is not implemented by the current driver"),Qe=m.reject(qr);return I(Qe,arguments[arguments.length-1]),Qe}},Te=0,Jr=me.length;Te<Jr;Te++){var Re=me[Te];r[Re]||(r[Re]=de(Re))}};H();var Y=function(de){le[c]&&console.info("Redefining LocalForage driver: "+c),le[c]=r,Xe[c]=de,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(Y,s):Y(!!r._support):Y(!0)}catch(q){s(q)}});return x(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=le[r]?m.resolve(le[r]):m.reject(new Error("Driver not found."));return x(n,o,i),n},e.prototype.getSerializer=function(r){var o=m.resolve(Ee);return x(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return x(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;je(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(y){return n._extend(y),s(),n._ready=n._initStorage(n._config),n._ready}function l(y){return function(){var A=0;function O(){for(;A<y.length;){var L=y[A];return A++,n._dbInfo=null,n._ready=null,n.getDriver(L).then(c).catch(O)}s();var H=new Error("No available storage method found.");return n._driverSet=m.reject(H),n._driverSet}return O()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var y=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(y).then(function(A){n._driver=A._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var y=new Error("No available storage method found.");return n._driverSet=m.reject(y),n._driverSet}),x(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!Xe[r]},e.prototype._extend=function(r){Ae(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Se.length;r<o;r++)Xr(this,Se[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),$r=new Qr;R.exports=$r},{3:3}]},{},[4])(4)})});var rr=Je((ye,er)=>{(function(g,T){typeof ye=="object"&&typeof er<"u"?T(ye):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],T):T(g.LocalforageDriverMemory={})})(typeof self<"u"?self:ye,function(g){"use strict";var T="localforage-driver-memory";function p(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function D(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(w){if(w.name!=="TypeError")throw w;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,b=new v,_=0;_<a.length;_+=1)b.append(a[_]);return b.getBlob(u.type)}}var R=/^~~local_forage_type~([^~]+)~/,X=9,P=X+4,z=Object.prototype.toString;function S(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var b=new ArrayBuffer(u),_=new Uint8Array(b),w=0,B=0;w<v;w+=4){var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w]),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+1]),ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+2]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+3]);_[B++]=V<<2|se>>4,_[B++]=(se&15)<<4|ae>>2,_[B++]=(ae&3)<<6|ce&63}return b}function M(a){for(var u=new Uint8Array(a),v="",b=0;b<u.length;b+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[b]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[b]&3)<<4|u[b+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[b+1]&15)<<2|u[b+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[b+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=z.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&z.call(a.buffer)==="[object ArrayBuffer]")){var b=void 0,_="__lfsc__:";a instanceof ArrayBuffer?(b=a,_+="arbf"):(b=a.buffer,v==="[object Int8Array]"?_+="si08":v==="[object Uint8Array]"?_+="ui08":v==="[object Uint8ClampedArray]"?_+="uic8":v==="[object Int16Array]"?_+="si16":v==="[object Uint16Array]"?_+="ur16":v==="[object Int32Array]"?_+="si32":v==="[object Uint32Array]"?_+="ui32":v==="[object Float32Array]"?_+="fl32":v==="[object Float64Array]"?_+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(_+M(b))}else if(v==="[object Blob]"){var w=new FileReader;w.onload=function(){var B="~~local_forage_type~"+a.type+"~"+M(this.result);u("__lfsc__:blob"+B)},w.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(B){console.error("Couldn't convert value into a JSON string: ",a),u(null,B)}}function J(a){if(a.substring(0,X)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(P),v=a.substring(X,P),b;if(v==="blob"&&R.test(u)){var _=u.match(R);b=_[1],u=u.substring(_[0].length)}var w=S(u);switch(v){case"arbf":return w;case"blob":return D([w],{type:b});case"si08":return new Int8Array(w);case"ui08":return new Uint8Array(w);case"uic8":return new Uint8ClampedArray(w);case"si16":return new Int16Array(w);case"ur16":return new Uint16Array(w);case"si32":return new Int32Array(w);case"ui32":return new Uint32Array(w);case"fl32":return new Float32Array(w);case"fl64":return new Float64Array(w);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var b=a instanceof Date?new Date(a):a.constructor();try{for(var _=p(Object.keys(a)),w=_.next();!w.done;w=_.next()){var B=w.value;Object.prototype.hasOwnProperty.call(a,B)&&(a.isActiveClone=null,b[B]=m(a[B]),delete a.isActiveClone)}}catch(V){u={error:V}}finally{try{w&&!w.done&&(v=_.return)&&v.call(_)}finally{if(u)throw u.error}}return b}function I(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function x(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function W(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Z(a,u){var v=this;if(u=W.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var b=this.config();a.name=a.name||b.name,a.storeName=a.storeName||b.storeName}var _;return a.name?_=new Promise(function(w){a.storeName?w(I(a,v._defaultConfig)):w(a.name+"/")}):_=Promise.reject("Invalid arguments"),{promise:_,callback:u}}function F(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:M,deserialize:J,serialize:K,stringToBuffer:S},U={},fe=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return U[u]||(U[u]=new a(u)),U[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete U[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function te(a){var u=a?m(a):{},v=I(u,this._defaultConfig),b=fe.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=b,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return x(v,a),v}function N(a,u){var v=Z.apply(this,arguments),b=v.promise,_=v.callback,w=b.then(function(B){fe.resolve(B).drop()});return x(w,_),b}function E(a,u){var v=this;a=F(a);var b=this.ready().then(function(){var _=v._dbInfo.mStore.get(a);return _==null?null:v._dbInfo.serializer.deserialize(_)});return x(b,u),b}function C(a,u){var v=this,b=this.ready().then(function(){for(var _=v._dbInfo.mStore,w=_.keys(),B=0;B<w.length;B++){var V=_.get(w[B]);if(V&&(V=v._dbInfo.serializer.deserialize(V)),V=a(V,w[B],B+1),V!==void 0)return V}});return x(b,u),b}function G(a,u){var v=this,b=this.ready().then(function(){var _;try{_=v._dbInfo.mStore.key(a),_===void 0&&(_=null)}catch{_=null}return _});return x(b,u),b}function j(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return x(v,a),v}function Q(a){var u=this.keys().then(function(v){return v.length});return x(u,a),u}function $(a,u){var v=this;a=F(a);var b=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return x(b,u),b}function ee(a,u,v){var b=this;a=F(a);var _=this.ready().then(function(){u===void 0&&(u=null);var w=u;return new Promise(function(B,V){b._dbInfo.serializer.serialize(u,function(se,ae){if(ae)V(ae);else try{b._dbInfo.mStore.set(a,se),B(w)}catch(ce){V(ce)}})})});return x(_,v),_}var ie=!0;g._support=ie,g._driver=T,g._initStorage=te,g.clear=h,g.dropInstance=N,g.getItem=E,g.iterate=C,g.key=G,g.keys=j,g.length=Q,g.removeItem=$,g.setItem=ee,Object.defineProperty(g,"__esModule",{value:!0})})});var ge=Ze(ke()),Ne=Ze(rr());import{SDKBase as pt,createSDK as gt}from"@magic-sdk/provider";import{createDuplicateIframeWarning as it,createModalLostError as at,createModalNotReadyError as ft,createURL as tr,ViewController as st}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as ut,MagicOutgoingWindowMessage as ct}from"@magic-sdk/types";var lt={display:"block",visibility:"hidden",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function dt(g){for(let[T,p]of Object.entries(lt))g.style[T]=p}function vt(g){let T=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(T.find(p=>p.src.includes(g)))}var ht=1e3,or=60*ht,nr=5*or,mt=60*or,pe=class extends st{constructor(){super(...arguments);this.activeElement=null;this.lastPongTime=null;this.heartbeatIntervalTimer=null;this.heartbeatDebounce=yt(()=>this.heartBeatCheck(),mt)}getIframeSrc(){return tr(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href}init(){this.test="hello",this.iframe=new Promise(p=>{let D=()=>{if(vt(encodeURIComponent(this.parameters)))it().log();else{let R=document.createElement("iframe");R.classList.add("magic-iframe"),R.dataset.magicIframeLabel=tr(this.endpoint).host,R.title="Secure Modal",R.src=this.getIframeSrc(),R.allow="clipboard-read; clipboard-write",dt(R),document.body.appendChild(R),p(R)}};["loaded","interactive","complete"].includes(document.readyState)?D():window.addEventListener("load",D,!1)}),this.iframe.then(p=>{p instanceof HTMLIFrameElement&&p.addEventListener("load",()=>re(this,null,function*(){this.heartbeatDebounce()}))}),window.addEventListener("message",p=>{var D;if(p.origin===this.endpoint&&p.data.msgType&&(p.data.msgType.includes(ut.MAGIC_PONG)&&(this.lastPongTime=Date.now()),p.data&&this.messageHandlers.size)){p.data.response=(D=p.data.response)!=null?D:{},this.stopHeartBeat();for(let R of this.messageHandlers.values())R(p)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}showOverlay(){return re(this,null,function*(){let p=yield this.iframe;p.style.visibility="visible",p.style.zIndex="2147483647",p.style.opacity="1",this.activeElement=document.activeElement,p.focus()})}hideOverlay(){return re(this,null,function*(){var D;let p=yield this.iframe;p.style.visibility="hidden",p.style.zIndex="-1",p.style.opacity="0",(D=this.activeElement)!=null&&D.focus&&this.activeElement.focus(),this.activeElement=null})}_post(p){return re(this,null,function*(){let D=yield this.checkIframeExistsInDOM();if(!D)throw this.init(),at();if(D&&D.contentWindow)D.contentWindow.postMessage(p,this.endpoint);else throw ft()})}heartBeatCheck(){let p=!0,D=()=>re(this,null,function*(){let R={msgType:`${ct.MAGIC_PING}-${this.parameters}`,payload:[]};yield this._post(R)});this.heartbeatIntervalTimer=setInterval(()=>re(this,null,function*(){if(this.lastPongTime){if(Date.now()-this.lastPongTime>nr*2){this.reloadIframe(),p=!0;return}}else if(!p){this.reloadIframe(),p=!0;return}yield D(),p=!1}),nr)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}reloadIframe(){return re(this,null,function*(){let p=yield this.iframe;this.stopHeartBeat(),p?p.src=this.getIframeSrc():(this.init(),console.warn("Magic SDK: Modal lost, re-initiating"))})}checkIframeExistsInDOM(){return re(this,null,function*(){return[].slice.call(document.querySelectorAll(".magic-iframe")).find(D=>D.src.includes(encodeURIComponent(this.parameters)))})}};function yt(g,T){let p=null;return function(...D){p&&clearTimeout(p),p=setTimeout(()=>{g(...D)},T)}}export*from"@magic-sdk/commons";var Dt=gt(pt,{platform:"web",sdkName:"magic-sdk",version:"29.0.2",defaultEndpoint:"https://auth.magic.link/",ViewController:pe,configureStorage:()=>re(void 0,null,function*(){let g=ge.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield g.defineDriver(Ne),yield g.setDriver([ge.default.INDEXEDDB,ge.default.LOCALSTORAGE,Ne._driver]),g})});export{Dt as Magic};
|
1
|
+
var $r=Object.create;var Je=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var ve=(b=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(b,{get:(R,_)=>(typeof require!="undefined"?require:R)[_]}):b)(function(b){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+b+'" is not supported')});var $e=(b,R)=>()=>(R||b((R={exports:{}}).exports,R),R.exports);var rt=(b,R,_,B)=>{if(R&&typeof R=="object"||typeof R=="function")for(let D of qr(R))!et.call(b,D)&&D!==_&&Je(b,D,{get:()=>R[D],enumerable:!(B=Zr(R,D))||B.enumerable});return b};var Ze=(b,R,_)=>(_=b!=null?$r(kr(b)):{},rt(R||!b||!b.__esModule?Je(_,"default",{value:b,enumerable:!0}):_,b));var oe=(b,R,_)=>new Promise((B,D)=>{var X=S=>{try{z(_.next(S))}catch(M){D(M)}},P=S=>{try{z(_.throw(S))}catch(M){D(M)}},z=S=>S.done?B(S.value):Promise.resolve(S.value).then(X,P);z((_=_.apply(b,R)).next())});var ke=$e((qe,Te)=>{(function(b){if(typeof qe=="object"&&typeof Te<"u")Te.exports=b();else if(typeof define=="function"&&define.amd)define([],b);else{var R;typeof window<"u"?R=window:typeof global<"u"?R=global:typeof self<"u"?R=self:R=this,R.localforage=b()}})(function(){var b,R,_;return function B(D,X,P){function z(H,$){if(!X[H]){if(!D[H]){var m=typeof ve=="function"&&ve;if(!$&&m)return m(H,!0);if(S)return S(H,!0);var w=new Error("Cannot find module '"+H+"'");throw w.code="MODULE_NOT_FOUND",w}var x=X[H]={exports:{}};D[H][0].call(x.exports,function(W){var Z=D[H][1][W];return z(Z||W)},x,x.exports,B,D,X,P)}return X[H].exports}for(var S=typeof ve=="function"&&ve,M=0;M<P.length;M++)z(P[M]);return z}({1:[function(B,D,X){(function(P){"use strict";var z=P.MutationObserver||P.WebKitMutationObserver,S;if(z){var M=0,H=new z(W),$=P.document.createTextNode("");H.observe($,{characterData:!0}),S=function(){$.data=M=++M%2}}else if(!P.setImmediate&&typeof P.MessageChannel<"u"){var m=new P.MessageChannel;m.port1.onmessage=W,S=function(){m.port2.postMessage(0)}}else"document"in P&&"onreadystatechange"in P.document.createElement("script")?S=function(){var F=P.document.createElement("script");F.onreadystatechange=function(){W(),F.onreadystatechange=null,F.parentNode.removeChild(F),F=null},P.document.documentElement.appendChild(F)}:S=function(){setTimeout(W,0)};var w,x=[];function W(){w=!0;for(var F,k,U=x.length;U;){for(k=x,x=[],F=-1;++F<U;)k[F]();U=x.length}w=!1}D.exports=Z;function Z(F){x.push(F)===1&&!w&&S()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(B,D,X){"use strict";var P=B(1);function z(){}var S={},M=["REJECTED"],H=["FULFILLED"],$=["PENDING"];D.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=$,this.queue=[],this.outcome=void 0,h!==z&&Z(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,T){if(typeof h!="function"&&this.state===H||typeof T!="function"&&this.state===M)return this;var E=new this.constructor(z);if(this.state!==$){var C=this.state===H?h:T;x(E,C,this.outcome)}else this.queue.push(new w(E,h,T));return E};function w(h,T,E){this.promise=h,typeof T=="function"&&(this.onFulfilled=T,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){S.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){x(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){S.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){x(this.promise,this.onRejected,h)};function x(h,T,E){P(function(){var C;try{C=T(E)}catch(V){return S.reject(h,V)}C===h?S.reject(h,new TypeError("Cannot resolve promise with itself")):S.resolve(h,C)})}S.resolve=function(h,T){var E=F(W,T);if(E.status==="error")return S.reject(h,E.value);var C=E.value;if(C)Z(h,C);else{h.state=H,h.outcome=T;for(var V=-1,j=h.queue.length;++V<j;)h.queue[V].callFulfilled(T)}return h},S.reject=function(h,T){h.state=M,h.outcome=T;for(var E=-1,C=h.queue.length;++E<C;)h.queue[E].callRejected(T);return h};function W(h){var T=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof T=="function")return function(){T.apply(h,arguments)}}function Z(h,T){var E=!1;function C(J){E||(E=!0,S.reject(h,J))}function V(J){E||(E=!0,S.resolve(h,J))}function j(){T(V,C)}var Q=F(j);Q.status==="error"&&C(Q.value)}function F(h,T){var E={};try{E.value=h(T),E.status="success"}catch(C){E.status="error",E.value=C}return E}m.resolve=k;function k(h){return h instanceof this?h:S.resolve(new this(z),h)}m.reject=U;function U(h){var T=new this(z);return S.reject(T,h)}m.all=fe;function fe(h){var T=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,C=!1;if(!E)return this.resolve([]);for(var V=new Array(E),j=0,Q=-1,J=new this(z);++Q<E;)ee(h[Q],Q);return J;function ee(ie,a){T.resolve(ie).then(u,function(v){C||(C=!0,S.reject(J,v))});function u(v){V[a]=v,++j===E&&!C&&(C=!0,S.resolve(J,V))}}}m.race=re;function re(h){var T=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,C=!1;if(!E)return this.resolve([]);for(var V=-1,j=new this(z);++V<E;)Q(h[V]);return j;function Q(J){T.resolve(J).then(function(ee){C||(C=!0,S.resolve(j,ee))},function(ee){C||(C=!0,S.reject(j,ee))})}}},{1:1}],3:[function(B,D,X){(function(P){"use strict";typeof P.Promise!="function"&&(P.Promise=B(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(B,D,X){"use strict";var P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(){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 M=S();function H(){try{if(!M||!M.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function $(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&B(3);var m=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function x(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function W(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function Z(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var F="local-forage-detect-blob-support",k=void 0,U={},fe=Object.prototype.toString,re="readonly",h="readwrite";function T(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new m(function(t){var r=e.transaction(F,h),o=$([""]);r.objectStore(F).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function C(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(t){return k=t,k})}function V(e){var t=U[e.name],r={};r.promise=new m(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function j(e){var t=U[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function Q(e,t){var r=U[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function J(e,t){return new m(function(r,o){if(U[e.name]=U[e.name]||G(),e.db)if(t)V(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=M.open.apply(M,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(F)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),j(e)}})}function ee(e){return J(e,!1)}function ie(e){return J(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=T(atob(e.data));return $([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function p(e){var t=this,r=t._initReady().then(function(){var o=U[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return x(r,e,e),r}function I(e){V(e);for(var t=U[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?ie(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw Q(e,n),n})}function N(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ie(e)}).then(function(){return I(e).then(function(){N(e,t,r,o-1)})}).catch(r);r(n)}}function G(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function se(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=U[r.name];i||(i=G(),U[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=p);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return r.db=i.db,ee(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?ie(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var y=0;y<l.length;y++){var A=l[y];A!==t&&(A._dbInfo.db=r.db,A._dbInfo.version=r.version)}})}function ae(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){N(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function ce(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){N(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var y=l.result;if(y){var A=y.value;g(A)&&(A=v(A));var O=e(A,y.key,d++);O!==void 0?i(O):y.continue()}else i()},l.onerror=function(){n(l.error)}}catch(y){n(y)}})}).catch(n)});return w(o,t),o}function tr(e,t,r){var o=this;e=W(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,fe.call(t)==="[object Blob]"?C(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){N(o._dbInfo,h,function(l,d){if(l)return f(l);try{var y=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var A=y.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var O=A.error?A.error:A.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return w(i,r),i}function nr(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){N(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function or(e){var t=this,r=new m(function(o,i){t.ready().then(function(){N(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){N(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ar(e,t){var r=this,o=new m(function(i,n){if(e<0){i(null);return}r.ready().then(function(){N(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var y=d.result;if(!y){i(null);return}e===0||l?i(y.key):(l=!0,y.advance(e))},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return w(o,t),o}function fr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){N(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function sr(e,t){t=Z.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=U[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(!!s.objectStoreNames.contains(e.storeName)){var c=s.version+1;V(e);var l=U[e.name],d=l.forages;s.close();for(var y=0;y<d.length;y++){var A=d[y];A._dbInfo.db=null,A._dbInfo.version=c}var O=new m(function(L,K){var Y=M.open(e.name,c);Y.onerror=function(q){var de=Y.result;de.close(),K(q)},Y.onupgradeneeded=function(){var q=Y.result;q.deleteObjectStore(e.storeName)},Y.onsuccess=function(){var q=Y.result;q.close(),L(q)}});return O.then(function(L){l.db=L;for(var K=0;K<d.length;K++){var Y=d[K];Y._dbInfo.db=L,j(Y._dbInfo)}}).catch(function(L){throw(Q(e,L)||m.resolve()).catch(function(){}),L})}}):i=f.then(function(s){V(e);var c=U[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var y=l[d];y._dbInfo.db=null}var A=new m(function(O,L){var K=M.deleteDatabase(e.name);K.onerror=function(){var Y=K.result;Y&&Y.close(),L(K.error)},K.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},K.onsuccess=function(){var Y=K.result;Y&&Y.close(),O(Y)}});return A.then(function(O){c.db=O;for(var L=0;L<l.length;L++){var K=l[L];j(K._dbInfo)}}).catch(function(O){throw(Q(e,O)||m.resolve()).catch(function(){}),O})})}return w(i,t),i}var ur={_driver:"asyncStorage",_initStorage:se,_support:H(),iterate:ce,getItem:ae,setItem:tr,removeItem:nr,clear:or,length:ir,key:ar,keys:fr,dropInstance:sr};function cr(){return typeof openDatabase=="function"}var te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lr="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,he="__lfsc__:",be=he.length,_e="arbf",we="blob",xe="si08",Oe="ui08",Ce="uic8",Le="si16",Pe="si32",Me="ur16",Fe="ui32",Ue="fl32",ze="fl64",We=be+_e.length,Ye=Object.prototype.toString;function Ke(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=te.indexOf(e[o]),f=te.indexOf(e[o+1]),s=te.indexOf(e[o+2]),c=te.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function Ie(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=te[t[o]>>2],r+=te[(t[o]&3)<<4|t[o+1]>>4],r+=te[(t[o+1]&15)<<2|t[o+2]>>6],r+=te[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function dr(e,t){var r="";if(e&&(r=Ye.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Ye.call(e.buffer)==="[object ArrayBuffer]")){var o,i=he;e instanceof ArrayBuffer?(o=e,i+=_e):(o=e.buffer,r==="[object Int8Array]"?i+=xe:r==="[object Uint8Array]"?i+=Oe:r==="[object Uint8ClampedArray]"?i+=Ce:r==="[object Int16Array]"?i+=Le:r==="[object Uint16Array]"?i+=Me:r==="[object Int32Array]"?i+=Pe:r==="[object Uint32Array]"?i+=Fe:r==="[object Float32Array]"?i+=Ue:r==="[object Float64Array]"?i+=ze:t(new Error("Failed to get type for BinaryArray"))),t(i+Ie(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=lr+e.type+"~"+Ie(this.result);t(he+we+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function vr(e){if(e.substring(0,be)!==he)return JSON.parse(e);var t=e.substring(We),r=e.substring(be,We),o;if(r===we&&Be.test(t)){var i=t.match(Be);o=i[1],t=t.substring(i[0].length)}var n=Ke(t);switch(r){case _e:return n;case we:return $([n],{type:o});case xe:return new Int8Array(n);case Oe:return new Uint8Array(n);case Ce:return new Uint8ClampedArray(n);case Le:return new Int16Array(n);case Me:return new Uint16Array(n);case Pe:return new Int32Array(n);case Fe:return new Uint32Array(n);case Ue:return new Float32Array(n);case ze:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ee={serialize:dr,deserialize:vr,stringToBuffer:Ke,bufferToString:Ie};function He(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function hr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new m(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){He(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=Ee,i}function ne(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):He(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function mr(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function yr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,y=d.length,A=0;A<y;A++){var O=d.item(A),L=O.value;if(L&&(L=f.serializer.deserialize(L)),L=e(L,O.key,A+1),L!==void 0){i(L);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Ve(e,t,r,o){var i=this;e=W(e);var n=new m(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,y){y?s(y):l.db.transaction(function(A){ne(A,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(O,L){s(L)})},function(A){if(A.code===A.QUOTA_ERR){if(o>0){f(Ve.apply(i,[e,c,r,o-1]));return}s(A)}})})}).catch(s)});return w(n,r),n}function gr(e,t,r){return Ve.apply(this,[e,t,r,1])}function pr(e,t){var r=this;e=W(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function _r(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function wr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Er(e){return new m(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Sr(e,t){t=Z.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new m(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Er(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(O){return new m(function(L,K){c.executeSql("DROP TABLE IF EXISTS "+O,[],function(){L()},function(Y,q){K(q)})})}for(var d=[],y=0,A=n.storeNames.length;y<A;y++)d.push(l(n.storeNames[y]));m.all(d).then(function(){f()}).catch(function(O){s(O)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),w(i,t),i}var Ar={_driver:"webSQLStorage",_initStorage:hr,_support:cr(),iterate:yr,getItem:mr,setItem:gr,removeItem:pr,clear:br,length:_r,key:wr,keys:Ir,dropInstance:Sr};function Rr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ge(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Dr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Tr(){return!Dr()||localStorage.length>0}function Nr(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ge(e,t._defaultConfig),Tr()?(t._dbInfo=r,r.serializer=Ee,m.resolve()):m.reject()}function Br(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function xr(e,t){var r=this;e=W(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Or(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var y=localStorage.getItem(d);if(y&&(y=i.serializer.deserialize(y)),y=e(y,d.substring(f),c++),y!==void 0)return y}}});return w(o,t),o}function Cr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Pr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function Mr(e,t){var r=this;e=W(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Fr(e,t,r){var o=this;e=W(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(y){(y.name==="QuotaExceededError"||y.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(y),s(y)}})})});return w(i,r),i}function Ur(e,t){if(t=Z.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new m(function(n){e.storeName?n(Ge(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),w(i,t),i}var zr={_driver:"localStorageWrapper",_initStorage:Nr,_support:Rr(),iterate:Or,getItem:xr,setItem:Fr,removeItem:Mr,clear:Br,length:Pr,key:Cr,keys:Lr,dropInstance:Ur},Wr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Yr=function(t,r){for(var o=t.length,i=0;i<o;){if(Wr(t[i],r))return!0;i++}return!1},je=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},le={},Xe={},ue={INDEXEDDB:ur,WEBSQL:Ar,LOCALSTORAGE:zr},Kr=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],me=["dropInstance"],Se=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(me),Hr={description:"",driver:Kr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Ae(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(je(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Gr=function(){function e(t){z(this,e);for(var r in ue)if(ue.hasOwnProperty(r)){var o=ue[r],i=o._driver;this[r]=i,le[i]||this.defineDriver(o)}this._defaultConfig=Ae({},Hr),this._config=Ae({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":P(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new m(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Se.concat("_initStorage"),y=0,A=d.length;y<A;y++){var O=d[y],L=!Yr(me,O);if((L||r[O])&&typeof r[O]!="function"){s(l);return}}var K=function(){for(var de=function(Qr){return function(){var Jr=new Error("Method "+Qr+" is not implemented by the current driver"),Qe=m.reject(Jr);return w(Qe,arguments[arguments.length-1]),Qe}},Re=0,Xr=me.length;Re<Xr;Re++){var De=me[Re];r[De]||(r[De]=de(De))}};K();var Y=function(de){le[c]&&console.info("Redefining LocalForage driver: "+c),le[c]=r,Xe[c]=de,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(Y,s):Y(!!r._support):Y(!0)}catch(q){s(q)}});return x(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=le[r]?m.resolve(le[r]):m.reject(new Error("Driver not found."));return x(n,o,i),n},e.prototype.getSerializer=function(r){var o=m.resolve(Ee);return x(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return x(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;je(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(y){return n._extend(y),s(),n._ready=n._initStorage(n._config),n._ready}function l(y){return function(){var A=0;function O(){for(;A<y.length;){var L=y[A];return A++,n._dbInfo=null,n._ready=null,n.getDriver(L).then(c).catch(O)}s();var K=new Error("No available storage method found.");return n._driverSet=m.reject(K),n._driverSet}return O()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var y=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(y).then(function(A){n._driver=A._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var y=new Error("No available storage method found.");return n._driverSet=m.reject(y),n._driverSet}),x(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!Xe[r]},e.prototype._extend=function(r){Ae(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Se.length;r<o;r++)Vr(this,Se[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),jr=new Gr;D.exports=jr},{3:3}]},{},[4])(4)})});var rr=$e((ye,er)=>{(function(b,R){typeof ye=="object"&&typeof er<"u"?R(ye):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],R):R(b.LocalforageDriverMemory={})})(typeof self<"u"?self:ye,function(b){"use strict";var R="localforage-driver-memory";function _(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function B(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,p=0;p<a.length;p+=1)g.append(a[p]);return g.getBlob(u.type)}}var D=/^~~local_forage_type~([^~]+)~/,X=9,P=X+4,z=Object.prototype.toString;function S(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),p=new Uint8Array(g),I=0,N=0;I<v;I+=4){var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);p[N++]=G<<2|se>>4,p[N++]=(se&15)<<4|ae>>2,p[N++]=(ae&3)<<6|ce&63}return g}function M(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function H(a,u){var v="";if(a&&(v=z.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&z.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,p="__lfsc__:";a instanceof ArrayBuffer?(g=a,p+="arbf"):(g=a.buffer,v==="[object Int8Array]"?p+="si08":v==="[object Uint8Array]"?p+="ui08":v==="[object Uint8ClampedArray]"?p+="uic8":v==="[object Int16Array]"?p+="si16":v==="[object Uint16Array]"?p+="ur16":v==="[object Int32Array]"?p+="si32":v==="[object Uint32Array]"?p+="ui32":v==="[object Float32Array]"?p+="fl32":v==="[object Float64Array]"?p+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(p+M(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var N="~~local_forage_type~"+a.type+"~"+M(this.result);u("__lfsc__:blob"+N)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(N){console.error("Couldn't convert value into a JSON string: ",a),u(null,N)}}function $(a){if(a.substring(0,X)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(P),v=a.substring(X,P),g;if(v==="blob"&&D.test(u)){var p=u.match(D);g=p[1],u=u.substring(p[0].length)}var I=S(u);switch(v){case"arbf":return I;case"blob":return B([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var p=_(Object.keys(a)),I=p.next();!I.done;I=p.next()){var N=I.value;Object.prototype.hasOwnProperty.call(a,N)&&(a.isActiveClone=null,g[N]=m(a[N]),delete a.isActiveClone)}}catch(G){u={error:G}}finally{try{I&&!I.done&&(v=p.return)&&v.call(p)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function x(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function W(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Z(a,u){var v=this;if(u=W.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var p;return a.name?p=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):p=Promise.reject("Invalid arguments"),{promise:p,callback:u}}function F(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:M,deserialize:$,serialize:H,stringToBuffer:S},U={},fe=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return U[u]||(U[u]=new a(u)),U[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete U[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=w(u,this._defaultConfig),g=fe.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return x(v,a),v}function T(a,u){var v=Z.apply(this,arguments),g=v.promise,p=v.callback,I=g.then(function(N){fe.resolve(N).drop()});return x(I,p),g}function E(a,u){var v=this;a=F(a);var g=this.ready().then(function(){var p=v._dbInfo.mStore.get(a);return p==null?null:v._dbInfo.serializer.deserialize(p)});return x(g,u),g}function C(a,u){var v=this,g=this.ready().then(function(){for(var p=v._dbInfo.mStore,I=p.keys(),N=0;N<I.length;N++){var G=p.get(I[N]);if(G&&(G=v._dbInfo.serializer.deserialize(G)),G=a(G,I[N],N+1),G!==void 0)return G}});return x(g,u),g}function V(a,u){var v=this,g=this.ready().then(function(){var p;try{p=v._dbInfo.mStore.key(a),p===void 0&&(p=null)}catch{p=null}return p});return x(g,u),g}function j(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return x(v,a),v}function Q(a){var u=this.keys().then(function(v){return v.length});return x(u,a),u}function J(a,u){var v=this;a=F(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return x(g,u),g}function ee(a,u,v){var g=this;a=F(a);var p=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(N,G){g._dbInfo.serializer.serialize(u,function(se,ae){if(ae)G(ae);else try{g._dbInfo.mStore.set(a,se),N(I)}catch(ce){G(ce)}})})});return x(p,v),p}var ie=!0;b._support=ie,b._driver=R,b._initStorage=re,b.clear=h,b.dropInstance=T,b.getItem=E,b.iterate=C,b.key=V,b.keys=j,b.length=Q,b.removeItem=J,b.setItem=ee,Object.defineProperty(b,"__esModule",{value:!0})})});var pe=Ze(ke()),Ne=Ze(rr());import{SDKBase as ct,createSDK as lt}from"@magic-sdk/provider";import{createDuplicateIframeWarning as tt,createModalNotReadyError as nt,createURL as ot,ViewController as it}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as at}from"@magic-sdk/types";var ft={display:"block",visibility:"hidden",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function st(b){for(let[R,_]of Object.entries(ft))b.style[R]=_}function ut(b){let R=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(R.find(_=>_.src.includes(b)))}var ge=class extends it{constructor(){super(...arguments);this.activeElement=null}init(){this.test="hello",this.iframe=new Promise(_=>{let B=()=>{if(ut(encodeURIComponent(this.parameters)))tt().log();else{let D=document.createElement("iframe");D.classList.add("magic-iframe"),D.dataset.magicIframeLabel=ot(this.endpoint).host,D.title="Secure Modal",D.src=this.getRelayerSrc(),D.allow="clipboard-read; clipboard-write",st(D),document.body.appendChild(D),_(D)}};["loaded","interactive","complete"].includes(document.readyState)?B():window.addEventListener("load",B,!1)}),this.iframe.then(_=>{_ instanceof HTMLIFrameElement&&_.addEventListener("load",()=>oe(this,null,function*(){this.heartbeatDebounce()}))}),window.addEventListener("message",_=>{var B;if(_.origin===this.endpoint&&_.data.msgType&&(_.data.msgType.includes(at.MAGIC_PONG)&&(this.lastPongTime=Date.now()),_.data&&this.messageHandlers.size)){_.data.response=(B=_.data.response)!=null?B:{},this.stopHeartBeat();for(let D of this.messageHandlers.values())D(_)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}showOverlay(){return oe(this,null,function*(){let _=yield this.iframe;_.style.visibility="visible",_.style.zIndex="2147483647",_.style.opacity="1",this.activeElement=document.activeElement,_.focus()})}hideOverlay(){return oe(this,null,function*(){var B;let _=yield this.iframe;_.style.visibility="hidden",_.style.zIndex="-1",_.style.opacity="0",(B=this.activeElement)!=null&&B.focus&&this.activeElement.focus(),this.activeElement=null})}_post(_){return oe(this,null,function*(){let B=yield this.iframe;if(B&&B.contentWindow)B.contentWindow.postMessage(_,this.endpoint);else throw nt()})}checkRelayerExistsInDOM(){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(B=>B.src.includes(encodeURIComponent(this.parameters)))}reloadRelayer(){return oe(this,null,function*(){let _=yield this.iframe;this.stopHeartBeat(),_?_.src=this.getRelayerSrc():(this.init(),console.warn("Magic SDK: Modal lost, re-initiating"))})}};export*from"@magic-sdk/commons";var wt=lt(ct,{platform:"web",sdkName:"magic-sdk",version:"29.0.2",defaultEndpoint:"https://auth.magic.link/",ViewController:ge,configureStorage:()=>oe(void 0,null,function*(){let b=pe.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield b.defineDriver(Ne),yield b.setDriver([pe.default.INDEXEDDB,pe.default.LOCALSTORAGE,Ne._driver]),b})});export{wt as Magic};
|
2
2
|
//# sourceMappingURL=index.mjs.map
|