diff --git a/dist/nkn.js b/dist/nkn.js index b7efbc9..6610fa1 100644 --- a/dist/nkn.js +++ b/dist/nkn.js @@ -111,6 +111,7 @@ class Client { this.eventListeners = { connect: [], connectFailed: [], + wsError: [], message: [] }; this.sigChainBlockHash = null; @@ -231,6 +232,15 @@ class Client { this.eventListeners.connectFailed.push(func); } + /** + * Add event listener function that will be called when client websocket + * connection throws an error. Multiple listeners will be called sequentially + * in the order of added. + */ + onWsError(func) { + this.eventListeners.wsError.push(func); + } + /** * Add event listener function that will be called when client receives a * message. Multiple listeners will be called sequentially in the order of @@ -755,8 +765,18 @@ class Client { } }; - ws.onerror = err => { - console.log(err.message); + ws.onerror = event => { + if (this.eventListeners.wsError.length > 0) { + this.eventListeners.wsError.forEach(async f => { + try { + await f(event); + } catch (e) { + console.log('WsError handler error:', e); + } + }); + } else { + console.log(event.message); + } }; } @@ -10317,6 +10337,7 @@ class MultiClient { this.eventListeners = { connect: [], connectFailed: [], + wsError: [], message: [], session: [] }; @@ -10454,6 +10475,22 @@ class MultiClient { console.log('All clients connect failed'); } }); + + Object.keys(this.clients).map(clientID => { + this.clients[clientID].onWsError(event => { + if (this.eventListeners.wsError.length > 0) { + this.eventListeners.wsError.forEach(async f => { + try { + await f(event); + } catch (e) { + console.log('WsError handler error:', e); + } + }); + } else { + console.log(event.message); + } + }); + }); } /** * Get the secret seed of the client. @@ -10658,6 +10695,17 @@ class MultiClient { onConnectFailed(func) { this.eventListeners.connectFailed.push(func); } + /** + * Add event listener function that will be called when any client websocket + * connection throws an error. Multiple listeners will be called sequentially + * in the order of added. + */ + + + onWsError(func) { + this.eventListeners.wsError.push(func); + } + /** * Add event listener function that will be called when client receives a * message. Multiple listeners will be called sequentially in the order of @@ -10670,8 +10718,6 @@ class MultiClient { * msg received will be sent back. Receiving reply or ACK will not trigger * the event listener. */ - - onMessage(func) { this.eventListeners.message.push(func); } diff --git a/dist/nkn.min.js b/dist/nkn.min.js index 4eddd7f..763de14 100644 --- a/dist/nkn.min.js +++ b/dist/nkn.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).nkn=e()}}(function(){var define,module,exports;return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var A="function"==typeof require&&require;if(!a&&A)return A(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var g=r[s]={exports:{}};t[s][0].call(g.exports,function(e){return i(t[s][1][e]||e)},g,g.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;sthis._connect(),this.reconnectInterval),this.reconnectInterval*=2,this.reconnectInterval>this.options.reconnectIntervalMax&&(this.reconnectInterval=this.options.reconnectIntervalMax)}_connectFailed(){this.isFailed||(this.isFailed=!0,this.eventListeners.connectFailed.length>0?this.eventListeners.connectFailed.forEach(async e=>{try{await e()}catch(e){console.log("Connect failed handler error:",e)}}):console.log("Client connect failed"))}on(e,t){this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(t)}onConnect(e){this.eventListeners.connect.push(e)}onConnectFailed(e){this.eventListeners.connectFailed.push(e)}onMessage(e){this.eventListeners.message.push(e)}_wsSend(e){if(!this.ws)throw new o.errors.ClientNotReadyError;this.ws.send(e)}async _processDest(e){if(0===e.length)throw new o.errors.InvalidDestinationError("destination is empty");let t=e.split(".");if(t[t.length-1].length<2*o.key.publicKeyLength){let r=await this.getRegistrant(t[t.length-1]);if(!(r.registrant&&r.registrant.length>0))throw new o.errors.InvalidDestinationError(e+" is neither a valid public key nor a registered name");t[t.length-1]=r.registrant}return t.join(".")}async _processDests(e){if(Array.isArray(e)){if(0===e.length)throw new o.errors.InvalidDestinationError("no destinations");if(0===(e=(e=await Promise.all(e.map(async e=>{try{return await this._processDest(e)}catch(e){return console.warn(e.message),""}}))).filter(e=>e.length>0)).length)throw new o.errors.InvalidDestinationError("all destinations are invalid")}else e=await this._processDest(e);return e}async _send(e,t,r=!0,n=0){if(Array.isArray(e)){if(0===e.length)return null;if(1===e.length)return await this._send(e[0],t,r,n)}e=await this._processDests(e);let i=await this._messageFromPayload(t,r,e),s=[],A=[],c=[];if((i=i.map(e=>e.serializeBinary())).length>1){let t=0,r=0;for(let g=0;ga.maxClientMessageSize)throw new o.errors.DataSizeTooLargeError("encoded message is greater than "+a.maxClientMessageSize+" bytes");t+r>a.maxClientMessageSize&&(s.push(await a.newOutboundMessage(this,A,c,n)),A=[],c=[],t=0),A.push(e[g]),c.push(i[g]),t+=r}}else{let t=i[0].length;if(Array.isArray(e))for(let r=0;ra.maxClientMessageSize)throw new o.errors.DataSizeTooLargeError("encoded message is greater than "+a.maxClientMessageSize+" bytes");A=e,c=i}return s.push(await a.newOutboundMessage(this,A,c,n)),s.length>1&&console.log(`Client message size is greater than ${a.maxClientMessageSize} bytes, split into ${s.length} batches.`),s.forEach(e=>{this._wsSend(e.serializeBinary())}),t.getMessageId()||null}async send(e,t,r={}){let n;r=o.util.assignDefined({},this.options,r),n="string"==typeof t?a.newTextPayload(t,r.replyToId,r.messageId):a.newBinaryPayload(t,r.replyToId,r.messageId);let i=await this._send(e,n,r.encrypt,r.msgHoldingSeconds);return null===i||r.noReply?null:await new Promise((e,t)=>{this.responseManager.add(new u(i,r.responseTimeout,e,t))})}async _sendACK(e,t,r){if(Array.isArray(e)){if(0===e.length)return;if(1===e.length)return await this._sendACK(e[0],t,r);if(e.length>1&&r){console.warn("Encrypted ACK with multicast is not supported, fallback to unicast.");for(let n=0;n=r.limit;){if(n+=r.limit,!((i=await this.getSubscribers(e,{offset:n,limit:r.limit})).subscribers instanceof Array))throw new o.errors.InvalidResponseError("subscribers should be an array");a=a.concat(i.subscribers)}return r.txPool&&A&&(a=a.concat(A)),await this.send(a,t,r),null}close(){this.responseManager.stop(),this.shouldReconnect=!1;try{this.ws&&this.ws.close()}catch(e){}this.isClosed=!0}async _messageFromPayload(e,t,r){return t?await this._encryptPayload(e.serializeBinary(),r):[a.newMessage(e.serializeBinary(),!1)]}async _handleMsg(e){let t=o.pb.messages.ClientMessage.deserializeBinary(e);switch(t.getMessageType()){case o.pb.messages.ClientMessageType.INBOUND_MESSAGE:return await this._handleInboundMsg(t.getMessage());default:return!1}}async _handleInboundMsg(e){let t=o.pb.messages.InboundMessage.deserializeBinary(e),r=t.getPrevSignature();if(r.length>0){r=o.util.bytesToHex(r);let e=await a.newReceipt(this,r);this._wsSend(e.serializeBinary())}let n,i=o.pb.payloads.Message.deserializeBinary(t.getPayload());n=i.getEncrypted()?await this._decryptPayload(i,t.getSrc()):i.getPayload();let s=o.pb.payloads.Payload.deserializeBinary(n),A=s.getData();switch(s.getType()){case o.pb.payloads.PayloadType.TEXT:let e=o.pb.payloads.TextData.deserializeBinary(A);A=e.getText();break;case o.pb.payloads.PayloadType.ACK:return this.responseManager.respond(s.getReplyToId(),null,s.getType()),!0}if(s.getReplyToId().length)return this.responseManager.respond(s.getReplyToId(),A,s.getType()),!0;switch(s.getType()){case o.pb.payloads.PayloadType.TEXT:case o.pb.payloads.PayloadType.BINARY:case o.pb.payloads.PayloadType.SESSION:if(this.eventListeners.message.length>0){let e=await Promise.all(this.eventListeners.message.map(async e=>{try{return await e({src:t.getSrc(),payload:A,payloadType:s.getType(),isEncrypted:i.getEncrypted(),messageId:s.getMessageId(),noReply:s.getNoReply()})}catch(e){return console.log("Message handler error:",e),null}}));if(!s.getNoReply()){let r=!1;for(let n of e){if(!1===n)return!0;if(void 0!==n&&null!==n){this.send(t.getSrc(),n,{encrypt:i.getEncrypted(),msgHoldingSeconds:0,replyToId:s.getMessageId()}).catch(e=>{console.log("Send response error:",e)}),r=!0;break}}r||await this._sendACK(t.getSrc(),s.getMessageId(),i.getEncrypted())}}return!0;default:return!1}}_shouldUseTls(){return void 0!==this.options.tls?!!this.options.tls:"undefined"!=typeof window&&!(!window.location||"https:"!==window.location.protocol)}_newWsAddr(e){if(!e.addr)return console.log("No address in node info",e),void(this.shouldReconnect?this._reconnect():this.isClosed||this._connectFailed());let t,r=this._shouldUseTls();try{(t=new n.default((r?"wss":"ws")+"://"+e.addr)).binaryType="arraybuffer"}catch(e){return console.log("Create WebSocket failed,",e),void(this.shouldReconnect?this._reconnect():this.isClosed||this._connectFailed())}if(this.ws){this.ws.onclose=(()=>{});try{this.ws.close()}catch(e){}}if(this.isClosed)try{t.close()}catch(e){}else this.ws=t,this.node=e,e.rpcAddr?this.wallet.options.rpcServerAddr=(r?"https":"http")+"://"+e.rpcAddr:this.wallet.options.rpcServerAddr="",t.onopen=(()=>{t.send(JSON.stringify({Action:"setClient",Addr:this.addr})),this.shouldReconnect=!0,this.reconnectInterval=this.options.reconnectIntervalMin}),t.onmessage=(async e=>{if(e.data instanceof ArrayBuffer){try{await this._handleMsg(e.data)||console.warn("Unhandled msg.")}catch(e){console.log(e)}return}let t=JSON.parse(e.data);if(void 0===t.Error||t.Error===o.errors.rpcRespErrCodes.success)switch(t.Action){case"setClient":this.sigChainBlockHash=t.Result.sigChainBlockHash,this.isReady||(this.isReady=!0,this.eventListeners.connect.length>0&&this.eventListeners.connect.forEach(async e=>{try{await e(t.Result)}catch(e){console.log("Connect handler error:",e)}}));break;case"updateSigChainBlockHash":this.sigChainBlockHash=t.Result;break;default:console.warn("Unknown msg type:",t.Action)}else if(console.log(t),t.Error===o.errors.rpcRespErrCodes.wrongNode)this._newWsAddr(t.Result);else if("setClient"===t.Action)try{this.ws&&this.ws.close()}catch(e){}}),t.onclose=(()=>{this.shouldReconnect?(console.warn("WebSocket unexpectedly closed."),this._reconnect()):this.isClosed||this._connectFailed()}),t.onerror=(e=>{console.log(e.message)})}async _encryptPayload(e,t){if(Array.isArray(t)){let r=o.util.randomBytes(o.crypto.nonceLength),n=o.util.randomBytes(o.crypto.keyLength),i=await o.crypto.encryptSymmetric(e,r,n),s=[];for(let e=0;e0){if(s.length!=2*o.crypto.nonceLength)throw new o.errors.DecryptionError("invalid nonce length");let e=await this.key.decrypt(A,s.slice(0,o.crypto.nonceLength),i);if(null===e)throw new o.errors.DecryptionError("decrypt shared key failed");if(null===(r=await o.crypto.decryptSymmetric(n,s.slice(o.crypto.nonceLength),e)))throw new o.errors.DecryptionError("decrypt message failed")}else{if(s.length!=o.crypto.nonceLength)throw new o.errors.DecryptionError("invalid nonce length");if(null===(r=await this.key.decrypt(n,s,i)))throw new o.errors.DecryptionError("decrypt message failed")}return r}async getLatestBlock(){if(this.wallet.options.rpcServerAddr)try{return await i.default.getLatestBlock(this.options)}catch(e){}return await i.default.getLatestBlock(this.options)}async getRegistrant(e){if(this.wallet.options.rpcServerAddr)try{return await i.default.getRegistrant(e,this.wallet.options)}catch(e){}return await i.default.getRegistrant(e,this.options)}async getSubscribers(e,t={}){if(this.wallet.options.rpcServerAddr)try{return await i.default.getSubscribers(e,Object.assign({},this.wallet.options,t))}catch(e){}return await i.default.getSubscribers(e,Object.assign({},this.options,t))}async getSubscribersCount(e){if(this.wallet.options.rpcServerAddr)try{return await i.default.getSubscribersCount(e,this.wallet.options)}catch(e){}return await i.default.getSubscribersCount(e,this.options)}async getSubscription(e,t){if(this.wallet.options.rpcServerAddr)try{return await i.default.getSubscription(e,t,this.wallet.options)}catch(e){}return await i.default.getSubscription(e,t,this.options)}async getBalance(e){if(this.wallet.options.rpcServerAddr)try{return await i.default.getBalance(e||this.wallet.address,this.wallet.options)}catch(e){}return await i.default.getBalance(e||this.wallet.address,this.options)}async getNonce(e,t={}){if(this.wallet.options.rpcServerAddr)try{return await i.default.getNonce(e||this.wallet.address,Object.assign({},this.wallet.options,t))}catch(e){}return await i.default.getNonce(e||this.wallet.address,Object.assign({},this.options,t))}async sendTransaction(e){if(this.wallet.options.rpcServerAddr)try{return await i.default.sendTransaction(e,this.wallet.options)}catch(e){}return await i.default.sendTransaction(e,this.options)}transferTo(e,t,r={}){return o.rpc.transferTo.call(this,e,t,r)}registerName(e,t={}){return o.rpc.registerName.call(this,e,t)}transferName(e,t,r={}){return o.rpc.transferName.call(this,e,t,r)}deleteName(e,t={}){return o.rpc.deleteName.call(this,e,t)}subscribe(e,t,r="",n="",i={}){return o.rpc.subscribe.call(this,e,t,r,n,i)}unsubscribe(e,t="",r={}){return o.rpc.unsubscribe.call(this,e,t,r)}createTransaction(e,t,r={}){return this.wallet.createTransaction(e,t,r)}};class u{constructor(e,t,r,n){f(this,"messageId",void 0),f(this,"deadline",void 0),f(this,"responseHandler",void 0),f(this,"timeoutHandler",void 0),e instanceof Uint8Array&&(e=o.util.bytesToHex(e)),this.messageId=e,t&&(this.deadline=Date.now()+t),this.responseHandler=r,this.timeoutHandler=n}checkTimeout(e){return!!this.deadline&&(e||(e=Date.now()),e>this.deadline)}handleResponse(e){this.responseHandler&&this.responseHandler(e)}handleTimeout(){this.timeoutHandler&&this.timeoutHandler(new Error("Message timeout"))}}class l{constructor(){f(this,"responseProcessors",void 0),f(this,"timer",void 0),this.responseProcessors=new Map,this.timer=null,this.checkTimeout()}add(e){this.responseProcessors.set(e.messageId,e)}clear(){for(let e of this.responseProcessors.values())e.handleTimeout();this.responseProcessors=new Map}stop(){clearTimeout(this.timer),this.clear()}respond(e,t,r){e instanceof Uint8Array&&(e=o.util.bytesToHex(e));let n=this.responseProcessors.get(e);n&&(n.handleResponse(t),this.responseProcessors.delete(e))}checkTimeout(){let e=[],t=Date.now();for(let r of this.responseProcessors.values())r.checkTimeout(t)&&e.push(r);e.forEach(e=>{e.handleTimeout(),this.responseProcessors.delete(e.messageId)}),this.timer=setTimeout(this.checkTimeout.bind(this),s.checkTimeoutInterval)}}},{"../common":10,"../wallet":28,"./consts":2,"./message":4,"isomorphic-ws":309}],2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultPublishOptions=r.defaultOptions=r.checkTimeoutInterval=void 0;r.defaultOptions={reconnectIntervalMin:1e3,reconnectIntervalMax:64e3,responseTimeout:5e3,msgHoldingSeconds:0,encrypt:!0,rpcServerAddr:"https://mainnet-rpc-node-0001.nkn.org/mainnet/api/wallet",worker:!1};r.defaultPublishOptions={txPool:!1,offset:0,limit:1e3};r.checkTimeoutInterval=250},{}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return i.default}});var n,i=(n=e("./client"))&&n.__esModule?n:{default:n}},{"./client":1}],4:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addrToID=u,r.addrToPubkey=l,r.messageIdSize=r.maxClientMessageSize=void 0,r.newAckPayload=function(e,t){return A(o.pb.payloads.PayloadType.ACK,e,null,t)},r.newBinaryPayload=function(e,t,r){return A(o.pb.payloads.PayloadType.BINARY,t,e,r)},r.newClientMessage=c,r.newMessage=function(e,t,r,n){let i=new o.pb.payloads.Message;i.setPayload(e),i.setEncrypted(t),r&&i.setNonce(r);n&&i.setEncryptedKey(n);return i},r.newOutboundMessage=async function(e,r,n,i){Array.isArray(r)||(r=[r]);if(0===r.length)throw new o.errors.InvalidArgumentError("no destination");Array.isArray(n)||(n=[n]);if(0===n.length)throw new o.errors.InvalidArgumentError("no payloads");if(n.length>1&&n.length!==r.length)throw new o.errors.InvalidArgumentError("invalid payload array length");let s=new o.pb.sigchain.SigChainElem;s.setNextPubkey(t.from(e.node.pubkey,"hex"));let a=f(s),A=new o.pb.sigchain.SigChain;A.setNonce(o.util.randomInt32()),e.sigChainBlockHash&&A.setBlockHash(t.from(e.sigChainBlockHash,"hex"));A.setSrcId(t.from(u(e.addr),"hex")),A.setSrcPubkey(t.from(e.key.publicKey,"hex"));let h,d,p,y=[];for(let i=0;i1?A.setDataSize(n[i].length):A.setDataSize(n[0].length),h=g(A),d=o.hash.sha256Hex(h),d=o.hash.sha256Hex(d+a),p=await e.key.sign(d),y.push(t.from(p,"hex"));let I,b=new o.pb.messages.OutboundMessage;b.setDestsList(r),b.setPayloadsList(n),b.setMaxHoldingSeconds(i),b.setNonce(A.getNonce()),b.setBlockHash(A.getBlockHash()),b.setSignaturesList(y),I=n.length>1?o.pb.messages.CompressionType.COMPRESSION_ZLIB:o.pb.messages.CompressionType.COMPRESSION_NONE;return c(o.pb.messages.ClientMessageType.OUTBOUND_MESSAGE,b.serializeBinary(),I)},r.newPayload=A,r.newReceipt=async function(e,r){let n=f(new o.pb.sigchain.SigChainElem),i=o.hash.sha256Hex(r);i=o.hash.sha256Hex(i+n);let s=await e.key.sign(i),a=new o.pb.messages.Receipt;return a.setPrevSignature(t.from(r,"hex")),a.setSignature(t.from(s,"hex")),c(o.pb.messages.ClientMessageType.RECEIPT,a.serializeBinary(),o.pb.messages.CompressionType.COMPRESSION_NONE)},r.newSessionPayload=function(e,t){return A(o.pb.payloads.PayloadType.SESSION,null,e,t)},r.newTextPayload=function(e,t,r){let n=new o.pb.payloads.TextData;return n.setText(e),A(o.pb.payloads.PayloadType.TEXT,t,n.serializeBinary(),r)},r.serializeSigChainElem=f,r.serializeSigChainMetadata=g;var n,i=(n=e("pako"))&&n.__esModule?n:{default:n},o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,r&&r.set(e,n);return n}(e("../common"));function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}const a=8;r.messageIdSize=a;function A(e,t,r,n){let i=new o.pb.payloads.Payload;return i.setType(e),t?i.setReplyToId(t):n?i.setMessageId(n):i.setMessageId(o.util.randomBytes(a)),i.setData(r),i}function c(e,t,r){let n=new o.pb.messages.ClientMessage;switch(n.setMessageType(e),n.setCompressionType(r),r){case o.pb.messages.CompressionType.COMPRESSION_NONE:break;case o.pb.messages.CompressionType.COMPRESSION_ZLIB:t=i.default.deflate(t);break;default:throw new o.errors.InvalidArgumentError("unknown compression type "+r)}return n.setMessage(t),n}function g(e){let t="";return t+=o.serialize.encodeUint32(e.getNonce()),t+=o.serialize.encodeUint32(e.getDataSize()),t+=o.serialize.encodeBytes(e.getBlockHash()),t+=o.serialize.encodeBytes(e.getSrcId()),t+=o.serialize.encodeBytes(e.getSrcPubkey()),t+=o.serialize.encodeBytes(e.getDestId()),t+=o.serialize.encodeBytes(e.getDestPubkey())}function f(e){let t="";return t+=o.serialize.encodeBytes(e.getId()),t+=o.serialize.encodeBytes(e.getNextPubkey()),t+=o.serialize.encodeBool(e.getMining())}function u(e){return o.hash.sha256(e)}function l(e){let t=e.split(".");return t[t.length-1]}r.maxClientMessageSize=4e6}).call(this,e("buffer").Buffer)},{"../common":10,buffer:119,pako:317}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decrypt=function(e,t,r){return i.default.AES.decrypt(i.default.enc.Hex.parse(e).toString(i.default.enc.Base64),i.default.enc.Hex.parse(t),{iv:i.default.enc.Hex.parse(r),mode:i.default.mode.CBC,padding:i.default.pad.NoPadding}).toString()},r.encrypt=function(e,t,r){return i.default.AES.encrypt(i.default.enc.Hex.parse(e),i.default.enc.Hex.parse(t),{iv:i.default.enc.Hex.parse(r),mode:i.default.mode.CBC,padding:i.default.pad.NoPadding}).ciphertext.toString(i.default.enc.Hex)};var n,i=(n=e("crypto-js"))&&n.__esModule?n:{default:n};!function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=o(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=i?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}n.default=e,r&&r.set(e,n)}(e("./hash"));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}},{"./hash":9,"crypto-js":232}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,i,o,s=e("decimal.js");s.Decimal.set({minE:-8});class a extends s.Decimal{value(){return this.times(a.unit).floor()}}r.default=a,n=a,i="unit",o=new s.Decimal("100000000"),i in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o},{"decimal.js":258}],7:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.computeSharedKey=async function(e,r){let n,a=await f(t.from(r,"hex"));try{n=i.default.crypto_box_beforenm(a,e)}catch(t){console.warn(t),n=o.default.box.before(a,e)}return s.bytesToHex(n)},r.decryptSymmetric=async function(e,t,r){try{return c||(await i.default.ready,c=!0),i.default.crypto_box_open_easy_afternm(e,t,r)}catch(n){return console.warn(n),o.default.secretbox.open(e,t,r)}},r.ed25519PkToCurve25519=f,r.ed25519SkToCurve25519=g,r.encryptSymmetric=async function(e,t,r){try{return c||(await i.default.ready,c=!0),i.default.crypto_box_easy_afternm(e,t,r)}catch(n){return console.warn(n),o.default.secretbox(e,t,r)}},r.keyLength=void 0,r.keyPair=function(e){let t=s.hexToBytes(e);try{let r=i.default.crypto_sign_seed_keypair(t);return{seed:e,publicKey:r.publicKey,privateKey:r.privateKey,curvePrivateKey:g(r.privateKey)}}catch(r){let i=o.default.sign.keyPair.fromSeed(t);return{seed:e,publicKey:i.publicKey,privateKey:i.secretKey,curvePrivateKey:n.default.convertSecretKey(i.secretKey)}}},r.seedLength=r.publicKeyLength=r.nonceLength=void 0,r.sign=async function(e,r){let n;try{c||(await i.default.ready,c=!0),n=i.default.crypto_sign_detached(t.from(r,"hex"),e)}catch(i){console.warn(i),n=o.default.sign.detached(t.from(r,"hex"),e)}return s.bytesToHex(n)},r.signatureLength=void 0;var n=A(e("ed2curve")),i=A(e("libsodium-wrappers")),o=A(e("tweetnacl")),s=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}n.default=e,r&&r.set(e,n);return n}(e("./util"));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}function A(e){return e&&e.__esModule?e:{default:e}}r.keyLength=32;r.nonceLength=24;r.publicKeyLength=32;r.seedLength=32;r.signatureLength=64;let c=!1;function g(e){try{return i.default.crypto_sign_ed25519_sk_to_curve25519(e)}catch(t){return n.default.convertSecretKey(e)}}async function f(e){try{return c||(await i.default.ready,c=!0),i.default.crypto_sign_ed25519_pk_to_curve25519(e)}catch(t){return console.warn(t),n.default.convertPublicKey(e)}}}).call(this,e("buffer").Buffer)},{"./util":19,buffer:119,ed2curve:269,"libsodium-wrappers":310,tweetnacl:383}],8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.rpcRespErrCodes=r.WrongPasswordError=r.UnknownError=r.ServerError=r.RpcTimeoutError=r.RpcError=r.NotEnoughBalanceError=r.InvalidWalletVersionError=r.InvalidWalletFormatError=r.InvalidResponseError=r.InvalidDestinationError=r.InvalidArgumentError=r.InvalidAddressError=r.DecryptionError=r.DataSizeTooLargeError=r.ClientNotReadyError=r.AddrNotAllowedError=void 0;r.rpcRespErrCodes={success:0,wrongNode:48001,appendTxnPool:45021};class n extends Error{constructor(e="address not allowed",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,n),this.name="AddrNotAllowedError"}}r.AddrNotAllowedError=n;class i extends Error{constructor(e="client not ready",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="ClientNotReadyError"}}r.ClientNotReadyError=i;class o extends Error{constructor(e="data size too large",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,o),this.name="DataSizeTooLargeError"}}r.DataSizeTooLargeError=o;class s extends Error{constructor(e="decrypt message error",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,s),this.name="DecryptionError"}}r.DecryptionError=s;class a extends Error{constructor(e="unknown error",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,a),this.name="UnknownError"}}r.UnknownError=a;class A extends Error{constructor(e="not enough balance",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,A),this.name="NotEnoughBalanceError"}}r.NotEnoughBalanceError=A;class c extends Error{constructor(e="wrong password",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,c),this.name="WrongPasswordError"}}r.WrongPasswordError=c;class g extends Error{constructor(e="invalid wallet address",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,g),this.name="InvalidAddressError"}}r.InvalidAddressError=g;class f extends Error{constructor(e="invalid wallet format",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,f),this.name="InvalidWalletFormatError"}}r.InvalidWalletFormatError=f;class u extends Error{constructor(e="invalid wallet version",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,u),this.name="InvalidWalletVersionError"}}r.InvalidWalletVersionError=u;class l extends Error{constructor(e="invalid argument",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,l),this.name="InvalidArgumentError"}}r.InvalidArgumentError=l;class h extends Error{constructor(e="invalid response from RPC server",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,h),this.name="InvalidResponseError"}}r.InvalidResponseError=h;class d extends Error{constructor(e="error from RPC server",...t){let r;super(r="object"==typeof e?e.message+": "+e.data:e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,d),this.name="ServerError",e.code&&(this.code=-e.code)}}r.ServerError=d;class p extends Error{constructor(e="invalid destination",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,p),this.name="InvalidDestinationError"}}r.InvalidDestinationError=p;class y extends Error{constructor(e="rpc timeout",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,y),this.name="RpcTimeoutError"}}r.RpcTimeoutError=y;class I extends Error{constructor(e="rpc error",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,I),this.name="RpcError"}}r.RpcError=I},{}],9:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.cryptoHexStringParse=o,r.doubleSha256=a,r.doubleSha256Hex=function(e){return a(o(e))},r.ripemd160=A,r.ripemd160Hex=function(e){return A(o(e))},r.sha256=s,r.sha256Hex=function(e){return s(o(e))};var n,i=(n=e("crypto-js"))&&n.__esModule?n:{default:n};function o(e){return i.default.enc.Hex.parse(e)}function s(e){return i.default.SHA256(e).toString()}function a(e){return i.default.SHA256(i.default.SHA256(e)).toString()}function A(e){return i.default.RIPEMD160(e).toString()}},{"crypto-js":232}],10:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"Amount",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(r,"Key",{enumerable:!0,get:function(){return o.default}}),r.util=r.serialize=r.rpc=r.pb=r.key=r.hash=r.errors=r.crypto=r.aes=void 0;var n,i=(n=e("./amount"))&&n.__esModule?n:{default:n},o=d(e("./key"));r.key=o;var s=d(e("./aes"));r.aes=s;var a=d(e("./crypto"));r.crypto=a;var A=d(e("./errors"));r.errors=A;var c=d(e("./hash"));r.hash=c;var g=d(e("./pb"));r.pb=g;var f=d(e("./rpc"));r.rpc=f;var u=d(e("./serialize"));r.serialize=u;var l=d(e("./util"));function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(h=function(e){return e?r:t})(e)}function d(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=h(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}r.util=l},{"./aes":5,"./amount":6,"./crypto":7,"./errors":8,"./hash":9,"./key":11,"./pb":12,"./rpc":17,"./serialize":18,"./util":19}],11:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,i=(n=e("webworkify"))&&n.__esModule?n:{default:n},o=A(e("./crypto")),s=(A(e("./errors")),A(e("./util")));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}function A(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.default=class{constructor(t,r={}){c(this,"seed",void 0),c(this,"publicKey",void 0),c(this,"privateKey",void 0),c(this,"curvePrivateKey",void 0),c(this,"sharedKeyCache",void 0),c(this,"useWorker",void 0),c(this,"worker",void 0),c(this,"workerMsgID",void 0),c(this,"workerMsgCache",void 0),t||(t=s.randomBytesHex(o.seedLength));let n=o.keyPair(t);this.seed=t,this.publicKey=s.bytesToHex(n.publicKey),this.privateKey=n.privateKey,this.curvePrivateKey=n.curvePrivateKey,this.sharedKeyCache=new Map,this.useWorker=this._shouldUseWorker(r.worker),this.worker=null,this.workerMsgID=0,this.workerMsgCache=new Map,this.useWorker&&(async()=>{try{if("function"==typeof r.worker)this.worker=await r.worker();else try{this.worker=(0,i.default)(e("../worker/worker.js"))}catch(t){try{let t=e("../worker/webpack.worker.js");this.worker=new t}catch(e){throw"neither browserify nor webpack worker-loader is detected"}}this.worker.onmessage=(e=>{if(void 0!==e.data.id&&this.workerMsgCache.has(e.data.id)){let t=this.workerMsgCache.get(e.data.id);e.data.error?t.reject(e.data.error):t.resolve(e.data.result),this.workerMsgCache.delete(e.data.id)}}),await this._sendToWorker({action:"setSeed",seed:this.seed})}catch(e){console.warn("Launch web worker failed:",e),this.useWorker=!1}})()}_shouldUseWorker(e){return!!e&&"undefined"!=typeof window&&!!window.Worker}_sendToWorker(e){return new Promise((t,r)=>{let n=this.workerMsgID;this.workerMsgID++,this.workerMsgCache.set(n,{resolve:t,reject:r}),this.worker.postMessage(Object.assign({id:n},e))})}async computeSharedKey(e){if(this.useWorker)try{return await this._sendToWorker({action:"computeSharedKey",otherPubkey:e})}catch(e){console.warn("worker computeSharedKey failed, fallback to main thread:",e)}return await o.computeSharedKey(this.curvePrivateKey,e)}async getOrComputeSharedKey(e){let t=this.sharedKeyCache.get(e);return t||(t=await this.computeSharedKey(e),this.sharedKeyCache.set(e,t)),t}async encrypt(e,r,n={}){let i=await this.getOrComputeSharedKey(r);i=t.from(i,"hex");let a=n.nonce||s.randomBytes(o.nonceLength);return{message:await o.encryptSymmetric(e,a,i),nonce:a}}async decrypt(e,r,n,i={}){let s=await this.getOrComputeSharedKey(n);return s=t.from(s,"hex"),await o.decryptSymmetric(e,r,s)}async sign(e){if(this.useWorker)try{return await this._sendToWorker({action:"sign",message:e})}catch(e){console.warn("worker sign failed, fallback to main thread:",e)}return await o.sign(this.privateKey,e)}}}).call(this,e("buffer").Buffer)},{"../worker/webpack.worker.js":31,"../worker/worker.js":32,"./crypto":7,"./errors":8,"./util":19,buffer:119,webworkify:386}],12:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.transaction=r.sigchain=r.payloads=r.messages=void 0;var n=A(e("./messages_pb"));r.messages=n;var i=A(e("./payloads_pb"));r.payloads=i;var o=A(e("./sigchain_pb"));r.sigchain=o;var s=A(e("./transaction_pb"));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}function A(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}r.transaction=s},{"./messages_pb":13,"./payloads_pb":14,"./sigchain_pb":15,"./transaction_pb":16}],13:[function(e,t,r){"use strict";var n=e("google-protobuf"),i=n,o=Function("return this")();i.exportSymbol("proto.messages.ClientMessage",null,o),i.exportSymbol("proto.messages.ClientMessageType",null,o),i.exportSymbol("proto.messages.CompressionType",null,o),i.exportSymbol("proto.messages.InboundMessage",null,o),i.exportSymbol("proto.messages.OutboundMessage",null,o),i.exportSymbol("proto.messages.Receipt",null,o),proto.messages.ClientMessage=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.messages.ClientMessage,n.Message),i.DEBUG&&!COMPILED&&(proto.messages.ClientMessage.displayName="proto.messages.ClientMessage"),proto.messages.OutboundMessage=function(e){n.Message.initialize(this,e,0,-1,proto.messages.OutboundMessage.repeatedFields_,null)},i.inherits(proto.messages.OutboundMessage,n.Message),i.DEBUG&&!COMPILED&&(proto.messages.OutboundMessage.displayName="proto.messages.OutboundMessage"),proto.messages.InboundMessage=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.messages.InboundMessage,n.Message),i.DEBUG&&!COMPILED&&(proto.messages.InboundMessage.displayName="proto.messages.InboundMessage"),proto.messages.Receipt=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.messages.Receipt,n.Message),i.DEBUG&&!COMPILED&&(proto.messages.Receipt.displayName="proto.messages.Receipt"),n.Message.GENERATE_TO_OBJECT&&(proto.messages.ClientMessage.prototype.toObject=function(e){return proto.messages.ClientMessage.toObject(e,this)},proto.messages.ClientMessage.toObject=function(e,t){var r={messageType:n.Message.getFieldWithDefault(t,1,0),message:t.getMessage_asB64(),compressionType:n.Message.getFieldWithDefault(t,3,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.messages.ClientMessage.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.messages.ClientMessage;return proto.messages.ClientMessage.deserializeBinaryFromReader(r,t)},proto.messages.ClientMessage.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readEnum();e.setMessageType(r);break;case 2:r=t.readBytes();e.setMessage(r);break;case 3:r=t.readEnum();e.setCompressionType(r);break;default:t.skipField()}}return e},proto.messages.ClientMessage.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.messages.ClientMessage.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.messages.ClientMessage.serializeBinaryToWriter=function(e,t){var r=void 0;0!==(r=e.getMessageType())&&t.writeEnum(1,r),(r=e.getMessage_asU8()).length>0&&t.writeBytes(2,r),0!==(r=e.getCompressionType())&&t.writeEnum(3,r)},proto.messages.ClientMessage.prototype.getMessageType=function(){return n.Message.getFieldWithDefault(this,1,0)},proto.messages.ClientMessage.prototype.setMessageType=function(e){n.Message.setProto3EnumField(this,1,e)},proto.messages.ClientMessage.prototype.getMessage=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.messages.ClientMessage.prototype.getMessage_asB64=function(){return n.Message.bytesAsB64(this.getMessage())},proto.messages.ClientMessage.prototype.getMessage_asU8=function(){return n.Message.bytesAsU8(this.getMessage())},proto.messages.ClientMessage.prototype.setMessage=function(e){n.Message.setProto3BytesField(this,2,e)},proto.messages.ClientMessage.prototype.getCompressionType=function(){return n.Message.getFieldWithDefault(this,3,0)},proto.messages.ClientMessage.prototype.setCompressionType=function(e){n.Message.setProto3EnumField(this,3,e)},proto.messages.OutboundMessage.repeatedFields_=[3,7,8],n.Message.GENERATE_TO_OBJECT&&(proto.messages.OutboundMessage.prototype.toObject=function(e){return proto.messages.OutboundMessage.toObject(e,this)},proto.messages.OutboundMessage.toObject=function(e,t){var r={dest:n.Message.getFieldWithDefault(t,1,""),payload:t.getPayload_asB64(),destsList:n.Message.getRepeatedField(t,3),maxHoldingSeconds:n.Message.getFieldWithDefault(t,4,0),nonce:n.Message.getFieldWithDefault(t,5,0),blockHash:t.getBlockHash_asB64(),signaturesList:t.getSignaturesList_asB64(),payloadsList:t.getPayloadsList_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.messages.OutboundMessage.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.messages.OutboundMessage;return proto.messages.OutboundMessage.deserializeBinaryFromReader(r,t)},proto.messages.OutboundMessage.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readString();e.setDest(r);break;case 2:r=t.readBytes();e.setPayload(r);break;case 3:r=t.readString();e.addDests(r);break;case 4:r=t.readUint32();e.setMaxHoldingSeconds(r);break;case 5:r=t.readUint32();e.setNonce(r);break;case 6:r=t.readBytes();e.setBlockHash(r);break;case 7:r=t.readBytes();e.addSignatures(r);break;case 8:r=t.readBytes();e.addPayloads(r);break;default:t.skipField()}}return e},proto.messages.OutboundMessage.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.messages.OutboundMessage.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.messages.OutboundMessage.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getDest()).length>0&&t.writeString(1,r),(r=e.getPayload_asU8()).length>0&&t.writeBytes(2,r),(r=e.getDestsList()).length>0&&t.writeRepeatedString(3,r),0!==(r=e.getMaxHoldingSeconds())&&t.writeUint32(4,r),0!==(r=e.getNonce())&&t.writeUint32(5,r),(r=e.getBlockHash_asU8()).length>0&&t.writeBytes(6,r),(r=e.getSignaturesList_asU8()).length>0&&t.writeRepeatedBytes(7,r),(r=e.getPayloadsList_asU8()).length>0&&t.writeRepeatedBytes(8,r)},proto.messages.OutboundMessage.prototype.getDest=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.messages.OutboundMessage.prototype.setDest=function(e){n.Message.setProto3StringField(this,1,e)},proto.messages.OutboundMessage.prototype.getPayload=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.messages.OutboundMessage.prototype.getPayload_asB64=function(){return n.Message.bytesAsB64(this.getPayload())},proto.messages.OutboundMessage.prototype.getPayload_asU8=function(){return n.Message.bytesAsU8(this.getPayload())},proto.messages.OutboundMessage.prototype.setPayload=function(e){n.Message.setProto3BytesField(this,2,e)},proto.messages.OutboundMessage.prototype.getDestsList=function(){return n.Message.getRepeatedField(this,3)},proto.messages.OutboundMessage.prototype.setDestsList=function(e){n.Message.setField(this,3,e||[])},proto.messages.OutboundMessage.prototype.addDests=function(e,t){n.Message.addToRepeatedField(this,3,e,t)},proto.messages.OutboundMessage.prototype.clearDestsList=function(){this.setDestsList([])},proto.messages.OutboundMessage.prototype.getMaxHoldingSeconds=function(){return n.Message.getFieldWithDefault(this,4,0)},proto.messages.OutboundMessage.prototype.setMaxHoldingSeconds=function(e){n.Message.setProto3IntField(this,4,e)},proto.messages.OutboundMessage.prototype.getNonce=function(){return n.Message.getFieldWithDefault(this,5,0)},proto.messages.OutboundMessage.prototype.setNonce=function(e){n.Message.setProto3IntField(this,5,e)},proto.messages.OutboundMessage.prototype.getBlockHash=function(){return n.Message.getFieldWithDefault(this,6,"")},proto.messages.OutboundMessage.prototype.getBlockHash_asB64=function(){return n.Message.bytesAsB64(this.getBlockHash())},proto.messages.OutboundMessage.prototype.getBlockHash_asU8=function(){return n.Message.bytesAsU8(this.getBlockHash())},proto.messages.OutboundMessage.prototype.setBlockHash=function(e){n.Message.setProto3BytesField(this,6,e)},proto.messages.OutboundMessage.prototype.getSignaturesList=function(){return n.Message.getRepeatedField(this,7)},proto.messages.OutboundMessage.prototype.getSignaturesList_asB64=function(){return n.Message.bytesListAsB64(this.getSignaturesList())},proto.messages.OutboundMessage.prototype.getSignaturesList_asU8=function(){return n.Message.bytesListAsU8(this.getSignaturesList())},proto.messages.OutboundMessage.prototype.setSignaturesList=function(e){n.Message.setField(this,7,e||[])},proto.messages.OutboundMessage.prototype.addSignatures=function(e,t){n.Message.addToRepeatedField(this,7,e,t)},proto.messages.OutboundMessage.prototype.clearSignaturesList=function(){this.setSignaturesList([])},proto.messages.OutboundMessage.prototype.getPayloadsList=function(){return n.Message.getRepeatedField(this,8)},proto.messages.OutboundMessage.prototype.getPayloadsList_asB64=function(){return n.Message.bytesListAsB64(this.getPayloadsList())},proto.messages.OutboundMessage.prototype.getPayloadsList_asU8=function(){return n.Message.bytesListAsU8(this.getPayloadsList())},proto.messages.OutboundMessage.prototype.setPayloadsList=function(e){n.Message.setField(this,8,e||[])},proto.messages.OutboundMessage.prototype.addPayloads=function(e,t){n.Message.addToRepeatedField(this,8,e,t)},proto.messages.OutboundMessage.prototype.clearPayloadsList=function(){this.setPayloadsList([])},n.Message.GENERATE_TO_OBJECT&&(proto.messages.InboundMessage.prototype.toObject=function(e){return proto.messages.InboundMessage.toObject(e,this)},proto.messages.InboundMessage.toObject=function(e,t){var r={src:n.Message.getFieldWithDefault(t,1,""),payload:t.getPayload_asB64(),prevSignature:t.getPrevSignature_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.messages.InboundMessage.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.messages.InboundMessage;return proto.messages.InboundMessage.deserializeBinaryFromReader(r,t)},proto.messages.InboundMessage.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readString();e.setSrc(r);break;case 2:r=t.readBytes();e.setPayload(r);break;case 3:r=t.readBytes();e.setPrevSignature(r);break;default:t.skipField()}}return e},proto.messages.InboundMessage.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.messages.InboundMessage.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.messages.InboundMessage.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSrc()).length>0&&t.writeString(1,r),(r=e.getPayload_asU8()).length>0&&t.writeBytes(2,r),(r=e.getPrevSignature_asU8()).length>0&&t.writeBytes(3,r)},proto.messages.InboundMessage.prototype.getSrc=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.messages.InboundMessage.prototype.setSrc=function(e){n.Message.setProto3StringField(this,1,e)},proto.messages.InboundMessage.prototype.getPayload=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.messages.InboundMessage.prototype.getPayload_asB64=function(){return n.Message.bytesAsB64(this.getPayload())},proto.messages.InboundMessage.prototype.getPayload_asU8=function(){return n.Message.bytesAsU8(this.getPayload())},proto.messages.InboundMessage.prototype.setPayload=function(e){n.Message.setProto3BytesField(this,2,e)},proto.messages.InboundMessage.prototype.getPrevSignature=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.messages.InboundMessage.prototype.getPrevSignature_asB64=function(){return n.Message.bytesAsB64(this.getPrevSignature())},proto.messages.InboundMessage.prototype.getPrevSignature_asU8=function(){return n.Message.bytesAsU8(this.getPrevSignature())},proto.messages.InboundMessage.prototype.setPrevSignature=function(e){n.Message.setProto3BytesField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.messages.Receipt.prototype.toObject=function(e){return proto.messages.Receipt.toObject(e,this)},proto.messages.Receipt.toObject=function(e,t){var r={prevSignature:t.getPrevSignature_asB64(),signature:t.getSignature_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.messages.Receipt.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.messages.Receipt;return proto.messages.Receipt.deserializeBinaryFromReader(r,t)},proto.messages.Receipt.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setPrevSignature(r);break;case 2:r=t.readBytes();e.setSignature(r);break;default:t.skipField()}}return e},proto.messages.Receipt.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.messages.Receipt.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.messages.Receipt.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getPrevSignature_asU8()).length>0&&t.writeBytes(1,r),(r=e.getSignature_asU8()).length>0&&t.writeBytes(2,r)},proto.messages.Receipt.prototype.getPrevSignature=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.messages.Receipt.prototype.getPrevSignature_asB64=function(){return n.Message.bytesAsB64(this.getPrevSignature())},proto.messages.Receipt.prototype.getPrevSignature_asU8=function(){return n.Message.bytesAsU8(this.getPrevSignature())},proto.messages.Receipt.prototype.setPrevSignature=function(e){n.Message.setProto3BytesField(this,1,e)},proto.messages.Receipt.prototype.getSignature=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.messages.Receipt.prototype.getSignature_asB64=function(){return n.Message.bytesAsB64(this.getSignature())},proto.messages.Receipt.prototype.getSignature_asU8=function(){return n.Message.bytesAsU8(this.getSignature())},proto.messages.Receipt.prototype.setSignature=function(e){n.Message.setProto3BytesField(this,2,e)},proto.messages.ClientMessageType={OUTBOUND_MESSAGE:0,INBOUND_MESSAGE:1,RECEIPT:2},proto.messages.CompressionType={COMPRESSION_NONE:0,COMPRESSION_ZLIB:1},i.object.extend(r,proto.messages)},{"google-protobuf":288}],14:[function(e,t,r){"use strict";var n=e("google-protobuf"),i=n,o=Function("return this")();i.exportSymbol("proto.payloads.Message",null,o),i.exportSymbol("proto.payloads.Payload",null,o),i.exportSymbol("proto.payloads.PayloadType",null,o),i.exportSymbol("proto.payloads.TextData",null,o),proto.payloads.Message=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.payloads.Message,n.Message),i.DEBUG&&!COMPILED&&(proto.payloads.Message.displayName="proto.payloads.Message"),proto.payloads.Payload=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.payloads.Payload,n.Message),i.DEBUG&&!COMPILED&&(proto.payloads.Payload.displayName="proto.payloads.Payload"),proto.payloads.TextData=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.payloads.TextData,n.Message),i.DEBUG&&!COMPILED&&(proto.payloads.TextData.displayName="proto.payloads.TextData"),n.Message.GENERATE_TO_OBJECT&&(proto.payloads.Message.prototype.toObject=function(e){return proto.payloads.Message.toObject(e,this)},proto.payloads.Message.toObject=function(e,t){var r={payload:t.getPayload_asB64(),encrypted:n.Message.getFieldWithDefault(t,2,!1),nonce:t.getNonce_asB64(),encryptedKey:t.getEncryptedKey_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.payloads.Message.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.payloads.Message;return proto.payloads.Message.deserializeBinaryFromReader(r,t)},proto.payloads.Message.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setPayload(r);break;case 2:r=t.readBool();e.setEncrypted(r);break;case 3:r=t.readBytes();e.setNonce(r);break;case 4:r=t.readBytes();e.setEncryptedKey(r);break;default:t.skipField()}}return e},proto.payloads.Message.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.payloads.Message.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.payloads.Message.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getPayload_asU8()).length>0&&t.writeBytes(1,r),(r=e.getEncrypted())&&t.writeBool(2,r),(r=e.getNonce_asU8()).length>0&&t.writeBytes(3,r),(r=e.getEncryptedKey_asU8()).length>0&&t.writeBytes(4,r)},proto.payloads.Message.prototype.getPayload=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.payloads.Message.prototype.getPayload_asB64=function(){return n.Message.bytesAsB64(this.getPayload())},proto.payloads.Message.prototype.getPayload_asU8=function(){return n.Message.bytesAsU8(this.getPayload())},proto.payloads.Message.prototype.setPayload=function(e){n.Message.setProto3BytesField(this,1,e)},proto.payloads.Message.prototype.getEncrypted=function(){return n.Message.getFieldWithDefault(this,2,!1)},proto.payloads.Message.prototype.setEncrypted=function(e){n.Message.setProto3BooleanField(this,2,e)},proto.payloads.Message.prototype.getNonce=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.payloads.Message.prototype.getNonce_asB64=function(){return n.Message.bytesAsB64(this.getNonce())},proto.payloads.Message.prototype.getNonce_asU8=function(){return n.Message.bytesAsU8(this.getNonce())},proto.payloads.Message.prototype.setNonce=function(e){n.Message.setProto3BytesField(this,3,e)},proto.payloads.Message.prototype.getEncryptedKey=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.payloads.Message.prototype.getEncryptedKey_asB64=function(){return n.Message.bytesAsB64(this.getEncryptedKey())},proto.payloads.Message.prototype.getEncryptedKey_asU8=function(){return n.Message.bytesAsU8(this.getEncryptedKey())},proto.payloads.Message.prototype.setEncryptedKey=function(e){n.Message.setProto3BytesField(this,4,e)},n.Message.GENERATE_TO_OBJECT&&(proto.payloads.Payload.prototype.toObject=function(e){return proto.payloads.Payload.toObject(e,this)},proto.payloads.Payload.toObject=function(e,t){var r={type:n.Message.getFieldWithDefault(t,1,0),messageId:t.getMessageId_asB64(),data:t.getData_asB64(),replyToId:t.getReplyToId_asB64(),noReply:n.Message.getFieldWithDefault(t,5,!1)};return e&&(r.$jspbMessageInstance=t),r}),proto.payloads.Payload.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.payloads.Payload;return proto.payloads.Payload.deserializeBinaryFromReader(r,t)},proto.payloads.Payload.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readEnum();e.setType(r);break;case 2:r=t.readBytes();e.setMessageId(r);break;case 3:r=t.readBytes();e.setData(r);break;case 4:r=t.readBytes();e.setReplyToId(r);break;case 5:r=t.readBool();e.setNoReply(r);break;default:t.skipField()}}return e},proto.payloads.Payload.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.payloads.Payload.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.payloads.Payload.serializeBinaryToWriter=function(e,t){var r=void 0;0!==(r=e.getType())&&t.writeEnum(1,r),(r=e.getMessageId_asU8()).length>0&&t.writeBytes(2,r),(r=e.getData_asU8()).length>0&&t.writeBytes(3,r),(r=e.getReplyToId_asU8()).length>0&&t.writeBytes(4,r),(r=e.getNoReply())&&t.writeBool(5,r)},proto.payloads.Payload.prototype.getType=function(){return n.Message.getFieldWithDefault(this,1,0)},proto.payloads.Payload.prototype.setType=function(e){n.Message.setProto3EnumField(this,1,e)},proto.payloads.Payload.prototype.getMessageId=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.payloads.Payload.prototype.getMessageId_asB64=function(){return n.Message.bytesAsB64(this.getMessageId())},proto.payloads.Payload.prototype.getMessageId_asU8=function(){return n.Message.bytesAsU8(this.getMessageId())},proto.payloads.Payload.prototype.setMessageId=function(e){n.Message.setProto3BytesField(this,2,e)},proto.payloads.Payload.prototype.getData=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.payloads.Payload.prototype.getData_asB64=function(){return n.Message.bytesAsB64(this.getData())},proto.payloads.Payload.prototype.getData_asU8=function(){return n.Message.bytesAsU8(this.getData())},proto.payloads.Payload.prototype.setData=function(e){n.Message.setProto3BytesField(this,3,e)},proto.payloads.Payload.prototype.getReplyToId=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.payloads.Payload.prototype.getReplyToId_asB64=function(){return n.Message.bytesAsB64(this.getReplyToId())},proto.payloads.Payload.prototype.getReplyToId_asU8=function(){return n.Message.bytesAsU8(this.getReplyToId())},proto.payloads.Payload.prototype.setReplyToId=function(e){n.Message.setProto3BytesField(this,4,e)},proto.payloads.Payload.prototype.getNoReply=function(){return n.Message.getFieldWithDefault(this,5,!1)},proto.payloads.Payload.prototype.setNoReply=function(e){n.Message.setProto3BooleanField(this,5,e)},n.Message.GENERATE_TO_OBJECT&&(proto.payloads.TextData.prototype.toObject=function(e){return proto.payloads.TextData.toObject(e,this)},proto.payloads.TextData.toObject=function(e,t){var r={text:n.Message.getFieldWithDefault(t,1,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.payloads.TextData.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.payloads.TextData;return proto.payloads.TextData.deserializeBinaryFromReader(r,t)},proto.payloads.TextData.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readString();e.setText(r);break;default:t.skipField()}}return e},proto.payloads.TextData.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.payloads.TextData.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.payloads.TextData.serializeBinaryToWriter=function(e,t){var r;(r=e.getText()).length>0&&t.writeString(1,r)},proto.payloads.TextData.prototype.getText=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.payloads.TextData.prototype.setText=function(e){n.Message.setProto3StringField(this,1,e)},proto.payloads.PayloadType={BINARY:0,TEXT:1,ACK:2,SESSION:3},i.object.extend(r,proto.payloads)},{"google-protobuf":288}],15:[function(e,t,r){"use strict";var n=e("google-protobuf"),i=n,o=Function("return this")();i.exportSymbol("proto.sigchain.SigAlgo",null,o),i.exportSymbol("proto.sigchain.SigChain",null,o),i.exportSymbol("proto.sigchain.SigChainElem",null,o),proto.sigchain.SigChainElem=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.sigchain.SigChainElem,n.Message),i.DEBUG&&!COMPILED&&(proto.sigchain.SigChainElem.displayName="proto.sigchain.SigChainElem"),proto.sigchain.SigChain=function(e){n.Message.initialize(this,e,0,-1,proto.sigchain.SigChain.repeatedFields_,null)},i.inherits(proto.sigchain.SigChain,n.Message),i.DEBUG&&!COMPILED&&(proto.sigchain.SigChain.displayName="proto.sigchain.SigChain"),n.Message.GENERATE_TO_OBJECT&&(proto.sigchain.SigChainElem.prototype.toObject=function(e){return proto.sigchain.SigChainElem.toObject(e,this)},proto.sigchain.SigChainElem.toObject=function(e,t){var r={id:t.getId_asB64(),nextPubkey:t.getNextPubkey_asB64(),mining:n.Message.getFieldWithDefault(t,3,!1),signature:t.getSignature_asB64(),sigAlgo:n.Message.getFieldWithDefault(t,5,0),vrf:t.getVrf_asB64(),proof:t.getProof_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.sigchain.SigChainElem.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.sigchain.SigChainElem;return proto.sigchain.SigChainElem.deserializeBinaryFromReader(r,t)},proto.sigchain.SigChainElem.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setId(r);break;case 2:r=t.readBytes();e.setNextPubkey(r);break;case 3:r=t.readBool();e.setMining(r);break;case 4:r=t.readBytes();e.setSignature(r);break;case 5:r=t.readEnum();e.setSigAlgo(r);break;case 6:r=t.readBytes();e.setVrf(r);break;case 7:r=t.readBytes();e.setProof(r);break;default:t.skipField()}}return e},proto.sigchain.SigChainElem.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.sigchain.SigChainElem.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.sigchain.SigChainElem.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getId_asU8()).length>0&&t.writeBytes(1,r),(r=e.getNextPubkey_asU8()).length>0&&t.writeBytes(2,r),(r=e.getMining())&&t.writeBool(3,r),(r=e.getSignature_asU8()).length>0&&t.writeBytes(4,r),0!==(r=e.getSigAlgo())&&t.writeEnum(5,r),(r=e.getVrf_asU8()).length>0&&t.writeBytes(6,r),(r=e.getProof_asU8()).length>0&&t.writeBytes(7,r)},proto.sigchain.SigChainElem.prototype.getId=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.sigchain.SigChainElem.prototype.getId_asB64=function(){return n.Message.bytesAsB64(this.getId())},proto.sigchain.SigChainElem.prototype.getId_asU8=function(){return n.Message.bytesAsU8(this.getId())},proto.sigchain.SigChainElem.prototype.setId=function(e){n.Message.setProto3BytesField(this,1,e)},proto.sigchain.SigChainElem.prototype.getNextPubkey=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.sigchain.SigChainElem.prototype.getNextPubkey_asB64=function(){return n.Message.bytesAsB64(this.getNextPubkey())},proto.sigchain.SigChainElem.prototype.getNextPubkey_asU8=function(){return n.Message.bytesAsU8(this.getNextPubkey())},proto.sigchain.SigChainElem.prototype.setNextPubkey=function(e){n.Message.setProto3BytesField(this,2,e)},proto.sigchain.SigChainElem.prototype.getMining=function(){return n.Message.getFieldWithDefault(this,3,!1)},proto.sigchain.SigChainElem.prototype.setMining=function(e){n.Message.setProto3BooleanField(this,3,e)},proto.sigchain.SigChainElem.prototype.getSignature=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.sigchain.SigChainElem.prototype.getSignature_asB64=function(){return n.Message.bytesAsB64(this.getSignature())},proto.sigchain.SigChainElem.prototype.getSignature_asU8=function(){return n.Message.bytesAsU8(this.getSignature())},proto.sigchain.SigChainElem.prototype.setSignature=function(e){n.Message.setProto3BytesField(this,4,e)},proto.sigchain.SigChainElem.prototype.getSigAlgo=function(){return n.Message.getFieldWithDefault(this,5,0)},proto.sigchain.SigChainElem.prototype.setSigAlgo=function(e){n.Message.setProto3EnumField(this,5,e)},proto.sigchain.SigChainElem.prototype.getVrf=function(){return n.Message.getFieldWithDefault(this,6,"")},proto.sigchain.SigChainElem.prototype.getVrf_asB64=function(){return n.Message.bytesAsB64(this.getVrf())},proto.sigchain.SigChainElem.prototype.getVrf_asU8=function(){return n.Message.bytesAsU8(this.getVrf())},proto.sigchain.SigChainElem.prototype.setVrf=function(e){n.Message.setProto3BytesField(this,6,e)},proto.sigchain.SigChainElem.prototype.getProof=function(){return n.Message.getFieldWithDefault(this,7,"")},proto.sigchain.SigChainElem.prototype.getProof_asB64=function(){return n.Message.bytesAsB64(this.getProof())},proto.sigchain.SigChainElem.prototype.getProof_asU8=function(){return n.Message.bytesAsU8(this.getProof())},proto.sigchain.SigChainElem.prototype.setProof=function(e){n.Message.setProto3BytesField(this,7,e)},proto.sigchain.SigChain.repeatedFields_=[8],n.Message.GENERATE_TO_OBJECT&&(proto.sigchain.SigChain.prototype.toObject=function(e){return proto.sigchain.SigChain.toObject(e,this)},proto.sigchain.SigChain.toObject=function(e,t){var r={nonce:n.Message.getFieldWithDefault(t,1,0),dataSize:n.Message.getFieldWithDefault(t,2,0),blockHash:t.getBlockHash_asB64(),srcId:t.getSrcId_asB64(),srcPubkey:t.getSrcPubkey_asB64(),destId:t.getDestId_asB64(),destPubkey:t.getDestPubkey_asB64(),elemsList:n.Message.toObjectList(t.getElemsList(),proto.sigchain.SigChainElem.toObject,e)};return e&&(r.$jspbMessageInstance=t),r}),proto.sigchain.SigChain.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.sigchain.SigChain;return proto.sigchain.SigChain.deserializeBinaryFromReader(r,t)},proto.sigchain.SigChain.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readUint32();e.setNonce(r);break;case 2:r=t.readUint32();e.setDataSize(r);break;case 3:r=t.readBytes();e.setBlockHash(r);break;case 4:r=t.readBytes();e.setSrcId(r);break;case 5:r=t.readBytes();e.setSrcPubkey(r);break;case 6:r=t.readBytes();e.setDestId(r);break;case 7:r=t.readBytes();e.setDestPubkey(r);break;case 8:r=new proto.sigchain.SigChainElem;t.readMessage(r,proto.sigchain.SigChainElem.deserializeBinaryFromReader),e.addElems(r);break;default:t.skipField()}}return e},proto.sigchain.SigChain.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.sigchain.SigChain.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.sigchain.SigChain.serializeBinaryToWriter=function(e,t){var r=void 0;0!==(r=e.getNonce())&&t.writeUint32(1,r),0!==(r=e.getDataSize())&&t.writeUint32(2,r),(r=e.getBlockHash_asU8()).length>0&&t.writeBytes(3,r),(r=e.getSrcId_asU8()).length>0&&t.writeBytes(4,r),(r=e.getSrcPubkey_asU8()).length>0&&t.writeBytes(5,r),(r=e.getDestId_asU8()).length>0&&t.writeBytes(6,r),(r=e.getDestPubkey_asU8()).length>0&&t.writeBytes(7,r),(r=e.getElemsList()).length>0&&t.writeRepeatedMessage(8,r,proto.sigchain.SigChainElem.serializeBinaryToWriter)},proto.sigchain.SigChain.prototype.getNonce=function(){return n.Message.getFieldWithDefault(this,1,0)},proto.sigchain.SigChain.prototype.setNonce=function(e){n.Message.setProto3IntField(this,1,e)},proto.sigchain.SigChain.prototype.getDataSize=function(){return n.Message.getFieldWithDefault(this,2,0)},proto.sigchain.SigChain.prototype.setDataSize=function(e){n.Message.setProto3IntField(this,2,e)},proto.sigchain.SigChain.prototype.getBlockHash=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.sigchain.SigChain.prototype.getBlockHash_asB64=function(){return n.Message.bytesAsB64(this.getBlockHash())},proto.sigchain.SigChain.prototype.getBlockHash_asU8=function(){return n.Message.bytesAsU8(this.getBlockHash())},proto.sigchain.SigChain.prototype.setBlockHash=function(e){n.Message.setProto3BytesField(this,3,e)},proto.sigchain.SigChain.prototype.getSrcId=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.sigchain.SigChain.prototype.getSrcId_asB64=function(){return n.Message.bytesAsB64(this.getSrcId())},proto.sigchain.SigChain.prototype.getSrcId_asU8=function(){return n.Message.bytesAsU8(this.getSrcId())},proto.sigchain.SigChain.prototype.setSrcId=function(e){n.Message.setProto3BytesField(this,4,e)},proto.sigchain.SigChain.prototype.getSrcPubkey=function(){return n.Message.getFieldWithDefault(this,5,"")},proto.sigchain.SigChain.prototype.getSrcPubkey_asB64=function(){return n.Message.bytesAsB64(this.getSrcPubkey())},proto.sigchain.SigChain.prototype.getSrcPubkey_asU8=function(){return n.Message.bytesAsU8(this.getSrcPubkey())},proto.sigchain.SigChain.prototype.setSrcPubkey=function(e){n.Message.setProto3BytesField(this,5,e)},proto.sigchain.SigChain.prototype.getDestId=function(){return n.Message.getFieldWithDefault(this,6,"")},proto.sigchain.SigChain.prototype.getDestId_asB64=function(){return n.Message.bytesAsB64(this.getDestId())},proto.sigchain.SigChain.prototype.getDestId_asU8=function(){return n.Message.bytesAsU8(this.getDestId())},proto.sigchain.SigChain.prototype.setDestId=function(e){n.Message.setProto3BytesField(this,6,e)},proto.sigchain.SigChain.prototype.getDestPubkey=function(){return n.Message.getFieldWithDefault(this,7,"")},proto.sigchain.SigChain.prototype.getDestPubkey_asB64=function(){return n.Message.bytesAsB64(this.getDestPubkey())},proto.sigchain.SigChain.prototype.getDestPubkey_asU8=function(){return n.Message.bytesAsU8(this.getDestPubkey())},proto.sigchain.SigChain.prototype.setDestPubkey=function(e){n.Message.setProto3BytesField(this,7,e)},proto.sigchain.SigChain.prototype.getElemsList=function(){return n.Message.getRepeatedWrapperField(this,proto.sigchain.SigChainElem,8)},proto.sigchain.SigChain.prototype.setElemsList=function(e){n.Message.setRepeatedWrapperField(this,8,e)},proto.sigchain.SigChain.prototype.addElems=function(e,t){return n.Message.addToRepeatedWrapperField(this,8,e,proto.sigchain.SigChainElem,t)},proto.sigchain.SigChain.prototype.clearElemsList=function(){this.setElemsList([])},proto.sigchain.SigAlgo={SIGNATURE:0,VRF:1},i.object.extend(r,proto.sigchain)},{"google-protobuf":288}],16:[function(e,t,r){"use strict";var n=e("google-protobuf"),i=n,o=Function("return this")();i.exportSymbol("proto.transaction.Coinbase",null,o),i.exportSymbol("proto.transaction.DeleteName",null,o),i.exportSymbol("proto.transaction.GenerateID",null,o),i.exportSymbol("proto.transaction.IssueAsset",null,o),i.exportSymbol("proto.transaction.NanoPay",null,o),i.exportSymbol("proto.transaction.Payload",null,o),i.exportSymbol("proto.transaction.PayloadType",null,o),i.exportSymbol("proto.transaction.Program",null,o),i.exportSymbol("proto.transaction.RegisterName",null,o),i.exportSymbol("proto.transaction.SigChainTxn",null,o),i.exportSymbol("proto.transaction.Subscribe",null,o),i.exportSymbol("proto.transaction.Transaction",null,o),i.exportSymbol("proto.transaction.TransferAsset",null,o),i.exportSymbol("proto.transaction.TransferName",null,o),i.exportSymbol("proto.transaction.UnsignedTx",null,o),i.exportSymbol("proto.transaction.Unsubscribe",null,o),proto.transaction.UnsignedTx=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.UnsignedTx,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.UnsignedTx.displayName="proto.transaction.UnsignedTx"),proto.transaction.Transaction=function(e){n.Message.initialize(this,e,0,-1,proto.transaction.Transaction.repeatedFields_,null)},i.inherits(proto.transaction.Transaction,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.Transaction.displayName="proto.transaction.Transaction"),proto.transaction.Program=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.Program,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.Program.displayName="proto.transaction.Program"),proto.transaction.Payload=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.Payload,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.Payload.displayName="proto.transaction.Payload"),proto.transaction.Coinbase=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.Coinbase,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.Coinbase.displayName="proto.transaction.Coinbase"),proto.transaction.SigChainTxn=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.SigChainTxn,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.SigChainTxn.displayName="proto.transaction.SigChainTxn"),proto.transaction.RegisterName=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.RegisterName,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.RegisterName.displayName="proto.transaction.RegisterName"),proto.transaction.TransferName=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.TransferName,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.TransferName.displayName="proto.transaction.TransferName"),proto.transaction.DeleteName=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.DeleteName,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.DeleteName.displayName="proto.transaction.DeleteName"),proto.transaction.Subscribe=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.Subscribe,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.Subscribe.displayName="proto.transaction.Subscribe"),proto.transaction.Unsubscribe=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.Unsubscribe,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.Unsubscribe.displayName="proto.transaction.Unsubscribe"),proto.transaction.TransferAsset=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.TransferAsset,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.TransferAsset.displayName="proto.transaction.TransferAsset"),proto.transaction.GenerateID=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.GenerateID,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.GenerateID.displayName="proto.transaction.GenerateID"),proto.transaction.NanoPay=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.NanoPay,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.NanoPay.displayName="proto.transaction.NanoPay"),proto.transaction.IssueAsset=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.transaction.IssueAsset,n.Message),i.DEBUG&&!COMPILED&&(proto.transaction.IssueAsset.displayName="proto.transaction.IssueAsset"),n.Message.GENERATE_TO_OBJECT&&(proto.transaction.UnsignedTx.prototype.toObject=function(e){return proto.transaction.UnsignedTx.toObject(e,this)},proto.transaction.UnsignedTx.toObject=function(e,t){var r,i={payload:(r=t.getPayload())&&proto.transaction.Payload.toObject(e,r),nonce:n.Message.getFieldWithDefault(t,2,0),fee:n.Message.getFieldWithDefault(t,3,0),attributes:t.getAttributes_asB64()};return e&&(i.$jspbMessageInstance=t),i}),proto.transaction.UnsignedTx.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.UnsignedTx;return proto.transaction.UnsignedTx.deserializeBinaryFromReader(r,t)},proto.transaction.UnsignedTx.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=new proto.transaction.Payload;t.readMessage(r,proto.transaction.Payload.deserializeBinaryFromReader),e.setPayload(r);break;case 2:r=t.readUint64();e.setNonce(r);break;case 3:r=t.readInt64();e.setFee(r);break;case 4:r=t.readBytes();e.setAttributes(r);break;default:t.skipField()}}return e},proto.transaction.UnsignedTx.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.UnsignedTx.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.UnsignedTx.serializeBinaryToWriter=function(e,t){var r=void 0;null!=(r=e.getPayload())&&t.writeMessage(1,r,proto.transaction.Payload.serializeBinaryToWriter),0!==(r=e.getNonce())&&t.writeUint64(2,r),0!==(r=e.getFee())&&t.writeInt64(3,r),(r=e.getAttributes_asU8()).length>0&&t.writeBytes(4,r)},proto.transaction.UnsignedTx.prototype.getPayload=function(){return n.Message.getWrapperField(this,proto.transaction.Payload,1)},proto.transaction.UnsignedTx.prototype.setPayload=function(e){n.Message.setWrapperField(this,1,e)},proto.transaction.UnsignedTx.prototype.clearPayload=function(){this.setPayload(void 0)},proto.transaction.UnsignedTx.prototype.hasPayload=function(){return null!=n.Message.getField(this,1)},proto.transaction.UnsignedTx.prototype.getNonce=function(){return n.Message.getFieldWithDefault(this,2,0)},proto.transaction.UnsignedTx.prototype.setNonce=function(e){n.Message.setProto3IntField(this,2,e)},proto.transaction.UnsignedTx.prototype.getFee=function(){return n.Message.getFieldWithDefault(this,3,0)},proto.transaction.UnsignedTx.prototype.setFee=function(e){n.Message.setProto3IntField(this,3,e)},proto.transaction.UnsignedTx.prototype.getAttributes=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.transaction.UnsignedTx.prototype.getAttributes_asB64=function(){return n.Message.bytesAsB64(this.getAttributes())},proto.transaction.UnsignedTx.prototype.getAttributes_asU8=function(){return n.Message.bytesAsU8(this.getAttributes())},proto.transaction.UnsignedTx.prototype.setAttributes=function(e){n.Message.setProto3BytesField(this,4,e)},proto.transaction.Transaction.repeatedFields_=[2],n.Message.GENERATE_TO_OBJECT&&(proto.transaction.Transaction.prototype.toObject=function(e){return proto.transaction.Transaction.toObject(e,this)},proto.transaction.Transaction.toObject=function(e,t){var r,i={unsignedTx:(r=t.getUnsignedTx())&&proto.transaction.UnsignedTx.toObject(e,r),programsList:n.Message.toObjectList(t.getProgramsList(),proto.transaction.Program.toObject,e)};return e&&(i.$jspbMessageInstance=t),i}),proto.transaction.Transaction.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.Transaction;return proto.transaction.Transaction.deserializeBinaryFromReader(r,t)},proto.transaction.Transaction.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=new proto.transaction.UnsignedTx;t.readMessage(r,proto.transaction.UnsignedTx.deserializeBinaryFromReader),e.setUnsignedTx(r);break;case 2:r=new proto.transaction.Program;t.readMessage(r,proto.transaction.Program.deserializeBinaryFromReader),e.addPrograms(r);break;default:t.skipField()}}return e},proto.transaction.Transaction.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.Transaction.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.Transaction.serializeBinaryToWriter=function(e,t){var r=void 0;null!=(r=e.getUnsignedTx())&&t.writeMessage(1,r,proto.transaction.UnsignedTx.serializeBinaryToWriter),(r=e.getProgramsList()).length>0&&t.writeRepeatedMessage(2,r,proto.transaction.Program.serializeBinaryToWriter)},proto.transaction.Transaction.prototype.getUnsignedTx=function(){return n.Message.getWrapperField(this,proto.transaction.UnsignedTx,1)},proto.transaction.Transaction.prototype.setUnsignedTx=function(e){n.Message.setWrapperField(this,1,e)},proto.transaction.Transaction.prototype.clearUnsignedTx=function(){this.setUnsignedTx(void 0)},proto.transaction.Transaction.prototype.hasUnsignedTx=function(){return null!=n.Message.getField(this,1)},proto.transaction.Transaction.prototype.getProgramsList=function(){return n.Message.getRepeatedWrapperField(this,proto.transaction.Program,2)},proto.transaction.Transaction.prototype.setProgramsList=function(e){n.Message.setRepeatedWrapperField(this,2,e)},proto.transaction.Transaction.prototype.addPrograms=function(e,t){return n.Message.addToRepeatedWrapperField(this,2,e,proto.transaction.Program,t)},proto.transaction.Transaction.prototype.clearProgramsList=function(){this.setProgramsList([])},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.Program.prototype.toObject=function(e){return proto.transaction.Program.toObject(e,this)},proto.transaction.Program.toObject=function(e,t){var r={code:t.getCode_asB64(),parameter:t.getParameter_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.Program.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.Program;return proto.transaction.Program.deserializeBinaryFromReader(r,t)},proto.transaction.Program.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setCode(r);break;case 2:r=t.readBytes();e.setParameter(r);break;default:t.skipField()}}return e},proto.transaction.Program.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.Program.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.Program.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getCode_asU8()).length>0&&t.writeBytes(1,r),(r=e.getParameter_asU8()).length>0&&t.writeBytes(2,r)},proto.transaction.Program.prototype.getCode=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.Program.prototype.getCode_asB64=function(){return n.Message.bytesAsB64(this.getCode())},proto.transaction.Program.prototype.getCode_asU8=function(){return n.Message.bytesAsU8(this.getCode())},proto.transaction.Program.prototype.setCode=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.Program.prototype.getParameter=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.Program.prototype.getParameter_asB64=function(){return n.Message.bytesAsB64(this.getParameter())},proto.transaction.Program.prototype.getParameter_asU8=function(){return n.Message.bytesAsU8(this.getParameter())},proto.transaction.Program.prototype.setParameter=function(e){n.Message.setProto3BytesField(this,2,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.Payload.prototype.toObject=function(e){return proto.transaction.Payload.toObject(e,this)},proto.transaction.Payload.toObject=function(e,t){var r={type:n.Message.getFieldWithDefault(t,1,0),data:t.getData_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.Payload.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.Payload;return proto.transaction.Payload.deserializeBinaryFromReader(r,t)},proto.transaction.Payload.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readEnum();e.setType(r);break;case 2:r=t.readBytes();e.setData(r);break;default:t.skipField()}}return e},proto.transaction.Payload.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.Payload.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.Payload.serializeBinaryToWriter=function(e,t){var r=void 0;0!==(r=e.getType())&&t.writeEnum(1,r),(r=e.getData_asU8()).length>0&&t.writeBytes(2,r)},proto.transaction.Payload.prototype.getType=function(){return n.Message.getFieldWithDefault(this,1,0)},proto.transaction.Payload.prototype.setType=function(e){n.Message.setProto3EnumField(this,1,e)},proto.transaction.Payload.prototype.getData=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.Payload.prototype.getData_asB64=function(){return n.Message.bytesAsB64(this.getData())},proto.transaction.Payload.prototype.getData_asU8=function(){return n.Message.bytesAsU8(this.getData())},proto.transaction.Payload.prototype.setData=function(e){n.Message.setProto3BytesField(this,2,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.Coinbase.prototype.toObject=function(e){return proto.transaction.Coinbase.toObject(e,this)},proto.transaction.Coinbase.toObject=function(e,t){var r={sender:t.getSender_asB64(),recipient:t.getRecipient_asB64(),amount:n.Message.getFieldWithDefault(t,3,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.Coinbase.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.Coinbase;return proto.transaction.Coinbase.deserializeBinaryFromReader(r,t)},proto.transaction.Coinbase.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSender(r);break;case 2:r=t.readBytes();e.setRecipient(r);break;case 3:r=t.readInt64();e.setAmount(r);break;default:t.skipField()}}return e},proto.transaction.Coinbase.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.Coinbase.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.Coinbase.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSender_asU8()).length>0&&t.writeBytes(1,r),(r=e.getRecipient_asU8()).length>0&&t.writeBytes(2,r),0!==(r=e.getAmount())&&t.writeInt64(3,r)},proto.transaction.Coinbase.prototype.getSender=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.Coinbase.prototype.getSender_asB64=function(){return n.Message.bytesAsB64(this.getSender())},proto.transaction.Coinbase.prototype.getSender_asU8=function(){return n.Message.bytesAsU8(this.getSender())},proto.transaction.Coinbase.prototype.setSender=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.Coinbase.prototype.getRecipient=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.Coinbase.prototype.getRecipient_asB64=function(){return n.Message.bytesAsB64(this.getRecipient())},proto.transaction.Coinbase.prototype.getRecipient_asU8=function(){return n.Message.bytesAsU8(this.getRecipient())},proto.transaction.Coinbase.prototype.setRecipient=function(e){n.Message.setProto3BytesField(this,2,e)},proto.transaction.Coinbase.prototype.getAmount=function(){return n.Message.getFieldWithDefault(this,3,0)},proto.transaction.Coinbase.prototype.setAmount=function(e){n.Message.setProto3IntField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.SigChainTxn.prototype.toObject=function(e){return proto.transaction.SigChainTxn.toObject(e,this)},proto.transaction.SigChainTxn.toObject=function(e,t){var r={sigChain:t.getSigChain_asB64(),submitter:t.getSubmitter_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.SigChainTxn.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.SigChainTxn;return proto.transaction.SigChainTxn.deserializeBinaryFromReader(r,t)},proto.transaction.SigChainTxn.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSigChain(r);break;case 2:r=t.readBytes();e.setSubmitter(r);break;default:t.skipField()}}return e},proto.transaction.SigChainTxn.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.SigChainTxn.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.SigChainTxn.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSigChain_asU8()).length>0&&t.writeBytes(1,r),(r=e.getSubmitter_asU8()).length>0&&t.writeBytes(2,r)},proto.transaction.SigChainTxn.prototype.getSigChain=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.SigChainTxn.prototype.getSigChain_asB64=function(){return n.Message.bytesAsB64(this.getSigChain())},proto.transaction.SigChainTxn.prototype.getSigChain_asU8=function(){return n.Message.bytesAsU8(this.getSigChain())},proto.transaction.SigChainTxn.prototype.setSigChain=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.SigChainTxn.prototype.getSubmitter=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.SigChainTxn.prototype.getSubmitter_asB64=function(){return n.Message.bytesAsB64(this.getSubmitter())},proto.transaction.SigChainTxn.prototype.getSubmitter_asU8=function(){return n.Message.bytesAsU8(this.getSubmitter())},proto.transaction.SigChainTxn.prototype.setSubmitter=function(e){n.Message.setProto3BytesField(this,2,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.RegisterName.prototype.toObject=function(e){return proto.transaction.RegisterName.toObject(e,this)},proto.transaction.RegisterName.toObject=function(e,t){var r={registrant:t.getRegistrant_asB64(),name:n.Message.getFieldWithDefault(t,2,""),registrationFee:n.Message.getFieldWithDefault(t,3,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.RegisterName.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.RegisterName;return proto.transaction.RegisterName.deserializeBinaryFromReader(r,t)},proto.transaction.RegisterName.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setRegistrant(r);break;case 2:r=t.readString();e.setName(r);break;case 3:r=t.readInt64();e.setRegistrationFee(r);break;default:t.skipField()}}return e},proto.transaction.RegisterName.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.RegisterName.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.RegisterName.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getRegistrant_asU8()).length>0&&t.writeBytes(1,r),(r=e.getName()).length>0&&t.writeString(2,r),0!==(r=e.getRegistrationFee())&&t.writeInt64(3,r)},proto.transaction.RegisterName.prototype.getRegistrant=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.RegisterName.prototype.getRegistrant_asB64=function(){return n.Message.bytesAsB64(this.getRegistrant())},proto.transaction.RegisterName.prototype.getRegistrant_asU8=function(){return n.Message.bytesAsU8(this.getRegistrant())},proto.transaction.RegisterName.prototype.setRegistrant=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.RegisterName.prototype.getName=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.RegisterName.prototype.setName=function(e){n.Message.setProto3StringField(this,2,e)},proto.transaction.RegisterName.prototype.getRegistrationFee=function(){return n.Message.getFieldWithDefault(this,3,0)},proto.transaction.RegisterName.prototype.setRegistrationFee=function(e){n.Message.setProto3IntField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.TransferName.prototype.toObject=function(e){return proto.transaction.TransferName.toObject(e,this)},proto.transaction.TransferName.toObject=function(e,t){var r={name:n.Message.getFieldWithDefault(t,1,""),registrant:t.getRegistrant_asB64(),recipient:t.getRecipient_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.TransferName.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.TransferName;return proto.transaction.TransferName.deserializeBinaryFromReader(r,t)},proto.transaction.TransferName.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readString();e.setName(r);break;case 2:r=t.readBytes();e.setRegistrant(r);break;case 3:r=t.readBytes();e.setRecipient(r);break;default:t.skipField()}}return e},proto.transaction.TransferName.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.TransferName.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.TransferName.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getName()).length>0&&t.writeString(1,r),(r=e.getRegistrant_asU8()).length>0&&t.writeBytes(2,r),(r=e.getRecipient_asU8()).length>0&&t.writeBytes(3,r)},proto.transaction.TransferName.prototype.getName=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.TransferName.prototype.setName=function(e){n.Message.setProto3StringField(this,1,e)},proto.transaction.TransferName.prototype.getRegistrant=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.TransferName.prototype.getRegistrant_asB64=function(){return n.Message.bytesAsB64(this.getRegistrant())},proto.transaction.TransferName.prototype.getRegistrant_asU8=function(){return n.Message.bytesAsU8(this.getRegistrant())},proto.transaction.TransferName.prototype.setRegistrant=function(e){n.Message.setProto3BytesField(this,2,e)},proto.transaction.TransferName.prototype.getRecipient=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.transaction.TransferName.prototype.getRecipient_asB64=function(){return n.Message.bytesAsB64(this.getRecipient())},proto.transaction.TransferName.prototype.getRecipient_asU8=function(){return n.Message.bytesAsU8(this.getRecipient())},proto.transaction.TransferName.prototype.setRecipient=function(e){n.Message.setProto3BytesField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.DeleteName.prototype.toObject=function(e){return proto.transaction.DeleteName.toObject(e,this)},proto.transaction.DeleteName.toObject=function(e,t){var r={registrant:t.getRegistrant_asB64(),name:n.Message.getFieldWithDefault(t,2,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.DeleteName.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.DeleteName;return proto.transaction.DeleteName.deserializeBinaryFromReader(r,t)},proto.transaction.DeleteName.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setRegistrant(r);break;case 2:r=t.readString();e.setName(r);break;default:t.skipField()}}return e},proto.transaction.DeleteName.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.DeleteName.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.DeleteName.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getRegistrant_asU8()).length>0&&t.writeBytes(1,r),(r=e.getName()).length>0&&t.writeString(2,r)},proto.transaction.DeleteName.prototype.getRegistrant=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.DeleteName.prototype.getRegistrant_asB64=function(){return n.Message.bytesAsB64(this.getRegistrant())},proto.transaction.DeleteName.prototype.getRegistrant_asU8=function(){return n.Message.bytesAsU8(this.getRegistrant())},proto.transaction.DeleteName.prototype.setRegistrant=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.DeleteName.prototype.getName=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.DeleteName.prototype.setName=function(e){n.Message.setProto3StringField(this,2,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.Subscribe.prototype.toObject=function(e){return proto.transaction.Subscribe.toObject(e,this)},proto.transaction.Subscribe.toObject=function(e,t){var r={subscriber:t.getSubscriber_asB64(),identifier:n.Message.getFieldWithDefault(t,2,""),topic:n.Message.getFieldWithDefault(t,3,""),bucket:n.Message.getFieldWithDefault(t,4,0),duration:n.Message.getFieldWithDefault(t,5,0),meta:n.Message.getFieldWithDefault(t,6,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.Subscribe.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.Subscribe;return proto.transaction.Subscribe.deserializeBinaryFromReader(r,t)},proto.transaction.Subscribe.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSubscriber(r);break;case 2:r=t.readString();e.setIdentifier(r);break;case 3:r=t.readString();e.setTopic(r);break;case 4:r=t.readUint32();e.setBucket(r);break;case 5:r=t.readUint32();e.setDuration(r);break;case 6:r=t.readString();e.setMeta(r);break;default:t.skipField()}}return e},proto.transaction.Subscribe.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.Subscribe.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.Subscribe.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSubscriber_asU8()).length>0&&t.writeBytes(1,r),(r=e.getIdentifier()).length>0&&t.writeString(2,r),(r=e.getTopic()).length>0&&t.writeString(3,r),0!==(r=e.getBucket())&&t.writeUint32(4,r),0!==(r=e.getDuration())&&t.writeUint32(5,r),(r=e.getMeta()).length>0&&t.writeString(6,r)},proto.transaction.Subscribe.prototype.getSubscriber=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.Subscribe.prototype.getSubscriber_asB64=function(){return n.Message.bytesAsB64(this.getSubscriber())},proto.transaction.Subscribe.prototype.getSubscriber_asU8=function(){return n.Message.bytesAsU8(this.getSubscriber())},proto.transaction.Subscribe.prototype.setSubscriber=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.Subscribe.prototype.getIdentifier=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.Subscribe.prototype.setIdentifier=function(e){n.Message.setProto3StringField(this,2,e)},proto.transaction.Subscribe.prototype.getTopic=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.transaction.Subscribe.prototype.setTopic=function(e){n.Message.setProto3StringField(this,3,e)},proto.transaction.Subscribe.prototype.getBucket=function(){return n.Message.getFieldWithDefault(this,4,0)},proto.transaction.Subscribe.prototype.setBucket=function(e){n.Message.setProto3IntField(this,4,e)},proto.transaction.Subscribe.prototype.getDuration=function(){return n.Message.getFieldWithDefault(this,5,0)},proto.transaction.Subscribe.prototype.setDuration=function(e){n.Message.setProto3IntField(this,5,e)},proto.transaction.Subscribe.prototype.getMeta=function(){return n.Message.getFieldWithDefault(this,6,"")},proto.transaction.Subscribe.prototype.setMeta=function(e){n.Message.setProto3StringField(this,6,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.Unsubscribe.prototype.toObject=function(e){return proto.transaction.Unsubscribe.toObject(e,this)},proto.transaction.Unsubscribe.toObject=function(e,t){var r={subscriber:t.getSubscriber_asB64(),identifier:n.Message.getFieldWithDefault(t,2,""),topic:n.Message.getFieldWithDefault(t,3,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.Unsubscribe.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.Unsubscribe;return proto.transaction.Unsubscribe.deserializeBinaryFromReader(r,t)},proto.transaction.Unsubscribe.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSubscriber(r);break;case 2:r=t.readString();e.setIdentifier(r);break;case 3:r=t.readString();e.setTopic(r);break;default:t.skipField()}}return e},proto.transaction.Unsubscribe.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.Unsubscribe.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.Unsubscribe.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSubscriber_asU8()).length>0&&t.writeBytes(1,r),(r=e.getIdentifier()).length>0&&t.writeString(2,r),(r=e.getTopic()).length>0&&t.writeString(3,r)},proto.transaction.Unsubscribe.prototype.getSubscriber=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.Unsubscribe.prototype.getSubscriber_asB64=function(){return n.Message.bytesAsB64(this.getSubscriber())},proto.transaction.Unsubscribe.prototype.getSubscriber_asU8=function(){return n.Message.bytesAsU8(this.getSubscriber())},proto.transaction.Unsubscribe.prototype.setSubscriber=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.Unsubscribe.prototype.getIdentifier=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.Unsubscribe.prototype.setIdentifier=function(e){n.Message.setProto3StringField(this,2,e)},proto.transaction.Unsubscribe.prototype.getTopic=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.transaction.Unsubscribe.prototype.setTopic=function(e){n.Message.setProto3StringField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.TransferAsset.prototype.toObject=function(e){return proto.transaction.TransferAsset.toObject(e,this)},proto.transaction.TransferAsset.toObject=function(e,t){var r={sender:t.getSender_asB64(),recipient:t.getRecipient_asB64(),amount:n.Message.getFieldWithDefault(t,3,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.TransferAsset.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.TransferAsset;return proto.transaction.TransferAsset.deserializeBinaryFromReader(r,t)},proto.transaction.TransferAsset.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSender(r);break;case 2:r=t.readBytes();e.setRecipient(r);break;case 3:r=t.readInt64();e.setAmount(r);break;default:t.skipField()}}return e},proto.transaction.TransferAsset.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.TransferAsset.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.TransferAsset.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSender_asU8()).length>0&&t.writeBytes(1,r),(r=e.getRecipient_asU8()).length>0&&t.writeBytes(2,r),0!==(r=e.getAmount())&&t.writeInt64(3,r)},proto.transaction.TransferAsset.prototype.getSender=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.TransferAsset.prototype.getSender_asB64=function(){return n.Message.bytesAsB64(this.getSender())},proto.transaction.TransferAsset.prototype.getSender_asU8=function(){return n.Message.bytesAsU8(this.getSender())},proto.transaction.TransferAsset.prototype.setSender=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.TransferAsset.prototype.getRecipient=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.TransferAsset.prototype.getRecipient_asB64=function(){return n.Message.bytesAsB64(this.getRecipient())},proto.transaction.TransferAsset.prototype.getRecipient_asU8=function(){return n.Message.bytesAsU8(this.getRecipient())},proto.transaction.TransferAsset.prototype.setRecipient=function(e){n.Message.setProto3BytesField(this,2,e)},proto.transaction.TransferAsset.prototype.getAmount=function(){return n.Message.getFieldWithDefault(this,3,0)},proto.transaction.TransferAsset.prototype.setAmount=function(e){n.Message.setProto3IntField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.GenerateID.prototype.toObject=function(e){return proto.transaction.GenerateID.toObject(e,this)},proto.transaction.GenerateID.toObject=function(e,t){var r={publicKey:t.getPublicKey_asB64(),registrationFee:n.Message.getFieldWithDefault(t,2,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.GenerateID.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.GenerateID;return proto.transaction.GenerateID.deserializeBinaryFromReader(r,t)},proto.transaction.GenerateID.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setPublicKey(r);break;case 2:r=t.readInt64();e.setRegistrationFee(r);break;default:t.skipField()}}return e},proto.transaction.GenerateID.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.GenerateID.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.GenerateID.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getPublicKey_asU8()).length>0&&t.writeBytes(1,r),0!==(r=e.getRegistrationFee())&&t.writeInt64(2,r)},proto.transaction.GenerateID.prototype.getPublicKey=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.GenerateID.prototype.getPublicKey_asB64=function(){return n.Message.bytesAsB64(this.getPublicKey())},proto.transaction.GenerateID.prototype.getPublicKey_asU8=function(){return n.Message.bytesAsU8(this.getPublicKey())},proto.transaction.GenerateID.prototype.setPublicKey=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.GenerateID.prototype.getRegistrationFee=function(){return n.Message.getFieldWithDefault(this,2,0)},proto.transaction.GenerateID.prototype.setRegistrationFee=function(e){n.Message.setProto3IntField(this,2,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.NanoPay.prototype.toObject=function(e){return proto.transaction.NanoPay.toObject(e,this)},proto.transaction.NanoPay.toObject=function(e,t){var r={sender:t.getSender_asB64(),recipient:t.getRecipient_asB64(),id:n.Message.getFieldWithDefault(t,3,0),amount:n.Message.getFieldWithDefault(t,4,0),txnExpiration:n.Message.getFieldWithDefault(t,5,0),nanoPayExpiration:n.Message.getFieldWithDefault(t,6,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.NanoPay.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.NanoPay;return proto.transaction.NanoPay.deserializeBinaryFromReader(r,t)},proto.transaction.NanoPay.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSender(r);break;case 2:r=t.readBytes();e.setRecipient(r);break;case 3:r=t.readUint64();e.setId(r);break;case 4:r=t.readInt64();e.setAmount(r);break;case 5:r=t.readUint32();e.setTxnExpiration(r);break;case 6:r=t.readUint32();e.setNanoPayExpiration(r);break;default:t.skipField()}}return e},proto.transaction.NanoPay.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.NanoPay.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.NanoPay.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSender_asU8()).length>0&&t.writeBytes(1,r),(r=e.getRecipient_asU8()).length>0&&t.writeBytes(2,r),0!==(r=e.getId())&&t.writeUint64(3,r),0!==(r=e.getAmount())&&t.writeInt64(4,r),0!==(r=e.getTxnExpiration())&&t.writeUint32(5,r),0!==(r=e.getNanoPayExpiration())&&t.writeUint32(6,r)},proto.transaction.NanoPay.prototype.getSender=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.NanoPay.prototype.getSender_asB64=function(){return n.Message.bytesAsB64(this.getSender())},proto.transaction.NanoPay.prototype.getSender_asU8=function(){return n.Message.bytesAsU8(this.getSender())},proto.transaction.NanoPay.prototype.setSender=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.NanoPay.prototype.getRecipient=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.NanoPay.prototype.getRecipient_asB64=function(){return n.Message.bytesAsB64(this.getRecipient())},proto.transaction.NanoPay.prototype.getRecipient_asU8=function(){return n.Message.bytesAsU8(this.getRecipient())},proto.transaction.NanoPay.prototype.setRecipient=function(e){n.Message.setProto3BytesField(this,2,e)},proto.transaction.NanoPay.prototype.getId=function(){return n.Message.getFieldWithDefault(this,3,0)},proto.transaction.NanoPay.prototype.setId=function(e){n.Message.setProto3IntField(this,3,e)},proto.transaction.NanoPay.prototype.getAmount=function(){return n.Message.getFieldWithDefault(this,4,0)},proto.transaction.NanoPay.prototype.setAmount=function(e){n.Message.setProto3IntField(this,4,e)},proto.transaction.NanoPay.prototype.getTxnExpiration=function(){return n.Message.getFieldWithDefault(this,5,0)},proto.transaction.NanoPay.prototype.setTxnExpiration=function(e){n.Message.setProto3IntField(this,5,e)},proto.transaction.NanoPay.prototype.getNanoPayExpiration=function(){return n.Message.getFieldWithDefault(this,6,0)},proto.transaction.NanoPay.prototype.setNanoPayExpiration=function(e){n.Message.setProto3IntField(this,6,e)},n.Message.GENERATE_TO_OBJECT&&(proto.transaction.IssueAsset.prototype.toObject=function(e){return proto.transaction.IssueAsset.toObject(e,this)},proto.transaction.IssueAsset.toObject=function(e,t){var r={sender:t.getSender_asB64(),name:n.Message.getFieldWithDefault(t,2,""),symbol:n.Message.getFieldWithDefault(t,3,""),totalSupply:n.Message.getFieldWithDefault(t,4,0),precision:n.Message.getFieldWithDefault(t,5,0)};return e&&(r.$jspbMessageInstance=t),r}),proto.transaction.IssueAsset.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.transaction.IssueAsset;return proto.transaction.IssueAsset.deserializeBinaryFromReader(r,t)},proto.transaction.IssueAsset.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setSender(r);break;case 2:r=t.readString();e.setName(r);break;case 3:r=t.readString();e.setSymbol(r);break;case 4:r=t.readInt64();e.setTotalSupply(r);break;case 5:r=t.readUint32();e.setPrecision(r);break;default:t.skipField()}}return e},proto.transaction.IssueAsset.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.transaction.IssueAsset.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.transaction.IssueAsset.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getSender_asU8()).length>0&&t.writeBytes(1,r),(r=e.getName()).length>0&&t.writeString(2,r),(r=e.getSymbol()).length>0&&t.writeString(3,r),0!==(r=e.getTotalSupply())&&t.writeInt64(4,r),0!==(r=e.getPrecision())&&t.writeUint32(5,r)},proto.transaction.IssueAsset.prototype.getSender=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.transaction.IssueAsset.prototype.getSender_asB64=function(){return n.Message.bytesAsB64(this.getSender())},proto.transaction.IssueAsset.prototype.getSender_asU8=function(){return n.Message.bytesAsU8(this.getSender())},proto.transaction.IssueAsset.prototype.setSender=function(e){n.Message.setProto3BytesField(this,1,e)},proto.transaction.IssueAsset.prototype.getName=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.transaction.IssueAsset.prototype.setName=function(e){n.Message.setProto3StringField(this,2,e)},proto.transaction.IssueAsset.prototype.getSymbol=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.transaction.IssueAsset.prototype.setSymbol=function(e){n.Message.setProto3StringField(this,3,e)},proto.transaction.IssueAsset.prototype.getTotalSupply=function(){return n.Message.getFieldWithDefault(this,4,0)},proto.transaction.IssueAsset.prototype.setTotalSupply=function(e){n.Message.setProto3IntField(this,4,e)},proto.transaction.IssueAsset.prototype.getPrecision=function(){return n.Message.getFieldWithDefault(this,5,0)},proto.transaction.IssueAsset.prototype.setPrecision=function(e){n.Message.setProto3IntField(this,5,e)},proto.transaction.PayloadType={COINBASE_TYPE:0,TRANSFER_ASSET_TYPE:1,SIG_CHAIN_TXN_TYPE:2,REGISTER_NAME_TYPE:3,TRANSFER_NAME_TYPE:4,DELETE_NAME_TYPE:5,SUBSCRIBE_TYPE:6,UNSUBSCRIBE_TYPE:7,GENERATE_ID_TYPE:8,NANO_PAY_TYPE:9,ISSUE_ASSET_TYPE:10},i.object.extend(r,proto.transaction)},{"google-protobuf":288}],17:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.deleteName=async function(e,t={}){let r=t.nonce;null!==r&&void 0!==r||(r=await this.getNonce());let n=a.newDeleteNamePayload(this.getPublicKey(),e),i=await this.createTransaction(n,r,t);return t.buildOnly?i:await this.sendTransaction(i)},r.getBalance=async function(e,t={}){if(!e)throw new s.InvalidArgumentError("address is empty");let r=await h.getBalanceByAddr(t.rpcServerAddr,{address:e});if(!r.amount)throw new s.InvalidResponseError("amount is empty");return new i.default(r.amount)},r.getLatestBlock=async function(e={}){return h.getLatestBlockHash(e.rpcServerAddr)},r.getNonce=async function(e,t={}){if(!e)throw new s.InvalidArgumentError("address is empty");t=A.assignDefined({txPool:!0},t);let r=await h.getNonceByAddr(t.rpcServerAddr,{address:e});if("number"!=typeof r.nonce)throw new s.InvalidResponseError("nonce is not a number");let n=r.nonce;t.txPool&&r.nonceInTxPool&&r.nonceInTxPool>n&&(n=r.nonceInTxPool);return n},r.getRegistrant=async function(e,t={}){return h.getRegistrant(t.rpcServerAddr,{name:e})},r.getSubscribers=async function(e,t={}){return h.getSubscribers(t.rpcServerAddr,{topic:e,offset:t.offset,limit:t.limit,meta:t.meta,txPool:t.txPool})},r.getSubscribersCount=async function(e,t={}){return h.getSubscribersCount(t.rpcServerAddr,{topic:e})},r.getSubscription=async function(e,t,r={}){return h.getSubscription(r.rpcServerAddr,{topic:e,subscriber:t})},r.getWsAddr=async function(e,t={}){return h.getWsAddr(t.rpcServerAddr,{address:e})},r.getWssAddr=async function(e,t={}){return h.getWssAddr(t.rpcServerAddr,{address:e})},r.registerName=async function(e,t={}){let r=t.nonce;null!==r&&void 0!==r||(r=await this.getNonce());let n=a.newRegisterNamePayload(this.getPublicKey(),e),i=await this.createTransaction(n,r,t);return t.buildOnly?i:await this.sendTransaction(i)},r.sendTransaction=async function(e,t={}){return h.sendRawTransaction(t.rpcServerAddr,{tx:A.bytesToHex(e.serializeBinary())})},r.subscribe=async function(e,t,r,n,i={}){let o=i.nonce;null!==o&&void 0!==o||(o=await this.getNonce());let s=a.newSubscribePayload(this.getPublicKey(),r,e,t,n),A=await this.createTransaction(s,o,i);return i.buildOnly?A:await this.sendTransaction(A)},r.transferName=async function(e,t,r={}){let n=r.nonce;null!==n&&void 0!==n||(n=await this.getNonce());let i=a.newTransferNamePayload(e,this.getPublicKey(),t),o=await this.createTransaction(i,n,r);return r.buildOnly?o:await this.sendTransaction(o)},r.transferTo=async function(e,t,r={}){if(!o.verifyAddress(e))throw new s.InvalidAddressError("invalid recipient address");let n=r.nonce;null!==n&&void 0!==n||(n=await this.getNonce());let i=o.publicKeyToSignatureRedeem(this.getPublicKey()),A=o.hexStringToProgramHash(i),c=a.newTransferPayload(A,o.addressStringToProgramHash(e),t),g=await this.createTransaction(c,n,r);return r.buildOnly?g:await this.sendTransaction(g)},r.unsubscribe=async function(e,t,r={}){let n=r.nonce;null!==n&&void 0!==n||(n=await this.getNonce());let i=a.newUnsubscribePayload(this.getPublicKey(),t,e),o=await this.createTransaction(i,n,r);return r.buildOnly?o:await this.sendTransaction(o)};var n=f(e("axios")),i=f(e("./amount")),o=g(e("../wallet/address")),s=g(e("./errors")),a=g(e("../wallet/transaction")),A=g(e("./util"));function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function g(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function f(e){return e&&e.__esModule?e:{default:e}}const u=1e4,l={getWsAddr:{method:"getwsaddr"},getWssAddr:{method:"getwssaddr"},getSubscribers:{method:"getsubscribers",defaultParams:{offset:0,limit:1e3,meta:!1,txPool:!1}},getSubscribersCount:{method:"getsubscriberscount"},getSubscription:{method:"getsubscription"},getBalanceByAddr:{method:"getbalancebyaddr"},getNonceByAddr:{method:"getnoncebyaddr"},getRegistrant:{method:"getregistrant"},getLatestBlockHash:{method:"getlatestblockhash"},sendRawTransaction:{method:"sendrawtransaction"}};var h={};for(let e in l)l.hasOwnProperty(e)&&(h[e]=((t,r)=>(r=A.assignDefined({},l[e].defaultParams,r),d(t,l[e].method,r))));async function d(e,t,r={}){const i=n.default.CancelToken.source();let o=null;setTimeout(()=>{null===o&&i.cancel("rpc timeout")},u);try{o=await(0,n.default)({url:e,method:"POST",timeout:u,cancelToken:i.token,data:{id:"nkn-sdk-js",jsonrpc:"2.0",method:t,params:r}})}catch(e){throw n.default.isCancel(e)?new s.RpcTimeoutError(e.message):new s.RpcError(e.message)}let a=o.data;if(a.error)throw new s.ServerError(a.error);if(void 0!==a.result)return a.result;throw new s.InvalidResponseError("rpc response contains no result or error field")}},{"../wallet/address":26,"../wallet/transaction":29,"./amount":6,"./errors":8,"./util":19,axios:56}],18:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.encodeBool=function(e){return o(e?1:0)},r.encodeBytes=function(e){let r=t.from(e);return c(r.length)+r.toString("hex")},r.encodeString=function(e){let r=t.from(e,"utf8");return c(r.length)+r.toString("hex")},r.encodeUint=c,r.encodeUint16=s,r.encodeUint32=a,r.encodeUint64=A,r.encodeUint8=o,r.maxUintBits=r.maxUint=void 0;var n;(n=e("./errors"))&&n.__esModule;r.maxUintBits=48;const i=2**48;function o(e){let r=t.alloc(1,0);return r.writeUInt8(e),r.toString("hex")}function s(e){let r=t.alloc(2,0);return r.writeUInt16LE(e),r.toString("hex")}function a(e){let r=t.alloc(4,0);return r.writeUInt32LE(e),r.toString("hex")}function A(e){if(e>i)throw new RangeError("full 64 bit integer is not supported in JavaScript");let r=t.alloc(8,0);return r.writeUIntLE(e,0,6),r.toString("hex")}function c(e){return e<253?o(e):e<=65535?"fd"+s(e):e<=4294967295?"fe"+a(e):"ff"+A(e)}r.maxUint=i}).call(this,e("buffer").Buffer)},{"./errors":8,buffer:119}],19:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.assignDefined=function(e,...t){for(let r of t)if(r)for(let t of Object.keys(r))void 0!==r[t]&&(e[t]=r[t]);return e},r.bytesToHex=a,r.hexToBytes=function(e){if(e.length%2==1)throw new RangeError("invalid hex string length "+e.length);if(!s.test(e))throw new RangeError("invalid hex string");let t=[];for(let r=0;rObject.assign(r,{[n.toLowerCase()]:"object"==typeof t[n]?e(t[n]):t[n]}),{})},r.utf8ToBytes=function(e){if(!e)return new Uint8Array;return new Uint8Array(t.from(e,"utf8"))};var n,i=(n=e("tweetnacl"))&&n.__esModule?n:{default:n},o=e("./serialize");const s=/^[0-9a-f]+$/i;function a(e){return Array.from(e,e=>{if(e<0||e>255)throw new RangeError("invalid byte "+e);return("0"+(255&e).toString(16)).slice(-2)}).join("")}var A=i.default.randomBytes;function c(e){return a(A(e))}r.randomBytes=A}).call(this,e("buffer").Buffer)},{"./serialize":18,buffer:119,tweetnacl:383}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={setPRNG:!0,ready:!0,Client:!0,MultiClient:!0,Wallet:!0};Object.defineProperty(r,"Client",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(r,"MultiClient",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(r,"Wallet",{enumerable:!0,get:function(){return A.default}}),r.default=void 0,Object.defineProperty(r,"ready",{enumerable:!0,get:function(){return i.ready}}),r.setPRNG=void 0;var i=e("libsodium-wrappers"),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=g(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}n.default=e,r&&r.set(e,n);return n}(e("./common"));Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||e in r&&r[e]===o[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}}))});var s=c(e("./client")),a=c(e("./multiclient")),A=c(e("./wallet"));function c(e){return e&&e.__esModule?e:{default:e}}function g(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(g=function(e){return e?r:t})(e)}var f=o.util.setPRNG;r.setPRNG=f,o.ready=i.ready,o.Client=s.default,o.MultiClient=a.default,o.Wallet=A.default,o.setPRNG=f;var u=o;r.default=u},{"./client":3,"./common":10,"./multiclient":22,"./wallet":28,"libsodium-wrappers":310}],21:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.sessionIDSize=r.multiclientIdentifierRe=r.defaultSessionAllowAddr=r.defaultOptions=r.acceptSessionBufSize=void 0;r.defaultOptions={numSubClients:4,originalClient:!1,msgCacheExpiration:3e5,sessionConfig:{}};r.acceptSessionBufSize=128;r.defaultSessionAllowAddr=/.*/;r.multiclientIdentifierRe=/^__\d+__$/;r.sessionIDSize=8},{}],22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return i.default}});var n,i=(n=e("./multiclient"))&&n.__esModule?n:{default:n}},{"./multiclient":23}],23:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=d(e("@nkn/ncp")),i=e("memory-cache"),o=l(e("core-js-pure/features/promise")),s=l(e("../client")),a=l(e("../wallet")),A=e("../client/consts"),c=d(e("../common")),g=d(e("./consts")),f=d(e("../client/message")),u=d(e("./util"));function l(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(h=function(e){return e?r:t})(e)}function d(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=h(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.default=class{constructor(e={}){p(this,"options",void 0),p(this,"key",void 0),p(this,"identifier",void 0),p(this,"addr",void 0),p(this,"eventListeners",void 0),p(this,"clients",void 0),p(this,"defaultClient",void 0),p(this,"msgCache",void 0),p(this,"acceptAddrs",void 0),p(this,"sessions",void 0),p(this,"isReady",void 0),p(this,"isFailed",void 0),p(this,"isClosed",void 0);let t=(e=c.util.assignDefined({},g.defaultOptions,e)).identifier||"",r={};if(e.originalClient){let t=u.addIdentifier("","");r[t]=new s.default(e),e.seed||(e=c.util.assignDefined({},e,{seed:r[t].key.seed}))}for(let n=0;n{if(this.isClosed)return!1;if(a===c.pb.payloads.PayloadType.SESSION){if(!A)return!1;try{await this._handleSessionMsg(t,i,g,s)}catch(e){if(!(e instanceof n.errors.SessionClosedError||e instanceof c.errors.AddrNotAllowedError))throw e}return!1}let l=c.util.bytesToHex(g);if(null!==this.msgCache.get(l))return!1;if(this.msgCache.put(l,t,e.msgCacheExpiration),i=u.removeIdentifier(i).addr,this.eventListeners.message.length>0){let e=await o.default.all(this.eventListeners.message.map(async e=>{try{return await e({src:i,payload:s,payloadType:a,isEncrypted:A,messageId:g,noReply:f})}catch(e){return console.log("Message handler error:",e),null}}));if(!f){let t=!1;for(let r of e){if(!1===r)return!1;if(void 0!==r&&null!==r){this.send(i,r,{encrypt:A,msgHoldingSeconds:0,replyToId:g}).catch(e=>{console.log("Send response error:",e)}),t=!0;break}}if(!t)for(let e of Object.keys(r))r[e].isReady&&r[e]._sendACK(u.addIdentifierPrefixAll(i,e),g,A).catch(e=>{console.log("Send ack error:",e)})}}return!1});let A=Object.keys(this.clients).map(e=>new o.default((t,r)=>{this.clients[e].onConnect(t)}));o.default.any(A).then(e=>{this.isReady=!0,this.eventListeners.connect.length>0&&this.eventListeners.connect.forEach(async t=>{try{await t(e)}catch(e){console.log("Connect handler error:",e)}})});let f=Object.keys(this.clients).map(e=>new o.default((t,r)=>{this.clients[e].onConnectFailed(t)}));o.default.all(f).then(()=>{this.isFailed=!0,this.eventListeners.connectFailed.length>0?this.eventListeners.connectFailed.forEach(async e=>{try{await e()}catch(e){console.log("Connect failed handler error:",e)}}):console.log("All clients connect failed")})}getSeed(){return this.key.seed}getPublicKey(){return this.key.publicKey}_shouldAcceptAddr(e){for(let t of this.acceptAddrs)if(t.test(e))return!0;return!1}async _handleSessionMsg(e,t,r,n){let i,s=u.removeIdentifier(t),a=s.addr,A=s.clientID,g=u.sessionKey(a,r),f=this.sessions.has(g);if(f)i=this.sessions.get(g);else{if(!this._shouldAcceptAddr(a))throw new c.errors.AddrNotAllowedError;i=this._newSession(a,r,this.options.sessionConfig),this.sessions.set(g,i)}i.receiveWith(e,A,n),f||(await i.accept(),this.eventListeners.session.length>0&&await o.default.all(this.eventListeners.session.map(async e=>{try{return await e(i)}catch(e){return void console.log("Session handler error:",e)}})))}_newSession(e,t,r={}){let i=this.readyClientIDs().sort();return new n.Session(this.addr,e,i,null,async(r,n,i)=>{let o=this.clients[r];if(!o.isReady)throw new c.errors.ClientNotReadyError;let s=f.newSessionPayload(i,t);await o._send(u.addIdentifierPrefix(e,n),s)},r)}async sendWithClient(e,t,r,n={}){let i=this.clients[e];if(!i)throw new c.errors.InvalidArgumentError("no such clientID");if(!i.isReady)throw new c.errors.ClientNotReadyError;return await i.send(u.addIdentifierPrefixAll(t,e),r,n)}readyClientIDs(){return Object.keys(this.clients).filter(e=>this.clients[e]&&this.clients[e].isReady)}async send(e,t,r={}){r=c.util.assignDefined({},r,{messageId:c.util.randomBytes(f.messageIdSize)});let n=this.readyClientIDs();if(0===n.length)throw new c.errors.ClientNotReadyError;e=await this.defaultClient._processDests(e);try{return await o.default.any(n.map(n=>this.sendWithClient(n,e,t,r)))}catch(e){throw new Error("failed to send with any client: "+e.errors)}}async publish(e,t,r={}){let n=(r=c.util.assignDefined({},A.defaultPublishOptions,r,{noReply:!0})).offset,i=await this.getSubscribers(e,{offset:n,limit:r.limit,txPool:r.txPool}),o=i.subscribers,s=i.subscribersInTxPool;for(;i.subscribers&&i.subscribers.length>=r.limit;)n+=r.limit,i=await this.getSubscribers(e,{offset:n,limit:r.limit}),o=o.concat(i.subscribers);return r.txPool&&(o=o.concat(s)),await this.send(o,t,r)}on(e,t){this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(t)}onConnect(e){this.eventListeners.connect.push(e)}onConnectFailed(e){this.eventListeners.connectFailed.push(e)}onMessage(e){this.eventListeners.message.push(e)}onSession(e){this.eventListeners.session.push(e)}async close(){let e=[];for(let t of this.sessions.values())e.push(t.close());try{await o.default.all(e)}catch(e){console.log(e)}Object.keys(this.clients).forEach(e=>{try{this.clients[e].close()}catch(e){console.log(e)}}),this.msgCache.clear(),this.isClosed=!0}listen(e){null===e||void 0===e?e=[g.defaultSessionAllowAddr]:Array.isArray(e)||(RegExp,e=[e]),this.acceptAddrs=[];for(let t=0;te.wallet.options.rpcServerAddr);if(t.length>0)try{return await o.default.any(t.map(t=>a.default.sendTransaction(e,t.wallet.options)))}catch(e){}return await a.default.sendTransaction(e,this.options)}transferTo(e,t,r={}){return c.rpc.transferTo.call(this,e,t,r)}registerName(e,t={}){return c.rpc.registerName.call(this,e,t)}transferName(e,t,r={}){return c.rpc.transferName.call(this,e,t,r)}deleteName(e,t={}){return c.rpc.deleteName.call(this,e,t)}subscribe(e,t,r="",n="",i={}){return c.rpc.subscribe.call(this,e,t,r,n,i)}unsubscribe(e,t="",r={}){return c.rpc.unsubscribe.call(this,e,t,r)}createTransaction(e,t,r={}){return this.defaultClient.wallet.createTransaction(e,t,r)}}},{"../client":3,"../client/consts":2,"../client/message":4,"../common":10,"../wallet":28,"./consts":21,"./util":24,"@nkn/ncp":38,"core-js-pure/features/promise":122,"memory-cache":313}],24:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addIdentifier=function(e,t){if(""===t)return e;return o(e,"__"+t+"__")},r.addIdentifierPrefix=o,r.addIdentifierPrefixAll=function(e,t){if(Array.isArray(e))return e.map(e=>o(e,t));return o(e,t)},r.removeIdentifier=function(e){let t=e.split(".");if(n.multiclientIdentifierRe.test(t[0]))return{addr:t.slice(1).join("."),clientID:t[0]};return{addr:e,clientID:""}},r.sessionKey=function(e,t){return e+t};var n=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=i(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=o?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}n.default=e,r&&r.set(e,n);return n}(e("./consts"));function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function o(e,t){return""===e?""+t:""===t?""+e:t+"."+e}},{"./consts":21}],25:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=s(e("./address")),i=s(e("../common"));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}function s(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=o(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=i?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}return n.default=e,r&&r.set(e,n),n}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.default=class{constructor(e,t={}){a(this,"key",void 0),a(this,"signatureRedeem",void 0),a(this,"programHash",void 0),a(this,"address",void 0),a(this,"contract",void 0),this.key=new i.Key(e,{worker:t.worker}),this.signatureRedeem=n.publicKeyToSignatureRedeem(this.key.publicKey),this.programHash=n.hexStringToProgramHash(this.signatureRedeem),this.address=n.programHashStringToAddress(this.programHash),this.contract=function(e,t){let r=n.prefixByteCountToHexString(e);return r+=n.prefixByteCountToHexString("00"),r+=t}(this.signatureRedeem,this.programHash)}getPublicKey(){return this.key.publicKey}getSeed(){return this.key.seed}}},{"../common":10,"./address":26}],26:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UINT160_LEN=r.CHECKSUM_LEN=r.BITCOIN_BASE58=r.ADDRESS_LEN=r.ADDRESS_GEN_PREFIX_LEN=r.ADDRESS_GEN_PREFIX=void 0,r.addressStringToProgramHash=f,r.genAddressVerifyBytesFromProgramHash=u,r.genAddressVerifyCodeFromProgramHash=l,r.getAddressStringVerifyCode=h,r.hexStringToProgramHash=function(e){return n.hash.ripemd160Hex(n.hash.sha256Hex(e))},r.prefixByteCountToHexString=function(e){let t=e.length;if(0===t)return"00";1==t%2&&(e="0"+e,t+=1);let r=t/2;1==(r=r.toString(16)).length%2&&(r="0"+r);return r+e},r.programHashStringToAddress=function(e){let r=u(e),i=n.util.hexToBytes(a+e);return s.encode(t.from(n.util.mergeTypedArrays(i,r)))},r.publicKeyToSignatureRedeem=function(e){return"20"+e+"ac"},r.signatureToParameter=function(e){return"40"+e},r.verifyAddress=function(e){try{let t=s.decode(e);if(t.length!==g)return!1;let r=t.slice(0,A),i=n.util.bytesToHex(r);if(i!==a)return!1;let o=f(e),c=h(e),u=l(o);return c===u}catch(e){return!1}};var n=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=i(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=o?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}n.default=e,r&&r.set(e,n);return n}(e("../common"));function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}const o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";r.BITCOIN_BASE58=o;const s=e("base-x")(o),a="02b825";r.ADDRESS_GEN_PREFIX=a;const A=a.length/2;r.ADDRESS_GEN_PREFIX_LEN=A;r.UINT160_LEN=20;const c=4;r.CHECKSUM_LEN=c;const g=A+20+c;function f(e){let t=s.decode(e),r=t.slice(A,t.length-c);return n.util.bytesToHex(r)}function u(e){return e=a+e,n.util.hexToBytes(n.hash.doubleSha256Hex(e)).slice(0,c)}function l(e){let t=u(e);return n.util.bytesToHex(t)}function h(e){let t=s.decode(e).slice(-c);return n.util.bytesToHex(t)}r.ADDRESS_LEN=g}).call(this,e("buffer").Buffer)},{"../common":10,"base-x":85,buffer:119}],27:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.scryptParams=r.defaultOptions=void 0;r.defaultOptions={rpcServerAddr:"https://mainnet-rpc-node-0001.nkn.org/mainnet/api/wallet",worker:!1};r.scryptParams={saltLen:8,N:32768,r:8,p:1}},{}],28:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return i.default}});var n,i=(n=e("./wallet"))&&n.__esModule?n:{default:n}},{"./wallet":30}],29:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.nameRegistrationFee=void 0,r.newDeleteNamePayload=function(e,r){let n=new i.pb.transaction.DeleteName;n.setRegistrant(t.from(e,"hex")),n.setName(r);let o=new i.pb.transaction.Payload;return o.setType(i.pb.transaction.PayloadType.DELETE_NAME_TYPE),o.setData(n.serializeBinary()),o},r.newNanoPayPayload=function(e,r,n,o,s,a){let A=new i.pb.transaction.NanoPay;A.setSender(t.from(e,"hex")),A.setRecipient(t.from(r,"hex")),A.setId(n),A.setAmount(new i.Amount(o).value()),A.setTxnExpiration(s),A.setNanoPayExpiration(a);let c=new i.pb.transaction.Payload;return c.setType(i.pb.transaction.PayloadType.NANO_PAY_TYPE),c.setData(A.serializeBinary()),c},r.newRegisterNamePayload=function(e,r,n=a){let o=new i.pb.transaction.RegisterName;o.setRegistrant(t.from(e,"hex")),o.setName(r),o.setRegistrationFee(new i.Amount(n).value());let s=new i.pb.transaction.Payload;return s.setType(i.pb.transaction.PayloadType.REGISTER_NAME_TYPE),s.setData(o.serializeBinary()),s},r.newSubscribePayload=function(e,r,n,o,s){let a=new i.pb.transaction.Subscribe;a.setSubscriber(t.from(e,"hex")),a.setIdentifier(r),a.setTopic(n),a.setDuration(o),a.setMeta(s);let A=new i.pb.transaction.Payload;return A.setType(i.pb.transaction.PayloadType.SUBSCRIBE_TYPE),A.setData(a.serializeBinary()),A},r.newTransaction=async function(e,r,n,o="0",s=""){let a=new i.pb.transaction.UnsignedTx;a.setPayload(r),a.setNonce(n),a.setFee(new i.Amount(o).value()),a.setAttributes(t.from(s,"hex"));let A=new i.pb.transaction.Transaction;return A.setUnsignedTx(a),await g(e,A),A},r.newTransferNamePayload=function(e,r,n){let o=new i.pb.transaction.TransferName;o.setName(e),o.setRegistrant(t.from(r,"hex")),o.setRecipient(t.from(n,"hex"));let s=new i.pb.transaction.Payload;return s.setType(i.pb.transaction.PayloadType.TRANSFER_NAME_TYPE),s.setData(o.serializeBinary()),s},r.newTransferPayload=function(e,r,n){let o=new i.pb.transaction.TransferAsset;o.setSender(t.from(e,"hex")),o.setRecipient(t.from(r,"hex")),o.setAmount(new i.Amount(n).value());let s=new i.pb.transaction.Payload;return s.setType(i.pb.transaction.PayloadType.TRANSFER_ASSET_TYPE),s.setData(o.serializeBinary()),s},r.newUnsubscribePayload=function(e,r,n){let o=new i.pb.transaction.Unsubscribe;o.setSubscriber(t.from(e,"hex")),o.setIdentifier(r),o.setTopic(n);let s=new i.pb.transaction.Payload;return s.setType(i.pb.transaction.PayloadType.UNSUBSCRIBE_TYPE),s.setData(o.serializeBinary()),s},r.serializePayload=A,r.serializeUnsignedTx=c,r.signTx=g;var n=s(e("./address")),i=s(e("../common"));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}function s(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=o(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=i?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}return n.default=e,r&&r.set(e,n),n}const a="10";function A(e){let t="";return t+=i.serialize.encodeUint32(e.getType()),t+=i.serialize.encodeBytes(e.getData())}function c(e){let t="";return t+=A(e.getPayload()),t+=i.serialize.encodeUint64(e.getNonce()),t+=i.serialize.encodeUint64(e.getFee()),t+=i.serialize.encodeBytes(e.getAttributes())}async function g(e,r){let o=c(r.getUnsignedTx()),s=i.hash.sha256Hex(o),a=await e.key.sign(s);r.hash=i.hash.doubleSha256Hex(o);let A=new i.pb.transaction.Program;A.setCode(t.from(e.signatureRedeem,"hex")),A.setParameter(t.from(n.signatureToParameter(a),"hex")),r.setProgramsList([A])}r.nameRegistrationFee=a}).call(this,e("buffer").Buffer)},{"../common":10,"./address":26,buffer:119}],30:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=f(e("scrypt-js")),i=f(e("./account")),o=g(e("./address")),s=g(e("../common")),a=g(e("./consts")),A=g(e("./transaction"));function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function g(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function f(e){return e&&e.__esModule?e:{default:e}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class l{constructor(e={}){switch(u(this,"options",void 0),u(this,"account",void 0),u(this,"iv",void 0),u(this,"masterKey",void 0),u(this,"address",void 0),u(this,"programHash",void 0),u(this,"seedEncrypted",void 0),u(this,"scryptParams",void 0),u(this,"version",void 0),e=s.util.assignDefined({},a.defaultOptions,e),this.version=e.version||l.version,this.version){case 2:this.scryptParams=s.util.assignDefined({},a.scryptParams,e.scrypt),this.scryptParams.salt=this.scryptParams.salt||s.util.randomBytesHex(this.scryptParams.saltLen)}this.options=e,this.account=new i.default(e.seed,{worker:e.worker}),this.address=this.account.address,this.programHash=this.account.programHash,(e.iv||e.masterKey||e.password||e.passwordKey)&&this._completeWallet(Object.assign({},e,{async:!1})),delete e.seed,delete e.iv,delete e.masterKey,delete e.password,delete e.passwordKey}static _computePasswordKey(e){if(!(e=s.util.toLowerKeys(e)).version)throw new s.errors.InvalidArgumentError("missing version field");switch(e.version){case 1:return e.async?Promise.resolve(s.hash.doubleSha256(e.password)):s.hash.doubleSha256(e.password);case 2:if(!e.scrypt)throw new s.errors.InvalidArgumentError("missing scrypt field");if(!(e.scrypt.salt&&e.scrypt.n&&e.scrypt.r&&e.scrypt.p))throw new s.errors.InvalidArgumentError("incomplete scrypt parameters");return e.async?n.default.scrypt(s.util.utf8ToBytes(e.password),s.util.hexToBytes(e.scrypt.salt),e.scrypt.n,e.scrypt.r,e.scrypt.p,32).then(s.util.bytesToHex):s.util.bytesToHex(n.default.syncScrypt(s.util.utf8ToBytes(e.password),s.util.hexToBytes(e.scrypt.salt),e.scrypt.n,e.scrypt.r,e.scrypt.p,32));default:throw new s.errors.InvalidWalletFormatError("unsupported wallet verison "+e.version)}}static _decryptWallet(e,t){switch(t.iv=e.iv,t.masterKey=s.aes.decrypt(e.masterkey,t.passwordKey,t.iv),t.seed=s.aes.decrypt(e.seedencrypted,t.masterKey,t.iv),t.passwordKey={[e.version]:t.passwordKey},e.version){case 2:t.scrypt={salt:e.scrypt.salt,N:e.scrypt.n,r:e.scrypt.r,p:e.scrypt.p}}if(new i.default(t.seed,{worker:!1}).address!==e.address)throw new s.errors.WrongPasswordError;return new l(t)}_completeWallet(e={}){if(this.seedEncrypted)return e.async?Promise.resolve():void 0;let t,r=t=>{let r=e.iv||s.util.randomBytesHex(16),n=e.masterKey||s.util.randomBytesHex(32);this.iv=r,this.masterKey=s.aes.encrypt(n,t,r),this.seedEncrypted=s.aes.encrypt(this.account.getSeed(),n,r)};if(e.passwordKey&&e.passwordKey[""+this.version])t=e.passwordKey[""+this.version];else{if(e.async)return l._computePasswordKey({version:this.version,password:e.password||"",scrypt:this.scryptParams,async:!0}).then(r);t=l._computePasswordKey({version:this.version,password:e.password||"",scrypt:this.scryptParams,async:!1})}return r(t),e.async?Promise.resolve():void 0}static fromJSON(e,t={}){let r;if(r="string"==typeof e?JSON.parse(e):e,"number"!=typeof(r=s.util.toLowerKeys(r)).version||r.versionl.maxCompatibleVersion)throw new s.errors.InvalidWalletVersionError("invalid wallet version "+r.version+", should be between "+l.minCompatibleVersion+" and "+l.maxCompatibleVersion);if(!r.masterkey)throw new s.errors.InvalidWalletFormatError("missing masterKey field");if(!r.iv)throw new s.errors.InvalidWalletFormatError("missing iv field");if(!r.seedencrypted)throw new s.errors.InvalidWalletFormatError("missing seedEncrypted field");if(!r.address)throw new s.errors.InvalidWalletFormatError("missing address field");if(t.async)return l._computePasswordKey(Object.assign({},r,{password:t.password,async:!0})).then(e=>l._decryptWallet(r,Object.assign({},t,{passwordKey:e})));{let e=l._computePasswordKey(Object.assign({},r,{password:t.password,async:!1}));return l._decryptWallet(r,Object.assign({},t,{passwordKey:e}))}}toJSON(){this._completeWallet({async:!1});let e={Version:this.version,MasterKey:this.masterKey,IV:this.iv,SeedEncrypted:this.seedEncrypted,Address:this.address};return this.scryptParams&&(e.Scrypt={Salt:this.scryptParams.salt,N:this.scryptParams.N,R:this.scryptParams.r,P:this.scryptParams.p}),e}getSeed(){return this.account.getSeed()}getPublicKey(){return this.account.getPublicKey()}static verifyAddress(e){return o.verifyAddress(e)}_verifyPassword(e){this._completeWallet({async:!1});let t=s.aes.decrypt(this.masterKey,e,this.iv),r=s.aes.decrypt(this.seedEncrypted,t,this.iv);return new i.default(r,{worker:!1}).address===this.address}verifyPassword(e,t={}){let r={version:this.version,password:e,scrypt:this.scryptParams,async:t.async};if(t.async){return(async()=>{await this._completeWallet({async:!0});let e=await l._computePasswordKey(r);return this._verifyPassword(e)})()}{this._completeWallet({async:!1});let e=l._computePasswordKey(r);return this._verifyPassword(e)}}static getLatestBlock(e={}){return e=s.util.assignDefined({},a.defaultOptions,e),s.rpc.getLatestBlock(e)}getLatestBlock(){return l.getLatestBlock(this.options)}static getRegistrant(e,t={}){return t=s.util.assignDefined({},a.defaultOptions,t),s.rpc.getRegistrant(e,t)}getRegistrant(e){return l.getRegistrant(e,this.options)}static getSubscribers(e,t={}){return t=s.util.assignDefined({},a.defaultOptions,t),s.rpc.getSubscribers(e,t)}getSubscribers(e,t={}){return l.getSubscribers(e,Object.assign({},this.options,t))}static getSubscribersCount(e,t={}){return t=s.util.assignDefined({},a.defaultOptions,t),s.rpc.getSubscribersCount(e,t)}getSubscribersCount(e){return l.getSubscribersCount(e,this.options)}static getSubscription(e,t,r={}){return r=s.util.assignDefined({},a.defaultOptions,r),s.rpc.getSubscription(e,t,r)}getSubscription(e,t){return l.getSubscription(e,t,this.options)}static getBalance(e,t={}){return t=s.util.assignDefined({},a.defaultOptions,t),s.rpc.getBalance(e,t)}getBalance(e){return l.getBalance(e||this.address,this.options)}static getNonce(e,t={}){return t=s.util.assignDefined({},a.defaultOptions,t),s.rpc.getNonce(e,t)}getNonce(e,t={}){return t=s.util.assignDefined({},this.options,t),l.getNonce(e||this.address,t)}static sendTransaction(e,t={}){return t=s.util.assignDefined({},a.defaultOptions,t),s.rpc.sendTransaction(e,t)}sendTransaction(e){return l.sendTransaction(e,this.options)}transferTo(e,t,r={}){return s.rpc.transferTo.call(this,e,t,r)}registerName(e,t={}){return s.rpc.registerName.call(this,e,t)}transferName(e,t,r={}){return s.rpc.transferName.call(this,e,t,r)}deleteName(e,t={}){return s.rpc.deleteName.call(this,e,t)}subscribe(e,t,r="",n="",i={}){return s.rpc.subscribe.call(this,e,t,r,n,i)}unsubscribe(e,t="",r={}){return s.rpc.unsubscribe.call(this,e,t,r)}async createOrUpdateNanoPay(e,t,r,n,i={}){if(!o.verifyAddress(e))throw new s.errors.InvalidAddressError("invalid recipient address");n||(n=s.util.randomUint64());let a=A.newNanoPayPayload(this.programHash,o.addressStringToProgramHash(e),n,t,r,r);return await this.createTransaction(a,0,i)}createTransaction(e,t,r={}){return A.newTransaction(this.account,e,t,r.fee,r.attrs)}static publicKeyToAddress(e){let t=o.publicKeyToSignatureRedeem(e),r=o.hexStringToProgramHash(t);return o.programHashStringToAddress(r)}}r.default=l,u(l,"version",2),u(l,"minCompatibleVersion",1),u(l,"maxCompatibleVersion",2)},{"../common":10,"./account":25,"./address":26,"./consts":27,"./transaction":29,"scrypt-js":371}],31:[function(e,t,r){"use strict";var n,i=(n=e("./worker"))&&n.__esModule?n:{default:n};"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&(0,i.default)(self)},{"./worker":32}],32:[function(e,t,r){"use strict";var n=o(e("../common/crypto"));o(e("../common/util"));function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function o(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=i(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=o?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=e[s]}return n.default=e,r&&r.set(e,n),n}t.exports=function(e){let t;e.onmessage=async function(r){try{let i=null;switch(r.data.action){case"setSeed":if(t){if(r.data.seed!==t.seed)throw"cannot set to different seed"}else t=n.keyPair(r.data.seed);break;case"computeSharedKey":if(!t)throw"worker key not created";i=await n.computeSharedKey(t.curvePrivateKey,r.data.otherPubkey);break;case"sign":if(!t)throw"worker key not created";i=await n.sign(t.privateKey,r.data.message);break;default:throw"unknown action: "+r.data.action}e.postMessage({id:r.data.id,result:i})}catch(t){e.postMessage({id:r.data.id,error:t})}}}},{"../common/crypto":7,"../common/util":19}],33:[function(e,t,r){(function(r){"use strict";e("setimmediate");const n=e=>{let t;const r=[],n=new Promise((e,n)=>{t={resolve:t=>{r.forEach(e=>{e(t)}),e(t)},reject:n}});return Object.assign(n,{cancel:()=>{t.cancelled=!0,r.splice(0,r.length)},channel:e,prethen:e=>{r.push(e)}}),{order:t,promise:n}},i={},o=function(e=0){let t,s=0,a=!1;const A=[],c=[],g=()=>{const r={push:0,shift:0};(r=>{for(;r.push{for(let r=t.push+s;r{for(;e.shift{for(let e=0;e{const t=o();return(async()=>{await f.forEach(t.push);for(let r=0;r{for(;;){const r=await f.shift();if(void 0===r)return!0;if(!e.call(t,r))return!1}},filter:(e,t)=>{const r=o();return(async()=>{await f.forEach(async n=>{await e.call(t,n)&&await r.push(n)}),await r.close()})(),r},forEach:async(e,t)=>{for(;;){const r=await f.shift();if(void 0===r)break;await e.call(t,r)}},join:async e=>(await f.values()).join(e),map:(e,t)=>{const r=o();return(async()=>{await f.forEach(n=>r.push(e.call(t,n))),await r.close()})(),r},readOnly:()=>f,reduce:async(e,...t)=>{let r=t[0],n=t.length>0;if(await f.forEach(t=>{n?r=e(r,t):(r=t,n=!0)}),n)return r;throw new TypeError("No values in channel and initialValue wasn't provided.")},shift:function(){const{order:e,promise:t}=n(this);return c.push(e),r(g),t},slice:(e,t=1/0)=>{const r=o();return(async()=>{for(let t=0;t{for(;;){const r=await f.shift();if(void 0===r)return!1;if(e.call(t,r))return!0}},toString:()=>`Channel(${e})`,value:()=>t,values:async()=>{const e=[];return await f.forEach(t=>{e.push(t)}),e}})),u=Object.freeze(Object.assign(Object.create(i),{close:()=>new Promise((e,t)=>{a?t(new Error("Can't close an already-closed channel.")):(a=!0,g(),r(e))}),length:e,push:function(e){const{order:t,promise:i}=n(this);return t.value=e,Promise.resolve(e).catch(()=>{}),a?t.reject(new Error("Can't push to closed channel.")):void 0===e?t.reject(new TypeError("Can't push 'undefined' to channel, use close instead.")):arguments.length>1?t.reject(new Error("Can't push more than one value at a time.")):(A.push(t),r(g)),i},writeOnly:()=>u}));return Object.freeze(Object.assign(Object.create(i),f,u))};o.from=((e,t,r)=>{const n=o();return(async()=>{try{for(let t of e)await n.push(t);await n.close()}catch(t){try{for(;;){const t=e();if(void 0===t){await n.close();break}await n.push(t)}}catch(t){((e,t)=>{t.on("readable",async()=>{for(;;){const r=t.read();if(null===r)break;await e.push(r)}}),t.once("end",e.close)})(n,e)}}})(),(t?n.map(t,r):n).readOnly()}),o.of=((...e)=>o.from(e)),o.isChannel=(e=>void 0!==e&&null!==e&&Object.getPrototypeOf(e)===i),o.select=(e=>{if(!Array.isArray(e))throw new TypeError("Channel.select: Argument must be an array.");const t=new Promise((t,r)=>{e.forEach(async n=>{try{n.prethen(()=>{e.forEach(e=>{e!==n&&e.cancel()})});try{await n}catch(e){r(e)}t(n.channel)}catch(e){r(new TypeError("Channel.select accepts only promises returned by push & shift."))}})});return Object.assign(t,{cancel:()=>e.forEach(e=>e.cancel())})}),o.selectValue=(e=>{if(!Array.isArray(e))throw new TypeError("Channel.select: Argument must be an array.");const t=new Promise((t,r)=>{e.forEach(async n=>{try{n.prethen(()=>{e.forEach(e=>{e!==n&&e.cancel()})});try{t(await n)}catch(e){r(e)}}catch(e){r(new TypeError("Channel.select accepts only promises returned by push & shift."))}})});return Object.assign(t,{cancel:()=>e.forEach(e=>e.cancel())})});const s=o(),a={reduce:2,slice:2};Object.keys(s).filter(e=>"function"==typeof s[e]).forEach(e=>{const t=function(...r){const n=a[e]||s[e].length;return r.length>n?r[n][e](...r.slice(0,n)):t.bind(this,...r)};o[e]=t}),t.exports=Object.freeze(o)}).call(this,e("timers").setImmediate)},{setimmediate:372,timers:382}],34:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=g(e("./channel")),i=g(e("heap")),o=e("./pb/packet_pb"),s=c(e("./errors")),a=c(e("./util"));function A(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(A=function(e){return e?r:t})(e)}function c(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=A(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function g(e){return e&&e.__esModule?e:{default:e}}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.default=class{constructor(e,t,r){f(this,"session",void 0),f(this,"localClientID",void 0),f(this,"remoteClientID",void 0),f(this,"windowSize",void 0),f(this,"sendWindowUpdate",void 0),f(this,"timeSentSeq",void 0),f(this,"resentSeq",void 0),f(this,"sendAckQueue",void 0),f(this,"retransmissionTimeout",void 0),this.session=e,this.localClientID=t,this.remoteClientID=r,this.windowSize=e.config.initialConnectionWindowSize,this.retransmissionTimeout=e.config.initialRetransmissionTimeout,this.sendWindowUpdate=new n.default(1),this.timeSentSeq=new Map,this.resentSeq=new Map,this.sendAckQueue=new i.default}sendWindowUsed(){return this.timeSentSeq.size}sendAck(e){this.sendAckQueue.push(e)}sendAckQueueLen(){return this.sendAckQueue.size()}receiveAck(e,t){if(this.timeSentSeq.has(e)){if(this.resentSeq.has(e)||(this.windowSize++,this.windowSize>this.session.config.maxConnectionWindowSize&&(this.windowSize=this.session.config.maxConnectionWindowSize)),t){let t=Date.now()-this.timeSentSeq.get(e);this.retransmissionTimeout+=100*Math.tanh((3*t-this.retransmissionTimeout)/1e3),this.retransmissionTimeout>this.session.config.maxRetransmissionTimeout&&(this.retransmissionTimeout=this.session.config.maxRetransmissionTimeout)}this.timeSentSeq.delete(e),this.resentSeq.delete(e),n.default.select([this.sendWindowUpdate.push(null),a.closedChan.shift()])}}async _waitForSendWindow(e){for(;this.sendWindowUsed()>=this.windowSize;){let t=a.timeoutChan(a._maxWait);switch(await n.default.select([this.sendWindowUpdate.shift(),t.shift(),e.done.shift()])){case this.sendWindowUpdate:break;case t:throw a._errMaxWait;case e.done:throw e.err}}}start(){this._tx().catch(()=>{}),this._sendAck().catch(()=>{}),this._checkTimeout().catch(()=>{})}async _tx(){let e=0;for(;;){if(0===e&&(e=await this.session._getResendSeq()),0===e){try{await this._waitForSendWindow(this.session.context)}catch(e){if(e===a._errMaxWait)continue;throw e}e=await this.session._getSendSeq()}let t=this.session.getDataToSend(e);if(t){try{await this.session.sendWith(this.localClientID,this.remoteClientID,t)}catch(t){if(this.session.isClosed)throw new s.SessionClosedError;switch(console.log(t),await n.default.select([this.session.resendChan.push(e),this.session.context.done.shift()])){case this.session.resendChan:e=0;break;case this.session.context.done:throw this.session.context.err}await a.sleep(1e3);continue}this.timeSentSeq.has(e)||this.timeSentSeq.set(e,Date.now()),this.resentSeq.delete(e),e=0}else this.timeSentSeq.delete(e),this.resentSeq.delete(e),e=0}}async _sendAck(){for(;;){let e=a.timeoutChan(this.session.config.sendAckInterval);switch(await n.default.select([e.shift(),this.session.context.done.shift()])){case e:break;case this.session.context.done:throw this.session.context.err}if(0===this.sendAckQueueLen())continue;let t=[],r=[];for(;this.sendAckQueueLen()>0&&t.length0&&this.sendAckQueue.peek()===a.nextSeq(e,n);)this.sendAckQueue.pop(),n++;t.push(e),r.push(n)}let i=!0;for(let e of r)if(1!=e){i=!1;break}i&&(r=null);try{let e=new o.Packet;e.setAckStartSeqList(t),r&&e.setAckSeqCountList(r),e.setBytesRead(this.session.bytesRead);let n=e.serializeBinary();await this.session.sendWith(this.localClientID,this.remoteClientID,n),this.session.bytesReadSentTime=Date.now()}catch(e){console.log(e),await a.sleep(1e3);continue}}}async _checkTimeout(){for(;;){let e=a.timeoutChan(this.session.config.checkTimeoutInterval);switch(await n.default.select([e.shift(),this.session.context.done.shift()])){case e:break;case this.session.context.done:throw this.session.context.err}let t=Date.now()-this.retransmissionTimeout;for(let[e,r]of this.timeSentSeq)if(!this.resentSeq.has(e)&&r0&&(A=new i.default,c.push(A.shift()),this.timeoutTimer=setTimeout(A.close,r)),c.length>0&&i.default.select(c).then(t=>{switch(t){case n:return e.err;case this.cancelChan:return new s;case A:return new a}}).then(e=>{this.err=e,this.done.close(),this.cancel(),clearTimeout(this.timeoutTimer)})}async cancel(){try{this.cancelChan&&await this.cancelChan.close()}catch(e){}}static background(){return new A(null,!1,0)}static withCancel(e){return new A(e,!0,0)}static withTimeout(e,t){return new A(e,!0,t)}}r.default=A},{"./channel":33}],37:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WriteDeadlineExceededError=r.SessionNotEstablishedError=r.SessionEstablishedError=r.SessionClosedError=r.RecvWindowFullError=r.ReadDeadlineExceededError=r.NotHandshakeError=r.InvalidPacketError=r.DialTimeoutError=r.DataSizeTooLargeError=r.BufferSizeTooSmallError=void 0;class n extends Error{constructor(e="session closed",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,n),this.name="SessionClosedError"}}r.SessionClosedError=n;class i extends Error{constructor(e="session is already established",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="SessionEstablishedError"}}r.SessionEstablishedError=i;class o extends Error{constructor(e="session not established yet",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,o),this.name="SessionNotEstablishedError"}}r.SessionNotEstablishedError=o;class s extends Error{constructor(e="read deadline exceeded",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,s),this.name="ReadDeadlineExceededError"}}r.ReadDeadlineExceededError=s;class a extends Error{constructor(e="write deadline exceeded",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,a),this.name="WriteDeadlineExceededError"}}r.WriteDeadlineExceededError=a;class A extends Error{constructor(e="read buffer size is less than data length in non-session mode",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,A),this.name="BufferSizeTooSmallError"}}r.BufferSizeTooSmallError=A;class c extends Error{constructor(e="data size is greater than session mtu in non-session mode",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,c),this.name="DataSizeTooLargeError"}}r.DataSizeTooLargeError=c;class g extends Error{constructor(e="invalid packet",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,g),this.name="InvalidPacketError"}}r.InvalidPacketError=g;class f extends Error{constructor(e="receive window full",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,f),this.name="RecvWindowFullError"}}r.RecvWindowFullError=f;class u extends Error{constructor(e="first packet is not handshake packet",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,u),this.name="NotHandshakeError"}}r.NotHandshakeError=u;class l extends Error{constructor(e="dial timeout",...t){super(e,...t),Error.captureStackTrace&&Error.captureStackTrace(this,l),this.name="DialTimeoutError"}}r.DialTimeoutError=l},{}],38:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"Connection",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(r,"Context",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(r,"Session",{enumerable:!0,get:function(){return o.default}}),r.util=r.errors=r.consts=void 0;var n=f(e("./connection")),i=f(e("./context")),o=f(e("./session")),s=g(e("./consts"));r.consts=s;var a=g(e("./errors"));r.errors=a;var A=g(e("./util"));function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function g(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function f(e){return e&&e.__esModule?e:{default:e}}r.util=A},{"./connection":34,"./consts":35,"./context":36,"./errors":37,"./session":40,"./util":41}],39:[function(e,t,r){"use strict";var n=e("google-protobuf"),i=n,o=Function("return this")();i.exportSymbol("proto.Packet",null,o),proto.Packet=function(e){n.Message.initialize(this,e,0,-1,proto.Packet.repeatedFields_,null)},i.inherits(proto.Packet,n.Message),i.DEBUG&&!COMPILED&&(proto.Packet.displayName="proto.Packet"),proto.Packet.repeatedFields_=[3,4,6],n.Message.GENERATE_TO_OBJECT&&(proto.Packet.prototype.toObject=function(e){return proto.Packet.toObject(e,this)},proto.Packet.toObject=function(e,t){var r={sequenceId:n.Message.getFieldWithDefault(t,1,0),data:t.getData_asB64(),ackStartSeqList:n.Message.getRepeatedField(t,3),ackSeqCountList:n.Message.getRepeatedField(t,4),bytesRead:n.Message.getFieldWithDefault(t,5,0),clientIdsList:n.Message.getRepeatedField(t,6),windowSize:n.Message.getFieldWithDefault(t,7,0),mtu:n.Message.getFieldWithDefault(t,8,0),close:n.Message.getFieldWithDefault(t,9,!1),handshake:n.Message.getFieldWithDefault(t,10,!1)};return e&&(r.$jspbMessageInstance=t),r}),proto.Packet.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.Packet;return proto.Packet.deserializeBinaryFromReader(r,t)},proto.Packet.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readUint32();e.setSequenceId(r);break;case 2:r=t.readBytes();e.setData(r);break;case 3:r=t.readPackedUint32();e.setAckStartSeqList(r);break;case 4:r=t.readPackedUint32();e.setAckSeqCountList(r);break;case 5:r=t.readUint64();e.setBytesRead(r);break;case 6:r=t.readString();e.addClientIds(r);break;case 7:r=t.readUint32();e.setWindowSize(r);break;case 8:r=t.readUint32();e.setMtu(r);break;case 9:r=t.readBool();e.setClose(r);break;case 10:r=t.readBool();e.setHandshake(r);break;default:t.skipField()}}return e},proto.Packet.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.Packet.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.Packet.serializeBinaryToWriter=function(e,t){var r=void 0;0!==(r=e.getSequenceId())&&t.writeUint32(1,r),(r=e.getData_asU8()).length>0&&t.writeBytes(2,r),(r=e.getAckStartSeqList()).length>0&&t.writePackedUint32(3,r),(r=e.getAckSeqCountList()).length>0&&t.writePackedUint32(4,r),0!==(r=e.getBytesRead())&&t.writeUint64(5,r),(r=e.getClientIdsList()).length>0&&t.writeRepeatedString(6,r),0!==(r=e.getWindowSize())&&t.writeUint32(7,r),0!==(r=e.getMtu())&&t.writeUint32(8,r),(r=e.getClose())&&t.writeBool(9,r),(r=e.getHandshake())&&t.writeBool(10,r)},proto.Packet.prototype.getSequenceId=function(){return n.Message.getFieldWithDefault(this,1,0)},proto.Packet.prototype.setSequenceId=function(e){n.Message.setProto3IntField(this,1,e)},proto.Packet.prototype.getData=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.Packet.prototype.getData_asB64=function(){return n.Message.bytesAsB64(this.getData())},proto.Packet.prototype.getData_asU8=function(){return n.Message.bytesAsU8(this.getData())},proto.Packet.prototype.setData=function(e){n.Message.setProto3BytesField(this,2,e)},proto.Packet.prototype.getAckStartSeqList=function(){return n.Message.getRepeatedField(this,3)},proto.Packet.prototype.setAckStartSeqList=function(e){n.Message.setField(this,3,e||[])},proto.Packet.prototype.addAckStartSeq=function(e,t){n.Message.addToRepeatedField(this,3,e,t)},proto.Packet.prototype.clearAckStartSeqList=function(){this.setAckStartSeqList([])},proto.Packet.prototype.getAckSeqCountList=function(){return n.Message.getRepeatedField(this,4)},proto.Packet.prototype.setAckSeqCountList=function(e){n.Message.setField(this,4,e||[])},proto.Packet.prototype.addAckSeqCount=function(e,t){n.Message.addToRepeatedField(this,4,e,t)},proto.Packet.prototype.clearAckSeqCountList=function(){this.setAckSeqCountList([])},proto.Packet.prototype.getBytesRead=function(){return n.Message.getFieldWithDefault(this,5,0)},proto.Packet.prototype.setBytesRead=function(e){n.Message.setProto3IntField(this,5,e)},proto.Packet.prototype.getClientIdsList=function(){return n.Message.getRepeatedField(this,6)},proto.Packet.prototype.setClientIdsList=function(e){n.Message.setField(this,6,e||[])},proto.Packet.prototype.addClientIds=function(e,t){n.Message.addToRepeatedField(this,6,e,t)},proto.Packet.prototype.clearClientIdsList=function(){this.setClientIdsList([])},proto.Packet.prototype.getWindowSize=function(){return n.Message.getFieldWithDefault(this,7,0)},proto.Packet.prototype.setWindowSize=function(e){n.Message.setProto3IntField(this,7,e)},proto.Packet.prototype.getMtu=function(){return n.Message.getFieldWithDefault(this,8,0)},proto.Packet.prototype.setMtu=function(e){n.Message.setProto3IntField(this,8,e)},proto.Packet.prototype.getClose=function(){return n.Message.getFieldWithDefault(this,9,!1)},proto.Packet.prototype.setClose=function(e){n.Message.setProto3BooleanField(this,9,e)},proto.Packet.prototype.getHandshake=function(){return n.Message.getFieldWithDefault(this,10,!1)},proto.Packet.prototype.setHandshake=function(e){n.Message.setProto3BooleanField(this,10,e)},i.object.extend(r,proto)},{"google-protobuf":288}],40:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=l(e("./channel")),i=l(e("core-js-pure/features/promise")),o=l(e("./connection")),s=u(e("./context")),a=e("./pb/packet_pb"),A=u(e("./consts")),c=u(e("./errors")),g=u(e("./util"));function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(f=function(e){return e?r:t})(e)}function u(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=f(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function l(e){return e&&e.__esModule?e:{default:e}}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.default=class{constructor(e,t,r,i,o,a={}){h(this,"config",void 0),h(this,"localAddr",void 0),h(this,"remoteAddr",void 0),h(this,"localClientIDs",void 0),h(this,"remoteClientIDs",void 0),h(this,"sendWith",void 0),h(this,"sendWindowSize",void 0),h(this,"recvWindowSize",void 0),h(this,"sendMtu",void 0),h(this,"recvMtu",void 0),h(this,"connections",void 0),h(this,"onAccept",void 0),h(this,"sendChan",void 0),h(this,"resendChan",void 0),h(this,"sendWindowUpdate",void 0),h(this,"recvDataUpdate",void 0),h(this,"context",void 0),h(this,"readContext",void 0),h(this,"writeContext",void 0),h(this,"isAccepted",void 0),h(this,"isEstablished",void 0),h(this,"isClosed",void 0),h(this,"sendBuffer",void 0),h(this,"sendWindowStartSeq",void 0),h(this,"sendWindowEndSeq",void 0),h(this,"sendWindowData",void 0),h(this,"recvWindowStartSeq",void 0),h(this,"recvWindowUsed",void 0),h(this,"recvWindowData",void 0),h(this,"bytesWrite",void 0),h(this,"bytesRead",void 0),h(this,"bytesReadSentTime",void 0),h(this,"bytesReadUpdateTime",void 0),h(this,"remoteBytesRead",void 0),h(this,"ReadableStream",void 0),h(this,"_readableStream",void 0),h(this,"WritableStream",void 0),h(this,"_writableStream",void 0),this.config=Object.assign({},A.defaultConfig,a),this.localAddr=e,this.remoteAddr=t,this.localClientIDs=r,this.remoteClientIDs=i,this.sendWith=o,this.sendWindowSize=this.config.sessionWindowSize,this.recvWindowSize=this.config.sessionWindowSize,this.sendMtu=this.config.mtu,this.recvMtu=this.config.mtu,this.sendWindowStartSeq=A.minSequenceID,this.sendWindowEndSeq=A.minSequenceID,this.recvWindowStartSeq=A.minSequenceID,this.recvWindowUsed=0,this.bytesWrite=0,this.bytesRead=0,this.bytesReadSentTime=Date.now(),this.bytesReadUpdateTime=Date.now(),this.remoteBytesRead=0,this.onAccept=new n.default(1),this.context=s.default.withCancel(),this.setTimeout(0),this.ReadableStream=null,this._readableStream=null,this.WritableStream=null,this._writableStream=null}isStream(){return!this.config.nonStream}sendWindowUsed(){return this.bytesWrite>this.remoteBytesRead?this.bytesWrite-this.remoteBytesRead:0}getDataToSend(e){return this.sendWindowData.get(e)}getConnWindowSize(){let e=0;for(let t of this.connections.values())e+=t.windowSize;return e}async _getResendSeq(){let e=await n.default.selectValue([this.resendChan.shift(),this.context.done.shift(),g.closedChan.shift()]);if(void 0===e){if(this.context.err)throw this.context.err;return 0}return e}async _getSendSeq(){let e=await n.default.selectValue([this.resendChan.shift(),this.sendChan.shift(),this.context.done.shift()]);if(void 0===e)throw this.context.err;return e}receiveWith(e,t,r){if(this.isClosed)throw new c.SessionClosedError;let i=a.Packet.deserializeBinary(r);if(i.getClose())return this._handleClosePacket();let o=this.isEstablished;if(!o&&i.getHandshake())return this._handleHandshakePacket(i);if(o&&(i.getAckStartSeqList().length>0||i.getAckSeqCountList().length>0)){if(i.getAckStartSeqList().length>0&&i.getAckSeqCountList().length>0&&i.getAckStartSeqList().length!==i.getAckSeqCountList().length)throw new c.InvalidPacketError("AckStartSeq and AckSeqCount should have the same length if both are non-empty");let r=0;r=i.getAckStartSeqList().length>0?i.getAckStartSeqList().length:i.getAckSeqCountList().length;let n=0,o=0;for(let s=0;s0?i.getAckStartSeqList()[s]:A.minSequenceID,o=i.getAckSeqCountList().length>0?g.nextSeq(n,i.getAckSeqCountList()[s]):g.nextSeq(n,1),g.seqInBetween(this.sendWindowStartSeq,this.sendWindowEndSeq,g.nextSeq(o,-1))){g.seqInBetween(this.sendWindowStartSeq,this.sendWindowEndSeq,n)||(n=this.sendWindowStartSeq);for(let r=n;g.seqInBetween(n,o,r);r=g.nextSeq(r,1)){for(let[n,i]of this.connections)i.receiveAck(r,n===g.connKey(e,t));this.sendWindowData.delete(r)}if(n===this.sendWindowStartSeq)for(;this.sendWindowStartSeq=g.nextSeq(this.sendWindowStartSeq,1),!this.sendWindowData.has(this.sendWindowStartSeq)&&this.sendWindowStartSeq!==this.sendWindowEndSeq;);}}if(o&&i.getBytesRead()>this.remoteBytesRead&&(this.remoteBytesRead=i.getBytesRead(),n.default.select([this.sendWindowUpdate.push(null),g.closedChan.shift()])),o&&i.getSequenceId()>0){if(i.getData().length>this.recvMtu)throw new c.DataSizeTooLargeError;if(g.compareSeq(i.getSequenceId(),this.recvWindowStartSeq)>=0&&!this.recvWindowData.has(i.getSequenceId())){if(this.recvWindowUsed+i.getData().length>this.recvWindowSize)throw new c.RecvWindowFullError;this.recvWindowData.set(i.getSequenceId(),i.getData()),this.recvWindowUsed+=i.getData().length,i.getSequenceId()===this.recvWindowStartSeq&&n.default.select([this.recvDataUpdate.push(null),g.closedChan.shift()])}let r=this.connections.get(g.connKey(e,t));r&&r.sendAck(i.getSequenceId())}}_start(){this._startFlush().catch(()=>{}),this._startCheckBytesRead().catch(()=>{});for(let e of this.connections.values())e.start()}async _startFlush(){for(;;){let e=g.timeoutChan(this.config.flushInterval);switch(await n.default.select([e.shift(),this.context.done.shift()])){case e:break;case this.context.done:throw this.context.err}if(this.sendBuffer&&0!==this.sendBuffer.length)try{await this._flushSendBuffer()}catch(e){if(this.context.err)throw e;console.log(e);continue}}}async _startCheckBytesRead(){for(;;){let e=g.timeoutChan(this.config.checkBytesReadInterval);switch(await n.default.select([e.shift(),this.context.done.shift()])){case e:break;case this.context.done:throw this.context.err}if(!(0===this.bytesRead||this.bytesReadSentTime>this.bytesReadUpdateTime||Date.now()-this.bytesReadUpdateTimethis.sendWindowSize;){let t=g.timeoutChan(g._maxWait);switch(await n.default.select([this.sendWindowUpdate.shift(),t.shift(),e.done.shift()])){case this.sendWindowUpdate:case t:break;case e.done:throw e.err}}return this.sendWindowSize-this.sendWindowUsed()}async _flushSendBuffer(){if(!this.sendBuffer||0===this.sendBuffer.length)return;let e=this.sendWindowEndSeq,t=new a.Packet;t.setSequenceId(e),t.setData(this.sendBuffer);let r=t.serializeBinary();switch(this.sendWindowData.set(e,r),this.sendWindowEndSeq=g.nextSeq(e,1),this.sendBuffer=new Uint8Array(0),await n.default.select([this.sendChan.push(e),this.context.done.shift()])){case this.sendChan:break;case this.context.done:throw this.context.err}}async _sendHandshakePacket(e){let t=new a.Packet;t.setHandshake(!0),t.setClientIdsList(this.localClientIDs),t.setWindowSize(this.recvWindowSize),t.setMtu(this.recvMtu);let r=t.serializeBinary(),n=[];if(this.connections&&this.connections.size>0)for(let t of this.connections.values())n.push(g.promiseTimeout(this.sendWith(t.localClientID,t.remoteClientID,r),e,new c.WriteDeadlineExceededError));else n=this.localClientIDs.map((t,n)=>{let i=t;return this.remoteClientIDs&&this.remoteClientIDs.length>0&&(i=this.remoteClientIDs[n%this.remoteClientIDs.length]),g.promiseTimeout(this.sendWith(t,i,r),e,new c.WriteDeadlineExceededError)});try{await i.default.any(n)}catch(e){throw e.errors}}_handleHandshakePacket(e){if(this.isEstablished)return;if(0===e.getWindowSize())throw new c.InvalidPacketError("WindowSize is zero");if(e.getWindowSize()0&&(t=g.timeoutChan(e),r.push(t.shift())),await n.default.select(r)){case this.onAccept:break;case t:throw new c.DialTimeoutError}this._start(),this.isAccepted=!0}async accept(){if(this.isAccepted)throw new c.SessionEstablishedError;switch(await n.default.select([this.onAccept.shift(),g.closedChan.shift()])){case this.onAccept:break;default:throw new c.NotHandshakeError}this._start(),this.isAccepted=!0,await this._sendHandshakePacket(this.config.maxRetransmissionTimeout)}async read(e=0){try{if(this.isClosed)throw new c.SessionClosedError;if(!this.isEstablished)throw new c.SessionNotEstablishedError;for(;;){if(this.readContext.err)throw this.readContext.err;if(this.recvWindowData.has(this.recvWindowStartSeq))break;let e=g.timeoutChan(g._maxWait);switch(await n.default.select([this.recvDataUpdate.shift(),e.shift(),this.readContext.done.shift()])){case this.recvDataUpdate:case e:break;case this.readContext.done:throw this.readContext.err}}let t=this.recvWindowData.get(this.recvWindowStartSeq);if(!this.isStream()&&e>0&&e0){r=new Uint8Array(e);let n=t.subarray(0,e);r.set(n),i=n.length}if(i===t.length?(this.recvWindowData.delete(this.recvWindowStartSeq),this.recvWindowStartSeq=g.nextSeq(this.recvWindowStartSeq,1)):this.recvWindowData.set(this.recvWindowStartSeq,t.subarray(i)),this.recvWindowUsed-=i,this.bytesRead+=i,this.bytesReadUpdateTime=Date.now(),this.isStream())for(;(e<0||i0){let o=t.subarray(0,e-i);r.set(o,i),n=o.length}else r=g.mergeUint8Array(r,t),n=t.length;n===t.length?(this.recvWindowData.delete(this.recvWindowStartSeq),this.recvWindowStartSeq=g.nextSeq(this.recvWindowStartSeq,1)):this.recvWindowData.set(this.recvWindowStartSeq,t.subarray(n)),this.recvWindowUsed-=n,this.bytesRead+=n,this.bytesReadUpdateTime=Date.now(),i+=n}return r.subarray(0,i)}catch(e){if(e instanceof s.ContextDeadlineExceededError)throw new c.ReadDeadlineExceededError;if(e instanceof s.ContextCanceledError)throw new c.SessionClosedError;throw e}}async write(e){try{if(this.isClosed)throw new c.SessionClosedError;if(!this.isEstablished)throw new c.SessionNotEstablishedError;if(!this.isStream()&&(e.length>this.sendMtu||e>this.sendWindowSize))throw new c.DataSizeTooLargeError;if(0===e.length)return;let t=0;if(this.isStream())for(;e.length>0;){let r=await this._waitForSendWindow(this.writeContext,1),n=e.length;n>r&&(n=r);let i=r===this.sendWindowSize,o=this.sendMtu,s=this.sendBuffer.length;n>=o-s&&(n=o-s,i=!0),this.sendBuffer=g.mergeUint8Array(this.sendBuffer,e.subarray(0,n)),this.bytesWrite+=n,t+=n,i&&await this._flushSendBuffer(),e=e.subarray(n)}else await this._waitForSendWindow(this.writeContext,e.length),this.sendBuffer=new Uint8Array(e),this.bytesWrite+=e.length,t+=e.length,await this._flushSendBuffer()}catch(e){if(e instanceof s.ContextDeadlineExceededError)throw new c.WriteDeadlineExceededError;if(e instanceof s.ContextCanceledError)throw new c.SessionClosedError;throw e}}async close(){this.readContext.cancel(),this.writeContext.cancel();let e=new n.default;if(this.config.linger>0&&setTimeout(e.close,this.config.linger),0!==this.config.linger){try{await this._flushSendBuffer()}catch(e){console.log(e)}await(async()=>{for(;;){let t=g.timeoutChan(100);switch(await n.default.select([t.shift(),e.shift()])){case t:if(this.sendWindowStartSeq===this.sendWindowEndSeq)return;break;case e:return}}})()}try{await this._sendClosePacket()}catch(e){console.log(e)}this.context.cancel(),this.isClosed=!0}setTimeout(e){this.setReadTimeout(e),this.setWriteTimeout(e)}setReadTimeout(e){this.readContext=s.default.withTimeout(this.context,e)}setWriteTimeout(e){this.writeContext=s.default.withTimeout(this.context,e)}setLinger(e){this.config.linger=e}getReadableStream(){if(!this._readableStream){let e=this.ReadableStream||ReadableStream;this._readableStream=new e({start:e=>{this.context.done.shift().then(()=>e.close())},pull:e=>this.isClosed?e.close():this.read().then(t=>e.enqueue(t))})}return this._readableStream}getWritableStream(e=!1){if(!this._writableStream){let t=this.WritableStream||WritableStream,r={write:(e,t)=>this.isClosed?t.error(new c.SessionClosedError):this.write(e)};e&&(r.close=(e=>this.close()),r.abort=(e=>(console.log("Abort stream:",e),this.setLinger(0),this.close()))),this._writableStream=new t(r)}return this._writableStream}}},{"./channel":33,"./connection":34,"./consts":35,"./context":36,"./errors":37,"./pb/packet_pb":39,"./util":41,"core-js-pure/features/promise":122}],41:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.closedChan=r._maxWait=r._errMaxWait=void 0,r.compareSeq=function(e,t){if(e===t)return 0;if(e{let o;t>0&&(o=setTimeout(()=>i(r),t)),e.then(()=>{clearTimeout(o),n()}).catch(i)})},r.seqInBetween=function(e,t,r){if(e<=t)return r>=e&&r=e||rsetTimeout(t,e))},r.timeoutChan=function(e){let t=new i.default;return setTimeout(t.close,e),t};var n,i=(n=e("./channel"))&&n.__esModule?n:{default:n},o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,r&&r.set(e,n);return n}(e("./consts"));function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}const a=4294967295;r.maxUint32=a;r._maxWait=1e3;const A=new Error("max wait time reached");r._errMaxWait=A;const c=new i.default;r.closedChan=c,c.close()},{"./channel":33,"./consts":35}],42:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":43,"./asn1/base":45,"./asn1/constants":49,"./asn1/decoders":51,"./asn1/encoders":54,"bn.js":87}],43:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":42,inherits:306,vm:385}],44:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function s(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function a(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof a||(e=new a(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(s,i),r.DecoderBuffer=s,s.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},s.prototype.restore=function(e){var t=new s(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},s.prototype.isEmpty=function(){return this.offset===this.length},s.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},s.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new s(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},s.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=a,a.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":45,buffer:119,inherits:306}],45:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":44,"./node":46,"./reporter":47}],46:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,s=e("minimalistic-assert"),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],A=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var g=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};g.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;A.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;s(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),s.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(s(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(s(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),a.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){s(e);var t=this._baseState;return s(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return s(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return s(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return s(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return s(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,s=!0,a=null;if(null!==r.key&&(a=e.enterKey(r.key)),r.optional){var A=null;if(null!==r.explicit?A=r.explicit:null!==r.implicit?A=r.implicit:null!==r.tag&&(A=r.tag),null!==A||r.any){if(s=this._peekTag(e,A,r.any),e.isError(s))return s}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(c)}}if(r.obj&&s&&(n=e.enterObject()),s){if(null!==r.explicit){var g=this._decodeTag(e,r.explicit);if(e.isError(g))return g;e=g}var f=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var u=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(u))return u;r.any?i=e.raw(c):e=u}if(t&&t.track&&null!==r.tag&&t.track(e.path(),f,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var l=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(l,t)}}return r.obj&&s&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var s=e.save(),a=r.choice[o];try{var A=a._decode(e,t);if(e.isError(A))return!1;n={type:o,value:A},i=!0}catch(t){return e.restore(s),!1}return!0},this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var s=null,a=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)s=this._getUse(i.contains,r)._encode(e,t),a=!0;else if(i.children)s=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),s=this._createEncoderBuffer(s);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var A=this.clone();A._baseState.implicit=null,s=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},A))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(s=this._encodePrimitive(i.tag,e),a=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,g=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,a,g,s))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||s(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":45,"minimalistic-assert":315}],47:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:306}],48:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":49}],49:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":48}],50:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,s=i.bignum,a=i.constants.der;function A(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function g(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=a.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function f(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=a.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=s,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var A=1,c=n.length;c>=256;c>>=8)A++;(o=new i(2+A))[0]=s,o[1]=128|A;c=1+A;for(var g=n.length;g>0;c--,g>>=8)o[c]=255&g;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n=128;s>>=7)o++}var a=new i(o),A=a.length-1;for(n=e.length-1;n>=0;n--){s=e[n];for(a[A--]=127&s;(s>>=7)>0;)a[A--]=128|127&s}return this._createEncoderBuffer(a)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[g(n.getFullYear()),g(n.getUTCMonth()+1),g(n.getUTCDate()),g(n.getUTCHours()),g(n.getUTCMinutes()),g(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[g(n.getFullYear()%100),g(n.getUTCMonth()+1),g(n.getUTCDate()),g(n.getUTCHours()),g(n.getUTCMinutes()),g(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var s=e;s>=256;s>>=8)n++;for(s=(o=new Array(n)).length-1;s>=0;s--)o[s]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],function(e){c.headers[e]={}}),n.forEach(["post","put","patch"],function(e){c.headers[e]=n.merge(s)}),t.exports=c}).call(this,e("_process"))},{"./adapters/http":57,"./adapters/xhr":57,"./core/enhanceError":67,"./helpers/normalizeHeaderName":79,"./utils":83,_process:344}],72:[function(e,t,r){"use strict";t.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}}),s):s}},{"./../utils":83}],81:[function(e,t,r){"use strict";t.exports=function(e){return function(t){return e.apply(null,t)}}},{}],82:[function(e,t,r){"use strict";var n=e("./../../package.json"),i={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){i[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});var o={},s=n.version.split(".");function a(e,t){for(var r=t?t.split("."):s,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]0;){var o=n[i],s=t[o];if(s){var a=e[o],A=void 0===a||s(a,o,e);if(!0!==A)throw new TypeError("option "+o+" must be "+A)}else if(!0!==r)throw Error("Unknown option "+o)}},validators:i}},{"./../../package.json":84}],83:[function(e,t,r){"use strict";var n=e("./helpers/bind"),i=Object.prototype.toString;function o(e){return"[object Array]"===i.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function A(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===i.call(e)}function g(e,t){if(null!==e&&void 0!==e)if("object"!=typeof e&&(e=[e]),o(e))for(var r=0,n=e.length;r=255)throw new TypeError("Alphabet too long");var t=new Uint8Array(256);t.fill(255);for(var r=0;r>>0,g=new Uint8Array(c);e[r];){var f=t[e.charCodeAt(r)];if(255===f)return;for(var u=0,l=c-1;(0!==f||u>>0,g[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=u,r++}if(" "!==e[r]){for(var h=c-o;h!==c&&0===g[h];)h++;var d=n.allocUnsafe(i+(c-h));d.fill(0,0,i);for(var p=i;h!==c;)d[p++]=g[h++];return d}}}return{encode:function(t){if(!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,A=t.length;o!==A&&0===t[o];)o++,r++;for(var g=(A-o)*c+1>>>0,f=new Uint8Array(g);o!==A;){for(var u=t[o],l=0,h=g-1;(0!==u||l>>0,f[h]=u%s>>>0,u=u/s>>>0;if(0!==u)throw new Error("Non-zero carry");i=l,o++}for(var d=g-i;d!==g&&0===f[d];)d++;for(var p=a.repeat(r);d0?s-4:s;for(r=0;r>16&255,A[g++]=t>>8&255,A[g++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,A[g++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,A[g++]=t>>8&255,A[g++]=255&t);return A},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,A=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function g(e,t,r){for(var i,o,s=[],a=t;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],87:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:e("buffer").Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function A(e,t,r){var n=a(e,r);return r-1>=t&&(n|=a(e,r-1)<<4),n}function c(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=A(e,t,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,A=0,g=r;g1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var g=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,A=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,f=67108863&A,u=Math.min(c,t.length-1),l=Math.max(0,c-e.length+1);l<=u;l++){var h=c-l|0;g+=(s=(i=0|e.words[h])*(o=0|t.words[l])+f)/67108864|0,f=67108863&s}r.words[c]=0|f,A=0|g}return 0!==A?r.words[c]=0|A:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?g[6-A.length]+A+r:A+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=f[e],l=u[e];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var d=h.modn(l).toString(e);r=(h=h.idivn(l)).isZero()?d+r:g[c-d.length]+d+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,A="le"===t,c=new e(o),g=this.clone();if(A){for(a=0;!g.isZero();a++)s=g.andln(255),g.iushrn(8),c[a]=s;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,l=0|s[1],h=8191&l,d=l>>>13,p=0|s[2],y=8191&p,I=p>>>13,b=0|s[3],_=8191&b,B=b>>>13,E=0|s[4],C=8191&E,m=E>>>13,w=0|s[5],v=8191&w,Q=w>>>13,S=0|s[6],D=8191&S,k=S>>>13,M=0|s[7],T=8191&M,F=M>>>13,R=0|s[8],x=8191&R,P=R>>>13,N=0|s[9],U=8191&N,H=N>>>13,j=0|a[0],L=8191&j,O=j>>>13,G=0|a[1],Y=8191&G,W=G>>>13,K=0|a[2],z=8191&K,J=K>>>13,V=0|a[3],q=8191&V,X=V>>>13,Z=0|a[4],$=8191&Z,ee=Z>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],Ae=8191&ae,ce=ae>>>13,ge=0|a[8],fe=8191&ge,ue=ge>>>13,le=0|a[9],he=8191&le,de=le>>>13;r.negative=e.negative^t.negative,r.length=19;var pe=(c+(n=Math.imul(f,L))|0)+((8191&(i=(i=Math.imul(f,O))+Math.imul(u,L)|0))<<13)|0;c=((o=Math.imul(u,O))+(i>>>13)|0)+(pe>>>26)|0,pe&=67108863,n=Math.imul(h,L),i=(i=Math.imul(h,O))+Math.imul(d,L)|0,o=Math.imul(d,O);var ye=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,W)|0)+Math.imul(u,Y)|0))<<13)|0;c=((o=o+Math.imul(u,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,L),i=(i=Math.imul(y,O))+Math.imul(I,L)|0,o=Math.imul(I,O),n=n+Math.imul(h,Y)|0,i=(i=i+Math.imul(h,W)|0)+Math.imul(d,Y)|0,o=o+Math.imul(d,W)|0;var Ie=(c+(n=n+Math.imul(f,z)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(u,z)|0))<<13)|0;c=((o=o+Math.imul(u,J)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(_,L),i=(i=Math.imul(_,O))+Math.imul(B,L)|0,o=Math.imul(B,O),n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(h,z)|0,i=(i=i+Math.imul(h,J)|0)+Math.imul(d,z)|0,o=o+Math.imul(d,J)|0;var be=(c+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(u,q)|0))<<13)|0;c=((o=o+Math.imul(u,X)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(C,L),i=(i=Math.imul(C,O))+Math.imul(m,L)|0,o=Math.imul(m,O),n=n+Math.imul(_,Y)|0,i=(i=i+Math.imul(_,W)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(y,z)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(I,z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(h,q)|0,i=(i=i+Math.imul(h,X)|0)+Math.imul(d,q)|0,o=o+Math.imul(d,X)|0;var _e=(c+(n=n+Math.imul(f,$)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(u,$)|0))<<13)|0;c=((o=o+Math.imul(u,ee)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(v,L),i=(i=Math.imul(v,O))+Math.imul(Q,L)|0,o=Math.imul(Q,O),n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,W)|0,n=n+Math.imul(_,z)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(B,z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(I,q)|0,o=o+Math.imul(I,X)|0,n=n+Math.imul(h,$)|0,i=(i=i+Math.imul(h,ee)|0)+Math.imul(d,$)|0,o=o+Math.imul(d,ee)|0;var Be=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(u,re)|0))<<13)|0;c=((o=o+Math.imul(u,ne)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,L),i=(i=Math.imul(D,O))+Math.imul(k,L)|0,o=Math.imul(k,O),n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(Q,Y)|0,o=o+Math.imul(Q,W)|0,n=n+Math.imul(C,z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(m,z)|0,o=o+Math.imul(m,J)|0,n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,X)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,X)|0,n=n+Math.imul(y,$)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(h,re)|0,i=(i=i+Math.imul(h,ne)|0)+Math.imul(d,re)|0,o=o+Math.imul(d,ne)|0;var Ee=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,se)|0)+Math.imul(u,oe)|0))<<13)|0;c=((o=o+Math.imul(u,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(T,L),i=(i=Math.imul(T,O))+Math.imul(F,L)|0,o=Math.imul(F,O),n=n+Math.imul(D,Y)|0,i=(i=i+Math.imul(D,W)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(v,z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(Q,z)|0,o=o+Math.imul(Q,J)|0,n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,X)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,X)|0,n=n+Math.imul(_,$)|0,i=(i=i+Math.imul(_,ee)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(h,oe)|0,i=(i=i+Math.imul(h,se)|0)+Math.imul(d,oe)|0,o=o+Math.imul(d,se)|0;var Ce=(c+(n=n+Math.imul(f,Ae)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(u,Ae)|0))<<13)|0;c=((o=o+Math.imul(u,ce)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(x,L),i=(i=Math.imul(x,O))+Math.imul(P,L)|0,o=Math.imul(P,O),n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(D,z)|0,i=(i=i+Math.imul(D,J)|0)+Math.imul(k,z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,X)|0)+Math.imul(Q,q)|0,o=o+Math.imul(Q,X)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,ee)|0,n=n+Math.imul(_,re)|0,i=(i=i+Math.imul(_,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(h,Ae)|0,i=(i=i+Math.imul(h,ce)|0)+Math.imul(d,Ae)|0,o=o+Math.imul(d,ce)|0;var me=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ue)|0)+Math.imul(u,fe)|0))<<13)|0;c=((o=o+Math.imul(u,ue)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(U,L),i=(i=Math.imul(U,O))+Math.imul(H,L)|0,o=Math.imul(H,O),n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(T,z)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(F,z)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(D,q)|0,i=(i=i+Math.imul(D,X)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(Q,$)|0,o=o+Math.imul(Q,ee)|0,n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0,n=n+Math.imul(_,oe)|0,i=(i=i+Math.imul(_,se)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,se)|0,n=n+Math.imul(y,Ae)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(I,Ae)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(h,fe)|0,i=(i=i+Math.imul(h,ue)|0)+Math.imul(d,fe)|0,o=o+Math.imul(d,ue)|0;var we=(c+(n=n+Math.imul(f,he)|0)|0)+((8191&(i=(i=i+Math.imul(f,de)|0)+Math.imul(u,he)|0))<<13)|0;c=((o=o+Math.imul(u,de)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(U,Y),i=(i=Math.imul(U,W))+Math.imul(H,Y)|0,o=Math.imul(H,W),n=n+Math.imul(x,z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(P,z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,X)|0,n=n+Math.imul(D,$)|0,i=(i=i+Math.imul(D,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(Q,re)|0,o=o+Math.imul(Q,ne)|0,n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0,n=n+Math.imul(_,Ae)|0,i=(i=i+Math.imul(_,ce)|0)+Math.imul(B,Ae)|0,o=o+Math.imul(B,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,ue)|0)+Math.imul(I,fe)|0,o=o+Math.imul(I,ue)|0;var ve=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,de)|0)+Math.imul(d,he)|0))<<13)|0;c=((o=o+Math.imul(d,de)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(U,z),i=(i=Math.imul(U,J))+Math.imul(H,z)|0,o=Math.imul(H,J),n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(F,$)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(D,re)|0,i=(i=i+Math.imul(D,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(Q,oe)|0,o=o+Math.imul(Q,se)|0,n=n+Math.imul(C,Ae)|0,i=(i=i+Math.imul(C,ce)|0)+Math.imul(m,Ae)|0,o=o+Math.imul(m,ce)|0,n=n+Math.imul(_,fe)|0,i=(i=i+Math.imul(_,ue)|0)+Math.imul(B,fe)|0,o=o+Math.imul(B,ue)|0;var Qe=(c+(n=n+Math.imul(y,he)|0)|0)+((8191&(i=(i=i+Math.imul(y,de)|0)+Math.imul(I,he)|0))<<13)|0;c=((o=o+Math.imul(I,de)|0)+(i>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,n=Math.imul(U,q),i=(i=Math.imul(U,X))+Math.imul(H,q)|0,o=Math.imul(H,X),n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(D,oe)|0,i=(i=i+Math.imul(D,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(v,Ae)|0,i=(i=i+Math.imul(v,ce)|0)+Math.imul(Q,Ae)|0,o=o+Math.imul(Q,ce)|0,n=n+Math.imul(C,fe)|0,i=(i=i+Math.imul(C,ue)|0)+Math.imul(m,fe)|0,o=o+Math.imul(m,ue)|0;var Se=(c+(n=n+Math.imul(_,he)|0)|0)+((8191&(i=(i=i+Math.imul(_,de)|0)+Math.imul(B,he)|0))<<13)|0;c=((o=o+Math.imul(B,de)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(U,$),i=(i=Math.imul(U,ee))+Math.imul(H,$)|0,o=Math.imul(H,ee),n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,se)|0,n=n+Math.imul(D,Ae)|0,i=(i=i+Math.imul(D,ce)|0)+Math.imul(k,Ae)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(v,fe)|0,i=(i=i+Math.imul(v,ue)|0)+Math.imul(Q,fe)|0,o=o+Math.imul(Q,ue)|0;var De=(c+(n=n+Math.imul(C,he)|0)|0)+((8191&(i=(i=i+Math.imul(C,de)|0)+Math.imul(m,he)|0))<<13)|0;c=((o=o+Math.imul(m,de)|0)+(i>>>13)|0)+(De>>>26)|0,De&=67108863,n=Math.imul(U,re),i=(i=Math.imul(U,ne))+Math.imul(H,re)|0,o=Math.imul(H,ne),n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,se)|0,n=n+Math.imul(T,Ae)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(F,Ae)|0,o=o+Math.imul(F,ce)|0,n=n+Math.imul(D,fe)|0,i=(i=i+Math.imul(D,ue)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,ue)|0;var ke=(c+(n=n+Math.imul(v,he)|0)|0)+((8191&(i=(i=i+Math.imul(v,de)|0)+Math.imul(Q,he)|0))<<13)|0;c=((o=o+Math.imul(Q,de)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(U,oe),i=(i=Math.imul(U,se))+Math.imul(H,oe)|0,o=Math.imul(H,se),n=n+Math.imul(x,Ae)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(P,Ae)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,ue)|0)+Math.imul(F,fe)|0,o=o+Math.imul(F,ue)|0;var Me=(c+(n=n+Math.imul(D,he)|0)|0)+((8191&(i=(i=i+Math.imul(D,de)|0)+Math.imul(k,he)|0))<<13)|0;c=((o=o+Math.imul(k,de)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(U,Ae),i=(i=Math.imul(U,ce))+Math.imul(H,Ae)|0,o=Math.imul(H,ce),n=n+Math.imul(x,fe)|0,i=(i=i+Math.imul(x,ue)|0)+Math.imul(P,fe)|0,o=o+Math.imul(P,ue)|0;var Te=(c+(n=n+Math.imul(T,he)|0)|0)+((8191&(i=(i=i+Math.imul(T,de)|0)+Math.imul(F,he)|0))<<13)|0;c=((o=o+Math.imul(F,de)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(U,fe),i=(i=Math.imul(U,ue))+Math.imul(H,fe)|0,o=Math.imul(H,ue);var Fe=(c+(n=n+Math.imul(x,he)|0)|0)+((8191&(i=(i=i+Math.imul(x,de)|0)+Math.imul(P,he)|0))<<13)|0;c=((o=o+Math.imul(P,de)|0)+(i>>>13)|0)+(Fe>>>26)|0,Fe&=67108863;var Re=(c+(n=Math.imul(U,he))|0)+((8191&(i=(i=Math.imul(U,de))+Math.imul(H,he)|0))<<13)|0;return c=((o=Math.imul(H,de))+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,A[0]=pe,A[1]=ye,A[2]=Ie,A[3]=be,A[4]=_e,A[5]=Be,A[6]=Ee,A[7]=Ce,A[8]=me,A[9]=we,A[10]=ve,A[11]=Qe,A[12]=Se,A[13]=De,A[14]=ke,A[15]=Me,A[16]=Te,A[17]=Fe,A[18]=Re,0!==c&&(A[19]=c,r.length++),r};function d(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(h=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?h(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):d(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==g||c>=i);c--){var f=0|this.words[c];this.words[c]=g<<26-o|f>>>o,g=f&a}return A&&0!==g&&(A.words[A.length++]=g),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(A/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,A=n.length-i.length;if("mod"!==t){(a=new o(null)).length=A+1,a.words=new Array(a.length);for(var c=0;c=0;f--){var u=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(u=Math.min(u/s|0,67108863),n._ishlnsubmul(i,u,f);0!==n.negative;)u--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=u)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),A=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var g=r.clone(),f=t.clone();!t.isZero();){for(var u=0,l=1;0==(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(g),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)(a.isOdd()||A.isOdd())&&(a.iadd(g),A.isub(f)),a.iushrn(1),A.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(A)):(r.isub(t),a.isub(i),A.isub(s))}return{a:a,b:A,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),A=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,g=1;0==(t.words[0]&g)&&c<26;++c,g<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(A),s.iushrn(1);for(var f=0,u=1;0==(r.words[0]&u)&&f<26;++f,u<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(A),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new C(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function I(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){I.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){I.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function B(){I.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){I.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function C(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function m(e){C.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}I.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},I.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},I.prototype.split=function(e,t){e.iushrn(this.n,0,t)},I.prototype.imulK=function(e){return e.imul(this.k)},i(b,I),b.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},b.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new b;else if("p224"===e)t=new _;else if("p192"===e)t=new B;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return y[e]=t,t},C.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},C.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},C.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},C.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},C.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},C.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},C.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},C.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},C.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},C.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},C.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},C.prototype.isqr=function(e){return this.imul(e,e.clone())},C.prototype.sqr=function(e){return this.mul(e,e)},C.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),A=a.redNeg(),c=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new o(2*g*g).toRed(this);0!==this.pow(g,c).cmp(A);)g.redIAdd(A);for(var f=this.pow(g,i),u=this.pow(e,i.addn(1).iushrn(1)),l=this.pow(e,i),h=s;0!==l.cmp(a);){for(var d=l,p=0;0!==d.cmp(a);p++)d=d.redSqr();n(p=0;n--){for(var c=t.words[n],g=A-1;g>=0;g--){var f=c>>g&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===g)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}A=26}return i},C.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},C.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new m(e)},i(m,C),m.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},m.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},m.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},m.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},m.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:89}],88:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^g[h>>>16&255]^f[d>>>8&255]^u[255&p]^t[y++],s=c[h>>>24]^g[d>>>16&255]^f[p>>>8&255]^u[255&l]^t[y++],a=c[d>>>24]^g[p>>>16&255]^f[l>>>8&255]^u[255&h]^t[y++],A=c[p>>>24]^g[l>>>16&255]^f[h>>>8&255]^u[255&d]^t[y++],l=o,h=s,d=a,p=A;return o=(n[l>>>24]<<24|n[h>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[y++],s=(n[h>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&l])^t[y++],a=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[l>>>8&255]<<8|n[255&h])^t[y++],A=(n[p>>>24]<<24|n[l>>>16&255]<<16|n[h>>>8&255]<<8|n[255&d])^t[y++],[o>>>=0,s>>>=0,a>>>=0,A>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],A=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,A=0;A<256;++A){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var g=e[s],f=e[g],u=e[f],l=257*e[c]^16843008*c;i[0][s]=l<<24|l>>>8,i[1][s]=l<<16|l>>>16,i[2][s]=l<<8|l>>>24,i[3][s]=l,l=16843009*u^65537*f^257*g^16843008*s,o[0][c]=l<<24|l>>>8,o[1][c]=l<<16|l>>>16,o[2][c]=l<<8|l>>>24,o[3][c]=l,0===s?s=a=1:(s=g^e[e[e[u^g]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,s=A.SBOX[s>>>24]<<24|A.SBOX[s>>>16&255]<<16|A.SBOX[s>>>8&255]<<8|A.SBOX[255&s],s^=a[o/t|0]<<24):t>6&&o%t==4&&(s=A.SBOX[s>>>24]<<24|A.SBOX[s>>>16&255]<<16|A.SBOX[s>>>8&255]<<8|A.SBOX[255&s]),i[o]=i[o-t]^s}for(var c=[],g=0;g>>24]]^A.INV_SUB_MIX[1][A.SBOX[u>>>16&255]]^A.INV_SUB_MIX[2][A.SBOX[u>>>8&255]]^A.INV_SUB_MIX[3][A.SBOX[255&u]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return s(e=i(e),this._keySchedule,A.SUB_MIX,A.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=s(e,this._invKeySchedule,A.INV_SUB_MIX,A.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},{"safe-buffer":370}],91:[function(e,t,r){var n=e("./aes"),i=e("safe-buffer").Buffer,o=e("cipher-base"),s=e("inherits"),a=e("./ghash"),A=e("buffer-xor"),c=e("./incr32");function g(e,t,r,s){o.call(this);var A=i.alloc(4,0);this._cipher=new n.AES(t);var g=this._cipher.encryptBlock(A);this._ghash=new a(g),r=function(e,t,r){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var n=new a(r),o=t.length,s=o%16;n.update(t),s&&(s=16-s,n.update(i.alloc(s,0))),n.update(i.alloc(8,0));var A=8*o,g=i.alloc(8);g.writeUIntBE(A,0,8),n.update(g),e._finID=n.state;var f=i.from(e._finID);return c(f),f}(this,r,g),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=s,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}s(g,o),g.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},g.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=A(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return u(e,n.key,n.iv)},r.createDecipheriv=u},{"./aes":90,"./authCipher":91,"./modes":103,"./streamCipher":106,"cipher-base":120,evp_bytestokey:287,inherits:306,"safe-buffer":370}],94:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),o=e("safe-buffer").Buffer,s=e("./streamCipher"),a=e("cipher-base"),A=e("./aes"),c=e("evp_bytestokey");function g(e,t,r){a.call(this),this._cache=new u,this._cipher=new A.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}e("inherits")(g,a),g.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var f=o.alloc(16,16);function u(){this.cache=o.allocUnsafe(0)}function l(e,t,r){var a=n[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===a.type?new s(a.module,t,r):"auth"===a.type?new i(a.module,t,r):new g(a.module,t,r)}g.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},g.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},u.prototype.add=function(e){this.cache=o.concat([this.cache,e])},u.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},u.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function s(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}s.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},s.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},s.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=s},{"safe-buffer":370}],96:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],97:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":118}],98:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("buffer-xor");function o(e,t,r){var o=t.length,s=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=n.concat([e._prev,r?t:s]),s}r.encrypt=function(e,t,r){for(var i,s=n.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=n.allocUnsafe(0)),!(e._cache.length<=t.length)){s=n.concat([s,o(e,t,r)]);break}i=e._cache.length,s=n.concat([s,o(e,t.slice(0,i),r)]),t=t.slice(i)}return s}},{"buffer-xor":118,"safe-buffer":370}],99:[function(e,t,r){var n=e("safe-buffer").Buffer;function i(e,t,r){for(var n,i,s,a=-1,A=0;++a<8;)n=e._cipher.encryptBlock(e._prev),i=t&1<<7-a?128:0,A+=(128&(s=n[0]^i))>>a%8,e._prev=o(e._prev,r?i:s);return A}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}r.encrypt=function(e,t,r){for(var o=t.length,s=n.allocUnsafe(o),a=-1;++a=0||!r.umod(e.prime1)||!r.umod(e.prime2);)r=new n(i(t));return r}t.exports=o,o.getr=s}).call(this,e("buffer").Buffer)},{"bn.js":87,buffer:119,randombytes:351}],111:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":112}],112:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],113:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],114:[function(e,t,r){(function(r){var n=e("create-hash"),i=e("stream"),o=e("inherits"),s=e("./sign"),a=e("./verify"),A=e("./algorithms.json");function c(e){i.Writable.call(this);var t=A[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function g(e){i.Writable.call(this);var t=A[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){return new c(e)}function u(e){return new g(e)}Object.keys(A).forEach(function(e){A[e].id=new r(A[e].id,"hex"),A[e.toLowerCase()]=A[e]}),o(c,i.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=s(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},o(g,i.Writable),g.prototype._write=function(e,t,r){this._hash.update(e),r()},g.prototype.update=function(e,t){return"string"==typeof e&&(e=new r(e,t)),this._hash.update(e),this},g.prototype.verify=function(e,t,n){"string"==typeof t&&(t=new r(t,n)),this.end();var i=this._hash.digest();return a(t,i,e,this._signType,this._tag)},t.exports={Sign:f,Verify:u,createSign:f,createVerify:u}}).call(this,e("buffer").Buffer)},{"./algorithms.json":112,"./sign":115,"./verify":116,buffer:119,"create-hash":219,inherits:306,stream:381}],115:[function(e,t,r){(function(r){var n=e("create-hmac"),i=e("browserify-rsa"),o=e("elliptic").ec,s=e("bn.js"),a=e("parse-asn1"),A=e("./curves.json");function c(e,t,i,o){if((e=new r(e.toArray())).length0&&r.ishrn(n),r}function f(e,t,i){var o,s;do{for(o=new r(0);8*o.length=t)throw new Error("invalid sig")}t.exports=function(e,t,A,c,g){var f=o(A);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(t,e,a)}(e,t,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,s=r.data.q,A=r.data.g,c=r.data.pub_key,g=o.signature.decode(e,"der"),f=g.s,u=g.r;a(f,s),a(u,s);var l=n.mont(i),h=f.invm(s);return 0===A.toRed(l).redPow(new n(t).mul(h).mod(s)).fromRed().mul(c.toRed(l).redPow(u.mul(h).mod(s)).fromRed()).mod(i).mod(s).cmp(u)}(e,t,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=r.concat([g,t]);for(var u=f.modulus.byteLength(),l=[1],h=0;t.length+l.length+2>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function A(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function g(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function u(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":370}],118:[function(e,t,r){(function(e){t.exports=function(t,r){for(var n=Math.min(t.length,r.length),i=new e(n),o=0;os)throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=new Uint8Array(e);return Object.setPrototypeOf(r,t.prototype),r}function t(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return g(e)}return A(e,t,r)}function A(e,r,n){if("string"==typeof e)return function(e,r){"string"==typeof r&&""!==r||(r="utf8");if(!t.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|l(e,r),i=a(n),o=i.write(e,r);o!==n&&(i=i.slice(0,o));return i}(e,r);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return function(e,r,n){if(r<0||e.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function l(e,r){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var o=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(o)return i?-1:P(e).length;r=(""+r).toLowerCase(),o=!0}}function h(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function d(e,r,n,i,o){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),j(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=t.from(r,i)),t.isBuffer(r))return 0===r.length?-1:p(e,r,n,i,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):p(e,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function p(e,t,r,n,i){var o,s=1,a=e.length,A=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,A/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var g=-1;for(o=r;oa&&(r=a-A),o=r;o>=0;o--){for(var f=!0,u=0;ui&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function C(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function m(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(g=c);break;case 2:128==(192&(o=e[i+1]))&&(A=(31&c)<<6|63&o)>127&&(g=A);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(A=(15&c)<<12|(63&o)<<6|63&s)>2047&&(A<55296||A>57343)&&(g=A);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(A=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&A<1114112&&(g=A)}null===g?(g=65533,f=1):g>65535&&(g-=65536,n.push(g>>>10&1023|55296),g=56320|1023&g),n.push(g),i+=f}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return S(this,t,r);case"utf8":case"utf-8":return m(this,t,r);case"ascii":return v(this,t,r);case"latin1":case"binary":return Q(this,t,r);case"base64":return C(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===t.compare(this,e)},t.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},o&&(t.prototype[o]=t.prototype.inspect),t.prototype.compare=function(e,r,n,i,o){if(H(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===r&&(r=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var s=o-i,a=n-r,A=Math.min(s,a),c=this.slice(i,o),g=e.slice(r,n),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return I(this,e,t,r);case"ascii":return b(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return B(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function v(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function M(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||re.length)throw new RangeError("Index out of range")}function T(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(e,t,r,n,o){return t=+t,r>>>=0,o||T(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function R(e,t,r,n,o){return t=+t,r>>>=0,o||T(e,0,r,8),i.write(e,t,r,n,52,8),r+8}t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,t>>>=0,r||k(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||k(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},t.prototype.readUInt8=function(e,t){return e>>>=0,t||k(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||k(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||k(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||k(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||k(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||k(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},t.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||k(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},t.prototype.readInt8=function(e,t){return e>>>=0,t||k(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||k(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(e,t){e>>>=0,t||k(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||k(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||k(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||k(e,4,this.length),i.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||k(e,4,this.length),i.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||k(e,8,this.length),i.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||k(e,8,this.length),i.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},t.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},t.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);M(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},t.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,r){return F(this,e,t,!0,r)},t.prototype.writeFloatBE=function(e,t,r){return F(this,e,t,!1,r)},t.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},t.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},t.prototype.copy=function(e,r,n,i){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r=0;--s)e[s+r]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,i),r);return o},t.prototype.fill=function(e,r,n,i){if("string"==typeof e){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var o=e.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(e=o)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=r;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(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=65536+(i-55296<<10|r-56320)}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)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function N(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(x,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function U(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function H(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function j(e){return e!=e}var L=function(){for(var e=new Array(256),t=0;t<16;++t)for(var r=16*t,n=0;n<16;++n)e[r+n]="0123456789abcdef"[t]+"0123456789abcdef"[n];return e}()}).call(this,e("buffer").Buffer)},{"base64-js":86,buffer:119,ieee754:305}],120:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function s(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(s,i),s.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},s.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},s.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},s.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=s},{inherits:306,"safe-buffer":370,stream:381,string_decoder:117}],121:[function(e,t,r){e("../../modules/es.object.to-string"),e("../../modules/es.string.iterator"),e("../../modules/web.dom-collections.iterator"),e("../../modules/es.promise"),e("../../modules/es.promise.all-settled"),e("../../modules/es.promise.finally");var n=e("../../internals/path");t.exports=n.Promise},{"../../internals/path":181,"../../modules/es.object.to-string":207,"../../modules/es.promise":210,"../../modules/es.promise.all-settled":208,"../../modules/es.promise.finally":209,"../../modules/es.string.iterator":211,"../../modules/web.dom-collections.iterator":216}],122:[function(e,t,r){var n=e("../../es/promise");e("../../modules/esnext.aggregate-error"),e("../../modules/esnext.promise.all-settled"),e("../../modules/esnext.promise.try"),e("../../modules/esnext.promise.any"),t.exports=n},{"../../es/promise":121,"../../modules/esnext.aggregate-error":212,"../../modules/esnext.promise.all-settled":213,"../../modules/esnext.promise.any":214,"../../modules/esnext.promise.try":215}],123:[function(e,t,r){t.exports=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}},{}],124:[function(e,t,r){var n=e("../internals/is-object");t.exports=function(e){if(!n(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e}},{"../internals/is-object":161}],125:[function(e,t,r){t.exports=function(){}},{}],126:[function(e,t,r){t.exports=function(e,t,r){if(!(e instanceof t))throw TypeError("Incorrect "+(r?r+" ":"")+"invocation");return e}},{}],127:[function(e,t,r){var n=e("../internals/is-object");t.exports=function(e){if(!n(e))throw TypeError(String(e)+" is not an object");return e}},{"../internals/is-object":161}],128:[function(e,t,r){var n=e("../internals/to-indexed-object"),i=e("../internals/to-length"),o=e("../internals/to-absolute-index"),s=function(e){return function(t,r,s){var a,A=n(t),c=i(A.length),g=o(s,c);if(e&&r!=r){for(;c>g;)if((a=A[g++])!=a)return!0}else for(;c>g;g++)if((e||g in A)&&A[g]===r)return e||g||0;return!e&&-1}};t.exports={includes:s(!0),indexOf:s(!1)}},{"../internals/to-absolute-index":196,"../internals/to-indexed-object":197,"../internals/to-length":199}],129:[function(e,t,r){var n=e("../internals/an-object");t.exports=function(e,t,r,i){try{return i?t(n(r)[0],r[1]):t(r)}catch(t){var o=e.return;throw void 0!==o&&n(o.call(e)),t}}},{"../internals/an-object":127}],130:[function(e,t,r){var n=e("../internals/well-known-symbol")("iterator"),i=!1;try{var o=0,s={next:function(){return{done:!!o++}},return:function(){i=!0}};s[n]=function(){return this},Array.from(s,function(){throw 2})}catch(e){}t.exports=function(e,t){if(!t&&!i)return!1;var r=!1;try{var o={};o[n]=function(){return{next:function(){return{done:r=!0}}}},e(o)}catch(e){}return r}},{"../internals/well-known-symbol":205}],131:[function(e,t,r){var n={}.toString;t.exports=function(e){return n.call(e).slice(8,-1)}},{}],132:[function(e,t,r){var n=e("../internals/to-string-tag-support"),i=e("../internals/classof-raw"),o=e("../internals/well-known-symbol")("toStringTag"),s="Arguments"==i(function(){return arguments}());t.exports=n?i:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),o))?r:s?i(t):"Object"==(n=i(t))&&"function"==typeof t.callee?"Arguments":n}},{"../internals/classof-raw":131,"../internals/to-string-tag-support":202,"../internals/well-known-symbol":205}],133:[function(e,t,r){var n=e("../internals/fails");t.exports=!n(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})},{"../internals/fails":146}],134:[function(e,t,r){"use strict";var n=e("../internals/iterators-core").IteratorPrototype,i=e("../internals/object-create"),o=e("../internals/create-property-descriptor"),s=e("../internals/set-to-string-tag"),a=e("../internals/iterators"),A=function(){return this};t.exports=function(e,t,r){var c=t+" Iterator";return e.prototype=i(n,{next:o(1,r)}),s(e,c,!1,!0),a[c]=A,e}},{"../internals/create-property-descriptor":136,"../internals/iterators":165,"../internals/iterators-core":164,"../internals/object-create":171,"../internals/set-to-string-tag":189}],135:[function(e,t,r){var n=e("../internals/descriptors"),i=e("../internals/object-define-property"),o=e("../internals/create-property-descriptor");t.exports=n?function(e,t,r){return i.f(e,t,o(1,r))}:function(e,t,r){return e[t]=r,e}},{"../internals/create-property-descriptor":136,"../internals/descriptors":138,"../internals/object-define-property":173}],136:[function(e,t,r){t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},{}],137:[function(e,t,r){"use strict";var n=e("../internals/export"),i=e("../internals/create-iterator-constructor"),o=e("../internals/object-get-prototype-of"),s=e("../internals/object-set-prototype-of"),a=e("../internals/set-to-string-tag"),A=e("../internals/create-non-enumerable-property"),c=e("../internals/redefine"),g=e("../internals/well-known-symbol"),f=e("../internals/is-pure"),u=e("../internals/iterators"),l=e("../internals/iterators-core"),h=l.IteratorPrototype,d=l.BUGGY_SAFARI_ITERATORS,p=g("iterator"),y=function(){return this};t.exports=function(e,t,r,g,l,I,b){i(r,t,g);var _,B,E,C=function(e){if(e===l&&S)return S;if(!d&&e in v)return v[e];switch(e){case"keys":case"values":case"entries":return function(){return new r(this,e)}}return function(){return new r(this)}},m=t+" Iterator",w=!1,v=e.prototype,Q=v[p]||v["@@iterator"]||l&&v[l],S=!d&&Q||C(l),D="Array"==t&&v.entries||Q;if(D&&(_=o(D.call(new e)),h!==Object.prototype&&_.next&&(f||o(_)===h||(s?s(_,h):"function"!=typeof _[p]&&A(_,p,y)),a(_,m,!0,!0),f&&(u[m]=y))),"values"==l&&Q&&"values"!==Q.name&&(w=!0,S=function(){return Q.call(this)}),f&&!b||v[p]===S||A(v,p,S),u[t]=S,l)if(B={values:C("values"),keys:I?S:C("keys"),entries:C("entries")},b)for(E in B)!d&&!w&&E in v||c(v,E,B[E]);else n({target:t,proto:!0,forced:d||w},B);return B}},{"../internals/create-iterator-constructor":134,"../internals/create-non-enumerable-property":135,"../internals/export":145,"../internals/is-pure":162,"../internals/iterators":165,"../internals/iterators-core":164,"../internals/object-get-prototype-of":175,"../internals/object-set-prototype-of":179,"../internals/redefine":185,"../internals/set-to-string-tag":189,"../internals/well-known-symbol":205}],138:[function(e,t,r){var n=e("../internals/fails");t.exports=!n(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})},{"../internals/fails":146}],139:[function(e,t,r){var n=e("../internals/global"),i=e("../internals/is-object"),o=n.document,s=i(o)&&i(o.createElement);t.exports=function(e){return s?o.createElement(e):{}}},{"../internals/global":150,"../internals/is-object":161}],140:[function(e,t,r){t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},{}],141:[function(e,t,r){var n=e("../internals/engine-user-agent");t.exports=/(iphone|ipod|ipad).*applewebkit/i.test(n)},{"../internals/engine-user-agent":142}],142:[function(e,t,r){var n=e("../internals/get-built-in");t.exports=n("navigator","userAgent")||""},{"../internals/get-built-in":148}],143:[function(e,t,r){var n,i,o=e("../internals/global"),s=e("../internals/engine-user-agent"),a=o.process,A=a&&a.versions,c=A&&A.v8;c?i=(n=c.split("."))[0]+n[1]:s&&(!(n=s.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=s.match(/Chrome\/(\d+)/))&&(i=n[1]),t.exports=i&&+i},{"../internals/engine-user-agent":142,"../internals/global":150}],144:[function(e,t,r){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},{}],145:[function(e,t,r){"use strict";var n=e("../internals/global"),i=e("../internals/object-get-own-property-descriptor").f,o=e("../internals/is-forced"),s=e("../internals/path"),a=e("../internals/function-bind-context"),A=e("../internals/create-non-enumerable-property"),c=e("../internals/has"),g=function(e){var t=function(t,r,n){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,n)}return e.apply(this,arguments)};return t.prototype=e.prototype,t};t.exports=function(e,t){var r,f,u,l,h,d,p,y,I=e.target,b=e.global,_=e.stat,B=e.proto,E=b?n:_?n[I]:(n[I]||{}).prototype,C=b?s:s[I]||(s[I]={}),m=C.prototype;for(u in t)r=!o(b?u:I+(_?".":"#")+u,e.forced)&&E&&c(E,u),h=C[u],r&&(d=e.noTargetGet?(y=i(E,u))&&y.value:E[u]),l=r&&d?d:t[u],r&&typeof h==typeof l||(p=e.bind&&r?a(l,n):e.wrap&&r?g(l):B&&"function"==typeof l?a(Function.call,l):l,(e.sham||l&&l.sham||h&&h.sham)&&A(p,"sham",!0),C[u]=p,B&&(c(s,f=I+"Prototype")||A(s,f,{}),s[f][u]=l,e.real&&m&&!m[u]&&A(m,u,l)))}},{"../internals/create-non-enumerable-property":135,"../internals/function-bind-context":147,"../internals/global":150,"../internals/has":151,"../internals/is-forced":160,"../internals/object-get-own-property-descriptor":174,"../internals/path":181}],146:[function(e,t,r){t.exports=function(e){try{return!!e()}catch(e){return!0}}},{}],147:[function(e,t,r){var n=e("../internals/a-function");t.exports=function(e,t,r){if(n(e),void 0===t)return e;switch(r){case 0:return function(){return e.call(t)};case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}}},{"../internals/a-function":123}],148:[function(e,t,r){var n=e("../internals/path"),i=e("../internals/global"),o=function(e){return"function"==typeof e?e:void 0};t.exports=function(e,t){return arguments.length<2?o(n[e])||o(i[e]):n[e]&&n[e][t]||i[e]&&i[e][t]}},{"../internals/global":150,"../internals/path":181}],149:[function(e,t,r){var n=e("../internals/classof"),i=e("../internals/iterators"),o=e("../internals/well-known-symbol")("iterator");t.exports=function(e){if(void 0!=e)return e[o]||e["@@iterator"]||i[n(e)]}},{"../internals/classof":132,"../internals/iterators":165,"../internals/well-known-symbol":205}],150:[function(e,t,r){(function(e){var r=function(e){return e&&e.Math==Math&&e};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof e&&e)||Function("return this")()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],151:[function(e,t,r){var n={}.hasOwnProperty;t.exports=function(e,t){return n.call(e,t)}},{}],152:[function(e,t,r){t.exports={}},{}],153:[function(e,t,r){var n=e("../internals/global");t.exports=function(e,t){var r=n.console;r&&r.error&&(1===arguments.length?r.error(e):r.error(e,t))}},{"../internals/global":150}],154:[function(e,t,r){var n=e("../internals/get-built-in");t.exports=n("document","documentElement")},{"../internals/get-built-in":148}],155:[function(e,t,r){var n=e("../internals/descriptors"),i=e("../internals/fails"),o=e("../internals/document-create-element");t.exports=!n&&!i(function(){return 7!=Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a})},{"../internals/descriptors":138,"../internals/document-create-element":139,"../internals/fails":146}],156:[function(e,t,r){var n=e("../internals/fails"),i=e("../internals/classof-raw"),o="".split;t.exports=n(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==i(e)?o.call(e,""):Object(e)}:Object},{"../internals/classof-raw":131,"../internals/fails":146}],157:[function(e,t,r){var n=e("../internals/shared-store"),i=Function.toString;"function"!=typeof n.inspectSource&&(n.inspectSource=function(e){return i.call(e)}),t.exports=n.inspectSource},{"../internals/shared-store":191}],158:[function(e,t,r){var n,i,o,s=e("../internals/native-weak-map"),a=e("../internals/global"),A=e("../internals/is-object"),c=e("../internals/create-non-enumerable-property"),g=e("../internals/has"),f=e("../internals/shared-key"),u=e("../internals/hidden-keys"),l=a.WeakMap;if(s){var h=new l,d=h.get,p=h.has,y=h.set;n=function(e,t){return y.call(h,e,t),t},i=function(e){return d.call(h,e)||{}},o=function(e){return p.call(h,e)}}else{var I=f("state");u[I]=!0,n=function(e,t){return c(e,I,t),t},i=function(e){return g(e,I)?e[I]:{}},o=function(e){return g(e,I)}}t.exports={set:n,get:i,has:o,enforce:function(e){return o(e)?i(e):n(e,{})},getterFor:function(e){return function(t){var r;if(!A(t)||(r=i(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}}}},{"../internals/create-non-enumerable-property":135,"../internals/global":150,"../internals/has":151,"../internals/hidden-keys":152,"../internals/is-object":161,"../internals/native-weak-map":169,"../internals/shared-key":190}],159:[function(e,t,r){var n=e("../internals/well-known-symbol"),i=e("../internals/iterators"),o=n("iterator"),s=Array.prototype;t.exports=function(e){return void 0!==e&&(i.Array===e||s[o]===e)}},{"../internals/iterators":165,"../internals/well-known-symbol":205}],160:[function(e,t,r){var n=e("../internals/fails"),i=/#|\.prototype\./,o=function(e,t){var r=a[s(e)];return r==c||r!=A&&("function"==typeof t?n(t):!!t)},s=o.normalize=function(e){return String(e).replace(i,".").toLowerCase()},a=o.data={},A=o.NATIVE="N",c=o.POLYFILL="P";t.exports=o},{"../internals/fails":146}],161:[function(e,t,r){t.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},{}],162:[function(e,t,r){t.exports=!0},{}],163:[function(e,t,r){var n=e("../internals/an-object"),i=e("../internals/is-array-iterator-method"),o=e("../internals/to-length"),s=e("../internals/function-bind-context"),a=e("../internals/get-iterator-method"),A=e("../internals/call-with-safe-iteration-closing"),c=function(e,t){this.stopped=e,this.result=t};(t.exports=function(e,t,r,g,f){var u,l,h,d,p,y,I,b=s(t,r,g?2:1);if(f)u=e;else{if("function"!=typeof(l=a(e)))throw TypeError("Target is not iterable");if(i(l)){for(h=0,d=o(e.length);d>h;h++)if((p=g?b(n(I=e[h])[0],I[1]):b(e[h]))&&p instanceof c)return p;return new c(!1)}u=l.call(e)}for(y=u.next;!(I=y.call(u)).done;)if("object"==typeof(p=A(u,b,I.value,g))&&p&&p instanceof c)return p;return new c(!1)}).stop=function(e){return new c(!0,e)}},{"../internals/an-object":127,"../internals/call-with-safe-iteration-closing":129,"../internals/function-bind-context":147,"../internals/get-iterator-method":149,"../internals/is-array-iterator-method":159,"../internals/to-length":199}],164:[function(e,t,r){"use strict";var n,i,o,s=e("../internals/object-get-prototype-of"),a=e("../internals/create-non-enumerable-property"),A=e("../internals/has"),c=e("../internals/well-known-symbol"),g=e("../internals/is-pure"),f=c("iterator"),u=!1;[].keys&&("next"in(o=[].keys())?(i=s(s(o)))!==Object.prototype&&(n=i):u=!0),void 0==n&&(n={}),g||A(n,f)||a(n,f,function(){return this}),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:u}},{"../internals/create-non-enumerable-property":135,"../internals/has":151,"../internals/is-pure":162,"../internals/object-get-prototype-of":175,"../internals/well-known-symbol":205}],165:[function(e,t,r){arguments[4][152][0].apply(r,arguments)},{dup:152}],166:[function(e,t,r){var n,i,o,s,a,A,c,g,f=e("../internals/global"),u=e("../internals/object-get-own-property-descriptor").f,l=e("../internals/classof-raw"),h=e("../internals/task").set,d=e("../internals/engine-is-ios"),p=f.MutationObserver||f.WebKitMutationObserver,y=f.process,I=f.Promise,b="process"==l(y),_=u(f,"queueMicrotask"),B=_&&_.value;B||(n=function(){var e,t;for(b&&(e=y.domain)&&e.exit();i;){t=i.fn,i=i.next;try{t()}catch(e){throw i?s():o=void 0,e}}o=void 0,e&&e.enter()},b?s=function(){y.nextTick(n)}:p&&!d?(a=!0,A=document.createTextNode(""),new p(n).observe(A,{characterData:!0}),s=function(){A.data=a=!a}):I&&I.resolve?(c=I.resolve(void 0),g=c.then,s=function(){g.call(c,n)}):s=function(){h.call(f,n)}),t.exports=B||function(e){var t={fn:e,next:void 0};o&&(o.next=t),i||(i=t,s()),o=t}},{"../internals/classof-raw":131,"../internals/engine-is-ios":141,"../internals/global":150,"../internals/object-get-own-property-descriptor":174,"../internals/task":195}],167:[function(e,t,r){var n=e("../internals/global");t.exports=n.Promise},{"../internals/global":150}],168:[function(e,t,r){var n=e("../internals/fails");t.exports=!!Object.getOwnPropertySymbols&&!n(function(){return!String(Symbol())})},{"../internals/fails":146}],169:[function(e,t,r){var n=e("../internals/global"),i=e("../internals/inspect-source"),o=n.WeakMap;t.exports="function"==typeof o&&/native code/.test(i(o))},{"../internals/global":150,"../internals/inspect-source":157}],170:[function(e,t,r){"use strict";var n=e("../internals/a-function");t.exports.f=function(e){return new function(e){var t,r;this.promise=new e(function(e,n){if(void 0!==t||void 0!==r)throw TypeError("Bad Promise constructor");t=e,r=n}),this.resolve=n(t),this.reject=n(r)}(e)}},{"../internals/a-function":123}],171:[function(e,t,r){var n,i=e("../internals/an-object"),o=e("../internals/object-define-properties"),s=e("../internals/enum-bug-keys"),a=e("../internals/hidden-keys"),A=e("../internals/html"),c=e("../internals/document-create-element"),g=e("../internals/shared-key")("IE_PROTO"),f=function(){},u=function(e){return"