@arcana/auth
Version:
Arcana Auth
1 lines • 408 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).arcana=t.arcana||{},t.arcana.auth={}))}(this,(function(t){"use strict";function e(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}function n(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&1===Object.keys(t).length?t.default:t}var o={},s={},a=f;f.default=f,f.stable=y,f.stableStringify=y;var c="[...]",u="[Circular]",l=[],h=[];function d(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function f(t,e,n,r){var i;void 0===r&&(r=d()),g(t,"",0,[],void 0,0,r);try{i=0===h.length?JSON.stringify(t,e,n):JSON.stringify(t,w(e),n)}catch(t){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==l.length;){var o=l.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function p(t,e,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:t}),l.push([r,n,e,i])):h.push([e,n,t]):(r[n]=t,l.push([r,n,e]))}function g(t,e,n,r,i,o,s){var a;if(o+=1,"object"==typeof t&&null!==t){for(a=0;a<r.length;a++)if(r[a]===t)return void p(u,t,e,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void p(c,t,e,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void p(c,t,e,i);if(r.push(t),Array.isArray(t))for(a=0;a<t.length;a++)g(t[a],a,a,r,t,o,s);else{var l=Object.keys(t);for(a=0;a<l.length;a++){var h=l[a];g(t[h],h,a,r,t,o,s)}}r.pop()}}function m(t,e){return t<e?-1:t>e?1:0}function y(t,e,n,r){void 0===r&&(r=d());var i,o=b(t,"",0,[],void 0,0,r)||t;try{i=0===h.length?JSON.stringify(o,e,n):JSON.stringify(o,w(e),n)}catch(t){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==l.length;){var s=l.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function b(t,e,n,r,i,o,s){var a;if(o+=1,"object"==typeof t&&null!==t){for(a=0;a<r.length;a++)if(r[a]===t)return void p(u,t,e,i);try{if("function"==typeof t.toJSON)return}catch(t){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void p(c,t,e,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void p(c,t,e,i);if(r.push(t),Array.isArray(t))for(a=0;a<t.length;a++)b(t[a],a,a,r,t,o,s);else{var h={},d=Object.keys(t).sort(m);for(a=0;a<d.length;a++){var f=d[a];b(t[f],f,a,r,t,o,s),h[f]=t[f]}if(void 0===i)return h;l.push([i,e,t]),i[e]=h}r.pop()}}function w(t){return t=void 0!==t?t:function(t,e){return e},function(e,n){if(h.length>0)for(var r=0;r<h.length;r++){var i=h[r];if(i[1]===e&&i[0]===n){n=i[2],h.splice(r,1);break}}return t.call(this,e,n)}}Object.defineProperty(s,"__esModule",{value:!0}),s.EthereumProviderError=s.EthereumRpcError=void 0;const v=a;class _ extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==n&&(this.data=n)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data),this.stack&&(t.stack=this.stack),t}toString(){return v.default(this.serialize(),k,2)}}s.EthereumRpcError=_;function k(t,e){if("[Circular]"!==e)return e}s.EthereumProviderError=class extends _{constructor(t,e,n){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}};var S={},x={};Object.defineProperty(x,"__esModule",{value:!0}),x.errorValues=x.errorCodes=void 0,x.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},x.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=x,n=s,r=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",o={code:r,message:a(r)};function a(n,r=i){if(Number.isInteger(n)){const r=n.toString();if(h(e.errorValues,r))return e.errorValues[r].message;if(u(n))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function c(t){if(!Number.isInteger(t))return!1;const n=t.toString();return!!e.errorValues[n]||!!u(t)}function u(t){return t>=-32099&&t<=-32e3}function l(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",t.getMessageFromCode=a,t.isValidCode=c,t.serializeError=function(t,{fallbackError:e=o,shouldIncludeStack:r=!1}={}){var i,s;if(!e||!Number.isInteger(e.code)||"string"!=typeof e.message)throw new Error("Must provide fallback error with integer number code and string message.");if(t instanceof n.EthereumRpcError)return t.serialize();const u={};if(t&&"object"==typeof t&&!Array.isArray(t)&&h(t,"code")&&c(t.code)){const e=t;u.code=e.code,e.message&&"string"==typeof e.message?(u.message=e.message,h(e,"data")&&(u.data=e.data)):(u.message=a(u.code),u.data={originalError:l(t)})}else{u.code=e.code;const n=null===(i=t)||void 0===i?void 0:i.message;u.message=n&&"string"==typeof n?n:e.message,u.data={originalError:l(t)}}const d=null===(s=t)||void 0===s?void 0:s.stack;return r&&t&&d&&"string"==typeof d&&(u.stack=d),u}}(S);var E={};Object.defineProperty(E,"__esModule",{value:!0}),E.ethErrors=void 0;const I=s,A=S,B=x;function P(t,e){const[n,r]=M(e);return new I.EthereumRpcError(t,n||A.getMessageFromCode(t),r)}function T(t,e){const[n,r]=M(e);return new I.EthereumProviderError(t,n||A.getMessageFromCode(t),r)}function M(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}E.ethErrors={rpc:{parse:t=>P(B.errorCodes.rpc.parse,t),invalidRequest:t=>P(B.errorCodes.rpc.invalidRequest,t),invalidParams:t=>P(B.errorCodes.rpc.invalidParams,t),methodNotFound:t=>P(B.errorCodes.rpc.methodNotFound,t),internal:t=>P(B.errorCodes.rpc.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return P(e,t)},invalidInput:t=>P(B.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>P(B.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>P(B.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>P(B.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>P(B.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>P(B.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>T(B.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>T(B.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>T(B.errorCodes.provider.unsupportedMethod,t),disconnected:t=>T(B.errorCodes.provider.disconnected,t),chainDisconnected:t=>T(B.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new I.EthereumProviderError(e,n,r)}}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=s;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const n=S;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=E;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=x;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(o);var C,O={},R={exports:{}},L="object"==typeof Reflect?Reflect:null,N=L&&"function"==typeof L.apply?L.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};C=L&&"function"==typeof L.ownKeys?L.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var U=Number.isNaN||function(t){return t!=t};function z(){z.init.call(this)}R.exports=z,R.exports.once=function(t,e){return new Promise((function(n,r){function i(n){t.removeListener(e,o),r(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}G(t,e,o,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&G(t,"error",e,n)}(t,i,{once:!0})}))},z.EventEmitter=z,z.prototype._events=void 0,z.prototype._eventsCount=0,z.prototype._maxListeners=void 0;var $=10;function W(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function F(t){return void 0===t._maxListeners?z.defaultMaxListeners:t._maxListeners}function D(t,e,n,r){var i,o,s,a;if(W(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]),void 0===s)s=o[e]=n,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=F(t))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return t}function j(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function q(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=j.bind(r);return i.listener=n,r.wrapFn=i,i}function K(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):V(i,i.length)}function H(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function V(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function G(t,e,n,r){if("function"==typeof t.on)r.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){r.once&&t.removeEventListener(e,i),n(o)}))}}Object.defineProperty(z,"defaultMaxListeners",{enumerable:!0,get:function(){return $},set:function(t){if("number"!=typeof t||t<0||U(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");$=t}}),z.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},z.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||U(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},z.prototype.getMaxListeners=function(){return F(this)},z.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)N(a,this,e);else{var c=a.length,u=V(a,c);for(n=0;n<c;++n)N(u[n],this,e)}return!0},z.prototype.addListener=function(t,e){return D(this,t,e,!1)},z.prototype.on=z.prototype.addListener,z.prototype.prependListener=function(t,e){return D(this,t,e,!0)},z.prototype.once=function(t,e){return W(e),this.on(t,q(this,t,e)),this},z.prototype.prependOnceListener=function(t,e){return W(e),this.prependListener(t,q(this,t,e)),this},z.prototype.removeListener=function(t,e){var n,r,i,o,s;if(W(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},z.prototype.off=z.prototype.removeListener,z.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},z.prototype.listeners=function(t){return K(this,t,!0)},z.prototype.rawListeners=function(t){return K(this,t,!1)},z.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):H.call(t,e)},z.prototype.listenerCount=H,z.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]},Object.defineProperty(O,"__esModule",{value:!0});const J=R.exports;function Z(t,e,n){try{Reflect.apply(t,e,n)}catch(t){setTimeout((()=>{throw t}))}}class Y extends J.EventEmitter{emit(t,...e){let n="error"===t;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let t;if(e.length>0&&([t]=e),t instanceof Error)throw t;const n=new Error("Unhandled error."+(t?` (${t.message})`:""));throw n.context=t,n}const i=r[t];if(void 0===i)return!1;if("function"==typeof i)Z(i,this,e);else{const t=i.length,n=function(t){const e=t.length,n=new Array(e);for(let r=0;r<e;r+=1)n[r]=t[r];return n}(i);for(let r=0;r<t;r+=1)Z(n[r],this,e)}return!0}}var X=O.default=Y;class Q extends Error{constructor(t,e){super(t),this.message=e,this.message=`[XAR_AUTH_SDK] error: [${t}] ${e}`}}const tt=new Q("user_not_logged_in","User is not logged in"),et=new Q("wallet_not_initialized","AuthProvider is not initialized. Please run `await auth.init(...)` before calling functions"),nt=new class{constructor(t,e){this.message=`[XAR_AUTH_SDK] warning: [${t}] ${e}`}log(){console.warn(this.message)}}("duplicate_iframe","Duplicate iframe detected, please keep a single instance of AuthProvider"),rt=1,it=2,ot=3,st=4,at=5,ct=t=>{ht.exceptionReporter&&ht.exceptionReporter(t)},ut=t=>{ht.logLevel=t},lt=()=>ht.logger;const ht={logger:new class{constructor(){this.prefix="[XAR_AUTH_SDK]"}info(t,e={}){this.internalLog(it,t,e)}debug(t,e={}){this.internalLog(rt,t,e)}warn(t,e={}){this.internalLog(ot,t,e)}error(t,e){if(e instanceof Error)return this.internalLog(st,t,e.message),void ct(JSON.stringify({message:t,error:e.message}));"string"==typeof e&&(this.internalLog(st,t,e),ct(JSON.stringify({message:t,error:e})))}internalLog(t,e,n){const r=`${this.prefix}\nMessage: ${e} \nParams: ${JSON.stringify(n)}`;this.consoleLog(t,r)}consoleLog(t,e){if(!(t<ht.logLevel))switch(t){case rt:console.debug(e);break;case ot:console.warn(e);break;case st:console.error(e);break;case it:console.info(e);break;default:console.log(e)}}},logLevel:at,exceptionReporter:null};class dt{constructor(t){this.url=t,this.requestHandler=()=>new Promise((t=>{let e=!1;const r=window.setInterval((()=>{var n;try{if(!e&&(null===(n=this.window)||void 0===n?void 0:n.closed))return t({id:1,jsonrpc:"2.0",error:"user_closed_popup"})}catch(t){}}),500),i=o=>n(this,void 0,void 0,(function*(){var n;if("json_rpc_response"==o.data.type)return e=!0,this.clear(i,r),null===(n=this.window)||void 0===n||n.close(),t(o.data.response)}));window.addEventListener("message",i,!1)}))}open(){const t=pt();return this.window=window.open(this.url,"_blank",t),this.getWindowResponse()}getWindowResponse(){return new Promise(((t,e)=>{let r=!1;const i=window.setInterval((()=>{var t;!r&&(null===(t=this.window)||void 0===t?void 0:t.closed)&&e("User closed the popup")}),500),o=s=>n(this,void 0,void 0,(function*(){var n,a,c;if(!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n.status))return;const u=s.data;return r=!0,this.clear(o,i),"success"===u.status?(null===(a=this.window)||void 0===a||a.close(),t("success")):"error"==u.status?(null===(c=this.window)||void 0===c||c.close(),e(u.error)):"done"===u.status?t("done"):void console.log("Unexpected event")}));window.addEventListener("message",o,!1)}))}clear(t,e){window.removeEventListener("message",t),window.clearInterval(e)}}const ft={titlebar:0,toolbar:0,status:0,menubar:0,resizable:0,height:1200,width:700,popup:1},pt=()=>{const t=[];for(const e in ft)t.push(`${e}=${ft[e]}`);return t.join(",")};class gt{constructor(t){this.url=t,this.requestCount=0,this.emitter=new X,this.ready=!1,this.cleanExit=!1,this.requestHandler=t=>new Promise((e=>{this.cleanExit=!1;const n=window.setInterval((()=>{var r;try{(null===(r=this.window)||void 0===r?void 0:r.closed)&&(this.cleanExit||this.emitter.emit(t,{id:t,jsonrpc:"2.0",error:"user_closed_popup"}),window.clearInterval(n),e("ok"))}catch(t){}}),500)})),this.handler=t=>n(this,void 0,void 0,(function*(){"json_rpc_response"==t.data.type&&(this.cleanExit=!0,this.emitter.emit(t.data.response.id,t.data.response))}))}sendRequest(t){return n(this,void 0,void 0,(function*(){if(this.window||(this.ready=!1,this.requestCount=0,this.window=window.open(this.url,"_blank",pt()),yield mt(),window.addEventListener("message",this.handler,!1)),this.window){this.requestCount++,this.window.postMessage({type:"json_rpc_request",data:t},this.url),this.window.focus(),this.requestHandler(String(t.request.id));return yield new Promise((e=>this.emitter.once(String(t.request.id),(t=>{var n;return this.requestCount--,this.requestCount<=0&&(window.removeEventListener("message",this.handler),null===(n=this.window)||void 0===n||n.close(),this.window=null),e(t)}))))}throw Error("error while opening popup")}))}}const mt=()=>new Promise((t=>{const e=n=>{"READY_TO_RECEIVE"===n.data.type&&(window.removeEventListener("message",e),t("ok"))};window.addEventListener("message",e,!1)})),yt="data:image/svg+xml,%3Csvg width='116' height='116' viewBox='0 0 116 116' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M115.341 58.0094C115.341 89.6796 89.6673 115.354 57.9967 115.354C26.3265 115.354 0.652344 89.6796 0.652344 58.0094C0.652344 26.3392 26.3265 0.665039 57.9967 0.665039C89.6673 0.665039 115.341 26.3392 115.341 58.0094Z' fill='%23B43030'/%3E%3Cpath d='M78.7969 37.2041L37.1953 78.8057' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M78.7969 78.8057L37.1953 37.2041' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A",bt=t=>"string"==typeof t&&t.trim().length>0,wt=t=>40===_t(t).length,vt="0x",_t=t=>t.startsWith(vt)?t.substring(2):t,kt=(t,e=!0)=>{const n=t.toString(16);return e?(t=>t.startsWith(vt)?t:vt+t)(n):_t(n)},St=()=>window.location.origin+window.location.pathname,xt=4294967295;let Et=Math.floor(Math.random()*xt);function It(t){return String.fromCharCode(parseInt(t.slice(1),16))}function At(t){return e=JSON.stringify(t),window.btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,It));var e}class Bt extends Error{constructor(t,e,n=""){super(e),this.code=t,this.message=e,this.data=n}}class Pt extends X{constructor(t){super(),this.authUrl=t,this.connected=!1,this.logger=lt(),this.onResponse=(t,e)=>{this.subscriber.emit(`result:${t}:${e.id}`,e)},this.handleEvents=(t,e)=>{switch(t){case Tt.ACCOUNTS_CHANGED:this.emit(t,[e]);break;case Tt.CHAIN_CHANGED:this.setChainId(e),this.emit(t,kt(e.chainId));break;case Tt.CONNECT:this.chainId="object"==typeof e?e.chainId:"",this.connected=!0,this.emit(t,e);break;case Tt.DISCONNECT:this.iframe.handleDisconnect(),this.connected=!1,this.emit(t,e);break;case Tt.MESSAGE:console.log({t:t,val:e}),this.emit(t,e)}},this.subscriber=new X}isArcana(){return!0}init(t,e){return n(this,void 0,void 0,(function*(){this.auth=e,this.popup=new gt(this.createRequestUrl(e.appId)),this.iframe=t;const{communication:n}=yield this.iframe.setConnectionMethods({onEvent:this.handleEvents,onMethodResponse:this.onResponse,getParentUrl:St,getAppMode:()=>this.iframe.appMode,getAppConfig:this.iframe.getAppConfig,getWalletPosition:this.iframe.getWalletPlace,getRpcConfig:()=>{},sendPendingRequestCount:this.iframe.onReceivingPendingRequestCount,triggerSocialLogin:e.loginWithSocial,triggerPasswordlessLogin:e.loginWithLink,getPopupState:()=>this.iframe.getState(),setIframeStyle:this.iframe.setIframeStyle,setSessionID:this.iframe.setSessionID,getSDKVersion:()=>"v3"});this.communication=n}))}isLoggedIn(){return n(this,void 0,void 0,(function*(){try{return(yield this.getCommunication("isLoggedIn")).isLoggedIn()}catch(t){return this.logger.error("isLoggedIn",t),!1}}))}connect(){return this.auth.connect()}isConnected(){return n(this,void 0,void 0,(function*(){return this.connected}))}isLoginAvailable(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("isLoginAvailable"),n=yield e.isLoginAvailable(t);return this.logger.debug("loginAvailable",{[t]:n}),n}))}initCustomLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("triggerCustomLogin");return yield e.triggerCustomLogin(t)}))}requestUserInfo(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getUserInfo");if(!(yield t.isLoggedIn()))throw tt;return yield t.getUserInfo()}))}getReconnectionUrl(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getReconnectionUrl");return yield t.getReconnectionUrl()}))}initOTPLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("initOTPLogin");return yield e.initOTPLogin(t)}))}completeOTPLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("completeOTPLogin");yield e.completeOTPLogin(t)}))}getPublicKey(t,e){return n(this,void 0,void 0,(function*(){return(yield this.getCommunication("getPublicKey")).getPublicKey(t,e)}))}getAvailableLogins(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getAvailableLogins");return yield t.getAvailableLogins()}))}logout(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("logout");yield t.logout()}))}initPasswordlessLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("initPasswordlessLogin");return yield e.initPasswordlessLogin(t)}))}initSocialLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("initSocialLogin");return yield e.initSocialLogin(t)}))}expandWallet(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("expandWallet");return yield t.expandWallet()}))}getKeySpaceConfigType(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getKeySpaceConfigType");return yield t.getKeySpaceConfigType()}))}getCommunication(t="sendRequest"){return n(this,void 0,void 0,(function*(){if(this.communication){const e=yield this.communication.promise;if(!e[t])throw new Q("fn_not_available",`The requested fn ${t} is not available in this context`);return e}throw new Q("connection_not_available","The connection is not available yet")}))}request(t){return n(this,void 0,void 0,(function*(){if(!t||"object"!=typeof t||Array.isArray(t))throw o.ethErrors.rpc.invalidRequest({message:"Invalid request arguments",data:t});const{method:e,params:r}=t;if(!e)throw o.ethErrors.rpc.invalidRequest({message:"Invalid method argument",data:t});const i={method:e,params:r,jsonrpc:"2.0",id:(Et=(Et+1)%xt,Et)};return new Promise(((t,r)=>{this.getCommunication().then((o=>n(this,void 0,void 0,(function*(){this.getResponse(e,i.id).then(t,r),yield o.sendRequest(i)}))),r)}))}))}getResponse(t,e){return new Promise(((n,r)=>{this.subscriber.once(`result:${t}:${e}`,(t=>t.error?r(Mt(t.error)):n(t.result)))}))}createRequestUrl(t){return new URL(`/${t}/permission/`,this.authUrl).href}setChainId(t){t&&"object"==typeof t&&"chainId"in t&&"number"==typeof t.chainId&&(this.chainId=kt(t.chainId))}}const Tt={ACCOUNTS_CHANGED:"accountsChanged",CHAIN_CHANGED:"chainChanged",CONNECT:"connect",DISCONNECT:"disconnect",MESSAGE:"message"},Mt=t=>{switch(lt().error("getError",t),t){case"user_deny":return new Bt(4001,"User rejected the request.");case"user_closed_popup":return new Bt(4001,"User closed the popup.");case"operation_not_supported":return new Bt(4200,"The requested method is not supported by this provider.");case"all_disconnected":return new Bt(4900,"The provider is disconnected from all chains. Login is pending.");default:return"string"!=typeof t?new Bt(t.code,t.message,t.data):o.ethErrors.rpc.internal(t)}};var Ct,Ot,Rt,Lt,Nt,Ut,zt,$t;!function(t){t[t.CREATED=0]="CREATED",t[t.RUNNING=1]="RUNNING",t[t.DONE=2]="DONE"}(Ct||(Ct={})),function(t){t.evm_secp256k1="evm_secp256k1",t.solana_cv25519="solana_cv25519"}(Ot||(Ot={})),t.BearerAuthentication=void 0,(t.BearerAuthentication||(t.BearerAuthentication={})).firebase="firebase",function(t){t[t.NoUI=0]="NoUI",t[t.Widget=1]="Widget",t[t.Full=2]="Full"}(Rt||(Rt={})),function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"}(Lt||(Lt={})),function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"}(Nt||(Nt={})),function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NoIframeSrc="NoIframeSrc"}(Ut||(Ut={})),function(t){t.DataCloneError="DataCloneError"}(zt||(zt={})),function(t){t.Message="message"}($t||($t={}));const Wt={"http:":"80","https:":"443"},Ft=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,Dt=["file:","data:"];const jt=({name:t,message:e,stack:n})=>({name:t,message:e,stack:n});let qt=0;var Kt=()=>++qt;const Ht=t=>t?t.split("."):[],Vt=(t,e,n)=>{const r=Ht(e);return r.reduce(((t,e,i)=>(void 0===t[e]&&(t[e]={}),i===r.length-1&&(t[e]=n),t[e])),t),t},Gt=(t,e)=>{const n={};return Object.keys(t).forEach((r=>{const i=t[r],o=((t,e)=>{const n=Ht(e||"");return n.push(t),(t=>t.join("."))(n)})(r,e);"object"==typeof i&&Object.assign(n,Gt(i,o)),"function"==typeof i&&(n[o]=i)})),n};var Jt=(t,e,n,r,i)=>{const{localName:o,local:s,remote:a,originForSending:c,originForReceiving:u}=e;let l=!1;i(`${o}: Connecting call sender`);const h=t=>(...e)=>{let n;i(`${o}: Sending ${t}() call`);try{a.closed&&(n=!0)}catch(t){n=!0}if(n&&r(),l){const e=new Error(`Unable to send ${t}() call due to destroyed connection`);throw e.code=Ut.ConnectionDestroyed,e}return new Promise(((n,r)=>{const l=Kt(),h=e=>{if(e.source!==a||e.data.penpal!==Lt.Reply||e.data.id!==l)return;if("*"!==u&&e.origin!==u)return void i(`${o} received message from origin ${e.origin} which did not match expected origin ${u}`);const c=e.data;i(`${o}: Received ${t}() reply`),s.removeEventListener($t.Message,h);let d=c.returnValue;c.returnValueIsError&&(d=(t=>{const e=new Error;return Object.keys(t).forEach((n=>e[n]=t[n])),e})(d)),(c.resolution===Nt.Fulfilled?n:r)(d)};s.addEventListener($t.Message,h);const d={penpal:Lt.Call,id:l,methodName:t,args:e};a.postMessage(d,c)}))},d=n.reduce(((t,e)=>(t[e]=h(e),t)),{});return Object.assign(t,(t=>{const e={};for(const n in t)Vt(e,n,t[n]);return e})(d)),()=>{l=!0}},Zt=(t,e,n,r,i)=>{const{destroy:o,onDestroy:s}=r;let a,c;const u={};return r=>{if("*"!==e&&r.origin!==e)return void i(`Parent: Handshake - Received ACK message from origin ${r.origin} which did not match expected origin ${e}`);i("Parent: Handshake - Received ACK");const l={localName:"Parent",local:window,remote:r.source,originForSending:n,originForReceiving:e};a&&a(),a=((t,e,n)=>{const{localName:r,local:i,remote:o,originForSending:s,originForReceiving:a}=t;let c=!1;const u=t=>{if(t.source!==o||t.data.penpal!==Lt.Call)return;if("*"!==a&&t.origin!==a)return void n(`${r} received message from origin ${t.origin} which did not match expected origin ${a}`);const i=t.data,{methodName:u,args:l,id:h}=i;n(`${r}: Received ${u}() call`);const d=t=>e=>{if(n(`${r}: Sending ${u}() reply`),c)return void n(`${r}: Unable to send ${u}() reply due to destroyed connection`);const i={penpal:Lt.Reply,id:h,resolution:t,returnValue:e};t===Nt.Rejected&&e instanceof Error&&(i.returnValue=jt(e),i.returnValueIsError=!0);try{o.postMessage(i,s)}catch(t){if(t.name===zt.DataCloneError){const e={penpal:Lt.Reply,id:h,resolution:Nt.Rejected,returnValue:jt(t),returnValueIsError:!0};o.postMessage(e,s)}throw t}};new Promise((t=>t(e[u].apply(e,l)))).then(d(Nt.Fulfilled),d(Nt.Rejected))};return i.addEventListener($t.Message,u),()=>{c=!0,i.removeEventListener($t.Message,u)}})(l,t,i),s(a),c&&c.forEach((t=>{delete u[t]})),c=r.data.methodNames;const h=Jt(u,l,c,o,i);return s(h),u}};var Yt=t=>{let{iframe:e,methods:n={},childOrigin:r,timeout:i,debug:o=!1}=t;const s=(t=>(...e)=>{t&&console.log("[Penpal]",...e)})(o),a=((t,e)=>{const n=[];let r=!1;return{destroy(i){r||(r=!0,e(`${t}: Destroying connection`),n.forEach((t=>{t(i)})))},onDestroy(t){r?t():n.push(t)}}})("Parent",s),{onDestroy:c,destroy:u}=a;r||((t=>{if(!t.src&&!t.srcdoc){const t=new Error("Iframe must have src or srcdoc property defined.");throw t.code=Ut.NoIframeSrc,t}})(e),r=(t=>{if(t&&Dt.find((e=>t.startsWith(e))))return"null";const e=document.location,n=Ft.exec(t);let r,i,o;return n?(r=n[1]?n[1]:e.protocol,i=n[2],o=n[4]):(r=e.protocol,i=e.hostname,o=e.port),`${r}//${i}${o&&o!==Wt[r]?`:${o}`:""}`})(e.src));const l="null"===r?"*":r,h=Gt(n),d=((t,e,n,r)=>i=>{if(!i.source)return;if("*"!==n&&i.origin!==n)return void t(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${n}`);t("Parent: Handshake - Received SYN, responding with SYN-ACK");const o={penpal:Lt.SynAck,methodNames:Object.keys(e)};i.source.postMessage(o,r)})(s,h,r,l),f=Zt(h,r,l,a,s),p=new Promise(((t,n)=>{const r=((t,e)=>{let n;return void 0!==t&&(n=window.setTimeout((()=>{const n=new Error(`Connection timed out after ${t}ms`);n.code=Ut.ConnectionTimeout,e(n)}),t)),()=>{clearTimeout(n)}})(i,u),o=n=>{if(n.source===e.contentWindow&&n.data)if(n.data.penpal!==Lt.Syn)if(n.data.penpal!==Lt.Ack);else{const e=f(n);e&&(r(),t(e))}else d(n)};window.addEventListener($t.Message,o),s("Parent: Awaiting handshake"),((t,e)=>{const{destroy:n,onDestroy:r}=e,i=setInterval((()=>{t.isConnected||(clearInterval(i),n())}),6e4);r((()=>{clearInterval(i)}))})(e,a),c((t=>{window.removeEventListener($t.Message,o),t&&n(t)}))}));return{promise:p,destroy(){u()}}};const Xt={border:"none",position:"fixed",height:0,width:0,right:0,bottom:0,zIndex:2147483648},Qt="xar-wallet";class te{constructor(t){this.params=t,this.getSessionID=()=>{const t=window.localStorage.getItem(`arcana-auth-${this.getIframeUrl()}-sessionID`);return t?JSON.parse(t):null},this.setSessionID=(t,e)=>{window.localStorage.setItem(`arcana-auth-${this.getIframeUrl()}-sessionID`,JSON.stringify({id:t,expiry:e}))},this.clearSessionID=()=>{window.localStorage.removeItem(`arcana-auth-${this.getIframeUrl()}-sessionID`)},this.setIframeStyle=t=>{var e;if(1==(null===(e=this.params.standaloneMode)||void 0===e?void 0:e.mode))this.widgetIframe.style.height=t.height?t.height:"80vh",this.widgetIframe.style.maxWidth="100%",this.widgetIframe.style.width="430px",this.widgetIframe.style.bottom="0",this.widgetIframe.style.right="0";else for(const e in t)this.widgetIframe.style[e]=t[e]},this.getWalletPlace=()=>this.params.position,this.getAppConfig=()=>this.params.appConfig,this.checkDuplicateIframe(),this.checkSecureOrigin()}setConnectionMethods(t){return n(this,void 0,void 0,(function*(){try{return this.iframeCommunication||(this.iframeCommunication=Yt({iframe:this.widgetIframe,methods:Object.assign(Object.assign({},t),{uiEvent:(t,e)=>{var n;(null===(n=this.params.standaloneMode)||void 0===n?void 0:n.handler)&&this.params.standaloneMode.handler(t,e)}}),childOrigin:this.params.iframeUrl}),yield this.iframeCommunication.promise),{iframe:this.widgetIframe,communication:this.iframeCommunication}}catch(t){throw new Error("Could not set connection methods")}}))}triggerBearerAuthentication(t,e){return n(this,void 0,void 0,(function*(){return(yield this.iframeCommunication.promise).triggerBearerLogin(t,e)}))}setWalletType(t){this.appMode=null!=t?t:Rt.Full,this.initWalletUI()}getState(){return this.state}handleDisconnect(){this.clearSessionID()}onReceivingPendingRequestCount(t){const e=document.getElementById("req-count-badge");e&&(t>0?(e.style.display="flex",e.textContent=`${t}`):e.style.display="none")}getIframeUrl(){var t,e;const n=At({standaloneMode:(null===(t=this.params.standaloneMode)||void 0===t?void 0:t.mode)?null===(e=this.params.standaloneMode)||void 0===e?void 0:e.mode:0}),r=new URL(`/${this.params.appId}/v2/login`,this.params.iframeUrl);return r.hash=n,r.toString()}createWidgetIframe(){return((t,e,...n)=>{const r=document.createElement(t);e&&(Object.assign(r,e),e.style&&Object.assign(r.style,e.style));for(const t of n)"string"!=typeof t?r.appendChild(t):r.appendChild(document.createTextNode(t));return r})("iframe",{style:Xt,src:this.getIframeUrl(),allow:"clipboard-write",className:Qt})}checkDuplicateIframe(){[].slice.call(document.querySelectorAll(`.${Qt}`)).length>0&&nt.log()}initWalletUI(){this.widgetIframe=this.createWidgetIframe(),document.body.appendChild(this.widgetIframe)}checkSecureOrigin(){const t="localhost"===location.hostname||"127.0.0.1"===location.hostname,e="https:"===location.protocol;if(!(t||e))throw new Error("Insecure origin")}}const ee={authUrl:"https://verify.dev.arcana.network",gatewayUrl:"https://gateway-dev.arcana.network",walletUrl:"https://wallet.dev.arcana.network"},ne={authUrl:"https://verify.beta.arcana.network",gatewayUrl:"https://gateway001-testnet.arcana.network",walletUrl:"https://wallet.beta.arcana.network"},re={authUrl:"https://auth.arcana.network",gatewayUrl:"https://gateway.arcana.network",walletUrl:"https://wallet.arcana.network"};function ie(t,e){return n(this,void 0,void 0,(function*(){const n=new URL(`/api/v1/get-app-theme/?id=${t}`,e);return yield(yield fetch(n.toString())).json()}))}function oe(t,e){return n(this,void 0,void 0,(function*(){const n=new URL(`/api/v1/get-app-config/?id=${t}`,e);return yield(yield fetch(n.toString())).json()}))}var se,ae,ce,ue,le,he,de,fe,pe,ge,me={},ye=[],be=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,we=Array.isArray;function ve(t,e){for(var n in e)t[n]=e[n];return t}function _e(t){var e=t.parentNode;e&&e.removeChild(t)}function ke(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++ce:i,__i:-1,__u:0};return null==i&&null!=ae.vnode&&ae.vnode(o),o}function Se(t){return t.children}function xe(t,e){this.props=t,this.context=e}function Ee(t,e){if(null==e)return t.__?Ee(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?Ee(t):null}function Ie(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return Ie(t)}}function Ae(t){(!t.__d&&(t.__d=!0)&&ue.push(t)&&!Be.__r++||le!==ae.debounceRendering)&&((le=ae.debounceRendering)||he)(Be)}function Be(){var t,e,n,r,i,o,s,a;for(ue.sort(de);t=ue.shift();)t.__d&&(e=ue.length,r=void 0,o=(i=(n=t).__v).__e,s=[],a=[],n.__P&&((r=ve({},i)).__v=i.__v+1,ae.vnode&&ae.vnode(r),Ne(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[o]:null,s,null==o?Ee(i):o,!!(32&i.__u),a),r.__v=i.__v,r.__.__k[r.__i]=r,Ue(s,r,a),r.__e!=o&&Ie(r)),ue.length>e&&ue.sort(de));Be.__r=0}function Pe(t,e,n,r,i,o,s,a,c,u,l){var h,d,f,p,g,m=r&&r.__k||ye,y=e.length;for(n.__d=c,Te(n,e,m),c=n.__d,h=0;h<y;h++)null!=(f=n.__k[h])&&"boolean"!=typeof f&&"function"!=typeof f&&(d=-1===f.__i?me:m[f.__i]||me,f.__i=h,Ne(t,f,d,i,o,s,a,c,u,l),p=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&$e(d.ref,null,f),l.push(f.ref,f.__c||p,f)),null==g&&null!=p&&(g=p),65536&f.__u||d.__k===f.__k?(c&&"string"==typeof f.type&&!t.contains(c)&&(c=Ee(d)),c=Me(f,c,t)):"function"==typeof f.type&&void 0!==f.__d?c=f.__d:p&&(c=p.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=c,n.__e=g}function Te(t,e,n){var r,i,o,s,a,c=e.length,u=n.length,l=u,h=0;for(t.__k=[],r=0;r<c;r++)s=r+h,null!=(i=t.__k[r]=null==(i=e[r])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?ke(null,i,null,null,null):we(i)?ke(Se,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?ke(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=t,i.__b=t.__b+1,a=Ce(i,n,s,l),i.__i=a,o=null,-1!==a&&(l--,(o=n[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&h--,"function"!=typeof i.type&&(i.__u|=65536)):a!==s&&(a==s-1?h=a-s:a==s+1?h++:a>s?l>c-s?h+=a-s:h--:a<s&&h++,a!==r+h&&(i.__u|=65536))):(o=n[s])&&null==o.key&&o.__e&&!(131072&o.__u)&&(o.__e==t.__d&&(t.__d=Ee(o)),We(o,o,!1),n[s]=null,l--);if(l)for(r=0;r<u;r++)null!=(o=n[r])&&!(131072&o.__u)&&(o.__e==t.__d&&(t.__d=Ee(o)),We(o,o))}function Me(t,e,n){var r,i;if("function"==typeof t.type){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=Me(r[i],e,n));return e}t.__e!=e&&(n.insertBefore(t.__e,e||null),e=t.__e);do{e=e&&e.nextSibling}while(null!=e&&8===e.nodeType);return e}function Ce(t,e,n,r){var i=t.key,o=t.type,s=n-1,a=n+1,c=e[n];if(null===c||c&&i==c.key&&o===c.type&&!(131072&c.__u))return n;if(r>(null==c||131072&c.__u?0:1))for(;s>=0||a<e.length;){if(s>=0){if((c=e[s])&&!(131072&c.__u)&&i==c.key&&o===c.type)return s;s--}if(a<e.length){if((c=e[a])&&!(131072&c.__u)&&i==c.key&&o===c.type)return a;a++}}return-1}function Oe(t,e,n){"-"===e[0]?t.setProperty(e,null==n?"":n):t[e]=null==n?"":"number"!=typeof n||be.test(e)?n:n+"px"}function Re(t,e,n,r,i){var o;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof r&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Oe(t.style,e,"");if(n)for(e in n)r&&n[e]===r[e]||Oe(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in t||"onFocusOut"===e||"onFocusIn"===e?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n.u=r.u:(n.u=fe,t.addEventListener(e,o?ge:pe,o)):t.removeEventListener(e,o?ge:pe,o);else{if("http://www.w3.org/2000/svg"==i)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=e&&"height"!=e&&"href"!=e&&"list"!=e&&"form"!=e&&"tabIndex"!=e&&"download"!=e&&"rowSpan"!=e&&"colSpan"!=e&&"role"!=e&&"popover"!=e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null==n||!1===n&&"-"!==e[4]?t.removeAttribute(e):t.setAttribute(e,"popover"==e&&1==n?"":n))}}function Le(t){return function(e){if(this.l){var n=this.l[e.type+t];if(null==e.t)e.t=fe++;else if(e.t<n.u)return;return n(ae.event?ae.event(e):e)}}}function Ne(t,e,n,r,i,o,s,a,c,u){var l,h,d,f,p,g,m,y,b,w,v,_,k,S,x,E,I=e.type;if(void 0!==e.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=e.__e=n.__e]),(l=ae.__b)&&l(e);t:if("function"==typeof I)try{if(y=e.props,b="prototype"in I&&I.prototype.render,w=(l=I.contextType)&&r[l.__c],v=l?w?w.props.value:l.__:r,n.__c?m=(h=e.__c=n.__c).__=h.__E:(b?e.__c=h=new I(y,v):(e.__c=h=new xe(y,v),h.constructor=I,h.render=Fe),w&&w.sub(h),h.props=y,h.state||(h.state={}),h.context=v,h.__n=r,d=h.__d=!0,h.__h=[],h._sb=[]),b&&null==h.__s&&(h.__s=h.state),b&&null!=I.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=ve({},h.__s)),ve(h.__s,I.getDerivedStateFromProps(y,h.__s))),f=h.props,p=h.state,h.__v=e,d)b&&null==I.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),b&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(b&&null==I.getDerivedStateFromProps&&y!==f&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(y,v),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(y,h.__s,v)||e.__v===n.__v)){for(e.__v!==n.__v&&(h.props=y,h.state=h.__s,h.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.forEach((function(t){t&&(t.__=e)})),_=0;_<h._sb.length;_++)h.__h.push(h._sb[_]);h._sb=[],h.__h.length&&s.push(h);break t}null!=h.componentWillUpdate&&h.componentWillUpdate(y,h.__s,v),b&&null!=h.componentDidUpdate&&h.__h.push((function(){h.componentDidUpdate(f,p,g)}))}if(h.context=v,h.props=y,h.__P=t,h.__e=!1,k=ae.__r,S=0,b){for(h.state=h.__s,h.__d=!1,k&&k(e),l=h.render(h.props,h.state,h.context),x=0;x<h._sb.length;x++)h.__h.push(h._sb[x]);h._sb=[]}else do{h.__d=!1,k&&k(e),l=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++S<25);h.state=h.__s,null!=h.getChildContext&&(r=ve(ve({},r),h.getChildContext())),b&&!d&&null!=h.getSnapshotBeforeUpdate&&(g=h.getSnapshotBeforeUpdate(f,p)),Pe(t,we(E=null!=l&&l.type===Se&&null==l.key?l.props.children:l)?E:[E],e,n,r,i,o,s,a,c,u),h.base=e.__e,e.__u&=-161,h.__h.length&&s.push(h),m&&(h.__E=h.__=null)}catch(t){e.__v=null,c||null!=o?(e.__e=a,e.__u|=c?160:32,o[o.indexOf(a)]=null):(e.__e=n.__e,e.__k=n.__k),ae.__e(t,e,n)}else null==o&&e.__v===n.__v?(e.__k=n.__k,e.__e=n.__e):e.__e=ze(n.__e,e,n,r,i,o,s,c,u);(l=ae.diffed)&&l(e)}function Ue(t,e,n){e.__d=void 0;for(var r=0;r<n.length;r++)$e(n[r],n[++r],n[++r]);ae.__c&&ae.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){ae.__e(t,e.__v)}}))}function ze(t,e,n,r,i,o,s,a,c){var u,l,h,d,f,p,g,m=n.props,y=e.props,b=e.type;if("svg"===b?i="http://www.w3.org/2000/svg":"math"===b?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!b&&(b?f.localName===b:3===f.nodeType)){t=f,o[u]=null;break}if(null==t){if(null===b)return document.createTextNode(y);t=document.createElementNS(i,b,y.is&&y),o=null,a=!1}if(null===b)m===y||a&&t.data===y||(t.data=y);else{if(o=o&&se.call(t.childNodes),m=n.props||me,!a&&null!=o)for(m={},u=0;u<t.attributes.length;u++)m[(f=t.attributes[u]).name]=f.value;for(u in m)if(f=m[u],"children"==u);else if("dangerouslySetInnerHTML"==u)h=f;else if("key"!==u&&!(u in y)){if("value"==u&&"defaultValue"in y||"checked"==u&&"defaultChecked"in y)continue;Re(t,u,null,f,i)}for(u in y)f=y[u],"children"==u?d=f:"dangerouslySetInnerHTML"==u?l=f:"value"==u?p=f:"checked"==u?g=f:"key"===u||a&&"function"!=typeof f||m[u]===f||Re(t,u,f,m[u],i);if(l)a||h&&(l.__html===h.__html||l.__html===t.innerHTML)||(t.innerHTML=l.__html),e.__k=[];else if(h&&(t.innerHTML=""),Pe(t,we(d)?d:[d],e,n,r,"foreignObject"===b?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Ee(n,0),a,c),null!=o)for(u=o.length;u--;)null!=o[u]&&_e(o[u]);a||(u="value",void 0!==p&&(p!==t[u]||"progress"===b&&!p||"option"===b&&p!==m[u])&&Re(t,u,p,m[u],i),u="checked",void 0!==g&&g!==t[u]&&Re(t,u,g,m[u],i))}return t}function $e(t,e,n){try{"function"==typeof t?t(e):t.current=e}catch(t){ae.__e(t,n)}}function We(t,e,n){var r,i;if(ae.unmount&&ae.unmount(t),(r=t.ref)&&(r.current&&r.current!==t.__e||$e(r,null,e)),null!=(r=t.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(t){ae.__e(t,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&We(r[i],e,n||"function"!=typeof t.type);n||null==t.__e||_e(t.__e),t.__c=t.__=t.__e=t.__d=void 0}function Fe(t,e,n){return this.constructor(t,n)}function De(t,e,n){var r,i,o,s;ae.__&&ae.__(t,e),i=(r="function"==typeof n)?null:n&&n.__k||e.__k,o=[],s=[],Ne(e,t=(!r&&n||e).__k=function(t,e,n){var r,i,o,s={};for(o in e)"key"==o?r=e[o]:"ref"==o?i=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?se.call(arguments,2):n),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===s[o]&&(s[o]=t.defaultProps[o]);return ke(t,s,r,i,null)}(Se,null,[t]),i||me,me,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?se.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,s),Ue(o,t,s)}se=ye.slice,ae={__e:function(t,e,n,r){for(var i,o,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(t)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(t,r||{}),s=i.__d),s)return i.__E=i}catch(e){t=e}throw t}},ce=0,xe.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=ve({},this.state),"function"==typeof t&&(t=t(ve({},n),this.props)),t&&ve(n,t),null!=t&&this.__v&&(e&&this._sb.push(e),Ae(this))},xe.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Ae(this))},xe.prototype.render=Se,ue=[],he="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,de=function(t,e){return t.__v.__b-e.__v.__b},Be.__r=0,fe=0,pe=Le(!1),ge=Le(!0);var je=0;function qe(t,e,n,r,i,o){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)"ref"==a?s=e[a]:c[a]=e[a];var u={type:t,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--je,__i:-1,__u:0,__source:i,__self:o};if("function"==typeof t&&(s=t.defaultProps))for(a in s)void 0===c[a]&&(c[a]=s[a]);return ae.vnode&&ae.vnode(u),u}var Ke,He,Ve,Ge,Je=0,Ze=[],Ye=ae,Xe=Ye.__b,Qe=Ye.__r,tn=Ye.diffed,en=Ye.__c,nn=Ye.unmount,rn=Ye.__;function on(t,e){Ye.__h&&Ye.__h(He,t,Je||e),Je=0;var n=He.__H||(He.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function sn(t){return Je=1,an(mn,t)}function an(t,e,n){var r=on(Ke++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):mn(void 0,e),function(t){var e=r.__N?r.__N[0]:r.__[0],n=r.t(e,t);e!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=He,!He.u)){var i=function(t,e,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter((function(t){return!!t.__c}));if(i.every((function(t){return!t.__N})))return!o||o.call(this,t,e,n);var s=!1;return i.forEach((function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),!(!s&&r.__c.props===t)&&(!o||o.call(this,t,e,n))};He.u=!0;var o=He.shouldComponentUpdate,s=He.componentWillUpdate;He.componentWillUpdate=function(t,e,n){if(this.__e){var r=o;o=void 0,i(t,e,n),o=r}s&&s.call(this,t,e,n)},He.shouldComponentUpdate=i}return r.__N||r.__}function cn(t,e){var n=on(Ke++,3);!Ye.__s&&gn(n.__H,e)&&(n.__=t,n.i=e,He.__H.__h.push(n))}function un(t){return Je=5,function(t,e){var n=on(Ke++,7);return gn(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}((function(){return{current:t}}),[])}function ln(){for(var t;t=Ze.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(fn),t.__H.__h.forEach(pn),t.__H.__h=[]}catch(e){t.__H.__h=[],Ye.__e(e,t.__v)}}Ye.__b=function(t){He=null,Xe&&Xe(t)},Ye.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),rn&&rn(t,e)},Ye.__r=function(t){Qe&&Qe(t),Ke=0;var e=(He=t.__c).__H;e&&(Ve===He?(e.__h=[],He.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.i=t.__N=void 0}))):(e.__h.forEach(fn),e.__h.forEach(pn),e.__h=[],Ke=0)),Ve=He},Ye.diffed=