forked from hmalmedal/ripple-utilities
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathripple-0.7.35-min.js
7 lines (7 loc) · 205 KB
/
ripple-0.7.35-min.js
1
2
3
4
5
6
7
var ripple=function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(null,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.e=function(t,r){r.call(null,e)},e.modules=t,e.cache=r,e(0)}({c:"",0:function(t,e,r){function n(t){var r=e[t];Object.keys(r.prototype).forEach(function(t){var e=/([A-Z]{1})[a-z]+/g;if(e.test(t)){var n=t.replace(e,function(t){return"_"+t.toLowerCase()});r.prototype[n]=r.prototype[t]}})}e.Remote=r(1).Remote,e.Request=r(2).Request,e.Amount=r(3).Amount,e.Account=r(4).Account,e.Transaction=r(5).Transaction,e.Currency=r(6).Currency,e.Base=r(7).Base,e.UInt160=r(8).UInt160,e.UInt256=r(9).UInt256,e.Seed=r(10).Seed,e.Meta=r(11).Meta,e.SerializedObject=r(12).SerializedObject,e.RippleError=r(13).RippleError,e.binformat=r(14),e.utils=r(15),e.Server=r(16).Server,e.sjcl=r(15).sjcl,e.config=r(17),["Remote","Request","Transaction","Account","Server"].forEach(n)},1:function(t,e,r){function n(t){function e(t){"transaction_all"===t&&(!a._transaction_subs&&a._connected&&a.request_subscribe("transactions").request(),a._transaction_subs+=1)}function r(t){"transaction_all"===t&&(a._transaction_subs-=1,!a._transaction_subs&&a._connected&&a.request_unsubscribe("transactions").request())}function n(){a.storage.getPendingTransactions(function(t,e){function r(t){var e=a.transaction();e.parseJson(t.tx_json),Object.keys(t).forEach(function(r){switch(r){case"submittedIDs":case"clientID":case"submitIndex":e[r]=t[r]}}),e.submit()}!t&&Array.isArray(e)&&e.forEach(r)})}function s(){var t=a.requestPing();t.on("error",function(){}),t.broadcast()}i.call(this);var a=this;if(this.trusted=t.trusted,this.local_sequence=t.local_sequence,this.local_fee="undefined"==typeof t.local_fee?!0:t.local_fee,this.local_signing="undefined"==typeof t.local_signing?!0:t.local_signing,this.canonical_signing="undefined"==typeof t.canonical_signing?!0:t.canonical_signing,this.fee_cushion="undefined"==typeof t.fee_cushion?1.2:t.fee_cushion,this.max_fee="undefined"==typeof t.max_fee?1/0:t.max_fee,this.id=0,this.trace=t.trace,this._server_fatal=!1,this._ledger_current_index=void 0,this._ledger_hash=void 0,this._ledger_time=void 0,this._stand_alone=void 0,this._testnet=void 0,this._transaction_subs=0,this.online_target=!1,this._online_state="closed",this.state="offline",this.retry_timer=void 0,this.retry=void 0,this._connection_count=0,this._connected=!1,this._connection_offset=1e3*("number"==typeof t.connection_offset?t.connection_offset:5),this._submission_timeout=1e3*("number"==typeof t.submission_timeout?t.submission_timeout:10),this._received_tx=o({max:100}),this._cur_path_find=null,this.local_signing&&(this.local_sequence=!0,this.local_fee=!0),this._servers=[],this._primary_server=void 0,this.accounts={},this._accounts={},this._books={},this.secrets={},this.ledgers={current:{account_root:{}}},t.hasOwnProperty("servers")||(t.servers=[{host:t.websocket_ip,port:t.websocket_port,secure:t.websocket_ssl,trusted:t.trusted}]),"number"!=typeof this._connection_offset)throw new TypeError('Remote "connection_offset" configuration is not a Number');if("number"!=typeof this._submission_timeout)throw new TypeError('Remote "submission_timeout" configuration is not a Number');if("number"!=typeof this.max_fee)throw new TypeError('Remote "max_fee" configuration is not a Number');if("number"!=typeof this.fee_cushion)throw new TypeError('Remote "fee_cushion" configuration is not a Number');if(!/^(undefined|boolean)$/.test(typeof t.trace))throw new TypeError('Remote "trace" configuration is not a Boolean');if("boolean"!=typeof this.local_signing)throw new TypeError('Remote "local_signing" configuration is not a Boolean');if("boolean"!=typeof this.local_fee)throw new TypeError('Remote "local_fee" configuration is not a Boolean');if("boolean"!=typeof this.local_sequence)throw new TypeError('Remote "local_sequence" configuration is not a Boolean');if(!Array.isArray(t.servers))throw new TypeError('Remote "servers" configuration is not an Array');if(!/^(undefined|number)$/.test(typeof t.ping))throw new TypeError('Remote "ping" configuration is not a Number');if(!/^(undefined|object)$/.test(typeof t.storage))throw new TypeError('Remote "storage" configuration is not an Object');t.servers.forEach(function(t){for(var e=Number(t.pool)||1;e--;)a.addServer(t)});var c=t.maxListeners||t.max_listeners||0;this._servers.concat(this).forEach(function(t){t.setMaxListeners(c)}),this.on("newListener",e),this.on("removeListener",r),t.storage&&(this.storage=t.storage,this.once("connect",n)),t.ping&&this.once("connect",function(){a._pingInterval=setInterval(s,1e3*t.ping)})}var i=r(31).EventEmitter,s=r(32),o=r(46),a=r(2).Request,c=r(16).Server,u=r(3).Amount,h=r(6).Currency,f=r(8).UInt160,l=r(5).Transaction,p=r(4).Account,_=r(11).Meta,d=r(18).OrderBook,y=r(19).PathFind,m=r(13).RippleError,v=r(15),g=r(15).sjcl,b=r(17),w=r(20).internal.sub("remote");s.inherits(n,i),n.flags={account_root:{PasswordSpent:65536,RequireDestTag:131072,RequireAuth:262144,DisallowXRP:524288,DisableMaster:1048576},offer:{Passive:65536,Sell:131072},state:{LowReserve:65536,HighReserve:131072,LowAuth:262144,HighAuth:524288,LowNoRipple:1048576,HighNoRipple:2097152}},n.from_config=function(t,e){function r(t){var e=this.accounts[t];"object"==typeof e&&e.secret&&(s.setSecret(t,e.secret),s.setSecret(e.account,e.secret))}var i="string"==typeof t?b.servers[t]:t,s=new n(i,e);return b.accounts&&Object.keys(b.accounts).forEach(r,b),s},n.prototype.addServer=function(t){function e(t){i._handleMessage(t,s)}function r(){i._connection_count+=1,(t.primary||!i._primary_server)&&i._setPrimaryServer(s),1===i._connection_count&&i._setState("online"),i._connection_count===i._servers.length&&i.emit("ready")}function n(){i._connection_count--,0===i._connection_count&&i._setState("offline")}var i=this,s=new c(this,t);return s.on("message",e),s.on("connect",r),s.on("disconnect",n),this._servers.push(s),this},n.prototype.serverFatal=function(){this._server_fatal=!0},n.prototype._setState=function(t){if(this.state!==t)switch(this._trace("remote: set_state:",t),this.state=t,this.emit("state",t),t){case"online":this._online_state="open",this._connected=!0,this.emit("connect"),this.emit("connected");break;case"offline":this._online_state="closed",this._connected=!1,this.emit("disconnect"),this.emit("disconnected")}},n.prototype.setTrace=function(t){return this.trace=void 0===t||t,this},n.prototype.setSecret=function(t,e){this.secrets[t]=e},n.prototype._trace=function(){this.trace&&w.info.apply(w,arguments)},n.prototype.connect=function(t){if(!this._servers.length)throw new Error("No servers available.");switch(typeof t){case"undefined":break;case"function":this.once("connect",t);break;default:if(!Boolean(t))return this.disconnect()}var e=this;return function r(t){var n=e._servers[t];n.connect(),n._sid=++t,t<e._servers.length&&setTimeout(function(){r(t)},e._connection_offset)}(0),this},n.prototype.disconnect=function(t){if(!this._servers.length)throw new Error("No servers available, not disconnecting");return"function"==typeof t&&this.once("disconnect",t),this._servers.forEach(function(t){t.disconnect()}),this._set_state("offline"),this},n.prototype._handleMessage=function(t,e){var r=this;try{t=JSON.parse(t)}catch(i){}if(!n.isValidMessage(t))return this.emit("error",new m("remoteUnexpected","Unexpected response from remote")),void 0;switch(t.type){case"response":break;case"ledgerClosed":if(!n.isValidLedgerData(t))return;t.ledger_index>=this._ledger_current_index&&(this._ledger_time=t.ledger_time,this._ledger_hash=t.ledger_hash,this._ledger_current_index=t.ledger_index+1,this.emit("ledger_closed",t,e));break;case"serverStatus":r.emit("server_status",t);break;case"transaction":var s=t.transaction.hash;if(this._received_tx.get(s))break;t.validated&&this._received_tx.set(s,!0),this._trace("remote: tx:",t),t.meta?(t.mmeta=new _(t.meta),t.mmeta.getAffectedAccounts().forEach(function(e){e=r._accounts[e],e&&e.notify(t)}),t.mmeta.getAffectedBooks().forEach(function(e){e=r._books[e],e&&e.notify(t)})):["Account","Destination"].forEach(function(e){var n=t.transaction[e];n&&(n=r.account(n))&&n.notify(t)}),this.emit("transaction",t),this.emit("transaction_all",t);break;case"path_find":this._cur_path_find&&this._cur_path_find.notify_update(t),this.emit("path_find_all",t);break;default:this._trace("remote: "+t.type+": ",t),this.emit("net_"+t.type,t)}},n.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},n.isValidLedgerData=function(t){return"object"==typeof t&&"number"==typeof t.fee_base&&"number"==typeof t.fee_ref&&"number"==typeof t.fee_base&&"string"==typeof t.ledger_hash&&"number"==typeof t.ledger_index&&"number"==typeof t.ledger_time&&"number"==typeof t.reserve_base&&"number"==typeof t.reserve_inc&&"number"==typeof t.txn_count},n.isLoadStatus=function(t){return"number"==typeof t.load_base&&"number"==typeof t.load_factor},n.prototype.ledgerHash=function(){return this._ledger_hash},n.prototype._setPrimaryServer=function(t){this._primary_server&&(this._primary_server._primary=!1),this._primary_server=t,this._primary_server._primary=!0},n.prototype._serverIsAvailable=function(t){return t&&t._connected},n.prototype._nextServer=function(){for(var t=null,e=0,r=this._servers.length;r>e;e++){var n=this._servers[e];if(this._serverIsAvailable(n)){t=n;break}}return t},n.prototype._getServer=function(){var t;return this._serverIsAvailable(this._primary_server)?t=this._primary_server:(t=this._nextServer(),t&&this._setPrimaryServer(t)),t},n.prototype.request=function(t){if("string"==typeof t){if(/^request_/.test(t)||(t="request_"+t),"function"==typeof this[t]){var e=Array.prototype.slice.call(arguments,1);return this[t].apply(this,e)}throw new Error("Command does not exist: "+t)}if(!(t instanceof a))throw new Error("Argument is not a Request");if(this._servers.length)if(this._connected)if(null===t.server)t.emit("error",new Error("Server does not exist"));else{var r=t.server||this._getServer();r?r.request(t):t.emit("error",new Error("No servers available"))}else this.once("connect",this.request.bind(this,t));else t.emit("error",new Error("No servers available"))},n.prototype.requestServerInfo=function(t){return new a(this,"server_info").callback(t)},n.prototype.requestLedger=function(t,e,r){var n=new a(this,"ledger");switch(t&&(n.message.ledger=t),typeof e){case"object":Object.keys(e).forEach(function(t){switch(t){case"full":case"expand":case"transactions":case"accounts":n.message[t]=!0}},e);break;case"function":r=e,e=void 0;break;default:this._trace("request_ledger: full parameter is deprecated"),n.message.full=!0}return n.callback(r),n},n.prototype.requestLedgerClosed=n.prototype.requestLedgerHash=function(t){return new a(this,"ledger_closed").callback(t)},n.prototype.requestLedgerHeader=function(t){return new a(this,"ledger_header").callback(t)},n.prototype.requestLedgerCurrent=function(t){return new a(this,"ledger_current").callback(t)},n.prototype.requestLedgerEntry=function(t,e){var r=this,n=new a(this,"ledger_entry");return"account_root"===t&&(n.request_default=n.request,n.request=function(){var e=!0;if(!r._ledger_hash&&"account_root"===t){var i=r.ledgers.current.account_root;i||(i=r.ledgers.current.account_root={});var s=r.ledgers.current.account_root[n.message.account_root];if(s)n.emit("success",{node:s}),e=!1;else switch(t){case"account_root":n.once("success",function(t){r.ledgers.current.account_root[t.node.Account]=t.node})}}e&&n.request_default()}),n.callback(e),n},n.prototype.requestSubscribe=function(t,e){var r=new a(this,"subscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},n.prototype.requestUnsubscribe=function(t,e){var r=new a(this,"unsubscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},n.prototype.requestTransaction=n.prototype.requestTransactionEntry=function(t,e,r){var n=new a(this,"transaction_entry");switch(n.txHash(t),typeof e){case"string":case"number":n.ledgerSelect(e);break;case"undefined":case"function":n.ledgerIndex("validated"),r=e;break;default:throw new Error("Invalid ledger_hash type")}return n.callback(r),n},n.prototype.requestTx=function(t,e){var r=new a(this,"tx");return r.message.transaction=t,r.callback(e),r},n.accountRequest=function(t,e,r,n,i,s){if("object"==typeof e){var o=e;s=r,n=o.ledger,r=o.account_index||o.accountIndex,e=o.accountID||o.account,i=o.peer}var c=arguments[arguments.length-1];"function"==typeof c&&(s=c);var u=new a(this,t),e=f.json_rewrite(e);return u.message.ident=e,u.message.account=e,"number"==typeof r&&(u.message.index=r),"undefined"!=typeof n&&u.ledgerChoose(n),"undefined"!=typeof i&&(u.message.peer=f.json_rewrite(i)),u.callback(s),u},n.prototype.requestAccountInfo=function(){var t=Array.prototype.concat.apply(["account_info"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountCurrencies=function(){var t=Array.prototype.concat.apply(["account_currencies"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountLines=function(){var t=Array.prototype.concat.apply(["account_lines"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountOffers=function(){var t=Array.prototype.concat.apply(["account_offers"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountTx=function(t,e){function n(t){var e=Object.keys(t);return function(r){var n=e.every(function(e){return r.tx[e]===t[e]});return n}}function i(t){var e={validated:t.validated};return e.meta=new c(t.meta).to_json(),e.tx=new c(t.tx_blob).to_json(),e.tx.ledger_index=t.ledger_index,e.tx.hash=l.from_json(e.tx).hash(),e}function s(e){function r(){var r=n.listeners("success");n.removeAllListeners("success"),n.once("success",function(s){t.binary&&(s.transactions=s.transactions.map(i)),e!==Boolean&&(s.transactions=s.transactions.filter(e)),"function"==typeof t.map&&(s.transactions=s.transactions.map(t.map)),"function"==typeof t.reduce&&(s.transactions=s.transactions.reduce(t.reduce)),"string"==typeof t.pluck&&(s=s[t.pluck]),r.forEach(function(t){t.call(n,s)})})}if("function"!=typeof e)throw new Error("Missing filter function");var n=this;return this.once("request",r),this}var o=new a(this,"account_tx");Object.keys(t).forEach(function(t){switch(t){case"account":case"ledger_index_min":case"ledger_index_max":case"binary":case"count":case"descending":case"offset":case"limit":case"forward":case"marker":o.message[t]=this[t]}},t);var c=r(12).SerializedObject;if(o.filter=s,(t.binary||t.map||t.reduce)&&(t.filter=t.filter||Boolean),t.filter)switch(t.filter){case"inbound":o.filter(n({Destination:t.account}));break;case"outbound":o.filter(n({Account:t.account}));break;default:"object"==typeof t.filter&&(t.filter=n(t.filter)),o.filter(t.filter)}return o.callback(e),o},n.prototype.requestTxHistory=function(t,e){var r=new a(this,"tx_history");return r.message.start=t,r.callback(e),r},n.prototype.requestBookOffers=function(t,e,r,n){if(t.hasOwnProperty("pays")){var i=t;n=e,r=i.taker,e=i.pays,t=i.gets}var s=arguments[arguments.length-1];"function"==typeof s&&(n=s);var o=new a(this,"book_offers");return o.message.taker_gets={currency:h.json_rewrite(t.currency)},"XRP"!==o.message.taker_gets.currency&&(o.message.taker_gets.issuer=f.json_rewrite(t.issuer)),o.message.taker_pays={currency:h.json_rewrite(e.currency)},"XRP"!==o.message.taker_pays.currency&&(o.message.taker_pays.issuer=f.json_rewrite(e.issuer)),o.message.taker=r?r:f.ACCOUNT_ONE,o.callback(n),o},n.prototype.requestWalletAccounts=function(t,e){v.assert(this.trusted);var r=new a(this,"wallet_accounts");return r.message.seed=t,r.callback(e),r},n.prototype.requestSign=function(t,e,r){v.assert(this.trusted);var n=new a(this,"sign");return n.message.secret=t,n.message.tx_json=e,n.callback(r),n},n.prototype.requestSubmit=function(t){return new a(this,"submit").callback(t)},n.prototype._serverPrepareSubscribe=function(t){function e(t){if(r._stand_alone=!!t.stand_alone,r._testnet=!!t.testnet,"string"==typeof t.random){for(var e=t.random.match(/[0-9A-F]{8}/gi);e&&e.length;)g.random.addEntropy(parseInt(e.pop(),16));r.emit("random",v.hexToArray(t.random))}t.ledger_hash&&t.ledger_index&&(r._ledger_time=t.ledger_time,r._ledger_hash=t.ledger_hash,r._ledger_current_index=t.ledger_index+1,r.emit("ledger_closed",t)),r.emit("subscribed")}var r=this,n=["ledger","server"];this._transaction_subs&&n.push("transactions");var i=this.requestSubscribe(n);return i.once("success",e),r.emit("prepare_subscribe",i),i.callback(t,"subscribed"),i},n.prototype.ledgerAccept=function(t){if(this._stand_alone){var e=new a(this,"ledger_accept");e.request(),e.callback(t)}else this.emit("error",new m("notStandAlone"));return this},n.accountRootRequest=function(t,e,r,n,i){"object"==typeof r&&(i=n,n=r.ledger,r=r.account);var s=arguments[arguments.length-1];"function"==typeof s&&(i=s);var o=this.requestLedgerEntry("account_root");return o.accountRoot(r),o.ledgerChoose(n),o.once("success",function(r){o.emit(t,e(r))}),o.callback(i,t),o},n.prototype.requestAccountBalance=function(){function t(t){return u.from_json(t.node.Balance)}var e=Array.prototype.concat.apply(["account_balance",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.requestAccountFlags=function(){function t(t){return t.node.Flags}var e=Array.prototype.concat.apply(["account_flags",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.requestOwnerCount=function(){function t(t){return t.node.OwnerCount}var e=Array.prototype.concat.apply(["owner_count",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.getAccount=function(t){return this._accounts[f.json_rewrite(t)]},n.prototype.addAccount=function(t){var e=new p(this,t);return e.is_valid()&&(this._accounts[t]=e),e},n.prototype.account=function(t){var e=this.getAccount(t);return e?e:this.addAccount(t)},n.prototype.pathFind=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.src_currencies,r=i.dst_amount,e=i.dst_account,t=i.src_account}var s=new y(this,t,e,r,n);return this._cur_path_find&&this._cur_path_find.notify_superceded(),s.create(),this._cur_path_find=s,s},n.prepareTrade=function(t,e){return t+("XRP"===t?"":"/"+e)},n.prototype.book=function(t,e,r,i){if("object"==typeof t){var s=t;i=s.issuer_pays,r=s.currency_pays,e=s.issuer_gets,t=s.currency_gets}var o,a=n.prepareTrade(t,e),c=n.prepareTrade(r,i),u=a+":"+c;return this._books.hasOwnProperty(u)||(o=new d(this,t,e,r,i,u),o.is_valid()&&(this._books[u]=o)),this._books[u]},n.prototype.accountSeq=function(t,e){var r,t=f.json_rewrite(t),n=this.accounts[t];if(account_info&&account_info.seq){r=n.seq;var i={ADVANCE:1,REWIND:-1}[e.toUpperCase()]||0;n.seq+=i}return r},n.prototype.setAccountSeq=function(t,e){var t=f.json_rewrite(t);this.accounts.hasOwnProperty(t)||(this.accounts[t]={}),this.accounts[t].seq=e},n.prototype.accountSeqCache=function(t,e,r){function n(t){delete o.caching_seq_request;var e=t.node.Sequence;o.seq=e,a.emit("success_account_seq_cache",t)}function i(t){delete o.caching_seq_request,a.emit("error_account_seq_cache",t)}if("object"==typeof t){var s=t;r=e,e=s.ledger,t=s.account}this.accounts.hasOwnProperty(t)||(this.accounts[t]={});var o=this.accounts[t],a=o.caching_seq_request;return a||(a=this.requestLedgerEntry("account_root"),a.accountRoot(t),a.ledgerChoose(e),a.once("success",n),a.once("error",i),o.caching_seq_request=a),a.callback(r,"success_account_seq_cache","error_account_seq_cache"),a},n.prototype.dirtyAccountRoot=function(t){var t=f.json_rewrite(t);delete this.ledgers.current.account_root[t]},n.prototype.requestRippleBalance=function(t,e,r,n,i){function s(r){var n=r.node,i=u.from_json(n.LowLimit),s=u.from_json(n.HighLimit),o=u.from_json(n.Balance),c=f.from_json(t).equals(s.issuer());a.emit("ripple_state",{account_balance:(c?o.negate():o.clone()).parse_issuer(t),peer_balance:(c?o.clone():o.negate()).parse_issuer(e),account_limit:(c?s:i).clone().parse_issuer(e),peer_limit:(c?i:s).clone().parse_issuer(t),account_quality_in:c?n.HighQualityIn:n.LowQualityIn,peer_quality_in:c?n.LowQualityIn:n.HighQualityIn,account_quality_out:c?n.HighQualityOut:n.LowQualityOut,peer_quality_out:c?n.LowQualityOut:n.HighQualityOut})}if("object"==typeof t){var o=t;i=e,n=o.ledger,r=o.currency,e=o.issuer,t=o.account}var a=this.requestLedgerEntry("ripple_state");return a.rippleState(t,e,r),a.ledgerChoose(n),a.once("success",s),a.callback(i,"ripple_state"),a},n.prepareCurrencies=function(t){var e={};return t.hasOwnProperty("issuer")&&(e.issuer=f.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=h.json_rewrite(t.currency)),e},n.prototype.requestRipplePathFind=function(t,e,r,i,s){if("object"==typeof t){var o=t;s=e,i=o.src_currencies,r=o.dst_amount,e=o.dst_account,t=o.src_account}var c=new a(this,"ripple_path_find");return c.message.source_account=f.json_rewrite(t),c.message.destination_account=f.json_rewrite(e),c.message.destination_amount=u.json_rewrite(r),i&&(c.message.source_currencies=i.map(n.prepareCurrencies)),c.callback(s),c},n.prototype.requestPathFindCreate=function(t,e,r,i,s){if("object"==typeof t){var o=t;s=e,i=o.src_currencies,r=o.dst_amount,e=o.dst_account,t=o.src_account}var c=new a(this,"path_find");return c.message.subcommand="create",c.message.source_account=f.json_rewrite(t),c.message.destination_account=f.json_rewrite(e),c.message.destination_amount=u.json_rewrite(r),i&&(c.message.source_currencies=i.map(n.prepareCurrencies)),c.callback(s),c},n.prototype.requestPathFindClose=function(){var t=new a(this,"path_find");return t.message.subcommand="close",t},n.prototype.requestUnlList=function(t){return new a(this,"unl_list").callback(t)},n.prototype.requestUnlAdd=function(t,e,r){var n=new a(this,"unl_add");return n.message.node=t,e&&(n.message.comment=void 0),n.callback(r),n},n.prototype.requestUnlDelete=function(t,e){var r=new a(this,"unl_delete");return r.message.node=t,r.callback(e),r},n.prototype.requestPeers=function(t){return new a(this,"peers").callback(t)},n.prototype.requestConnect=function(t,e,r){var n=new a(this,"connect");return n.message.ip=t,e&&(n.message.port=e),n.callback(r),n},n.prototype.createTransaction=n.prototype.transaction=function(t,e){var r,n=new l(this),i={payment:"payment",accountset:"accountSet",trustset:"trustSet",offercreate:"offerCreate",offercancel:"offerCancel",sign:"sign"};switch(typeof t){case"object":if("string"!=typeof t.type)throw new Error("Missing transaction type");if(r=i[t.type.toLowerCase()],!r)throw new Error("Invalid transaction type: "+r);n=n[r](t);break;case"string":if(r=i[t.toLowerCase()],!r)throw new Error("Invalid transaction type: "+r);n=n[r](e)}var s=arguments[arguments.length-1];return"function"==typeof s&&n.submit(s),n},n.prototype.feeTx=function(t){return this._getServer().feeTx(t)},n.prototype.feeTxUnit=function(){return this._getServer().feeTxUnit()},n.prototype.reserve=function(t){return this._getServer().reserve(t)},n.prototype.requestPing=n.prototype.ping=function(t,e){var r=new a(this,"ping");switch(typeof t){case"function":e=t;break;case"string":r.setServer(t)}var n=Date.now();return r.once("success",function(){r.emit("pong",Date.now()-n)}),r.callback(e,"pong"),r},e.Remote=n},2:function(t,e,r){function n(t,e){i.call(this),this.remote=t,this.requested=!1,this.message={command:e,id:void 0}}var i=r(31).EventEmitter,s=r(32),o=r(8).UInt160,a=r(6).Currency;r(5).Transaction,r(4).Account,r(11).Meta,r(18).OrderBook;var c=r(13).RippleError,u=r(16).Server;s.inherits(n,i),n.prototype.broadcast=function(){return this._broadcast=!0,this.request()},n.prototype.request=function(t){return this.requested?void 0:(this.requested=!0,this.on("error",new Function),this.emit("request",t),this._broadcast?this.remote._servers.forEach(function(t){this.setServer(t),this.remote.request(this)},this):this.remote.request(this),this)},n.prototype.callback=function(t,e,r){function n(e){t.call(s,null,e)}function i(e){e instanceof c||(e=new c(e)),t.call(s,e)}var s=this;return this.requestsed||"function"!=typeof t?this:(this.once(e||"success",n),this.once(r||"error",i),this.request(),this)},n.prototype.timeout=function(t,e){function r(){n.timeout(t,e)}var n=this;if(!this.requested)return this.once("request",r);var i=this.emit,s=!1,o=setTimeout(function(){s=!0,"function"==typeof e&&e(),i.call(n,"timeout")},t);return this.emit=function(){s||(clearTimeout(o),i.apply(n,arguments))},this},n.prototype.setServer=function(t){var e=null;switch(typeof t){case"object":e=t;break;case"string":for(var r,n=this.remote._servers,i=0;r=n[i];i++)if(r._host===t){e=r;break}}return e instanceof u&&(this.server=e),this},n.prototype.buildPath=function(t){if(this.remote.local_signing)throw new Error("`build_path` is completely ignored when doing local signing as `Paths` is a component of the signed blob. The `tx_blob` is signed,sealed and delivered, and the txn unmodified after");return t?this.message.build_path=!0:delete this.message.build_path,this},n.prototype.ledgerChoose=function(t){return t?this.message.ledger_index=this.remote._ledger_current_index:this.message.ledger_hash=this.remote._ledger_hash,this},n.prototype.ledgerHash=function(t){return this.message.ledger_hash=t,this},n.prototype.ledgerIndex=function(t){return this.message.ledger_index=t,this},n.prototype.ledgerSelect=function(t){switch(t){case"current":case"closed":case"verified":this.message.ledger_index=ledger_spec;break;default:isNaN(t)?this.message.ledger_hash=t:(t=Number(t))&&(this.message.ledger_index=t)}return this},n.prototype.accountRoot=function(t){return this.message.account_root=o.json_rewrite(t),this},n.prototype.index=function(t){return this.message.index=t,this},n.prototype.offerId=function(t,e){return this.message.offer={account:o.json_rewrite(t),seq:e},this},n.prototype.offerIndex=function(t){return this.message.offer=t,this},n.prototype.secret=function(t){return t&&(this.message.secret=t),this},n.prototype.txHash=function(t){return this.message.tx_hash=t,this},n.prototype.txJson=function(t){return this.message.tx_json=t,this},n.prototype.txBlob=function(t){return this.message.tx_blob=t,this},n.prototype.rippleState=function(t,e,r){return this.message.ripple_state={currency:r,accounts:[o.json_rewrite(t),o.json_rewrite(e)]},this},n.prototype.accounts=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return o.json_rewrite(t)});return e?this.message.accounts_proposed=r:this.message.accounts=r,this},n.prototype.addAccount=function(t,e){var r=o.json_rewrite(t);return e?this.message.accounts_proposed=(this.message.accounts_proposed||[]).concat(r):this.message.accounts=(this.message.accounts||[]).concat(r),this},n.prototype.rtAccounts=n.prototype.accountsProposed=function(t){return this.accounts(t,!0)},n.prototype.addAccountProposed=function(t){return this.addAccount(t,!0)},n.prototype.books=function(t,e){this.message.books=[];for(var r=0,n=t.length;n>r;r++){var i=t[r];this.addBook(i,e)}return this},n.prototype.addBook=function(t,e){function r(e){if(!t[e])throw new Error("Missing "+e);var r=n[e]={currency:a.json_rewrite(t[e].currency)};"XRP"!==r.currency&&(r.issuer=o.json_rewrite(t[e].issuer))}Array.isArray(this.message.books)||(this.message.books=[]);var n={};["taker_gets","taker_pays"].forEach(r),e&&(n.snapshot=!0),t.both&&(n.both=!0),this.message.books.push(n)},e.Request=n},3:function(t,e,r){function n(){this._value=new o,this._offset=0,this._is_native=!0,this._is_negative=!1,this._currency=new u,this._issuer=new a}var i=r(15),s=i.sjcl;s.bn;var o=i.jsbn.BigInteger,a=r(8).UInt160,c=r(10).Seed,u=r(6).Currency,h=e.consts={currency_xns:0,currency_one:1,xns_precision:6,bi_5:new o("5"),bi_7:new o("7"),bi_10:new o("10"),bi_1e14:new o(String(1e14)),bi_1e16:new o(String(1e16)),bi_1e17:new o(String(1e17)),bi_1e32:new o("100000000000000000000000000000000"),bi_man_max_value:new o("9999999999999999"),bi_man_min_value:new o("1000000000000000"),bi_xns_max:new o("9000000000000000000"),bi_xns_min:new o("-9000000000000000000"),bi_xns_unit:new o("1000000"),cMinOffset:-96,cMaxOffset:80};n.text_full_rewrite=function(t){return n.from_json(t).to_text_full()},n.json_rewrite=function(t){return n.from_json(t).to_json()},n.from_number=function(t){return(new n).parse_number(t)},n.from_json=function(t){return(new n).parse_json(t)},n.from_quality=function(t,e,r,i){return(new n).parse_quality(t,e,r,i)},n.from_human=function(t,e){return(new n).parse_human(t,e)},n.is_valid=function(t){return n.from_json(t).is_valid()},n.is_valid_full=function(t){return n.from_json(t).is_valid_full()},n.NaN=function(){var t=new n;return t._value=0/0,t},n.prototype.abs=function(){return this.clone(this.is_negative())},n.prototype.add=function(t){var e;if(t=n.from_json(t),this.is_comparable(t))if(t.is_zero())e=this;else if(this.is_zero())e=t.clone(),e._is_native=this._is_native,e._currency=this._currency,e._issuer=this._issuer;else if(this._is_native){e=new n;var r=this._is_negative?this._value.negate():this._value,i=t._is_negative?t._value.negate():t._value,s=r.add(i);e._is_negative=s.compareTo(o.ZERO)<0,e._value=e._is_negative?s.negate():s,e._currency=this._currency,e._issuer=this._issuer}else{for(var r=this._is_negative?this._value.negate():this._value,a=this._offset,i=t._is_negative?t._value.negate():t._value,c=t._offset;c>a;)r=r.divide(h.bi_10),a+=1;for(;a>c;)i=i.divide(h.bi_10),c+=1;e=new n,e._is_native=!1,e._offset=a,e._value=r.add(i),e._is_negative=e._value.compareTo(o.ZERO)<0,e._is_negative&&(e._value=e._value.negate()),e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}else e=n.NaN();return e},n.prototype._invert=function(){return this._value=h.bi_1e32.divide(this._value),this._offset=-32-this._offset,this.canonicalize(),this},n.prototype.invert=function(){return this.copy()._invert()},n.prototype.canonicalize=function(){if(this._value instanceof o)if(this._is_native)if(this._value.equals(o.ZERO))this._offset=0,this._is_negative=!1;else{for(;this._offset<0;)this._value=this._value.divide(h.bi_10),this._offset+=1;for(;this._offset>0;)this._value=this._value.multiply(h.bi_10),this._offset-=1}else if(this.is_zero())this._offset=-100,this._is_negative=!1;else{for(;this._value.compareTo(h.bi_man_min_value)<0;)this._value=this._value.multiply(h.bi_10),this._offset-=1;for(;this._value.compareTo(h.bi_man_max_value)>0;)this._value=this._value.divide(h.bi_10),this._offset+=1}else;return this},n.prototype.clone=function(t){return this.copyTo(new n,t)},n.prototype.compareTo=function(t){var e;return this.is_comparable(t)?this._is_negative!==t._is_negative?e=this._is_negative?-1:1:this._value.equals(o.ZERO)?e=t._value.equals(o.ZERO)?0:-1:t._value.equals(o.ZERO)?e=1:!this._is_native&&this._offset>t._offset?e=this._is_negative?-1:1:!this._is_native&&this._offset<t._offset?e=this._is_negative?1:-1:(e=this._value.compareTo(t._value),e>0?e=this._is_negative?-1:1:0>e&&(e=this._is_negative?1:-1)):e=n.NaN(),e},n.prototype.copyTo=function(t,e){return"object"==typeof this._value?this._value.copyTo(t._value):t._value=this._value,t._offset=this._offset,t._is_native=this._is_native,t._is_negative=e?!this._is_negative:this._is_negative,t._currency=this._currency,t._issuer=this._issuer,t.is_zero()&&(t._is_negative=!1),t},n.prototype.currency=function(){return this._currency},n.prototype.equals=function(t,e){if("string"==typeof t)return this.equals(n.from_json(t));var r=!0;return r=!!(this.is_valid()&&t.is_valid()&&this._is_native===t._is_native&&this._value.equals(t._value)&&this._offset===t._offset&&this._is_negative===t._is_negative&&(this._is_native||this._currency.equals(t._currency)&&(e||this._issuer.equals(t._issuer))))},n.prototype.divide=function(t){var e;if(t.is_zero())throw"divide by zero";if(this.is_zero())e=this;else{if(!this.is_valid())throw new Error("Invalid dividend");if(!t.is_valid())throw new Error("Invalid divisor");var r=this;if(r.is_native())for(r=r.clone();r._value.compareTo(h.bi_man_min_value)<0;)r._value=r._value.multiply(h.bi_10),r._offset-=1;var i=t;if(i.is_native())for(i=i.clone();i._value.compareTo(h.bi_man_min_value)<0;)i._value=i._value.multiply(h.bi_10),i._offset-=1;
e=new n,e._offset=r._offset-i._offset-17,e._value=r._value.multiply(h.bi_1e17).divide(i._value).add(h.bi_5),e._is_native=r._is_native,e._is_negative=r._is_negative!==i._is_negative,e._currency=r._currency,e._issuer=r._issuer,e.canonicalize()}return e},n.prototype.ratio_human=function(t,e){e=e||{},t="number"==typeof t&&parseInt(t,10)===t?n.from_json(""+t+".0"):n.from_json(t);var r=this;return t=n.from_json(t),r.is_valid()&&t.is_valid()?(e.reference_date&&(t=t.applyInterest(e.reference_date)),t._is_native&&(r=r.clone(),r._value=r._value.multiply(h.bi_xns_unit),r.canonicalize()),r.divide(t)):n.NaN()},n.prototype.product_human=function(t,e){if(e=e||{},t="number"==typeof t&&parseInt(t,10)===t?n.from_json(String(t)+".0"):n.from_json(t),!this.is_valid()||!t.is_valid())return n.NaN();e.reference_date&&(t=t.applyInterest(e.reference_date));var r=this.multiply(t);return t._is_native&&(r._value=r._value.divide(h.bi_xns_unit),r.canonicalize()),r},n.prototype.is_comparable=function(t){return this._value instanceof o&&t._value instanceof o&&this._is_native===t._is_native},n.prototype.is_native=function(){return this._is_native},n.prototype.is_negative=function(){return this._value instanceof o?this._is_negative:!1},n.prototype.is_positive=function(){return!this.is_zero()&&!this.is_negative()},n.prototype.is_valid=function(){return this._value instanceof o},n.prototype.is_valid_full=function(){return this.is_valid()&&this._currency.is_valid()&&this._issuer.is_valid()},n.prototype.is_zero=function(){return this._value instanceof o?this._value.equals(o.ZERO):!1},n.prototype.issuer=function(){return this._issuer},n.prototype.multiply=function(t){var e;if(this.is_zero())e=this;else if(t.is_zero())e=this.clone(),e._value=o.ZERO;else{var r=this._value,i=this._offset,s=t._value,a=t._offset;if(this.is_native())for(;r.compareTo(h.bi_man_min_value)<0;)r=r.multiply(h.bi_10),i-=1;if(t.is_native())for(;s.compareTo(h.bi_man_min_value)<0;)s=s.multiply(h.bi_10),a-=1;e=new n,e._offset=i+a+14,e._value=r.multiply(s).divide(h.bi_1e14).add(h.bi_7),e._is_native=this._is_native,e._is_negative=this._is_negative!==t._is_negative,e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}return e},n.prototype.negate=function(){return this.clone("NEGATE")},n.prototype.invert=function(){var t=this.clone();return t._value=o.ONE,t._offset=0,t._is_negative=!1,t.canonicalize(),t.ratio_human(this)},n.human_RE=/^\s*([a-z]{3})?\s*(-)?(\d+)(?:\.(\d*))?\s*([a-f0-9]{40}|[a-z0-9]{3})?\s*$/i,n.prototype.parse_human=function(t,e){e=e||{};var r=String(t).match(n.human_RE);if(r){var i=r[1]||r[5]||"XRP",s=r[3]||"0",a=r[4]||"",c=null;if(i=i.toUpperCase(),this._value=new o(s),this.set_currency(i),"XRP"===i){for(a=a.slice(0,6);a.length<6;)a+="0";this._is_native=!0,this._value=this._value.multiply(h.bi_xns_unit).add(new o(a))}else{a=a.replace(/0+$/,""),c=a.length,this._is_native=!1;var u=h.bi_10.clone().pow(c);this._value=this._value.multiply(u).add(new o(a)),this._offset=-c,this.canonicalize()}if(this._is_negative=!!r[2],e.reference_date&&this._currency.has_interest()){var f=this._currency.get_interest_at(e.reference_date),l=n.from_json(""+f+"/1/1");if(l.is_valid()){var p=this.divide(l);this._value=p._value,this._offset=p._offset}}}else this._value=0/0;return this},n.prototype.parse_issuer=function(t){return this._issuer=a.from_json(t),this},n.prototype.parse_quality=function(t,e,r,i){i=i||{};var s=u.from_json(i.base_currency);if(this._is_negative=!1,this._value=new o(t.substring(t.length-14),16),this._offset=parseInt(t.substring(t.length-16,t.length-14),16)-100,this._currency=u.from_json(e),this._issuer=a.from_json(r),this._is_native=this._currency.is_native(),!i.xrp_as_drops&&s.is_valid()&&s.is_native()&&(i.inverse?this._offset-=6:this._offset+=6),i.inverse&&this._invert(),this.canonicalize(),i.reference_date&&s.is_valid()&&s.has_interest()){var c=s.get_interest_at(i.reference_date),h=n.from_json(""+c+"/1/1");if(h.is_valid()){var f=this.divide(h);this._value=f._value,this._offset=f._offset}}return this},n.prototype.parse_number=function(t){return this._is_native=!1,this._currency=u.from_json(1),this._issuer=a.from_json(1),this._is_negative=0>t?1:0,this._value=new o(String(this._is_negative?-t:t)),this._offset=0,this.canonicalize(),this},n.prototype.parse_json=function(t){switch(typeof t){case"string":var e=t.match(/^([^/]+)\/([^/]+)(?:\/(.+))?$/);e?(this._currency=u.from_json(e[2]),this._issuer=e[3]?a.from_json(e[3]):a.from_json("1"),this.parse_value(e[1])):(this.parse_native(t),this._currency=u.from_json("0"),this._issuer=a.from_json("0"));break;case"number":this.parse_json(String(t));break;case"object":if(null===t)break;t instanceof n?t.copyTo(this):t.hasOwnProperty("value")&&(this._currency.parse_json(t.currency,!0),"string"==typeof t.issuer&&this._issuer.parse_json(t.issuer),this.parse_value(t.value));break;default:this._value=0/0}return this},n.prototype.parse_native=function(t){var e;if("string"==typeof t&&(e=t.match(/^(-?)(\d*)(\.\d{0,6})?$/)),e){if(void 0===e[3])this._value=new o(e[2]);else{var r=new o(e[2]).multiply(h.bi_xns_unit),n=new o(e[3]).multiply(new o(String(Math.pow(10,1+h.xns_precision-e[3].length))));this._value=r.add(n)}this._is_native=!0,this._offset=0,this._is_negative=!!e[1]&&0!==this._value.compareTo(o.ZERO),this._value.compareTo(h.bi_xns_max)>0&&(this._value=0/0)}else this._value=0/0;return this},n.prototype.parse_value=function(t){switch(this._is_native=!1,typeof t){case"number":this._is_negative=0>t,this._value=new o(Math.abs(t)),this._offset=0,this.canonicalize();break;case"string":var e=t.match(/^(-?)(\d+)$/),r=!e&&t.match(/^(-?)(\d*)\.(\d*)$/),n=!n&&t.match(/^(-?)(\d*)e(-?\d+)$/);if(n)this._value=new o(n[2]),this._offset=parseInt(n[3]),this._is_negative=!!n[1],this.canonicalize();else if(r){var i=new o(r[2]),s=new o(r[3]),a=r[3].length;this._value=i.multiply(h.bi_10.clone().pow(a)).add(s),this._offset=-a,this._is_negative=!!r[1],this.canonicalize()}else e?(this._value=new o(e[2]),this._offset=0,this._is_negative=!!e[1],this.canonicalize()):this._value=0/0;break;default:this._value=t instanceof o?t:0/0}return this},n.prototype.set_currency=function(t){return this._currency=u.from_json(t),this._is_native=this._currency.is_native(),this},n.prototype.set_issuer=function(t){return this._issuer=t instanceof a?t:a.from_json(t),this},n.prototype.subtract=function(t){return this.add(n.from_json(t).negate())},n.prototype.to_number=function(t){var e=this.to_text(t);return"string"==typeof e?Number(e):e},n.prototype.to_text=function(t){var e=0/0;if(this._is_native)this.is_valid()&&this._value.compareTo(h.bi_xns_max)<=0&&(e=this._value.toString());else if(this.is_zero())e="0";else if(this._offset&&(this._offset<-25||this._offset>-4))e=this._value.toString()+"e"+this._offset;else{var r="000000000000000000000000000"+this._value.toString()+"00000000000000000000000",n=r.substring(0,this._offset+43),i=r.substring(this._offset+43),s=n.match(/[1-9].*$/),o=i.match(/[1-9]0*$/);e=""+(s?s[0]:"0")+(o?"."+i.substring(0,1+i.length-o[0].length):"")}return!t&&"number"==typeof e&&isNaN(e)?e="0":this._is_negative&&(e="-"+e),e},n.prototype.applyInterest=function(t){if(!this._currency.has_interest())return this;var e=this._currency.get_interest_at(t),r=n.from_json(""+e+"/1/1");return r.is_valid()?this.multiply(r):void 0},n.prototype.to_human=function(t){if(t=t||{},!this.is_valid())return"";"undefined"==typeof t.signed&&(t.signed=!0),"undefined"==typeof t.group_sep&&(t.group_sep=!0),t.group_width=t.group_width||3;var e=this;t.reference_date&&(e=this.applyInterest(t.reference_date));for(var r=e._is_native?h.xns_precision:-e._offset,n=h.bi_10.clone().pow(r),s=e._value.divide(n).toString(),o=e._value.mod(n).toString();o.length<r;)o="0"+o;if(s=s.replace(/^0*/,""),o=o.replace(/0*$/,""),o.length||!t.skip_empty_fraction){if("number"==typeof t.precision&&(0===t.precision&&o.charCodeAt(0)>=53&&(s=(Number(s)+1).toString()),o=o.slice(0,t.precision)),"number"==typeof t.max_sig_digits){var a=0===+s,c=a?0:s.length,u=a?o.replace(/^0*/,""):o;c+=u.length;var f=c-t.max_sig_digits;f=Math.max(f,0),f=Math.min(f,o.length),f>0&&(o=o.slice(0,-f))}if("number"==typeof t.min_precision)for(;o.length<t.min_precision;)o+="0"}t.group_sep&&("string"!=typeof t.group_sep&&(t.group_sep=","),s=i.chunkString(s,t.group_width,!0).join(t.group_sep));var l="";return t.signed&&this._is_negative&&("string"!=typeof t.signed&&(t.signed="-"),l+=t.signed),l+=s.length?s:"0",l+=o.length?"."+o:""},n.prototype.to_human_full=function(t){t=t||{};var e=this.to_human(t),r=this._currency.to_human(),n=this._issuer.to_json(t),i=i=this.is_native?e+"/"+r:e+"/"+r+"/"+n;return i},n.prototype.to_json=function(){var t;if(this._is_native)t=this.to_text();else{var e={value:this.to_text(),currency:this._currency.to_json()};this._issuer.is_valid()&&(e.issuer=this._issuer.to_json()),t=e}return t},n.prototype.to_text_full=function(t){return this._value instanceof o?this._is_native?this.to_human()+"/XRP":this.to_text()+"/"+this._currency.to_json()+"/"+this._issuer.to_json(t):0/0},n.prototype.not_equals_why=function(t,e){var r=!1;if("string"==typeof t)r=this.not_equals_why(n.from_json(t));else if(t instanceof n)if(this.is_valid()&&t.is_valid())if(this._is_native!==t._is_native)r="Native mismatch.";else{var i=this._is_native?"XRP":"Non-XRP";this._value.equals(t._value)&&this._offset===t._offset?this._is_negative!==t._is_negative?r=i+" sign differs.":this._is_native||(this._currency.equals(t._currency)?e||this._issuer.equals(t._issuer)||(r="Non-XRP issuer differs: "+t._issuer.to_json()+"/"+this._issuer.to_json()):r="Non-XRP currency differs."):r=i+" value differs."}else r="Invalid amount.";else r="Wrong constructor.";return r},e.Amount=n,e.Currency=u,e.Seed=c,e.UInt160=a},4:function(t,e,r){function n(t,e){function r(t){~n.subscribeEvents.indexOf(t)&&(!f._subs&&f._remote._connected&&f._remote.request_subscribe().add_account(f._account_id).broadcast(),f._subs+=1)}function s(t){~n.subscribeEvents.indexOf(t)&&(f._subs-=1,!f._subs&&f._remote._connected&&f._remote.request_unsubscribe().add_account(f._account_id).broadcast())}function u(t){f._account.is_valid()&&f._subs&&t.add_account(f._account_id)}function h(t){if(t.mmeta){var e=!1;t.mmeta.each(function(t){var r=t.fields.Account===f._account_id,n=r&&"AccountRoot"===t.entryType;n&&(o(f._entry,t.fieldsNew,t.fieldsFinal),e=!0)}),e&&f.emit("entry",f._entry)}}i.call(this);var f=this;return this._remote=t,this._account=a.from_json(e),this._account_id=this._account.to_json(),this._subs=0,this._entry={},this.on("newListener",r),this.on("removeListener",s),this._remote.on("prepare_subscribe",u),this.on("transaction",h),this._transactionManager=new c(this),this}var i=r(31).EventEmitter,s=r(32),o=r(35);r(3).Amount;var a=r(8).UInt160,c=r(21).TransactionManager;s.inherits(n,i),n.subscribeEvents=["transaction","entry"],n.prototype.toJson=function(){return this._account.to_json()},n.prototype.isValid=function(){return this._account.is_valid()},n.prototype.getInfo=function(t){return this._remote.request_account_info(this._account_id,t)},n.prototype.entry=function(t){function e(e,n){e?t(e):(o(r._entry,n.account_data),r.emit("entry",r._entry),t(null,n))}var r=this,t="function"==typeof t?t:function(){};return this.getInfo(e),this},n.prototype.getNextSequence=function(t){function e(e,r){e&&"object"==typeof e&&"object"==typeof e.remote&&"actNotFound"===e.remote.error?t(null,0):e?t(e):t(null,r.account_data.Sequence)}var t="function"==typeof t?t:function(){};return this.getInfo(e),this},n.prototype.lines=function(t){function e(e,n){e?t(e):(r._lines=n.lines,r.emit("lines",r._lines),t(null,n))}var r=this,t="function"==typeof t?t:function(){};return this._remote.requestAccountLines(this._account_id,e),this},n.prototype.line=function(t,e,r){var n=this,r="function"==typeof r?r:function(){};return n.lines(function(n,i){if(n)r(n);else{var s=i.lines.filter(function(r){return r.account===e&&r.currency===t?r:void 0})[0];r(null,s)}}),this},n.prototype.notify=n.prototype.notifyTx=function(t){if(this._subs){this.emit("transaction",t);var e=t.transaction.Account;if(!e)return;var r=e===this._account_id;this.emit(r?"transaction-outbound":"transaction-inbound",t)}},n.prototype.submit=function(t){this._transactionManager.submit(t)},e.Account=n},5:function(t,e,r){function n(t){i.call(this);var e=this;this.remote=t,this.tx_json={Flags:0},this._secret=void 0,this._build_path=!1,this.state="unsubmitted",this.finalized=!1,this.previousSigningHash=void 0,this.submitIndex=void 0,this.canonical="object"==typeof t?!!t.canonical_signing:!0,this.submittedIDs=[],this.once("success",function(t){e.setState("validated"),e.finalize(t),e.emit("cleanup",t)}),this.once("error",function(t){e.setState("failed"),e.finalize(t),e.emit("cleanup",t)}),this.once("submitted",function(){e.setState("submitted")}),this.once("proposed",function(){e.setState("pending")})}var i=r(31).EventEmitter,s=r(32),o=r(15),a=r(15).sjcl,c=r(3).Amount,u=r(3).Currency,h=r(3).UInt160,f=r(10).Seed,l=r(12).SerializedObject,p=r(13).RippleError,_=r(22),d=r(17);s.inherits(n,i),n.fee_units={"default":10},n.flags={Universal:{FullyCanonicalSig:2147483648},AccountSet:{RequireDestTag:65536,OptionalDestTag:131072,RequireAuth:262144,OptionalAuth:524288,DisallowXRP:1048576,AllowXRP:2097152},TrustSet:{SetAuth:65536,NoRipple:131072,ClearNoRipple:262144},OfferCreate:{Passive:65536,ImmediateOrCancel:131072,FillOrKill:262144,Sell:524288},Payment:{NoRippleDirect:65536,PartialPayment:131072,LimitQuality:262144}},n.set_clear_flags={AccountSet:{asfRequireDest:1,asfRequireAuth:2,asfDisallowXRP:3,asfDisableMaster:4}},n.formats=r(14).tx,n.prototype.consts={telLOCAL_ERROR:-399,temMALFORMED:-299,tefFAILURE:-199,terRETRY:-99,tesSUCCESS:0,tecCLAIMED:100},n.from_json=function(t){return(new n).parseJson(t)},n.prototype.parseJson=function(t){return this.tx_json=t,this},n.prototype.isTelLocal=function(t){return t>=this.consts.telLOCAL_ERROR&&t<this.consts.temMALFORMED},n.prototype.isTemMalformed=function(t){return t>=this.consts.temMALFORMED&&t<this.consts.tefFAILURE},n.prototype.isTefFailure=function(t){return t>=this.consts.tefFAILURE&&t<this.consts.terRETRY},n.prototype.isTerRetry=function(t){return t>=this.consts.terRETRY&&t<this.consts.tesSUCCESS},n.prototype.isTepSuccess=function(t){return t>=this.consts.tesSUCCESS},n.prototype.isTecClaimed=function(t){return t>=this.consts.tecCLAIMED},n.prototype.isRejected=function(t){return this.isTelLocal(t)||this.isTemMalformed(t)||this.isTefFailure(t)},n.prototype.setState=function(t){this.state!==t&&(this.state=t,this.emit("state",t),this.emit("save"))},n.prototype.finalize=function(t){return this.finalized=!0,this.result?(this.result.ledger_index=t.ledger_index,this.result.ledger_hash=t.ledger_hash):(this.result=t,this.result.tx_json=this.tx_json),this},n.prototype._accountSecret=function(t){return this.remote.secrets[t]},n.prototype.getFee=n.prototype.feeUnits=function(){return n.fee_units["default"]},n.prototype._getServer=function(){for(var t,e=this.remote._servers,r=1/0,n=0;n<e.length;n++){var i=e[n];if(i._connected){var s=i.computeFee(this);r>s&&(t=i,r=s)}}return t},n.prototype.complete=function(){if(!this._secret&&!(this._secret=this._accountSecret(this.tx_json.Account)))return this.emit("error",new p("tejSecretUnknown","Missing secret")),!1;if("undefined"==typeof this.tx_json.SigningPubKey)try{var t=f.from_json(this._secret),e=t.get_key(this.tx_json.Account);this.tx_json.SigningPubKey=e.to_hex_pub()}catch(r){return this.emit("error",new p("tejSecretInvalid","Invalid secret")),!1}return this.remote.trusted||this.remote.local_signing?(this.remote&&"undefined"==typeof this.tx_json.Fee&&(this.remote.local_fee||!this.remote.trusted)&&(this._server=this._getServer(),this.tx_json.Fee=this._server.computeFee(this)),Number(this.tx_json.Fee)>this._maxFee?(tx.emit("error",new p("tejMaxFeeExceeded","Max fee exceeded")),!1):(this.remote&&this.remote.local_signing&&this.canonical&&(this.tx_json.Flags|=n.flags.Universal.FullyCanonicalSig,this.tx_json.Flags=this.tx_json.Flags>>>0),this.tx_json)):(this.emit("error",new p("tejServerUntrusted","Attempt to give secret to untrusted server")),!1)},n.prototype.serialize=function(){return l.from_json(this.tx_json)},n.prototype.signingHash=function(){return this.hash(d.testnet?"HASH_TX_SIGN_TESTNET":"HASH_TX_SIGN")},n.prototype.hash=function(t,e){if("string"==typeof t){if("undefined"==typeof _[t])throw new Error("Unknown hashing prefix requested.");t=_[t]}else t||(t=_.HASH_TX_ID);var r=l.from_json(this.tx_json).hash(t);return e?r:r.to_hex()},n.prototype.sign=function(){var t=f.from_json(this._secret),e=this.tx_json.TxnSignature;delete this.tx_json.TxnSignature;var r=this.signingHash();if(e&&r===this.previousSigningHash)return this.tx_json.TxnSignature=e,this;var n=t.get_key(this.tx_json.Account),i=n.sign(r,0),s=a.codec.hex.fromBits(i).toUpperCase();return this.tx_json.TxnSignature=s,this.previousSigningHash=r,this},n.prototype.addId=function(t){-1===this.submittedIDs.indexOf(t)&&(this.submittedIDs.unshift(t),this.emit("signed",t),this.emit("save"))},n.prototype.findId=function(t){for(var e,r=0;r<this.submittedIDs.length;r++){var n=this.submittedIDs[r];if(e=t[n])break}return e},n.prototype.buildPath=function(t){return this._build_path=t,this},n.prototype.destinationTag=function(t){return void 0!==t&&(this.tx_json.DestinationTag=t),this},n.prototype.invoiceID=function(t){if("string"==typeof t){for(;t.length<64;)t+="0";this.tx_json.InvoiceID=t}return this},n.prototype.clientID=function(t){return"string"==typeof t&&(this._clientID=t),this},n.prototype.lastLedger=function(t){return"number"==typeof t&&(this._setLastLedger=!0,this.tx_json.LastLedgerSequence=t),this},n._pathRewrite=function(t){return t.map(function(t){var e={};return t.hasOwnProperty("account")&&(e.account=h.json_rewrite(t.account)),t.hasOwnProperty("issuer")&&(e.issuer=h.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=u.json_rewrite(t.currency)),t.hasOwnProperty("type_hex")&&(e.type_hex=t.type_hex),e})},n.prototype.pathAdd=function(t){return Array.isArray(t)&&(this.tx_json.Paths=this.tx_json.Paths||[],this.tx_json.Paths.push(n._pathRewrite(t))),this},n.prototype.paths=function(t){if(Array.isArray(t))for(var e=0,r=t.length;r>e;e++)this.pathAdd(t[e]);return this},n.prototype.secret=function(t){return this._secret=t,this},n.prototype.sendMax=function(t){return t&&(this.tx_json.SendMax=c.json_rewrite(t)),this},n.prototype.sourceTag=function(t){return t&&(this.tx_json.SourceTag=t),this},n.prototype.transferRate=function(t){if(this.tx_json.TransferRate=Number(t),this.tx_json.TransferRate<1e9)throw new Error("invalidTransferRate");return this},n.prototype.setFlags=function(t){if(!t)return this;for(var e=Array.isArray(t)?t:Array.prototype.slice.call(arguments),r=n.flags[this.tx_json.TransactionType]||{},i=0,s=e.length;s>i;i++){var o=e[i];if(!r.hasOwnProperty(o))return this.emit("error",new p("tejInvalidFlag"));this.tx_json.Flags+=r[o]}return this},n.prototype.accountSet=function(t,e,r){function i(t){return"number"==typeof t?t:o[t]||o["asf"+t]}if("object"==typeof t){var s=t;t=s.source||s.from||s.account,e=s.set_flag||s.set,r=s.clear_flag||s.clear}if(!h.is_valid(t))throw new Error("Source address invalid");this.tx_json.TransactionType="AccountSet",this.tx_json.Account=h.json_rewrite(t);var o=n.set_clear_flags.AccountSet;return e&&(e=i(e))&&(this.tx_json.SetFlag=e),r&&(r=i(r))&&(this.tx_json.ClearFlag=r),this},n.prototype.claim=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.signature,r=i.public_key,e=i.generator,t=i.source||i.from||i.account}return this.tx_json.TransactionType="Claim",this.tx_json.Generator=e,this.tx_json.PublicKey=r,this.tx_json.Signature=n,this},n.prototype.offerCancel=function(t,e){if("object"==typeof t){var r=t;e=r.sequence,t=r.source||r.from||r.account}if(!h.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCancel",this.tx_json.Account=h.json_rewrite(t),this.tx_json.OfferSequence=Number(e),this},n.prototype.offerCreate=function(t,e,r,n,i){if("object"==typeof t){var s=t;i=s.cancel_sequence,n=s.expiration,r=s.taker_gets||s.sell,e=s.taker_pays||s.buy,t=s.source||s.from||s.account}if(!h.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCreate",this.tx_json.Account=h.json_rewrite(t),this.tx_json.TakerPays=c.json_rewrite(e),this.tx_json.TakerGets=c.json_rewrite(r),n&&(this.tx_json.Expiration=o.time.toRipple(n)),i&&(this.tx_json.OfferSequence=Number(i)),this},n.prototype.passwordFund=function(t,e){if("object"==typeof t){var r=t;e=r.destination||r.to,t=r.source||r.from}if(!h.is_valid(e))throw new Error("Destination address invalid");return this.tx_json.TransactionType="PasswordFund",this.tx_json.Destination=h.json_rewrite(e),this},n.prototype.passwordSet=function(t,e,r,n,i){if("object"==typeof t){var s=t;i=s.signature,n=s.public_key,r=s.generator,e=s.authorized_key,t=s.source||s.from||s.account}if(!h.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="PasswordSet",this.tx_json.RegularKey=e,this.tx_json.Generator=r,this.tx_json.PublicKey=n,this.tx_json.Signature=i,this},n.prototype.setRegularKey=function(t,e){if("object"==typeof t){var r=t;t=r.address||r.account||r.from,e=r.regular_key}if(!h.is_valid(t))throw new Error("Source address invalid");if(!h.is_valid(e))throw new Error("RegularKey must be a valid Ripple Address (a Hash160 of the public key)");this.tx_json.TransactionType="SetRegularKey",this.tx_json.Account=h.json_rewrite(t),this.tx_json.RegularKey=h.json_rewrite(e)},n.prototype.payment=function(t,e,r){if("object"==typeof t){var n=t;r=n.amount,e=n.destination||n.to,t=n.source||n.from||n.account}if(t.invoiceID&&this.invoiceID(t.invoiceID),!h.is_valid(t))throw new Error("Payment source address invalid");if(!h.is_valid(e))throw new Error("Payment destination address invalid");return/^[\d]+[A-Z]{3}$/.test(r)&&(r=c.from_human(r)),this.tx_json.TransactionType="Payment",this.tx_json.Account=h.json_rewrite(t),this.tx_json.Amount=c.json_rewrite(r),this.tx_json.Destination=h.json_rewrite(e),this},n.prototype.trustSet=n.prototype.rippleLineSet=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.quality_out,r=i.quality_in,e=i.limit,t=i.source||i.from||i.account}if(!h.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="TrustSet",this.tx_json.Account=h.json_rewrite(t),void 0!==e&&(this.tx_json.LimitAmount=c.json_rewrite(e)),r&&(this.tx_json.QualityIn=r),n&&(this.tx_json.QualityOut=n),this},n.prototype.walletAdd=function(t,e,r,n,i){if("object"==typeof t){var s=t;i=s.signature,n=s.public_key,r=s.authorized_key,e=s.amount,t=s.source||s.from||s.account}if(!h.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="WalletAdd",this.tx_json.Amount=c.json_rewrite(e),this.tx_json.RegularKey=r,this.tx_json.PublicKey=n,this.tx_json.Signature=i,this},n.prototype.submit=function(t){function e(t,e){t instanceof p||(t=new p(t,e)),n.callback(t)}function r(t){n.callback(null,t)}var n=this;this.callback="function"==typeof t?t:function(){},this._errorHandler=e,this._successHandler=r,this.on("error",function(){});var i=this.tx_json.Account;return"string"!=typeof i?this.emit("error",new p("tejInvalidAccount","Account is unspecified")):(this.remote.account(i).submit(this),this)},n.prototype.transactionManager=function(){return this.remote.account(this.tx_json.Account)._transactionManager},n.prototype.abort=function(t){if(!this.finalized){var t="function"==typeof t?t:function(){};this.once("final",t),this.emit("abort")}},n.prototype.iff=function(t){this._iff=t},n.prototype.summary=function(){return n.summary.call(this)},n.summary=function(){var t={tx_json:this.tx_json,clientID:this._clientID,submittedIDs:this.submittedIDs,submissionAttempts:this.attempts,submitIndex:this.submitIndex,initialSubmitIndex:this.initialSubmitIndex,lastLedgerSequence:this.lastLedgerSequence,state:this.state,server:this._server?this._server._opts.url:void 0,finalized:this.finalized};return this.result&&(t.result={engine_result:this.result.engine_result,engine_result_message:this.result.engine_result_message,ledger_hash:this.result.ledger_hash,ledger_index:this.result.ledger_index,transaction_hash:this.result.tx_json.hash}),t},e.Transaction=n},6:function(t,e,r){var n=r(35),i=r(8).UInt160,s=r(23).Float,o=r(15),a=n(function(){this._value=0/0,this._update()},i);a.prototype=n({},i.prototype),a.prototype.constructor=a,a.HEX_CURRENCY_BAD="0000000000000000000000005852500000000000",a.from_json=function(t,e){return t instanceof this?t.clone():(new this).parse_json(t,e)},a.prototype.parse_json=function(t,e){switch(this._value=0/0,typeof t){case"string":if(!t||/^(0|XRP)$/.test(t))e?this.parse_hex(a.HEX_CURRENCY_BAD):this.parse_hex(a.HEX_ZERO);else if(/^[a-zA-Z0-9]{3}$/.test(t)){var r=t.toUpperCase(),n=o.arraySet(20,0);n[12]=255&r.charCodeAt(0),n[13]=255&r.charCodeAt(1),n[14]=255&r.charCodeAt(2),this.parse_bytes(n)}else this.parse_hex(t);break;case"number":isNaN(t)||this.parse_number(t);break;case"object":t instanceof a&&(this._value=t.copyTo({})._value,this._update())}return this},a.prototype._update=function(){var t=this.to_bytes(),e=!0;if(!t)return"XRP";this._native=!1,this._type=-1,this._interest_start=new Date,this._interest_period=0/0,this._iso_code="";for(var r=0;20>r;r++)e=e&&(12===r||13===r||14===r||0===t[r]);e?(this._iso_code=String.fromCharCode(t[12])+String.fromCharCode(t[13])+String.fromCharCode(t[14]),"\0\0\0"===this._iso_code&&(this._native=!0,this._iso_code="XRP"),this._type=0):1===t[0]&&(this._iso_code=String.fromCharCode(t[1])+String.fromCharCode(t[2])+String.fromCharCode(t[3]),this._type=1,this._interest_start=(t[4]<<24)+(t[5]<<16)+(t[6]<<8)+t[7],this._interest_period=s.fromBytes(t.slice(8,16)))},a.prototype.is_native=function(){return this._native},a.prototype.has_interest=function(){return 1===this._type&&this._interest_start&&!isNaN(this._interest_period)},a.prototype.get_interest_at=function(t){return this.has_interest?(t instanceof Date&&(t=o.fromTimestamp(t.getTime())),Math.pow(Math.E,(t-this._interest_start)/this._interest_period)):1},a.prototype.to_json=function(){if(!this.is_valid())return"XRP";if(/^[A-Z0-9]{3}$/.test(this._iso_code)&&!this.has_interest())return this._iso_code;var t=this.to_hex();return t===a.HEX_ONE?1:t},a.prototype.to_human=function(){return/^[A-Z0-9]{3}$/.test(this._iso_code)?this._iso_code:this.to_json()},e.Currency=a},7:function(t,e,r){function n(t){return s.codec.bytes.fromBits(s.hash.sha256.hash(s.codec.bytes.toBits(t)))}function i(t){return n(n(t))}var s=r(15).sjcl,o=r(15),a=r(35),c=o.jsbn.BigInteger,u={},h=u.alphabets={ripple:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",tipple:"RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"};a(u,{VER_NONE:1,VER_NODE_PUBLIC:28,VER_NODE_PRIVATE:32,VER_ACCOUNT_ID:0,VER_ACCOUNT_PUBLIC:35,VER_ACCOUNT_PRIVATE:34,VER_FAMILY_GENERATOR:41,VER_FAMILY_SEED:33}),u.encode=function(t,e){for(var r=h[e||"ripple"],n=new c(String(r.length)),i=new c,s=new c,o=new c(t),a=[];o.compareTo(c.ZERO)>0;)o.divRemTo(n,i,s),i.copyTo(o),a.push(r[s.intValue()]);for(var u=0;u!==t.length&&!t[u];u+=1)a.push(r[0]);return a.reverse().join("")},u.decode=function(t,e){if("string"!=typeof t)return void 0;var r,n=h[e||"ripple"],i=new c(String(n.length)),s=new c;for(r=0;r!=t.length&&t[r]===n[0];r+=1);for(;r!==t.length;r+=1){var a=n.indexOf(t[r]);if(0>a)return void 0;var u=new c;u.fromInt(a),s=s.multiply(i).add(u)}for(var f=s.toByteArray().map(function(t){return t?0>t?256+t:t:0}),l=0;l!=f.length&&!f[l];)l+=1;l&&(f=f.slice(l));for(var p=0;p!==t.length&&t[p]===n[0];)p+=1;return[].concat(o.arraySet(p,0),f)},u.verify_checksum=function(t){for(var e=i(t.slice(0,-4)).slice(0,4),r=t.slice(-4),n=!0,s=0;4>s;s++)if(e[s]!==r[s]){n=!1;break}return n},u.encode_check=function(t,e,r){var i=[].concat(t,e),s=n(n(i)).slice(0,4);return u.encode([].concat(i,s),r)},u.decode_check=function(t,e,r){var n=u.decode(e,r);if(!n||n.length<5)return 0/0;if("number"==typeof t&&n[0]!==t)return 0/0;if(Array.isArray(t)){for(var i=!1,s=0,o=t.length;o>s;s++)i|=t[s]===n[0];if(!i)return 0/0}return u.verify_checksum(n)?(n[0]=0,new c(n.slice(0,-4),256)):0/0},e.Base=u},8:function(t,e,r){r(15).sjcl;var n=r(15),i=r(17),s=r(35),o=n.jsbn.BigInteger,a=r(24).UInt,c=r(7).Base,u=s(function(){this._value=0/0,this._version_byte=void 0,this._update()},a);u.width=20,u.prototype=s({},a.prototype),u.prototype.constructor=u,u.ACCOUNT_ZERO="rrrrrrrrrrrrrrrrrrrrrhoLvTp",u.ACCOUNT_ONE="rrrrrrrrrrrrrrrrrrrrBZbvji";var h=u.HEX_ZERO="0000000000000000000000000000000000000000",f=u.HEX_ONE="0000000000000000000000000000000000000001";u.STR_ZERO=n.hexToString(h),u.STR_ONE=n.hexToString(f),u.prototype.set_version=function(t){return this._version_byte=t,this},u.prototype.get_version=function(){return this._version_byte},u.prototype.parse_json=function(t){return i.accounts&&t in i.accounts&&(t=i.accounts[t].account),"number"!=typeof t||isNaN(t)?"string"!=typeof t?this._value=0/0:"r"===t[0]?(this._value=c.decode_check(c.VER_ACCOUNT_ID,t),this._version_byte=c.VER_ACCOUNT_ID):this.parse_hex(t):(this._value=new o(String(t)),this._version_byte=c.VER_ACCOUNT_ID),this._update(),this},u.prototype.parse_generic=function(t){return a.prototype.parse_generic.call(this,t),isNaN(this._value)&&"string"==typeof t&&"r"===t[0]&&(this._value=c.decode_check(c.VER_ACCOUNT_ID,t)),this._update(),this},u.prototype.to_json=function(t){if(t=t||{},this._value instanceof o){if("number"==typeof this._version_byte){var e=c.encode_check(this._version_byte,this.to_bytes());return t.gateways&&e in t.gateways&&(e=t.gateways[e]),e}return this.to_hex()}return 0/0},e.UInt160=u},9:function(t,e,r){r(15).sjcl;var n=r(15);r(17);var i=r(35);n.jsbn.BigInteger;var s=r(24).UInt;r(7).Base;var o=i(function(){this._value=0/0},s);o.width=32,o.prototype=i({},s.prototype),o.prototype.constructor=o;var a=o.HEX_ZERO="0000000000000000000000000000000000000000000000000000000000000000",c=o.HEX_ONE="0000000000000000000000000000000000000000000000000000000000000001";o.STR_ZERO=n.hexToString(a),o.STR_ONE=n.hexToString(c),e.UInt256=o},10:function(t,e,r){function n(t,e){return[].concat(t,e>>24,255&e>>16,255&e>>8,255&e)}function i(t){return o.bitArray.bitSlice(o.hash.sha512.hash(o.codec.bytes.toBits(t)),0,256)}var s=r(15),o=s.sjcl,a=r(35),c=s.jsbn.BigInteger,u=r(7).Base,h=r(24).UInt;r(9).UInt256;var f=r(25).KeyPair,l=a(function(){this._curve=o.ecc.curves.c256,this._value=0/0},h);l.width=16,l.prototype=a({},h.prototype),l.prototype.constructor=l,l.prototype.parse_json=function(t){return"string"==typeof t?t.length?"s"===t[0]?this._value=u.decode_check(u.VER_FAMILY_SEED,t):32===t.length?this._value=this.parse_hex(t):this.parse_passphrase(t):this._value=0/0:this._value=0/0,this},l.prototype.parse_passphrase=function(t){if("string"!=typeof t)throw new Error("Passphrase must be a string");var e=o.hash.sha512.hash(o.codec.utf8String.toBits(t)),r=o.bitArray.bitSlice(e,0,128);return this.parse_bits(r),this},l.prototype.to_json=function(){if(!(this._value instanceof c))return 0/0;var t=u.encode_check(u.VER_FAMILY_SEED,this.to_bytes());return t},l.prototype.get_key=function(){if(!this.is_valid())throw new Error("Cannot generate keys from invalid seed!");var t,e,r=this._curve,s=0,a=0;do t=o.bn.fromBits(i(n(this.to_bytes(),a))),a++;while(!r.r.greaterEquals(t));e=r.G.mult(t);var c;a=0;do c=o.bn.fromBits(i(n(n(e.toBytesCompressed(),s),a))),a++;while(!r.r.greaterEquals(c));return c=c.add(t).mod(r.r),f.from_bn_secret(c)},e.Seed=l},11:function(t,e,r){function n(t){var e=this;this.nodes=[],t.AffectedNodes.forEach(function(t){var r={};(r.diffType=e.diffType(t))&&(t=t[r.diffType],r.entryType=t.LedgerEntryType,r.ledgerIndex=t.LedgerIndex,r.fields=i({},t.PreviousFields,t.NewFields,t.FinalFields),r.fieldsPrev=t.PreviousFields||{},r.fieldsNew=t.NewFields||{},r.fieldsFinal=t.FinalFields||{},e.nodes.push(r))
})}var i=r(35),s=r(15),o=r(8).UInt160,a=r(3).Amount;n.node_types=["CreatedNode","ModifiedNode","DeletedNode"],n.prototype.diffType=function(t){for(var e=!1,r=0;r<n.node_types.length;r++){var i=n.node_types[r];if(t.hasOwnProperty(i)){e=i;break}}return e},n.prototype.each=function(t){for(var e=0,r=this.nodes.length;r>e;e++)t(this.nodes[e],e)},["forEach","map","filter","every","reduce"].forEach(function(t){n.prototype[t]=function(){return Array.prototype[t].apply(this.nodes,arguments)}});var c=["LowLimit","HighLimit","TakerPays","TakerGets"];n.prototype.getAffectedAccounts=function(){var t=[];return this.nodes.forEach(function(e){var r="CreatedNode"===e.diffType?e.fieldsNew:e.fieldsFinal;for(var n in r){var i=r[n];if("string"==typeof i&&o.is_valid(i))t.push(i);else if(-1!==c.indexOf(n)){var s=a.from_json(i),u=s.issuer();u.is_valid()&&!u.is_zero()&&t.push(u.to_json())}}}),s.arrayUnique(t)},n.prototype.getAffectedBooks=function(){var t=[];return this.nodes.forEach(function(e){if("Offer"===e.entryType){var r=a.from_json(e.fields.TakerGets),n=a.from_json(e.fields.TakerPays),i=r.currency().to_json();"XRP"!==i&&(i+="/"+r.issuer().to_json());var s=n.currency().to_json();"XRP"!==s&&(s+="/"+n.issuer().to_json());var o=[i,s].join(":");e.bookKey=o,t.push(o)}}),s.arrayUnique(t)},e.Meta=n},12:function(t,e,r){!function(t,r){function n(t){if(Array.isArray(t)||r&&r.isBuffer(t))this.buffer=t;else if("string"==typeof t)this.buffer=f.codec.bytes.fromBits(f.codec.hex.toBits(t));else{if(t)throw new Error("Invalid buffer passed.");this.buffer=[]}this.pointer=0}function i(t){return function(e){var r=this.pointer,n=r+e;if(n>this.buffer.length)throw new Error("Buffer length exceeded");var i=this.buffer.slice(r,n);return t&&(this.pointer=n),i}}var s=t(14),o=t(35),a=t(26),c=t(9).UInt256,u=t(33),h=t(15),f=h.sjcl,l=h.jsbn.BigInteger,p={};Object.keys(s.tx).forEach(function(t){p[s.tx[t][0]]=t});var _={};Object.keys(s.ledger).forEach(function(t){_[s.ledger[t][0]]=t});var d={};Object.keys(s.ter).forEach(function(t){d[s.ter[t]]=t}),n.from_json=function(t){var e,t=o({},t),r=new n;if("number"==typeof t.TransactionType&&(t.TransactionType=n.lookup_type_tx(t.TransactionType),!t.TransactionType))throw new Error("Transaction type ID is invalid.");if("string"==typeof t.TransactionType){if(e=s.tx[t.TransactionType],!Array.isArray(e))throw new Error("Transaction type is invalid");e=e.slice(),t.TransactionType=e.shift()}else{if("undefined"!=typeof t.LedgerEntryType)throw new Error("Ledger entry binary format not yet implemented.");if("object"!=typeof t.AffectedNodes)throw new Error("Object to be serialized must contain either TransactionType, LedgerEntryType or AffectedNodes.");e=s.metadata}return n.check_no_missing_fields(e,t),r.serialize(e,t),r},n.check_no_missing_fields=function(t,e){for(var r=[],i=t.length-1;i>=0;i--){var o=t[i],a=o[0],c=o[1];s.REQUIRED===c&&null==e[a]&&r.push(a)}if(r.length>0){var u;throw u=null!=e.TransactionType?n.lookup_type_tx(e.TransactionType):"TransactionMetaData",new Error(u+" is missing fields: "+JSON.stringify(r))}},n.prototype.append=function(t){t instanceof n&&(t=t.buffer),this.buffer=this.buffer.concat(t),this.pointer+=t.length},n.prototype.resetPointer=function(){this.pointer=0},n.prototype.read=i(!0),n.prototype.peek=i(!1),n.prototype.to_bits=function(){return f.codec.bytes.toBits(this.buffer)},n.prototype.to_hex=function(){return f.codec.hex.fromBits(this.to_bits()).toUpperCase()},n.prototype.to_json=function(){var t=this.pointer;this.resetPointer();for(var e={};this.pointer<this.buffer.length;){var r=a.parse(this),i=r[0],s=r[1];e[i]=n.jsonify_structure(s,i)}return this.pointer=t,e},n.jsonify_structure=function(t,e){var r;switch(typeof t){case"number":switch(e){case"LedgerEntryType":r=_[t];break;case"TransactionResult":r=d[t];break;case"TransactionType":r=p[t];break;default:r=t}break;case"object":if(!t)break;if("function"==typeof t.to_json)r=t.to_json();else if(t instanceof l)r=t.toString(16).toUpperCase();else{r=new t.constructor;for(var i=Object.keys(t),s=0,o=i.length;o>s;s++){var a=i[s];r[a]=n.jsonify_structure(t[a],a)}}break;default:r=t}return r},n.prototype.serialize=function(t,e){a.Object.serialize(this,e,!0)},n.prototype.hash=function(t){var e=new n;return a.Int32.serialize(e,t),e.append(this.buffer),e.hash_sha512_half()},n.prototype.signing_hash=n.prototype.hash,n.prototype.hash_sha512_half=function(){var t=f.codec.bytes.toBits(this.buffer),e=f.bitArray.bitSlice(f.hash.sha512.hash(t),0,256);return c.from_hex(f.codec.hex.fromBits(e))},n.prototype.serialize_field=function(t,e){var r=t[0],n=t[1];if(t[2],a[t[3]],"undefined"!=typeof e[r])try{a.serialize(this,r,e[r])}catch(i){throw i.message='Error serializing "'+r+'": '+i.message,i}else if(n===s.REQUIRED)throw new Error("Missing required field "+r)},n.get_field_header=function(t,e){var r=[0];return t>15?r.push(255&t):r[0]+=(15&t)<<4,e>15?r.push(255&e):r[0]+=15&e,r},n.sort_typedef=function(t){function e(t,e){return t[3]!==e[3]?a[t[3]].id-a[e[3]].id:t[2]-e[2]}return u(Array.isArray(t)),t.sort(e)},n.lookup_type_tx=function(t){return u("number"==typeof t),p[t]},e.SerializedObject=n}(r,r(27).Buffer)},13:function(t,e,r){function n(t,e){switch(typeof t){case"object":s(this,t);break;case"string":this.result=t,this.result_message=e}this.engine_result=this.result=this.result||this.engine_result||this.error||"Error",this.engine_result_message=this.result_message=this.result_message||this.engine_result_message||this.error_message||"Error",this.result_message=this.message=this.result_message;var r;Error.captureStackTrace?Error.captureStackTrace(this,t||this):(r=(new Error).stack)&&(this.stack=r)}var i=r(32),s=r(35);i.inherits(n,Error),n.prototype.name="RippleError",e.RippleError=n},14:function(t,e){e.types=[void 0,"Int16","Int32","Int64","Hash128","Hash256","Amount","VL","Account",void 0,void 0,void 0,void 0,void 0,"Object","Array","Int8","Hash160","PathSet","Vector256"];var r=e.fields={1:{1:"LedgerEntryType",2:"TransactionType"},2:{2:"Flags",3:"SourceTag",4:"Sequence",5:"PreviousTxnLgrSeq",6:"LedgerSequence",7:"CloseTime",8:"ParentCloseTime",9:"SigningTime",10:"Expiration",11:"TransferRate",12:"WalletSize",13:"OwnerCount",14:"DestinationTag",16:"HighQualityIn",17:"HighQualityOut",18:"LowQualityIn",19:"LowQualityOut",20:"QualityIn",21:"QualityOut",22:"StampEscrow",23:"BondAmount",24:"LoadFee",25:"OfferSequence",26:"FirstLedgerSequence",27:"LastLedgerSequence",28:"TransactionIndex",29:"OperationLimit",30:"ReferenceFeeUnits",31:"ReserveBase",32:"ReserveIncrement",33:"SetFlag",34:"ClearFlag"},3:{1:"IndexNext",2:"IndexPrevious",3:"BookNode",4:"OwnerNode",5:"BaseFee",6:"ExchangeRate",7:"LowNode",8:"HighNode"},4:{1:"EmailHash"},5:{1:"LedgerHash",2:"ParentHash",3:"TransactionHash",4:"AccountHash",5:"PreviousTxnID",6:"LedgerIndex",7:"WalletLocator",8:"RootIndex",9:"AccountTxnID",16:"BookDirectory",17:"InvoiceID",18:"Nickname",19:"Feature"},6:{1:"Amount",2:"Balance",3:"LimitAmount",4:"TakerPays",5:"TakerGets",6:"LowLimit",7:"HighLimit",8:"Fee",9:"SendMax",16:"MinimumOffer",17:"RippleEscrow",18:"DeliveredAmount"},7:{1:"PublicKey",2:"MessageKey",3:"SigningPubKey",4:"TxnSignature",5:"Generator",6:"Signature",7:"Domain",8:"FundCode",9:"RemoveCode",10:"ExpireCode",11:"CreateCode",12:"MemoType",13:"MemoData"},8:{1:"Account",2:"Owner",3:"Destination",4:"Issuer",7:"Target",8:"RegularKey"},14:{1:void 0,2:"TransactionMetaData",3:"CreatedNode",4:"DeletedNode",5:"ModifiedNode",6:"PreviousFields",7:"FinalFields",8:"NewFields",9:"TemplateEntry",10:"Memo"},15:{1:void 0,2:"SigningAccounts",3:"TxnSignatures",4:"Signatures",5:"Template",6:"Necessary",7:"Sufficient",8:"AffectedNodes",9:"Memos"},16:{1:"CloseResolution",2:"TemplateEntryType",3:"TransactionResult"},17:{1:"TakerPaysCurrency",2:"TakerPaysIssuer",3:"TakerGetsCurrency",4:"TakerGetsIssuer"},18:{1:"Paths"},19:{1:"Indexes",2:"Hashes",3:"Features"}},n=e.fieldsInverseMap={};Object.keys(r).forEach(function(t){Object.keys(r[t]).forEach(function(e){n[r[t][e]]=[Number(t),Number(e)]})});var i=e.REQUIRED=0,s=e.OPTIONAL=1,o=e.DEFAULT=2,a=[["TransactionType",i],["Flags",s],["SourceTag",s],["Account",i],["Sequence",i],["Fee",i],["OperationLimit",s],["SigningPubKey",i],["TxnSignature",s]];e.tx={AccountSet:[3].concat(a,[["EmailHash",s],["WalletLocator",s],["WalletSize",s],["MessageKey",s],["Domain",s],["TransferRate",s]]),TrustSet:[20].concat(a,[["LimitAmount",s],["QualityIn",s],["QualityOut",s]]),OfferCreate:[7].concat(a,[["TakerPays",i],["TakerGets",i],["Expiration",s]]),OfferCancel:[8].concat(a,[["OfferSequence",i]]),SetRegularKey:[5].concat(a,[["RegularKey",i]]),Payment:[0].concat(a,[["Destination",i],["Amount",i],["SendMax",s],["Paths",o],["InvoiceID",s],["DestinationTag",s]]),Contract:[9].concat(a,[["Expiration",i],["BondAmount",i],["StampEscrow",i],["RippleEscrow",i],["CreateCode",s],["FundCode",s],["RemoveCode",s],["ExpireCode",s]]),RemoveContract:[10].concat(a,[["Target",i]]),EnableFeature:[100].concat(a,[["Feature",i]]),SetFee:[101].concat(a,[["Features",i],["BaseFee",i],["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i]])},e.ledger={AccountRoot:[97],Contract:[99],DirectoryNode:[100],Features:[102],GeneratorMap:[103],LedgerHashes:[104],Nickname:[110],Offer:[111],RippleState:[114],FeeSettings:[115]},e.metadata=[["TransactionIndex",i],["TransactionResult",i],["AffectedNodes",i]],e.ter={tesSUCCESS:0,tecCLAIM:100,tecPATH_PARTIAL:101,tecUNFUNDED_ADD:102,tecUNFUNDED_OFFER:103,tecUNFUNDED_PAYMENT:104,tecFAILED_PROCESSING:105,tecDIR_FULL:121,tecINSUF_RESERVE_LINE:122,tecINSUF_RESERVE_OFFER:123,tecNO_DST:124,tecNO_DST_INSUF_XRP:125,tecNO_LINE_INSUF_RESERVE:126,tecNO_LINE_REDUNDANT:127,tecPATH_DRY:128,tecUNFUNDED:129,tecMASTER_DISABLED:130,tecNO_REGULAR_KEY:131,tecOWNERS:132}},15:function(t,e,r){function n(t,e){return function(){console.log("%s: %s",n,arguments.toString),e(arguments)}}function i(t,e){for(var r=new Array(t),n=0;t>n;n++)r[n]=e;return r}function s(t){var e=[],r=0;for(t.length%2&&(e.push(String.fromCharCode(parseInt(t.substring(0,1),16))),r=1);r<t.length;r+=2)e.push(String.fromCharCode(parseInt(t.substring(r,r+2),16)));return e.join("")}function o(t){for(var e="",r=0;r<t.length;r++){var n=t.charCodeAt(r);e+=16>n?"0"+n.toString(16):n.toString(16)}return e}function a(t){for(var e=new Array(t.length),r=0;r<e.length;r+=1)e[r]=t.charCodeAt(r);return e}function c(t){return a(s(t))}function u(t,e,r){var n=[],i=0,s=t.length;for(r&&(i=t.length%e,i&&n.push(t.slice(0,i)));s>i;i+=e)n.push(t.slice(i,e+i));return n}function h(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:"."))}function f(t){for(var e={},r=[],n=0,i=t.length;i>n;n++){var s=t[n];e[s]||(r.push(s),e[s]=!0)}return r}function l(t){return 1e3*(t+946684800)}function p(t){return t instanceof Date&&(t=t.getTime()),Math.round(t/1e3)-946684800}Function.prototype.method=function(t,e){return this.prototype[t]=e,this},e.time={fromRipple:l,toRipple:p},e.trace=n,e.arraySet=i,e.hexToString=s,e.hexToArray=c,e.stringToArray=a,e.stringToHex=o,e.chunkString=u,e.assert=h,e.arrayUnique=f,e.toTimestamp=l,e.fromTimestamp=p,e.sjcl=r(28),e.jsbn=r(29)},16:function(t,e,r){function n(t,e){if(s.call(this),"object"!=typeof e)throw new TypeError("Server configuration is not an Object");e.host||(e.host=e.websocket_ip),e.port||(e.port=e.websocket_port),e.secure||(e.secure=e.websocket_ssl),"undefined"==typeof e.secure&&(e.secure=!1);var r=/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/;if(!r.test(e.host))throw new Error('Server host is malformed, use "host" and "port" server configuration');if("string"==typeof e.port&&(e.port=parseFloat(e.port)),"number"!=typeof e.port||e.port>>>0!==parseFloat(e.port)||e.port<1||e.port>65535)throw new TypeError('Server "port" must be an integer in range 1-65535');if("boolean"!=typeof e.secure)throw new TypeError('Server "secure" configuration is not a Boolean');var n=this;this._remote=t,this._opts=e,this._host=e.host,this._port=e.port,this._secure=e.secure,this._ws=void 0,this._connected=!1,this._shouldConnect=!1,this._state="offline",this._id=0,this._retry=0,this._requests={},this._load_base=256,this._load_factor=256,this._fee_ref=10,this._fee_base=10,this._reserve_base=void 0,this._reserve_inc=void 0,this._fee_cushion=this._remote.fee_cushion,this._opts.url=(e.secure?"wss://":"ws://")+e.host+":"+e.port,this.on("message",function(t){n._handleMessage(t)}),this.on("response_subscribe",function(t){n._handleResponseSubscribe(t)}),this.on("disconnect",function(){clearInterval(n._activityInterval)}),this.once("ledger_closed",function(){})}var i=r(32),s=r(31).EventEmitter,o=r(5).Transaction,a=r(3).Amount;r(15);var c=r(20).internal.sub("server");i.inherits(n,s),n.onlineStates=["syncing","tracking","proposing","validating","full"],n.prototype._setState=function(t){if(t!==this._state)switch(this._remote.trace&&c.info("set_state:",t),this._state=t,this.emit("state",t),t){case"online":this._connected=!0,this.emit("connect");break;case"offline":this._connected=!1,this.emit("disconnect")}},n.prototype._remoteAddress=function(){try{var t=this._ws._socket.remoteAddress}catch(e){}return t},n.websocketConstructor=function(){return r(30)},n.prototype.disconnect=function(){this._shouldConnect=!1,this._setState("offline"),this._ws&&this._ws.close()},n.prototype.reconnect=function(){this._ws&&(this.once("disconnect",this.connect.bind(this)),this.disconnect())},n.prototype.connect=function(){var t=this;if(!this._connected){this._remote.trace&&c.info("connect:",this._opts.url),this._ws&&this._ws.close();var e=n.websocketConstructor();if(!e)throw new Error("No websocket support detected!");var r=this._ws=new e(this._opts.url);this._shouldConnect=!0,t.emit("connecting"),r.onmessage=function(e){t.emit("message",e.data)},r.onopen=function(){r===t._ws&&(t.emit("socket_open"),t.request(t._remote._serverPrepareSubscribe()))},r.onerror=function(e){r===t._ws&&(t.emit("socket_error"),t._remote.trace&&c.info("onerror:",t._opts.url,e.data||e),t._handleClose())},r.onclose=function(){r===t._ws&&(t._remote.trace&&c.info("onclose:",t._opts.url,r.readyState),t._handleClose())}}},n.prototype._retryConnect=function(){function t(){e._shouldConnect&&(e._remote.trace&&c.info("retry",e._opts.url),e.connect())}var e=this;this._retry+=1;var r=this._retry<40?50:this._retry<100?1e3:this._retry<160?1e4:3e4;this._retryTimer=setTimeout(t,r)},n.prototype._handleClose=function(){var t=this,e=this._ws;this.emit("socket_close"),this._setState("offline"),e.onopen=e.onerror=e.onclose=e.onmessage=function(){},t._shouldConnect&&this._retryConnect()},n.prototype._handleMessage=function(t){var e=this;try{t=JSON.parse(t)}catch(r){}if(n.isValidMessage(t))switch(t.type){case"ledgerClosed":this._lastLedgerClose=Date.now(),this.emit("ledger_closed",t);break;case"serverStatus":if(this._setState(~n.onlineStates.indexOf(t.server_status)?"online":"offline"),n.isLoadStatus(t)){e.emit("load",t,e),e._remote.emit("load",t,e);var i=t.load_base!==e._load_base||t.load_factor!==e._load_factor;i&&(e._load_base=t.load_base,e._load_factor=t.load_factor,e.emit("load_changed",t,e),e._remote.emit("load_changed",t,e))}break;case"response":var s=e._requests[t.id];delete e._requests[t.id],s?"success"===t.status?(this._remote.trace&&c.info("response:",e._opts.url,t),s.emit("success",t.result),[e,e._remote].forEach(function(e){e.emit("response_"+s.message.command,t.result,s,t)})):t.error&&(this._remote.trace&&c.info("error:",e._opts.url,t),s.emit("error",{error:"remoteError",error_message:"Remote reported an error.",remote:t})):this._remote.trace&&c.info("UNEXPECTED:",e._opts.url,t);break;case"path_find":this._remote.trace&&c.info("path_find:",e._opts.url,t)}},n.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},n.isLoadStatus=function(t){return"number"==typeof t.load_base&&"number"==typeof t.load_factor},n.prototype._handleResponseSubscribe=function(t){~n.onlineStates.indexOf(t.server_status)&&this._setState("online"),n.isLoadStatus(t)&&(this._load_base=t.load_base||256,this._load_factor=t.load_factor||256,this._fee_ref=t.fee_ref,this._fee_base=t.fee_base,this._reserve_base=t.reserve_base,this._reserve_inc=t.reserve_inc)},n.prototype.sendMessage=function(t){this._ws&&(this._remote.trace&&c.info("request:",this._opts.url,t),this._ws.send(JSON.stringify(t)))},n.prototype.request=function(t){function e(){r.sendMessage(t.message)}var r=this;return this._ws?(t.server=this,t.message.id=this._id,this._requests[t.message.id]=t,this._id++,this._isConnected(t)?this.sendMessage(t.message):this.once("connect",e),void 0):(this._remote.trace&&c.info("request: DROPPING:",r._opts.url,t.message),void 0)},n.prototype._isConnected=function(t){var e=t&&"subscribe"===t.message.command&&1===this._ws.readyState;return this._connected||this._ws&&e},n.prototype.computeFee=function(t){var e;if(t instanceof o)e=t.feeUnits();else{if("number"!=typeof t)throw new Error("Invalid argument");e=t}return this.feeTx(e).to_json()},n.prototype.feeTx=function(t){var e=this.feeTxUnit();return a.from_json(String(Math.ceil(t*e)))},n.prototype.feeTxUnit=function(){var t=this._fee_base/this._fee_ref;return t*=this._load_factor/this._load_base,t*=this._fee_cushion},n.prototype.reserve=function(t){var e=a.from_json(String(this._reserve_base)),r=a.from_json(String(this._reserve_inc)),t=t||0;if(0>t)throw new Error("Owner count must not be negative.");return e.add(r.product_human(t))},e.Server=n},17:function(t,e,r){var n=r(35),i=t.exports={load:function(t){return n(i,t),i}}},18:function(t,e,r){function n(t,e,r,s,o,a){function c(t){~n.subscribe_events.indexOf(t)&&(f._subs+=1,1==f._subs&&f._remote._connected&&f._subscribe())}function u(t){~n.subscribe_events.indexOf(t)&&(f._subs-=1,!f._subs&&f._remote._connected&&(f._sync=!1,f._remote.request_unsubscribe().books([f.to_json()]).request()))}function h(){f._sync=!1}i.call(this);var f=this;return this._remote=t,this._currency_gets=e,this._issuer_gets=r,this._currency_pays=s,this._issuer_pays=o,this._subs=0,this._key=a,this._sync=!1,this._offers=[],this.on("newListener",c),this.on("removeListener",u),this._remote.on("prepare_subscribe",function(t){f._subscribe(t)}),this._remote.on("disconnect",h),this}var i=r(31).EventEmitter,s=r(32),o=r(35),a=r(3).Amount,c=r(8).UInt160,u=r(6).Currency;s.inherits(n,i),n.subscribe_events=["transaction","model","trade"],n.prototype._subscribe=function(t){var e=this;if(e.is_valid()&&e._subs){var t=this._remote.request_subscribe();t.addBook(e.to_json(),!0),t.once("success",function(t){e._sync=!0,e._offers=t.offers,e.emit("model",e._offers)}),t.once("error",function(){}),t.request()}},n.prototype.to_json=function(){var t={taker_gets:{currency:this._currency_gets},taker_pays:{currency:this._currency_pays}};return"XRP"!==this._currency_gets&&(t.taker_gets.issuer=this._issuer_gets),"XRP"!==this._currency_pays&&(t.taker_pays.issuer=this._issuer_pays),t},n.prototype.is_valid=function(){return u.is_valid(this._currency_pays)&&("XRP"===this._currency_pays||c.is_valid(this._issuer_pays))&&u.is_valid(this._currency_gets)&&("XRP"===this._currency_gets||c.is_valid(this._issuer_gets))&&!("XRP"===this._currency_pays&&"XRP"===this._currency_gets)},n.prototype.trade=function(t){var e="0"+("XRP"===this["_currency_"+t]?"":"/"+this["_currency_"+t]+"/"+this["_issuer_"+t]);return a.from_json(e)},n.prototype.notify=function(t){function e(e){if("Offer"===e.entryType&&e.bookKey===r._key){var c,u,h;switch(e.diffType){case"DeletedNode":case"ModifiedNode":var f="DeletedNode"===e.diffType;for(c=0,u=r._offers.length;u>c;c++)if(h=r._offers[c],h.index===e.ledgerIndex){f?r._offers.splice(c,1):o(h,e.fieldsFinal),n=!0;break}if("OfferCancel"===t.transaction.TransactionType)return;i=i.add(e.fieldsPrev.TakerGets),s=s.add(e.fieldsPrev.TakerPays),f||(i=i.subtract(e.fieldsFinal.TakerGets),s=s.subtract(e.fieldsFinal.TakerPays));break;case"CreatedNode":var l=a.from_json(e.fields.TakerPays).ratio_human(e.fields.TakerGets,{reference_date:new Date});for(c=0,u=r._offers.length;u>c;c++){h=r._offers[c];var p=a.from_json(h.TakerPays).ratio_human(h.TakerGets,{reference_date:new Date});if(l.compareTo(p)<=0){var _=e.fields;_.index=e.ledgerIndex,r._offers.splice(c,0,e.fields),n=!0;break}}}}}var r=this,n=!1,i=this.trade("gets"),s=this.trade("pays");t.mmeta.each(e),this._subs&&(this.emit("transaction",t),n&&this.emit("model",this._offers),i.is_zero()||this.emit("trade",s,i))},n.prototype.notifyTx=n.prototype.notify,n.prototype.offers=function(t){return"function"==typeof t&&(this._sync?t(this._offers):this.once("model",t)),this},n.prototype.offersSync=function(){return this._offers},e.OrderBook=n},19:function(t,e,r){function n(t,e,r,n,s){i.call(this),this.remote=t,this.src_account=e,this.dst_account=r,this.dst_amount=n,this.src_currencies=s}var i=r(31).EventEmitter,s=r(32),o=r(3).Amount;r(35),s.inherits(n,i),n.prototype.create=function(){function t(t,r){t?e.emit("error",t):e.notify_update(r)}var e=this,r=this.remote.request_path_find_create(this.src_account,this.dst_account,this.dst_amount,this.src_currencies,t);r.request()},n.prototype.close=function(){this.remote.request_path_find_close().request(),this.emit("end"),this.emit("close")},n.prototype.notify_update=function(t){var e=t.source_account,r=t.destination_account,n=o.from_json(t.destination_amount);this.src_account===e&&this.dst_account===r&&this.dst_amount.equals(n)&&this.emit("update",t)},n.prototype.notify_superceded=function(){this.emit("end"),this.emit("superceded")},e.PathFind=n},20:function(t,e,r){var e=t.exports=r(34),n={logObject:function(t){var e=Array.prototype.slice.call(arguments,1);e=e.map(function(t){return/MSIE/.test(navigator.userAgent)?JSON.stringify(t,null,2):t}),e.unshift(t),console.log.apply(console,e)}};window.console&&window.console.log&&(e.Log.engine=n)},21:function(t,e,r){function n(t){function e(t){var e=n.normalizeTransaction(t),r=e.transaction.Sequence,i=e.transaction.hash;if(e.validated){h._pending.addReceivedSequence(r);var s=h._pending.getSubmission(i);h._remote._trace("transactionmanager: transaction_received:",e.transaction),s?s.emit("success",e):h._pending.addReceivedId(i,e)}}function r(t,e){h._pending.forEach(function(t){var r=t._server===e&&h._remote.local_fee&&t.tx_json.Fee;if(r){var n=t.tx_json.Fee,i=e.computeFee(t);if(Number(i)>h._maxFee)return t.once("presubmit",function(){t.emit("error","tejMaxFeeExceeded")});t.tx_json.Fee=i,t.emit("fee_adjusted",n,i),h._remote._trace("transactionmanager: adjusting_fees:",t.tx_json,n,i)}})}function i(t){h._pending.forEach(function(e){switch(t.ledger_index-e.submitIndex){case 8:e.emit("lost",t),h._remote._trace("transactionmanager: update_pending:",e.tx_json);break;case 4:e.emit("missing",t)}})}function o(t){function r(r,n){!r&&Array.isArray(n.transactions)&&n.transactions.forEach(e),h._remote.on("ledger_closed",i),h._loadSequence(function(){h._resubmit()}),t()}var t="function"==typeof t?t:function(){};if(!h._pending.length)return t();var n={account:h._accountID,ledger_index_min:-1,ledger_index_max:-1,binary:!0,limit:100,filter:"outbound"};h._remote.requestAccountTx(n,r),h.emit("reconnect")}function a(){h._remote.once("connect",o),h._remote.removeListener("ledger_closed",i)}function u(t){h._remote.storage.saveTransaction(t.summary())}s.call(this);var h=this;this._account=t,this._accountID=t._account_id,this._remote=t._remote,this._nextSequence=void 0,this._maxFee=this._remote.max_fee,this._submissionTimeout=this._remote._submission_timeout,this._pending=new c,this._loadSequence(),this._account.on("transaction-outbound",e),this._remote.on("load_changed",r),this._remote.on("ledger_closed",i),this._remote.on("disconnect",a),this._remote.storage&&this.on("save",u)}var i=r(32),s=r(31).EventEmitter,o=r(5).Transaction,a=r(13).RippleError,c=r(36).TransactionQueue;i.inherits(n,s),n.normalizeTransaction=function(t){var e=t;return t.engine_result||(e={engine_result:t.meta.TransactionResult,transaction:t.tx,hash:t.tx.hash,ledger_index:t.tx.ledger_index,meta:t.meta,type:"transaction",validated:!0},e.result=e.engine_result,e.result_message=e.engine_result_message),e.metadata=e.meta,e.tx_json||(e.tx_json=e.transaction),e},n.prototype._fillSequence=function(t,e){function r(e,r){var n=i._remote.transaction();n.account_set(i._accountID),n.tx_json.Sequence=e,n.once("submitted",r),t._secret&&n.secret(t._secret),n.submit()}function n(n,i){if("number"!=typeof i)return e(new Error("Failed to fetch account transaction sequence"));var s=t.tx_json.Sequence-i,o=0;!function a(n){n>=t.tx_json.Sequence||r(n,function(){++o===s?e():a(n+1)})}(i)}var i=this;this._loadSequence(n)},n.prototype._loadSequence=function(t){function e(e,n){"number"==typeof n?(r._nextSequence=n,r.emit("sequence_loaded",n),"function"==typeof t&&t(e,n)):setTimeout(function(){r._loadSequence(t)},3e3)}var r=this;this._account.getNextSequence(e)},n.prototype._resubmit=function(t,e){function r(t){if(t&&!t.finalized){var e=t.findId(i._pending._idCache);if(i._remote._trace("transactionmanager: resubmit:",t.tx_json),e)return t.emit("success",e);for(;i._pending.hasSequence(t.tx_json.Sequence);)t.tx_json.Sequence+=1,i._remote._trace("transactionmanager: incrementing sequence:",t.tx_json);i._request(t)}}function n(){!function t(n){var s=e[n];s instanceof o&&(s.once("submitted",function(r){s.emit("resubmitted",r),i._loadSequence(),++n<e.length&&t(n)}),r(s))}(0)}var i=this,e=e?[e]:this._pending,t=Number(t)||0;this._waitLedgers(t,n)},n.prototype._waitLedgers=function(t,e){function r(){++i===t&&(n._remote.removeListener("ledger_closed",r),e())}if(1>t)return e();var n=this,i=0;this._remote.on("ledger_closed",r)},n.prototype._request=function(t){function e(e){t.finalized||(e.rejected=t.isRejected(e.engine_result_code),t.emit("proposed",e))}function r(e){if(!t.finalized)switch(e.engine_result){case"tefPAST_SEQ":l._resubmit(1,t);break;default:t.emit("error",e)}}function i(){t.finalized||l._fillSequence(t,function(){l._resubmit(1,t)})}function s(e){t.finalized||t.emit("error",e)}function o(e){if(!t.finalized){var r=l._remote.local_fee&&"telINSUF_FEE_P"===e.engine_result;r?l._resubmit(1,t):c(e)}}function c(e){t.finalized||(n._isTooBusy(e)?l._resubmit(1,t):(l._nextSequence--,t.emit("error",e)))}function u(n){if(!t.finalized)switch(n.tx_json&&n.tx_json.hash&&t.addId(n.tx_json.hash),n.result=n.engine_result||"",t.result=n,p._trace("transactionmanager: submit_response:",n),t.emit("submitted",n),n.result.slice(0,3)){case"tes":e(n);break;case"tec":s(n);break;case"ter":i(n);break;case"tef":r(n);break;case"tel":o(n);break;default:c(n)}}function h(){t.finalized||(t.emit("timeout"),p._connected&&(p._trace("transactionmanager: timeout:",t.tx_json),l._resubmit(3,t)))}function f(){t.finalized||(d.timeout(l._submissionTimeout,h),d.request(),t.attempts++,t.emit("postsubmit"))}var l=this,p=this._remote;if(t.attempts>10)return t.emit("error",new a("tejAttemptsExceeded"));if(t.attempts>0&&!p.local_signing){var _="It is not possible to resubmit transactions automatically safely without synthesizing the transactionID locally. See `local_signing` config option";return t.emit("error",new a("tejLocalSigningRequired",_))}if(t.emit("presubmit"),!t.finalized){t.submitIndex=this._remote._ledger_current_index,0===t.attempts&&(t.initialSubmitIndex=t.submitIndex),t._setLastLedger||(t.tx_json.LastLedgerSequence=t.submitIndex+8),t.lastLedgerSequence=t.tx_json.LastLedgerSequence;var d=p.requestSubmit();return p.local_signing?(t.sign(),d.tx_blob(t.serialize().to_hex()),t.addId(t.hash())):(d.build_path(t._build_path),d.secret(t._secret),d.tx_json(t.tx_json)),p._trace("transactionmanager: submit:",t.tx_json),d.once("error",u),d.once("success",u),t._server&&(d.server=t._server),"function"==typeof t._iff?t._iff(t.summary(),function(e,r){e||!r?t.emit("abort"):f()}):(f(),d)}},n._isNoOp=function(t){return"object"==typeof t&&"object"==typeof t.tx_json&&"AccountSet"===t.tx_json.TransactionType&&0===t.tx_json.Flags},n._isRemoteError=function(t){return"object"==typeof t&&"remoteError"===t.error&&"object"==typeof t.remote},n._isNotFound=function(t){return n._isRemoteError(t)&&/^(txnNotFound|transactionNotFound)$/.test(t.remote.error)},n._isTooBusy=function(t){return n._isRemoteError(t)&&"tooBusy"===t.remote.error},n.prototype.submit=function(t){function e(){n.submit(t)}function r(e){n._pending.remove(t),t.emit("final",e),i._trace("transactionmanager: finalize_transaction:",t.tx_json)}var n=this,i=this._remote;if("undefined"==typeof this._nextSequence)return this.once("sequence_loaded",e),void 0;if(!t.finalized){if(t.once("cleanup",r),t.on("save",function(){n.emit("save",t)}),t.once("error",function(e){t._errorHandler(e)}),t.once("success",function(e){t._successHandler(e)}),t.once("abort",function(){t.emit("error",new a("tejAbort","Transaction aborted"))}),"number"!=typeof t.tx_json.Sequence&&(t.tx_json.Sequence=this._nextSequence++),!t.complete())return this._nextSequence--,void 0;t.attempts=0,this._pending.push(t),this._request(t)}},e.TransactionManager=n},22:function(t,e){e.HASH_TX_ID=1415073280,e.HASH_TX_NODE=1397638144,e.HASH_INNER_NODE=1296649728,e.HASH_TX_SIGN=1398036480,e.HASH_TX_SIGN_TESTNET=1937012736},23:function(t,e){var r=e.Float={},n=/^0+$/,i=/^1+$/;r.fromBytes=function(t){for(var e="",r=0,s=t.length;s>r;r++){for(var o=(255&t[r]).toString(2);o.length<8;)o="0"+o;e+=o}var a=4===t.length?4:11,c=8*t.length-a-1,u=Math.pow(2,a-1)-1,h=1-u-c,f=e[0],l=e.substring(1,a+1),p=e.substring(a+1),_=0,d="0"===f?1:-1;if(n.test(l))n.test(p)||(_=parseInt(p,2)*Math.pow(2,h));else if(i.test(l))_=n.test(p)?1/0:0/0;else{var y=parseInt(l,2)-u,m=parseInt(p,2);_=(1+m*Math.pow(2,-c))*Math.pow(2,y)}return _*d}},24:function(t,e,r){var n=r(15),i=n.sjcl,s=r(17),o=n.jsbn.BigInteger;r(7).Base;var a=function(){this._value=0/0,this._update()};a.json_rewrite=function(t,e){return this.from_json(t).to_json(e)},a.from_generic=function(t){return t instanceof this?t.clone():(new this).parse_generic(t)},a.from_hex=function(t){return t instanceof this?t.clone():(new this).parse_hex(t)},a.from_json=function(t){return t instanceof this?t.clone():(new this).parse_json(t)},a.from_bits=function(t){return t instanceof this?t.clone():(new this).parse_bits(t)},a.from_bytes=function(t){return t instanceof this?t.clone():(new this).parse_bytes(t)},a.from_bn=function(t){return t instanceof this?t.clone():(new this).parse_bn(t)},a.from_number=function(t){return t instanceof this?t.clone():(new this).parse_number(t)},a.is_valid=function(t){return this.from_json(t).is_valid()},a.prototype.clone=function(){return this.copyTo(new this.constructor)},a.prototype.copyTo=function(t){return t._value=this._value,"function"==typeof t._update&&t._update(),t},a.prototype.equals=function(t){return this._value instanceof o&&t._value instanceof o&&this._value.equals(t._value)},a.prototype.is_valid=function(){return this._value instanceof o},a.prototype.is_zero=function(){return this._value.equals(o.ZERO)},a.prototype._update=function(){},a.prototype.parse_generic=function(t){switch(s.accounts&&t in s.accounts&&(t=s.accounts[t].account),t){case void 0:case"0":case this.constructor.STR_ZERO:case this.constructor.ACCOUNT_ZERO:case this.constructor.HEX_ZERO:this._value=o.valueOf();break;case"1":case this.constructor.STR_ONE:case this.constructor.ACCOUNT_ONE:case this.constructor.HEX_ONE:this._value=new o([1]);break;default:this._value="string"!=typeof t?0/0:this.constructor.width===t.length?new o(n.stringToArray(t),256):2*this.constructor.width===t.length?new o(t,16):0/0}return this._update(),this},a.prototype.parse_hex=function(t){return this._value="string"==typeof t&&t.length===2*this.constructor.width?new o(t,16):0/0,this._update(),this},a.prototype.parse_bits=function(t){if(i.bitArray.bitLength(t)!==8*this.constructor.width)this._value=0/0;else{var e=i.codec.bytes.fromBits(t);this.parse_bytes(e)}return this._update(),this},a.prototype.parse_bytes=function(t){return this._value=Array.isArray(t)&&t.length===this.constructor.width?new o([0].concat(t),256):0/0,this._update(),this},a.prototype.parse_json=a.prototype.parse_hex,a.prototype.parse_bn=function(t){if(t instanceof i.bn&&t.bitLength()<=8*this.constructor.width){var e=i.codec.bytes.fromBits(t.toBits());
this._value=new o(e,256)}else this._value=0/0;return this._update(),this},a.prototype.parse_number=function(t){return this._value=0/0,"number"==typeof t&&t===+t&&t>=0&&(this._value=new o(""+t)),this._update(),this},a.prototype.to_bytes=function(){if(!(this._value instanceof o))return null;var t=this._value.toByteArray();t=t.map(function(t){return(t+256)%256});var e=this.constructor.width;for(t=t.slice(-e);t.length<e;)t.unshift(0);return t},a.prototype.to_hex=function(){if(!(this._value instanceof o))return null;var t=this.to_bytes();return i.codec.hex.fromBits(i.codec.bytes.toBits(t)).toUpperCase()},a.prototype.to_json=a.prototype.to_hex,a.prototype.to_bits=function(){if(!(this._value instanceof o))return null;var t=this.to_bytes();return i.codec.bytes.toBits(t)},a.prototype.to_bn=function(){if(!(this._value instanceof o))return null;var t=this.to_bits();return i.bn.fromBits(t)},e.UInt=a},25:function(t,e,r){function n(){this._curve=s.ecc.curves.c256,this._secret=null,this._pubkey=null}function i(t){return s.hash.ripemd160.hash(s.hash.sha256.hash(t))}var s=r(15).sjcl,o=r(8).UInt160,a=r(9).UInt256,c=r(7).Base;n.from_bn_secret=function(t){return t instanceof this?t.clone():(new this).parse_bn_secret(t)},n.prototype.parse_bn_secret=function(t){return this._secret=new s.ecc.ecdsa.secretKey(s.ecc.curves.c256,t),this},n.prototype._pub=function(){var t=this._curve;if(!this._pubkey&&this._secret){var e=this._secret._exponent;this._pubkey=new s.ecc.ecdsa.publicKey(t,t.G.mult(e))}return this._pubkey},n.prototype._pub_bits=function(){var t=this._pub();if(!t)return null;var e=t._point,r=e.y.mod(2).equals(0);return s.bitArray.concat([s.bitArray.partial(8,r?2:3)],e.x.toBits(this._curve.r.bitLength()))},n.prototype.to_hex_pub=function(){var t=this._pub_bits();return t?s.codec.hex.fromBits(t).toUpperCase():null},n.prototype.get_address=function(){var t=this._pub_bits();if(!t)return null;var e=i(t),r=o.from_bits(e);return r.set_version(c.VER_ACCOUNT_ID),r},n.prototype.sign=function(t){t=a.from_json(t);var e=this._secret.sign(t.to_bits(),0);return e=this._secret.canonicalizeSignature(e),this._secret.encodeDER(e)},e.KeyPair=n},26:function(t,e,r){function n(t){return"number"==typeof t&&isFinite(t)}function i(t){return"string"==typeof t}function s(t){return i(t)&&/^[0-9A-F]{0,16}$/i.test(t)}function o(t){return t instanceof j}function a(t,e,r){var n=k.fromBits(A.toBits(e));r||B.serialize_varint(t,n.length),t.append(n)}function c(t){return v.codec.hex.fromBits(v.codec.bytes.toBits(t)).toUpperCase()}function u(t,e,r){if(!n(e))throw new Error("Value is not a number");if(0>e||e>=Math.pow(256,r))throw new Error("Value out of bounds");for(var i=[],s=0;r>s;s++)i.unshift(255&e>>>8*s);t.append(i)}function h(t,e){var r=0;if(e>4)throw new Error("This function only supports up to four bytes.");for(var n=0;e>n;n++){var i=t.read(1)[0];r+=i<<8*(e-n-1)}return r>>>0}function f(t,r,n){var i=y.fieldsInverseMap[r],s=i[0],o=i[1],a=(16>s?s<<4:0)|(16>o?o:0);"LedgerEntryType"===r&&"string"==typeof n&&(n=y.ledger[n][0]),"TransactionResult"===r&&"string"==typeof n&&(n=y.ter[n]),I.serialize(t,a),s>=16&&I.serialize(t,s),o>=16&&I.serialize(t,o);var c=e[y.types[s]];c.serialize(t,n)}function l(t){var r=t.read(1)[0],n=r>>4;0===n&&(n=t.read(1)[0]);var i=e[y.types[n]];_(i,"Unknown type - header byte is 0x"+r.toString(16));var s=15&r,o=o=0===s?y.fields[n][t.read(1)[0]]:y.fields[n][s];return _(o,"Unknown field - header byte is 0x"+r.toString(16)),[o,i.parse(t)]}function p(t){function e(t,e){var r=y.fieldsInverseMap[t],n=r[0],i=r[1],s=y.fieldsInverseMap[e],o=s[0],a=s[1];return n!==o?n-o:i-a}return t.sort(e)}var _=r(33),d=r(35),y=r(14),m=r(15),v=m.sjcl,g=r(37).UInt128,b=r(8).UInt160,w=r(9).UInt256,E=r(7).Base,x=r(3),S=x.Amount,T=x.Currency,A=v.codec.hex,k=v.codec.bytes,j=m.jsbn.BigInteger,B=function(t){d(this,t)};B.serialize_varint=function(t,e){if(0>e)throw new Error("Variable integers are unsigned.");if(192>=e)t.append([e]);else if(12480>=e)e-=193,t.append([193+(e>>>8),255&e]);else{if(!(918744>=e))throw new Error("Variable integer overflow.");e-=12481,t.append([241+(e>>>16),255&e>>>8,255&e])}},B.prototype.parse_varint=function(t){var e,r,n,i=t.read(1)[0];if(i>254)throw new Error("Invalid varint length indicator");return 192>=i?n=i:240>=i?(e=t.read(1)[0],n=193+256*(i-193)+e):254>=i&&(e=t.read(1)[0],r=t.read(1)[0],n=12481+65536*(i-241)+256*e+r),n};var I=e.Int8=new B({serialize:function(t,e){u(t,e,1)},parse:function(t){return h(t,1)}});I.id=16;var R=e.Int16=new B({serialize:function(t,e){u(t,e,2)},parse:function(t){return h(t,2)}});R.id=1;var q=e.Int32=new B({serialize:function(t,e){u(t,e,4)},parse:function(t){return h(t,4)}});q.id=2;var D=e.Int64=new B({serialize:function(t,e){var r;if(n(e)){if(e=Math.floor(e),0>e)throw new Error("Negative value for unsigned Int64 is invalid.");r=new j(String(e),10)}else if(i(e)){if(!s(e))throw new Error("Not a valid hex Int64.");r=new j(e,16)}else{if(!o(e))throw new Error("Invalid type for Int64");if(e.compareTo(j.ZERO)<0)throw new Error("Negative value for unsigned Int64 is invalid.");r=e}var c=r.toString(16);if(c.length>16)throw new Error("Int64 is too large");for(;c.length<16;)c="0"+c;a(t,c,!0)},parse:function(t){var e=new j(t.read(8),256);return _(e instanceof j),e}});D.id=3;var C=e.Hash128=new B({serialize:function(t,e){var r=g.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash128");a(t,r.to_hex(),!0)},parse:function(t){return g.from_bytes(t.read(16))}});C.id=4;var O=e.Hash256=new B({serialize:function(t,e){var r=w.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash256");a(t,r.to_hex(),!0)},parse:function(t){return w.from_bytes(t.read(32))}});O.id=5;var L=e.Hash160=new B({serialize:function(t,e){var r=b.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash160");a(t,r.to_hex(),!0)},parse:function(t){return b.from_bytes(t.read(20))}});L.id=17;var M=new B({serialize:function(t,e){var r=e.to_bytes();if(!r)throw new Error("Tried to serialize invalid/unimplemented currency type.");t.append(r)},parse:function(t){var e=t.read(20),r=T.from_bytes(e);return r}}),N=e.Amount=new B({serialize:function(t,e){var r=S.from_json(e);if(!r.is_valid())throw new Error("Not a valid Amount object.");var n=m.arraySet(8,0);if(r.is_native()){var i=r._value.toString(16);if(i.length>16)throw new Error("Value out of bounds");for(;i.length<16;)i="0"+i;n=k.fromBits(A.toBits(i)),n[0]&=63,r.is_negative()||(n[0]|=64)}else{var s=0,o=0;s|=1<<31,r.is_zero()||(r.is_negative()||(s|=1<<30),s|=(255&97+r._offset)<<22,s|=4194303&r._value.shiftRight(32).intValue(),o=4294967295&r._value.intValue()),n=v.codec.bytes.fromBits([s,o])}if(t.append(n),!r.is_native()){var a=r.currency();M.serialize(t,a,!0),t.append(r.issuer().to_bytes())}},parse:function(t){for(var e=new S,r=t.read(8),n=!(127&r[0]),i=1;8>i;i++)n=n&&!r[i];if(128&r[0]){var s=M.parse(t),o=t.read(20),a=b.from_bytes(o);a.set_version(E.VER_ACCOUNT_ID);var c=((63&r[0])<<2)+(r[1]>>>6)-97,u=r.slice(1);u[0]&=63;var h=new j(u,256);if(h.equals(j.ZERO)&&!n)throw new Error("Invalid zero representation");e._value=h,e._offset=c,e._currency=s,e._issuer=a,e._is_native=!1}else{var f=r.slice();f[0]&=63,e._value=new j(f,256),e._is_native=!0}return e._is_negative=!(n||64&r[0]),e}});N.id=6;var F=e.VariableLength=e.VL=new B({serialize:function(t,e){if("string"!=typeof e)throw new Error("Unknown datatype.");a(t,e)},parse:function(t){var e=this.parse_varint(t);return c(t.read(e))}});F.id=7;var P=e.Account=new B({serialize:function(t,e){var r=b.from_json(e);if(!r.is_valid())throw new Error("Invalid account!");a(t,r.to_hex())},parse:function(t){var e=this.parse_varint(t);if(20!==e)throw new Error("Non-standard-length account ID");var r=b.from_bytes(t.read(e));return r.set_version(E.VER_ACCOUNT_ID),r}});P.id=8;var z=e.PathSet=new B({typeBoundary:255,typeEnd:0,typeAccount:1,typeCurrency:16,typeIssuer:32,serialize:function(t,e){for(var r=0,n=e.length;n>r;r++){r&&I.serialize(t,this.typeBoundary);for(var i=0,s=e[r].length;s>i;i++){var o=e[r][i],a=0;if(o.account&&(a|=this.typeAccount),o.currency&&(a|=this.typeCurrency),o.issuer&&(a|=this.typeIssuer),I.serialize(t,a),o.account&&t.append(b.from_json(o.account).to_bytes()),o.currency){var c=T.from_json(o.currency,o.non_native);M.serialize(t,c)}o.issuer&&t.append(b.from_json(o.issuer).to_bytes())}}I.serialize(t,this.typeEnd)},parse:function(t){for(var e,r=[],n=[];(e=t.read(1)[0])!==this.typeEnd;)if(e===this.typeBoundary)n&&r.push(n),n=[];else{var i={};if(e&this.typeAccount&&(i.account=L.parse(t),i.account.set_version(E.VER_ACCOUNT_ID)),e&this.typeCurrency&&(i.currency=M.parse(t),"XRP"!==i.currency.to_json()||i.currency.is_native()||(i.non_native=!0)),e&this.typeIssuer&&(i.issuer=L.parse(t),i.issuer.set_version(E.VER_ACCOUNT_ID)),!(i.account||i.currency||i.issuer))throw new Error("Invalid path entry");n.push(i)}return n&&r.push(n),r}});z.id=18;var U=e.Vector256=new B({serialize:function(t,e){B.serialize_varint(t,32*e.length);for(var r=0,n=e.length;n>r;r++)O.serialize(t,e[r])},parse:function(t){for(var e=this.parse_varint(t),r=[],n=0;e/32>n;n++)r.push(O.parse(t));return r}});U.id=19,e.serialize=e.serialize_whatever=f,e.parse=e.parse_whatever=l;var H=e.Object=new B({serialize:function(t,e,r){var n=Object.keys(e);n=n.filter(function(t){return t[0]!==t[0].toLowerCase()}),n.forEach(function(t){if("undefined"==typeof y.fieldsInverseMap[t])throw new Error("JSON contains unknown field: '"+t+"'")}),n=p(n);for(var i=0;i<n.length;i++)f(t,n[i],e[n[i]]);r||I.serialize(t,225)},parse:function(t){for(var e={};225!==t.peek(1)[0];){var r=l(t);e[r[0]]=r[1]}return t.read(1),e}});H.id=14;var V=e.Array=new B({serialize:function(t,e){for(var r=0,n=e.length;n>r;r++){var i=Object.keys(e[r]);if(1!==i.length)throw Error("Cannot serialize an array containing non-single-key objects");var s=i[0],o=e[r][s];f(t,s,o)}I.serialize(t,241)},parse:function(t){for(var e=[];241!==t.peek(1)[0];){var r=l(t),n={};n[r[0]]=r[1],e.push(n)}return t.read(1),e}});V.id=15},27:function(t,e,r){!function(t,r){function n(t){this.length=t}function i(t){return 16>t?"0"+t.toString(16):t.toString(16)}function s(t){for(var e=[],r=0;r<t.length;r++)if(t.charCodeAt(r)<=127)e.push(t.charCodeAt(r));else for(var n=encodeURIComponent(t.charAt(r)).substr(1).split("%"),i=0;i<n.length;i++)e.push(parseInt(n[i],16));return e}function o(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function a(e){return t(47).toByteArray(e)}function c(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);)e[i+r]=t[i],i++;return i}function u(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function h(t){return t=~~Math.ceil(+t),0>t?0:t}function r(t,e,i){if(!(this instanceof r))return new r(t,e,i);var s;if("number"==typeof i)this.length=h(e),this.parent=t,this.offset=i;else{switch(s=typeof t){case"number":this.length=h(t);break;case"string":this.length=r.byteLength(t,e);break;case"object":this.length=h(t.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>r.poolSize?(this.parent=new n(this.length),this.offset=0):((!B||B.length-B.used<this.length)&&l(),this.parent=B,this.offset=B.used,B.used+=this.length),f(t))for(var o=0;o<this.length;o++)this.parent[o+this.offset]=t[o];else"string"==s&&(this.length=this.write(t,0,e))}}function f(t){return Array.isArray(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function l(){B=new n(r.poolSize),B.used=0}function p(t,e,r,n){var i=0;return n||(j.ok("boolean"==typeof r,"missing or invalid endian"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e+1<t.length,"Trying to read beyond buffer length")),r?(i=t.parent[t.offset+e]<<8,i|=t.parent[t.offset+e+1]):(i=t.parent[t.offset+e],i|=t.parent[t.offset+e+1]<<8),i}function _(t,e,r,n){var i=0;return n||(j.ok("boolean"==typeof r,"missing or invalid endian"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e+3<t.length,"Trying to read beyond buffer length")),r?(i=t.parent[t.offset+e+1]<<16,i|=t.parent[t.offset+e+2]<<8,i|=t.parent[t.offset+e+3],i+=t.parent[t.offset+e]<<24>>>0):(i=t.parent[t.offset+e+2]<<16,i|=t.parent[t.offset+e+1]<<8,i|=t.parent[t.offset+e],i+=t.parent[t.offset+e+3]<<24>>>0),i}function d(t,e,r,n){var i,s;return n||(j.ok("boolean"==typeof r,"missing or invalid endian"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e+1<t.length,"Trying to read beyond buffer length")),s=p(t,e,r,n),i=32768&s,i?-1*(65535-s+1):s}function y(t,e,r,n){var i,s;return n||(j.ok("boolean"==typeof r,"missing or invalid endian"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e+3<t.length,"Trying to read beyond buffer length")),s=_(t,e,r,n),i=2147483648&s,i?-1*(4294967295-s+1):s}function m(e,r,n,i){return i||(j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(r+3<e.length,"Trying to read beyond buffer length")),t(38).readIEEE754(e,r,n,23,4)}function v(e,r,n,i){return i||(j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(r+7<e.length,"Trying to read beyond buffer length")),t(38).readIEEE754(e,r,n,52,8)}function g(t,e){j.ok("number"==typeof t,"cannot write a non-number as a number"),j.ok(t>=0,"specified a negative value for writing an unsigned value"),j.ok(e>=t,"value is larger than maximum value for type"),j.ok(Math.floor(t)===t,"value has a fractional component")}function b(t,e,r,n,i){i||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+1<t.length,"trying to write beyond buffer length"),g(e,65535)),n?(t.parent[t.offset+r]=(65280&e)>>>8,t.parent[t.offset+r+1]=255&e):(t.parent[t.offset+r+1]=(65280&e)>>>8,t.parent[t.offset+r]=255&e)}function w(t,e,r,n,i){i||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+3<t.length,"trying to write beyond buffer length"),g(e,4294967295)),n?(t.parent[t.offset+r]=255&e>>>24,t.parent[t.offset+r+1]=255&e>>>16,t.parent[t.offset+r+2]=255&e>>>8,t.parent[t.offset+r+3]=255&e):(t.parent[t.offset+r+3]=255&e>>>24,t.parent[t.offset+r+2]=255&e>>>16,t.parent[t.offset+r+1]=255&e>>>8,t.parent[t.offset+r]=255&e)}function E(t,e,r){j.ok("number"==typeof t,"cannot write a non-number as a number"),j.ok(e>=t,"value larger than maximum allowed value"),j.ok(t>=r,"value smaller than minimum allowed value"),j.ok(Math.floor(t)===t,"value has a fractional component")}function x(t,e,r){j.ok("number"==typeof t,"cannot write a non-number as a number"),j.ok(e>=t,"value larger than maximum allowed value"),j.ok(t>=r,"value smaller than minimum allowed value")}function S(t,e,r,n,i){i||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+1<t.length,"Trying to write beyond buffer length"),E(e,32767,-32768)),e>=0?b(t,e,r,n,i):b(t,65535+e+1,r,n,i)}function T(t,e,r,n,i){i||(j.ok(void 0!==e&&null!==e,"missing value"),j.ok("boolean"==typeof n,"missing or invalid endian"),j.ok(void 0!==r&&null!==r,"missing offset"),j.ok(r+3<t.length,"Trying to write beyond buffer length"),E(e,2147483647,-2147483648)),e>=0?w(t,e,r,n,i):w(t,4294967295+e+1,r,n,i)}function A(e,r,n,i,s){s||(j.ok(void 0!==r&&null!==r,"missing value"),j.ok("boolean"==typeof i,"missing or invalid endian"),j.ok(void 0!==n&&null!==n,"missing offset"),j.ok(n+3<e.length,"Trying to write beyond buffer length"),x(r,3.4028234663852886e38,-3.4028234663852886e38)),t(38).writeIEEE754(e,r,n,i,23,4)}function k(e,r,n,i,s){s||(j.ok(void 0!==r&&null!==r,"missing value"),j.ok("boolean"==typeof i,"missing or invalid endian"),j.ok(void 0!==n&&null!==n,"missing offset"),j.ok(n+7<e.length,"Trying to write beyond buffer length"),x(r,1.7976931348623157e308,-1.7976931348623157e308)),t(38).writeIEEE754(e,r,n,i,52,8)}var j=t(33);e.INSPECT_MAX_BYTES=50,n.byteLength=function(t,e){switch(e||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return s(t).length;case"ascii":return t.length;case"base64":return a(t).length;default:throw new Error("Unknown encoding")}},n.prototype.utf8Write=function(t,e,r){return n._charsWritten=c(s(t),this,e,r)},n.prototype.asciiWrite=function(t,e,r){return n._charsWritten=c(o(t),this,e,r)},n.prototype.base64Write=function(t,e,r){return n._charsWritten=c(a(t),this,e,r)},n.prototype.base64Slice=function(){var e=Array.prototype.slice.apply(this,arguments);return t(47).fromByteArray(e)},n.prototype.utf8Slice=function(){for(var t=Array.prototype.slice.apply(this,arguments),e="",r="",n=0;n<t.length;)t[n]<=127?(e+=u(r)+String.fromCharCode(t[n]),r=""):r+="%"+t[n].toString(16),n++;return e+u(r)},n.prototype.asciiSlice=function(){for(var t=Array.prototype.slice.apply(this,arguments),e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},n.prototype.inspect=function(){for(var t=[],r=this.length,n=0;r>n;n++)if(t[n]=i(this[n]),n==e.INSPECT_MAX_BYTES){t[n+1]="...";break}return"<SlowBuffer "+t.join(" ")+">"},n.prototype.hexSlice=function(t,e){var r=this.length;(!t||0>t)&&(t=0),(!e||0>e||e>r)&&(e=r);for(var n="",s=t;e>s;s++)n+=i(this[s]);return n},n.prototype.toString=function(t,e,r){if(t=String(t||"utf8").toLowerCase(),e=+e||0,"undefined"==typeof r&&(r=this.length),+r==e)return"";switch(t){case"hex":return this.hexSlice(e,r);case"utf8":case"utf-8":return this.utf8Slice(e,r);case"ascii":return this.asciiSlice(e,r);case"binary":return this.binarySlice(e,r);case"base64":return this.base64Slice(e,r);case"ucs2":case"ucs-2":return this.ucs2Slice(e,r);default:throw new Error("Unknown encoding")}},n.prototype.hexWrite=function(t,e,r){e=+e||0;var i=this.length-e;r?(r=+r,r>i&&(r=i)):r=i;var s=t.length;if(s%2)throw new Error("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;r>o;o++){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))throw new Error("Invalid hex string");this[e+o]=a}return n._charsWritten=2*o,o},n.prototype.write=function(t,e,r,n){if(isFinite(e))isFinite(r)||(n=r,r=void 0);else{var i=n;n=e,e=r,r=i}e=+e||0;var s=this.length-e;switch(r?(r=+r,r>s&&(r=s)):r=s,n=String(n||"utf8").toLowerCase()){case"hex":return this.hexWrite(t,e,r);case"utf8":case"utf-8":return this.utf8Write(t,e,r);case"ascii":return this.asciiWrite(t,e,r);case"binary":return this.binaryWrite(t,e,r);case"base64":return this.base64Write(t,e,r);case"ucs2":case"ucs-2":return this.ucs2Write(t,e,r);default:throw new Error("Unknown encoding")}},n.prototype.slice=function(t,e){if(void 0===e&&(e=this.length),e>this.length)throw new Error("oob");if(t>e)throw new Error("oob");return new r(this,e-t,+t)},n.prototype.copy=function(t,e,r,n){for(var i=[],s=r;n>s;s++)j.ok("undefined"!=typeof this[s],"copying undefined buffer bytes!"),i.push(this[s]);for(var s=e;s<e+i.length;s++)t[s]=i[s-e]},e.SlowBuffer=n,e.Buffer=r,r.poolSize=8192;var B;r.isBuffer=function(t){return t instanceof r||t instanceof n},r.concat=function(t,e){if(!Array.isArray(t))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===t.length)return new r(0);if(1===t.length)return t[0];if("number"!=typeof e){e=0;for(var n=0;n<t.length;n++){var i=t[n];e+=i.length}}for(var s=new r(e),o=0,n=0;n<t.length;n++){var i=t[n];i.copy(s,o),o+=i.length}return s},r.prototype.inspect=function(){for(var t=[],r=this.length,n=0;r>n;n++)if(t[n]=i(this.parent[n+this.offset]),n==e.INSPECT_MAX_BYTES){t[n+1]="...";break}return"<Buffer "+t.join(" ")+">"},r.prototype.get=function(t){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]},r.prototype.set=function(t,e){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]=e},r.prototype.write=function(t,e,i,s){if(isFinite(e))isFinite(i)||(s=i,i=void 0);else{var o=s;s=e,e=i,i=o}e=+e||0;var a=this.length-e;i?(i=+i,i>a&&(i=a)):i=a,s=String(s||"utf8").toLowerCase();var c;switch(s){case"hex":c=this.parent.hexWrite(t,this.offset+e,i);break;case"utf8":case"utf-8":c=this.parent.utf8Write(t,this.offset+e,i);break;case"ascii":c=this.parent.asciiWrite(t,this.offset+e,i);break;case"binary":c=this.parent.binaryWrite(t,this.offset+e,i);break;case"base64":c=this.parent.base64Write(t,this.offset+e,i);break;case"ucs2":case"ucs-2":c=this.parent.ucs2Write(t,this.offset+e,i);break;default:throw new Error("Unknown encoding")}return r._charsWritten=n._charsWritten,c},r.prototype.toString=function(t,e,r){switch(t=String(t||"utf8").toLowerCase(),"undefined"==typeof e||0>e?e=0:e>this.length&&(e=this.length),"undefined"==typeof r||r>this.length?r=this.length:0>r&&(r=0),e+=this.offset,r+=this.offset,t){case"hex":return this.parent.hexSlice(e,r);case"utf8":case"utf-8":return this.parent.utf8Slice(e,r);case"ascii":return this.parent.asciiSlice(e,r);case"binary":return this.parent.binarySlice(e,r);case"base64":return this.parent.base64Slice(e,r);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(e,r);default:throw new Error("Unknown encoding")}},r.byteLength=n.byteLength,r.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(e>r)throw new Error("end < start");if(r===e)return 0;if(0==this.length)return 0;if(0>e||e>=this.length)throw new Error("start out of bounds");if(0>r||r>this.length)throw new Error("end out of bounds");return this.parent.fill(t,e+this.offset,r+this.offset)},r.prototype.copy=function(t,e,r,n){var i=this;if(r||(r=0),n||(n=this.length),e||(e=0),r>n)throw new Error("sourceEnd < sourceStart");if(n===r)return 0;if(0==t.length||0==i.length)return 0;if(0>e||e>=t.length)throw new Error("targetStart out of bounds");if(0>r||r>=i.length)throw new Error("sourceStart out of bounds");if(0>n||n>i.length)throw new Error("sourceEnd out of bounds");return n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r),this.parent.copy(t.parent,e+t.offset,r+this.offset,n+this.offset)},r.prototype.slice=function(t,e){if(void 0===e&&(e=this.length),e>this.length)throw new Error("oob");if(t>e)throw new Error("oob");return new r(this.parent,e-t,+t+this.offset)},r.prototype.utf8Slice=function(t,e){return this.toString("utf8",t,e)},r.prototype.binarySlice=function(t,e){return this.toString("binary",t,e)},r.prototype.asciiSlice=function(t,e){return this.toString("ascii",t,e)},r.prototype.utf8Write=function(t,e){return this.write(t,e,"utf8")},r.prototype.binaryWrite=function(t,e){return this.write(t,e,"binary")},r.prototype.asciiWrite=function(t,e){return this.write(t,e,"ascii")},r.prototype.readUInt8=function(t,e){var r=this;return e||(j.ok(void 0!==t&&null!==t,"missing offset"),j.ok(t<r.length,"Trying to read beyond buffer length")),r.parent[r.offset+t]},r.prototype.readUInt16LE=function(t,e){return p(this,t,!1,e)},r.prototype.readUInt16BE=function(t,e){return p(this,t,!0,e)},r.prototype.readUInt32LE=function(t,e){return _(this,t,!1,e)},r.prototype.readUInt32BE=function(t,e){return _(this,t,!0,e)},r.prototype.readInt8=function(t,e){var r,n=this;return e||(j.ok(void 0!==t&&null!==t,"missing offset"),j.ok(t<n.length,"Trying to read beyond buffer length")),r=128&n.parent[n.offset+t],r?-1*(255-n.parent[n.offset+t]+1):n.parent[n.offset+t]},r.prototype.readInt16LE=function(t,e){return d(this,t,!1,e)},r.prototype.readInt16BE=function(t,e){return d(this,t,!0,e)},r.prototype.readInt32LE=function(t,e){return y(this,t,!1,e)},r.prototype.readInt32BE=function(t,e){return y(this,t,!0,e)},r.prototype.readFloatLE=function(t,e){return m(this,t,!1,e)},r.prototype.readFloatBE=function(t,e){return m(this,t,!0,e)},r.prototype.readDoubleLE=function(t,e){return v(this,t,!1,e)},r.prototype.readDoubleBE=function(t,e){return v(this,t,!0,e)},r.prototype.writeUInt8=function(t,e,r){var n=this;r||(j.ok(void 0!==t&&null!==t,"missing value"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e<n.length,"trying to write beyond buffer length"),g(t,255)),n.parent[n.offset+e]=t},r.prototype.writeUInt16LE=function(t,e,r){b(this,t,e,!1,r)},r.prototype.writeUInt16BE=function(t,e,r){b(this,t,e,!0,r)},r.prototype.writeUInt32LE=function(t,e,r){w(this,t,e,!1,r)},r.prototype.writeUInt32BE=function(t,e,r){w(this,t,e,!0,r)},r.prototype.writeInt8=function(t,e,r){var n=this;r||(j.ok(void 0!==t&&null!==t,"missing value"),j.ok(void 0!==e&&null!==e,"missing offset"),j.ok(e<n.length,"Trying to write beyond buffer length"),E(t,127,-128)),t>=0?n.writeUInt8(t,e,r):n.writeUInt8(255+t+1,e,r)},r.prototype.writeInt16LE=function(t,e,r){S(this,t,e,!1,r)},r.prototype.writeInt16BE=function(t,e,r){S(this,t,e,!0,r)},r.prototype.writeInt32LE=function(t,e,r){T(this,t,e,!1,r)},r.prototype.writeInt32BE=function(t,e,r){T(this,t,e,!0,r)},r.prototype.writeFloatLE=function(t,e,r){A(this,t,e,!1,r)},r.prototype.writeFloatBE=function(t,e,r){A(this,t,e,!0,r)},r.prototype.writeDoubleLE=function(t,e,r){k(this,t,e,!1,r)},r.prototype.writeDoubleBE=function(t,e,r){k(this,t,e,!0,r)},n.prototype.readUInt8=r.prototype.readUInt8,n.prototype.readUInt16LE=r.prototype.readUInt16LE,n.prototype.readUInt16BE=r.prototype.readUInt16BE,n.prototype.readUInt32LE=r.prototype.readUInt32LE,n.prototype.readUInt32BE=r.prototype.readUInt32BE,n.prototype.readInt8=r.prototype.readInt8,n.prototype.readInt16LE=r.prototype.readInt16LE,n.prototype.readInt16BE=r.prototype.readInt16BE,n.prototype.readInt32LE=r.prototype.readInt32LE,n.prototype.readInt32BE=r.prototype.readInt32BE,n.prototype.readFloatLE=r.prototype.readFloatLE,n.prototype.readFloatBE=r.prototype.readFloatBE,n.prototype.readDoubleLE=r.prototype.readDoubleLE,n.prototype.readDoubleBE=r.prototype.readDoubleBE,n.prototype.writeUInt8=r.prototype.writeUInt8,n.prototype.writeUInt16LE=r.prototype.writeUInt16LE,n.prototype.writeUInt16BE=r.prototype.writeUInt16BE,n.prototype.writeUInt32LE=r.prototype.writeUInt32LE,n.prototype.writeUInt32BE=r.prototype.writeUInt32BE,n.prototype.writeInt8=r.prototype.writeInt8,n.prototype.writeInt16LE=r.prototype.writeInt16LE,n.prototype.writeInt16BE=r.prototype.writeInt16BE,n.prototype.writeInt32LE=r.prototype.writeInt32LE,n.prototype.writeInt32BE=r.prototype.writeInt32BE,n.prototype.writeFloatLE=r.prototype.writeFloatLE,n.prototype.writeFloatBE=r.prototype.writeFloatBE,n.prototype.writeDoubleLE=r.prototype.writeDoubleLE,n.prototype.writeDoubleBE=r.prototype.writeDoubleBE}(r,r(27).Buffer)},28:function(t,e,r){!function(t,e){"use strict";function r(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};"undefined"!=typeof e&&e.exports&&(e.exports=n),n.cipher.aes=function(t){this._tables[0][0][0]||this._precompute();var e,r,i,s,o,a=this._tables[0][4],c=this._tables[1],u=t.length,h=1;if(4!==u&&6!==u&&8!==u)throw new n.exception.invalid("invalid aes key size");for(this._key=[s=t.slice(0),o=[]],e=u;4*u+28>e;e++)i=s[e-1],(0===e%u||8===u&&4===e%u)&&(i=a[i>>>24]<<24^a[255&i>>16]<<16^a[255&i>>8]<<8^a[255&i],0===e%u&&(i=i<<8^i>>>24^h<<24,h=h<<1^283*(h>>7))),s[e]=s[e-u]^i;for(r=0;e;r++,e--)i=s[3&r?e:e-4],o[r]=4>=e||4>r?i:c[0][a[i>>>24]]^c[1][a[255&i>>16]]^c[2][a[255&i>>8]]^c[3][a[255&i]]},n.cipher.aes.prototype={encrypt:function(t){return this._crypt(t,0)},decrypt:function(t){return this._crypt(t,1)},_tables:[[[],[],[],[],[]],[[],[],[],[],[]]],_precompute:function(){var t,e,r,n,i,s,o,a,c,u=this._tables[0],h=this._tables[1],f=u[4],l=h[4],p=[],_=[];for(t=0;256>t;t++)_[(p[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!f[e];e^=n||1,r=_[r]||1)for(o=r^r<<1^r<<2^r<<3^r<<4,o=99^(o>>8^255&o),f[e]=o,l[o]=e,s=p[i=p[n=p[e]]],c=16843009*s^65537*i^257*n^16843008*e,a=257*p[o]^16843008*o,t=0;4>t;t++)u[t][e]=a=a<<24^a>>>8,h[t][o]=c=c<<24^c>>>8;for(t=0;5>t;t++)u[t]=u[t].slice(0),h[t]=h[t].slice(0)},_crypt:function(t,e){if(4!==t.length)throw new n.exception.invalid("invalid aes block size");var r,i,s,o,a=this._key[e],c=t[0]^a[0],u=t[e?3:1]^a[1],h=t[2]^a[2],f=t[e?1:3]^a[3],l=a.length/4-2,p=4,_=[0,0,0,0],d=this._tables[e],y=d[0],m=d[1],v=d[2],g=d[3],b=d[4];for(o=0;l>o;o++)r=y[c>>>24]^m[255&u>>16]^v[255&h>>8]^g[255&f]^a[p],i=y[u>>>24]^m[255&h>>16]^v[255&f>>8]^g[255&c]^a[p+1],s=y[h>>>24]^m[255&f>>16]^v[255&c>>8]^g[255&u]^a[p+2],f=y[f>>>24]^m[255&c>>16]^v[255&u>>8]^g[255&h]^a[p+3],p+=4,c=r,u=i,h=s;for(o=0;4>o;o++)_[e?3&-o:o]=b[c>>>24]<<24^b[255&u>>16]<<16^b[255&h>>8]<<8^b[255&f]^a[p++],r=c,c=u,u=h,h=f,f=r;return _}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n,i=Math.floor(31&-e-r);return n=-32&(e+r-1^e)?t[0|e/32]<<32-i^t[0|e/32+1]>>>i:t[0|e/32]>>>i,n&(1<<r)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var r=t[t.length-1],i=n.bitArray.getPartial(r);return 32===i?t.concat(e):n.bitArray._shiftRight(e,i,0|r,t.slice(0,t.length-1))},bitLength:function(t){var e,r=t.length;return 0===r?0:(e=t[r-1],32*(r-1)+n.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length<e)return t;t=t.slice(0,Math.ceil(e/32));var r=t.length;return e=31&e,r>0&&e&&(t[r-1]=n.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r<t.length;r++)i|=t[r]^e[r];return 0===i},_shiftRight:function(t,e,r,i){var s,o,a=0;for(void 0===i&&(i=[]);e>=32;e-=32)i.push(r),r=0;if(0===e)return i.concat(t);for(s=0;s<t.length;s++)i.push(r|t[s]>>>e),r=t[s]<<32-e;return a=t.length?t[t.length-1]:0,o=n.bitArray.getPartial(a),i.push(n.bitArray.partial(31&e+o,e+o>32?r:i.pop(),1)),i},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]}},n.codec.utf8String={fromBits:function(t){var e,r,i="",s=n.bitArray.bitLength(t);for(e=0;s/8>e;e++)0===(3&e)&&(r=t[e/4]),i+=String.fromCharCode(r>>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;e<t.length;e++)i=i<<8|t.charCodeAt(e),3===(3&e)&&(r.push(i),i=0);return 3&e&&r.push(n.bitArray.partial(8*(3&e),i)),r}},n.codec.hex={fromBits:function(t){var e,r="";for(e=0;e<t.length;e++)r+=((0|t[e])+0xf00000000000).toString(16).substr(4);return r.substr(0,n.bitArray.bitLength(t)/4)},toBits:function(t){var e,r,i=[];for(t=t.replace(/\s|0x/g,""),r=t.length,t+="00000000",e=0;e<t.length;e+=8)i.push(0^parseInt(t.substr(e,8),16));return n.bitArray.clamp(i,4*r)}},n.codec.base64={_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,r){var i,s="",o=0,a=n.codec.base64._chars,c=0,u=n.bitArray.bitLength(t);for(r&&(a=a.substr(0,62)+"-_"),i=0;6*s.length<u;)s+=a.charAt((c^t[i]>>>o)>>>26),6>o?(c=t[i]<<6-o,o+=26,i++):(c<<=6,o-=6);for(;3&s.length&&!e;)s+="=";return s},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,s=[],o=0,a=n.codec.base64._chars,c=0;for(e&&(a=a.substr(0,62)+"-_"),r=0;r<t.length;r++){if(i=a.indexOf(t.charAt(r)),0>i)throw new n.exception.invalid("this isn't base64!");o>26?(o-=26,s.push(c^i>>>o),c=i<<32-o):(o+=6,c^=i<<32-o)}return 56&o&&s.push(n.bitArray.partial(56&o,c,1)),s}},n.codec.base64url={fromBits:function(t){return n.codec.base64.fromBits(t,1,1)},toBits:function(t){return n.codec.base64.toBits(t,1)}},n.codec.bytes={fromBits:function(t){var e,r,i=[],s=n.bitArray.bitLength(t);for(e=0;s/8>e;e++)0===(3&e)&&(r=t[e/4]),i.push(r>>>24),r<<=8;return i},toBits:function(t){var e,r=[],i=0;for(e=0;e<t.length;e++)i=i<<8|t[e],3===(3&e)&&(r.push(i),i=0);return 3&e&&r.push(n.bitArray.partial(8*(3&e),i)),r}},n.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()
},n.hash.sha256.hash=function(t){return(new n.hash.sha256).update(t).finalize()},n.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this._buffer=n.bitArray.concat(this._buffer,t),i=this._length,s=this._length=i+n.bitArray.bitLength(t);for(e=-512&512+i;s>=e;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)]),t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){function t(t){return 0|4294967296*(t-Math.floor(t))}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;n>=e*e;e++)if(0===n%e)continue t;8>r&&(this._init[r]=t(Math.pow(n,.5))),this._key[r]=t(Math.pow(n,1/3)),r++}},_block:function(t){var e,r,n,i,s=t.slice(0),o=this._h,a=this._key,c=o[0],u=o[1],h=o[2],f=o[3],l=o[4],p=o[5],_=o[6],d=o[7];for(e=0;64>e;e++)16>e?r=s[e]:(n=s[15&e+1],i=s[15&e+14],r=s[15&e]=0|(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+s[15&e]+s[15&e+9]),r=r+d+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(_^l&(p^_))+a[e],d=_,_=p,p=l,l=0|f+r,f=h,h=u,u=c,c=0|r+(u&h^f&(u^h))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10);o[0]=0|o[0]+c,o[1]=0|o[1]+u,o[2]=0|o[2]+h,o[3]=0|o[3]+f,o[4]=0|o[4]+l,o[5]=0|o[5]+p,o[6]=0|o[6]+_,o[7]=0|o[7]+d}},n.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this._buffer=n.bitArray.concat(this._buffer,t),i=this._length,s=this._length=i+n.bitArray.bitLength(t);for(e=-1024&1024+i;s>=e;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)]),t=e.length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[],_keyr:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],_precompute:function(){function t(t){return 0|4294967296*(t-Math.floor(t))}function e(t){return 255&1099511627776*(t-Math.floor(t))}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;i>=r*r;r++)if(0===i%r)continue t;8>n&&(this._init[2*n]=t(Math.pow(i,.5)),this._init[2*n+1]=e(Math.pow(i,.5))<<24|this._initr[n]),this._key[2*n]=t(Math.pow(i,1/3)),this._key[2*n+1]=e(Math.pow(i,1/3))<<24|this._keyr[n],n++}},_block:function(t){var e,r,n,i=t.slice(0),s=this._h,o=this._key,a=s[0],c=s[1],u=s[2],h=s[3],f=s[4],l=s[5],p=s[6],_=s[7],d=s[8],y=s[9],m=s[10],v=s[11],g=s[12],b=s[13],w=s[14],E=s[15],x=a,S=c,T=u,A=h,k=f,j=l,B=p,I=_,R=d,q=y,D=m,C=v,O=g,L=b,M=w,N=E;for(e=0;80>e;e++){if(16>e)r=i[2*e],n=i[2*e+1];else{var F=i[2*(e-15)],P=i[2*(e-15)+1],z=(P<<31|F>>>1)^(P<<24|F>>>8)^F>>>7,U=(F<<31|P>>>1)^(F<<24|P>>>8)^(F<<25|P>>>7),H=i[2*(e-2)],V=i[2*(e-2)+1],X=(V<<13|H>>>19)^(H<<3|V>>>29)^H>>>6,G=(H<<13|V>>>19)^(V<<3|H>>>29)^(H<<26|V>>>6),Z=i[2*(e-7)],K=i[2*(e-7)+1],W=i[2*(e-16)],J=i[2*(e-16)+1];n=U+K,r=z+Z+(U>>>0>n>>>0?1:0),n+=G,r+=X+(G>>>0>n>>>0?1:0),n+=J,r+=W+(J>>>0>n>>>0?1:0)}i[2*e]=r|=0,i[2*e+1]=n|=0;var Q=R&D^~R&O,Y=q&C^~q&L,$=x&T^x&k^T&k,te=S&A^S&j^A&j,ee=(S<<4|x>>>28)^(x<<30|S>>>2)^(x<<25|S>>>7),re=(x<<4|S>>>28)^(S<<30|x>>>2)^(S<<25|x>>>7),ne=(q<<18|R>>>14)^(q<<14|R>>>18)^(R<<23|q>>>9),ie=(R<<18|q>>>14)^(R<<14|q>>>18)^(q<<23|R>>>9),se=o[2*e],oe=o[2*e+1],ae=N+ie,ce=M+ne+(N>>>0>ae>>>0?1:0);ae+=Y,ce+=Q+(Y>>>0>ae>>>0?1:0),ae+=oe,ce+=se+(oe>>>0>ae>>>0?1:0),ae+=n,ce+=r+(n>>>0>ae>>>0?1:0);var ue=re+te,he=ee+$+(re>>>0>ue>>>0?1:0);M=O,N=L,O=D,L=C,D=R,C=q,q=0|I+ae,R=0|B+ce+(I>>>0>q>>>0?1:0),B=k,I=j,k=T,j=A,T=x,A=S,S=0|ae+ue,x=0|ce+he+(ae>>>0>S>>>0?1:0)}c=s[1]=0|c+S,s[0]=0|a+x+(S>>>0>c>>>0?1:0),h=s[3]=0|h+A,s[2]=0|u+T+(A>>>0>h>>>0?1:0),l=s[5]=0|l+j,s[4]=0|f+k+(j>>>0>l>>>0?1:0),_=s[7]=0|_+I,s[6]=0|p+B+(I>>>0>_>>>0?1:0),y=s[9]=0|y+q,s[8]=0|d+R+(q>>>0>y>>>0?1:0),v=s[11]=0|v+C,s[10]=0|m+D+(C>>>0>v>>>0?1:0),b=s[13]=0|b+L,s[12]=0|g+O+(L>>>0>b>>>0?1:0),E=s[15]=0|E+N,s[14]=0|w+M+(N>>>0>E>>>0?1:0)}},n.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},n.hash.sha1.hash=function(t){return(new n.hash.sha1).update(t).finalize()},n.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this._buffer=n.bitArray.concat(this._buffer,t),i=this._length,s=this._length=i+n.bitArray.bitLength(t);for(e=this.blockSize+i&-this.blockSize;s>=e;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)]),t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,n){return 19>=t?e&r|~e&n:39>=t?e^r^n:59>=t?e&r|e&n|r&n:79>=t?e^r^n:void 0},_S:function(t,e){return e<<t|e>>>32-t},_block:function(t){var e,r,n,i,s,o,a,c=t.slice(0),u=this._h;for(this._key,n=u[0],i=u[1],s=u[2],o=u[3],a=u[4],e=0;79>=e;e++)e>=16&&(c[e]=this._S(1,c[e-3]^c[e-8]^c[e-14]^c[e-16])),r=0|this._S(5,n)+this._f(e,i,s,o)+a+c[e]+this._key[Math.floor(e/20)],a=o,o=s,s=this._S(30,i),i=n,n=r;u[0]=0|u[0]+n,u[1]=0|u[1]+i,u[2]=0|u[2]+s,u[3]=0|u[3]+o,u[4]=0|u[4]+a}},n.mode.ccm={name:"ccm",encrypt:function(t,e,r,i,s){var o,a,c=e.slice(0),u=n.bitArray,h=u.bitLength(r)/8,f=u.bitLength(c)/8;if(s=s||64,i=i||[],7>h)throw new n.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&f>>>8*o;o++);return 15-h>o&&(o=15-h),r=u.clamp(r,8*(15-o)),a=n.mode.ccm._computeTag(t,e,r,i,s,o),c=n.mode.ccm._ctrMode(t,c,r,a,s,o),u.concat(c.data,c.tag)},decrypt:function(t,e,r,i,s){s=s||64,i=i||[];var o,a,c=n.bitArray,u=c.bitLength(r)/8,h=c.bitLength(e),f=c.clamp(e,h-s),l=c.bitSlice(e,h-s);if(h=(h-s)/8,7>u)throw new n.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&h>>>8*o;o++);if(15-u>o&&(o=15-u),r=c.clamp(r,8*(15-o)),f=n.mode.ccm._ctrMode(t,f,r,l,s,o),a=n.mode.ccm._computeTag(t,f.data,r,i,s,o),!c.equal(f.tag,a))throw new n.exception.corrupt("ccm: tag doesn't match");return f.data},_computeTag:function(t,e,r,i,s,o){var a,c,u,h=[],f=n.bitArray,l=f._xor4;if(s/=8,s%2||4>s||s>16)throw new n.exception.invalid("ccm: invalid tag length");if(i.length>4294967295||e.length>4294967295)throw new n.exception.bug("ccm: can't deal with 4GiB or more data");if(a=[f.partial(8,(i.length?64:0)|s-2<<2|o-1)],a=f.concat(a,r),a[3]|=f.bitLength(e)/8,a=t.encrypt(a),i.length)for(c=f.bitLength(i)/8,65279>=c?h=[f.partial(16,c)]:4294967295>=c&&(h=f.concat([f.partial(16,65534)],[c])),h=f.concat(h,i),u=0;u<h.length;u+=4)a=t.encrypt(l(a,h.slice(u,u+4).concat([0,0,0])));for(u=0;u<e.length;u+=4)a=t.encrypt(l(a,e.slice(u,u+4).concat([0,0,0])));return f.clamp(a,8*s)},_ctrMode:function(t,e,r,i,s,o){var a,c,u,h=n.bitArray,f=h._xor4,l=e.length,p=h.bitLength(e);if(u=h.concat([h.partial(8,o-1)],r).concat([0,0,0]).slice(0,4),i=h.bitSlice(f(i,t.encrypt(u)),0,s),!l)return{tag:i,data:[]};for(c=0;l>c;c+=4)u[3]++,a=t.encrypt(u),e[c]^=a[0],e[c+1]^=a[1],e[c+2]^=a[2],e[c+3]^=a[3];return{tag:i,data:h.clamp(e,p)}}},n.misc.hmac=function(t,e){this._hash=e=e||n.hash.sha256;var r,i=[[],[]],s=e.prototype.blockSize/32;for(this._baseHash=[new e,new e],t.length>s&&(t=e.hash(t)),r=0;s>r;r++)i[0][r]=909522486^t[r],i[1][r]=1549556828^t[r];this._baseHash[0].update(i[0]),this._baseHash[1].update(i[1])},n.misc.hmac.prototype.encrypt=n.misc.hmac.prototype.mac=function(t){var e=new this._hash(this._baseHash[0]).update(t).finalize();return new this._hash(this._baseHash[1]).update(e).finalize()},n.misc.pbkdf2=function(t,e,r,i,s){if(r=r||1e3,0>i||0>r)throw n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),s=s||n.misc.hmac;var o,a,c,u,h,f=new s(t),l=[],p=n.bitArray;for(h=1;32*l.length<(i||1);h++){for(o=a=f.encrypt(p.concat(e,[h])),c=1;r>c;c++)for(a=f.encrypt(a),u=0;u<a.length;u++)o[u]^=a[u];l=l.concat(o)}return i&&(l=p.clamp(l,i)),l},n.prng=function(t){this._pools=[new n.hash.sha256],this._poolEntropy=[0],this._reseedCount=0,this._robins={},this._eventId=0,this._collectorIds={},this._collectorIdNext=0,this._strength=0,this._poolStrength=0,this._nextReseed=0,this._key=[0,0,0,0,0,0,0,0],this._counter=[0,0,0,0],this._cipher=void 0,this._defaultParanoia=t,this._collectorsStarted=!1,this._callbacks={progress:{},seeded:{}},this._callbackI=0,this._NOT_READY=0,this._READY=1,this._REQUIRES_RESEED=2,this._MAX_WORDS_PER_BURST=65536,this._PARANOIA_LEVELS=[0,48,64,96,128,192,256,384,512,768,1024],this._MILLISECONDS_PER_RESEED=3e4,this._BITS_PER_RESEED=80},n.prng.prototype={randomWords:function(t,e){var r,i,s=[],o=this.isReady(e);if(o===this._NOT_READY)throw new n.exception.notReady("generator isn't seeded");for(o&this._REQUIRES_RESEED&&this._reseedFromPools(!(o&this._READY)),r=0;t>r;r+=4)0===(r+1)%this._MAX_WORDS_PER_BURST&&this._gate(),i=this._gen4words(),s.push(i[0],i[1],i[2],i[3]);return this._gate(),s.slice(0,t)},setDefaultParanoia:function(t){this._defaultParanoia=t},addEntropy:function(t,e,r){r=r||"user";var i,s,o,a=(new Date).valueOf(),c=this._robins[r],u=this.isReady(),h=0;switch(i=this._collectorIds[r],void 0===i&&(i=this._collectorIds[r]=this._collectorIdNext++),void 0===c&&(c=this._robins[r]=0),this._robins[r]=(this._robins[r]+1)%this._pools.length,typeof t){case"number":void 0===e&&(e=1),this._pools[c].update([i,this._eventId++,1,e,a,1,0|t]);break;case"object":var f=Object.prototype.toString.call(t);if("[object Uint32Array]"===f){for(o=[],s=0;s<t.length;s++)o.push(t[s]);t=o}else for("[object Array]"!==f&&(h=1),s=0;s<t.length&&!h;s++)"number"!=typeof t[s]&&(h=1);if(!h){if(void 0===e)for(e=0,s=0;s<t.length;s++)for(o=t[s];o>0;)e++,o>>>=1;this._pools[c].update([i,this._eventId++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this._pools[c].update([i,this._eventId++,3,e,a,t.length]),this._pools[c].update(t);break;default:h=1}if(h)throw new n.exception.bug("random: addEntropy only supports number, array of numbers or string");this._poolEntropy[c]+=e,this._poolStrength+=e,u===this._NOT_READY&&(this.isReady()!==this._NOT_READY&&this._fireEvent("seeded",Math.max(this._strength,this._poolStrength)),this._fireEvent("progress",this.getProgress()))},isReady:function(t){var e=this._PARANOIA_LEVELS[void 0!==t?t:this._defaultParanoia];return this._strength&&this._strength>=e?this._poolEntropy[0]>this._BITS_PER_RESEED&&(new Date).valueOf()>this._nextReseed?this._REQUIRES_RESEED|this._READY:this._READY:this._poolStrength>=e?this._REQUIRES_RESEED|this._NOT_READY:this._NOT_READY},getProgress:function(t){var e=this._PARANOIA_LEVELS[t?t:this._defaultParanoia];return this._strength>=e?1:this._poolStrength>e?1:this._poolStrength/e},startCollectors:function(){if(!this._collectorsStarted){if(window.addEventListener)window.addEventListener("load",this._loadTimeCollector,!1),window.addEventListener("mousemove",this._mouseCollector,!1);else{if(!document.attachEvent)throw new n.exception.bug("can't attach event");document.attachEvent("onload",this._loadTimeCollector),document.attachEvent("onmousemove",this._mouseCollector)}this._collectorsStarted=!0}},stopCollectors:function(){this._collectorsStarted&&(window.removeEventListener?(window.removeEventListener("load",this._loadTimeCollector,!1),window.removeEventListener("mousemove",this._mouseCollector,!1)):window.detachEvent&&(window.detachEvent("onload",this._loadTimeCollector),window.detachEvent("onmousemove",this._mouseCollector)),this._collectorsStarted=!1)},addEventListener:function(t,e){this._callbacks[t][this._callbackI++]=e},removeEventListener:function(t,e){var r,n,i=this._callbacks[t],s=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&s.push(n);for(r=0;r<s.length;r++)n=s[r],delete i[n]},_gen4words:function(){for(var t=0;4>t&&(this._counter[t]=0|this._counter[t]+1,!this._counter[t]);t++);return this._cipher.encrypt(this._counter)},_gate:function(){this._key=this._gen4words().concat(this._gen4words()),this._cipher=new n.cipher.aes(this._key)},_reseed:function(t){this._key=n.hash.sha256.hash(this._key.concat(t)),this._cipher=new n.cipher.aes(this._key);for(var e=0;4>e&&(this._counter[e]=0|this._counter[e]+1,!this._counter[e]);e++);},_reseedFromPools:function(t){var e,r=[],i=0;for(this._nextReseed=r[0]=(new Date).valueOf()+this._MILLISECONDS_PER_RESEED,e=0;16>e;e++)r.push(0|4294967296*Math.random());for(e=0;e<this._pools.length&&(r=r.concat(this._pools[e].finalize()),i+=this._poolEntropy[e],this._poolEntropy[e]=0,t||!(this._reseedCount&1<<e));e++);this._reseedCount>=1<<this._pools.length&&(this._pools.push(new n.hash.sha256),this._poolEntropy.push(0)),this._poolStrength-=i,i>this._strength&&(this._strength=i),this._reseedCount++,this._reseed(r)},_mouseCollector:function(t){var e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0;n.random.addEntropy([e,r],2,"mouse")},_loadTimeCollector:function(){n.random.addEntropy((new Date).valueOf(),2,"loadtime")},_fireEvent:function(t,e){var r,i=n.random._callbacks[t],s=[];for(r in i)i.hasOwnProperty(r)&&s.push(i[r]);for(r=0;r<s.length;r++)s[r](e)}},n.random=new n.prng(6),function(){try{var t=new Uint32Array(32);crypto.getRandomValues(t),n.random.addEntropy(t,1024,"crypto.getRandomValues")}catch(e){}}(),n.json={defaults:{v:1,iter:1e3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},encrypt:function(t,e,r,i){r=r||{},i=i||{};var s,o,a,c=n.json,u=c._add({iv:n.random.randomWords(4,0)},c.defaults);if(c._add(u,r),a=u.adata,"string"==typeof u.salt&&(u.salt=n.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=n.codec.base64.toBits(u.iv)),!n.mode[u.mode]||!n.cipher[u.cipher]||"string"==typeof t&&u.iter<=100||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||u.iv.length<2||u.iv.length>4)throw new n.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(s=n.misc.cachedPbkdf2(t,u),t=s.key.slice(0,u.ks/32),u.salt=s.salt):n.ecc&&t instanceof n.ecc.elGamal.publicKey&&(s=t.kem(),u.kemtag=s.tag,t=s.key.slice(0,u.ks/32)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),"string"==typeof a&&(a=n.codec.utf8String.toBits(a)),o=new n.cipher[u.cipher](t),c._add(i,u),i.key=t,u.ct=n.mode[u.mode].encrypt(o,e,u.iv,a,u.ts),c.encode(u)},decrypt:function(t,e,r,i){r=r||{},i=i||{};var s,o,a,c=n.json,u=c._add(c._add(c._add({},c.defaults),c.decode(e)),r,!0),h=u.adata;if("string"==typeof u.salt&&(u.salt=n.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=n.codec.base64.toBits(u.iv)),!n.mode[u.mode]||!n.cipher[u.cipher]||"string"==typeof t&&u.iter<=100||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||!u.iv||u.iv.length<2||u.iv.length>4)throw new n.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(o=n.misc.cachedPbkdf2(t,u),t=o.key.slice(0,u.ks/32),u.salt=o.salt):n.ecc&&t instanceof n.ecc.elGamal.secretKey&&(t=t.unkem(n.codec.base64.toBits(u.kemtag)).slice(0,u.ks/32)),"string"==typeof h&&(h=n.codec.utf8String.toBits(h)),a=new n.cipher[u.cipher](t),s=n.mode[u.mode].decrypt(a,u.ct,u.iv,h,u.ts),c._add(i,u),i.key=t,n.codec.utf8String.fromBits(s)},encode:function(t){var e,r="{",i="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new n.exception.invalid("json encode: invalid property name");switch(r+=i+'"'+e+'":',i=",",typeof t[e]){case"number":case"boolean":r+=t[e];break;case"string":r+='"'+escape(t[e])+'"';break;case"object":r+='"'+n.codec.base64.fromBits(t[e],0)+'"';break;default:throw new n.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(t=t.replace(/\s/g,""),!t.match(/^\{.*\}$/))throw new n.exception.invalid("json decode: this isn't json!");var e,r,i=t.replace(/^\{|\}$/g,"").split(/,/),s={};for(e=0;e<i.length;e++){if(!(r=i[e].match(/^(?:(["']?)([a-z][a-z0-9]*)\1):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i)))throw new n.exception.invalid("json decode: this isn't json!");s[r[2]]=r[3]?parseInt(r[3],10):r[2].match(/^(ct|salt|iv)$/)?n.codec.base64.toBits(r[4]):unescape(r[4])}return s},_add:function(t,e,r){if(void 0===t&&(t={}),void 0===e)return t;var i;for(i in e)if(e.hasOwnProperty(i)){if(r&&void 0!==t[i]&&t[i]!==e[i])throw new n.exception.invalid("required parameter overridden");t[i]=e[i]}return t},_subtract:function(t,e){var r,n={};for(r in t)t.hasOwnProperty(r)&&t[r]!==e[r]&&(n[r]=t[r]);return n},_filter:function(t,e){var r,n={};for(r=0;r<e.length;r++)void 0!==t[e[r]]&&(n[e[r]]=t[e[r]]);return n}},n.encrypt=n.json.encrypt,n.decrypt=n.json.decrypt,n.misc._pbkdf2Cache={},n.misc.cachedPbkdf2=function(t,e){var r,i,s,o,a=n.misc._pbkdf2Cache;return e=e||{},o=e.iter||1e3,i=a[t]=a[t]||{},r=i[o]=i[o]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):n.random.randomWords(2,0)},s=void 0===e.salt?r.firstSalt:e.salt,r[s]=r[s]||n.misc.pbkdf2(t,s,e.iter),{key:r[s].slice(0),salt:s.slice(0)}},n.bn=function(t){this.initWith(t)},n.bn.prototype={radix:24,maxMul:8,_class:n.bn,copy:function(){return new this._class(this)},initWith:function(t){var e,r=0;switch(typeof t){case"object":this.limbs=t.limbs.slice(0);break;case"number":this.limbs=[t],this.normalize();break;case"string":for(t=t.replace(/^0x/,""),this.limbs=[],e=this.radix/4,r=0;r<t.length;r+=e)this.limbs.push(parseInt(t.substring(Math.max(t.length-r-e,0),t.length-r),16));break;default:this.limbs=[0]}return this},equals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r=0;for(this.fullReduce(),t.fullReduce(),e=0;e<this.limbs.length||e<t.limbs.length;e++)r|=this.getLimb(e)^t.getLimb(e);return 0===r},getLimb:function(t){return t>=this.limbs.length?0:this.limbs[t]},greaterEquals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=0,s=0;for(e=Math.max(this.limbs.length,t.limbs.length)-1;e>=0;e--)r=this.getLimb(e),n=t.getLimb(e),s|=n-r&~i,i|=r-n&~s;return(s|~i)>>>31},toString:function(){this.fullReduce();var t,e,r="",n=this.limbs;for(t=0;t<this.limbs.length;t++){for(e=n[t].toString(16);t<this.limbs.length-1&&e.length<6;)e="0"+e;r=e+r}return"0x"+r},addM:function(t){"object"!=typeof t&&(t=new this._class(t));var e,r=this.limbs,n=t.limbs;for(e=r.length;e<n.length;e++)r[e]=0;for(e=0;e<n.length;e++)r[e]+=n[e];return this},doubleM:function(){var t,e,r=0,n=this.radix,i=this.radixMask,s=this.limbs;for(t=0;t<s.length;t++)e=s[t],e=e+e+r,s[t]=e&i,r=e>>n;return r&&s.push(r),this},halveM:function(){var t,e,r=0,n=this.radix,i=this.limbs;for(t=i.length-1;t>=0;t--)e=i[t],i[t]=e+r>>1,r=(1&e)<<n;return i[i.length-1]||i.pop(),this},subM:function(t){"object"!=typeof t&&(t=new this._class(t));var e,r=this.limbs,n=t.limbs;for(e=r.length;e<n.length;e++)r[e]=0;for(e=0;e<n.length;e++)r[e]-=n[e];return this},mod:function(t){var e=!this.greaterEquals(new n.bn(0));t=new n.bn(t).normalize();var r=new n.bn(this).normalize(),i=0;for(e&&(r=new n.bn(0).subM(r).normalize());r.greaterEquals(t);i++)t.doubleM();for(e&&(r=t.sub(r).normalize());i>0;i--)t.halveM(),r.greaterEquals(t)&&r.subM(t).normalize();return r.trim()},inverseMod:function(t){var e,r,i=new n.bn(1),s=new n.bn(0),o=new n.bn(this),a=new n.bn(t),c=1;if(!(1&t.limbs[0]))throw new n.exception.invalid("inverseMod: p must be odd");do for(1&o.limbs[0]&&(o.greaterEquals(a)||(e=o,o=a,a=e,e=i,i=s,s=e),o.subM(a),o.normalize(),i.greaterEquals(s)||i.addM(t),i.subM(s)),o.halveM(),1&i.limbs[0]&&i.addM(t),i.normalize(),i.halveM(),r=c=0;r<o.limbs.length;r++)c|=o.limbs[r];while(c);if(!a.equals(1))throw new n.exception.invalid("inverseMod: p and x must be relatively prime");return s},add:function(t){return this.copy().addM(t)},sub:function(t){return this.copy().subM(t)},mul:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=this.limbs,s=t.limbs,o=i.length,a=s.length,c=new this._class,u=c.limbs,h=this.maxMul;for(e=0;e<this.limbs.length+t.limbs.length+1;e++)u[e]=0;for(e=0;o>e;e++){for(n=i[e],r=0;a>r;r++)u[e+r]+=n*s[r];--h||(h=this.maxMul,c.cnormalize())}return c.cnormalize().reduce()},square:function(){return this.mul(this)},power:function(t){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var e,r,n=new this._class(1),i=this;for(e=0;e<t.length;e++)for(r=0;r<this.radix;r++)t[e]&1<<r&&(n=n.mul(i)),i=i.square();return n},mulmod:function(t,e){return this.mod(e).mul(t.mod(e)).mod(e)},powermod:function(t,e){for(var r=new n.bn(1),i=new n.bn(this),s=new n.bn(t);;){if(1&s.limbs[0]&&(r=r.mulmod(i,e)),s.halveM(),s.equals(0))break;i=i.mulmod(i,e)}return r.normalize().reduce()},trim:function(){var t,e=this.limbs;do t=e.pop();while(e.length&&0===t);return e.push(t),this},reduce:function(){return this},fullReduce:function(){return this.normalize()},normalize:function(){var t,e,r,n=0,i=(this.placeVal,this.ipv),s=this.limbs,o=s.length,a=this.radixMask;for(t=0;o>t||0!==n&&-1!==n;t++)e=(s[t]||0)+n,r=s[t]=e&a,n=(e-r)*i;return-1===n&&(s[t-1]-=this.placeVal),this},cnormalize:function(){var t,e,r,n=0,i=this.ipv,s=this.limbs,o=s.length,a=this.radixMask;for(t=0;o-1>t;t++)e=s[t]+n,r=s[t]=e&a,n=(e-r)*i;return s[t]+=n,this},toBits:function(t){this.fullReduce(),t=t||this.exponent||this.bitLength();var e=Math.floor((t-1)/24),r=n.bitArray,i=(-8&t+7)%this.radix||this.radix,s=[r.partial(i,this.getLimb(e))];for(e--;e>=0;e--)s=r.concat(s,[r.partial(Math.min(this.radix,t),this.getLimb(e))]),t-=this.radix;return s},bitLength:function(){this.fullReduce();for(var t=this.radix*(this.limbs.length-1),e=this.limbs[this.limbs.length-1];e;e>>>=1)t++;return-8&t+7}},n.bn.fromBits=function(t){var e=this,r=new e,i=[],s=n.bitArray,o=this.prototype,a=Math.min(this.bitLength||4294967296,s.bitLength(t)),c=a%o.radix||o.radix;for(i[0]=s.extract(t,0,c);a>c;c+=o.radix)i.unshift(s.extract(t,c,o.radix));return r.limbs=i,r},n.bn.prototype.ipv=1/(n.bn.prototype.placeVal=Math.pow(2,n.bn.prototype.radix)),n.bn.prototype.radixMask=(1<<n.bn.prototype.radix)-1,n.bn.pseudoMersennePrime=function(t,e){function r(t){this.initWith(t)}var i,s,o,a=r.prototype=new n.bn;for(o=a.modOffset=Math.ceil(s=t/a.radix),a.exponent=t,a.offset=[],a.factor=[],a.minOffset=o,a.fullMask=0,a.fullOffset=[],a.fullFactor=[],a.modulus=r.modulus=new n.bn(Math.pow(2,t)),a.fullMask=0|-Math.pow(2,t%a.radix),i=0;i<e.length;i++)a.offset[i]=Math.floor(e[i][0]/a.radix-s),a.fullOffset[i]=Math.ceil(e[i][0]/a.radix-s),a.factor[i]=e[i][1]*Math.pow(.5,t-e[i][0]+a.offset[i]*a.radix),a.fullFactor[i]=e[i][1]*Math.pow(.5,t-e[i][0]+a.fullOffset[i]*a.radix),a.modulus.addM(new n.bn(Math.pow(2,e[i][0])*e[i][1])),a.minOffset=Math.min(a.minOffset,-a.offset[i]);return a._class=r,a.modulus.cnormalize(),a.reduce=function(){var t,e,r,n,i=this.modOffset,s=this.limbs,o=this.offset,a=this.offset.length,c=this.factor;for(t=this.minOffset;s.length>i;){for(r=s.pop(),n=s.length,e=0;a>e;e++)s[n+o[e]]-=c[e]*r;t--,t||(s.push(0),this.cnormalize(),t=this.minOffset)}return this.cnormalize(),this},a._strongReduce=-1===a.fullMask?a.reduce:function(){var t,e,r=this.limbs,n=r.length-1;if(this.reduce(),n===this.modOffset-1){for(e=r[n]&this.fullMask,r[n]-=e,t=0;t<this.fullOffset.length;t++)r[n+this.fullOffset[t]]-=this.fullFactor[t]*e;this.normalize()}},a.fullReduce=function(){var t,e;for(this._strongReduce(),this.addM(this.modulus),this.addM(this.modulus),this.normalize(),this._strongReduce(),e=this.limbs.length;e<this.modOffset;e++)this.limbs[e]=0;for(t=this.greaterEquals(this.modulus),e=0;e<this.limbs.length;e++)this.limbs[e]-=this.modulus.limbs[e]*t;return this.cnormalize(),this},a.inverse=function(){return this.power(this.modulus.sub(2))},r.fromBits=n.bn.fromBits,r},n.bn.prime={p127:n.bn.pseudoMersennePrime(127,[[0,-1]]),p25519:n.bn.pseudoMersennePrime(255,[[0,-19]]),p192:n.bn.pseudoMersennePrime(192,[[0,-1],[64,-1]]),p224:n.bn.pseudoMersennePrime(224,[[0,1],[96,-1]]),p256:n.bn.pseudoMersennePrime(256,[[0,-1],[96,1],[192,1],[224,-1]]),p384:n.bn.pseudoMersennePrime(384,[[0,-1],[32,1],[96,-1],[128,-1]]),p521:n.bn.pseudoMersennePrime(521,[[0,-1]])},n.bn.random=function(t,e){"object"!=typeof t&&(t=new n.bn(t));for(var r,i,s=t.limbs.length,o=t.limbs[s-1]+1,a=new n.bn;;){do r=n.random.randomWords(s,e),r[s-1]<0&&(r[s-1]+=4294967296);while(Math.floor(r[s-1]/o)===Math.floor(4294967296/o));for(r[s-1]%=o,i=0;s-1>i;i++)r[i]&=t.radixMask;if(a.limbs=r,!a.greaterEquals(t))return a}},n.ecc={},n.ecc.point=function(t,e,r){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.isIdentity=!1),this.curve=t},n.ecc.point.prototype={toJac:function(){return new n.ecc.pointJac(this.curve,this.x,this.y,new this.curve.field(1))},mult:function(t){return this.toJac().mult(t,this).toAffine()},mult2:function(t,e,r){return this.toJac().mult2(t,this,e,r).toAffine()},multiples:function(){var t,e,r;if(void 0===this._multiples)for(r=this.toJac().doubl(),t=this._multiples=[new n.ecc.point(this.curve),this,r.toAffine()],e=3;16>e;e++)r=r.add(this),t.push(r.toAffine());return this._multiples},isValid:function(){return this.y.square().equals(this.curve.b.add(this.x.mul(this.curve.a.add(this.x.square()))))},toBits:function(){return n.bitArray.concat(this.x.toBits(),this.y.toBits())}},n.ecc.pointJac=function(t,e,r,n){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.z=n,this.isIdentity=!1),this.curve=t},n.ecc.pointJac.prototype={add:function(t){var e,r,i,s,o,a,c,u,h,f,l,p=this;if(p.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";return p.isIdentity?t.toJac():t.isIdentity?p:(e=p.z.square(),r=t.x.mul(e).subM(p.x),r.equals(0)?p.y.equals(t.y.mul(e.mul(p.z)))?p.doubl():new n.ecc.pointJac(p.curve):(i=t.y.mul(e.mul(p.z)).subM(p.y),s=r.square(),o=i.square(),a=r.square().mul(r).addM(p.x.add(p.x).mul(s)),c=o.subM(a),u=p.x.mul(s).subM(c).mul(i),h=p.y.mul(r.square().mul(r)),f=u.subM(h),l=p.z.mul(r),new n.ecc.pointJac(this.curve,c,f,l)))},doubl:function(){if(this.isIdentity)return this;var t=this.y.square(),e=t.mul(this.x.mul(4)),r=t.square().mul(8),i=this.z.square(),s=this.x.sub(i).mul(3).mul(this.x.add(i)),o=s.square().subM(e).subM(e),a=e.sub(o).mul(s).subM(r),c=this.y.add(this.y).mul(this.z);return new n.ecc.pointJac(this.curve,o,a,c)},toAffine:function(){if(this.isIdentity||this.z.equals(0))return new n.ecc.point(this.curve);var t=this.z.inverse(),e=t.square();return new n.ecc.point(this.curve,this.x.mul(e).fullReduce(),this.y.mul(e.mul(t)).fullReduce())},mult:function(t,e){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var r,i,s=new n.ecc.point(this.curve).toJac(),o=e.multiples();for(r=t.length-1;r>=0;r--)for(i=n.bn.prototype.radix-4;i>=0;i-=4)s=s.doubl().doubl().doubl().doubl().add(o[15&t[r]>>i]);return s},mult2:function(t,e,r,i){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs),"number"==typeof r?r=[r]:void 0!==r.limbs&&(r=r.normalize().limbs);var s,o,a,c,u=new n.ecc.point(this.curve).toJac(),h=e.multiples(),f=i.multiples();for(s=Math.max(t.length,r.length)-1;s>=0;s--)for(a=0|t[s],c=0|r[s],o=n.bn.prototype.radix-4;o>=0;o-=4)u=u.doubl().doubl().doubl().doubl().add(h[15&a>>o]).add(f[15&c>>o]);return u},isValid:function(){var t=this.z.square(),e=t.square(),r=e.mul(t);return this.y.square().equals(this.curve.b.mul(r).add(this.x.mul(this.curve.a.mul(e).add(this.x.square()))))}},n.ecc.curve=function(t,e,r,i,s,o){this.field=t,this.r=t.prototype.modulus.sub(e),this.a=new t(r),this.b=new t(i),this.G=new n.ecc.point(this,new t(s),new t(o))},n.ecc.curve.prototype.fromBits=function(t){var e=n.bitArray,r=-8&this.field.prototype.exponent+7,i=new n.ecc.point(this,this.field.fromBits(e.bitSlice(t,0,r)),this.field.fromBits(e.bitSlice(t,r,2*r)));if(!i.isValid())throw new n.exception.corrupt("not on the curve!");return i},n.ecc.curves={c192:new n.ecc.curve(n.bn.prime.p192,"0x662107c8eb94364e4b2dd7ce",-3,"0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"),c224:new n.ecc.curve(n.bn.prime.p224,"0xe95c1f470fc1ec22d6baa3a3d5c4",-3,"0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4","0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21","0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),c256:new n.ecc.curve(n.bn.prime.p256,"0x4319055358e8617b0c46353d039cdaae",-3,"0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),c384:new n.ecc.curve(n.bn.prime.p384,"0x389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68c",-3,"0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef","0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7","0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},n.ecc._dh=function(t){n.ecc[t]={publicKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._point=e instanceof Array?t.fromBits(e):e,this.get=function(){var t=this._point.toBits(),e=n.bitArray.bitLength(t),r=n.bitArray.bitSlice(t,0,e/2),i=n.bitArray.bitSlice(t,e/2);return{x:r,y:i}}},secretKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._exponent=e,this.get=function(){return this._exponent.toBits()}},generateKeys:function(e,r,i){if(void 0===e&&(e=256),"number"==typeof e&&(e=n.ecc.curves["c"+e],void 0===e))throw new n.exception.invalid("no such curve");if(void 0===i)var i=n.bn.random(e.r,r);var s=e.G.mult(i);return{pub:new n.ecc[t].publicKey(e,s),sec:new n.ecc[t].secretKey(e,i)}}}},n.ecc._dh("elGamal"),n.ecc.elGamal.publicKey.prototype={kem:function(t){var e=n.bn.random(this._curve.r,t),r=this._curve.G.mult(e).toBits(),i=n.hash.sha256.hash(this._point.mult(e).toBits());return{key:i,tag:r}}},n.ecc.elGamal.secretKey.prototype={unkem:function(t){return n.hash.sha256.hash(this._curve.fromBits(t).mult(this._exponent).toBits())},dh:function(t){return n.hash.sha256.hash(t._point.mult(this._exponent).toBits())}},n.ecc._dh("ecdsa"),n.ecc.ecdsa.secretKey.prototype={sign:function(t,e,r,i){n.bitArray.bitLength(t)>this._curveBitLength&&(t=n.bitArray.clamp(t,this._curveBitLength));var s=this._curve.r,o=s.bitLength(),a=i||n.bn.random(s.sub(1),e).add(1),c=this._curve.G.mult(a).x.mod(s),u=n.bn.fromBits(t).add(c.mul(this._exponent)),h=r?u.inverseMod(s).mul(a).mod(s):u.mul(a.inverseMod(s)).mod(s);return n.bitArray.concat(c.toBits(o),h.toBits(o))}},n.ecc.ecdsa.publicKey.prototype={verify:function(t,e,r){n.bitArray.bitLength(t)>this._curveBitLength&&(t=n.bitArray.clamp(t,this._curveBitLength));var i=n.bitArray,s=this._curve.r,o=this._curveBitLength,a=n.bn.fromBits(i.bitSlice(e,0,o)),c=n.bn.fromBits(i.bitSlice(e,o,2*o)),u=r?c:c.inverseMod(s),h=n.bn.fromBits(t).mul(u).mod(s),f=a.mul(u).mod(s),l=this._curve.G.mult2(h,f,this._point).x;if(a.equals(0)||c.equals(0)||a.greaterEquals(s)||c.greaterEquals(s)||!l.equals(a)){if(void 0===r)return this.verify(t,e,!0);
throw new n.exception.corrupt("signature didn't check out")}return!0}},n.keyexchange.srp={makeVerifier:function(t,e,r,i){var s;return s=n.keyexchange.srp.makeX(t,e,r),s=n.bn.fromBits(s),i.g.powermod(s,i.N)},makeX:function(t,e,r){var i=n.hash.sha1.hash(t+":"+e);return n.hash.sha1.hash(n.bitArray.concat(r,i))},knownGroup:function(t){return"string"!=typeof t&&(t=t.toString()),n.keyexchange.srp._didInitKnownGroups||n.keyexchange.srp._initKnownGroups(),n.keyexchange.srp._knownGroups[t]},_didInitKnownGroups:!1,_initKnownGroups:function(){var t,e,r;for(t=0;t<n.keyexchange.srp._knownGroupSizes.length;t++)e=n.keyexchange.srp._knownGroupSizes[t].toString(),r=n.keyexchange.srp._knownGroups[e],r.N=new n.bn(r.N),r.g=new n.bn(r.g);n.keyexchange.srp._didInitKnownGroups=!0},_knownGroupSizes:[1024,1536,2048],_knownGroups:{1024:{N:"EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3",g:2},1536:{N:"9DEF3CAFB939277AB1F12A8617A47BBBDBA51DF499AC4C80BEEEA9614B19CC4D5F4F5F556E27CBDE51C6A94BE4607A291558903BA0D0F84380B655BB9A22E8DCDF028A7CEC67F0D08134B1C8B97989149B609E0BE3BAB63D47548381DBC5B1FC764E3F4B53DD9DA1158BFD3E2B9C8CF56EDF019539349627DB2FD53D24B7C48665772E437D6C7F8CE442734AF7CCB7AE837C264AE3A9BEB87F8A2FE9B8B5292E5A021FFF5E91479E8CE7A28C2442C6F315180F93499A234DCF76E3FED135F9BB",g:2},2048:{N:"AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73",g:2}}},n.ecc.curves.c256=new n.ecc.curve(n.bn.pseudoMersennePrime(256,[[0,-1],[4,-1],[6,-1],[7,-1],[8,-1],[9,-1],[32,-1]]),"0x14551231950b75fc4402da1722fc9baee",0,7,"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),n.ecc.pointJac.prototype.add=function(t){var e=this;if(e.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";if(e.isIdentity)return t.toJac();if(t.isIdentity)return e;var r=e.z.square(),i=t.x.mul(r).subM(e.x),s=t.y.mul(e.z).mul(r);if(i.equals(0))return e.y.equals(t.y.mul(r.mul(e.z)))?e.doubl():new n.ecc.pointJac(e.curve);var o=i.square(),a=o.copy().doubleM().doubleM(),c=i.mul(a),u=s.sub(e.y).doubleM(),h=e.x.mul(a),f=u.square().subM(c).subM(h.copy().doubleM()),l=u.mul(h.sub(f)).subM(e.y.mul(c).doubleM()),p=e.z.add(i).square().subM(r).subM(o);return new n.ecc.pointJac(this.curve,f,l,p)},n.ecc.pointJac.prototype.doubl=function(){if(this.isIdentity)return this;var t=this.x.square(),e=this.y.square(),r=e.square(),i=this.x.add(e).square().subM(t).subM(r).doubleM(),s=t.mul(3),o=s.square(),a=o.sub(i.copy().doubleM()),c=s.mul(i.sub(a)).subM(r.doubleM().doubleM().doubleM()),u=this.y.mul(this.z).doubleM();return new n.ecc.pointJac(this.curve,a,c,u)},n.ecc.point.prototype.toBytesCompressed=function(){var t="0x0"==this.y.mod(2).toString()?2:3;return[t].concat(n.codec.bytes.fromBits(this.x.toBits()))},function(){function t(t,e,r){return t^e^r}function e(t,e,r){return t&e|~t&r}function r(t,e,r){return(t|~e)^r}function i(t,e,r){return t&r|e&~r}function s(t,e,r){return t^(e|~r)}function o(t,e){return t<<e|t>>>32-e}function a(t){return(255&t)<<24|(65280&t)<<8|(t&255<<16)>>>8|(t&255<<24)>>>24}function c(n){for(var a,c=this._h[0],u=this._h[1],l=this._h[2],p=this._h[3],v=this._h[4],g=this._h[0],b=this._h[1],w=this._h[2],E=this._h[3],x=this._h[4],S=0;16>S;++S)a=o(c+t(u,l,p)+n[_[S]]+h[S],y[S])+v,c=v,v=p,p=o(l,10),l=u,u=a,a=o(g+s(b,w,E)+n[d[S]]+f[S],m[S])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;32>S;++S)a=o(c+e(u,l,p)+n[_[S]]+h[S],y[S])+v,c=v,v=p,p=o(l,10),l=u,u=a,a=o(g+i(b,w,E)+n[d[S]]+f[S],m[S])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;48>S;++S)a=o(c+r(u,l,p)+n[_[S]]+h[S],y[S])+v,c=v,v=p,p=o(l,10),l=u,u=a,a=o(g+r(b,w,E)+n[d[S]]+f[S],m[S])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;64>S;++S)a=o(c+i(u,l,p)+n[_[S]]+h[S],y[S])+v,c=v,v=p,p=o(l,10),l=u,u=a,a=o(g+e(b,w,E)+n[d[S]]+f[S],m[S])+x,g=x,x=E,E=o(w,10),w=b,b=a;for(;80>S;++S)a=o(c+s(u,l,p)+n[_[S]]+h[S],y[S])+v,c=v,v=p,p=o(l,10),l=u,u=a,a=o(g+t(b,w,E)+n[d[S]]+f[S],m[S])+x,g=x,x=E,E=o(w,10),w=b,b=a;a=this._h[1]+l+E,this._h[1]=this._h[2]+p+x,this._h[2]=this._h[3]+v+g,this._h[3]=this._h[4]+c+b,this._h[4]=this._h[0]+u+w,this._h[0]=a}n.hash.ripemd160=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},n.hash.ripemd160.hash=function(t){return(new n.hash.ripemd160).update(t).finalize()},n.hash.ripemd160.prototype={reset:function(){return this._h=u.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this._buffer=n.bitArray.concat(this._buffer,t),i=this._length,s=this._length=i+n.bitArray.bitLength(t);for(e=-512&512+i;s>=e;e+=512){for(var o=r.splice(0,16),u=0;16>u;++u)o[u]=a(o[u]);c.call(this,o)}return this},finalize:function(){var t=n.bitArray.concat(this._buffer,[n.bitArray.partial(1,1)]),e=(this._length+1)%512,r=(e>448?512:448)-e%448,i=r%32;for(i>0&&(t=n.bitArray.concat(t,[n.bitArray.partial(i,0)]));r>=32;r-=32)t.push(0);for(t.push(a(0|this._length)),t.push(a(Math.floor(this._length/4294967296)));t.length;){for(var s=t.splice(0,16),o=0;16>o;++o)s[o]=a(s[o]);c.call(this,s)}var u=this._h;this.reset();for(var o=0;5>o;++o)u[o]=a(u[o]);return u}};for(var u=[1732584193,4023233417,2562383102,271733878,3285377520],h=[0,1518500249,1859775393,2400959708,2840853838],f=[1352829926,1548603684,1836072691,2053994217,0],l=4;l>=0;--l)for(var p=1;16>p;++p)h.splice(l,0,h[l]),f.splice(l,0,f[l]);var _=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],d=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],m=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]}(),n.bn.ZERO=new n.bn(0),n.bn.prototype.divRem=function(t){"object"!=typeof t&&(t=new this._class(t));var e=this.abs(),r=t.abs(),i=new this._class(0),s=0;if(!e.greaterEquals(r))return[new n.bn(0),this.copy()];if(e.equals(r))return[new n.bn(1),new n.bn(0)];for(;e.greaterEquals(r);s++)r.doubleM();for(;s>0;s--)i.doubleM(),r.halveM(),e.greaterEquals(r)&&(i.addM(1),e.subM(t).normalize());return[i,e]},n.bn.prototype.divRound=function(t){var e=this.divRem(t),r=e[0],n=e[1];return n.doubleM().greaterEquals(t)&&r.addM(1),r},n.bn.prototype.div=function(t){var e=this.divRem(t);return e[0]},n.bn.prototype.sign=function(){return this.greaterEquals(n.bn.ZERO)?1:-1},n.bn.prototype.neg=function(){return n.bn.ZERO.sub(this)},n.bn.prototype.abs=function(){return-1===this.sign()?this.neg():this},n.bn.prototype.shiftRight=function(t){if("number"!=typeof t)throw new Error("shiftRight expects a number");if(t=+t,0>t)return this.shiftLeft(t);for(var e=new n.bn(this);t>=this.radix;)e.limbs.shift(),t-=this.radix;for(;t--;)e.halveM();return e},n.bn.prototype.shiftLeft=function(t){if("number"!=typeof t)throw new Error("shiftLeft expects a number");if(t=+t,0>t)return this.shiftRight(t);for(var e=new n.bn(this);t>=this.radix;)e.limbs.unshift(0),t-=this.radix;for(;t--;)e.doubleM();return e},n.bn.prototype.toNumber=function(){return 0|this.limbs[0]},n.bn.prototype.testBit=function(t){var e=Math.floor(t/this.radix),r=t%this.radix;return e>=this.limbs.length?0:1&this.limbs[e]>>>r},n.bn.prototype.setBitM=function(t){for(var e=Math.floor(t/this.radix),r=t%this.radix;e>=this.limbs.length;)this.limbs.push(0);return this.limbs[e]|=1<<r,this.cnormalize(),this},n.bn.prototype.modInt=function(t){return this.toNumber()%t},n.bn.prototype.invDigit=function(){var t=1+this.radixMask;if(this.limbs.length<1)return 0;var e=this.limbs[0];if(0==(1&e))return 0;var r=3&e;return r=15&r*(2-(15&e)*r),r=255&r*(2-(255&e)*r),r=65535&r*(2-(65535&(65535&e)*r)),r=r*(2-e*r%t)%t,r>0?t-r:-r},n.bn.prototype.am=function(t,e,r,n,i,s){for(var o=4095&e,a=e>>12;--s>=0;){var c=4095&this.limbs[t],u=this.limbs[t++]>>12,h=a*c+u*o;c=o*c+((4095&h)<<12)+r.limbs[n]+i,i=(c>>24)+(h>>12)+a*u,r.limbs[n++]=16777215&c}return i};var i=function(t){this.m=t,this.mt=t.limbs.length,this.mt2=2*this.mt,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.radix-15)-1};i.prototype.reduce=function(t){for(var e=t.radixMask+1;t.limbs.length<=this.mt2;)t.limbs[t.limbs.length]=0;for(var r=0;r<this.mt;++r){var n=32767&t.limbs[r],i=n*this.mpl+((n*this.mph+(t.limbs[r]>>15)*this.mpl&this.um)<<15)&t.radixMask;for(n=r+this.mt,t.limbs[n]+=this.m.am(0,i,t,r,0,this.mt);t.limbs[n]>=e;)t.limbs[n]-=e,t.limbs[++n]++}return t.trim(),t=t.shiftRight(this.mt*this.m.radix),t.greaterEquals(this.m)&&(t=t.sub(this.m)),t.trim().normalize().reduce()},i.prototype.square=function(t){return this.reduce(t.square())},i.prototype.multiply=function(t,e){return this.reduce(t.mul(e))},i.prototype.convert=function(t){return t.abs().shiftLeft(this.mt*this.m.radix).mod(this.m)},i.prototype.revert=function(t){return this.reduce(t.copy())},n.bn.prototype.powermodMontgomery=function(t,e){var n,s=t.bitLength(),o=new this._class(1);if(0>=s)return o;if(n=18>s?1:48>s?3:144>s?4:768>s?5:6,8>s||!e.testBit(0))return this.powermod(t,e);var a=new i(e);t.trim().normalize();var c=new Array,u=3,h=n-1,f=(1<<n)-1;if(c[1]=a.convert(this),n>1)for(var l=a.square(c[1]);f>=u;)c[u]=a.multiply(l,c[u-2]),u+=2;var p,_,d=t.limbs.length-1,y=!0,m=new this._class;for(s=r(t.limbs[d])-1;d>=0;){for(s>=h?p=t.limbs[d]>>s-h&f:(p=(t.limbs[d]&(1<<s+1)-1)<<h-s,d>0&&(p|=t.limbs[d-1]>>this.radix+s-h)),u=n;0==(1&p);)p>>=1,--u;if((s-=u)<0&&(s+=this.radix,--d),y)o=c[p].copy(),y=!1;else{for(;u>1;)m=a.square(o),o=a.square(m),u-=2;u>0?m=a.square(o):(_=o,o=m,m=_),o=a.multiply(m,c[p])}for(;d>=0&&0==(t.limbs[d]&1<<s);)m=a.square(o),_=o,o=m,m=_,--s<0&&(s=this.radix-1,--d)}return a.revert(o)},n.ecc.ecdsa.secretKey.prototype={sign:function(t,e){var r=this._curve.r,i=r.bitLength(),s=n.bn.random(r.sub(1),e).add(1),o=this._curve.G.mult(s).x.mod(r),a=n.bn.fromBits(t).add(o.mul(this._exponent)).mul(s.inverseMod(r)).mod(r);return n.bitArray.concat(o.toBits(i),a.toBits(i))}},n.ecc.ecdsa.publicKey.prototype={verify:function(t,e){var r=n.bitArray,i=this._curve.r,s=i.bitLength(),o=n.bn.fromBits(r.bitSlice(e,0,s)),a=n.bn.fromBits(r.bitSlice(e,s,2*s)),c=a.inverseMod(i),u=n.bn.fromBits(t).mul(c).mod(i),h=o.mul(c).mod(i),f=this._curve.G.mult2(u,h,this._point).x;if(o.equals(0)||a.equals(0)||o.greaterEquals(i)||a.greaterEquals(i)||!f.equals(o))throw new n.exception.corrupt("signature didn't check out");return!0}},n.ecc.ecdsa.secretKey.prototype.canonicalizeSignature=function(t){var e=n.bitArray,r=this._curve.r,i=r.bitLength(),s=n.bn.fromBits(e.bitSlice(t,0,i)),o=n.bn.fromBits(e.bitSlice(t,i,2*i));return r.copy().halveM().greaterEquals(o)||(o=r.sub(o)),e.concat(s.toBits(i),o.toBits(i))},n.ecc.ecdsa.secretKey.prototype.signDER=function(t,e){return this.encodeDER(this.sign(t,e))},n.ecc.ecdsa.secretKey.prototype.encodeDER=function(t){for(var e=n.bitArray,r=this._curve.r,i=r.bitLength(),s=n.codec.bytes.fromBits(e.bitSlice(t,0,i)),o=n.codec.bytes.fromBits(e.bitSlice(t,i,2*i));!s[0]&&s.length;)s.shift();for(;!o[0]&&o.length;)o.shift();128&s[0]&&s.unshift(0),128&o[0]&&o.unshift(0);var a=[].concat(48,4+s.length+o.length,2,s.length,s,2,o.length,o);return n.codec.bytes.toBits(a)},n.bn.prototype.jacobi=function(t){var e=this;if(t=new n.bn(t),-1!==t.sign()){if(e.equals(0))return 0;if(e.equals(1))return 1;for(var r=0,i=0;!e.testBit(i);)i++;var s=e.shiftRight(i);if(0===(1&i))r=1;else{var o=t.modInt(8);1===o||7===o?r=1:(3===o||5===o)&&(r=-1)}return 3===t.modInt(4)&&3===s.modInt(4)&&(r=-r),s.equals(1)?r:r*t.mod(s).jacobi(s)}}}(r,r(39)(t))},29:function(t,e){function r(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function n(){return new r(null)}function i(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i}function s(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*o;c=o*c+((32767&h)<<15)+r[n]+(1073741823&i),i=(c>>>30)+(h>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i}function o(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*o;c=o*c+((16383&h)<<14)+r[n]+i,i=(c>>28)+(h>>14)+a*u,r[n++]=268435455&c}return i}function a(t){return or.charAt(t)}function c(t,e){var r=ar[t.charCodeAt(e)];return null==r?-1:r}function u(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function h(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+this.DV:this.t=0}function f(t){var e=n();return e.fromInt(t),e}function l(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return this.fromRadix(t,e),void 0;n=2}this.t=0,this.s=0;for(var i=t.length,s=!1,o=0;--i>=0;){var a=8==n?255&t[i]:c(t,i);0>a?"-"==t.charAt(i)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,o+=n,o>=this.DB&&(o-=this.DB))}8==n&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&r.ZERO.subTo(this,this)}function p(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function _(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,s="",o=this.t,c=this.DB-o*this.DB%e;if(o-->0)for(c<this.DB&&(r=this[o]>>c)>0&&(i=!0,s=a(r));o>=0;)e>c?(r=(this[o]&(1<<c)-1)<<e-c,r|=this[--o]>>(c+=this.DB-e)):(r=this[o]>>(c-=e)&n,0>=c&&(c+=this.DB,--o)),r>0&&(i=!0),i&&(s+=a(r));return i?s:"0"}function d(){var t=n();return r.ZERO.subTo(this,t),t}function y(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(e=r-t.t,0!=e)return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}function v(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function g(){return this.t<=0?0:this.DB*(this.t-1)+v(this[this.t-1]^this.s&this.DM)}function b(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}function w(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}function E(t,e){var r,n=t%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;r>=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()}function x(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)return e.t=0,void 0;var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;n>0&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}function S(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);i>r;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=0>n?-1:0,-1>n?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}function T(t,e){var n=this.abs(),i=t.abs(),s=n.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+n.t]=n.am(0,i[s],e,s,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)}function A(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}function k(t,e,i){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t<s.t)return null!=e&&e.fromInt(0),null!=i&&this.copyTo(i),void 0;null==i&&(i=n());var a=n(),c=this.s,u=t.s,h=this.DB-v(s[s.t-1]);h>0?(s.lShiftTo(h,a),o.lShiftTo(h,i)):(s.copyTo(a),o.copyTo(i));var f=a.t,l=a[f-1];if(0!=l){var p=l*(1<<this.F1)+(f>1?a[f-2]>>this.F2:0),_=this.FV/p,d=(1<<this.F1)/p,y=1<<this.F2,m=i.t,g=m-f,b=null==e?n():e;for(a.dlShiftTo(g,b),i.compareTo(b)>=0&&(i[i.t++]=1,i.subTo(b,i)),r.ONE.dlShiftTo(f,b),b.subTo(a,a);a.t<f;)a[a.t++]=0;for(;--g>=0;){var w=i[--m]==l?this.DM:Math.floor(i[m]*_+(i[m-1]+y)*d);if((i[m]+=a.am(0,w,i,g,0,f))<w)for(a.dlShiftTo(g,b),i.subTo(b,i);i[m]<--w;)i.subTo(b,i)}null!=e&&(i.drShiftTo(f,e),c!=u&&r.ZERO.subTo(e,e)),i.t=f,i.clamp(),h>0&&i.rShiftTo(h,i),0>c&&r.ZERO.subTo(i,i)}}}function j(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e}function B(t){this.m=t}function I(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function R(t){return t}function q(t){t.divRemTo(this.m,null,t)}function D(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function C(t,e){t.squareTo(e),this.reduce(e)}function O(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=15&e*(2-(15&t)*e),e=255&e*(2-(255&t)*e),e=65535&e*(2-(65535&(65535&t)*e)),e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function L(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function M(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(r.ZERO)>0&&this.m.subTo(e,e),e}function N(t){var e=n();return t.copyTo(e),this.reduce(e),e}function F(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t[r]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function P(t,e){t.squareTo(e),this.reduce(e)}function z(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function U(){return 0==(this.t>0?1&this[0]:this.s)}function H(t,e){if(t>4294967295||1>t)return r.ONE;var i=n(),s=n(),o=e.convert(this),a=v(t)-1;for(o.copyTo(i);--a>=0;)if(e.sqrTo(i,s),(t&1<<a)>0)e.mulTo(s,o,i);else{var c=i;i=s,s=c}return e.revert(i)}function V(t,e){var r;return r=256>t||e.isEven()?new B(e):new L(e),this.exp(t,r)}function X(){var t=n();return this.copyTo(t),t}function G(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Z(){return 0==this.t?this.s:this[0]<<24>>24}function K(){return 0==this.t?this.s:this[0]<<16>>16}function W(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function J(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function Q(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=f(r),s=n(),o=n(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(r+o.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(t)+a}function Y(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),i=Math.pow(e,n),s=!1,o=0,a=0,u=0;u<t.length;++u){var h=c(t,u);0>h?"-"==t.charAt(u)&&0==this.signum()&&(s=!0):(a=e*a+h,++o>=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),s&&r.ZERO.subTo(this,this)}function $(t,e,n){if("number"==typeof e)if(2>t)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),ae,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=(t>>3)+1,e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}}function te(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-->0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)8>n?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=255&this[t]>>(n-=8),0>=n&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e}function ee(t){return 0==this.compareTo(t)}function re(t){return this.compareTo(t)<0?this:t}function ne(t){return this.compareTo(t)>0?this:t}function ie(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;s>n;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function se(t,e){return t&e}function oe(t){var e=n();return this.bitwiseTo(t,se,e),e}function ae(t,e){return t|e}function ce(t){var e=n();return this.bitwiseTo(t,ae,e),e}function ue(t,e){return t^e}function he(t){var e=n();return this.bitwiseTo(t,ue,e),e}function fe(t,e){return t&~e}function le(t){var e=n();return this.bitwiseTo(t,fe,e),e}function pe(){for(var t=n(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function _e(t){var e=n();return 0>t?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function de(t){var e=n();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function ye(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function me(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+ye(this[t]);return this.s<0?this.t*this.DB:-1}function ve(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function ge(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=ve(this[r]^e);return t}function be(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)}function we(t,e){var n=r.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n}function Ee(t){return this.changeBit(t,ae)}function xe(t){return this.changeBit(t,fe)}function Se(t){return this.changeBit(t,ue)}function Te(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);i>r;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=0>n?-1:0,n>0?e[r++]=n:-1>n&&(e[r++]=this.DV+n),e.t=r,e.clamp()}function Ae(t){var e=n();return this.addTo(t,e),e}function ke(t){var e=n();return this.subTo(t,e),e}function je(t){var e=n();return this.multiplyTo(t,e),e}function Be(){var t=n();return this.squareTo(t),t}function Ie(t){var e=n();return this.divRemTo(t,e,null),e}function Re(t){var e=n();return this.divRemTo(t,null,e),e}function qe(t){var e=n(),r=n();return this.divRemTo(t,e,r),new Array(e,r)}function De(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Ce(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function Oe(){}function Le(t){return t}function Me(t,e,r){t.multiplyTo(e,r)}function Ne(t,e){t.squareTo(e)}function Fe(t){return this.exp(t,new Oe)}function Pe(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;var i;for(i=r.t-this.t;i>n;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);i>n;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}function ze(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}function Ue(t){this.r2=n(),this.q3=n(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function He(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e}function Ve(t){return t}function Xe(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function Ge(t,e){t.squareTo(e),this.reduce(e)}function Ze(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function Ke(t,e){var r,i,s=t.bitLength(),o=f(1);if(0>=s)return o;r=18>s?1:48>s?3:144>s?4:768>s?5:6,i=8>s?new B(e):e.isEven()?new Ue(e):new L(e);var a=new Array,c=3,u=r-1,h=(1<<r)-1;if(a[1]=i.convert(this),r>1){var l=n();for(i.sqrTo(a[1],l);h>=c;)a[c]=n(),i.mulTo(l,a[c-2],a[c]),c+=2}var p,_,d=t.t-1,y=!0,m=n();for(s=v(t[d])-1;d>=0;){for(s>=u?p=t[d]>>s-u&h:(p=(t[d]&(1<<s+1)-1)<<u-s,d>0&&(p|=t[d-1]>>this.DB+s-u)),c=r;0==(1&p);)p>>=1,--c;if((s-=c)<0&&(s+=this.DB,--d),y)a[p].copyTo(o),y=!1;else{for(;c>1;)i.sqrTo(o,m),i.sqrTo(m,o),c-=2;c>0?i.sqrTo(o,m):(_=o,o=m,m=_),i.mulTo(m,a[p],o)}for(;d>=0&&0==(t[d]&1<<s);)i.sqrTo(o,m),_=o,o=m,m=_,--s<0&&(s=this.DB-1,--d)}return i.revert(o)}function We(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(0>s)return e;for(s>i&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function Je(t){if(0>=t)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}function Qe(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var n=t.clone(),i=this.clone(),s=f(1),o=f(0),a=f(0),c=f(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(t,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),e?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(t,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);n.compareTo(i)>=0?(n.subTo(i,n),e&&s.subTo(a,s),o.subTo(c,o)):(i.subTo(n,i),e&&a.subTo(s,a),c.subTo(o,c))}return 0!=i.compareTo(r.ONE)?r.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c}function Ye(t){var e,r=this.abs();if(1==r.t&&r[0]<=cr[cr.length-1]){for(e=0;e<cr.length;++e)if(r[0]==cr[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<cr.length;){for(var n=cr[e],i=e+1;i<cr.length&&ur>n;)n*=cr[i++];for(n=r.modInt(n);i>e;)if(0==n%cr[e++])return!1}return r.millerRabin(t)}function $e(t){var e=this.subtract(r.ONE),i=e.getLowestSetBit();if(0>=i)return!1;var s=e.shiftRight(i);t=t+1>>1,t>cr.length&&(t=cr.length);for(var o=n(),a=0;t>a;++a){o.fromInt(cr[Math.floor(Math.random()*cr.length)]);var c=o.modPow(s,this);if(0!=c.compareTo(r.ONE)&&0!=c.compareTo(e)){for(var u=1;u++<i&&0!=c.compareTo(e);)if(c=c.modPowInt(2,this),0==c.compareTo(r.ONE))return!1;if(0!=c.compareTo(e))return!1}}return!0}var tr,er=0xdeadbeefcafe,rr=15715070==(16777215&er);rr&&"undefined"!=typeof navigator&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=s,tr=30):rr&&"undefined"!=typeof navigator&&"Netscape"!=navigator.appName?(r.prototype.am=i,tr=26):(r.prototype.am=o,tr=28),r.prototype.DB=tr,r.prototype.DM=(1<<tr)-1,r.prototype.DV=1<<tr;var nr=52;r.prototype.FV=Math.pow(2,nr),r.prototype.F1=nr-tr,r.prototype.F2=2*tr-nr;var ir,sr,or="0123456789abcdefghijklmnopqrstuvwxyz",ar=new Array;for(ir="0".charCodeAt(0),sr=0;9>=sr;++sr)ar[ir++]=sr;for(ir="a".charCodeAt(0),sr=10;36>sr;++sr)ar[ir++]=sr;for(ir="A".charCodeAt(0),sr=10;36>sr;++sr)ar[ir++]=sr;B.prototype.convert=I,B.prototype.revert=R,B.prototype.reduce=q,B.prototype.mulTo=D,B.prototype.sqrTo=C,L.prototype.convert=M,L.prototype.revert=N,L.prototype.reduce=F,L.prototype.mulTo=z,L.prototype.sqrTo=P,Oe.prototype.convert=Le,Oe.prototype.revert=Le,Oe.prototype.mulTo=Me,Oe.prototype.sqrTo=Ne,Ue.prototype.convert=He,Ue.prototype.revert=Ve,Ue.prototype.reduce=Xe,Ue.prototype.mulTo=Ze,Ue.prototype.sqrTo=Ge;var cr=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ur=(1<<26)/cr[cr.length-1];r.prototype.chunkSize=W,r.prototype.toRadix=Q,r.prototype.fromRadix=Y,r.prototype.fromNumber=$,r.prototype.bitwiseTo=ie,r.prototype.changeBit=we,r.prototype.addTo=Te,r.prototype.dMultiply=De,r.prototype.dAddOffset=Ce,r.prototype.multiplyLowerTo=Pe,r.prototype.multiplyUpperTo=ze,r.prototype.modInt=Je,r.prototype.millerRabin=$e,r.prototype.copyTo=u,r.prototype.fromInt=h,r.prototype.fromString=l,r.prototype.clamp=p,r.prototype.dlShiftTo=b,r.prototype.drShiftTo=w,r.prototype.lShiftTo=E,r.prototype.rShiftTo=x,r.prototype.subTo=S,r.prototype.multiplyTo=T,r.prototype.squareTo=A,r.prototype.divRemTo=k,r.prototype.invDigit=O,r.prototype.isEven=U,r.prototype.exp=H,r.prototype.toString=_,r.prototype.negate=d,r.prototype.abs=y,r.prototype.compareTo=m,r.prototype.bitLength=g,r.prototype.mod=j,r.prototype.modPowInt=V,r.prototype.clone=X,r.prototype.intValue=G,r.prototype.byteValue=Z,r.prototype.shortValue=K,r.prototype.signum=J,r.prototype.toByteArray=te,r.prototype.equals=ee,r.prototype.min=re,r.prototype.max=ne,r.prototype.and=oe,r.prototype.or=ce,r.prototype.xor=he,r.prototype.andNot=le,r.prototype.not=pe,r.prototype.shiftLeft=_e,r.prototype.shiftRight=de,r.prototype.getLowestSetBit=me,r.prototype.bitCount=ge,r.prototype.testBit=be,r.prototype.setBit=Ee,r.prototype.clearBit=xe,r.prototype.flipBit=Se,r.prototype.add=Ae,r.prototype.subtract=ke,r.prototype.multiply=je,r.prototype.divide=Ie,r.prototype.remainder=Re,r.prototype.divideAndRemainder=qe,r.prototype.modPow=Ke,r.prototype.modInverse=Qe,r.prototype.pow=Fe,r.prototype.gcd=We,r.prototype.isProbablePrime=Ye,r.prototype.square=Be,r.ZERO=f(0),r.ONE=f(1),r.valueOf=n,e.BigInteger=r},30:function(t){try{t.exports=WebSocket}catch(e){t.exports=MozWebSocket}var r,n=/Version\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//;"object"==typeof navigator&&"string"==typeof navigator.userAgent&&(r=n.exec(navigator.userAgent))&&2===window.WebSocket.CLOSED&&(/iP(hone|od|ad)/.test(navigator.platform)?+r[1]<5&&(t.exports=void 0):-1!==navigator.appVersion.indexOf("Mac")&&+r[1]<6&&(t.exports=void 0))},31:function(t,e,r){var n=e.EventEmitter=function(){},i=r(40);r(41);var s=10;n.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._maxListeners=t},n.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var r=Array.prototype.slice.call(arguments,1);e.apply(this,r)}return!0}if(i(e)){for(var r=Array.prototype.slice.call(arguments,1),n=e.slice(),s=0,o=n.length;o>s;s++)n[s].apply(this,r);
return!0}return!1},n.prototype.addListener=function(t,e){if("function"!=typeof e)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t]?i(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,i(this._events[t])&&!this._events[t].warned){var r;r=void 0!==this._maxListeners?this._maxListeners:s,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(events) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){n.removeListener(t,r),e.apply(this,arguments)}if("function"!=typeof e)throw new Error(".once only takes instances of Function");var n=this;return r.listener=e,n.on(t,r),this},n.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var r=this._events[t];if(i(r)){for(var n=-1,s=0,o=r.length;o>s;s++)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;r.splice(n,1),0==r.length&&delete this._events[t]}else(r===e||r.listener&&r.listener===e)&&delete this._events[t];return this},n.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},n.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),i(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}},32:function(t,e,r){function n(t){if(t instanceof Date)return!0;if("object"!=typeof t)return!1;var e=Date.prototype&&o(Date.prototype),r=t.__proto__&&o(t.__proto__);return JSON.stringify(r)===JSON.stringify(e)}r(31);var i=r(40),s=r(42),o=r(43),a=r(44),c=r(45);e.isArray=i,e.isDate=n,e.isRegExp=c,e.print=function(){},e.puts=function(){},e.debug=function(){},e.inspect=function(t,r,a,u){function h(t,a){if(t&&"function"==typeof t.inspect&&t!==e&&(!t.constructor||t.constructor.prototype!==t))return t.inspect(a);switch(typeof t){case"undefined":return l("undefined","undefined");case"string":var u="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l(u,"string");case"number":return l(""+t,"number");case"boolean":return l(""+t,"boolean")}if(null===t)return l("null","null");var p=s(t),_=r?o(t):p;if("function"==typeof t&&0===_.length){if(c(t))return l(""+t,"regexp");var d=t.name?": "+t.name:"";return l("[Function"+d+"]","special")}if(n(t)&&0===_.length)return l(t.toUTCString(),"date");var y,m,v;if(i(t)?(m="Array",v=["[","]"]):(m="Object",v=["{","}"]),"function"==typeof t){var g=t.name?": "+t.name:"";y=c(t)?" "+t:" [Function"+g+"]"}else y="";if(n(t)&&(y=" "+t.toUTCString()),0===_.length)return v[0]+y+v[1];if(0>a)return c(t)?l(""+t,"regexp"):l("[Object]","special");f.push(t);var b=_.map(function(e){var r,n;if(t.__lookupGetter__&&(t.__lookupGetter__(e)?n=t.__lookupSetter__(e)?l("[Getter/Setter]","special"):l("[Getter]","special"):t.__lookupSetter__(e)&&(n=l("[Setter]","special"))),p.indexOf(e)<0&&(r="["+e+"]"),n||(f.indexOf(t[e])<0?(n=null===a?h(t[e]):h(t[e],a-1),n.indexOf("\n")>-1&&(n=i(t)?n.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+n.split("\n").map(function(t){return" "+t}).join("\n"))):n=l("[Circular]","special")),"undefined"==typeof r){if("Array"===m&&e.match(/^\d+$/))return n;r=JSON.stringify(""+e),r.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(r=r.substr(1,r.length-2),r=l(r,"name")):(r=r.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),r=l(r,"string"))}return r+": "+n});f.pop();var w=0,E=b.reduce(function(t,e){return w++,e.indexOf("\n")>=0&&w++,t+e.length+1},0);return b=E>50?v[0]+(""===y?"":y+"\n ")+" "+b.join(",\n ")+" "+v[1]:v[0]+y+" "+b.join(", ")+" "+v[1]}var f=[],l=function(t,e){var r={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},n={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[e];return n?"["+r[n][0]+"m"+t+"["+r[n][1]+"m":t};return u||(l=function(t){return t}),h(t,"undefined"==typeof a?2:a)},e.log=function(){},e.pump=null,e.inherits=function(t,e){t.super_=e,t.prototype=a(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};var u=/%[sdj%]/g;e.format=function(t){if("string"!=typeof t){for(var r=[],n=0;n<arguments.length;n++)r.push(e.inspect(arguments[n]));return r.join(" ")}for(var n=1,i=arguments,s=i.length,o=String(t).replace(u,function(t){if("%%"===t)return"%";if(n>=s)return t;switch(t){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":return JSON.stringify(i[n++]);default:return t}}),a=i[n];s>n;a=i[++n])o+=null===a||"object"!=typeof a?" "+a:" "+e.inspect(a);return o}},33:function(t,e,r){function n(t,e){return void 0===e?""+e:"number"!=typeof e||!isNaN(e)&&isFinite(e)?"function"==typeof e||e instanceof RegExp?e.toString():e:e.toString()}function i(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function s(t,e,r,n,i){throw new m.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function o(t,e){t||s(t,!0,e,"==",m.ok)}function a(t,e){if(t===e)return!0;if(r(27).Buffer.isBuffer(t)&&r(27).Buffer.isBuffer(e)){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():y(t)&&y(e)?t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase:"object"!=typeof t&&"object"!=typeof e?t==e:h(t,e)}function c(t){return null===t||void 0===t}function u(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function h(t,e){if(c(t)||c(e))return!1;if(t.prototype!==e.prototype)return!1;if(u(t))return u(e)?(t=_.call(t),e=_.call(e),a(t,e)):!1;try{var r,n,i=d(t),s=d(e)}catch(o){return!1}if(i.length!=s.length)return!1;for(i.sort(),s.sort(),n=i.length-1;n>=0;n--)if(i[n]!=s[n])return!1;for(n=i.length-1;n>=0;n--)if(r=i[n],!a(t[r],e[r]))return!1;return!0}function f(t,e){return t&&e?y(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function l(t,e,r,n){var i;"string"==typeof r&&(n=r,r=null);try{e()}catch(o){i=o}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&s(i,r,"Missing expected exception"+n),!t&&f(i,r)&&s(i,r,"Got unwanted exception"+n),t&&i&&r&&!f(i,r)||!t&&i)throw i}var p=r(32),_=Array.prototype.slice,d=r(42),y=r(45),m=t.exports=o;m.AssertionError=function(t){this.name="AssertionError",this.message=t.message,this.actual=t.actual,this.expected=t.expected,this.operator=t.operator;var e=t.stackStartFunction||s;Error.captureStackTrace&&Error.captureStackTrace(this,e)},p.inherits(m.AssertionError,Error),m.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",i(JSON.stringify(this.actual,n),128),this.operator,i(JSON.stringify(this.expected,n),128)].join(" ")},m.AssertionError.__proto__=Error.prototype,m.fail=s,m.ok=o,m.equal=function(t,e,r){t!=e&&s(t,e,r,"==",m.equal)},m.notEqual=function(t,e,r){t==e&&s(t,e,r,"!=",m.notEqual)},m.deepEqual=function(t,e,r){a(t,e)||s(t,e,r,"deepEqual",m.deepEqual)},m.notDeepEqual=function(t,e,r){a(t,e)&&s(t,e,r,"notDeepEqual",m.notDeepEqual)},m.strictEqual=function(t,e,r){t!==e&&s(t,e,r,"===",m.strictEqual)},m.notStrictEqual=function(t,e,r){t===e&&s(t,e,r,"!==",m.notStrictEqual)},m.throws=function(){l.apply(this,[!0].concat(_.call(arguments)))},m.doesNotThrow=function(){l.apply(this,[!1].concat(_.call(arguments)))},m.ifError=function(t){if(t)throw t}},34:function(t){var e=function(t){this._namespace=t?Array.isArray(t)?t:[""+t]:[],this._prefix=this._namespace.concat([""]).join(": ")};e.prototype.sub=function(t){var r=this._namespace.slice();t&&"string"==typeof t&&r.push(t);var n=new e(r);return n._setParent(this),n},e.prototype._setParent=function(t){this._parent=t},e.makeLevel=function(){return function(){arguments[0]=this._prefix+arguments[0],e.engine.logObject.apply(e,Array.prototype.slice.call(arguments))}},e.prototype.debug=e.makeLevel(1),e.prototype.info=e.makeLevel(2),e.prototype.warn=e.makeLevel(3),e.prototype.error=e.makeLevel(4);var r={logObject:function(t){var e=Array.prototype.slice.call(arguments,1);e=e.map(function(t){return JSON.stringify(t,null,2)}),e.unshift(t),console.log.apply(console,e)}},n={logObject:function(){}};e.engine=n,console&&console.log&&(e.engine=r),t.exports=new e,t.exports.internal=t.exports.sub(),t.exports.Log=e},35:function(t){function e(t){if(!t||"[object Object]"!==n.call(t)||t.nodeType||t.setInterval)return!1;var e=r.call(t,"constructor"),i=r.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!e&&!i)return!1;var s;for(s in t);return void 0===s||r.call(t,s)}var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function i(){var t,r,n,s,o,a,c=arguments[0]||{},u=1,h=arguments.length,f=!1;for("boolean"==typeof c&&(f=c,c=arguments[1]||{},u=2),"object"!=typeof c&&"function"!=typeof c&&(c={});h>u;u++)if(null!=(t=arguments[u]))for(r in t)n=c[r],s=t[r],c!==s&&(f&&s&&(e(s)||(o=Array.isArray(s)))?(o?(o=!1,a=n&&Array.isArray(n)?n:[]):a=n&&e(n)?n:{},c[r]=i(f,a,s)):void 0!==s&&(c[r]=s));return c}},36:function(t,e,r){function n(){this._queue=[],this._idCache=i({max:100}),this._sequenceCache=i({max:100}),this._save=void 0}r(5).Transaction;var i=r(46);n.prototype.save=function(){"function"==typeof this._save&&this._save(this._queue.map(function(t){return{tx_json:t.tx_json,submittedIDs:t.submittedIDs}}))},n.prototype.addReceivedSequence=function(t){this._sequenceCache.set(String(t),!0)},n.prototype.addReceivedId=function(t,e){this._idCache.set(t,e)},n.prototype.getReceived=function(t){return this._idCache.get(t)},n.prototype.hasSequence=function(t){return this._sequenceCache.has(String(t))},n.prototype.getSubmission=function(t){for(var e,r=!1,n=0;e=this._queue[n];n++)if(~e.submittedIDs.indexOf(t)){r=e;break}return r},n.prototype.remove=function(t){for(var e=this._queue.length;e--;)if(this._queue[e]===t){this._queue.splice(e,1);break}this.save()},n.prototype.push=function(t){this._queue.push(t),this.save()},n.prototype.forEach=function(t){this._queue.forEach(t)},n.prototype.length=function(){return this._queue.length},e.TransactionQueue=n},37:function(t,e,r){r(15).sjcl;var n=r(15);r(17);var i=r(35);n.jsbn.BigInteger;var s=r(24).UInt;r(7).Base;var o=i(function(){this._value=0/0},s);o.width=16,o.prototype=i({},s.prototype),o.prototype.constructor=o;var a=o.HEX_ZERO="00000000000000000000000000000000",c=o.HEX_ONE="00000000000000000000000000000000";o.STR_ZERO=n.hexToString(a),o.STR_ONE=n.hexToString(c),e.UInt128=o},38:function(t,e){e.readIEEE754=function(t,e,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,h=-7,f=r?0:i-1,l=r?1:-1,p=t[e+f];for(f+=l,s=p&(1<<-h)-1,p>>=-h,h+=a;h>0;s=256*s+t[e+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+t[e+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?0/0:1/0*(p?-1:1);o+=Math.pow(2,n),s-=u}return(p?-1:1)*o*Math.pow(2,s-n)},e.writeIEEE754=function(t,e,r,n,i,s){var o,a,c,u=8*s-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?s-1:0,_=n?-1:1,d=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),e+=o+f>=1?l/c:l*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&a,p+=_,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+p]=255&o,p+=_,o/=256,u-=8);t[r+p-_]|=128*d}},39:function(t){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},40:function(t){t.exports="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)}},41:function(t){t.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0;r<t.length;r++)if(e===t[r])return r;return-1}},42:function(t){t.exports=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},43:function(t){t.exports=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.hasOwnProperty.call(t,r)&&e.push(r);return e}},44:function(t){t.exports=Object.create||function(t,e){var r;if(null===t)r={__proto__:null};else{if("object"!=typeof t)throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var n=function(){};n.prototype=t,r=new n,r.__proto__=t}return"undefined"!=typeof e&&Object.defineProperties&&Object.defineProperties(r,e),r}},45:function(t){t.exports=function(t){return t instanceof RegExp||"object"==typeof t&&"[object RegExp]"===Object.prototype.toString.call(t)}},46:function(t,e,r){!function(t,e){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(){return 1}function n(t){return this instanceof n?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||r,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=r),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,this.reset(),void 0):new n(t)}function i(t,e,r){var n=t._cache[e];return n&&(t._maxAge&&Date.now()-n.now>t._maxAge?(c(t,n),t._allowStale||(n=void 0)):r&&s(t,n),n&&(n=n.value)),n}function s(t,e){a(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function o(t){for(;t._lru<t._mru&&t._length>t._max;)c(t,t._lruList[t._lru])}function a(t,e){for(delete t._lruList[e.lu];t._lru<t._mru&&!t._lruList[t._lru];)t._lru++}function c(t,e){e&&(t._dispose&&t._dispose(e.key,e.value),t._length-=e.length,t._itemCount--,delete t._cache[e.key],a(t,e))}function u(t,e,r,n,i){this.key=t,this.value=e,this.lu=r,this.length=n,this.now=i}"object"==typeof e&&e.exports?e.exports=n:this.LRUCache=n,Object.defineProperty(n.prototype,"max",{set:function(t){(!t||"number"!=typeof t||0>=t)&&(t=1/0),this._max=t,this._length>this._max&&o(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(n.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=r,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&o(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(n.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(n.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),n.prototype.forEach=function(t,e){e=e||this;for(var r=0,n=this._mru-1;n>=0&&r<this._itemCount;n--)if(this._lruList[n]){r++;var i=this._lruList[n];this._maxAge&&Date.now()-i.now>this._maxAge&&(c(this,i),this._allowStale||(i=void 0)),i&&t.call(e,i.value,i.key,this)}},n.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;r>=0&&e<this._itemCount;r--)if(this._lruList[r]){var n=this._lruList[r];t[e++]=n.key}return t},n.prototype.values=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;r>=0&&e<this._itemCount;r--)if(this._lruList[r]){var n=this._lruList[r];t[e++]=n.value}return t},n.prototype.reset=function(){if(this._dispose&&this._cache)for(var t in this._cache)this._dispose(t,this._cache[t].value);this._cache=Object.create(null),this._lruList=Object.create(null),this._mru=0,this._lru=0,this._length=0,this._itemCount=0},n.prototype.dump=function(){return this._cache},n.prototype.dumpLru=function(){return this._lruList},n.prototype.set=function(e,r){if(t(this._cache,e))return this._dispose&&this._dispose(e,this._cache[e].value),this._maxAge&&(this._cache[e].now=Date.now()),this._cache[e].value=r,this.get(e),!0;var n=this._lengthCalculator(r),i=this._maxAge?Date.now():0,s=new u(e,r,this._mru++,n,i);return s.length>this._max?(this._dispose&&this._dispose(e,r),!1):(this._length+=s.length,this._lruList[s.lu]=this._cache[e]=s,this._itemCount++,this._length>this._max&&o(this),!0)},n.prototype.has=function(e){if(!t(this._cache,e))return!1;var r=this._cache[e];return this._maxAge&&Date.now()-r.now>this._maxAge?!1:!0},n.prototype.get=function(t){return i(this,t,!0)},n.prototype.peek=function(t){return i(this,t,!1)},n.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},n.prototype.del=function(t){c(this,this._cache[t])}}()}(r,r(39)(t))},47:function(t){!function(){"use strict";function e(t){var e,r,i,s,o,a;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(o=t.indexOf("="),o=o>0?t.length-o:0,a=[],i=o>0?t.length-4:t.length,e=0,r=0;i>e;e+=4,r+=3)s=n.indexOf(t[e])<<18|n.indexOf(t[e+1])<<12|n.indexOf(t[e+2])<<6|n.indexOf(t[e+3]),a.push((16711680&s)>>16),a.push((65280&s)>>8),a.push(255&s);return 2===o?(s=n.indexOf(t[e])<<2|n.indexOf(t[e+1])>>4,a.push(255&s)):1===o&&(s=n.indexOf(t[e])<<10|n.indexOf(t[e+1])<<4|n.indexOf(t[e+2])>>2,a.push(255&s>>8),a.push(255&s)),a}function r(t){function e(t){return n[63&t>>18]+n[63&t>>12]+n[63&t>>6]+n[63&t]}var r,i,s,o=t.length%3,a="";for(r=0,s=t.length-o;s>r;r+=3)i=(t[r]<<16)+(t[r+1]<<8)+t[r+2],a+=e(i);switch(o){case 1:i=t[t.length-1],a+=n[i>>2],a+=n[63&i<<4],a+="==";break;case 2:i=(t[t.length-2]<<8)+t[t.length-1],a+=n[i>>10],a+=n[63&i>>4],a+=n[63&i<<2],a+="="}return a}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";t.exports.toByteArray=e,t.exports.fromByteArray=r}()}});