1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1417],{40562:function(e,t,r){let n;function i(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(s,a)}u((n=n.apply(e,t||[])).next())})}function o(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function s(e,t){if(!e)throw Error(t)}r.d(t,{Z:function(){return tf}}),"function"==typeof SuppressedError&&SuppressedError,(L=D||(D={})).prod="BLOCTO_SDK",L.dev="BLOCTO_SDK_DEV",L.staging="BLOCTO_SDK_STAGING",(M=K||(K={})).ETHEREUM="ethereum",M.SOLANA="solana",M.APTOS="aptos";let a="undefined"!=typeof window?window.memoryStorage:new class{constructor(){this.storage={}}getItem(e){return this[e]||null}setItem(e,t){this.storage[e]=t}removeItem(e){delete this.storage[e]}},u=(()=>{if("undefined"==typeof window)return!1;try{window.sessionStorage.setItem("local_storage_supported","1");let e=window.sessionStorage.getItem("local_storage_supported");return window.sessionStorage.removeItem("local_storage_supported"),"1"===e}catch(e){return!1}})()?window.sessionStorage:a,c=(e,t=null)=>{let r=u.getItem(e);try{return r&&JSON.parse(r)||t}catch(e){return r||t}},h=(e,t)=>u.setItem(e,"string"==typeof t?t:JSON.stringify(t)),l=e=>{h(e,""),u.removeItem(e)},d=e=>{let t=c(e,null);return t?new Date().getTime()>t.expiry||t.v!==C?(l(e),null):null==t?void 0:t.data:null},f=(e,t,r)=>{var n,i,o;let s=c(e),a={data:{code:(null==t?void 0:t.code)||(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n.code),connected:!!((null==t?void 0:t.code)||(null===(i=null==s?void 0:s.data)||void 0===i?void 0:i.code)),accounts:Object.assign(Object.assign({},null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.accounts),null==t?void 0:t.accounts)},expiry:r||(null==s?void 0:s.expiry)||new Date().getTime()+T,v:C};h(e,a)},p=(e,t)=>{var r,n;return(null===(r=d(e))||void 0===r?void 0:r.code)?(null===(n=d(e))||void 0===n?void 0:n.accounts[t])||null:(l(e),null)},v=(e,t,r)=>{f(e,{accounts:{[t]:r}})},g=(e,t)=>{f(e,{accounts:{[t]:void 0}})},y={56:"https://bsc-dataseed1.binance.org",97:"https://data-seed-prebsc-1-s1.binance.org:8545",137:"https://rpc-mainnet.maticvigil.com/",80001:"https://rpc-mumbai.matic.today/",43114:"https://api.avax.network/ext/bc/C/rpc",43113:"https://api.avax-test.network/ext/bc/C/rpc",42161:"https://arb1.arbitrum.io/rpc",421613:"https://endpoints.omniatech.io/v1/arbitrum/goerli/public",10:"https://mainnet.optimism.io",420:"https://goerli.optimism.io"},m={prod:"https://wallet-v2.blocto.app",staging:"https://wallet-v2-staging.blocto.app",dev:"https://wallet-v2-dev.blocto.app"},b={prod:D.prod,staging:D.staging,dev:D.dev},w={MainnetBeta:"mainnet-beta",Testnet:"testnet",Devnet:"devnet"},E={[w.MainnetBeta]:"https://wallet-v2.blocto.app",[w.Devnet]:"https://wallet-v2-dev.blocto.app",[w.Testnet]:"https://wallet-v2-dev.blocto.app"},S={[w.MainnetBeta]:D.prod,[w.Devnet]:D.dev,[w.Testnet]:D.dev},A={1:D.prod,2:D.dev,3:D.dev,4:D.dev,5:D.staging},O={1:"https://wallet-v2.blocto.app",2:"https://wallet-v2-dev.blocto.app",3:"https://wallet-v2-dev.blocto.app",4:"https://wallet-v2-dev.blocto.app",5:"https://wallet-v2-staging.blocto.app"};(x=$||($={})).Mainnet="mainnet",x.Testnet="testnet",x.Devnet="devnet",x.Testing="testing",x.Premainnet="premainnet";let P={1:$.Mainnet,2:$.Testnet,3:$.Devnet,4:$.Testing,5:$.Premainnet},R={1:"https://fullnode.mainnet.aptoslabs.com/v1",2:"https://fullnode.testnet.aptoslabs.com/v1",3:"https://fullnode.devnet.aptoslabs.com/v1",4:"",5:"https://premainnet.aptosdev.com/v1"},_=["connect","disconnect","message","chainChanged","accountsChanged"],T=864e5,I="00000000-0000-0000-0000-000000000000",C="0.5.5";class j{constructor(){this.isBlocto=!0,this.isConnecting=!1,this.eventListeners={}
1,this.off=this.removeListener,_.forEach(e=>{this.eventListeners[e]=[]}),this.appId=I}request(e){return i(this,void 0,void 0,function*(){})}on(e,t){_.includes(e)&&this.eventListeners[e].push(t)}once(){}removeListener(e,t){let r=this.eventListeners[e],n=r.findIndex(e=>e===t);-1!==n&&this.eventListeners[e].splice(n,1)}}function N(e){let t=document.createElement("iframe");return t.setAttribute("src",e),t.setAttribute("style","width:100vw;height:100%;position:fixed;top:0;left:0;z-index:2147483646;border:none;box-sizing:border-box;color-scheme:light;inset:0px;display:block;pointer-events:auto;"),t}function B(e){document.body.appendChild(e)}function U(e){let t=e&&e.parentNode;t&&t.removeChild instanceof Function&&t.removeChild(e)}var k,L,M,x,D,K,$,q,Y,F,z,J=(e,t,r=window)=>{r.addEventListener(e,function n(i){t(i,()=>r.removeEventListener(e,n))})};function V(e,t,r){return i(this,void 0,void 0,function*(){if((403===e.status||401===e.status)&&(r&&r(),l(t)),!e.ok){let t=yield e.json(),r=Error((null==t?void 0:t.message)||"unknown error");throw r.error_code=null==t?void 0:t.error_code,r}return e.json()})}let W=e=>/\S+@\S+\.\S+/.test(e),G=e=>"object"==typeof e&&null!==e&&"from"in e,H=e=>Array.isArray(e)&&e.every(e=>G(e));var X={};function Z(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function Q(e){return(Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!==Q(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Q(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Q(t)?t:String(t)}(n.key),n)}}function et(e,t,r){return t&&ee(e.prototype,t),r&&ee(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function er(e,t){return(er=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function en(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&er(e,t)}function ei(e){return(ei=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eo(e,t,r){return(eo=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&er(i,r.prototype),i}:Reflect.construct.bind()).apply(null,arguments)}function es(e){var t="function"==typeof Map?new Map:void 0;return(es=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return eo(e,arguments,ei(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),er(r,e)})(e)}var ea={};ef.default=ef,ef.stable=eg,ef.stableStringify=eg;var eu="[...]",ec="[Circular]",eh=[],el=[];function ed(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function ef(e,t,r,n){void 0===n&&(n=ed()),function e(t,r,n,i,o,s,a){if(s+=1,"object"===Q(t)&&null!==t){for(u=0;u<i.length;u++)if(i[u]===t){ep(ec,t,r,o);return}if(void 0!==a.depthLimit&&s>a.depthLimit||void 0!==a.edgesLimit&&n+1>a.edgesLimit){ep(eu,t,r,o);return}if(i.push(t),Array.isArray(t))for(u=0;
1u<t.length;u++)e(t[u],u,u,i,t,s,a);else{var u,c=Object.keys(t);for(u=0;u<c.length;u++){var h=c[u];e(t[h],h,u,i,t,s,a)}}i.pop()}}(e,"",0,[],void 0,0,n);try{i=0===el.length?JSON.stringify(e,t,r):JSON.stringify(e,ey(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==eh.length;){var i,o=eh.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function ep(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);void 0!==i.get?i.configurable?(Object.defineProperty(n,r,{value:e}),eh.push([n,r,t,i])):el.push([t,r,e]):(n[r]=e,eh.push([n,r,t]))}function ev(e,t){return e<t?-1:e>t?1:0}function eg(e,t,r,n){void 0===n&&(n=ed());var i,o=function e(t,r,n,i,o,s,a){if(s+=1,"object"===Q(t)&&null!==t){for(u=0;u<i.length;u++)if(i[u]===t){ep(ec,t,r,o);return}try{if("function"==typeof t.toJSON)return}catch(e){return}if(void 0!==a.depthLimit&&s>a.depthLimit||void 0!==a.edgesLimit&&n+1>a.edgesLimit){ep(eu,t,r,o);return}if(i.push(t),Array.isArray(t))for(u=0;u<t.length;u++)e(t[u],u,u,i,t,s,a);else{var u,c={},h=Object.keys(t).sort(ev);for(u=0;u<h.length;u++){var l=h[u];e(t[l],l,u,i,t,s,a),c[l]=t[l]}if(void 0===o)return c;eh.push([o,r,t]),o[r]=c}i.pop()}}(e,"",0,[],void 0,0,n)||e;try{i=0===el.length?JSON.stringify(o,t,r):JSON.stringify(o,ey(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==eh.length;){var s=eh.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function ey(e){return e=void 0!==e?e:function(e,t){return t},function(t,r){if(el.length>0)for(var n=0;n<el.length;n++){var i=el[n];if(i[1]===t&&i[0]===r){r=i[2],el.splice(n,1);break}}return e.call(this,t,r)}}function em(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=ei(e);if(t){var i=ei(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===Q(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}Object.defineProperty(ea,"__esModule",{value:!0}),ea.EthereumProviderError=ea.EthereumRpcError=void 0;var eb=function(e){en(r,e);var t=em(r);function r(e,n,i){var o;if(Z(this,r),!Number.isInteger(e))throw Error('"code" must be an integer.');if(!n||"string"!=typeof n)throw Error('"message" must be a nonempty string.');return(o=t.call(this,n)).code=e,void 0!==i&&(o.data=i),o}return et(r,[{key:"serialize",value:function(){var e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}},{key:"toString",value:function(){return ef.default(this.serialize(),eE,2)}}]),r}(es(Error));ea.EthereumRpcError=eb;var ew=function(e){en(r,e);var t=em(r);function r(e,n,i){if(Z(this,r),!(Number.isInteger(e)&&e>=1e3&&e<=4999))throw Error('"code" must be an integer such that: 1000 <= code <= 4999');return t.call(this,e,n,i)}return et(r)}(eb);function eE(e,t){if("[Circular]"!==t)return t}ea.EthereumProviderError=ew;var eS={},eA={};function eO(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function eP(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,s,a=[],u=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eO(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return eO(e,t)}}
1(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}Object.defineProperty(eA,"__esModule",{value:!0}),eA.errorValues=eA.errorCodes=void 0,eA.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}},eA.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(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;var t=eA.errorCodes.rpc.internal,r={code:t,message:n(t)};function n(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Unspecified error message. This is a bug, please report it.";if(Number.isInteger(t)){var n=t.toString();if(s(eA.errorValues,n))return eA.errorValues[n].message;if(t>=-32099&&t<=-32e3)return e.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function i(e){if(!Number.isInteger(e))return!1;var t=e.toString();return!!(eA.errorValues[t]||e>=-32099&&e<=-32e3)}function o(e){return e&&"object"===Q(e)&&!Array.isArray(e)?Object.assign({},e):e}function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",e.getMessageFromCode=n,e.isValidCode=i,e.serializeError=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.fallbackError,u=void 0===a?r:a,c=t.shouldIncludeStack;if(!u||!Number.isInteger(u.code)||"string"!=typeof u.message)throw Error("Must provide fallback error with integer number code and string message.");if(e instanceof ea.EthereumRpcError)return e.serialize();var h={};if(e&&"object"===Q(e)&&!Array.isArray(e)&&s(e,"code")&&i(e.code))h.code=e.code,e.message&&"string"==typeof e.message?(h.message=e.message,s(e,"data")&&(h.data=e.data)):(h.message=n(h.code),h.data={originalError:o(e)});
1else{h.code=u.code;var l=null==e?void 0:e.message;h.message=l&&"string"==typeof l?l:u.message,h.data={originalError:o(e)}}var d=null==e?void 0:e.stack;return void 0!==c&&c&&e&&d&&"string"==typeof d&&(h.stack=d),h}}(eS);var eR={};function e_(e,t){var r=eP(eI(t),2),n=r[0],i=r[1];return new ea.EthereumRpcError(e,n||eS.getMessageFromCode(e),i)}function eT(e,t){var r=eP(eI(t),2),n=r[0],i=r[1];return new ea.EthereumProviderError(e,n||eS.getMessageFromCode(e),i)}function eI(e){if(e){if("string"==typeof e)return[e];if("object"===Q(e)&&!Array.isArray(e)){var t=e.message,r=e.data;if(t&&"string"!=typeof t)throw Error("Must specify string message.");return[t||void 0,r]}}return[]}Object.defineProperty(eR,"__esModule",{value:!0}),eR.ethErrors=void 0,eR.ethErrors={rpc:{parse:function(e){return e_(eA.errorCodes.rpc.parse,e)},invalidRequest:function(e){return e_(eA.errorCodes.rpc.invalidRequest,e)},invalidParams:function(e){return e_(eA.errorCodes.rpc.invalidParams,e)},methodNotFound:function(e){return e_(eA.errorCodes.rpc.methodNotFound,e)},internal:function(e){return e_(eA.errorCodes.rpc.internal,e)},server:function(e){if(!e||"object"!==Q(e)||Array.isArray(e))throw Error("Ethereum RPC Server errors must provide single object argument.");var t=e.code;if(!Number.isInteger(t)||t>-32005||t<-32099)throw Error('"code" must be an integer such that: -32099 <= code
1<= -32005');return e_(t,e)},invalidInput:function(e){return e_(eA.errorCodes.rpc.invalidInput,e)},resourceNotFound:function(e){return e_(eA.errorCodes.rpc.resourceNotFound,e)},resourceUnavailable:function(e){return e_(eA.errorCodes.rpc.resourceUnavailable,e)},transactionRejected:function(e){return e_(eA.errorCodes.rpc.transactionRejected,e)},methodNotSupported:function(e){return e_(eA.errorCodes.rpc.methodNotSupported,e)},limitExceeded:function(e){return e_(eA.errorCodes.rpc.limitExceeded,e)}},provider:{userRejectedRequest:function(e){return eT(eA.errorCodes.provider.userRejectedRequest,e)},unauthorized:function(e){return eT(eA.errorCodes.provider.unauthorized,e)},unsupportedMethod:function(e){return eT(eA.errorCodes.provider.unsupportedMethod,e)},disconnected:function(e){return eT(eA.errorCodes.provider.disconnected,e)},chainDisconnected:function(e){return eT(eA.errorCodes.provider.chainDisconnected,e)},custom:function(e){if(!e||"object"!==Q(e)||Array.isArray(e))throw Error("Ethereum Provider custom errors must provide single object argument.");var t=e.code,r=e.message,n=e.data;if(!r||"string"!=typeof r)throw Error('"message" must be a nonempty string');return new ea.EthereumProviderError(t,r,n)}}},Object.defineProperty(X,"__esModule",{value:!0}),X.getMessageFromCode=X.serializeError=X.EthereumProviderError=X.EthereumRpcError=X.ethErrors=X.errorCodes=void 0,Object.defineProperty(X,"EthereumRpcError",{enumerable:!0,get:function(){return ea.EthereumRpcError}}),Object.defineProperty(X,"EthereumProviderError",{enumerable:!0,get:function(){return ea.EthereumProviderError}}),Object.defineProperty(X,"serializeError",{enumerable:!0,get:function(){return eS.serializeError}}),Object.defineProperty(X,"getMessageFromCode",{enumerable:!0,get:function(){return eS.getMessageFromCode}}),Object.defineProperty(X,"ethErrors",{enumerable:!0,get:function(){return eR.ethErrors}}),Object.defineProperty(X,"errorCodes",{enumerable:!0,get:function(){return eA.errorCodes}});var eC="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ej=[],eN=[],eB="undefined"!=typeof Uint8Array?Uint8Array:Array,eU=!1;function ek(){eU=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)ej[t]=e[t],eN[e.charCodeAt(t)]=t;eN["-".charCodeAt(0)]=62,eN["_".charCodeAt(0)]=63}function eL(e){eU||ek();for(var t,r=e.length,n=r%3,i="",o=[],s=0,a=r-n;s<a;s+=16383)o.push(function(e,t,r){for(var n,i=[],o=t;o<r;o+=3)i.push(ej[(n=(e[o]<<16)+(e[o+1]<<8)+e[o+2])>>18&63]+ej[n>>12&63]+ej[n>>6&63]+ej[63&n]);return i.join("")}(e,s,s+16383>a?a:s+16383));return 1===n?i+=ej[(t=e[r-1])>>2]+ej[t<<4&63]+"==":2===n&&(i+=ej[(t=(e[r-2]<<8)+e[r-1])>>10]+ej[t>>4&63]+ej[t<<2&63]+"="),o.push(i),o.join("")}function eM(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?i-1:0,d=r?-1:1,f=e[t+l];for(l+=d,o=f&(1<<-h)-1,f>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=d,h-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(f?-1:1)*(1/0);s+=Math.pow(2,n),o-=c}return(f?-1:1)*s*Math.pow(2,o-n)}function ex(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,h=(1<<c)-1,l=h>>1,d=23===i?5960464477539062e-23:0,f=n?0:o-1,p=n?1:-1,v=t<0||0===t&&1/t<0?1:0;for(isNaN(t=Math.abs(t))||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+l>=1?t+=d/u:t+=d*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+f]=255&s,f+=p,s/=256,c-=8);e[r+f-p]|=128*v}var eD={}.toString,eK=Array.isArray||function(e){return"[object Array]"==eD.call(e)};function e$(){return eY.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function eq(e,t){if(e$()<t)throw RangeError("Invalid typed array length");return eY.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=eY.prototype:(null===e&&(e=new eY(t)),e.length=t),e}function eY(e,t,r){if(!eY.TYPED_ARRAY_SUPPORT&&!(this instanceof eY))return new eY(e,t,r);if("number"==typeof e){if("string"==typeof t)throw Error("If encoding is specified then the first argument must be a string");return eJ(this,e)}return eF(this,e,t,r)}function eF(e,t,r,n){if("number"==typeof t)throw TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),eY.TYPED_ARRAY_SUPPORT?(e=t).__proto__=eY.prototype:e=eV(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if(("string"!=typeof r||""===r)&&(r="utf8"),!eY.isEncoding(r))throw TypeError('"encoding" must be a valid string encoding');var n=0|eH(t,r),i=(e=eq(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(eG(t)){var r,n=0|eW(t.length);return 0===(e=eq(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?eq(e,0):eV(e,t);if("Buffer"===t.type&&eK(t.data))return eV(e,t.data)}throw TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function ez(e){if("number"!=typeof e)throw TypeError('"size" argument must be a number');if(e<0)throw RangeError('"size" argument must not be negative')}function eJ(e,t){if(ez(t),e=eq(e,t<0?0:0|eW(t)),!eY.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function eV(e,t){var r=t.length<0?0:0|eW(t.length);e=eq(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function eW(e){if(e>=e$())throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e$().toString(16)+" bytes");return 0|e}function eG(e){return!!(null!=e&&e._isBuffer)}function eH(e,t){if(eG(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&
1(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return te(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return tr(e).length;default:if(n)return te(e).length;t=(""+t).toLowerCase(),n=!0}}function eX(e,t,r){var n,i,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n,i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var o="",s=t;s<r;++s)o+=(n=e[s])<16?"0"+n.toString(16):n.toString(16);return o}(this,t,r);case"utf8":case"utf-8":return e1(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}(this,t,r);case"base64":return n=t,i=r,0===n&&i===this.length?eL(this):eL(this.slice(n,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function eZ(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function eQ(e,t,r,n,i){if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),isNaN(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return -1;r=e.length-1}else if(r<0){if(!i)return -1;r=0}if("string"==typeof t&&(t=eY.from(t,n)),eG(t))return 0===t.length?-1:e0(e,t,r,n,i);if("number"==typeof t)return(t&=255,eY.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf)?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):e0(e,[t],r,n,i);throw TypeError("val must be string, number or Buffer")}function e0(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===u)return h*s}else -1!==h&&(o-=o-h),h=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,d=0;d<u;d++)if(c(e,o+d)!==c(t,d)){l=!1;break}if(l)return o}return -1}function e1(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],h=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:(192&(o=e[i+1]))==128&&(u=(31&c)<<6|63&o)>127&&(h=u);break;case 3:o=e[i+1],s=e[i+2],(192&o)==128&&(192&s)==128&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],(192&o)==128&&(192&s)==128&&(192&a)==128&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}function e2(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function e3(e,t,r,n,i,o){if(!eG(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function e5(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function e6(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>(n?i:3-i)*8&255}function e4(e,t,r,n,i,o){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function e8(e,t,r,n,i){return i||e4(e,t,r,4),ex(e,t,r,n,23,4),r+4}function e9(e,t,r,n,i){return i||e4(e,t,r,8),ex(e,t,r,n,52,8),r+8}eY.TYPED_ARRAY_SUPPORT=void 0===eC.TYPED_ARRAY_SUPPORT||eC.TYPED_ARRAY_SUPPORT,e$(),eY.poolSize=8192,eY._augment=function(e){return e.__proto__=eY.prototype,e},eY.from=function(e,t,r){return eF(null,e,t,r)},eY.TYPED_ARRAY_SUPPORT&&(eY.prototype.__proto__=Uint8Array.prototype,eY.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&eY[Symbol.species]),eY.alloc=function(e,t,r){return(ez(e),e<=0)?eq(null,e):void 0!==t?"string"==typeof r?eq(null,e).fill(t,r):eq(null,e).fill(t):eq(null,e)},eY.allocUnsafe=function(e){return eJ(null,e)},eY.allocUnsafeSlow=function(e){return eJ(null,e)},eY.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ti(e)||"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ti(e.slice(0,0)))},eY.compare=function(e,t){if(!eG(e)||!eG(t))throw TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},eY.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},eY.concat=function(e,t){if(!eK(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return eY.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=eY.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!eG(o))throw TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},eY.byteLength=eH,eY.prototype._isBuffer=!0,eY.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)eZ(this,t,t+1);return this},eY.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)eZ(this,t,t+3),eZ(this,t+1,t+2);return this},eY.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)eZ(this,t,t+7),eZ(this,t+1,t+6),eZ(this,t+2,t+5),eZ(this,t+3,t+4);return this},eY.prototype.toString=function(){var e=0|this.length;return 0===e?"":0==arguments.length?e1(this,0,e):eX.apply(this,arguments)},eY.prototype.equals=function(e){if(!eG(e))throw TypeError("Argument must be a Buffer");return this===e||0===eY.compare(this,e)},eY.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},eY.prototype.compare=function(e,t,r,n,i){if(!eG(e))throw TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(u[h]!==c[h]){o=u[h],s=c[h];break}return o<s?-1:s<o?1:0},eY.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},eY.prototype.indexOf=function(e,t,r){return eQ(this,e,t,r,!0)},eY.prototype.lastIndexOf=function(e,t,r){return eQ(this,e,t,r,!1)},eY.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,o,s,a,u,c,h,l,d,f,p,v,g=this.length-t;if((void 0===r||r>g)&&(r=g),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var y=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))break;e[r+s]=a}return s}(this,e,t,r);case"utf8":case"utf-8":return u=t,c=r,tn(te(e,this.length-u),this,u,c);case"ascii":return h=t,l=r,tn(tt(e),this,h,l);case"latin1":case"binary":;return i=this,o=e,s=t,a=r,tn(tt(o),i,s,a);case"base64":return d=t,f=r,tn(tr(e),this,d,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p=t,v=r,tn(function(e,t){for(var r,n,i=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i.push(r%256),i.push(n);return i}(e,this.length-p),this,p,v);default:if(y)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),y=!0}},eY.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},eY.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),eY.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=eY.prototype;else{var i=t-e;r=new eY(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},eY.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||e2(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},eY.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||e2(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},eY.prototype.readUInt8=function(e,t){return t||e2(e,1,this.length),this[e]},eY.prototype.readUInt16LE=function(e,t){return t||e2(e,2,this.length),this[e]|this[e+1]<<8},eY.prototype.readUInt16BE=function(e,t){return t||e2(e,2,this.length),this[e]<<8|this[e+1]},eY.prototype.readUInt32LE=function(e,t){return t||e2(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},eY.prototype.readUInt32BE=function(e,t){return t||e2(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},eY.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||e2(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},eY.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||e2(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},eY.prototype.readInt8=function(e,t){return(t||e2(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},eY.prototype.readInt16LE=function(e,t){t||e2(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},eY.prototype.readInt16BE=function(e,t){t||e2(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},eY.prototype.readInt32LE=function(e,t){return t||e2(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},eY.prototype.readInt32BE=function(e,t){return t||e2(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},eY.prototype.readFloatLE=function(e,t){return t||e2(e,4,this.length),eM(this,e,!0,23,4)},eY.prototype.readFloatBE=function(e,t){return t||e2(e,4,this.length),eM(this,e,!1,23,4)},eY.prototype.readDoubleLE=function(e,t){return t||e2(e,8,this.length),eM(this,e,!0,52,8)},eY.prototype.readDoubleBE=function(e,t){return t||e2(e,8,this.length),eM(this,e,!1,52,8)},eY.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){var i=Math.pow(2,8*r)-1;e3(this,e,t,r,i,0)}var o=1,s=0;for(this[t]=255&e;++s<r&&(o*=256);)this[t+s]=e/o&255;return t+r},eY.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){var i=Math.pow(2,8*r)-1;e3(this,e,t,r,i,0)}var o=r-1,s=1;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+r},eY.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,1,255,0),eY.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},eY.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,2,65535,0),eY.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):e5(this,e,t,!0),t+2},eY.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,2,65535,0),eY.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):e5(this,e,t,!1),t+2},eY.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,4,4294967295,0),eY.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):e6(this,e,t,!0),t+4},eY.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,4,4294967295,0),eY.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):e6(this,e,t,!1),t+4},eY.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);e3(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},eY.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);e3(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},eY.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,1,127,-128),eY.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},eY.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,2,32767,-32768),eY.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):e5(this,e,t,!0),t+2},eY.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,2,32767,-32768),eY.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):e5(this,e,t,!1),t+2},eY.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,4,2147483647,-2147483648),eY.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):e6(this,e,t,!0),t+4},eY.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||e3(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),eY.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):e6(this,e,t,!1),t+4},eY.prototype.writeFloatLE=function(e,t,r){return e8(this,e,t,!0,r)},eY.prototype.writeFloatBE=function(e,t,r){return e8(this,e,t,!1,r)},eY.prototype.writeDoubleLE=function(e,t,r){return e9(this,e,t,!0,r)},eY.prototype.writeDoubleBE=function(e,t,r){return e9(this,e,t,!1,r)},eY.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("sourceStart out of bounds");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!eY.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},eY.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i,o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!eY.isEncoding(n))throw TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=eG(e)?e:te(new eY(e,n).toString()),a=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};var e7=/[^+\/0-9A-Za-z-_]/g;function te(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319||s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}
1else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return o}function tt(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function tr(e){return function(e){eU||ek();var t,r,n,i,o,s,a=e.length;if(a%4>0)throw Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new eB(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t<n;t+=4,r+=3)i=eN[e.charCodeAt(t)]<<18|eN[e.charCodeAt(t+1)]<<12|eN[e.charCodeAt(t+2)]<<6|eN[e.charCodeAt(t+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=eN[e.charCodeAt(t)]<<2|eN[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=eN[e.charCodeAt(t)]<<10|eN[e.charCodeAt(t+1)]<<4|eN[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(e7,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function tn(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function ti(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}let to=e=>"string"==typeof e&&/^0x[0-9A-Fa-f]*$/.test(e),ts=e=>eY.from(e,"utf8").toString("hex");function ta(e){return e?"number"==typeof e?e:e.startsWith("0x")?parseInt(e,16):parseInt(e,10):1}class tu extends j{constructor({chainId:e,rpc:t,walletServer:r,appId:n}){super(),q.add(this),this.networkVersion="1",s(e,"'chainId' is required"),this.networkVersion=`${ta(e)}`,this.chainId=`0x${ta(e).toString(16)}`,this.rpc=t||y[this.networkVersion],s(this.rpc,"'rpc' is required"),this.injectedWalletServer=r,this._blocto={sessionKey:D.prod,walletServer:this.injectedWalletServer||"",blockchainName:"",networkType:"",supportNetworkList:{},switchableNetwork:{}},this.appId=n||I}send(e,t){return i(this,void 0,void 0,function*(){switch(!0){case t instanceof Function:return this.sendAsync(e,t);case"string"==typeof e&&Array.isArray(t):return this.sendAsync({jsonrpc:"2.0",method:e,params:t});default:return this.sendAsync(e)}})}sendAsync(e,t){return i(this,void 0,void 0,function*(){let r=new Promise(t=>{if(Array.isArray(e)){let r=e.filter(e=>"eth_sendTransaction"===e.method).map(e=>{var t;return null===(t=e.params)||void 0===t?void 0:t[0]}),n=Math.floor(1e4*Math.random()),i=this.request({method:"blocto_sendBatchTransaction",params:r}),o=e.map(({method:e,params:t},r)=>"eth_sendTransaction"===e?i:this.request({id:n+r+1,jsonrpc:"2.0",method:e,params:t}));Promise.allSettled(o).then(r=>t(r.map((t,r)=>({id:String(n+r+1),jsonrpc:"2.0",method:e[r].method,result:"fulfilled"===t.status?t.value:void 0,error:"fulfilled"!==t.status?t.reason:void 0})))).catch(e=>{throw X.ethErrors.rpc.internal(null==e?void 0:e.message)})}else this.request(Object.assign(Object.assign({},e),{id:Number(e.id)})).then(t)});if(!t)return r;r.then(e=>t(null,e)).catch(e=>t(e))})}sendUserOperation(e){return i(this,void 0,void 0,function*(){return this.request({method:"eth_sendUserOperation",params:[e]})})}request(e){var t,r,n,s,a,u,c,h,l,d;return i(this,void 0,void 0,function*(){if(!(null==e?void 0:e.method))throw X.ethErrors.rpc.invalidRequest();let i=window.ethereum;if(i&&i.isBlocto){if("wallet_switchEthereumChain"===e.method){if(!(null===(r=null===(t=null==e?void 0:e.params)||void 0===t?void 0:t[0])||void 0===r?void 0:r.chainId))throw X.ethErrors.rpc.invalidParams();return i.request(e).then(()=>{var t,r,n;return this.networkVersion=`${ta(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t[0].chainId)}`,this.chainId=`0x${ta(null===(r=null==e?void 0:e.params)||void 0===r?void 0:r[0].chainId).toString(16)}`,this.rpc=null===(n=null==v?void 0:v[this.networkVersion])||void 0===n?void 0:n.rpc_url,null})}return i.request(e)}let{blockchainName:f,switchableNetwork:v,sessionKey:g}=yield o(this,q,"m",Y).call(this);switch(e.method){case"eth_chainId":return this.chainId;case"net_version":return this.networkVersion;case"wallet_addEthereumChain":return this.loadSwitchableNetwork((null==e?void 0:e.params)||[]);case"eth_call":{let t=yield this.handleReadRequests(e);if(!t||t&&!t.result&&t.error){let e=(null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.message)?t.error.message:"Request failed";throw X.ethErrors.rpc.internal(e)}return t.result}case"wallet_switchEthereumChain":{if(!(null===(a=null===(s=null==e?void 0:e.params)||void 0===s?void 0:s[0])||void 0===a?void 0:a.chainId))throw X.ethErrors.rpc.invalidParams();let t=e.params[0].chainId;if(!p(g,f)){let e=ta(t);
1if(!v[e])throw X.ethErrors.provider.custom({code:4902,message:`Unrecognized chain ID "${t}". Try adding the chain using wallet_addEthereumChain first.`});return this.networkVersion=`${e}`,this.chainId=`0x${e.toString(16)}`,this.rpc=v[e].rpc_url,this.eventListeners.chainChanged.forEach(e=>e(this.chainId)),null}}}if(!p(g,f)){let t=null===(u=null==e?void 0:e.params)||void 0===u?void 0:u[0];"eth_requestAccounts"===e.method&&W(t)?yield this.enable(t):yield this.enable()}try{let t=null,r=null;switch(e.method){case"eth_requestAccounts":yield this.fetchAccounts();case"eth_accounts":r=p(g,f);break;case"eth_coinbase":r=null===(c=p(g,f))||void 0===c?void 0:c[0];break;case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"personal_sign":case"eth_sign":r=yield this.handleSign(e);break;case"wallet_disconnect":this.handleDisconnect(),r=null;break;case"eth_sendTransaction":r=yield this.handleSendTransaction(e);break;case"blocto_sendBatchTransaction":r=yield this.handleSendBatchTransaction(e);break;case"eth_signTransaction":case"eth_sendRawTransaction":throw X.ethErrors.rpc.methodNotSupported("Method Not Supported: "+e.method);case"eth_sendUserOperation":r=yield this.handleSendUserOperation(e);break;case"wallet_switchEthereumChain":{if(!(null===(l=null===(h=null==e?void 0:e.params)||void 0===h?void 0:h[0])||void 0===l?void 0:l.chainId))throw X.ethErrors.rpc.invalidParams();let t=null===(d=p(g,f))||void 0===d?void 0:d[0],n=this.chainId,i=e.params[0].chainId;if(!v[ta(i)])throw X.ethErrors.provider.custom({code:4902,message:`Unrecognized chain ID "${ta(e.params[0].chainId)}". Try adding the chain using wallet_addEthereumChain first.`});this.networkVersion=`${ta(i)}`,this.chainId=`0x${ta(i).toString(16)}`,this.rpc=v[this.networkVersion].rpc_url,yield this.enable().then(([e])=>{var n;e!==t&&(null===(n=this.eventListeners)||void 0===n||n.accountsChanged.forEach(t=>t([e]))),this.eventListeners.chainChanged.forEach(e=>e(this.chainId)),r=null}).catch(e=>{throw this.networkVersion=`${ta(n)}`,this.chainId=`0x${ta(n).toString(16)}`,this.rpc=v[this.networkVersion].rpc_url,e});break}case"eth_estimateUserOperationGas":case"eth_getUserOperationByHash":case"eth_getUserOperationReceipt":case"eth_supportedEntryPoints":r=yield this.handleBundler(e);break;default:t=yield this.handleReadRequests(e)}if(t&&!t.result&&t.error){let e=t.error.message?t.error.message:"Request failed";throw X.ethErrors.rpc.internal(e)}if(t)return t.result;return r}catch(e){throw X.ethErrors.rpc.internal(null==e?void 0:e.message)}})}bloctoApi(e,t){var r;return i(this,void 0,void 0,function*(){let{walletServer:n,blockchainName:i,sessionKey:s}=yield o(this,q,"m",Y).call(this),a=(null===(r=d(s))||void 0===r?void 0:r.code)||"";if(!a)throw X.ethErrors.provider.unauthorized();return fetch(`${n}/api/${i}${e}`,Object.assign({headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":a}},t)).then(e=>V(e,s,()=>{var e;null===(e=this.eventListeners)||void 0===e||e.disconnect.forEach(e=>e(X.ethErrors.provider.disconnected()))})).catch(e=>{if((null==e?void 0:e.error_code)==="unsupported_method")throw X.ethErrors.rpc.methodNotSupported("Method Not Supported: "+e.message);throw X.ethErrors.rpc.server({code:-32005,message:`Blocto server error: ${e.message}`})})})}responseListener(e,t){return i(this,void 0,void 0,function*(){let{walletServer:r}=yield o(this,q,"m",Y).call(this);return new Promise((n,i)=>J("message",(o,s)=>{o.origin===r&&"ETH:FRAME:RESPONSE"===o.data.type&&("APPROVED"===o.data.status&&(s(),U(e),n(o.data[t])),"DECLINED"===o.data.status&&(s(),U(e),"incorrect_session_id"===o.data.errorCode&&this.handleDisconnect(),i(X.ethErrors.provider.userRejectedRequest(o.data.errorMessage)))),"ETH:FRAME:CLOSE"===o.data.type&&(s(),U(e),i(X.ethErrors.provider.userRejectedRequest("User declined the request")))}))})}setIframe(e){return i(this,void 0,void 0,function*(){if("undefined"==typeof window)throw X.ethErrors.provider.custom({code:1001,message:"Blocto SDK only works in browser environment"});let{walletServer:t,blockchainName:r}=yield o(this,q,"m",Y).call(this),n=N(`${t}/${this.appId}/${r}${e}`);return B(n),n})}enable(e){return i(this,void 0,void 0,function*(){let{walletServer:t,blockchainName:r,sessionKey:n}=yield o(this,q,"m",Y).call(this),i=window.ethereum;if(i&&i.isBlocto)return i.chainId!==this.chainId&&(yield i.request({method:"wallet_addEthereumChain",params:[{chainId:this.chainId}]}),yield i.request({method:"wallet_switchEthereumChain",params:[{chainId:this.chainId}]}),v(n,r,[i.address])),new Promise((e,t)=>
1setTimeout(()=>i.enable().then(e).catch(t),10));let s=p(n,r);if(s)return new Promise(e=>{e(s)});let a=new URLSearchParams;a.set("l6n",window.location.origin),a.set("v",C);let u=e&&W(e)?`/${e}`:"",c=yield this.setIframe(`/authn${u}?${a.toString()}`);return new Promise((e,i)=>{J("message",(o,s)=>{var a;o.origin===t&&("ETH:FRAME:RESPONSE"===o.data.type&&(s(),U(c),null===(a=this.eventListeners)||void 0===a||a.connect.forEach(e=>e({chainId:this.chainId})),f(n,{code:o.data.code,connected:!0,accounts:{[r]:[o.data.addr]}},o.data.exp),e([o.data.addr])),"ETH:FRAME:CLOSE"===o.data.type&&(s(),U(c),i(X.ethErrors.provider.userRejectedRequest())))})})})}fetchAccounts(){return i(this,void 0,void 0,function*(){o(this,q,"m",z).call(this);let{blockchainName:e,sessionKey:t}=yield o(this,q,"m",Y).call(this),{accounts:r}=yield this.bloctoApi("/accounts");return v(t,e,r),r})}handleReadRequests(e){return i(this,void 0,void 0,function*(){return o(this,q,"m",z).call(this),fetch(this.rpc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({id:1,jsonrpc:"2.0"},e))}).then(e=>e.json()).catch(e=>{throw X.ethErrors.rpc.internal(e)})})}handleSign({method:e,params:t}){return i(this,void 0,void 0,function*(){let r="";if(Array.isArray(t)){if("eth_sign"===e)r=to(t[1])?t[1].slice(2):ts(t[1]);else if("personal_sign"===e)r=to(t[0])?t[0].slice(2):ts(t[0]);else if(["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4"].includes(e)){r=t[1];let{domain:e}=JSON.parse(r);if(to(e.chainId))throw X.ethErrors.rpc.invalidParams(`Provided chainId "${e.chainId}" must be a number`);if(ta(e.chainId)!==ta(this.chainId))throw X.ethErrors.rpc.invalidParams(`Provided chainId "${e.chainId}" must match the active chainId "${ta(this.chainId)}"`)}}o(this,q,"m",z).call(this);let{signatureId:n}=yield this.bloctoApi("/user-signature",{method:"POST",body:JSON.stringify({method:e,message:r})}),i=yield this.setIframe(`/user-signature/${n}`);return this.responseListener(i,"signature")})}handleSendTransaction(e){var t;return i(this,void 0,void 0,function*(){if(o(this,q,"m",z).call(this),!G(null===(t=e.params)||void 0===t?void 0:t[0]))throw X.ethErrors.rpc.invalidParams();let{authorizationId:r}=yield this.bloctoApi("/authz",{method:"POST",body:JSON.stringify(e.params)}),n=yield this.setIframe(`/authz/${r}`);return this.responseListener(n,"txHash")})}handleSendBatchTransaction(e){return i(this,void 0,void 0,function*(){o(this,q,"m",z).call(this);let t=e.params.map(e=>"params"in e?e.params[0]:e),r=Object.assign(Object.assign({},e),{params:t});if(!H(r.params))throw X.ethErrors.rpc.invalidParams();return this.handleSendTransaction(r)})}handleSendUserOperation(e){return i(this,void 0,void 0,function*(){o(this,q,"m",z).call(this);let{authorizationId:t}=yield this.bloctoApi("/user-operation",{method:"POST",body:JSON.stringify(e.params)}),r=yield this.setIframe(`/user-operation/${t}`);return this.responseListener(r,"userOpHash")})}handleBundler(e){return i(this,void 0,void 0,function*(){return o(this,q,"m",z).call(this),this.bloctoApi("/rpc/bundler",{method:"POST",body:JSON.stringify(Object.assign({id:1,jsonrpc:"2.0"},e))})})}handleDisconnect(){var e;return i(this,void 0,void 0,function*(){let t=window.ethereum;if(t&&t.isBlocto)return t.disconnect();let{sessionKey:r,blockchainName:n}=yield o(this,q,"m",Y).call(this);g(r,n),null===(e=this.eventListeners)||void 0===e||e.disconnect.forEach(e=>e(X.ethErrors.provider.disconnected()))})}loadSwitchableNetwork(e){return i(this,void 0,void 0,function*(){if(null==e?void 0:e.length){let t=e.map(({chainId:e,rpcUrls:t})=>{if(!e)throw X.ethErrors.rpc.invalidParams("Empty chainId");if(!(null==t?void 0:t.length))throw X.ethErrors.rpc.invalidParams("Empty rpcUrls");return o(this,q,"m",F).call(this,{chainId:`${ta(e)}`,rpcUrls:t})});return Promise.all(t).then(()=>null)}throw X.ethErrors.rpc.invalidParams("Empty networkList")})}}q=new WeakSet,Y=function(){return i(this,void 0,void 0,function*(){Object.keys(this._blocto.supportNetworkList).length||(yield(function(){return i(this,void 0,void 0,function*(){let{networks:e}=yield fetch("https://api.blocto.app/networks/evm").then(e=>e.json()),t=e.reduce((e,t)=>
1Object.assign(Object.assign({},e),{[t.chain_id]:t}),{});return t})})().then(e=>this._blocto.supportNetworkList=e).catch(e=>{throw X.ethErrors.provider.custom({code:1001,message:`Get blocto server failed: ${e.message}`})}));let{chain_id:e,name:t,network_type:r,blocto_service_environment:n,display_name:o}=this._blocto.supportNetworkList[this.networkVersion];if(!e)throw X.ethErrors.provider.unsupportedMethod(`Get support chain failed: ${this.networkVersion} might not be supported yet.`);return this._blocto=Object.assign(Object.assign({},this._blocto),{sessionKey:b[n],walletServer:this.injectedWalletServer||m[n],blockchainName:t,networkType:r,switchableNetwork:Object.assign(Object.assign({},this._blocto.switchableNetwork),{[e]:{name:t,display_name:o,network_type:r,wallet_web_url:this._blocto.walletServer,rpc_url:this.rpc}})}),this._blocto})},F=function({chainId:e,rpcUrls:t}){return i(this,void 0,void 0,function*(){let{supportNetworkList:r}=yield o(this,q,"m",Y).call(this),{chain_id:n,name:i,display_name:s,network_type:a,blocto_service_environment:u}=r[e],c=m[u];this._blocto.switchableNetwork[n]={name:i,display_name:s,network_type:a,wallet_web_url:c,rpc_url:t[0]}})},z=function(){let e=window.ethereum;if(e&&e.isBlocto&&ta(e.chainId)!==ta(this.chainId))throw X.ethErrors.provider.chainDisconnected()};var tc=(k=function(e){if(e.length>=255)throw TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),o=i.charCodeAt(0);if(255!==t[o])throw TypeError(i+" is ambiguous");t[o]=n}var s=e.length,a=e.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,i=0;e[r]===a;)n++,r++;for(var o=(e.length-r)*u+1>>>0,c=new Uint8Array(o);e[r];){var h=t[e.charCodeAt(r)];if(255===h)return;for(var l=0,d=o-1;(0!==h||l<i)&&-1!==d;d--,l++)h+=s*c[d]>>>0,c[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");i=l,r++}for(var f=o-i;f!==o&&0===c[f];)f++;for(var p=new Uint8Array(n+(o-f)),v=n;f!==o;)p[v++]=c[f++];return p}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=t[i],d=0,f=u-1;(0!==l||d<n)&&-1!==f;f--,d++)l+=256*h[f]>>>0,h[f]=l%s>>>0,l=l/s>>>0;if(0!==l)throw Error("Non-zero carry");n=d,i++}for(var p=u-n;p!==u&&0===h[p];)p++;for(var v=a.repeat(r);p<u;++p)v+=e.charAt(h[p]);return v},decodeUnsafe:h,decode:function(e){var t=h(e);if(t)return t;throw Error("Non-base"+s+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"))&&k.__esModule&&Object.prototype.hasOwnProperty.call(k,"default")?k.default:k;try{n=require("@solana/web3.js")}catch(e){}class th extends j{constructor({net:e="mainnet-beta",server:t,appId:r,rpc:i}){if(super(),s(e,"'net' is required"),s(Object.values(w).includes(e),"unsupported net"),this.net=e,this.rpc=i||("mainnet-beta"===e?"https://free.rpcpool.com":`https://api.${e}.solana.com`),this.server=t||E[this.net]||"",this.appId=r||I,this.sessionKey=S[this.net],!n)throw Error("No @solana/web3.js installed. Please install it to interact with Solana.")}request(e){var t;return i(this,void 0,void 0,function*(){let r=window.solana;if(r&&r.isBlocto)return r.request(e);p(this.sessionKey,K.SOLANA)||(yield this.connect());try{let r=null,i=null;switch(e.method){case"connect":i=yield this.fetchAccounts();break;case"disconnect":this.disconnect();break;case"getAccounts":i=(null===(t=p(this.sessionKey,K.SOLANA))||void 0===t?void 0:t.length)?p(this.sessionKey,K.SOLANA):yield this.fetchAccounts();break;case"getAccountInfo":{let t=yield this.handleReadRequests(e),[r,o]=t.result.value.data;i=Object.assign(Object.assign({},t.result.value),{data:eY.from(r,o),owner:new n.PublicKey(t.result.value.owner)}
1);break}case"convertToProgramWalletTransaction":i=yield this.handleConvertTransaction(e);break;case"signAndSendTransaction":i=yield this.handleSignAndSendTransaction(e);break;case"signTransaction":case"signAllTransactions":throw Error(`Blocto is program wallet, which doesn't support ${e.method}. Use signAndSendTransaction instead.`);default:r=yield this.handleReadRequests(e)}if(r&&!r.result&&r.error){let e=r.error.message?r.error.message:"Request failed";throw Error(e)}if(r)return r.result;return i}catch(e){throw console.error(e),e}})}connect(){return i(this,void 0,void 0,function*(){let e=window.solana;return new Promise(e&&e.isBlocto?t=>{e.on("connect",()=>{v(this.sessionKey,K.SOLANA,[e.publicKey.toBase58()]),t()}),e.connect()}:(e,t)=>{if("undefined"==typeof window)return t("Currently only supported in browser");if(p(this.sessionKey,K.SOLANA))return e();let r=encodeURIComponent(window.location.origin),n=N(`${this.server}/${this.appId}/solana/authn?l6n=${r}&v=${C}`);B(n),J("message",(r,i)=>{r.origin===this.server&&("SOL:FRAME:RESPONSE"===r.data.type&&(i(),U(n),this.eventListeners.connect.forEach(e=>e(this.net)),f(this.sessionKey,{code:r.data.code,connected:!0,accounts:{[K.SOLANA]:[r.data.addr]}},r.data.exp),e()),"SOL:FRAME:CLOSE"===r.data.type&&(i(),U(n),t(Error("User declined the login request"))))})})})}disconnect(){return i(this,void 0,void 0,function*(){let e=window.solana;if(e&&e.isBlocto){yield e.disconnect();return}this.eventListeners.disconnect.forEach(e=>e(null)),g(this.sessionKey,K.SOLANA)})}fetchAccounts(){var e;return i(this,void 0,void 0,function*(){let t=(null===(e=d(this.sessionKey))||void 0===e?void 0:e.code)||"",{accounts:r}=yield fetch(`${this.server}/api/solana/accounts`,{headers:{"Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":t}}).then(e=>V(e,this.sessionKey));return v(this.sessionKey,K.SOLANA,r),r})}handleReadRequests(e){return i(this,void 0,void 0,function*(){return fetch(this.rpc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({id:1,jsonrpc:"2.0"},e))}).then(e=>e.json())})}convertToProgramWalletTransaction(e){return i(this,void 0,void 0,function*(){let t=window.solana;if(t&&t.isBlocto)return t.convertToProgramWalletTransaction(e);let r=yield this.request({method:"convertToProgramWalletTransaction",params:{message:e.serializeMessage().toString("hex")}});return this.toTransaction(r,[])})}signAndSendTransaction(e,t){return i(this,void 0,void 0,function*(){let r=window.solana;if(r&&r.isBlocto)return r.signAndSendTransaction(e);let n={};if(t){t.commitment&&(n.commitment=t.commitment);let e=t?t._rpcEndpoint:null;e&&e!==this.rpc&&(this.rpc=e,this.disconnect(),yield this.connect())}return this.request({method:"signAndSendTransaction",params:Object.assign({signatures:yield this.collectSignatures(e),message:e.serializeMessage().toString("hex")},n)})})}toTransaction(e,t){return i(this,void 0,void 0,function*(){let r=n.Message.from(eY.from(e,"hex")),i=new n.Transaction;return i.recentBlockhash=r.recentBlockhash,r.header.numRequiredSignatures>0&&(i.feePayer=r.accountKeys[0]),t.forEach((e,t)=>{let o={signature:e===n.PublicKey.default.toBase58()?null:tc.decode(e),publicKey:r.accountKeys[t]};i.signatures.push(o)}),r.instructions.forEach(e=>{let t=e.accounts.map(e=>{let t=r.accountKeys[e];return{pubkey:t,isSigner:e<r.header.numRequiredSignatures,isWritable:r.isAccountWritable(e)}});i.instructions.push(new n.TransactionInstruction({keys:t,programId:r.accountKeys[e.programIdIndex],data:tc.decode(e.data)}))}),i})}collectSignatures(e){return i(this,void 0,void 0,function*(){return e.signatures.reduce((e,t)=>(t.signature&&(e[t.publicKey.toBase58()]=t.signature.toString("hex")),e),{})})}handleConvertTransaction(e){var t;return i(this,void 0,void 0,function*(){let r=(null===(t=d(this.sessionKey))||void 0===t?void 0:t.code)||"";return fetch(`${this.server}/api/solana/convertToWalletTx`,{method:"POST",headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":r},body:JSON.stringify(e.params)}).then(e=>V(e,this.sessionKey))})}handleSignAndSendTransaction(e){var t;return i(this,void 0,void 0,function*(){let r=(null===(t=d(this.sessionKey))||void 0===t?void 0:t.code)||"",{authorizationId:n}=yield fetch(`${this.server}/api/solana/authz`,{method:"POST",headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":r},body:JSON.stringify(e.params)}).then(e=>V(e,this.sessionKey));if("undefined"==typeof window)throw Error("Currently only supported in browser");let i=N(`${this.server}/${this.appId}/solana/authz/${n}`);return B(i),new Promise((e,t)=>
1J("message",(r,n)=>{r.origin===this.server&&"SOL:FRAME:RESPONSE"===r.data.type&&("APPROVED"===r.data.status&&(n(),U(i),e(r.data.txHash)),"DECLINED"===r.data.status&&(n(),U(i),"incorrect_session_id"===r.data.errorCode&&this.disconnect(),t(Error(r.data.errorMessage))))}))})}}let tl=e=>{var t,r;let n=Object.assign({},e),{message:i,nonce:o,address:s,application:a,chainId:u}=e;return"string"!=typeof i&&(n.message=null!==(t=String(i))&&void 0!==t?t:""),"string"!=typeof o&&(n.nonce=null!==(r=String(o))&&void 0!==r?r:""),s&&"boolean"!=typeof s&&(n.address=!!s),a&&"boolean"!=typeof a&&(n.application=!!a),u&&"boolean"!=typeof u&&(n.chainId=!!u),n};class td extends j{constructor({chainId:e,server:t,appId:r}){super(),this.publicKey=[],this.authKey="",s(e,"'chainId' is required"),s(r,"It is necessary to interact with Blocto wallet via your app id. Please visit https://developers.blocto.app for more details."),this.chainId=e,this.networkName=P[e],this.api=R[e],this.sessionKey=A[e];let n=O[e];this.appId=r||I,this.server=t||n||""}get publicAccount(){var e;return{address:(null===(e=p(this.sessionKey,K.APTOS))||void 0===e?void 0:e[0])||null,publicKey:this.publicKey.length?this.publicKey:null,authKey:null,minKeysRequired:2}}network(){return i(this,void 0,void 0,function*(){return{name:this.networkName,api:this.api,chainId:this.chainId.toString()}})}isConnected(){var e;return i(this,void 0,void 0,function*(){return!!(null===(e=d(this.sessionKey))||void 0===e?void 0:e.code)})}signTransaction(e){var t;return i(this,void 0,void 0,function*(){let r=window.bloctoAptos;if(r)return r.signTransaction(e);let n=yield this.isConnected();if(n||(yield this.connect()),!(null===(t=p(this.sessionKey,K.APTOS))||void 0===t?void 0:t.length))throw Error("Fail to get account");throw Error("signTransaction method not supported.")})}disconnect(){return i(this,void 0,void 0,function*(){let e=window.bloctoAptos;if(e){yield e.disconnect();return}g(this.sessionKey,K.APTOS)})}signAndSubmitTransaction(e,t={}){var r,n;return i(this,void 0,void 0,function*(){let i=window.bloctoAptos;if(i)return i.signAndSubmitTransaction(e,t);let o=yield this.isConnected();if(o||(yield this.connect()),!(null===(r=p(this.sessionKey,K.APTOS))||void 0===r?void 0:r.length))throw Error("Fail to get account");let s=(null===(n=d(this.sessionKey))||void 0===n?void 0:n.code)||"",{authorizationId:a}=yield fetch(`${this.server}/api/aptos/authz`,{method:"POST",headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":s},body:JSON.stringify(Object.assign(Object.assign({},e),t))}).then(e=>V(e,this.sessionKey));if("undefined"==typeof window)throw Error("Currently only supported in browser");let u=N(`${this.server}/${this.appId}/aptos/authz/${a}`);return B(u),new Promise((e,t)=>J("message",(r,n)=>{r.origin===this.server&&"APTOS:FRAME:RESPONSE"===r.data.type&&("APPROVED"===r.data.status&&(n(),U(u),e({hash:r.data.txHash})),"DECLINED"===r.data.status&&(n(),U(u),"incorrect_session_id"===r.data.errorCode&&this.disconnect(),t(Error(r.data.errorMessage))))}))})}signMessage(e){var t,r;return i(this,void 0,void 0,function*(){let n=window.bloctoAptos,i=tl(e);if(n)return n.signMessage(i);let o=yield this.isConnected();if(o||(yield this.connect()),!(null===(t=p(this.sessionKey,K.APTOS))||void 0===t?void 0:t.length))throw Error("Fail to get account");if("undefined"==typeof window)throw Error("Currently only supported in browser");let s=(null===(r=d(this.sessionKey))||void 0===r?void 0:r.code)||"",{signatureId:a}=yield fetch(`${this.server}/api/aptos/user-signature`,{method:"POST",headers:{"Content-Type":"application/json","Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":s},body:JSON.stringify(i)}).then(e=>V(e,this.sessionKey)),u=`${this.server}/${this.appId}/aptos/user-signature/${a}`,c=N(u);return B(c),new Promise((e,t)=>J("message",(r,n)=>{r.origin===this.server&&"APTOS:FRAME:RESPONSE"===r.data.type&&("APPROVED"===r.data.status&&(n(),U(c),e(r.data)),"DECLINED"===r.data.status&&(n(),U(c),"incorrect_session_id"===r.data.errorCode&&this.disconnect(),t(Error(r.data.errorMessage))))}))})}connect(){return i(this,void 0,void 0,function*(){let e=window.bloctoAptos;return new Promise(e?(t,r)=>setTimeout(()=>
1e.connect().then(t).catch(r),10):(e,t)=>{var r,n;if("undefined"==typeof window)return t("Currently only supported in browser");if(null===(r=p(this.sessionKey,K.APTOS))||void 0===r?void 0:r.length)return e({address:(null===(n=p(this.sessionKey,K.APTOS))||void 0===n?void 0:n[0])||null,publicKey:this.publicKey,authKey:null,minKeysRequired:2});let o=encodeURIComponent(window.location.origin),s=N(`${this.server}/${this.appId}/aptos/authn?l6n=${o}&v=${C}}`);B(s),J("message",(r,n)=>i(this,void 0,void 0,function*(){var i,o,a;if(r.origin===this.server){if("APTOS:FRAME:RESPONSE"===r.data.type){if(n(),U(s),f(this.sessionKey,{code:r.data.code,connected:!0,accounts:{[K.APTOS]:[r.data.addr]}},r.data.exp),null===(i=p(this.sessionKey,K.APTOS))||void 0===i||!i.length)return t();try{let{public_keys:t}=yield fetch(`${this.server}/blocto/aptos/accounts/${null===(o=p(this.sessionKey,K.APTOS))||void 0===o?void 0:o[0]}`).then(e=>e.json());this.publicKey=t||[],e({address:(null===(a=p(this.sessionKey,K.APTOS))||void 0===a?void 0:a[0])||"",publicKey:this.publicKey,authKey:null,minKeysRequired:2})}catch(e){return t(r)}}"APTOS:FRAME:CLOSE"===r.data.type&&(n(),U(s),t(Error("User declined the login request")))}}))})})}fetchAddress(){var e;return i(this,void 0,void 0,function*(){let t=(null===(e=d(this.sessionKey))||void 0===e?void 0:e.code)||"",{accounts:r}=yield fetch(`${this.server}/api/aptos/accounts`,{headers:{"Blocto-Application-Identifier":this.appId,"Blocto-Session-Identifier":t}}).then(e=>V(e,this.sessionKey));return v(this.sessionKey,K.APTOS,r),(null==r?void 0:r[0])||""})}}class tf{constructor({appId:e,ethereum:t,solana:r,aptos:n}){t&&(this.ethereum=new tu(Object.assign(Object.assign({}
1,t),{appId:e}))),r&&(this.solana=new th(Object.assign(Object.assign({},r),{appId:e}))),n&&(this.aptos=new td(Object.assign(Object.assign({},n),{appId:e})))}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.