diff --git a/dist/bundle-core.js b/dist/bundle-core.js index 074fbc7..60fd1f4 100644 --- a/dist/bundle-core.js +++ b/dist/bundle-core.js @@ -1,36 +1,36 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i{if(e)return console.error(e);t.destroy()})}exports.getPeer=function(){let e=Array.from(SSB.net.conn.hub().entries());var r=(e=e.filter(([,e])=>!!e.key).map(([e,r])=>({address:e,data:r}))).find(e=>"room"!=e.data.type);let t=Object.values(SSB.net.peers).flat();return r?t.find(e=>e.id==r.data.key):t.length>0?t[0]:null},exports.removeIndexes=function(e){SSB.db.clearIndexes()},exports.removeDB=function(){deleteDatabaseFile("log.bipf"),new(require("idb-kv-store"))(path.join(SSB.dir,"indexes")).clear()},exports.removeBlobs=function(){window.webkitRequestFileSystem(window.PERSISTENT,0,function(e){!function e(r,t){r.root.getDirectory(t,{},function(t){t.createReader().readEntries(function(t){for(var n=0;n{if(r)return console.error(r);e.destroy()})}}})})}(e,"/.ssb-lite/blobs")})},exports.convertHopsIntoGraph=function(e){const r=[],t=[],n=[],o=Object.keys(e);for(var i=0;i0&&e[s]<=SSB.net.config.friends.hops?n.push(s):-1==e[s]&&t.push(s)}return{following:r,extended:n,blocking:t}},exports.getGraphForFeed=function(e,r){SSB.net.friends.hops({start:e},(t,n)=>{if(t)return r(t);r(null,exports.convertHopsIntoGraph(n,e==SSB.net.id))})}; -},{"idb-kv-store":249,"path":424,"polyraf":440,"pull-stream":526,"ssb-keys":766,"ssb-validate":785}],3:[function(require,module,exports){ -exports.init=function(e,r,o){const s=require("events");SSB={events:new s,dbOperators:require("ssb-db2/operators")},SSB.dbOperators.mentions=require("ssb-db2/operators/full-mentions"),require("sodium-browserify").events.on("sodium-browserify:wasm loaded",function(){console.log("wasm loaded");var s=require("./net").init(e,r,o);console.log("my id: ",s.id);var t=require("./core-helpers");SSB=Object.assign(SSB,{db:s.db,net:s,dir:e,getPeer:t.getPeer,removeDB:t.removeDB,removeIndexes:t.removeIndexes,removeBlobs:t.removeBlobs,convertHopsIntoGraph:t.convertHopsIntoGraph,getGraphForFeed:t.getGraphForFeed,box:require("ssb-keys").box,blobFiles:require("ssb-blob-files")}),r&&r.core&&r.core.startOffline||setTimeout(()=>{SSB.net.conn.start(),SSB.net.dhtInvite.start((e,r)=>{})},2e3),SSB.events.emit("SSB: loaded")})}; +},{"idb-kv-store":255,"path":430,"polyraf":446,"pull-stream":533,"ssb-keys":785,"ssb-validate":805}],3:[function(require,module,exports){ +exports.init=function(e,r,o){const s=require("events");SSB={events:new s,dbOperators:require("ssb-db2/operators")},SSB.dbOperators.mentions=require("ssb-db2/operators/full-mentions"),require("sodium-browserify").events.on("sodium-browserify:wasm loaded",function(){console.log("wasm loaded");var s=require("./net").init(e,r,o);console.log("my id: ",s.id);var t=require("./core-helpers");SSB=Object.assign(SSB,{db:s.db,net:s,dir:e,getPeer:t.getPeer,removeDB:t.removeDB,removeIndexes:t.removeIndexes,removeBlobs:t.removeBlobs,convertHopsIntoGraph:t.convertHopsIntoGraph,getGraphForFeed:t.getGraphForFeed,box:require("ssb-keys").box,blobFiles:require("ssb-blob-files")}),r&&r.core&&r.core.startOffline||setTimeout(()=>{SSB.net.conn.start(),SSB.net.dhtInvite.start((e,r)=>{})},2500),SSB.events.emit("SSB: loaded")})}; -},{"./core-helpers":2,"./net":5,"events":186,"sodium-browserify":699,"ssb-blob-files":704,"ssb-db2/operators":738,"ssb-db2/operators/full-mentions":737,"ssb-keys":766}],4:[function(require,module,exports){ +},{"./core-helpers":2,"./net":5,"events":192,"sodium-browserify":712,"ssb-blob-files":721,"ssb-db2/operators":756,"ssb-db2/operators/full-mentions":755,"ssb-keys":785}],4:[function(require,module,exports){ (function (setImmediate){(function (){ -const pull=require("pull-stream"),validate=require("ssb-validate"),FastPriorityQueue=require("fastpriorityqueue"),Partial=require("./partial");exports.name="feedReplication",exports.version="1.0.0",exports.manifest={request:"sync",updatePartialState:"async",partialStatus:"sync",inSync:"sync"},exports.permissions={anonymous:{allow:[]}},exports.init=function(e,t){console.log("loading feed replication!");const n=Partial(t.path);let l=null;function a(t,a,r,i){if(l[t]&&l[t][a])i(null,t);else{let l=e.db.addOOO;if("syncedMessages"==a){const t=validate.initial();l=((n,l)=>e.db.addOOOStrictOrder(n,t,l))}else l=((t,n)=>{const l=validate.initial();e.db.addOOOStrictOrder(t,l,n)});pull(r(),pull.asyncMap(l),pull.collect((e,l)=>{if(e)return console.error(e.message),i(e);var r={};r[a]=!0,n.updateState(t,r,e=>{i(e,t)})}))}}n.get((e,t)=>{l=t,d()});let r={};pull(e.conn.hub().listen(),pull.filter(t=>{if(("connected"===t.type||"disconnected"===t.type)&&t.details){let n=Array.from(e.conn.hub().entries());const l=(n=n.filter(([,e])=>!!e.key).map(([e,t])=>({address:e,data:t}))).find(e=>e.data.key==t.details.rpc.id);return l&&"room"!==l.data.type}return!1}),pull.drain(e=>{"connected"===e.type?o.set(e.details.rpc,0):o.delete(e.details.rpc),d()}));var i=new FastPriorityQueue(function(e,t){return t.hops>e.hops});let s={};let o=new Map,c=!1,u=new Map;function p(){c=!1,d()}function d(){if(i.isEmpty())return void e.db.onDrain("ebt",()=>{for(let t of u.keys())e.ebt.request(t,!0);u.clear()});if(null===l)return;if(0==o.size)return;let t=null,s=0;for(let[e,n]of o)null===t?t={rpc:e,concurrent:n}:t.concurrent{const r=a[i]?a[i].sequence+1:0;pull(t.partialReplication.getFeed({id:i,seq:r,keys:!1}),pull.asyncMap(e.db.add),pull.collect(e=>{if(e)return o(e);u.set(i,!0),n.updateState(i,{full:!0},o)}))})):pull(pull.values([i]),pull.asyncMap((e,n)=>{a(e,"syncedMessages",()=>t.partialReplication.getFeedReverse({id:e,keys:!1,limit:25}),n)}),pull.asyncMap((e,n)=>{a(e,"syncedProfile",()=>t.partialReplication.getMessagesOfType({id:e,type:"about"}),n)}),pull.asyncMap((e,n)=>{a(e,"syncedContacts",()=>t.partialReplication.getMessagesOfType({id:e,type:"contact"}),n)}),pull.collect(e=>{if(e)return o(e);u.set(i,!0),o()}))}(t.rpc,f.feed,f.hops,()=>{o.set(t.rpc,o.get(t.rpc)-1),setImmediate(d)}),d()):c||(c=!0,setTimeout(p,100))}return{request:function(t,n,l){s[t]=n,l?i.add({feed:t,hops:n,validFrom:+new Date+200}):(u.delete(t),i.removeMany(e=>e.feed===t),e.ebt.request(t,!1)),d()},updatePartialState:function(e,t,l){n.updateState(e,t,l)},partialStatus:function(){let e=n.getSync(),t=SSB.convertHopsIntoGraph(s),l=t.following.length,a=0,r=t.extended.length,i=0,o=0,c=0;for(var u in e){const t=e[u];t.full&&(a+=1),t.syncedProfile&&(i+=1),t.syncedContacts&&(o+=1),t.syncedMessages&&(c+=1)}return{totalPartial:r,profilesSynced:i,contactsSynced:o,messagesSynced:c,totalFull:l,fullSynced:a}},inSync:function(){return i.isEmpty()},getGraph:function(){return SSB.convertHopsIntoGraph(s)}}}; +const pull=require("pull-stream"),validate=require("ssb-validate"),FastPriorityQueue=require("fastpriorityqueue"),Partial=require("./partial");exports.name="feedReplication",exports.version="1.0.0",exports.manifest={request:"sync",updatePartialState:"async",partialStatus:"sync",inSync:"sync"},exports.permissions={anonymous:{allow:[]}},exports.init=function(e,t){console.log("loading feed replication!");const n=Partial(t.path);let l=null;function r(t,r,a,i){l[t]&&l[t][r]?i(null,t):pull(a(),pull.collect((l,a)=>{if(l)return console.error(l.message),i(l);if("syncedMessages"===r){const t=a[a.length-1];a=a.filter(e=>"contact"!==e.content.type&&"about"!==e.content.type);const n=validate.toKeyValueTimestamp(t);e.db.setPost(n)}e.db.addOOOBatch(a,e=>{if(e)return i(e);var l={};l[r]=!0,n.updateState(t,l,e=>{i(e,t)})})}))}n.get((e,t)=>{l=t,f()});let a={};function i(t,i,s,o){if(a[i])return o();a[i]=1,0===s?o():1===s?l[i]&&l[i].full?o():(console.log("full replication of",i),function(t,n){e.db.getLatest(t,(e,t)=>{if(e)return n(e);n(null,t?t.sequence+1:0)})}(i,(l,r)=>{pull(t.partialReplication.getFeed({id:i,seq:r,keys:!1}),pull.collect((t,l)=>{if(t)return o(t);e.db.addBatch(l,()=>{p.set(i,!0),n.updateState(i,{full:!0},o)})}))})):pull(pull.values([i]),pull.asyncMap((e,n)=>{r(e,"syncedProfile",()=>t.partialReplication.getMessagesOfType({id:e,type:"about"}),n)}),pull.asyncMap((e,n)=>{r(e,"syncedContacts",()=>t.partialReplication.getMessagesOfType({id:e,type:"contact"}),n)}),pull.asyncMap((e,n)=>{r(e,"syncedMessages",()=>t.partialReplication.getFeedReverse({id:e,keys:!1,limit:25}),n)}),pull.collect(e=>{if(e)return o(e);p.set(i,!0),o()}))}pull(e.conn.hub().listen(),pull.filter(t=>{if(("connected"===t.type||"disconnected"===t.type)&&t.details){let n=Array.from(e.conn.hub().entries());const l=(n=n.filter(([,e])=>!!e.key).map(([e,t])=>({address:e,data:t}))).find(e=>e.data.key==t.details.rpc.id);return l&&"room"!==l.data.type}return!1}),pull.drain(e=>{"connected"===e.type?c.set(e.details.rpc,0):c.delete(e.details.rpc),f()}));var s=new FastPriorityQueue(function(e,t){return t.hops>e.hops});let o={};let c=new Map,u=!1,p=new Map;function d(){u=!1,f()}function f(){if(s.isEmpty())return void e.db.onDrain("ebt",()=>{for(let t of p.keys())e.ebt.request(t,!0);p.clear()});if(null===l)return;if(0==c.size)return;let t=null,n=0;for(let[e,l]of c)null===t?t={rpc:e,concurrent:l}:t.concurrent{c.set(t.rpc,c.get(t.rpc)-1),setImmediate(f)}),f()):u||(u=!0,setTimeout(d,100))}return{request:function(t,n,l){o[t]=n,l?s.add({feed:t,hops:n,validFrom:+new Date+200}):(p.delete(t),s.removeMany(e=>e.feed===t),e.ebt.request(t,!1)),f()},updatePartialState:function(e,t,l){n.updateState(e,t,l)},partialStatus:function(){let e=n.getSync(),t=SSB.convertHopsIntoGraph(o),l=t.following.length,r=0,a=t.extended.length,i=0,s=0,c=0;for(var u in e){const t=e[u];t.full&&(r+=1),t.syncedProfile&&(i+=1),t.syncedContacts&&(s+=1),t.syncedMessages&&(c+=1)}return{totalPartial:a,profilesSynced:i,contactsSynced:s,messagesSynced:c,totalFull:l,fullSynced:r}},inSync:function(){return s.isEmpty()},getGraph:function(){return SSB.convertHopsIntoGraph(o)}}}; }).call(this)}).call(this,require("timers").setImmediate) -},{"./partial":862,"fastpriorityqueue":190,"pull-stream":526,"ssb-validate":785,"timers":831}],5:[function(require,module,exports){ +},{"./partial":887,"fastpriorityqueue":196,"pull-stream":533,"ssb-validate":805,"timers":853}],5:[function(require,module,exports){ (function (Buffer){(function (){ const SecretStack=require("secret-stack"),caps=require("ssb-caps"),ssbKeys=require("ssb-keys"),helpers=require("./core-helpers"),path=require("path");exports.init=function(e,s,r){var n=ssbKeys.loadOrCreateSync(path.join(e,"secret")),t=Object.assign({caps:{shs:Buffer.from(caps.shs,"base64")},keys:n,friends:{hops:2,hookReplicate:!1},connections:{incoming:{tunnel:[{scope:"public",transform:"shs"}],dht:[{scope:"public",transform:"shs"}]},outgoing:{net:[{transform:"shs"}],ws:[{transform:"shs"},{transform:"noauth"}],tunnel:[{transform:"shs"}],dht:[{transform:"shs"}]}},path:e,timers:{inactivity:3e4},conn:{autostart:!1,populatePubs:!1},ebt:{logging:!1},blobs:{sympathy:0,stingy:!1,pushy:3,max:262144}},s);let o=SecretStack(t).use(require("ssb-db2/db")).use(require("ssb-db2/compat")).use(require("ssb-conn")).use(require("ssb-friends")).use(require("ssb-ebt")).use(require("./feed-replication")).use(require("ssb-replication-scheduler")).use(require("./ssb-partial-replication")).use(require("./simple-ooo")).use(require("ssb-ws")).use(require("ssb-room-client")).use(require("ssb-no-auth")).use(require("./simple-blobs")).use(require("ssb-dht-invite"));r&&(o=r(o));var i=o();return i.on("rpc:connect",function(e,s){let r;console.log("connected to:",e.id),function s(){e.tunnel.ping(function(e,n){if(e)return console.error(e);clearTimeout(r),r=setTimeout(s,1e4)})}()}),i.connectAndRemember=function(e,s){i.conn.connect(e,s,(r,n)=>{i.conn.remember(e,Object.assign(s,{autoconnect:!0}))})},i.directConnect=function(e,s){i.conn.connect(e,s)},i}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./core-helpers":2,"./feed-replication":4,"./simple-blobs":863,"./simple-ooo":864,"./ssb-partial-replication":865,"buffer":99,"path":424,"secret-stack":640,"ssb-caps":708,"ssb-conn":721,"ssb-db2/compat":726,"ssb-db2/db":728,"ssb-dht-invite":742,"ssb-ebt":760,"ssb-friends":765,"ssb-keys":766,"ssb-no-auth":773,"ssb-replication-scheduler":775,"ssb-room-client":777,"ssb-ws":786}],6:[function(require,module,exports){ +},{"./core-helpers":2,"./feed-replication":4,"./simple-blobs":888,"./simple-ooo":889,"./ssb-partial-replication":890,"buffer":104,"path":430,"secret-stack":649,"ssb-caps":725,"ssb-conn":738,"ssb-db2/compat":743,"ssb-db2/db":745,"ssb-dht-invite":760,"ssb-ebt":779,"ssb-friends":784,"ssb-keys":785,"ssb-no-auth":792,"ssb-replication-scheduler":794,"ssb-room-client":796,"ssb-ws":808}],6:[function(require,module,exports){ (function (process,Buffer){(function (){ const{EventEmitter:EventEmitter}=require("events"),crypto=require("crypto"),assert=require("nanocustomassert"),pump=require("pump"),log=require("debug")("discovery-swarm-webrtc"),MMSTSignalClient=require("./lib/mmst-signal-client"),{toHex:toHex,callbackPromise:callbackPromise,resolveCallback:resolveCallback}=require("./lib/utils"),errors=require("./lib/errors"),{ERR_CONNECTION_DUPLICATED:ERR_CONNECTION_DUPLICATED}=errors,assertChannel=e=>assert(Buffer.isBuffer(e)&&32===e.length,"Channel must be a buffer of 32 bytes");class DiscoverySwarmWebrtc extends EventEmitter{constructor(e={}){super(),log("opts",e);const{id:t=crypto.randomBytes(32),bootstrap:i,stream:r,simplePeer:s,maxPeers:n=5,timeout:o=15e3,signal:a,mmst:c={}}=e;assert(Array.isArray(i)&&i.length>0,"The `bootstrap` options is required."),assert(Buffer.isBuffer(t)&&32===t.length,"The `id` option needs to be a Buffer of 32 bytes."),this.id=t;const l=2*o,h={id:this.id,bootstrap:i,createConnection:e=>this._createConnection(e),requestTimeout:o,simplePeer:s,reconnectingWebsocket:{connectionTimeout:o}};this.signal=a?a(h,this):new MMSTSignalClient({...h,mmstOpts:{maxPeers:n,queueTimeout:l,lookupTimeout:o,...c}}),this._maxPeers=n,this._stream=r,this._destroyed=!1,this._initialize(e)}get connected(){return this.signal.peersConnected}get connecting(){return this.signal.peersConnecting}listen(){}getPeers(e){return e?this.signal.getPeersByTopic(e).filter(e=>e.connected):this.signal.peersConnected}join(e){this.signal.join(e)}leave(e,t=callbackPromise()){return assertChannel(e),resolveCallback(this.signal.leave(e),t),t.promise}close(e=callbackPromise()){return resolveCallback(this._close(),e),e.promise}async connect(e,t){assert(e&&Buffer.isBuffer(e),"channel must be a buffer"),assert(t&&Buffer.isBuffer(t),"peerId must be a buffer");const i=this.signal.connect(e,t);return i.subscribeMediaStream=!0,await i.ready(),i.stream}async _close(){this._destroyed||(this._destroyed=!0,await this.signal.close(),this.emit("close"))}_initialize(){const e=this.signal;this.on("error",(...e)=>log("error",...e)),e.on("peer-error",e=>this.emit("error",e)),e.on("error",e=>this.emit("error",e)),e.open().catch(e=>process.nextTick(()=>this.emit("error",e))),e.on("candidates-updated",(...e)=>this.emit("candidates-updated",...e))}_createConnection(e){e.subscribeMediaStream=!0,e.channel=e.topic,e.getInfo=(()=>({id:e.id,channel:e.topic,initiator:e.initiator})),e.printInfo=(()=>({id:toHex(e.id),channel:toHex(e.topic),initiator:e.initiator})),log("createConnection",{info:e.printInfo()});try{const t=this._checkForDuplicate(e);if(t){if(t===e)throw new ERR_CONNECTION_DUPLICATED(toHex(this.id),toHex(e.id));t.destroy()}return this._bindSocketEvents(e),e}catch(t){throw this.emit("connect-failed",t,e.getInfo()),t}}_bindSocketEvents(e){const t=e.getInfo();e.on("error",e=>{log("error",e),this.emit("connection-error",e,t)}),e.on("connect",()=>{if(log("connect",{peer:e}),e.stream.destroyed)return;if(!this._stream)return void this._handleConnection(e.stream,t);const i=this._stream(t);i?(this.emit("handshaking",i,t),i.on("handshake",this._handshake.bind(this,i,t)),pump(e.stream,i,e.stream)):this._handleConnection(e.stream,t)}),e.on("close",()=>{log("close",{peer:e}),this.emit("connection-closed",e.stream,t)})}_handshake(e,t){this._handleConnection(e,t)}_handleConnection(e,t){this.emit("connection",e,t)}_checkForDuplicate(e){const t=this.signal.getPeersByTopic(e.channel).find(t=>t.id.equals(e.id)&&!t.sessionId.equals(e.sessionId));if(!t)return;const i=[e,t];if(e.initiator&&t.initiator||!e.initiator&&!t.initiator)return i.sort((e,t)=>Buffer.compare(e.sessionId,t.sessionId))[0];const r=[this.id,e.id].sort(Buffer.compare)[0];return i.find(e=>e.id.equals(r))}}module.exports=((...e)=>new DiscoverySwarmWebrtc(...e)),module.exports.errors=errors; }).call(this)}).call(this,require('_process'),require("buffer").Buffer) -},{"./lib/errors":7,"./lib/mmst-signal-client":8,"./lib/utils":10,"_process":443,"buffer":99,"crypto":130,"debug":131,"events":186,"nanocustomassert":374,"pump":570}],7:[function(require,module,exports){ +},{"./lib/errors":7,"./lib/mmst-signal-client":8,"./lib/utils":10,"_process":449,"buffer":104,"crypto":135,"debug":136,"events":192,"nanocustomassert":379,"pump":577}],7:[function(require,module,exports){ const nanoerror=require("nanoerror");function createError(r,e){exports[r]=nanoerror(r,e)}createError("ERR_MAX_PEERS_REACHED","max peers reached: %s"),createError("ERR_INVALID_CHANNEL","invalid channel: %s"),createError("ERR_CONNECTION_DUPLICATED","connection duplicated: %s -> %s"); -},{"nanoerror":375}],8:[function(require,module,exports){ +},{"nanoerror":380}],8:[function(require,module,exports){ (function (Buffer){(function (){ const{SocketSignalWebsocketClient:SocketSignalWebsocketClient}=require("socket-signal-websocket"),MMST=require("mostly-minimal-spanning-tree"),assert=require("nanocustomassert"),{Readable:Readable}=require("stream"),log=require("debug")("discovery-swarm-webrtc:mmst-signal"),{toHex:toHex}=require("./utils"),{ERR_INVALID_CHANNEL:ERR_INVALID_CHANNEL,ERR_MAX_PEERS_REACHED:ERR_MAX_PEERS_REACHED}=require("./errors"),Scheduler=require("./scheduler"),assertChannel=t=>assert(Buffer.isBuffer(t)&&32===t.length,"Channel must be a buffer of 32 bytes"),kOnConnected=Symbol("mmstsignal.onconnected"),kGetCandidates=Symbol("mmstsignal.getcandidates");module.exports=class extends SocketSignalWebsocketClient{constructor(t={}){const{bootstrap:e,createConnection:s,mmstOpts:n={},strict:i=!0,...a}=t;super(e,a),this._createConnection=s,this._mmstOpts=n,this._strict=i,this._channels=new Map,this._mmsts=new Map,this._candidates=new Map,this._scheduler=new Scheduler,this[kOnConnected]=this[kOnConnected].bind(this)}join(t){assertChannel(t);const e=toHex(t);if(!this._channels.has(e)){this._channels.set(e,t);const s=new MMST({...this._mmstOpts,id:this.id,lookup:()=>this._lookup(t),connect:async e=>{await this.open();try{const s=this.connect(t,e);return this._runCreateConnection(s),await s.ready(),s.stream}catch(s){const n=this[kGetCandidates](t);throw n.list=n.list.filter(t=>!t.equals(e)),0===n.list.length&&(n.lookup=!0),s}}});this._mmsts.set(e,s)}this.connected&&super.join(t).catch(()=>{})}async leave(t){assertChannel(t);const e=toHex(t);this._scheduler.delete(e),this._mmsts.get(e).destroy(),this._mmsts.delete(e),this._channels.delete(e),this._candidates.delete(e),await super.leave(t),await super.closeConnectionsByTopic(t)}async _open(){this.on("connected",this[kOnConnected]),this.on("join",async(t,e)=>{log("discover",{channel:t}),this.hasChannel(t)&&(await this._updateCandidates(t,e),await this._run(t),this._scheduler.add(t.toString("hex"),async()=>{const e=this[kGetCandidates](t);0!==e.list.length&&0!==this.getPeersByTopic(t).length||(e.lookup=!0,await this._updateCandidates(t),await this._run(t))}))}),this.onIncomingPeer(t=>this._runCreateConnection(t)),await super._open()}hasChannel(t){return this._channels.has(toHex(t))}_runCreateConnection(t){if(!this.hasChannel(t.topic))throw new ERR_INVALID_CHANNEL(toHex(t.topic));const e=this._getMMST(t.topic);if(this._strict&&!t.initiator&&!e.shouldHandleIncoming())throw new ERR_MAX_PEERS_REACHED(this._mmstOpts.maxPeers);return this._createConnection(t),t.initiator||e.addConnection(t.id,t.stream),t}async _close(){await super._close(),this.removeListener("connected",this[kOnConnected]),this._mmsts.forEach(t=>t.destroy()),this._mmsts.clear(),this._channels.clear(),this._candidates.clear(),this._scheduler.clear()}async _run(t){if(this.connected&&!(this.getPeersByTopic(t).filter(t=>t.initiator).length>0))try{this.hasChannel(t)&&await this._getMMST(t).run()}catch(t){log("run error",t.message)}}_getMMST(t){return this._mmsts.get(toHex(t))}_lookup(t){const e=new Readable({read(){},objectMode:!0});return this._updateCandidates(t).finally(()=>{e.push(this[kGetCandidates](t).list),e.push(null)}),e}async[kOnConnected](t){this._channels.forEach(t=>super.join(t).catch(()=>{}))}async _updateCandidates(t,e){const s=this[kGetCandidates](t);let n=s.list;if(e)n=e;else if(s.lookup){s.lookup=!1;try{n=await this.lookup(t)}catch(t){}}s.list=n.filter(t=>!t.equals(this.id)),this.emit("candidates-updated",t,n)}[kGetCandidates](t){assert(Buffer.isBuffer(t));let e=this._candidates.get(toHex(t));return e||(e={list:[],lookup:!1},this._candidates.set(toHex(t),e),e)}}; }).call(this)}).call(this,{"isBuffer":require("../../../is-buffer/index.js")}) -},{"../../../is-buffer/index.js":261,"./errors":7,"./scheduler":9,"./utils":10,"debug":131,"mostly-minimal-spanning-tree":353,"nanocustomassert":374,"socket-signal-websocket":687,"stream":792}],9:[function(require,module,exports){ +},{"../../../is-buffer/index.js":267,"./errors":7,"./scheduler":9,"./utils":10,"debug":136,"mostly-minimal-spanning-tree":358,"nanocustomassert":379,"socket-signal-websocket":696,"stream":814}],9:[function(require,module,exports){ const delay=t=>{let s,e=!1;const a=new Promise((a,i)=>{const o=setTimeout(()=>{e=!0,a()},t);s=(()=>{e||(clearTimeout(o),i(new Error("timeout")))})});return a.cancel=s,a};class Task{constructor(t){this._fn=t,this._stop=!1,this.run()}run(){(async()=>{for(;!this._stop;)this._time=delay(1e3*Math.floor(11*Math.random())),await this._time,await this._fn()})().catch(()=>{})}stop(){this._time&&this._time.cancel(),this._stop=!1}}module.exports=class{constructor(){this._tasks=new Map}add(t,s){this._tasks.set(t,new Task(s))}delete(t){const s=this._tasks.get(t);s&&s.stop(),this._tasks.delete(t)}clear(){this._tasks.forEach(t=>{t.stop()}),this._tasks.clear()}}; },{}],10:[function(require,module,exports){ @@ -38,7 +38,7 @@ const delay=t=>{let s,e=!1;const a=new Promise((a,i)=>{const o=setTimeout(()=>{e const toHex=e=>{if("string"==typeof e)return e;if(Buffer.isBuffer(e))return e.toString("hex");throw new Error("Cannot convert the buffer to hex: ",e)},toBuffer=e=>{if(Buffer.isBuffer(e))return e;if("string"==typeof e)return Buffer.from(e,"hex");throw new Error("Cannot convert the string to buffer: ",e)},callbackPromise=()=>{let e;const r=new Promise((r,t)=>{e=((e,o)=>{e?t(e):r(o)})});return e.promise=r,e},resolveCallback=(e,r)=>(e.then||(e=Promise.resolve()),e.then(e=>r(null,e)).catch(r));module.exports={toHex:toHex,toBuffer:toBuffer,callbackPromise:callbackPromise,resolveCallback:resolveCallback}; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99}],11:[function(require,module,exports){ +},{"buffer":104}],11:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var common=require("@minireq/common");function makeRequest(e=common.defaultSerializers,n={}){return function(t){var s;const r=Object.assign(Object.assign(Object.assign({},common.defaults),n),t),o=r.url+common.makeQueryString(r.query);let a,i;const d=new XMLHttpRequest;if(r.timeout&&(d.timeout=r.timeout),r.onTimeout&&d.addEventListener("timeout",r.onTimeout),d.addEventListener("load",()=>{var n,t;let s=d.response;if("parsed"===r.responseType){const r=null===(n=d.getResponseHeader("Content-Type"))||void 0===n?void 0:n.split(";")[0];r&&(null===(t=e[r])||void 0===t?void 0:t.parse)&&(s=e[r].parse(s))}a({status:d.status,data:s})}),d.addEventListener("error",i),r.progress&&(d.onprogress=r.progress),r.uploadProgress&&(d.upload.onprogress=r.uploadProgress),d.open(r.method,o,!0),d.responseType="binary"===r.responseType?"arraybuffer":"text",r.headers)for(const e in r.headers)d.setRequestHeader(e,r.headers[e]);if(r.contentType&&d.setRequestHeader("Content-Type",r.contentType),r.accept&&d.setRequestHeader("Accept",r.accept),r.auth&&d.setRequestHeader("Authorization",`Basic ${btoa(r.auth.user+":"+r.auth.password)}`),r.send)if("string"==typeof r.send||r.send instanceof Blob||r.send instanceof ArrayBuffer||r.send instanceof Int8Array||r.send instanceof Uint8Array||r.send instanceof Uint8ClampedArray||r.send instanceof Int16Array||r.send instanceof Uint16Array||r.send instanceof Int32Array||r.send instanceof Uint32Array||r.send instanceof Float32Array||r.send instanceof Float64Array||r.send instanceof DataView||r.send instanceof FormData||r.send instanceof URLSearchParams)d.send(r.send);else{if(null===(s=e[r.contentType])||void 0===s||!s.convert)throw new Error(`Could not find a serializer for content type ${r.contentType}`);d.send(e[r.contentType].convert(r.send))}else d.send();return{promise:new Promise((e,n)=>{a=e,i=n}),abort:()=>{d.abort()}}}}exports.makeRequest=makeRequest; },{"@minireq/common":12}],12:[function(require,module,exports){ @@ -49,7 +49,7 @@ const toHex=e=>{if("string"==typeof e)return e;if(Buffer.isBuffer(e))return e.to "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var common=require("@minireq/common"),http=require("http"),https=require("https");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var http__namespace=_interopNamespace(http),https__namespace=_interopNamespace(https);function makeRequest(e=common.defaultSerializers,t={}){return function(n){var r;const o=Object.assign(Object.assign(Object.assign({},common.defaults),t),n),s=o.url+common.makeQueryString(o.query),a=/^http:\/\//.test(o.url)?http__namespace:https__namespace;if(o.uploadProgress)throw new Error("Node.js does not support reporting upload progress");const i=Object.assign({},o.headers);if(o.contentType&&(i["Content-Type"]=o.contentType),o.accept&&(i.Accept=o.accept),o.auth){const e=Buffer.from(o.auth.user+":"+o.auth.password).toString("base64");i.Authorization=`Basic ${e}`}let c="";const p=a.request(s,{method:o.method,timeout:o.timeout,headers:i});let u=void 0;o.timeout&&(u=setTimeout(()=>{p.abort(),o.onTimeout&&o.onTimeout(makeProgress(c,void 0))},o.timeout));const f=new Promise((t,n)=>{p.on("response",n=>{"binary"!==o.responseType&&n.setEncoding("utf-8"),n.on("data",e=>{"string"==typeof e?c+=e:""===c?c=[]:c.push(e),o.progress&&o.progress(makeProgress(c,n.headers["content-length"]))}),n.on("end",()=>{var r,s;u&&clearTimeout(u);let a=c;if(Array.isArray(c)){const e=Buffer.concat(c);a=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if("string"==typeof a&&"parsed"===o.responseType){const t=null===(r=n.headers["content-type"])||void 0===r?void 0:r.split(";")[0];t&&(null===(s=e[t])||void 0===s?void 0:s.parse)&&(a=e[t].parse(a))}t({status:n.statusCode,data:a})})}),p.on("error",e=>{p.aborted||n(e)})});if(o.send)if("string"==typeof o.send||o.send instanceof ArrayBuffer||o.send instanceof ArrayBuffer||o.send instanceof Int8Array||o.send instanceof Uint8Array||o.send instanceof Uint8ClampedArray||o.send instanceof Int16Array||o.send instanceof Uint16Array||o.send instanceof Int32Array||o.send instanceof Uint32Array||o.send instanceof Float32Array||o.send instanceof Float64Array||o.send instanceof DataView||o.send instanceof URLSearchParams)p.write(o.send);else{if(null===(r=e[o.contentType])||void 0===r||!r.convert)throw p.abort(),new Error(`Could not find a serializer for content type ${o.contentType}`);p.write(e[o.contentType].convert(o.send))}return p.end(),{promise:f,abort:()=>p.abort()}}}function makeProgress(e,t){const n=void 0!==t,r="string"==typeof e?Buffer.byteLength(e):e.reduce((e,t)=>e+t.length,0);let o=0;return n&&(o=parseInt(t)),{lengthComputable:n,loaded:r,total:o}}exports.makeRequest=makeRequest; }).call(this)}).call(this,require("buffer").Buffer) -},{"@minireq/common":12,"buffer":99,"http":807,"https":242}],14:[function(require,module,exports){ +},{"@minireq/common":12,"buffer":104,"http":829,"https":248}],14:[function(require,module,exports){ var nextTick=require("./next-tick");function AbstractChainedBatch(t){if("object"!=typeof t||null===t)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=t,this._operations=[],this._written=!1}AbstractChainedBatch.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")},AbstractChainedBatch.prototype.put=function(t,e){this._checkWritten();var i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;return t=this.db._serializeKey(t),e=this.db._serializeValue(e),this._put(t,e),this},AbstractChainedBatch.prototype._put=function(t,e){this._operations.push({type:"put",key:t,value:e})},AbstractChainedBatch.prototype.del=function(t){this._checkWritten();var e=this.db._checkKey(t);if(e)throw e;return t=this.db._serializeKey(t),this._del(t),this},AbstractChainedBatch.prototype._del=function(t){this._operations.push({type:"del",key:t})},AbstractChainedBatch.prototype.clear=function(){return this._checkWritten(),this._clear(),this},AbstractChainedBatch.prototype._clear=function(){this._operations=[]},AbstractChainedBatch.prototype.write=function(t,e){if(this._checkWritten(),"function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("write() requires a callback argument");"object"==typeof t&&null!==t||(t={}),this._written=!0,this._write(t,e)},AbstractChainedBatch.prototype._write=function(t,e){this.db._batch(this._operations,t,e)},AbstractChainedBatch.prototype._nextTick=nextTick,module.exports=AbstractChainedBatch; },{"./next-tick":18}],15:[function(require,module,exports){ @@ -58,13 +58,13 @@ var nextTick=require("./next-tick");function AbstractIterator(t){if("object"!=ty },{"./next-tick":18}],16:[function(require,module,exports){ var xtend=require("xtend"),supports=require("level-supports"),Buffer=require("buffer").Buffer,AbstractIterator=require("./abstract-iterator"),AbstractChainedBatch=require("./abstract-chained-batch"),nextTick=require("./next-tick"),hasOwnProperty=Object.prototype.hasOwnProperty,rangeOptions="start end gt gte lt lte".split(" ");function AbstractLevelDOWN(t){this.status="new",this.supports=supports(t,{status:!0})}function cleanRangeOptions(t,e){var r={};for(var n in e)if(hasOwnProperty.call(e,n)){var i=e[n];isRangeOption(n)&&(i=t._serializeKey(i)),r[n]=i}return r}function isRangeOption(t){return-1!==rangeOptions.indexOf(t)}AbstractLevelDOWN.prototype.open=function(t,e){var r=this,n=this.status;if("function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("open() requires a callback argument");"object"==typeof t&&null!==t||(t={}),t.createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists,this.status="opening",this._open(t,function(t){if(t)return r.status=n,e(t);r.status="open",e()})},AbstractLevelDOWN.prototype._open=function(t,e){nextTick(e)},AbstractLevelDOWN.prototype.close=function(t){var e=this,r=this.status;if("function"!=typeof t)throw new Error("close() requires a callback argument");this.status="closing",this._close(function(n){if(n)return e.status=r,t(n);e.status="closed",t()})},AbstractLevelDOWN.prototype._close=function(t){nextTick(t)},AbstractLevelDOWN.prototype.get=function(t,e,r){if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("get() requires a callback argument");var n=this._checkKey(t);if(n)return nextTick(r,n);t=this._serializeKey(t),"object"==typeof e&&null!==e||(e={}),e.asBuffer=!1!==e.asBuffer,this._get(t,e,r)},AbstractLevelDOWN.prototype._get=function(t,e,r){nextTick(function(){r(new Error("NotFound"))})},AbstractLevelDOWN.prototype.put=function(t,e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("put() requires a callback argument");var i=this._checkKey(t)||this._checkValue(e);if(i)return nextTick(n,i);t=this._serializeKey(t),e=this._serializeValue(e),"object"==typeof r&&null!==r||(r={}),this._put(t,e,r,n)},AbstractLevelDOWN.prototype._put=function(t,e,r,n){nextTick(n)},AbstractLevelDOWN.prototype.del=function(t,e,r){if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("del() requires a callback argument");var n=this._checkKey(t);if(n)return nextTick(r,n);t=this._serializeKey(t),"object"==typeof e&&null!==e||(e={}),this._del(t,e,r)},AbstractLevelDOWN.prototype._del=function(t,e,r){nextTick(r)},AbstractLevelDOWN.prototype.batch=function(t,e,r){if(!arguments.length)return this._chainedBatch();if("function"==typeof e&&(r=e),"function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(t))return nextTick(r,new Error("batch(array) requires an array argument"));if(0===t.length)return nextTick(r);"object"==typeof e&&null!==e||(e={});for(var n=new Array(t.length),i=0;i>6],i=0==(32&t);if(31==(31&t)){let o=t;for(t=0;128==(128&o);){if(o=e.readUInt8(r),e.isError(o))return o;t<<=7,t|=127&o}}else t&=31;return{cls:o,primitive:i,tag:t,tagStr:der.tag[t]}}function derDecodeLen(e,r,t){let o=e.readUInt8(t);if(e.isError(o))return o;if(!r&&128===o)return null;if(0==(128&o))return o;const i=127&o;if(i>4)return e.error("length octect is too long");o=0;for(let r=0;r=31?o.error("Multi-octet tag encoding unsupported"):(t||(n|=32),n|=der.tagClassByName[r||"universal"]<<6)}module.exports=DEREncoder,DEREncoder.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},inherits(DERNode,Node),DERNode.prototype._encodeComposite=function(e,t,r,o){const n=encodeTag(e,t,r,this.reporter);if(o.length<128){const e=Buffer.alloc(2);return e[0]=n,e[1]=o.length,this._createEncoderBuffer([e,o])}let i=1;for(let e=o.length;e>=256;e>>=8)i++;const s=Buffer.alloc(2+i);s[0]=n,s[1]=128|i;for(let e=1+i,t=o.length;t>0;e--,t>>=8)s[e]=255&t;return this._createEncoderBuffer([s,o])},DERNode.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=Buffer.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t=128;r>>=7)o++}const n=Buffer.alloc(o);let i=n.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(n[i--]=127&r;(r>>=7)>0;)n[i--]=128|127&r}return this._createEncoderBuffer(n)},DERNode.prototype._encodeTime=function(e,t){let r;const o=new Date(e);return"gentime"===t?r=[two(o.getUTCFullYear()),two(o.getUTCMonth()+1),two(o.getUTCDate()),two(o.getUTCHours()),two(o.getUTCMinutes()),two(o.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[two(o.getUTCFullYear()%100),two(o.getUTCMonth()+1),two(o.getUTCDate()),two(o.getUTCHours()),two(o.getUTCMinutes()),two(o.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer("")},DERNode.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!Buffer.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=Buffer.from(t)}if(Buffer.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=Buffer.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const o=new Array(r);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(Buffer.from(o))},DERNode.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},DERNode.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},DERNode.prototype._skipDefault=function(e,t,r){const o=this._baseState;let n;if(null===o.default)return!1;const i=e.join();if(void 0===o.defaultBuffer&&(o.defaultBuffer=this._encodeValue(o.default,t,r).join()),i.length!==o.defaultBuffer.length)return!1;for(n=0;n=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return h}function s(t,i,r,h){for(var n=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,h){if("number"==typeof t)return this._initNumber(t,i,h);if("object"==typeof t)return this._initArray(t,i,h);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===i?this._parseHex(t,n):this._parseBase(t,i,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initNumber=function(t,i,h){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initArray=function(t,i,h){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===h)for(n=0,e=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},n.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)n=o(t,r,r+6),this.words[h]|=n<>>26-e&4194303,(e+=24)>=26&&(e-=26,h++);r+6!==i&&(n=o(t,i,r+6),this.words[h]|=n<>>26-e&4194303),this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,u=Math.min(e,e-o)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}n.prototype.toString=function(t,i){var h;if(i=0|i||1,16===(t=t||10)||"hex"===t){h="";for(var n=0,e=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-m.length]+m+h:m+h,(n+=2)>=26&&(n-=26,o--)}for(0!==e&&(h=e.toString(16)+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}if(t===(0|t)&&t>=2&&t<=36){var f=a[t],d=l[t];h="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);h=(p=p.idivn(d)).isZero()?M+h:u[f-M.length]+M+h}for(this.isZero()&&(h="0"+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,h){var n=this.byteLength(),e=h||Math.max(1,n);r(n<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0"),this.strip();var o,s,u="le"===i,a=new t(e),l=this.clone();if(u){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),a[s]=o;for(;s=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;ht.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),h=t%26;this._expand(i),h>0&&i--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-h),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var h=t/26|0,n=t%26;return this._expand(h+1),this.words[h]=i?this.words[h]|1<t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e>>26;for(;0!==n&&e>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],R=8191&q,B=q>>>13,N=0|o[7],L=8191&N,I=N>>>13,z=0|o[8],T=8191&z,E=z>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,C=P>>>13,D=0|s[1],H=8191&D,J=D>>>13,U=0|s[2],G=8191&U,Q=U>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(h=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,F),n=(n=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,F),n=(n=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|0;var ct=(a+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,F),n=(n=Math.imul(y,C))+Math.imul(b,F)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,F),n=(n=Math.imul(k,C))+Math.imul(A,F)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(S,F),n=(n=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(R,F),n=(n=Math.imul(R,C))+Math.imul(B,F)|0,e=Math.imul(B,C),h=h+Math.imul(S,H)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(a+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(L,F),n=(n=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),h=h+Math.imul(R,H)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(B,H)|0,e=e+Math.imul(B,J)|0,h=h+Math.imul(S,G)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(T,F),n=(n=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),h=h+Math.imul(L,H)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,h=h+Math.imul(R,G)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(B,G)|0,e=e+Math.imul(B,Q)|0,h=h+Math.imul(S,W)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,F),n=(n=Math.imul(j,C))+Math.imul(K,F)|0,e=Math.imul(K,C),h=h+Math.imul(T,H)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,h=h+Math.imul(L,G)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,h=h+Math.imul(R,W)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(B,W)|0,e=e+Math.imul(B,X)|0,h=h+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var xt=(a+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),h=h+Math.imul(T,G)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(L,W)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,h=h+Math.imul(R,$)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,tt)|0,h=h+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var St=(a+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(T,W)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,h=h+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(B,rt)|0,e=e+Math.imul(B,ht)|0,h=h+Math.imul(S,et)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var Zt=(a+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,ht)|0,h=h+Math.imul(R,et)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(B,et)|0,e=e+Math.imul(B,ot)|0,h=h+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var qt=(a+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(L,et)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,h=h+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(B,ut)|0,e=e+Math.imul(B,at)|0,h=h+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Rt=(a+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(T,et)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,h=h+Math.imul(R,mt)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(B,mt)|0,e=e+Math.imul(B,ft)|0;var Bt=(a+(h=h+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,h=h+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(h=h+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,Mt)|0)+Math.imul(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),h=h+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(h=h+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(h=h+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(a+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=xt,u[10]=St,u[11]=Zt,u[12]=qt,u[13]=Rt,u[14]=Bt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function d(t,i,r){return(new p).mulp(t,i,r)}function p(t,i){this.x=t,this.y=i}Math.imul||(f=m),n.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,i):r<63?m(this,t,i):r<1024?function(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r.strip()}(this,t,i):d(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),r=n.prototype._countBits(t)-1,h=0;h>=1;return h},p.prototype.permute=function(t,i,r,h,n,e){for(var o=0;o>>=1)n++;return 1<>>=13,h[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,i+=n/67108864|0,i+=e>>>26,this.words[h]=67108863&e}return 0!==i&&(this.words[h]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r>>n}return i}(t);if(0===i.length)return new n(1);for(var r=this,h=0;h=0);var i,h=t%26,n=(t-h)/26,e=67108863>>>26-h<<26-h;if(0!==h){var o=0;for(i=0;i>>26-h}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,h){return r(0===this.negative),this.iushrn(t,i,h)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,h=(t-i)/26,n=1<=0);var i=t%26,h=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=h)return this;if(0!==i&&h++,this.length=Math.min(h,this.length),0!==i){var n=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[n+h]=67108863&e}for(;n>26,this.words[n+h]=67108863&e;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&e;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),h.iushln(r),o=0|e.words[e.length-1]);var s,u=h.length-e.length;if("mod"!==i){(s=new n(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|h.words[e.length+m])+(0|h.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(e,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(e,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s.strip(),h.strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},n.prototype.divmod=function(t,i,h){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i);var e,o,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,h=0,n=this.length-1;n>=0;n--)h=(i*h+(0|this.words[n]))%t;return h},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,h=this.length-1;h>=0;h--){var n=(0|this.words[h])+67108864*i;this.words[h]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=new n(0),u=new n(1),a=0;i.isEven()&&h.isEven();)i.iushrn(1),h.iushrn(1),++a;for(var l=h.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(h.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(h.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(s),o.isub(u)):(h.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:h.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e,o=new n(1),s=new n(0),u=h.clone();i.cmpn(1)>0&&h.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(h.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(h.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(h)>=0?(i.isub(h),o.isub(s)):(h.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,h=(t-i)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,h=t<0;if(0!==this.negative&&!h)return-1;if(0===this.negative&&h)return 1;if(this.strip(),this.length>1)i=1;else{h&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:nt.length)return 1;if(this.length=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){hn&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new b(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},h(g,v),g.prototype.split=function(t,i){for(var r=Math.min(t.length,9),h=0;h>>22,n=e}n>>>=22,t.words[h-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(M[t])return M[t];var i;if("k256"===t)i=new g;else if("p224"===t)i=new c;else if("p192"===t)i=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new y}return M[t]=i,i},b.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},b.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var h=this.m.add(new n(1)).iushrn(2);return this.pow(t,h)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new n(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;h--){for(var a=i.words[h],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===h&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new _(t)},h(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(h).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":55}],35:[function(require,module,exports){ +},{"buffer":60}],35:[function(require,module,exports){ (function (global){(function (){ "use strict";var objectAssign=require("object-assign");function compare(t,e){if(t===e)return 0;for(var r=t.length,i=e.length,n=0,a=Math.min(r,i);n=0;u--)if(o[u]!==c[u])return!1;for(u=o.length-1;u>=0;u--)if(!_deepEqual(t[s=o[u]],e[s],r,i))return!1;return!0}function notDeepStrictEqual(t,e,r){_deepEqual(t,e,!0)&&fail(t,e,r,"notDeepStrictEqual",notDeepStrictEqual)}function expectedException(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function _tryBlock(t){var e;try{t()}catch(t){e=t}return e}function _throws(t,e,r,i){var n;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(i=r,r=null),n=_tryBlock(e),i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:"."),t&&!n&&fail(n,r,"Missing expected exception"+i);var a="string"==typeof i,s=!t&&n&&!r;if((!t&&util.isError(n)&&a&&expectedException(n,r)||s)&&fail(n,r,"Got unwanted exception"+i),t&&n&&r&&!expectedException(n,r)||!t&&n)throw n}function strict(t,e){t||fail(t,!0,e,"==",strict)}assert.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=getMessage(this),this.generatedMessage=!0);var e=t.stackStartFunction||fail;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var i=r.stack,n=getName(e),a=i.indexOf("\n"+n);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},util.inherits(assert.AssertionError,Error),assert.fail=fail,assert.ok=ok,assert.equal=function(t,e,r){t!=e&&fail(t,e,r,"==",assert.equal)},assert.notEqual=function(t,e,r){t==e&&fail(t,e,r,"!=",assert.notEqual)},assert.deepEqual=function(t,e,r){_deepEqual(t,e,!1)||fail(t,e,r,"deepEqual",assert.deepEqual)},assert.deepStrictEqual=function(t,e,r){_deepEqual(t,e,!0)||fail(t,e,r,"deepStrictEqual",assert.deepStrictEqual)},assert.notDeepEqual=function(t,e,r){_deepEqual(t,e,!1)&&fail(t,e,r,"notDeepEqual",assert.notDeepEqual)},assert.notDeepStrictEqual=notDeepStrictEqual,assert.strictEqual=function(t,e,r){t!==e&&fail(t,e,r,"===",assert.strictEqual)},assert.notStrictEqual=function(t,e,r){t===e&&fail(t,e,r,"!==",assert.notStrictEqual)},assert.throws=function(t,e,r){_throws(!0,t,e,r)},assert.doesNotThrow=function(t,e,r){_throws(!1,t,e,r)},assert.ifError=function(t){if(t)throw t},assert.strict=objectAssign(strict,assert,{equal:assert.strictEqual,deepEqual:assert.deepStrictEqual,notEqual:assert.notStrictEqual,notDeepEqual:assert.notDeepStrictEqual}),assert.strict.strict=assert.strict;var objectKeys=Object.keys||function(t){var e=[];for(var r in t)hasOwn.call(t,r)&&e.push(r);return e}; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"object-assign":394,"util/":38}],36:[function(require,module,exports){ +},{"object-assign":400,"util/":38}],36:[function(require,module,exports){ "function"==typeof Object.create?module.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(t,e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}; },{}],37:[function(require,module,exports){ @@ -128,15 +128,15 @@ module.exports=function(o){return o&&"object"==typeof o&&"function"==typeof o.co var formatRegExp=/%[sdj%]/g;exports.format=function(e){if(!isString(e)){for(var r=[],t=0;t=i)return e;switch(e){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(e){return"[Circular]"}default:return e}}),s=n[t];t=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),isBoolean(r)?t.showHidden=r:r&&exports._extend(t,r),isUndefined(t.showHidden)&&(t.showHidden=!1),isUndefined(t.depth)&&(t.depth=2),isUndefined(t.colors)&&(t.colors=!1),isUndefined(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=stylizeWithColor),formatValue(t,e,t.depth)}function stylizeWithColor(e,r){var t=inspect.styles[r];return t?"["+inspect.colors[t][0]+"m"+e+"["+inspect.colors[t][1]+"m":e}function stylizeNoColor(e,r){return e}function arrayToHash(e){var r={};return e.forEach(function(e,t){r[e]=!0}),r}function formatValue(e,r,t){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==exports.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(t,e);return isString(n)||(n=formatValue(e,n,t)),n}var i=formatPrimitive(e,r);if(i)return i;var o=Object.keys(r),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),isError(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(r);if(0===o.length){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(isDate(r))return e.stylize(Date.prototype.toString.call(r),"date");if(isError(r))return formatError(r)}var c,a="",l=!1,p=["{","}"];(isArray(r)&&(l=!0,p=["[","]"]),isFunction(r))&&(a=" [Function"+(r.name?": "+r.name:"")+"]");return isRegExp(r)&&(a=" "+RegExp.prototype.toString.call(r)),isDate(r)&&(a=" "+Date.prototype.toUTCString.call(r)),isError(r)&&(a=" "+formatError(r)),0!==o.length||l&&0!=r.length?t<0?isRegExp(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=l?formatArray(e,r,t,s,o):o.map(function(n){return formatProperty(e,r,t,s,n,l)}),e.seen.pop(),reduceToSingleString(c,a,p)):p[0]+a+p[1]}function formatPrimitive(e,r){if(isUndefined(r))return e.stylize("undefined","undefined");if(isString(r)){var t="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(t,"string")}return isNumber(r)?e.stylize(""+r,"number"):isBoolean(r)?e.stylize(""+r,"boolean"):isNull(r)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,r,t,n,i){for(var o=[],s=0,u=r.length;s-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n")):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,r,t){return e.reduce(function(e,r){return 0,r.indexOf("\n")>=0&&0,e+r.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?t[0]+(""===r?"":r+"\n ")+" "+e.join(",\n ")+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}exports.debuglog=function(e){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){var r=process.pid;debugs[e]=function(){var t=exports.format.apply(exports,arguments);console.error("%s %d: %s",e,r,t)}}else debugs[e]=function(){};return debugs[e]},exports.inspect=inspect,inspect.colors={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]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var e=new Date,r=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],r].join(" ")}function hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(e,r){if(!r||!isObject(r))return e;for(var t=Object.keys(r),n=t.length;n--;)e[t[n]]=r[t[n]];return e}; }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":37,"_process":443,"inherits":36}],39:[function(require,module,exports){ +},{"./support/isBuffer":37,"_process":449,"inherits":36}],39:[function(require,module,exports){ (function (Buffer){(function (){ -const Cache=require("hashlru"),RAF=require("polyraf"),Obv=require("obz"),debounce=require("lodash.debounce"),debug=require("debug")("async-flumelog"),Stream=require("./stream");function alwaysTrue(){return!0}function id(e){return e}var _codec={encode:id,decode:id,buffer:!0};module.exports=function(e,t){var n,r=new Cache(1024),o=RAF(e),i=t&&t.blockSize||65536,u=t&&t.codec||_codec,l=t&&t.writeTimeout||250,f=t&&t.validateRecord||alwaysTrue,s=Obv(),c=[];const a=new Map,d=new Map;let g=-1;var h=null,b=null,v=null;function m(e){return e%i}function w(e){return(e-m(e))/i}function p(e){return(w(e)+1)*i}function y(e,t,n,r,u){debug("found record that does not validate, fixing last block",t);var l=e.slice(0,t);const f=Buffer.alloc(i);l.copy(f,0),o.write(n,f,()=>{u(null,r)})}function k(e,t){var n=e-m(e),u=n/i,l=r.get(u);l?(debug("getting offset %d from cache",e),t(null,l)):(debug("getting offset %d from disc",e),o.read(n,i,(n,o)=>{r.set(w(e),o),t(n,o)}))}function E(e){return e.length+2}function z(e){let t=u.encode(e);if("string"==typeof t&&(t=Buffer.from(t)),E(t)+2>i)throw new Error("data larger than block size");if(v+E(t)+2>i){var n=Buffer.alloc(i);h=n,b+=1,v=0,debug("data doesn't fit current block, creating new")}!function(e,t,n){e.writeUInt16LE(t.length,n),t.copy(e,n+2)}(h,t,v),r.set(b,h);const o=v+b*i;return v+=E(t),d.set(b,{block:h,fileOffset:o}),I(),debug("data inserted at offset %d",o),o}o.stat(function(t,n){t&&debug("failed to stat "+e,t);var u=n?n.size:-1;if(u<=0)for(debug("empty file"),h=Buffer.alloc(i),b=0,v=0,r.set(0,h),s.set(-1);c.length;)c.shift()();else o.read(u-i,i,(e,t)=>{if(e)throw e;!function(e,t,n){for(var r=0,o=0;ri)return y(e,r,t,o,n);var l=e.slice(r+2,r+2+u);if(!f(l))return y(e,r,t,o,n);o=r,r+=2+u}n(null,o)}(t,u-i,(e,n)=>{s.set(u-i+n),h=t;var r=t.readUInt16LE(n);for(v=n+2+r,b=u/i-1,debug("opened file, since: %d",s.value);c.length;)c.shift()()})})});var I=debounce(q,l);function q(){d.size>0&&function(e){if(!d.has(e))return;g=e;const{block:t,fileOffset:r}=d.get(e);d.delete(e),debug("writing block of size: %d, to offset: %d",t.length,e*i),o.write(e*i,t,t=>{const o=(a.get(e)||[]).slice(0);if(g=-1,t)throw debug("failed to write block %d",e),t;{s.set(r),n.streams.forEach(e=>{e.ended||!e.live||e.writing||(-1===e.cursor?e.cursor=0:e.skipFirst=!0,e.writing=!0,e.resume())}),debug("draining the waiting queue for %d, items: %d",e,o.length);for(var i=0;i= 0`):void k(e,(n,r)=>{if(n)return t(n);!function(e,t,n){var r=e.readUInt16LE(t),o=e.slice(t+2,t+2+r);if(o.every(e=>0===e)){const e=new Error("item has been deleted");return e.code="flumelog:deleted",n(e)}n(null,u.decode(o))}(r,m(e),t)})}),del:B(function(e,t){k(e,(n,r)=>{if(n)return t(n);const i=m(e),u=r.readUInt16LE(i);Buffer.alloc(u).copy(r,i+2),o.write(e-i,r,t)})}),append:B(function(e,t){if(Array.isArray(e)){for(var n=0,r=0,o=e.length;r0?function(e){let t=null;for(let n of e)t=n;return t}(d.keys()):g,n=a.get(t)||[];n.push(e),a.set(t,n)}}),filename:e,getNextBlockIndex:p,getDataNextOffset:function(e,t){const n=m(t),r=w(t),o=e.readUInt16LE(n),l=e.slice(n+2,n+2+o),f=e.readUInt16LE(n+2+o);let c=n+2+o+r*i;return 0===f&&p(t)>s.value?c=-1:0===f&&(c=0),l.every(e=>0===e)?[c,null]:[c,u.decode(l)]},getBlock:k,stream:function(e){var t=new Stream(n,e);return n.streams.push(t),t},streams:[]}}; +const Cache=require("hashlru"),RAF=require("polyraf"),Obv=require("obz"),debounce=require("lodash.debounce"),debug=require("debug")("async-flumelog"),fs=require("fs"),mutexify=require("mutexify"),Stream=require("./stream");function alwaysTrue(){return!0}function id(e){return e}const _codec={encode:id,decode:id,buffer:!0};module.exports=function(e,t){const n=new Cache(1024),r=RAF(e),o=t&&t.blockSize||65536,u=t&&t.codec||_codec,f=t&&t.writeTimeout||250,i=t&&t.validateRecord||alwaysTrue;let l;const s=Obv(),c=[],a=new Map,d=new Map;let g=-1,b=null,h=null,m=null;function p(e){return e%o}function y(e){return(e-p(e))/o}function w(e){return(y(e)+1)*o}r.stat(function(t,u){t&&debug("failed to stat "+e,t);const f=u?u.size:-1;if(f<=0)for(debug("empty file"),b=Buffer.alloc(o),h=0,m=0,n.set(0,b),s.set(-1);c.length;)c.shift()();else r.read(f-o,o,(e,t)=>{if(e)throw e;!function(e,t,n){let r=0;for(let u=0;uo)return v(e,u,t,r,n);{const o=e.slice(u+2,u+2+f);if(!i(o))return v(e,u,t,r,n);r=u,u+=2+f}}n(null,r)}(t,f-o,(e,n)=>{s.set(f-o+n),b=t;const r=t.readUInt16LE(n);for(m=n+2+r,h=f/o-1,debug("opened file, since: %d",s.value);c.length;)c.shift()()})})});const k=mutexify();function E(e,t,n,o){k(u=>{r.write(e,t,e=>{if(e)return u(o,e);r.fd?fs.fsync(r.fd,e=>{e?u(o,e):u(o,null,n)}):u(o,null,n)})})}function v(e,t,n,r,u){debug("found record that does not validate, fixing last block",t);const f=e.slice(0,t),i=Buffer.alloc(o);f.copy(i,0),E(n,i,r,u)}function x(e,t){const u=e-p(e),f=u/o;var i=n.get(f);i?(debug("getting offset %d from cache",e),t(null,i)):(debug("getting offset %d from disc",e),r.read(u,o,(e,r)=>{n.set(f,r),t(e,r)}))}function q(e,t,n){e.writeUInt16LE(t.length,n),t.copy(e,n+2)}function z(e){return e.length+2}function B(e){let t=u.encode(e);if("string"==typeof t&&(t=Buffer.from(t)),z(t)+2>o)throw new Error("data larger than block size");if(m+z(t)+2>o){const e=Buffer.alloc(o);b=e,h+=1,m=0,debug("data doesn't fit current block, creating new")}q(b,t,m),n.set(h,b);const r=m+h*o;return m+=z(t),d.set(h,{block:b,fileOffset:r}),I(),debug("data inserted at offset %d",r),r}const I=debounce(O,f);function O(){d.size>0&&function(e){if(!d.has(e))return;g=e;const{block:t,fileOffset:n}=d.get(e);d.delete(e),debug("writing block of size: %d, to offset: %d",t.length,e*o),E(e*o,t,null,t=>{const r=(a.get(e)||[]).slice(0);if(g=-1,t)throw debug("failed to write block %d",e),t;{s.set(n),l.streams.forEach(e=>{e.ended||!e.live||e.writing||(-1===e.cursor?e.cursor=0:e.skipNext=!0,e.writing=!0,e.resume())}),debug("draining the waiting queue for %d, items: %d",e,r.length);for(let e=0;e= 0`):void x(e,(n,r)=>{if(n)return t(n);!function(e,t,n){const r=e.readUInt16LE(t),o=e.slice(t+2,t+2+r);if(o.every(e=>0===e)){const e=new Error("item has been deleted");return e.code="flumelog:deleted",n(e)}n(null,u.decode(o))}(r,p(e),t)})}),del:L(function(e,t){x(e,(n,r)=>{if(n)return t(n);const o=p(e),u=r.readUInt16LE(o);Buffer.alloc(u).copy(r,o+2),E(e-o,r,null,t)})}),append:L(function(e,t){if(Array.isArray(e)){let n=0;for(let t=0,r=e.length;t{let t=u.encode(e);return"string"==typeof t&&(t=Buffer.from(t)),r+=z(t),t});if((r+=2)>o)return t(new Error("data larger than block size"));if(m+r>o){const e=Buffer.alloc(o);b=e,h+=1,m=0,debug("data doesn't fit current block, creating new")}const i=[];return f.forEach(e=>{q(b,e,m),n.set(h,b);const t=m+h*o;i.push(t),m+=z(e),d.set(h,{block:b,fileOffset:t}),debug("data inserted at offset %d",t)}),I(),t(null,i)}),close:L(function(e){l.onDrain(function(){for(;l.streams.length;)l.streams.shift().abort(new Error("async-flumelog: closed"));r.close(e)})}),since:s,onReady:function(e){null!==b?e():c.push(e)},onDrain:L(function(e){if(0===d.size&&-1===g)e();else{const t=d.size>0?function(e){let t=null;for(let n of e)t=n;return t}(d.keys()):g,n=a.get(t)||[];n.push(e),a.set(t,n)}}),filename:e,getNextBlockIndex:w,getDataNextOffset:function(e,t){const n=p(t),r=y(t),f=e.readUInt16LE(n),i=e.slice(n+2,n+2+f),l=e.readUInt16LE(n+2+f);let c=n+2+f+r*o;return 0===l&&w(t)>s.value?c=-1:0===l&&(c=0),i.every(e=>0===e)?[c,null]:[c,u.decode(i)]},getBlock:x,stream:function(e){const t=new Stream(l,e);return l.streams.push(t),t},streams:[]}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./stream":40,"buffer":99,"debug":131,"hashlru":237,"lodash.debounce":332,"obz":403,"polyraf":440}],40:[function(require,module,exports){ -var ltgt=require("ltgt"),looper=require("looper");function Stream(i,t){t=t||{},this.blocks=i,this.live=!!t.live,this.offsets=!1!==t.offsets,this.values=!1!==t.values,this.limit=t.limit||0,this.min=this.max=this.min_inclusive=this.max_inclusive=null,this.cursor=-1,this.count=0,this.hasWritten=!1,this.writing=!1,this.ended=!1,this.skipFirst=!1,this.opts=t,this._resumeCallback=this._resumeCallback.bind(this),this.blocks.onReady(this._ready.bind(this))}module.exports=Stream,Stream.prototype._ready=function(){this.min=ltgt.lowerBound(this.opts,null),ltgt.lowerBoundInclusive(this.opts)&&(this.min_inclusive=this.min),this.max=ltgt.upperBound(this.opts,null),ltgt.upperBoundInclusive(this.opts)&&(this.max_inclusive=this.max),this.cursor=ltgt.lowerBound(this.opts,0),this.cursor<0&&(this.cursor=0),this.opts.gt>=0&&(this.skipFirst=!0),this.live||0!==this.cursor||-1!==this.blocks.since.value||(this.ended=!0),this.live&&0===this.cursor&&-1===this.blocks.since.value&&(this.cursor=-1),this.resume()},Stream.prototype._writeToSink=function(i){this.hasWritten||(this.hasWritten=!0),this.values?this.offsets?this.sink.write({offset:this.cursor,value:i}):this.sink.write(i):this.sink.write(this.cursor)},Stream.prototype._handleBlock=function(i){for(;;){if(this.sink.paused)return null;const[t,s]=this.blocks.getDataNextOffset(i,this.cursor),e=this.cursor;if(this.skipFirst){if(this.skipFirst=!1,t>0){this.cursor=t;continue}if(0===t)return!0;if(-1===t)return!0===this.live&&(this.writing=!1),!1}if(this.count++,!(null===this.min||this.mine||this.max_inclusive===e))return!1;if(this._writeToSink(s),t>0)this.cursor=t;else{if(0===t)return!0;if(-1===t)return!0===this.live&&(this.writing=!1),!1}if(this.limit>0&&this.count>=this.limit)return!1}},Stream.prototype._resume=function(){if(this.sink&&!this.sink.paused)if(this.ended){if(!this.sink.ended){if(!0===this.ended&&!this.live)return this.abort();if(this.sink.end)return this.sink.end(!0===this.ended?null:this.ended)}}else-1!==this.cursor&&(this.live&&!this.writing&&this.hasWritten||(this.writing=!0,this.blocks.getBlock(this.cursor,this._resumeCallback)))},Stream.prototype._resumeCallback=function(i,t){if(i)return void console.error(i);const s=this._handleBlock(t);if(!0===s)this.cursor=this.blocks.getNextBlockIndex(this.cursor),this._next();else{if(null===s)return;!0!==this.live&&this.abort()}},Stream.prototype.resume=function(){this._next=looper(this._resume.bind(this)),this._next()},Stream.prototype.abort=function(i){this.ended=i||!0;var t=this.blocks.streams.indexOf(this);~t&&this.blocks.streams.splice(t,1),!this.sink.ended&&this.sink.end&&(this.sink.ended=!0,this.sink.end(!0===i?null:i))},Stream.prototype.pipe=require("push-stream/pipe"); +},{"./stream":40,"buffer":104,"debug":136,"fs":103,"hashlru":243,"lodash.debounce":338,"mutexify":371,"obz":409,"polyraf":446}],40:[function(require,module,exports){ +const ltgt=require("ltgt"),looper=require("looper");function Stream(t,i){i=i||{},this.blocks=t,this.live=!!i.live,this.offsets=!1!==i.offsets,this.values=!1!==i.values,this.limit=i.limit||0,this.min=this.max=this.min_inclusive=this.max_inclusive=null,this.cursor=-1,this.count=0,this.hasWritten=!1,this.writing=!1,this.ended=!1,this.skipNext=!1,this.opts=i,this._resumeCallback=this._resumeCallback.bind(this),this.blocks.onReady(this._ready.bind(this))}module.exports=Stream,Stream.prototype._ready=function(){this.min=ltgt.lowerBound(this.opts,null),ltgt.lowerBoundInclusive(this.opts)&&(this.min_inclusive=this.min),this.max=ltgt.upperBound(this.opts,null),ltgt.upperBoundInclusive(this.opts)&&(this.max_inclusive=this.max),this.cursor=ltgt.lowerBound(this.opts,0),this.cursor<0&&(this.cursor=0),this.opts.gt>=0&&(this.skipNext=!0),this.live||0!==this.cursor||-1!==this.blocks.since.value||(this.ended=!0),this.live&&0===this.cursor&&-1===this.blocks.since.value&&(this.cursor=-1),this.resume()},Stream.prototype._writeToSink=function(t){this.hasWritten||(this.hasWritten=!0),this.values?this.offsets?this.sink.write({offset:this.cursor,value:t}):this.sink.write(t):this.sink.write(this.cursor)},Stream.prototype._handleBlock=function(t){for(;;){if(this.sink.paused)return null;const[i,s]=this.blocks.getDataNextOffset(t,this.cursor);if(this.skipNext){if(this.skipNext=!1,i>0){this.cursor=i;continue}if(0===i)return!0;if(-1===i)return!0===this.live&&(this.writing=!1),!1}this.count++;const e=this.cursor;if(!(null===this.min||this.mine||this.max_inclusive===e))return!1;if(this._writeToSink(s),i>0)this.cursor=i;else{if(0===i)return!0;if(-1===i)return!0===this.live&&(this.writing=!1),!1}if(this.limit>0&&this.count>=this.limit)return!1}},Stream.prototype._resume=function(){if(this.sink&&!this.sink.paused)if(this.ended){if(!this.sink.ended){if(!0===this.ended&&!this.live)return this.abort();if(this.sink.end)return this.sink.end(!0===this.ended?null:this.ended)}}else-1!==this.cursor&&(this.live&&!this.writing&&this.hasWritten||(this.writing=!0,this.blocks.getBlock(this.cursor,this._resumeCallback)))},Stream.prototype._resumeCallback=function(t,i){if(t)return void console.error(t);const s=this._handleBlock(i);if(!0===s)this.cursor=this.blocks.getNextBlockIndex(this.cursor),this._next();else{if(null===s)return;!0!==this.live&&this.abort()}},Stream.prototype.resume=function(){this._next=looper(this._resume.bind(this)),this._next()},Stream.prototype.abort=function(t){this.ended=t||!0;const i=this.blocks.streams.indexOf(this);~i&&this.blocks.streams.splice(i,1),!this.sink.ended&&this.sink.end&&(this.sink.ended=!0,this.sink.end(!0===t?null:t))},Stream.prototype.pipe=require("push-stream/pipe"); -},{"looper":333,"ltgt":338,"push-stream/pipe":577}],41:[function(require,module,exports){ +},{"looper":339,"ltgt":343,"push-stream/pipe":584}],41:[function(require,module,exports){ function Single(t,i){if(!(this instanceof Single))return new Single(t,i);this.writing=!1,this.value=null,this.onDrain=null,this._async=t,this._options=i||{},this._setTimeout=i&&i.setTimeout||function(t,i){return setTimeout(t,i)}}module.exports=Single,Single.prototype.write=function(t){this.value=t,this.writing||this._timeout()},Single.prototype._write=function(){this.writing=!0;var t=this.value;this.value=null,this._async(t,this._written.bind(this))},Single.prototype._timeout=function(t){clearTimeout(this._timer),this._timer=this._setTimeout(this._write.bind(this),null==t?Math.max(this._options.min,this._options.max-(Date.now()-this._ts)):t)},Single.prototype._written=function(){if(this._ts=Date.now(),this.writing=!1,this.value)this.write(this.value);else{this.onDrain&&this.onDrain();var t=this._cb;this._cb=null,t&&t()}},Single.prototype.close=function(t){this.writing?this._cb=t:this.value?(this._cb=t,this._timeout(0)):t()}; },{}],42:[function(require,module,exports){ @@ -144,10 +144,10 @@ function Single(t,i){if(!(this instanceof Single))return new Single(t,i);this.wr const IdbKvStore=require("idb-kv-store");function getStoreAndKey(e){const t=e.split("/"),r=t.pop(),n=t.join("/");return{store:new IdbKvStore(n,{disableBroadcast:!0}),key:r}}function isUint8Array(e){return-1!==toString.call(e).indexOf("Uint8Array")}module.exports={readFile:function(e,t,r){r||(r=t);const{store:n,key:o}=getStoreAndKey(e);n.get.bind(n)(o,(e,t)=>{if(e)return r(e);r(null,isUint8Array(t)?Buffer.from(t):t)})},writeFile:function(e,t,r,n){n||(n=r);const{store:o,key:i}=getStoreAndKey(e);return o.set.bind(o)(i,t,n)}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99,"idb-kv-store":249}],43:[function(require,module,exports){ +},{"buffer":104,"idb-kv-store":255}],43:[function(require,module,exports){ const fs=require("fs"),path=require("path"),mutexify=require("mutexify");function getEncoding(e){return e&&e.encoding?e.encoding:null}const locks=new Map;module.exports={readFile:function(e,n,i){i||(i=n),fs.readFile(e,getEncoding(n),i)},writeFile:function(e,n,i,r){r||(r=i),locks.has(e)||locks.set(e,mutexify()),locks.get(e)(t=>{const s=e+"~";fs.mkdirSync(path.dirname(s),{recursive:!0}),fs.open(s,"w",(f,c)=>{if(f)return t(r,f);fs.writeFile(c,n,getEncoding(i),i=>{if(i)return t(r,i);fs.fsync(c,i=>{if(i)return t(r,i);fs.close(c,i=>{if(i)return t(r,i);fs.rename(s,e,e=>{if(e)return t(r,e);t(r,null,n)})})})})})})}}; -},{"fs":98,"mutexify":366,"path":424}],44:[function(require,module,exports){ +},{"fs":103,"mutexify":371,"path":430}],44:[function(require,module,exports){ "undefined"==typeof localStorage||null===localStorage?module.exports=require("./fs"):module.exports=require("./browser"); },{"./browser":42,"./fs":43}],45:[function(require,module,exports){ @@ -156,12 +156,12 @@ const Store=require("./store/idb"),Inject=require("./inject");module.exports=fun },{"./inject":46,"./store/idb":47}],46:[function(require,module,exports){ "use strict";var mutexify=require("mutexify");module.exports=function(n,t){var e,u=t||require("flumecodec/json"),r=mutexify();return{get:function(t){if(e)return t(null,e);n.get(function(n,r){if(n)return t(n);try{e=u.decode(r)}catch(n){return t(n)}t(null,e)})},set:function(t,i){r(function(r){n.set(u.encode(t),function(n){n||(e=t),r(i,n,t)})})},destroy:function(t){r(function(u){n.destroy(function(n){e=null,u(t,n)})})}}}; -},{"flumecodec/json":192,"mutexify":366}],47:[function(require,module,exports){ +},{"flumecodec/json":198,"mutexify":371}],47:[function(require,module,exports){ (function (Buffer){(function (){ const IdbKvStore=require("idb-kv-store");module.exports=function(o,t,e){const n=o.split("/"),r=n.pop(),s=n.join("/"),i=new IdbKvStore(s,{disableBroadcast:!0});return{set:function(o,t){i.set(r,e?o.toString("base64"):o,t)},get:function(o){i.get(r,function(t,n){t?o(t):n?o(null,n&&(e?Buffer.from(n,"base64"):n)):o(new Error("not found"))})},destroy:function(o){i.remove(r,o)}}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99,"idb-kv-store":249}],48:[function(require,module,exports){ +},{"buffer":104,"idb-kv-store":255}],48:[function(require,module,exports){ (function (global){(function (){ "use strict";var filter=require("array-filter");module.exports=function(){return filter(["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],function(r){return"function"==typeof global[r]})}; @@ -174,65 +174,88 @@ const IdbKvStore=require("idb-kv-store");module.exports=function(o,t,e){const n= "use strict";function unescape(e){return(e+"===".slice((e.length+3)%4)).replace(/-/g,"+").replace(/_/g,"/")}function escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function encode(e,c){return escape(Buffer.from(e,c||"utf8").toString("base64"))}function decode(e,c){return Buffer.from(unescape(e),"base64").toString(c||"utf8")}module.exports={unescape:unescape,escape:escape,encode:encode,decode:decode}; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99}],51:[function(require,module,exports){ +},{"buffer":104}],51:[function(require,module,exports){ +(function (Buffer){(function (){ +const INTEGER_START=105,STRING_DELIM=58,DICTIONARY_START=100,LIST_START=108,END_OF_TYPE=101;function getIntFromBuffer(e,d,o){let t=0,n=1;for(let c=d;c=48)t=10*t+(o-48);else if(c!==d||43!==o){if(c!==d||45!==o){if(46===o)break;throw new Error("not a number: buffer["+c+"] = "+o)}n=-1}}return t*n}function decode(e,d,o,t){return null==e||0===e.length?null:("number"!=typeof d&&null==t&&(t=d,d=void 0),"number"!=typeof o&&null==t&&(t=o,o=void 0),decode.position=0,decode.encoding=t||null,decode.data=Buffer.isBuffer(e)?e.slice(d,o):Buffer.from(e),decode.bytes=decode.data.length,decode.next())}decode.bytes=0,decode.position=0,decode.data=null,decode.encoding=null,decode.next=function(){switch(decode.data[decode.position]){case 100:return decode.dictionary();case 108:return decode.list();case 105:return decode.integer();default:return decode.buffer()}},decode.find=function(e){let d=decode.position;const o=decode.data.length,t=decode.data;for(;d>>1,f=r[i];(void 0!==o?o(f,n):f-n)>=0?(u=i,e=i-1):t=i+1}return u}function gt(r,n,o,t,e){for(var u=e+1;t<=e;){var i=t+e>>>1,f=r[i];(void 0!==o?o(f,n):f-n)>0?(u=i,e=i-1):t=i+1}return u}function lt(r,n,o,t,e){for(var u=t-1;t<=e;){var i=t+e>>>1,f=r[i];(void 0!==o?o(f,n):f-n)<0?(u=i,t=i+1):e=i-1}return u}function le(r,n,o,t,e){for(var u=t-1;t<=e;){var i=t+e>>>1,f=r[i];(void 0!==o?o(f,n):f-n)<=0?(u=i,t=i+1):e=i-1}return u}function eq(r,n,o,t,e){for(;t<=e;){var u=t+e>>>1,i=r[u],f=void 0!==o?o(i,n):i-n;if(0===f)return u;f<=0?t=u+1:e=u-1}return-1}function norm(r,n,o,t,e,u){return"function"==typeof o?u(r,n,o,void 0===t?0:0|t,void 0===e?r.length-1:0|e):u(r,n,void 0,void 0===o?0:0|o,void 0===t?r.length-1:0|t)}module.exports={ge:function(r,n,o,t,e){return norm(r,n,o,t,e,ge)},gt:function(r,n,o,t,e){return norm(r,n,o,t,e,gt)},lt:function(r,n,o,t,e){return norm(r,n,o,t,e,lt)},le:function(r,n,o,t,e){return norm(r,n,o,t,e,le)},eq:function(r,n,o,t,e){return norm(r,n,o,t,e,eq)}}; -},{}],52:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ (function (Buffer){(function (){ var varint=require("varint"),STRING=0,BUFFER=1,INT=2,DOUBLE=3,ARRAY=4,OBJECT=5,BOOLNULL=6,RESERVED=7,TAG_SIZE=3,TAG_MASK=7,bytes=0,encoders=[function(e,r,n){return r.write(e,n)},function(e,r,n){return e.copy(r,n,0,e.length),e.length},function(e,r,n){return r.writeInt32LE(e,n),4},function(e,r,n){return r.writeDoubleLE(e,n),8},function(e,r,n){for(var t=n,o=0;o>TAG_SIZE,a=decode_type(i,e,r+(o+=varint.decode.bytes),c);t.push(a),o+=c}return t}function decode_object(e,r,n){for(var t={},o=0;o>TAG_SIZE,c=decode_string(e,r+(o+=varint.decode.bytes),i);o+=i;var a=varint.decode(e,r+o),u=a&TAG_MASK;if(7===u)throw new Error("reserved type:value");var f=a>>TAG_SIZE,v=decode_type(u,e,r+(o+=varint.decode.bytes),f);o+=f,t[c]=v}return t}function decode_boolnull(e,r,n){if(0===n)return null;if(e[r]>2)throw new Error("invalid boolnull");if(n>1)throw new Error("invalid boolnull, length must = 1");return 0!==e[r]&&(1===e[r]||void 0)}function getType(e){return"string"==typeof e||e instanceof Date?STRING:Buffer.isBuffer(e)?BUFFER:Number.isInteger(e)&&Math.abs(e)<=4294967296?INT:"number"==typeof e&&Number.isFinite(e)?DOUBLE:Array.isArray(e)?ARRAY:e&&"object"==typeof e?OBJECT:"boolean"==typeof e||null==e?BOOLNULL:void 0}function encodingLength(e){var r=getType(e),n=encodingLengthers[r](e);return varint.encodingLength(n<>TAG_SIZE;return e.slice(r+varint.decode.bytes,r+varint.decode.bytes+n)}function getEncodedLength(e,r){return varint.decode(e,r)>>TAG_SIZE}function getEncodedType(e,r){return varint.decode(e,r)&TAG_MASK}function encode(e,r,n,t){n|=0;var o=getType(e);if("function"!=typeof encodingLengthers[o])throw new Error("unknown type:"+o+", "+JSON.stringify(e));var d=void 0===t?encodingLengthers[o](e):t;if(7===o)throw new Error("reserved type");varint.encode(d<>TAG_SIZE,d=varint.decode.bytes,i=decode_type(t,e,r+=d,o);return decode.bytes=o+d,i}function seekKey(e,r,n){if(-1===r)return-1;var t=varint.decode(e,r);if((t&TAG_MASK)!=OBJECT)return-1;for(var o=(n=Buffer.isBuffer(n)?n:Buffer.from(n)).length,d=t>>TAG_SIZE,i=varint.decode.bytes;i>TAG_SIZE;if((c&TAG_MASK)===STRING&&o===a&&0===e.compare(n,0,o,r+i,r+i+o))return r+i+a;i+=a;var u=varint.decode(e,r+i);i+=varint.decode.bytes,i+=u>>TAG_SIZE}return-1}function seekKey2(e,r,n,t){var o=varint.decode(e,r);if((o&TAG_MASK)!=OBJECT)return-1;for(var d=varint.decode.bytes,i=o>>TAG_SIZE,c=varint.decode(n,t),a=(c>>TAG_SIZE)+varint.decode.bytes;d+a>TAG_SIZE)+varint.decode.bytes;d+=(u>>TAG_SIZE)+varint.decode.bytes,d+=(varint.decode(e,r+d)>>TAG_SIZE)+varint.decode.bytes}return-1}function seekPath(e,r,n,t){var o=decode(n,t=t||0);if(!Array.isArray(o))throw new Error("path must be encoded array");for(var d=0;d>TAG_SIZE,d=Math.min(n.length,o);return e.compare(n,0,d,r+varint.decode.bytes,r+varint.decode.bytes+d)||n.length-o}function isNull(e){return 6===e}function isUndefined(e,r){return 14===e&&2===r}function compare(e,r,n,t){if(-1===r||-1===t)return r-t;var o=varint.decode(e,r),d=varint.decode.bytes,i=varint.decode(n,t),c=varint.decode.bytes,a=o&TAG_MASK,u=i&TAG_MASK;if(isNull(o))return isNull(i)?0:-1;if(isNull(i))return 1;if(isUndefined(o,e[r+1]))return isUndefined(i,n[t+1])?0:1;if(isUndefined(i,n[t+1]))return-1;if(a===INT&&u===DOUBLE)return e.readInt32LE(r+d)-n.readDoubleLE(t+c);if(a===DOUBLE&&a===INT)return e.readDoubleLE(r+d)-n.readInt32LE(t+c);if(a!==u)return a-u;if(a===DOUBLE)return e.readDoubleLE(r+d)-n.readDoubleLE(t+c);if(a===INT)return e.readInt32LE(r+d)-n.readInt32LE(t+c);if(a!==STRING){var f=a-u;if(f)return f}return e.compare(n,t+c,t+c+(i>>TAG_SIZE),r+d,r+d+(o>>TAG_SIZE))}function iterate(e,r,n){var t=varint.decode(e,r),o=t>>TAG_SIZE,d=t&TAG_MASK;if(d===OBJECT){for(var i=varint.decode.bytes;i>TAG_SIZE),f=varint.decode(e,u),v=varint.decode.bytes+(f>>TAG_SIZE);if(n(e,u,c))return r;i+=v}return r}if(d===ARRAY){var s=0;for(i=varint.decode.bytes;i>TAG_SIZE)}return r}return-1}function createCompareAt(e){var r=e.map(createSeekPath);return function(e,n){for(var t=0;t=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:a,o|=u}return r(!(240&o),"Invalid character in "+t),h}function s(t,i,n,h){for(var e=0,o=0,s=Math.min(t.length,n),u=i;u=49?a-49+10:a>=17?a-17+10:a,r(a>=0&&o0?t:i},h.min=function(t,i){return t.cmp(i)<0?t:i},h.prototype._init=function(t,i,n){if("number"==typeof t)return this._initNumber(t,i,n);if("object"==typeof t)return this._initArray(t,i,n);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var h=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&h++,16===i?this._parseHex(t,h):this._parseBase(t,i,h),"-"===t[0]&&(this.negative=1),this._strip(),"le"===n&&this._initArray(this.toArray(),i,n)},h.prototype._initNumber=function(t,i,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),i,n)},h.prototype._initArray=function(t,i,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var h=0;h=0;h-=3)o=t[h]|t[h-1]<<8|t[h-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===n)for(h=0,e=0;h>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this._strip()},h.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)h=o(t,r,r+6),this.words[n]|=h<>>26-e&4194303,(e+=24)>=26&&(e-=26,n++);r+6!==i&&(h=o(t,i,r+6),this.words[n]|=h<>>26-e&4194303),this._strip()},h.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var n=0,h=1;h<=67108863;h*=i)n++;n--,h=h/i|0;for(var e=t.length-r,o=e%n,u=Math.min(e,e-o)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},h.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{h.prototype[Symbol.for("nodejs.util.inspect.custom")]=a}catch(t){h.prototype.inspect=a}else h.prototype.inspect=a;function a(){return(this.red?""}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];h.prototype.toString=function(t,i){var n;if(i=0|i||1,16===(t=t||10)||"hex"===t){n="";for(var h=0,e=0,o=0;o>>24-h&16777215)||o!==this.length-1?l[6-u.length]+u+n:u+n,(h+=2)>=26&&(h-=26,o--)}for(0!==e&&(n=e.toString(16)+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var a=m[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modrn(d).toString(t);n=(p=p.idivn(d)).isZero()?M+n:l[a-M.length]+M+n}for(this.isZero()&&(n="0"+n);n.length%i!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},h.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},h.prototype.toJSON=function(){return this.toString(16,2)},e&&(h.prototype.toBuffer=function(t,i){return this.toArrayLike(e,t,i)}),h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)};function d(t,i,r){r.negative=i.negative^t.negative;var n=t.length+i.length|0;r.length=n,n=n-1|0;var h=0|t.words[0],e=0|i.words[0],o=h*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(h=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r._strip()}h.prototype.toArrayLike=function(t,i,n){this._strip();var h=this.byteLength(),e=n||Math.max(1,h);r(h<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,e);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,h),o},h.prototype._toArrayLikeLE=function(t,i){for(var r=0,n=0,h=0,e=0;h>8&255),r>16&255),6===e?(r>24&255),n=0,e=0):(n=o>>>24,e+=2)}if(r=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===e?(r>=0&&(t[r--]=o>>24&255),n=0,e=0):(n=o>>>24,e+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?h.prototype._countBits=function(t){return 32-Math.clz32(t)}:h.prototype._countBits=function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},h.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},h.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},h.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},h.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},h.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},h.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},h.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},h.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},h.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),n=t%26;this._expand(i),n>0&&i--;for(var h=0;h0&&(this.words[h]=~this.words[h]&67108863>>26-n),this._strip()},h.prototype.notn=function(t){return this.clone().inotn(t)},h.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var n=t/26|0,h=t%26;return this._expand(n+1),this.words[n]=i?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var h=0,e=0;e>>26;for(;0!==h&&e>>26;if(this.length=r.length,0!==h)this.words[this.length]=h,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},h.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,h=this.cmp(t);if(0===h)return this.negative=0,this.length=1,this.words[0]=0,this;h>0?(r=this,n=t):(r=t,n=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,S=0|o[5],x=8191&S,q=S>>>13,B=0|o[6],R=8191&B,Z=B>>>13,L=0|o[7],N=8191&L,I=L>>>13,E=0|o[8],z=8191&E,T=E>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,U=P>>>13,C=0|s[1],D=8191&C,H=C>>>13,J=0|s[2],G=8191&J,Q=J>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,nt=it>>>13,ht=0|s[6],et=8191&ht,ot=ht>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(n=Math.imul(m,F))|0)+((8191&(h=(h=Math.imul(m,U))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,U))+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,F),h=(h=Math.imul(p,U))+Math.imul(M,F)|0,e=Math.imul(M,U);var gt=(a+(n=n+Math.imul(m,D)|0)|0)+((8191&(h=(h=h+Math.imul(m,H)|0)+Math.imul(f,D)|0))<<13)|0;a=((e=e+Math.imul(f,H)|0)+(h>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,F),h=(h=Math.imul(g,U))+Math.imul(c,F)|0,e=Math.imul(c,U),n=n+Math.imul(p,D)|0,h=(h=h+Math.imul(p,H)|0)+Math.imul(M,D)|0,e=e+Math.imul(M,H)|0;var ct=(a+(n=n+Math.imul(m,G)|0)|0)+((8191&(h=(h=h+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(h>>>13)|0)+(ct>>>26)|0,ct&=67108863,n=Math.imul(y,F),h=(h=Math.imul(y,U))+Math.imul(b,F)|0,e=Math.imul(b,U),n=n+Math.imul(g,D)|0,h=(h=h+Math.imul(g,H)|0)+Math.imul(c,D)|0,e=e+Math.imul(c,H)|0,n=n+Math.imul(p,G)|0,h=(h=h+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(n=n+Math.imul(m,W)|0)|0)+((8191&(h=(h=h+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(h>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,F),h=(h=Math.imul(k,U))+Math.imul(A,F)|0,e=Math.imul(A,U),n=n+Math.imul(y,D)|0,h=(h=h+Math.imul(y,H)|0)+Math.imul(b,D)|0,e=e+Math.imul(b,H)|0,n=n+Math.imul(g,G)|0,h=(h=h+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,n=n+Math.imul(p,W)|0,h=(h=h+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(n=n+Math.imul(m,$)|0)|0)+((8191&(h=(h=h+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(h>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(x,F),h=(h=Math.imul(x,U))+Math.imul(q,F)|0,e=Math.imul(q,U),n=n+Math.imul(k,D)|0,h=(h=h+Math.imul(k,H)|0)+Math.imul(A,D)|0,e=e+Math.imul(A,H)|0,n=n+Math.imul(y,G)|0,h=(h=h+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,n=n+Math.imul(g,W)|0,h=(h=h+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,n=n+Math.imul(p,$)|0,h=(h=h+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(n=n+Math.imul(m,rt)|0)|0)+((8191&(h=(h=h+Math.imul(m,nt)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,nt)|0)+(h>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(R,F),h=(h=Math.imul(R,U))+Math.imul(Z,F)|0,e=Math.imul(Z,U),n=n+Math.imul(x,D)|0,h=(h=h+Math.imul(x,H)|0)+Math.imul(q,D)|0,e=e+Math.imul(q,H)|0,n=n+Math.imul(k,G)|0,h=(h=h+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,n=n+Math.imul(y,W)|0,h=(h=h+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,n=n+Math.imul(g,$)|0,h=(h=h+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,n=n+Math.imul(p,rt)|0,h=(h=h+Math.imul(p,nt)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,nt)|0;var _t=(a+(n=n+Math.imul(m,et)|0)|0)+((8191&(h=(h=h+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(h>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(N,F),h=(h=Math.imul(N,U))+Math.imul(I,F)|0,e=Math.imul(I,U),n=n+Math.imul(R,D)|0,h=(h=h+Math.imul(R,H)|0)+Math.imul(Z,D)|0,e=e+Math.imul(Z,H)|0,n=n+Math.imul(x,G)|0,h=(h=h+Math.imul(x,Q)|0)+Math.imul(q,G)|0,e=e+Math.imul(q,Q)|0,n=n+Math.imul(k,W)|0,h=(h=h+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,n=n+Math.imul(y,$)|0,h=(h=h+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,n=n+Math.imul(g,rt)|0,h=(h=h+Math.imul(g,nt)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,nt)|0,n=n+Math.imul(p,et)|0,h=(h=h+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(n=n+Math.imul(m,ut)|0)|0)+((8191&(h=(h=h+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(h>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(z,F),h=(h=Math.imul(z,U))+Math.imul(T,F)|0,e=Math.imul(T,U),n=n+Math.imul(N,D)|0,h=(h=h+Math.imul(N,H)|0)+Math.imul(I,D)|0,e=e+Math.imul(I,H)|0,n=n+Math.imul(R,G)|0,h=(h=h+Math.imul(R,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,n=n+Math.imul(x,W)|0,h=(h=h+Math.imul(x,X)|0)+Math.imul(q,W)|0,e=e+Math.imul(q,X)|0,n=n+Math.imul(k,$)|0,h=(h=h+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,n=n+Math.imul(y,rt)|0,h=(h=h+Math.imul(y,nt)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,nt)|0,n=n+Math.imul(g,et)|0,h=(h=h+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,n=n+Math.imul(p,ut)|0,h=(h=h+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(n=n+Math.imul(m,mt)|0)|0)+((8191&(h=(h=h+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(h>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(j,F),h=(h=Math.imul(j,U))+Math.imul(K,F)|0,e=Math.imul(K,U),n=n+Math.imul(z,D)|0,h=(h=h+Math.imul(z,H)|0)+Math.imul(T,D)|0,e=e+Math.imul(T,H)|0,n=n+Math.imul(N,G)|0,h=(h=h+Math.imul(N,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,n=n+Math.imul(R,W)|0,h=(h=h+Math.imul(R,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,n=n+Math.imul(x,$)|0,h=(h=h+Math.imul(x,tt)|0)+Math.imul(q,$)|0,e=e+Math.imul(q,tt)|0,n=n+Math.imul(k,rt)|0,h=(h=h+Math.imul(k,nt)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,nt)|0,n=n+Math.imul(y,et)|0,h=(h=h+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,n=n+Math.imul(g,ut)|0,h=(h=h+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,n=n+Math.imul(p,mt)|0,h=(h=h+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var St=(a+(n=n+Math.imul(m,pt)|0)|0)+((8191&(h=(h=h+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(h>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(j,D),h=(h=Math.imul(j,H))+Math.imul(K,D)|0,e=Math.imul(K,H),n=n+Math.imul(z,G)|0,h=(h=h+Math.imul(z,Q)|0)+Math.imul(T,G)|0,e=e+Math.imul(T,Q)|0,n=n+Math.imul(N,W)|0,h=(h=h+Math.imul(N,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,n=n+Math.imul(R,$)|0,h=(h=h+Math.imul(R,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,n=n+Math.imul(x,rt)|0,h=(h=h+Math.imul(x,nt)|0)+Math.imul(q,rt)|0,e=e+Math.imul(q,nt)|0,n=n+Math.imul(k,et)|0,h=(h=h+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,n=n+Math.imul(y,ut)|0,h=(h=h+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,n=n+Math.imul(g,mt)|0,h=(h=h+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var xt=(a+(n=n+Math.imul(p,pt)|0)|0)+((8191&(h=(h=h+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(h>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(j,G),h=(h=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),n=n+Math.imul(z,W)|0,h=(h=h+Math.imul(z,X)|0)+Math.imul(T,W)|0,e=e+Math.imul(T,X)|0,n=n+Math.imul(N,$)|0,h=(h=h+Math.imul(N,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,n=n+Math.imul(R,rt)|0,h=(h=h+Math.imul(R,nt)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,nt)|0,n=n+Math.imul(x,et)|0,h=(h=h+Math.imul(x,ot)|0)+Math.imul(q,et)|0,e=e+Math.imul(q,ot)|0,n=n+Math.imul(k,ut)|0,h=(h=h+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,n=n+Math.imul(y,mt)|0,h=(h=h+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var qt=(a+(n=n+Math.imul(g,pt)|0)|0)+((8191&(h=(h=h+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(h>>>13)|0)+(qt>>>26)|0,qt&=67108863,n=Math.imul(j,W),h=(h=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),n=n+Math.imul(z,$)|0,h=(h=h+Math.imul(z,tt)|0)+Math.imul(T,$)|0,e=e+Math.imul(T,tt)|0,n=n+Math.imul(N,rt)|0,h=(h=h+Math.imul(N,nt)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,nt)|0,n=n+Math.imul(R,et)|0,h=(h=h+Math.imul(R,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,n=n+Math.imul(x,ut)|0,h=(h=h+Math.imul(x,at)|0)+Math.imul(q,ut)|0,e=e+Math.imul(q,at)|0,n=n+Math.imul(k,mt)|0,h=(h=h+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var Bt=(a+(n=n+Math.imul(y,pt)|0)|0)+((8191&(h=(h=h+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(h>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(j,$),h=(h=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),n=n+Math.imul(z,rt)|0,h=(h=h+Math.imul(z,nt)|0)+Math.imul(T,rt)|0,e=e+Math.imul(T,nt)|0,n=n+Math.imul(N,et)|0,h=(h=h+Math.imul(N,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,n=n+Math.imul(R,ut)|0,h=(h=h+Math.imul(R,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,n=n+Math.imul(x,mt)|0,h=(h=h+Math.imul(x,ft)|0)+Math.imul(q,mt)|0,e=e+Math.imul(q,ft)|0;var Rt=(a+(n=n+Math.imul(k,pt)|0)|0)+((8191&(h=(h=h+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(h>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(j,rt),h=(h=Math.imul(j,nt))+Math.imul(K,rt)|0,e=Math.imul(K,nt),n=n+Math.imul(z,et)|0,h=(h=h+Math.imul(z,ot)|0)+Math.imul(T,et)|0,e=e+Math.imul(T,ot)|0,n=n+Math.imul(N,ut)|0,h=(h=h+Math.imul(N,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,n=n+Math.imul(R,mt)|0,h=(h=h+Math.imul(R,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Zt=(a+(n=n+Math.imul(x,pt)|0)|0)+((8191&(h=(h=h+Math.imul(x,Mt)|0)+Math.imul(q,pt)|0))<<13)|0;a=((e=e+Math.imul(q,Mt)|0)+(h>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,n=Math.imul(j,et),h=(h=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),n=n+Math.imul(z,ut)|0,h=(h=h+Math.imul(z,at)|0)+Math.imul(T,ut)|0,e=e+Math.imul(T,at)|0,n=n+Math.imul(N,mt)|0,h=(h=h+Math.imul(N,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Lt=(a+(n=n+Math.imul(R,pt)|0)|0)+((8191&(h=(h=h+Math.imul(R,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(h>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(j,ut),h=(h=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),n=n+Math.imul(z,mt)|0,h=(h=h+Math.imul(z,ft)|0)+Math.imul(T,mt)|0,e=e+Math.imul(T,ft)|0;var Nt=(a+(n=n+Math.imul(N,pt)|0)|0)+((8191&(h=(h=h+Math.imul(N,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(h>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(j,mt),h=(h=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(n=n+Math.imul(z,pt)|0)|0)+((8191&(h=(h=h+Math.imul(z,Mt)|0)+Math.imul(T,pt)|0))<<13)|0;a=((e=e+Math.imul(T,Mt)|0)+(h>>>13)|0)+(It>>>26)|0,It&=67108863;var Et=(a+(n=Math.imul(j,pt))|0)+((8191&(h=(h=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(h>>>13)|0)+(Et>>>26)|0,Et&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=St,u[10]=xt,u[11]=qt,u[12]=Bt,u[13]=Rt,u[14]=Zt,u[15]=Lt,u[16]=Nt,u[17]=It,u[18]=Et,0!==a&&(u[19]=a,r.length++),r};function M(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var n=0,h=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,n=o,o=h}return 0!==n?r.words[e]=n:r.length--,r._strip()}function v(t,i,r){return M(t,i,r)}function g(t,i){this.x=t,this.y=i}Math.imul||(p=d),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,i):r<63?d(this,t,i):r<1024?M(this,t,i):v(this,t,i)},g.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,i,r,n,h,e){for(var o=0;o>>=1)h++;return 1<>>=13,n[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,n+=e/67108864|0,n+=o>>>26,this.words[h]=67108863&o}return 0!==n&&(this.words[h]=n,this.length++),i?this.ineg():this},h.prototype.muln=function(t){return this.clone().imuln(t)},h.prototype.sqr=function(){return this.mul(this)},h.prototype.isqr=function(){return this.imul(this.clone())},h.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r>>h&1}return i}(t);if(0===i.length)return new h(1);for(var r=this,n=0;n=0);var i,n=t%26,h=(t-n)/26,e=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(i=0;i>>26-n}o&&(this.words[i]=o,this.length++)}if(0!==h){for(i=this.length-1;i>=0;i--)this.words[i+h]=this.words[i];for(i=0;i=0),h=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=h);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},h.prototype.ishrn=function(t,i,n){return r(0===this.negative),this.iushrn(t,i,n)},h.prototype.shln=function(t){return this.clone().ishln(t)},h.prototype.ushln=function(t){return this.clone().iushln(t)},h.prototype.shrn=function(t){return this.clone().ishrn(t)},h.prototype.ushrn=function(t){return this.clone().iushrn(t)},h.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,n=(t-i)/26,h=1<=0);var i=t%26,n=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==i&&n++,this.length=Math.min(n,this.length),0!==i){var h=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},h.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[h+n]=67108863&e}for(;h>26,this.words[h+n]=67108863&e;if(0===s)return this._strip();for(r(-1===s),s=0,h=0;h>26,this.words[h]=67108863&e;return this.negative=1,this._strip()},h.prototype._wordDiv=function(t,i){var r=(this.length,t.length),n=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),n.iushln(r),o=0|e.words[e.length-1]);var s,u=n.length-e.length;if("mod"!==i){(s=new h(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|n.words[e.length+m])+(0|n.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),n._ishlnsubmul(e,f,m);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(e,1,m),n.isZero()||(n.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),n._strip(),"div"!==i&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},h.prototype.divmod=function(t,i,n){return r(!t.isZero()),this.isZero()?{div:new h(0),mod:new h(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),n&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),n&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new h(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new h(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modrn(t.words[0]))}:this._wordDiv(t,i);var e,o,s},h.prototype.div=function(t){return this.divmod(t,"div",!1).div},h.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},h.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},h.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,n=t.ushrn(1),h=t.andln(1),e=r.cmp(n);return e<0||1===h&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},h.prototype.modrn=function(t){var i=t<0;i&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,h=0,e=this.length-1;e>=0;e--)h=(n*h+(0|this.words[e]))%t;return i?-h:h},h.prototype.modn=function(t){return this.modrn(t)},h.prototype.idivn=function(t){var i=t<0;i&&(t=-t),r(t<=67108863);for(var n=0,h=this.length-1;h>=0;h--){var e=(0|this.words[h])+67108864*n;this.words[h]=e/t|0,n=e%t}return this._strip(),i?this.ineg():this},h.prototype.divn=function(t){return this.clone().idivn(t)},h.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new h(1),o=new h(0),s=new h(0),u=new h(1),a=0;i.isEven()&&n.isEven();)i.iushrn(1),n.iushrn(1),++a;for(var l=n.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(n.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(n)>=0?(i.isub(n),e.isub(s),o.isub(u)):(n.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:n.iushln(a)}},h.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,n=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e,o=new h(1),s=new h(0),u=n.clone();i.cmpn(1)>0&&n.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(n.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(n.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(n)>=0?(i.isub(n),o.isub(s)):(n.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},h.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var n=0;i.isEven()&&r.isEven();n++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var h=i.cmp(r);if(h<0){var e=i;i=r,r=e}else if(0===h||0===r.cmpn(1))break;i.isub(r)}return r.iushln(n)},h.prototype.invm=function(t){return this.egcd(t).a.umod(t)},h.prototype.isEven=function(){return 0==(1&this.words[0])},h.prototype.isOdd=function(){return 1==(1&this.words[0])},h.prototype.andln=function(t){return this.words[0]&t},h.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,n=(t-i)/26,h=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},h.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},h.prototype.cmpn=function(t){var i,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)i=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var h=0|this.words[0];i=h===t?0:ht.length)return 1;if(this.length=0;r--){var n=0|this.words[r],h=0|t.words[r];if(n!==h){nh&&(i=1);break}}return i},h.prototype.gtn=function(t){return 1===this.cmpn(t)},h.prototype.gt=function(t){return 1===this.cmp(t)},h.prototype.gten=function(t){return this.cmpn(t)>=0},h.prototype.gte=function(t){return this.cmp(t)>=0},h.prototype.ltn=function(t){return-1===this.cmpn(t)},h.prototype.lt=function(t){return-1===this.cmp(t)},h.prototype.lten=function(t){return this.cmpn(t)<=0},h.prototype.lte=function(t){return this.cmp(t)<=0},h.prototype.eqn=function(t){return 0===this.cmpn(t)},h.prototype.eq=function(t){return 0===this.cmp(t)},h.red=function(t){return new A(t)},h.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},h.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},h.prototype._forceRed=function(t){return this.red=t,this},h.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},h.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},h.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},h.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},h.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},h.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},h.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},h.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},h.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},h.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},h.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},h.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},h.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},h.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var c={k256:null,p224:null,p192:null,p25519:null};function w(t,i){this.name=t,this.p=new h(i,16),this.n=this.p.bitLength(),this.k=new h(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var i=h._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new h(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var n=i0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,i){t.iushrn(this.n,0,i)},w.prototype.imulK=function(t){return t.imul(this.k)},n(y,w),y.prototype.split=function(t,i){for(var r=Math.min(t.length,9),n=0;n>>22,h=e}h>>>=22,t.words[n-10]=h,0===h&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=h,i=n}return 0!==i&&(t.words[t.length++]=i),t},h._prime=function(t){if(c[t])return c[t];var i;if("k256"===t)i=new y;else if("p224"===t)i=new b;else if("p192"===t)i=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new k}return c[t]=i,i},A.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},A.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},A.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var n=this.m.add(new h(1)).iushrn(2);return this.pow(t,n)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new h(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new h(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;n--){for(var a=i.words[n],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===n&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},A.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},A.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new S(t)},n(S,A),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},S.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),h=r.isub(n).iushrn(this.shift),e=h;return h.cmp(this.m)>=0?e=h.isub(this.m):h.cmpn(0)<0&&(e=h.iadd(this.m)),e._forceRed(this)},S.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new h(0)._forceRed(this);var r=t.mul(i),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(n).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":55}],54:[function(require,module,exports){ +},{"buffer":60}],59:[function(require,module,exports){ var r;function Rand(t){this.rand=t}if(module.exports=function(t){return r||(r=new Rand(null)),r.generate(t)},module.exports.Rand=Rand,Rand.prototype.generate=function(t){return this._rand(t)},Rand.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var r=new Uint8Array(t),e=0;e>>24]^f[_>>>16&255]^a[I>>>8&255]^s[255&l]^e[X++],B=u[_>>>24]^f[I>>>16&255]^a[l>>>8&255]^s[255&y]^e[X++],c=u[I>>>24]^f[l>>>16&255]^a[y>>>8&255]^s[255&_]^e[X++],i=u[l>>>24]^f[y>>>16&255]^a[_>>>8&255]^s[255&I]^e[X++],y=S,_=B,I=c,l=i;return S=(n[y>>>24]<<24|n[_>>>16&255]<<16|n[I>>>8&255]<<8|n[255&l])^e[X++],B=(n[_>>>24]<<24|n[I>>>16&255]<<16|n[l>>>8&255]<<8|n[255&y])^e[X++],c=(n[I>>>24]<<24|n[l>>>16&255]<<16|n[y>>>8&255]<<8|n[255&_])^e[X++],i=(n[l>>>24]<<24|n[y>>>16&255]<<16|n[_>>>8&255]<<8|n[255&I])^e[X++],[S>>>=0,B>>>=0,c>>>=0,i>>>=0]}var RCON=[0,1,2,4,8,16,32,64,128,27,54],G=function(){for(var r=new Array(256),e=0;e<256;e++)r[e]=e<128?e<<1:e<<1^283;for(var t=[],n=[],o=[[],[],[],[]],S=[[],[],[],[]],B=0,c=0,i=0;i<256;++i){var u=c^c<<1^c<<2^c<<3^c<<4;u=u>>>8^255&u^99,t[B]=u,n[u]=B;var f=r[B],a=r[f],s=r[a],y=257*r[u]^16843008*u;o[0][B]=y<<24|y>>>8,o[1][B]=y<<16|y>>>16,o[2][B]=y<<8|y>>>24,o[3][B]=y,y=16843009*s^65537*a^257*f^16843008*B,S[0][u]=y<<24|y>>>8,S[1][u]=y<<16|y>>>16,S[2][u]=y<<8|y>>>24,S[3][u]=y,0===B?B=c=1:(B=f^r[r[r[s^f]]],c^=r[r[c]])}return{SBOX:t,INV_SBOX:n,SUB_MIX:o,INV_SUB_MIX:S}}();function AES(r){this._key=asUInt32Array(r),this._reset()}AES.blockSize=16,AES.keySize=32,AES.prototype.blockSize=AES.blockSize,AES.prototype.keySize=AES.keySize,AES.prototype._reset=function(){for(var r=this._key,e=r.length,t=e+6,n=4*(t+1),o=[],S=0;S>>24,B=G.SBOX[B>>>24]<<24|G.SBOX[B>>>16&255]<<16|G.SBOX[B>>>8&255]<<8|G.SBOX[255&B],B^=RCON[S/e|0]<<24):e>6&&S%e==4&&(B=G.SBOX[B>>>24]<<24|G.SBOX[B>>>16&255]<<16|G.SBOX[B>>>8&255]<<8|G.SBOX[255&B]),o[S]=o[S-e]^B}for(var c=[],i=0;i>>24]]^G.INV_SUB_MIX[1][G.SBOX[f>>>16&255]]^G.INV_SUB_MIX[2][G.SBOX[f>>>8&255]]^G.INV_SUB_MIX[3][G.SBOX[255&f]]}this._nRounds=t,this._keySchedule=o,this._invKeySchedule=c},AES.prototype.encryptBlockRaw=function(r){return cryptBlock(r=asUInt32Array(r),this._keySchedule,G.SUB_MIX,G.SBOX,this._nRounds)},AES.prototype.encryptBlock=function(r){var e=this.encryptBlockRaw(r),t=Buffer.allocUnsafe(16);return t.writeUInt32BE(e[0],0),t.writeUInt32BE(e[1],4),t.writeUInt32BE(e[2],8),t.writeUInt32BE(e[3],12),t},AES.prototype.decryptBlock=function(r){var e=(r=asUInt32Array(r))[1];r[1]=r[3],r[3]=e;var t=cryptBlock(r,this._invKeySchedule,G.INV_SUB_MIX,G.INV_SBOX,this._nRounds),n=Buffer.allocUnsafe(16);return n.writeUInt32BE(t[0],0),n.writeUInt32BE(t[3],4),n.writeUInt32BE(t[2],8),n.writeUInt32BE(t[1],12),n},AES.prototype.scrub=function(){scrubVec(this._keySchedule),scrubVec(this._invKeySchedule),scrubVec(this._key)},module.exports.AES=AES; -},{"safe-buffer":629}],57:[function(require,module,exports){ +},{"safe-buffer":638}],62:[function(require,module,exports){ var aes=require("./aes"),Buffer=require("safe-buffer").Buffer,Transform=require("cipher-base"),inherits=require("inherits"),GHASH=require("./ghash"),xor=require("buffer-xor"),incr32=require("./incr32");function xorTest(t,e){var r=0;t.length!==e.length&&r++;for(var a=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");for(var t=-1;++t16)return r=this.cache.slice(0,16),this.cache=this.cache.slice(16),r}else if(this.cache.length>=16)return r=this.cache.slice(0,16),this.cache=this.cache.slice(16),r;return null},Splitter.prototype.flush=function(){if(this.cache.length)return this.cache},exports.createDecipher=createDecipher,exports.createDecipheriv=createDecipheriv; -},{"./aes":56,"./authCipher":57,"./modes":69,"./streamCipher":72,"cipher-base":109,"evp_bytestokey":187,"inherits":258,"safe-buffer":629}],60:[function(require,module,exports){ +},{"./aes":61,"./authCipher":62,"./modes":74,"./streamCipher":77,"cipher-base":114,"evp_bytestokey":193,"inherits":264,"safe-buffer":638}],65:[function(require,module,exports){ var MODES=require("./modes"),AuthCipher=require("./authCipher"),Buffer=require("safe-buffer").Buffer,StreamCipher=require("./streamCipher"),Transform=require("cipher-base"),aes=require("./aes"),ebtk=require("evp_bytestokey"),inherits=require("inherits");function Cipher(e,r,t){Transform.call(this),this._cache=new Splitter,this._cipher=new aes.AES(r),this._prev=Buffer.from(t),this._mode=e,this._autopadding=!0}inherits(Cipher,Transform),Cipher.prototype._update=function(e){var r,t;this._cache.add(e);for(var i=[];r=this._cache.get();)t=this._mode.encrypt(this,r),i.push(t);return Buffer.concat(i)};var PADDING=Buffer.alloc(16,16);function Splitter(){this.cache=Buffer.allocUnsafe(0)}function createCipheriv(e,r,t){var i=MODES[e.toLowerCase()];if(!i)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=Buffer.from(r)),r.length!==i.key/8)throw new TypeError("invalid key length "+r.length);if("string"==typeof t&&(t=Buffer.from(t)),"GCM"!==i.mode&&t.length!==i.iv)throw new TypeError("invalid iv length "+t.length);return"stream"===i.type?new StreamCipher(i.module,r,t):"auth"===i.type?new AuthCipher(i.module,r,t):new Cipher(i.module,r,t)}function createCipher(e,r){var t=MODES[e.toLowerCase()];if(!t)throw new TypeError("invalid suite type");var i=ebtk(r,!1,t.key,t.iv);return createCipheriv(e,i.key,i.iv)}Cipher.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(PADDING))throw this._cipher.scrub(),new Error("data not multiple of block length")},Cipher.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},Splitter.prototype.add=function(e){this.cache=Buffer.concat([this.cache,e])},Splitter.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},Splitter.prototype.flush=function(){for(var e=16-this.cache.length,r=Buffer.allocUnsafe(e),t=-1;++t>>0,0),r.writeUInt32BE(t[1]>>>0,4),r.writeUInt32BE(t[2]>>>0,8),r.writeUInt32BE(t[3]>>>0,12),r}function GHASH(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}GHASH.prototype.ghash=function(t){for(var r=-1;++r0;t--)e[t]=e[t]>>>1|(1&e[t-1])<<31;e[0]=e[0]>>>1,r&&(e[0]=e[0]^225<<24)}this.state=fromArray(a)},GHASH.prototype.update=function(t){var r;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)r=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(r)},GHASH.prototype.final=function(t,r){return this.cache.length&&this.ghash(Buffer.concat([this.cache,ZEROES],16)),this.ghash(fromArray([0,t,0,r])),this.state},module.exports=GHASH; -},{"safe-buffer":629}],62:[function(require,module,exports){ +},{"safe-buffer":638}],67:[function(require,module,exports){ function incr32(r){for(var n,t=r.length;t--;){if(255!==(n=r.readUInt8(t))){n++,r.writeUInt8(n,t);break}r.writeUInt8(0,t)}}module.exports=incr32; -},{}],63:[function(require,module,exports){ +},{}],68:[function(require,module,exports){ var xor=require("buffer-xor");exports.encrypt=function(r,e){var p=xor(e,r._prev);return r._prev=r._cipher.encryptBlock(p),r._prev},exports.decrypt=function(r,e){var p=r._prev;r._prev=e;var c=r._cipher.decryptBlock(e);return xor(c,p)}; -},{"buffer-xor":104}],64:[function(require,module,exports){ +},{"buffer-xor":109}],69:[function(require,module,exports){ var Buffer=require("safe-buffer").Buffer,xor=require("buffer-xor");function encryptStart(e,r,c){var f=r.length,t=xor(r,e._cache);return e._cache=e._cache.slice(f),e._prev=Buffer.concat([e._prev,c?r:t]),t}exports.encrypt=function(e,r,c){for(var f,t=Buffer.allocUnsafe(0);r.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=Buffer.allocUnsafe(0)),!(e._cache.length<=r.length)){t=Buffer.concat([t,encryptStart(e,r,c)]);break}f=e._cache.length,t=Buffer.concat([t,encryptStart(e,r.slice(0,f),c)]),r=r.slice(f)}return t}; -},{"buffer-xor":104,"safe-buffer":629}],65:[function(require,module,exports){ +},{"buffer-xor":109,"safe-buffer":638}],70:[function(require,module,exports){ var Buffer=require("safe-buffer").Buffer;function encryptByte(r,e,f){for(var n,t,u=-1,c=0;++u<8;)n=e&1<<7-u?128:0,c+=(128&(t=r._cipher.encryptBlock(r._prev)[0]^n))>>u%8,r._prev=shiftIn(r._prev,f?n:t);return c}function shiftIn(r,e){var f=r.length,n=-1,t=Buffer.allocUnsafe(r.length);for(r=Buffer.concat([r,Buffer.from([e])]);++n>7;return t}exports.encrypt=function(r,e,f){for(var n=e.length,t=Buffer.allocUnsafe(n),u=-1;++u=0||!r.umod(e.prime1)||!r.umod(e.prime2));return r}function crt(e,r){var o=blind(r),n=r.modulus.byteLength(),u=new BN(e).mul(o.blinder).umod(r.modulus),d=u.toRed(BN.mont(r.prime1)),m=u.toRed(BN.mont(r.prime2)),t=r.coefficient,i=r.prime1,l=r.prime2,b=d.redPow(r.exponent1).fromRed(),s=m.redPow(r.exponent2).fromRed(),p=b.isub(s).imul(t).umod(i).imul(l);return s.iadd(p).imul(o.unblinder).umod(r.modulus).toArrayLike(Buffer,"be",n)}crt.getr=getr,module.exports=crt; }).call(this)}).call(this,require("buffer").Buffer) -},{"bn.js":53,"buffer":99,"randombytes":608}],77:[function(require,module,exports){ +},{"bn.js":58,"buffer":104,"randombytes":616}],82:[function(require,module,exports){ module.exports=require("./browser/algorithms.json"); -},{"./browser/algorithms.json":78}],78:[function(require,module,exports){ +},{"./browser/algorithms.json":83}],83:[function(require,module,exports){ module.exports={ "sha224WithRSAEncryption": { "sign": "rsa", @@ -604,7 +627,7 @@ module.exports={ } } -},{}],79:[function(require,module,exports){ +},{}],84:[function(require,module,exports){ module.exports={ "1.3.132.0.10": "secp256k1", "1.3.132.0.33": "p224", @@ -614,238 +637,238 @@ module.exports={ "1.3.132.0.35": "p521" } -},{}],80:[function(require,module,exports){ +},{}],85:[function(require,module,exports){ var Buffer=require("safe-buffer").Buffer,createHash=require("create-hash"),stream=require("readable-stream"),inherits=require("inherits"),sign=require("./sign"),verify=require("./verify"),algorithms=require("./algorithms.json");function Sign(e){stream.Writable.call(this);var t=algorithms[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=createHash(t.hash),this._tag=t.id,this._signType=t.sign}function Verify(e){stream.Writable.call(this);var t=algorithms[e];if(!t)throw new Error("Unknown message digest");this._hash=createHash(t.hash),this._tag=t.id,this._signType=t.sign}function createSign(e){return new Sign(e)}function createVerify(e){return new Verify(e)}Object.keys(algorithms).forEach(function(e){algorithms[e].id=Buffer.from(algorithms[e].id,"hex"),algorithms[e.toLowerCase()]=algorithms[e]}),inherits(Sign,stream.Writable),Sign.prototype._write=function(e,t,r){this._hash.update(e),r()},Sign.prototype.update=function(e,t){return"string"==typeof e&&(e=Buffer.from(e,t)),this._hash.update(e),this},Sign.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),i=sign(r,e,this._hashType,this._signType,this._tag);return t?i.toString(t):i},inherits(Verify,stream.Writable),Verify.prototype._write=function(e,t,r){this._hash.update(e),r()},Verify.prototype.update=function(e,t){return"string"==typeof e&&(e=Buffer.from(e,t)),this._hash.update(e),this},Verify.prototype.verify=function(e,t,r){"string"==typeof t&&(t=Buffer.from(t,r)),this.end();var i=this._hash.digest();return verify(t,i,e,this._signType,this._tag)},module.exports={Sign:createSign,Verify:createVerify,createSign:createSign,createVerify:createVerify}; -},{"./algorithms.json":78,"./sign":81,"./verify":82,"create-hash":118,"inherits":258,"readable-stream":97,"safe-buffer":629}],81:[function(require,module,exports){ +},{"./algorithms.json":83,"./sign":86,"./verify":87,"create-hash":123,"inherits":264,"readable-stream":102,"safe-buffer":638}],86:[function(require,module,exports){ var Buffer=require("safe-buffer").Buffer,createHmac=require("create-hmac"),crt=require("browserify-rsa"),EC=require("elliptic").ec,BN=require("bn.js"),parseKeys=require("parse-asn1"),curves=require("./curves.json");function sign(e,r,t,a,n){var u=parseKeys(r);if(u.curve){if("ecdsa"!==a&&"ecdsa/rsa"!==a)throw new Error("wrong private key type");return ecSign(e,u)}if("dsa"===u.type){if("dsa"!==a)throw new Error("wrong private key type");return dsaSign(e,u,t)}if("rsa"!==a&&"ecdsa/rsa"!==a)throw new Error("wrong private key type");e=Buffer.concat([n,e]);for(var o=u.modulus.byteLength(),f=[0,1];e.length+f.length+10&&t.ishrn(a),t}function bits2octets(e,r){e=(e=bits2int(e,r)).mod(r);var t=Buffer.from(e.toArray());if(t.length=r)throw new Error("invalid sig")}module.exports=verify; -},{"./curves.json":79,"bn.js":53,"elliptic":152,"parse-asn1":423,"safe-buffer":629}],83:[function(require,module,exports){ +},{"./curves.json":84,"bn.js":58,"elliptic":158,"parse-asn1":429,"safe-buffer":638}],88:[function(require,module,exports){ "use strict";function _inheritsLoose(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}var codes={};function createErrorType(e,r,t){t||(t=Error);var n=function(e){function t(t,n,o){return e.call(this,function(e,t,n){return"string"==typeof r?r:r(e,t,n)}(t,n,o))||this}return _inheritsLoose(t,e),t}(t);n.prototype.name=t.name,n.prototype.code=e,codes[e]=n}function oneOf(e,r){if(Array.isArray(e)){var t=e.length;return e=e.map(function(e){return String(e)}),t>2?"one of ".concat(r," ").concat(e.slice(0,t-1).join(", "),", or ")+e[t-1]:2===t?"one of ".concat(r," ").concat(e[0]," or ").concat(e[1]):"of ".concat(r," ").concat(e[0])}return"of ".concat(r," ").concat(String(e))}function startsWith(e,r,t){return e.substr(!t||t<0?0:+t,r.length)===r}function endsWith(e,r,t){return(void 0===t||t>e.length)&&(t=e.length),e.substring(t-r.length,t)===r}function includes(e,r,t){return"number"!=typeof t&&(t=0),!(t+r.length>e.length)&&-1!==e.indexOf(r,t)}createErrorType("ERR_INVALID_OPT_VALUE",function(e,r){return'The value "'+r+'" is invalid for option "'+e+'"'},TypeError),createErrorType("ERR_INVALID_ARG_TYPE",function(e,r,t){var n,o;if("string"==typeof r&&startsWith(r,"not ")?(n="must not be",r=r.replace(/^not /,"")):n="must be",endsWith(e," argument"))o="The ".concat(e," ").concat(n," ").concat(oneOf(r,"type"));else{var c=includes(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(oneOf(r,"type"))}return o+=". Received type ".concat(typeof t)},TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),module.exports.codes=codes; -},{}],84:[function(require,module,exports){ +},{}],89:[function(require,module,exports){ (function (process){(function (){ "use strict";var objectKeys=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};module.exports=Duplex;var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");require("inherits")(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v0)if("string"==typeof t||d.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=_uint8ArrayToBuffer(t)),a)d.endEmitted?errorOrDestroy(e,new ERR_STREAM_UNSHIFT_AFTER_END_EVENT):addChunk(e,d,t,!0);else if(d.ended)errorOrDestroy(e,new ERR_STREAM_PUSH_AFTER_EOF);else{if(d.destroyed)return!1;d.reading=!1,d.decoder&&!r?(t=d.decoder.write(t),d.objectMode||0!==t.length?addChunk(e,d,t,!1):maybeReadMore(e,d)):addChunk(e,d,t,!1)}else a||(d.reading=!1,maybeReadMore(e,d));return!d.ended&&(d.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function onEofChunk(e,t){if(debug("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?emitReadable(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,emitReadable_(e)))}}function emitReadable(e){var t=e._readableState;debug("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(emitReadable_,e))}function emitReadable_(e){var t=e._readableState;debug("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function nReadingNextTick(e){debug("readable nexttick read 0"),e.read(0)}function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(resume_,e,t))}function resume_(e,t){debug("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}function flow(e){var t=e._readableState;for(debug("flow",t.flowing);t.flowing&&null!==e.read(););}function fromList(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function endReadable(e){var t=e._readableState;debug("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(endReadableNT,t,e))}function endReadableNT(e,t){if(debug("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function indexOf(e,t){for(var r=0,a=e.length;r=t.highWaterMark:t.length>0)||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var a,n=t.needReadable;return debug("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&endReadable(this)),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){errorOrDestroy(this,new ERR_METHOD_NOT_IMPLEMENTED("_read()"))},Readable.prototype.pipe=function(e,t){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e)}a.pipesCount+=1,debug("pipe count=%d opts=%j",a.pipesCount,t);var n=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?d:f;function i(t,n){debug("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,debug("cleanup"),e.removeListener("close",b),e.removeListener("finish",p),e.removeListener("drain",o),e.removeListener("error",u),e.removeListener("unpipe",i),r.removeListener("end",d),r.removeListener("end",f),r.removeListener("data",l),s=!0,!a.awaitDrain||e._writableState&&!e._writableState.needDrain||o())}function d(){debug("onend"),e.end()}a.endEmitted?process.nextTick(n):r.once("end",n),e.on("unpipe",i);var o=pipeOnDrain(r);e.on("drain",o);var s=!1;function l(t){debug("ondata");var n=e.write(t);debug("dest.write",n),!1===n&&((1===a.pipesCount&&a.pipes===e||a.pipesCount>1&&-1!==indexOf(a.pipes,e))&&!s&&(debug("false write response, pause",a.awaitDrain),a.awaitDrain++),r.pause())}function u(t){debug("onerror",t),f(),e.removeListener("error",u),0===EElistenerCount(e,"error")&&errorOrDestroy(e,t)}function b(){e.removeListener("finish",p),f()}function p(){debug("onfinish"),e.removeListener("close",b),f()}function f(){debug("unpipe"),r.unpipe(e)}return r.on("data",l),prependListener(e,"error",u),e.once("close",b),e.once("finish",p),e.emit("pipe",r),a.flowing||(debug("pipe resume"),r.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var a=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i0,!1!==a.flowing&&this.resume()):"readable"===e&&(a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.flowing=!1,a.emittedReadable=!1,debug("on readable",a.length,a.reading),a.length?emitReadable(this):a.reading||process.nextTick(nReadingNextTick,this))),r},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.removeListener=function(e,t){var r=Stream.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(updateReadableListening,this),r},Readable.prototype.removeAllListeners=function(e){var t=Stream.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(updateReadableListening,this),t},Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(debug("resume"),e.flowing=!e.readableListening,resume(this,e)),e.paused=!1,this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Readable.prototype.wrap=function(e){var t=this,r=this._readableState,a=!1;for(var n in e.on("end",function(){if(debug("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){(debug("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(a=!0,e.pause()))}),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var i=0;i-1))throw new ERR_UNKNOWN_ENCODING(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Writable.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Writable.prototype._write=function(e,t,r){r(new ERR_METHOD_NOT_IMPLEMENTED("_write()"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||endWritable(this,i,r),this},Object.defineProperty(Writable.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(Writable.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(e,t){t(e)}; }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../errors":83,"./_stream_duplex":84,"./internal/streams/destroy":91,"./internal/streams/state":95,"./internal/streams/stream":96,"_process":443,"buffer":99,"inherits":258,"util-deprecate":844}],89:[function(require,module,exports){ +},{"../errors":88,"./_stream_duplex":89,"./internal/streams/destroy":96,"./internal/streams/state":100,"./internal/streams/stream":101,"_process":449,"buffer":104,"inherits":264,"util-deprecate":869}],94:[function(require,module,exports){ (function (process){(function (){ "use strict";var _Object$setPrototypeO;function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var finished=require("./end-of-stream"),kLastResolve=Symbol("lastResolve"),kLastReject=Symbol("lastReject"),kError=Symbol("error"),kEnded=Symbol("ended"),kLastPromise=Symbol("lastPromise"),kHandlePromise=Symbol("handlePromise"),kStream=Symbol("stream");function createIterResult(e,t){return{value:e,done:t}}function readAndResolve(e){var t=e[kLastResolve];if(null!==t){var r=e[kStream].read();null!==r&&(e[kLastPromise]=null,e[kLastResolve]=null,e[kLastReject]=null,t(createIterResult(r,!1)))}}function onReadable(e){process.nextTick(readAndResolve,e)}function wrapForNext(e,t){return function(r,o){e.then(function(){t[kEnded]?r(createIterResult(void 0,!0)):t[kHandlePromise](r,o)},o)}}var AsyncIteratorPrototype=Object.getPrototypeOf(function(){}),ReadableStreamAsyncIteratorPrototype=Object.setPrototypeOf((_defineProperty(_Object$setPrototypeO={get stream(){return this[kStream]},next:function(){var e=this,t=this[kError];if(null!==t)return Promise.reject(t);if(this[kEnded])return Promise.resolve(createIterResult(void 0,!0));if(this[kStream].destroyed)return new Promise(function(t,r){process.nextTick(function(){e[kError]?r(e[kError]):t(createIterResult(void 0,!0))})});var r,o=this[kLastPromise];if(o)r=new Promise(wrapForNext(o,this));else{var n=this[kStream].read();if(null!==n)return Promise.resolve(createIterResult(n,!1));r=new Promise(this[kHandlePromise])}return this[kLastPromise]=r,r}},Symbol.asyncIterator,function(){return this}),_defineProperty(_Object$setPrototypeO,"return",function(){var e=this;return new Promise(function(t,r){e[kStream].destroy(null,function(e){e?r(e):t(createIterResult(void 0,!0))})})}),_Object$setPrototypeO),AsyncIteratorPrototype),createReadableStreamAsyncIterator=function(e){var t,r=Object.create(ReadableStreamAsyncIteratorPrototype,(_defineProperty(t={},kStream,{value:e,writable:!0}),_defineProperty(t,kLastResolve,{value:null,writable:!0}),_defineProperty(t,kLastReject,{value:null,writable:!0}),_defineProperty(t,kError,{value:null,writable:!0}),_defineProperty(t,kEnded,{value:e._readableState.endEmitted,writable:!0}),_defineProperty(t,kHandlePromise,{value:function(e,t){var o=r[kStream].read();o?(r[kLastPromise]=null,r[kLastResolve]=null,r[kLastReject]=null,e(createIterResult(o,!1))):(r[kLastResolve]=e,r[kLastReject]=t)},writable:!0}),t));return r[kLastPromise]=null,finished(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[kLastReject];return null!==t&&(r[kLastPromise]=null,r[kLastResolve]=null,r[kLastReject]=null,t(e)),void(r[kError]=e)}var o=r[kLastResolve];null!==o&&(r[kLastPromise]=null,r[kLastResolve]=null,r[kLastReject]=null,o(createIterResult(void 0,!0))),r[kEnded]=!0}),e.on("readable",onReadable.bind(null,r)),r};module.exports=createReadableStreamAsyncIterator; }).call(this)}).call(this,require('_process')) -},{"./end-of-stream":92,"_process":443}],90:[function(require,module,exports){ +},{"./end-of-stream":97,"_process":449}],95:[function(require,module,exports){ "use strict";function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return Buffer.alloc(0);for(var t=Buffer.allocUnsafe(e>>>0),n=this.head,r=0;n;)copyBuffer(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return ea.length?a.length:e;if(i===a.length?r+=a:r+=a.slice(0,e),0===(e-=i)){i===a.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=a.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=Buffer.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var a=n.data,i=e>a.length?a.length:e;if(a.copy(t,t.length-e,0,i),0===(e-=i)){i===a.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=a.slice(i));break}++r}return this.length-=r,t}},{key:custom,value:function(e,t){return inspect(this,_objectSpread({},t,{depth:0,customInspect:!1}))}}]),e}(); -},{"buffer":99,"util":55}],91:[function(require,module,exports){ +},{"buffer":104,"util":60}],96:[function(require,module,exports){ (function (process){(function (){ "use strict";function destroy(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(emitErrorNT,this,t)):process.nextTick(emitErrorNT,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?process.nextTick(emitCloseNT,r):(r._writableState.errorEmitted=!0,process.nextTick(emitErrorAndCloseNT,r,t)):process.nextTick(emitErrorAndCloseNT,r,t):e?(process.nextTick(emitCloseNT,r),e(t)):process.nextTick(emitCloseNT,r)}),this)}function emitErrorAndCloseNT(t,e){emitErrorNT(t,e),emitCloseNT(t)}function emitCloseNT(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function undestroy(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function emitErrorNT(t,e){t.emit("error",e)}function errorOrDestroy(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}module.exports={destroy:destroy,undestroy:undestroy,errorOrDestroy:errorOrDestroy}; }).call(this)}).call(this,require('_process')) -},{"_process":443}],92:[function(require,module,exports){ +},{"_process":449}],97:[function(require,module,exports){ "use strict";var ERR_STREAM_PREMATURE_CLOSE=require("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function once(e){var r=!1;return function(){if(!r){r=!0;for(var t=arguments.length,n=new Array(t),o=0;o0,function(e){o||(o=e),e&&i.forEach(call),u||(i.forEach(call),t(o))})});return r.reduce(pipe)}module.exports=pipeline; -},{"../../../errors":83,"./end-of-stream":92}],95:[function(require,module,exports){ +},{"../../../errors":88,"./end-of-stream":97}],100:[function(require,module,exports){ "use strict";var ERR_INVALID_OPT_VALUE=require("../../../errors").codes.ERR_INVALID_OPT_VALUE;function highWaterMarkFrom(r,e,t){return null!=r.highWaterMark?r.highWaterMark:e?r[t]:null}function getHighWaterMark(r,e,t,a){var i=highWaterMarkFrom(e,a,t);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new ERR_INVALID_OPT_VALUE(a?t:"highWaterMark",i);return Math.floor(i)}return r.objectMode?16:16384}module.exports={getHighWaterMark:getHighWaterMark}; -},{"../../../errors":83}],96:[function(require,module,exports){ +},{"../../../errors":88}],101:[function(require,module,exports){ module.exports=require("events").EventEmitter; -},{"events":186}],97:[function(require,module,exports){ +},{"events":192}],102:[function(require,module,exports){ exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),exports.finished=require("./lib/internal/streams/end-of-stream.js"),exports.pipeline=require("./lib/internal/streams/pipeline.js"); -},{"./lib/_stream_duplex.js":84,"./lib/_stream_passthrough.js":85,"./lib/_stream_readable.js":86,"./lib/_stream_transform.js":87,"./lib/_stream_writable.js":88,"./lib/internal/streams/end-of-stream.js":92,"./lib/internal/streams/pipeline.js":94}],98:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":89,"./lib/_stream_passthrough.js":90,"./lib/_stream_readable.js":91,"./lib/_stream_transform.js":92,"./lib/_stream_writable.js":93,"./lib/internal/streams/end-of-stream.js":97,"./lib/internal/streams/pipeline.js":99}],103:[function(require,module,exports){ -},{}],99:[function(require,module,exports){ +},{}],104:[function(require,module,exports){ (function (Buffer){(function (){ "use strict";var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;function typedArraySupport(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>K_MAX_LENGTH)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return fromString(e,t);if(ArrayBuffer.isView(e))return fromArrayLike(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return Buffer.from(n,t,r);var f=fromObject(e);if(f)return f;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);return f!==r&&(n=n.slice(0,f)),n}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var f=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(f)return n?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),f=!0}}function slowToString(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){var i,o=1,u=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,s/=2,r/=2}function a(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(f){var h=-1;for(i=r;iu&&(r=u-s),i=r;i>=0;i--){for(var c=!0,l=0;lf&&(n=f):n=f;var i=t.length;n>i/2&&(n=i/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(f+c<=r)switch(c){case 1:a<128&&(h=a);break;case 2:128==(192&(i=e[f+1]))&&(s=(31&a)<<6|63&i)>127&&(h=s);break;case 3:i=e[f+1],o=e[f+2],128==(192&i)&&128==(192&o)&&(s=(15&a)<<12|(63&i)<<6|63&o)>2047&&(s<55296||s>57343)&&(h=s);break;case 4:i=e[f+1],o=e[f+2],u=e[f+3],128==(192&i)&&128==(192&o)&&128==(192&u)&&(s=(15&a)<<18|(63&i)<<12|(63&o)<<6|63&u)>65535&&s<1114112&&(h=s)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),f+=c}return decodeCodePointsArray(n)}exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,f=0,i=Math.min(r,n);ft&&(e+=" ... "),""},Buffer.prototype.compare=function(e,t,r,n,f){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(f>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),u=Math.min(i,o),s=this.slice(n,f),a=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var f="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i=(f*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return i>=(f*=128)&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return f},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var f=e.charCodeAt(0);("utf8"===n&&f<128||"latin1"===n)&&(e=f)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(e){for(var t=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(e){return base64.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var f=0;f=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e} }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":49,"buffer":99,"ieee754":250}],100:[function(require,module,exports){ +},{"base64-js":49,"buffer":104,"ieee754":256}],105:[function(require,module,exports){ (function (Buffer){(function (){ function allocUnsafe(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');return Buffer.allocUnsafe?Buffer.allocUnsafe(e):new Buffer(e)}module.exports=allocUnsafe; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99}],101:[function(require,module,exports){ +},{"buffer":104}],106:[function(require,module,exports){ (function (Buffer){(function (){ var bufferFill=require("buffer-fill"),allocUnsafe=require("buffer-alloc-unsafe");module.exports=function(e,r,f){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');if(Buffer.alloc)return Buffer.alloc(e,r,f);var u=allocUnsafe(e);return 0===e?u:void 0===r?bufferFill(u,0):("string"!=typeof f&&(f=void 0),bufferFill(u,r,f))}; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99,"buffer-alloc-unsafe":100,"buffer-fill":102}],102:[function(require,module,exports){ +},{"buffer":104,"buffer-alloc-unsafe":105,"buffer-fill":107}],107:[function(require,module,exports){ (function (Buffer){(function (){ var hasFullSupport=function(){try{if(!Buffer.isEncoding("latin1"))return!1;var r=Buffer.alloc?Buffer.alloc(4):new Buffer(4);return r.fill("ab","ucs2"),"61006200"===r.toString("hex")}catch(r){return!1}}();function isSingleByte(r){return 1===r.length&&r.charCodeAt(0)<256}function fillWithNumber(r,e,n,t){if(n<0||t>r.length)throw new RangeError("Out of range index");return n>>>=0,(t=void 0===t?r.length:t>>>0)>n&&r.fill(e,n,t),r}function fillWithBuffer(r,e,n,t){if(n<0||t>r.length)throw new RangeError("Out of range index");if(t<=n)return r;n>>>=0,t=void 0===t?r.length:t>>>0;for(var i=n,f=e.length;i<=t-f;)e.copy(r,i),i+=f;return i!==t&&e.copy(r,i,0,t-i),r}function fill(r,e,n,t,i){if(hasFullSupport)return r.fill(e,n,t,i);if("number"==typeof e)return fillWithNumber(r,e,n,t);if("string"==typeof e){if("string"==typeof n?(i=n,n=0,t=r.length):"string"==typeof t&&(i=t,t=r.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("latin1"===i&&(i="binary"),"string"==typeof i&&!Buffer.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(""===e)return fillWithNumber(r,0,n,t);if(isSingleByte(e))return fillWithNumber(r,e.charCodeAt(0),n,t);e=new Buffer(e,i)}return Buffer.isBuffer(e)?fillWithBuffer(r,e,n,t):fillWithNumber(r,0,n,t)}module.exports=fill; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99}],103:[function(require,module,exports){ +},{"buffer":104}],108:[function(require,module,exports){ (function (Buffer){(function (){ var toString=Object.prototype.toString,isModern="function"==typeof Buffer.alloc&&"function"==typeof Buffer.allocUnsafe&&"function"==typeof Buffer.from;function isArrayBuffer(r){return"ArrayBuffer"===toString.call(r).slice(8,-1)}function fromArrayBuffer(r,f,e){f>>>=0;var n=r.byteLength-f;if(n<0)throw new RangeError("'offset' is out of bounds");if(void 0===e)e=n;else if((e>>>=0)>n)throw new RangeError("'length' is out of bounds");return isModern?Buffer.from(r.slice(f,f+e)):new Buffer(new Uint8Array(r.slice(f,f+e)))}function fromString(r,f){if("string"==typeof f&&""!==f||(f="utf8"),!Buffer.isEncoding(f))throw new TypeError('"encoding" must be a valid string encoding');return isModern?Buffer.from(r,f):new Buffer(r,f)}function bufferFrom(r,f,e){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return isArrayBuffer(r)?fromArrayBuffer(r,f,e):"string"==typeof r?fromString(r,f):isModern?Buffer.from(r):new Buffer(r)}module.exports=bufferFrom; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99}],104:[function(require,module,exports){ +},{"buffer":104}],109:[function(require,module,exports){ (function (Buffer){(function (){ module.exports=function(e,n){for(var r=Math.min(e.length,n.length),t=new Buffer(r),f=0;f-1?callBind(t):t}; -},{"./":107,"get-intrinsic":203}],107:[function(require,module,exports){ +},{"./":112,"get-intrinsic":209}],112:[function(require,module,exports){ "use strict";var bind=require("function-bind"),GetIntrinsic=require("get-intrinsic"),$apply=GetIntrinsic("%Function.prototype.apply%"),$call=GetIntrinsic("%Function.prototype.call%"),$reflectApply=GetIntrinsic("%Reflect.apply%",!0)||bind.call($call,$apply),$gOPD=GetIntrinsic("%Object.getOwnPropertyDescriptor%",!0),$defineProperty=GetIntrinsic("%Object.defineProperty%",!0),$max=GetIntrinsic("%Math.max%");if($defineProperty)try{$defineProperty({},"a",{value:1})}catch(e){$defineProperty=null}module.exports=function(e){var t=$reflectApply(bind,$call,arguments);$gOPD&&$defineProperty&&($gOPD(t,"length").configurable&&$defineProperty(t,"length",{value:1+$max(0,e.length-(arguments.length-1))}));return t};var applyBind=function(){return $reflectApply(bind,$apply,arguments)};$defineProperty?$defineProperty(module.exports,"apply",{value:applyBind}):module.exports.apply=applyBind; -},{"function-bind":201,"get-intrinsic":203}],108:[function(require,module,exports){ +},{"function-bind":207,"get-intrinsic":209}],113:[function(require,module,exports){ module.exports=require("sodium-browserify"); -},{"sodium-browserify":699}],109:[function(require,module,exports){ +},{"sodium-browserify":712}],114:[function(require,module,exports){ var Buffer=require("safe-buffer").Buffer,Transform=require("stream").Transform,StringDecoder=require("string_decoder").StringDecoder,inherits=require("inherits");function CipherBase(t){Transform.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}inherits(CipherBase,Transform),CipherBase.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},CipherBase.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},CipherBase.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},CipherBase.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){i=t}finally{r(i)}},CipherBase.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},CipherBase.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},CipherBase.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new StringDecoder(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i},module.exports=CipherBase; -},{"inherits":258,"safe-buffer":629,"stream":792,"string_decoder":829}],110:[function(require,module,exports){ +},{"inherits":264,"safe-buffer":638,"stream":814,"string_decoder":851}],115:[function(require,module,exports){ (function (Buffer){(function (){ function isArray(r){return Array.isArray?Array.isArray(r):"[object Array]"===objectToString(r)}function isBoolean(r){return"boolean"==typeof r}function isNull(r){return null===r}function isNullOrUndefined(r){return null==r}function isNumber(r){return"number"==typeof r}function isString(r){return"string"==typeof r}function isSymbol(r){return"symbol"==typeof r}function isUndefined(r){return void 0===r}function isRegExp(r){return"[object RegExp]"===objectToString(r)}function isObject(r){return"object"==typeof r&&null!==r}function isDate(r){return"[object Date]"===objectToString(r)}function isError(r){return"[object Error]"===objectToString(r)||r instanceof Error}function isFunction(r){return"function"==typeof r}function isPrimitive(r){return null===r||"boolean"==typeof r||"number"==typeof r||"string"==typeof r||"symbol"==typeof r||void 0===r}function objectToString(r){return Object.prototype.toString.call(r)}exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=Buffer.isBuffer; }).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":261}],111:[function(require,module,exports){ +},{"../../is-buffer/index.js":267}],116:[function(require,module,exports){ (function (process){(function (){ "use strict";function getUsage(e){var s;return e&&e._start?(s=Object.assign({},process.cpuUsage(e._start.cpuUsage))).time=Date.now()-e._start.time:(s=Object.assign({},process.cpuUsage())).time=1e3*process.uptime(),s.percent=(s.system+s.user)/(10*s.time),Object.defineProperty(s,"_start",{value:{cpuUsage:process.cpuUsage(),time:Date.now()}}),s}module.exports=getUsage; }).call(this)}).call(this,require('_process')) -},{"_process":443}],112:[function(require,module,exports){ +},{"_process":449}],117:[function(require,module,exports){ "use strict";module.exports=require("./es6/crc32").default; -},{"./es6/crc32":113}],113:[function(require,module,exports){ +},{"./es6/crc32":118}],118:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _buffer=require("buffer"),_create_buffer=require("./create_buffer"),_create_buffer2=_interopRequireDefault(_create_buffer),_define_crc=require("./define_crc"),_define_crc2=_interopRequireDefault(_define_crc);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var TABLE=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(TABLE=new Int32Array(TABLE));var crc32=(0,_define_crc2.default)("crc-32",function(e,r){_buffer.Buffer.isBuffer(e)||(e=(0,_create_buffer2.default)(e));for(var f=0===r?0:-1^~~r,u=0;u>>8}return-1^f});exports.default=crc32; -},{"./create_buffer":114,"./define_crc":115,"buffer":99}],114:[function(require,module,exports){ +},{"./create_buffer":119,"./define_crc":120,"buffer":104}],119:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _buffer=require("buffer"),createBuffer=_buffer.Buffer.from&&_buffer.Buffer.alloc&&_buffer.Buffer.allocUnsafe&&_buffer.Buffer.allocUnsafeSlow?_buffer.Buffer.from:function(f){return new _buffer.Buffer(f)};exports.default=createBuffer; -},{"buffer":99}],115:[function(require,module,exports){ +},{"buffer":104}],120:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e,t){var n=function(e,n){return t(e,n)>>>0};return n.signed=t,n.unsigned=n,n.model=e,n}; -},{}],116:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ (function (Buffer){(function (){ var elliptic=require("elliptic"),BN=require("bn.js");module.exports=function(e){return new ECDH(e)};var aliases={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function ECDH(e){this.curveType=aliases[e],this.curveType||(this.curveType={name:e}),this.curve=new elliptic.ec(this.curveType.name),this.keys=void 0}function formatReturnValue(e,t,r){Array.isArray(e)||(e=e.toArray());var i=new Buffer(e);if(r&&i.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return h}function s(t,i,r,h){for(var n=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,h){if("number"==typeof t)return this._initNumber(t,i,h);if("object"==typeof t)return this._initArray(t,i,h);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===i?this._parseHex(t,n):this._parseBase(t,i,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initNumber=function(t,i,h){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initArray=function(t,i,h){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===h)for(n=0,e=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},n.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)n=o(t,r,r+6),this.words[h]|=n<>>26-e&4194303,(e+=24)>=26&&(e-=26,h++);r+6!==i&&(n=o(t,i,r+6),this.words[h]|=n<>>26-e&4194303),this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,u=Math.min(e,e-o)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}n.prototype.toString=function(t,i){var h;if(i=0|i||1,16===(t=t||10)||"hex"===t){h="";for(var n=0,e=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-m.length]+m+h:m+h,(n+=2)>=26&&(n-=26,o--)}for(0!==e&&(h=e.toString(16)+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}if(t===(0|t)&&t>=2&&t<=36){var f=a[t],d=l[t];h="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);h=(p=p.idivn(d)).isZero()?M+h:u[f-M.length]+M+h}for(this.isZero()&&(h="0"+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,h){var n=this.byteLength(),e=h||Math.max(1,n);r(n<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0"),this.strip();var o,s,u="le"===i,a=new t(e),l=this.clone();if(u){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),a[s]=o;for(;s=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;ht.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),h=t%26;this._expand(i),h>0&&i--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-h),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var h=t/26|0,n=t%26;return this._expand(h+1),this.words[h]=i?this.words[h]|1<t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e>>26;for(;0!==n&&e>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],R=8191&q,B=q>>>13,N=0|o[7],L=8191&N,I=N>>>13,z=0|o[8],T=8191&z,E=z>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,C=P>>>13,D=0|s[1],H=8191&D,J=D>>>13,U=0|s[2],G=8191&U,Q=U>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(h=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,F),n=(n=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,F),n=(n=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|0;var ct=(a+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,F),n=(n=Math.imul(y,C))+Math.imul(b,F)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,F),n=(n=Math.imul(k,C))+Math.imul(A,F)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(S,F),n=(n=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(R,F),n=(n=Math.imul(R,C))+Math.imul(B,F)|0,e=Math.imul(B,C),h=h+Math.imul(S,H)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(a+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(L,F),n=(n=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),h=h+Math.imul(R,H)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(B,H)|0,e=e+Math.imul(B,J)|0,h=h+Math.imul(S,G)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(T,F),n=(n=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),h=h+Math.imul(L,H)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,h=h+Math.imul(R,G)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(B,G)|0,e=e+Math.imul(B,Q)|0,h=h+Math.imul(S,W)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,F),n=(n=Math.imul(j,C))+Math.imul(K,F)|0,e=Math.imul(K,C),h=h+Math.imul(T,H)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,h=h+Math.imul(L,G)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,h=h+Math.imul(R,W)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(B,W)|0,e=e+Math.imul(B,X)|0,h=h+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var xt=(a+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),h=h+Math.imul(T,G)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(L,W)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,h=h+Math.imul(R,$)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,tt)|0,h=h+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var St=(a+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(T,W)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,h=h+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(B,rt)|0,e=e+Math.imul(B,ht)|0,h=h+Math.imul(S,et)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var Zt=(a+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,ht)|0,h=h+Math.imul(R,et)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(B,et)|0,e=e+Math.imul(B,ot)|0,h=h+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var qt=(a+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(L,et)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,h=h+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(B,ut)|0,e=e+Math.imul(B,at)|0,h=h+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Rt=(a+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(T,et)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,h=h+Math.imul(R,mt)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(B,mt)|0,e=e+Math.imul(B,ft)|0;var Bt=(a+(h=h+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,h=h+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(h=h+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,Mt)|0)+Math.imul(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),h=h+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(h=h+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(h=h+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(a+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=xt,u[10]=St,u[11]=Zt,u[12]=qt,u[13]=Rt,u[14]=Bt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function d(t,i,r){return(new p).mulp(t,i,r)}function p(t,i){this.x=t,this.y=i}Math.imul||(f=m),n.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,i):r<63?m(this,t,i):r<1024?function(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r.strip()}(this,t,i):d(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),r=n.prototype._countBits(t)-1,h=0;h>=1;return h},p.prototype.permute=function(t,i,r,h,n,e){for(var o=0;o>>=1)n++;return 1<>>=13,h[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,i+=n/67108864|0,i+=e>>>26,this.words[h]=67108863&e}return 0!==i&&(this.words[h]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r>>n}return i}(t);if(0===i.length)return new n(1);for(var r=this,h=0;h=0);var i,h=t%26,n=(t-h)/26,e=67108863>>>26-h<<26-h;if(0!==h){var o=0;for(i=0;i>>26-h}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,h){return r(0===this.negative),this.iushrn(t,i,h)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,h=(t-i)/26,n=1<=0);var i=t%26,h=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=h)return this;if(0!==i&&h++,this.length=Math.min(h,this.length),0!==i){var n=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[n+h]=67108863&e}for(;n>26,this.words[n+h]=67108863&e;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&e;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),h.iushln(r),o=0|e.words[e.length-1]);var s,u=h.length-e.length;if("mod"!==i){(s=new n(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|h.words[e.length+m])+(0|h.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(e,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(e,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s.strip(),h.strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},n.prototype.divmod=function(t,i,h){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i);var e,o,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,h=0,n=this.length-1;n>=0;n--)h=(i*h+(0|this.words[n]))%t;return h},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,h=this.length-1;h>=0;h--){var n=(0|this.words[h])+67108864*i;this.words[h]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=new n(0),u=new n(1),a=0;i.isEven()&&h.isEven();)i.iushrn(1),h.iushrn(1),++a;for(var l=h.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(h.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(h.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(s),o.isub(u)):(h.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:h.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e,o=new n(1),s=new n(0),u=h.clone();i.cmpn(1)>0&&h.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(h.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(h.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(h)>=0?(i.isub(h),o.isub(s)):(h.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,h=(t-i)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,h=t<0;if(0!==this.negative&&!h)return-1;if(0===this.negative&&h)return 1;if(this.strip(),this.length>1)i=1;else{h&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:nt.length)return 1;if(this.length=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){hn&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new b(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},h(g,v),g.prototype.split=function(t,i){for(var r=Math.min(t.length,9),h=0;h>>22,n=e}n>>>=22,t.words[h-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(M[t])return M[t];var i;if("k256"===t)i=new g;else if("p224"===t)i=new c;else if("p192"===t)i=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new y}return M[t]=i,i},b.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},b.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var h=this.m.add(new n(1)).iushrn(2);return this.pow(t,h)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new n(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;h--){for(var a=i.words[h],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===h&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new _(t)},h(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(h).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":55}],118:[function(require,module,exports){ +},{"buffer":60}],123:[function(require,module,exports){ "use strict";var inherits=require("inherits"),MD5=require("md5.js"),RIPEMD160=require("ripemd160"),sha=require("sha.js"),Base=require("cipher-base");function Hash(e){Base.call(this,"digest"),this._hash=e}inherits(Hash,Base),Hash.prototype._update=function(e){this._hash.update(e)},Hash.prototype._final=function(){return this._hash.digest()},module.exports=function(e){return"md5"===(e=e.toLowerCase())?new MD5:"rmd160"===e||"ripemd160"===e?new RIPEMD160:new Hash(sha(e))}; -},{"cipher-base":109,"inherits":258,"md5.js":340,"ripemd160":628,"sha.js":646}],119:[function(require,module,exports){ +},{"cipher-base":114,"inherits":264,"md5.js":345,"ripemd160":637,"sha.js":655}],124:[function(require,module,exports){ var MD5=require("md5.js");module.exports=function(e){return(new MD5).update(e).digest()}; -},{"md5.js":340}],120:[function(require,module,exports){ +},{"md5.js":345}],125:[function(require,module,exports){ "use strict";var inherits=require("inherits"),Legacy=require("./legacy"),Base=require("cipher-base"),Buffer=require("safe-buffer").Buffer,md5=require("create-hash/md5"),RIPEMD160=require("ripemd160"),sha=require("sha.js"),ZEROS=Buffer.alloc(128);function Hmac(e,a){Base.call(this,"digest"),"string"==typeof a&&(a=Buffer.from(a));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=a,a.length>r)?a=("rmd160"===e?new RIPEMD160:sha(e)).update(a).digest():a.lengthblocksize?s=e(s):s.length=this._finalSize&&(this._update(this._block),this._block.fill(0));var e=8*this._len;if(e<=4294967295)this._block.writeUInt32BE(e,this._blockSize-4);else{var s=(4294967295&e)>>>0,h=(e-s)/4294967296;this._block.writeUInt32BE(h,this._blockSize-8),this._block.writeUInt32BE(s,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash; -},{"safe-buffer":629}],123:[function(require,module,exports){ +},{"safe-buffer":638}],128:[function(require,module,exports){ var exports=module.exports=function(e){e=e.toLowerCase();var r=exports[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512"); -},{"./sha":124,"./sha1":125,"./sha224":126,"./sha256":127,"./sha384":128,"./sha512":129}],124:[function(require,module,exports){ +},{"./sha":129,"./sha1":130,"./sha224":131,"./sha256":132,"./sha384":133,"./sha512":134}],129:[function(require,module,exports){ var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(t){return t<<5|t>>>27}function rotl30(t){return t<<30|t>>>2}function ft(t,i,r,h){return 0===t?i&r|~i&h:2===t?i&r|i&h|r&h:i^r^h}inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(t){for(var i=this._w,r=0|this._a,h=0|this._b,s=0|this._c,e=0|this._d,n=0|this._e,_=0;_<16;++_)i[_]=t.readInt32BE(4*_);for(;_<80;++_)i[_]=i[_-3]^i[_-8]^i[_-14]^i[_-16];for(var a=0;a<80;++a){var o=~~(a/20),f=rotl5(r)+ft(o,h,s,e)+n+i[a]+K[o]|0;n=e,e=s,s=rotl30(h),h=r,r=f}this._a=r+this._a|0,this._b=h+this._b|0,this._c=s+this._c|0,this._d=e+this._d|0,this._e=n+this._e|0},Sha.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},module.exports=Sha; -},{"./hash":122,"inherits":258,"safe-buffer":629}],125:[function(require,module,exports){ +},{"./hash":127,"inherits":264,"safe-buffer":638}],130:[function(require,module,exports){ var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(t){return t<<1|t>>>31}function rotl5(t){return t<<5|t>>>27}function rotl30(t){return t<<30|t>>>2}function ft(t,i,r,h){return 0===t?i&r|~i&h:2===t?i&r|i&h|r&h:i^r^h}inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(t){for(var i=this._w,r=0|this._a,h=0|this._b,s=0|this._c,e=0|this._d,n=0|this._e,_=0;_<16;++_)i[_]=t.readInt32BE(4*_);for(;_<80;++_)i[_]=rotl1(i[_-3]^i[_-8]^i[_-14]^i[_-16]);for(var a=0;a<80;++a){var o=~~(a/20),f=rotl5(r)+ft(o,h,s,e)+n+i[a]+K[o]|0;n=e,e=s,s=rotl30(h),h=r,r=f}this._a=r+this._a|0,this._b=h+this._b|0,this._c=s+this._c|0,this._d=e+this._d|0,this._e=n+this._e|0},Sha1.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},module.exports=Sha1; -},{"./hash":122,"inherits":258,"safe-buffer":629}],126:[function(require,module,exports){ +},{"./hash":127,"inherits":264,"safe-buffer":638}],131:[function(require,module,exports){ var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=new Array(64);function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},module.exports=Sha224; -},{"./hash":122,"./sha256":127,"inherits":258,"safe-buffer":629}],127:[function(require,module,exports){ +},{"./hash":127,"./sha256":132,"inherits":264,"safe-buffer":638}],132:[function(require,module,exports){ var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=new Array(64);function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(t,i,h){return h^t&(i^h)}function maj(t,i,h){return t&i|h&(t|i)}function sigma0(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function sigma1(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function gamma0(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function gamma1(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(t){for(var i=this._w,h=0|this._a,s=0|this._b,r=0|this._c,e=0|this._d,n=0|this._e,_=0|this._f,a=0|this._g,f=0|this._h,u=0;u<16;++u)i[u]=t.readInt32BE(4*u);for(;u<64;++u)i[u]=gamma1(i[u-2])+i[u-7]+gamma0(i[u-15])+i[u-16]|0;for(var o=0;o<64;++o){var c=f+sigma1(n)+ch(n,_,a)+K[o]+i[o]|0,m=sigma0(h)+maj(h,s,r)|0;f=a,a=_,_=n,n=e+c|0,e=r,r=s,s=h,h=c+m|0}this._a=h+this._a|0,this._b=s+this._b|0,this._c=r+this._c|0,this._d=e+this._d|0,this._e=n+this._e|0,this._f=_+this._f|0,this._g=a+this._g|0,this._h=f+this._h|0},Sha256.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},module.exports=Sha256; -},{"./hash":122,"inherits":258,"safe-buffer":629}],128:[function(require,module,exports){ +},{"./hash":127,"inherits":264,"safe-buffer":638}],133:[function(require,module,exports){ var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=new Array(160);function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){var h=Buffer.allocUnsafe(48);function i(i,t,s){h.writeInt32BE(i,s),h.writeInt32BE(t,s+4)}return i(this._ah,this._al,0),i(this._bh,this._bl,8),i(this._ch,this._cl,16),i(this._dh,this._dl,24),i(this._eh,this._el,32),i(this._fh,this._fl,40),h},module.exports=Sha384; -},{"./hash":122,"./sha512":129,"inherits":258,"safe-buffer":629}],129:[function(require,module,exports){ +},{"./hash":127,"./sha512":134,"inherits":264,"safe-buffer":638}],134:[function(require,module,exports){ var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(h,t,i){return i^h&(t^i)}function maj(h,t,i){return h&t|i&(h|t)}function sigma0(h,t){return(h>>>28|t<<4)^(t>>>2|h<<30)^(t>>>7|h<<25)}function sigma1(h,t){return(h>>>14|t<<18)^(h>>>18|t<<14)^(t>>>9|h<<23)}function Gamma0(h,t){return(h>>>1|t<<31)^(h>>>8|t<<24)^h>>>7}function Gamma0l(h,t){return(h>>>1|t<<31)^(h>>>8|t<<24)^(h>>>7|t<<25)}function Gamma1(h,t){return(h>>>19|t<<13)^(t>>>29|h<<3)^h>>>6}function Gamma1l(h,t){return(h>>>19|t<<13)^(t>>>29|h<<3)^(h>>>6|t<<26)}function getCarry(h,t){return h>>>0>>0?1:0}inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(h){for(var t=this._w,i=0|this._ah,s=0|this._bh,r=0|this._ch,_=0|this._dh,a=0|this._eh,e=0|this._fh,l=0|this._gh,n=0|this._hh,f=0|this._al,g=0|this._bl,u=0|this._cl,c=0|this._dl,m=0|this._el,o=0|this._fl,y=0|this._gl,C=0|this._hl,d=0;d<32;d+=2)t[d]=h.readInt32BE(4*d),t[d+1]=h.readInt32BE(4*d+4);for(;d<160;d+=2){var b=t[d-30],p=t[d-30+1],G=Gamma0(b,p),v=Gamma0l(p,b),B=Gamma1(b=t[d-4],p=t[d-4+1]),S=Gamma1l(p,b),w=t[d-14],E=t[d-14+1],I=t[d-32],j=t[d-32+1],q=v+E|0,H=G+w+getCarry(q,v)|0;H=(H=H+B+getCarry(q=q+S|0,S)|0)+I+getCarry(q=q+j|0,j)|0,t[d]=H,t[d+1]=q}for(var W=0;W<160;W+=2){H=t[W],q=t[W+1];var x=maj(i,s,r),A=maj(f,g,u),U=sigma0(i,f),k=sigma0(f,i),z=sigma1(a,m),D=sigma1(m,a),F=K[W],J=K[W+1],L=Ch(a,e,l),M=Ch(m,o,y),N=C+D|0,O=n+z+getCarry(N,C)|0;O=(O=(O=O+L+getCarry(N=N+M|0,M)|0)+F+getCarry(N=N+J|0,J)|0)+H+getCarry(N=N+q|0,q)|0;var P=k+A|0,Q=U+x+getCarry(P,k)|0;n=l,C=y,l=e,y=o,e=a,o=m,a=_+O+getCarry(m=c+N|0,c)|0,_=r,c=u,r=s,u=g,s=i,g=f,i=O+Q+getCarry(f=N+P|0,N)|0}this._al=this._al+f|0,this._bl=this._bl+g|0,this._cl=this._cl+u|0,this._dl=this._dl+c|0,this._el=this._el+m|0,this._fl=this._fl+o|0,this._gl=this._gl+y|0,this._hl=this._hl+C|0,this._ah=this._ah+i+getCarry(this._al,f)|0,this._bh=this._bh+s+getCarry(this._bl,g)|0,this._ch=this._ch+r+getCarry(this._cl,u)|0,this._dh=this._dh+_+getCarry(this._dl,c)|0,this._eh=this._eh+a+getCarry(this._el,m)|0,this._fh=this._fh+e+getCarry(this._fl,o)|0,this._gh=this._gh+l+getCarry(this._gl,y)|0,this._hh=this._hh+n+getCarry(this._hl,C)|0},Sha512.prototype._hash=function(){var h=Buffer.allocUnsafe(64);function t(t,i,s){h.writeInt32BE(t,s),h.writeInt32BE(i,s+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),h},module.exports=Sha512; -},{"./hash":122,"inherits":258,"safe-buffer":629}],130:[function(require,module,exports){ +},{"./hash":127,"inherits":264,"safe-buffer":638}],135:[function(require,module,exports){ "use strict";exports.randomBytes=exports.rng=exports.pseudoRandomBytes=exports.prng=require("randombytes"),exports.createHash=exports.Hash=require("create-hash"),exports.createHmac=exports.Hmac=require("create-hmac");var algos=require("browserify-sign/algos"),algoKeys=Object.keys(algos),hashes=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(algoKeys);exports.getHashes=function(){return hashes};var p=require("pbkdf2");exports.pbkdf2=p.pbkdf2,exports.pbkdf2Sync=p.pbkdf2Sync;var aes=require("browserify-cipher");exports.Cipher=aes.Cipher,exports.createCipher=aes.createCipher,exports.Cipheriv=aes.Cipheriv,exports.createCipheriv=aes.createCipheriv,exports.Decipher=aes.Decipher,exports.createDecipher=aes.createDecipher,exports.Decipheriv=aes.Decipheriv,exports.createDecipheriv=aes.createDecipheriv,exports.getCiphers=aes.getCiphers,exports.listCiphers=aes.listCiphers;var dh=require("diffie-hellman");exports.DiffieHellmanGroup=dh.DiffieHellmanGroup,exports.createDiffieHellmanGroup=dh.createDiffieHellmanGroup,exports.getDiffieHellman=dh.getDiffieHellman,exports.createDiffieHellman=dh.createDiffieHellman,exports.DiffieHellman=dh.DiffieHellman;var sign=require("browserify-sign");exports.createSign=sign.createSign,exports.Sign=sign.Sign,exports.createVerify=sign.createVerify,exports.Verify=sign.Verify,exports.createECDH=require("create-ecdh");var publicEncrypt=require("public-encrypt");exports.publicEncrypt=publicEncrypt.publicEncrypt,exports.privateEncrypt=publicEncrypt.privateEncrypt,exports.publicDecrypt=publicEncrypt.publicDecrypt,exports.privateDecrypt=publicEncrypt.privateDecrypt;var rf=require("randomfill");exports.randomFill=rf.randomFill,exports.randomFillSync=rf.randomFillSync,exports.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},exports.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}; -},{"browserify-cipher":73,"browserify-sign":80,"browserify-sign/algos":77,"create-ecdh":116,"create-hash":118,"create-hmac":120,"diffie-hellman":143,"pbkdf2":425,"public-encrypt":454,"randombytes":608,"randomfill":609}],131:[function(require,module,exports){ +},{"browserify-cipher":78,"browserify-sign":85,"browserify-sign/algos":82,"create-ecdh":121,"create-hash":123,"create-hmac":125,"diffie-hellman":148,"pbkdf2":431,"public-encrypt":460,"randombytes":616,"randomfill":617}],136:[function(require,module,exports){ (function (process){(function (){ function useColors(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function formatArgs(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+module.exports.humanize(this.diff),!this.useColors)return;const o="color: "+this.color;e.splice(1,0,o,"color: inherit");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(t++,"%c"===e&&(C=t))}),e.splice(C,0,o)}function save(e){try{e?exports.storage.setItem("debug",e):exports.storage.removeItem("debug")}catch(e){}}function load(){let e;try{e=exports.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}function localstorage(){try{return localStorage}catch(e){}}exports.formatArgs=formatArgs,exports.save=save,exports.load=load,exports.useColors=useColors,exports.storage=localstorage(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),exports.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],exports.log=console.debug||console.log||(()=>{}),module.exports=require("./common")(exports);const{formatters:formatters}=module.exports;formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}; }).call(this)}).call(this,require('_process')) -},{"./common":132,"_process":443}],132:[function(require,module,exports){ -function setup(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";i++;const s=n.formatters[o];if("function"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),"function"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(t=0;t{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n{if("%%"===r)return"%";a++;const o=n.formatters[s];if("function"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),"function"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),s=r.length;for(t=0;t{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n2?arguments[2]:{},o=keys(r);hasSymbols&&(o=concat.call(o,Object.getOwnPropertySymbols(r)));for(var n=0;nMath.floor(Math.random()*(r-e+1)+e),createAbortError=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},createDelay=({clearTimeout:e,setTimeout:r,willResolve:t})=>(o,{value:a,signal:l}={})=>{if(l&&l.aborted)return Promise.reject(createAbortError());let c,i,n;const s=e||clearTimeout,m=()=>{s(c),n(createAbortError())},u=new Promise((e,s)=>{i=(()=>{l&&l.removeEventListener("abort",m),t?e(a):s(a)}),n=s,c=(r||setTimeout)(i,o)});return l&&l.addEventListener("abort",m,{once:!0}),u.clear=(()=>{s(c),c=null,i()}),u},delay=createDelay({willResolve:!0});delay.reject=createDelay({willResolve:!1}),delay.range=((e,r,t)=>delay(randomInteger(e,r),t)),delay.createWithTimers=(({clearTimeout:e,setTimeout:r})=>{const t=createDelay({clearTimeout:e,setTimeout:r,willResolve:!0});return t.reject=createDelay({clearTimeout:e,setTimeout:r,willResolve:!1}),t}),module.exports=delay,module.exports.default=delay; -},{}],137:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ "use strict";exports.utils=require("./des/utils"),exports.Cipher=require("./des/cipher"),exports.DES=require("./des/des"),exports.CBC=require("./des/cbc"),exports.EDE=require("./des/ede"); -},{"./des/cbc":138,"./des/cipher":139,"./des/des":140,"./des/ede":141,"./des/utils":142}],138:[function(require,module,exports){ +},{"./des/cbc":143,"./des/cipher":144,"./des/des":145,"./des/ede":146,"./des/utils":147}],143:[function(require,module,exports){ "use strict";var assert=require("minimalistic-assert"),inherits=require("inherits"),proto={};function CBCState(t){assert.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var i=0;i0;i--)e+=this._buffer(t,e),r+=this._flushBuffer(f,r);return e+=this._buffer(t,e),f},Cipher.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},Cipher.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=utils.r28shl(r,n),i=utils.r28shl(i,n),utils.pc2(r,i,t.keys,s)}},DES.prototype._update=function(t,e,r,i){var s=this._desState,n=utils.readUInt32BE(t,e),p=utils.readUInt32BE(t,e+4);utils.ip(n,p,s.tmp,0),n=s.tmp[0],p=s.tmp[1],"encrypt"===this.type?this._encrypt(s,n,p,s.tmp,0):this._decrypt(s,n,p,s.tmp,0),n=s.tmp[0],p=s.tmp[1],utils.writeUInt32BE(r,n,i),utils.writeUInt32BE(r,p,i+4)},DES.prototype._pad=function(t,e){for(var r=t.length-e,i=e;i>>0,n=o}utils.rip(p,n,i,s)},DES.prototype._decrypt=function(t,e,r,i,s){for(var n=r,p=e,u=t.keys.length-2;u>=0;u-=2){var l=t.keys[u],a=t.keys[u+1];utils.expand(n,t.tmp,0),l^=t.tmp[0],a^=t.tmp[1];var h=utils.substitute(l,a),o=n;n=(p^utils.permute(h))>>>0,p=o}utils.rip(n,p,i,s)}; -},{"./cipher":139,"./utils":142,"inherits":258,"minimalistic-assert":343}],141:[function(require,module,exports){ +},{"./cipher":144,"./utils":147,"inherits":264,"minimalistic-assert":348}],146:[function(require,module,exports){ "use strict";var assert=require("minimalistic-assert"),inherits=require("inherits"),Cipher=require("./cipher"),DES=require("./des");function EDEState(e,t){assert.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),p=t.slice(8,16),i=t.slice(16,24);this.ciphers="encrypt"===e?[DES.create({type:"encrypt",key:r}),DES.create({type:"decrypt",key:p}),DES.create({type:"encrypt",key:i})]:[DES.create({type:"decrypt",key:i}),DES.create({type:"encrypt",key:p}),DES.create({type:"decrypt",key:r})]}function EDE(e){Cipher.call(this,e);var t=new EDEState(this.type,this.options.key);this._edeState=t}inherits(EDE,Cipher),module.exports=EDE,EDE.create=function(e){return new EDE(e)},EDE.prototype._update=function(e,t,r,p){var i=this._edeState;i.ciphers[0]._update(e,t,r,p),i.ciphers[1]._update(r,p,r,p),i.ciphers[2]._update(r,p,r,p)},EDE.prototype._pad=DES.prototype._pad,EDE.prototype._unpad=DES.prototype._unpad; -},{"./cipher":139,"./des":140,"inherits":258,"minimalistic-assert":343}],142:[function(require,module,exports){ +},{"./cipher":144,"./des":145,"inherits":264,"minimalistic-assert":348}],147:[function(require,module,exports){ "use strict";exports.readUInt32BE=function(r,o){return(r[0+o]<<24|r[1+o]<<16|r[2+o]<<8|r[3+o])>>>0},exports.writeUInt32BE=function(r,o,t){r[0+t]=o>>>24,r[1+t]=o>>>16&255,r[2+t]=o>>>8&255,r[3+t]=255&o},exports.ip=function(r,o,t,e){for(var f=0,n=0,a=6;a>=0;a-=2){for(var p=0;p<=24;p+=8)f<<=1,f|=o>>>p+a&1;for(p=0;p<=24;p+=8)f<<=1,f|=r>>>p+a&1}for(a=6;a>=0;a-=2){for(p=1;p<=25;p+=8)n<<=1,n|=o>>>p+a&1;for(p=1;p<=25;p+=8)n<<=1,n|=r>>>p+a&1}t[e+0]=f>>>0,t[e+1]=n>>>0},exports.rip=function(r,o,t,e){for(var f=0,n=0,a=0;a<4;a++)for(var p=24;p>=0;p-=8)f<<=1,f|=o>>>p+a&1,f<<=1,f|=r>>>p+a&1;for(a=4;a<8;a++)for(p=24;p>=0;p-=8)n<<=1,n|=o>>>p+a&1,n<<=1,n|=r>>>p+a&1;t[e+0]=f>>>0,t[e+1]=n>>>0},exports.pc1=function(r,o,t,e){for(var f=0,n=0,a=7;a>=5;a--){for(var p=0;p<=24;p+=8)f<<=1,f|=o>>p+a&1;for(p=0;p<=24;p+=8)f<<=1,f|=r>>p+a&1}for(p=0;p<=24;p+=8)f<<=1,f|=o>>p+a&1;for(a=1;a<=3;a++){for(p=0;p<=24;p+=8)n<<=1,n|=o>>p+a&1;for(p=0;p<=24;p+=8)n<<=1,n|=r>>p+a&1}for(p=0;p<=24;p+=8)n<<=1,n|=r>>p+a&1;t[e+0]=f>>>0,t[e+1]=n>>>0},exports.r28shl=function(r,o){return r<>>28-o};var pc2table=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];exports.pc2=function(r,o,t,e){for(var f=0,n=0,a=pc2table.length>>>1,p=0;p>>pc2table[p]&1;for(p=a;p>>pc2table[p]&1;t[e+0]=f>>>0,t[e+1]=n>>>0},exports.expand=function(r,o,t){var e=0,f=0;e=(1&r)<<5|r>>>27;for(var n=23;n>=15;n-=4)e<<=6,e|=r>>>n&63;for(n=11;n>=3;n-=4)f|=r>>>n&63,f<<=6;f|=(31&r)<<1|r>>>31,o[t+0]=e>>>0,o[t+1]=f>>>0};var sTable=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];exports.substitute=function(r,o){for(var t=0,e=0;e<4;e++){t<<=4,t|=sTable[64*e+(r>>>18-6*e&63)]}for(e=0;e<4;e++){t<<=4,t|=sTable[256+64*e+(o>>>18-6*e&63)]}return t>>>0};var permuteTable=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];exports.permute=function(r){for(var o=0,t=0;t>>permuteTable[t]&1;return o>>>0},exports.padSplit=function(r,o,t){for(var e=r.toString(2);e.lengthe;)i.ishrn(1);if(i.isEven()&&i.iadd(ONE),i.testn(1)||i.iadd(TWO),r.cmp(TWO)){if(!r.cmp(FIVE))for(;i.mod(TEN).cmp(THREE);)i.iadd(FOUR)}else for(;i.mod(TWENTYFOUR).cmp(ELEVEN);)i.iadd(FOUR);if(simpleSieve(n=i.shrn(1))&&simpleSieve(i)&&fermatTest(n)&&fermatTest(i)&&millerRabin.test(n)&&millerRabin.test(i))return i}} -},{"bn.js":147,"miller-rabin":341,"randombytes":608}],146:[function(require,module,exports){ +},{"bn.js":152,"miller-rabin":346,"randombytes":616}],151:[function(require,module,exports){ module.exports={ "modp1": { "gen": "02", @@ -880,72 +903,75 @@ module.exports={ "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" } } -},{}],147:[function(require,module,exports){ +},{}],152:[function(require,module,exports){ !function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function h(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,i,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var e;"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;try{e=require("buffer").Buffer}catch(t){}function o(t,i,r){for(var h=0,n=Math.min(t.length,r),e=i;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return h}function s(t,i,r,h){for(var n=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,h){if("number"==typeof t)return this._initNumber(t,i,h);if("object"==typeof t)return this._initArray(t,i,h);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===i?this._parseHex(t,n):this._parseBase(t,i,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initNumber=function(t,i,h){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initArray=function(t,i,h){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===h)for(n=0,e=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},n.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)n=o(t,r,r+6),this.words[h]|=n<>>26-e&4194303,(e+=24)>=26&&(e-=26,h++);r+6!==i&&(n=o(t,i,r+6),this.words[h]|=n<>>26-e&4194303),this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,u=Math.min(e,e-o)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}n.prototype.toString=function(t,i){var h;if(i=0|i||1,16===(t=t||10)||"hex"===t){h="";for(var n=0,e=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-m.length]+m+h:m+h,(n+=2)>=26&&(n-=26,o--)}for(0!==e&&(h=e.toString(16)+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}if(t===(0|t)&&t>=2&&t<=36){var f=a[t],d=l[t];h="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);h=(p=p.idivn(d)).isZero()?M+h:u[f-M.length]+M+h}for(this.isZero()&&(h="0"+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,h){var n=this.byteLength(),e=h||Math.max(1,n);r(n<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0"),this.strip();var o,s,u="le"===i,a=new t(e),l=this.clone();if(u){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),a[s]=o;for(;s=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;ht.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),h=t%26;this._expand(i),h>0&&i--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-h),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var h=t/26|0,n=t%26;return this._expand(h+1),this.words[h]=i?this.words[h]|1<t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e>>26;for(;0!==n&&e>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],R=8191&q,B=q>>>13,N=0|o[7],L=8191&N,I=N>>>13,z=0|o[8],T=8191&z,E=z>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,C=P>>>13,D=0|s[1],H=8191&D,J=D>>>13,U=0|s[2],G=8191&U,Q=U>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(h=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,F),n=(n=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,F),n=(n=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|0;var ct=(a+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,F),n=(n=Math.imul(y,C))+Math.imul(b,F)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,F),n=(n=Math.imul(k,C))+Math.imul(A,F)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(S,F),n=(n=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(R,F),n=(n=Math.imul(R,C))+Math.imul(B,F)|0,e=Math.imul(B,C),h=h+Math.imul(S,H)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(a+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(L,F),n=(n=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),h=h+Math.imul(R,H)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(B,H)|0,e=e+Math.imul(B,J)|0,h=h+Math.imul(S,G)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(T,F),n=(n=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),h=h+Math.imul(L,H)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,h=h+Math.imul(R,G)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(B,G)|0,e=e+Math.imul(B,Q)|0,h=h+Math.imul(S,W)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,F),n=(n=Math.imul(j,C))+Math.imul(K,F)|0,e=Math.imul(K,C),h=h+Math.imul(T,H)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,h=h+Math.imul(L,G)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,h=h+Math.imul(R,W)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(B,W)|0,e=e+Math.imul(B,X)|0,h=h+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var xt=(a+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),h=h+Math.imul(T,G)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(L,W)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,h=h+Math.imul(R,$)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,tt)|0,h=h+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var St=(a+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(T,W)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,h=h+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(B,rt)|0,e=e+Math.imul(B,ht)|0,h=h+Math.imul(S,et)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var Zt=(a+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,ht)|0,h=h+Math.imul(R,et)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(B,et)|0,e=e+Math.imul(B,ot)|0,h=h+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var qt=(a+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(L,et)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,h=h+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(B,ut)|0,e=e+Math.imul(B,at)|0,h=h+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Rt=(a+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(T,et)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,h=h+Math.imul(R,mt)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(B,mt)|0,e=e+Math.imul(B,ft)|0;var Bt=(a+(h=h+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,h=h+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(h=h+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,Mt)|0)+Math.imul(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),h=h+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(h=h+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(h=h+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(a+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=xt,u[10]=St,u[11]=Zt,u[12]=qt,u[13]=Rt,u[14]=Bt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function d(t,i,r){return(new p).mulp(t,i,r)}function p(t,i){this.x=t,this.y=i}Math.imul||(f=m),n.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,i):r<63?m(this,t,i):r<1024?function(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r.strip()}(this,t,i):d(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),r=n.prototype._countBits(t)-1,h=0;h>=1;return h},p.prototype.permute=function(t,i,r,h,n,e){for(var o=0;o>>=1)n++;return 1<>>=13,h[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,i+=n/67108864|0,i+=e>>>26,this.words[h]=67108863&e}return 0!==i&&(this.words[h]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r>>n}return i}(t);if(0===i.length)return new n(1);for(var r=this,h=0;h=0);var i,h=t%26,n=(t-h)/26,e=67108863>>>26-h<<26-h;if(0!==h){var o=0;for(i=0;i>>26-h}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,h){return r(0===this.negative),this.iushrn(t,i,h)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,h=(t-i)/26,n=1<=0);var i=t%26,h=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=h)return this;if(0!==i&&h++,this.length=Math.min(h,this.length),0!==i){var n=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[n+h]=67108863&e}for(;n>26,this.words[n+h]=67108863&e;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&e;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),h.iushln(r),o=0|e.words[e.length-1]);var s,u=h.length-e.length;if("mod"!==i){(s=new n(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|h.words[e.length+m])+(0|h.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(e,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(e,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s.strip(),h.strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},n.prototype.divmod=function(t,i,h){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i);var e,o,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,h=0,n=this.length-1;n>=0;n--)h=(i*h+(0|this.words[n]))%t;return h},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,h=this.length-1;h>=0;h--){var n=(0|this.words[h])+67108864*i;this.words[h]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=new n(0),u=new n(1),a=0;i.isEven()&&h.isEven();)i.iushrn(1),h.iushrn(1),++a;for(var l=h.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(h.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(h.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(s),o.isub(u)):(h.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:h.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e,o=new n(1),s=new n(0),u=h.clone();i.cmpn(1)>0&&h.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(h.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(h.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(h)>=0?(i.isub(h),o.isub(s)):(h.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,h=(t-i)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,h=t<0;if(0!==this.negative&&!h)return-1;if(0===this.negative&&h)return 1;if(this.strip(),this.length>1)i=1;else{h&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:nt.length)return 1;if(this.length=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){hn&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new b(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},h(g,v),g.prototype.split=function(t,i){for(var r=Math.min(t.length,9),h=0;h>>22,n=e}n>>>=22,t.words[h-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(M[t])return M[t];var i;if("k256"===t)i=new g;else if("p224"===t)i=new c;else if("p192"===t)i=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new y}return M[t]=i,i},b.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},b.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var h=this.m.add(new n(1)).iushrn(2);return this.pow(t,h)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new n(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;h--){for(var a=i.words[h],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===h&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new _(t)},h(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(h).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":55}],148:[function(require,module,exports){ +},{"buffer":60}],153:[function(require,module,exports){ (function (process,Buffer){(function (){ var stream=require("readable-stream"),eos=require("end-of-stream"),inherits=require("inherits"),shift=require("stream-shift"),SIGNAL_FLUSH=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),onuncork=function(e,t){e._corked?e.once("uncork",t):t()},autoDestroy=function(e,t){e._autoDestroy&&e.destroy(t)},destroyer=function(e,t){return function(i){i?autoDestroy(e,"premature close"===i.message?null:i):t&&!e._ended&&e.end()}},end=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},toStreams2=function(e){return new stream.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},Duplexify=function(e,t,i){if(!(this instanceof Duplexify))return new Duplexify(e,t,i);stream.Duplex.call(this,i),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!i||!1!==i.autoDestroy,this._forwardDestroy=!i||!1!==i.destroy,this._forwardEnd=!i||!1!==i.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};inherits(Duplexify,stream.Duplex),Duplexify.obj=function(e,t,i){return i||(i={}),i.objectMode=!0,i.highWaterMark=16,new Duplexify(e,t,i)},Duplexify.prototype.cork=function(){1==++this._corked&&this.emit("cork")},Duplexify.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},Duplexify.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,i=eos(e,{writable:!0,readable:!1},destroyer(this,this._forwardEnd)),r=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&process.nextTick(r),this._writable=e,this._writable.on("drain",r),this._unwrite=function(){t._writable.removeListener("drain",r),i()},this.uncork()}else this.end()},Duplexify.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,i=eos(e,{writable:!1,readable:!0},destroyer(this)),r=function(){t._forward()},n=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:toStreams2(e),this._readable2.on("readable",r),this._readable2.on("end",n),this._unread=function(){t._readable2.removeListener("readable",r),t._readable2.removeListener("end",n),i()},this._forward()}},Duplexify.prototype._read=function(){this._drained=!0,this._forward()},Duplexify.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=shift(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},Duplexify.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;process.nextTick(function(){t._destroy(e)})}},Duplexify.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},Duplexify.prototype._write=function(e,t,i){return this.destroyed?i():this._corked?onuncork(this,this._write.bind(this,e,t,i)):e===SIGNAL_FLUSH?this._finish(i):this._writable?void(!1===this._writable.write(e)?this._ondrain=i:i()):i()},Duplexify.prototype._finish=function(e){var t=this;this.emit("preend"),onuncork(this,function(){end(t._forwardEnd&&t._writable,function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),onuncork(t,e)})})},Duplexify.prototype.end=function(e,t,i){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(SIGNAL_FLUSH),stream.Writable.prototype.end.call(this,i))},module.exports=Duplexify; }).call(this)}).call(this,require('_process'),require("buffer").Buffer) -},{"_process":443,"buffer":99,"end-of-stream":174,"inherits":258,"readable-stream":620,"stream-shift":826}],149:[function(require,module,exports){ +},{"_process":449,"buffer":104,"end-of-stream":180,"inherits":264,"readable-stream":628,"stream-shift":848}],154:[function(require,module,exports){ "use strict";const Duplex=require("readable-stream").Duplex,kCallback=Symbol("Callback"),kOtherSide=Symbol("Other");class DuplexSocket extends Duplex{constructor(e){super(e),this[kCallback]=null,this[kOtherSide]=null}_read(){const e=this[kCallback];e&&(this[kCallback]=null,e())}_write(e,t,s){this[kOtherSide][kCallback]=s,this[kOtherSide].push(e)}_final(e){this[kOtherSide].on("end",e),this[kOtherSide].push(null)}}class DuplexPair{constructor(e){this.socket1=new DuplexSocket(e),this.socket2=new DuplexSocket(e),this.socket1[kOtherSide]=this.socket2,this.socket2[kOtherSide]=this.socket1}}module.exports=DuplexPair; -},{"readable-stream":620}],150:[function(require,module,exports){ +},{"readable-stream":628}],155:[function(require,module,exports){ "use strict";var _Heap=require("heap"),Heap=function(r){return new _Heap(r)};module.exports=function(r){var n={};function e(n,e,u,t){return r.min(n[u],function(n,e,u){return r.add(n[e],u)}(n,e,t))}function u(n,e,u,t){return n[u]===r.add(n[e],t)}function t(r,n,u,t){return r[u]===e(r,n,u,t)}function i(n,u,t,i,a){if(!a)throw new Error("_hops must be provided");for(;!i.empty();){var o=i.pop();if(r.expand(t[o],u))for(var f in n[o]){var l=e(t,o,f,n[o][f]);if(isNaN(l))throw new Error("NaN");l!=t[f]&&(a[f]=t[f]=l,i.push(f))}}return a}function a(r,n,e,u,t){r[e]=r[e]||{},n[u]=n[u]||{},r[e][u]=n[u][e]=t}return n.reverse=function(r){var n={};for(var e in r)for(var u in r[e])n[u]=n[u]||{},n[u][e]=r[e][u];return n},n.traverse=n.brute=function(n,e,u,t){var a={};a[t]=r.initial();var o=Heap(function(r,n){return a[r]-a[n]},function(r){return a[r]});return o.push(t),i(n,u,a,o,a)},n.uncertain=function(r,n,e,t){n[t];var i={};i[t]=!0;var a=Heap(function(r,e){return n[r]-n[e]});for(a.push(t);!a.empty();){var o=a.pop();for(var f in r[o])u(n,o,f,r[o][f])&&(i[f]||(i[f]=!0,a.push(f)))}return i},n.sources=function(r,n,e){if(!r)throw new Error("backlink graph must be provided");var u={};for(var t in e)if(n[t])for(var i in r[t])e[i]||null==n[i]||(u[i]=!0);return u},n.update=function(o,f,l,v,p,d,c,s){var h={};null==l[p]&&(l[p]=r.initial());var m=o[d]&&o[d][c];if(function(n,e){return r.isAdd(n)&&(r.isRemove(e)||r.min(n,e)==n)}(s,m)){if(a(o,f,d,c,s),null==l[d]||d==c)return null;var w=e(l,d,c,s);if(!r.expand(l[d],v))return null;if(w==l[c]&&r.add(l[d],m)==l[c]){for(var x in f[c])if(x!=d&&r.expand(l[x],v)&&r.add(l[x],o[x][c])===l[c])return null;var H=null;for(var x in f[c])null!=l[x]&&r.expand(l[x],v)&&(H=r.min(H,r.add(l[x],o[x][c])));w=H}return w!=l[c]?(h[c]=l[c]=w,r.expand(l[c],v)?((_=Heap(function(r,n){return l[r]-l[n]})).push(c),i(o,v,l,_,h)):h):null}if(!s&&!f)throw new Error("expected increment:"+s);var b=d,E=c,N=s,A=o[d]&&o[d][c];if(c===p||d==c||!r.expand(l[b],v)||(null==A||!u(l,b,E,A))&&t(l,b,E,N)||(null==A||u(l,b,E,A))&&t(l,b,E,N)&&function(){for(var r in f[E])if(r!==b&&null!=l[r]&&u(l,r,E,o[r][E]))return!0}())return a(o,f,d,c,s),null;if(r.isRemove(N)&&l[b]>=0&&null==l[E])return a(o,f,b,E,N),r.expand(l[b],3)&&(h[E]=l[E]=r.add(l[b],N)),h;var _=Heap(function(r,n){return l[r]-l[n]},function(r){return l[r]}),k=n.uncertain(o,l,v,c),y=n.sources(f,l,k);a(o,f,d,c,s),y[d]=!0;var R={};for(var g in k)R[g]=l[g],delete l[g];var q=n.updateAll(o,l,v,y,h);for(var E in R)q[E]==R[E]&&delete q[E];return q},n.updateAll=function(r,n,e,u,t){var a=Heap(function(r,e){return n[r]-n[e]});for(var o in u)a.push(o);return i(r,e,n,a,t)},n}; -},{"heap":238}],151:[function(require,module,exports){ +},{"heap":244}],156:[function(require,module,exports){ function min(n,t){return null==n?t:null==t?n:Math.abs(n)==Math.abs(t)?n>t?n:t:Math.abs(n)=0?n>=0?n+t:n-t:n>=0?-1*n+t:n},initial:function(){return 0},expand:function(n,t){return null!=n&&n>=0&&n=0},isRemove:function(n){return n<0}}; -},{}],152:[function(require,module,exports){ +},{}],157:[function(require,module,exports){ +!function(r,n){"use strict";"undefined"!=typeof module&&module.exports?module.exports=n(require("tweetnacl/nacl-fast")):r.ed2curve=n(r.nacl)}(this,function(r){"use strict";if(!r)throw new Error("tweetnacl not loaded");var n=function(r){var n,o=new Float64Array(16);if(r)for(n=0;n=0;e--)c(t,t),2!==e&&4!==e&&f(t,t,o);for(e=0;e<16;e++)r[e]=t[e]}(l,l),f(a,a,l),function(r,o){var f,c,u,i=n(),a=n();for(f=0;f<16;f++)a[f]=o[f];for(e(a),e(a),e(a),c=0;c<2;c++){for(i[0]=a[0]-65517,f=1;f<15;f++)i[f]=a[f]-65535-(i[f-1]>>16&1),i[f-1]&=65535;i[15]=a[15]-32767-(i[14]>>16&1),u=i[15]>>16&1,i[14]&=65535,t(a,i,1-u)}for(f=0;f<16;f++)r[2*f]=255&a[f],r[2*f+1]=a[f]>>8}(u,a),u}function i(n){var o,e=new Uint8Array(64),t=new Uint8Array(32);for(r.lowlevel.crypto_hash(e,n,32),e[0]&=248,e[31]&=127,e[31]|=64,o=0;o<32;o++)t[o]=e[o];for(o=0;o<64;o++)e[o]=0;return t}return{convertPublicKey:u,convertSecretKey:i,convertKeyPair:function(r){return{publicKey:u(r.publicKey),secretKey:i(r.secretKey)}}}}); + +},{"tweetnacl/nacl-fast":862}],158:[function(require,module,exports){ "use strict";var elliptic=exports;elliptic.version=require("../package.json").version,elliptic.utils=require("./elliptic/utils"),elliptic.rand=require("brorand"),elliptic.curve=require("./elliptic/curve"),elliptic.curves=require("./elliptic/curves"),elliptic.ec=require("./elliptic/ec"),elliptic.eddsa=require("./elliptic/eddsa"); -},{"../package.json":168,"./elliptic/curve":155,"./elliptic/curves":158,"./elliptic/ec":159,"./elliptic/eddsa":162,"./elliptic/utils":166,"brorand":54}],153:[function(require,module,exports){ +},{"../package.json":174,"./elliptic/curve":161,"./elliptic/curves":164,"./elliptic/ec":165,"./elliptic/eddsa":168,"./elliptic/utils":172,"brorand":59}],159:[function(require,module,exports){ "use strict";var BN=require("bn.js"),utils=require("../utils"),getNAF=utils.getNAF,getJSF=utils.getJSF,assert=utils.assert;function BaseCurve(t,e){this.type=t,this.p=new BN(e.p,16),this.red=e.prime?BN.red(e.prime):BN.mont(this.p),this.zero=new BN(0).toRed(this.red),this.one=new BN(1).toRed(this.red),this.two=new BN(2).toRed(this.red),this.n=e.n&&new BN(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(t,e){this.curve=t,this.type=e,this.precomputed=null}module.exports=BaseCurve,BaseCurve.prototype.point=function(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(t,e){assert(t.precomputed);var n=t._getDoubles(),r=getNAF(e,1,this._bitLength),i=(1<=o;u--)s=(s<<1)+r[u];a.push(s)}for(var p=this.jpoint(null,null,null),h=this.jpoint(null,null,null),d=i;d>0;d--){for(o=0;o=0;a--){for(var u=0;a>=0&&0===o[a];a--)u++;if(a>=0&&u++,s=s.dblp(u),a<0)break;var p=o[a];assert(0!==p),s="affine"===t.type?p>0?s.mixedAdd(i[p-1>>1]):s.mixedAdd(i[-p-1>>1].neg()):p>0?s.add(i[p-1>>1]):s.add(i[-p-1>>1].neg())}return"affine"===t.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function(t,e,n,r,i){var o,s,a,u=this._wnafT1,p=this._wnafT2,h=this._wnafT3,d=0;for(o=0;o=1;o-=2){var f=o-1,c=o;if(1===u[f]&&1===u[c]){var g=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(g[1]=e[f].add(e[c]),g[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(g[1]=e[f].toJ().mixedAdd(e[c]),g[2]=e[f].add(e[c].neg())):(g[1]=e[f].toJ().mixedAdd(e[c]),g[2]=e[f].toJ().mixedAdd(e[c].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],m=getJSF(n[f],n[c]);for(d=Math.max(m[0].length,d),h[f]=new Array(d),h[c]=new Array(d),s=0;s=0;o--){for(var A=0;o>=0;){var _=!0;for(s=0;s=0&&A++,B=B.dblp(A),o<0)break;for(s=0;s0?a=p[s][N-1>>1]:N<0&&(a=p[s][-N-1>>1].neg()),B="affine"===a.type?B.mixedAdd(a):B.add(a))}}for(o=0;o=Math.ceil((t.bitLength()+1)/e.step)},BasePoint.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),r=this.y.redSqr(),e=this.z.redSqr();e=e.redIAdd(e);var i=this.curve._mulA(t),d=this.x.redAdd(this.y).redSqr().redISub(t).redISub(r),s=i.redAdd(r),u=s.redSub(e),n=i.redSub(r),h=d.redMul(u),o=s.redMul(n),l=d.redMul(n),c=u.redMul(s);return this.curve.point(h,o,c,l)},Point.prototype._projDbl=function(){var t,r,e,i,d,s,u=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var o=(i=this.curve._mulA(n)).redAdd(h);this.zOne?(t=u.redSub(n).redSub(h).redMul(o.redSub(this.curve.two)),r=o.redMul(i.redSub(h)),e=o.redSqr().redSub(o).redSub(o)):(d=this.z.redSqr(),s=o.redSub(d).redISub(d),t=u.redSub(n).redISub(h).redMul(s),r=o.redMul(i.redSub(h)),e=o.redMul(s))}else i=n.redAdd(h),d=this.curve._mulC(this.z).redSqr(),s=i.redSub(d).redSub(d),t=this.curve._mulC(u.redISub(i)).redMul(s),r=this.curve._mulC(i).redMul(n.redISub(h)),e=i.redMul(s);return this.curve.point(t,r,e)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var r=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),e=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),d=this.z.redMul(t.z.redAdd(t.z)),s=e.redSub(r),u=d.redSub(i),n=d.redAdd(i),h=e.redAdd(r),o=s.redMul(u),l=n.redMul(h),c=s.redMul(h),p=u.redMul(n);return this.curve.point(o,l,p,c)},Point.prototype._projAdd=function(t){var r,e,i=this.z.redMul(t.z),d=i.redSqr(),s=this.x.redMul(t.x),u=this.y.redMul(t.y),n=this.curve.d.redMul(s).redMul(u),h=d.redSub(n),o=d.redAdd(n),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(u),c=i.redMul(h).redMul(l);return this.curve.twisted?(r=i.redMul(o).redMul(u.redSub(this.curve._mulA(s))),e=h.redMul(o)):(r=i.redMul(o).redMul(u.redSub(s)),e=this.curve._mulC(h).redMul(o)),this.curve.point(c,r,e)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,r,e){return this.curve._wnafMulAdd(1,[this,r],[t,e],2,!1)},Point.prototype.jmulAdd=function(t,r,e){return this.curve._wnafMulAdd(1,[this,r],[t,e],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var r=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(r))return!0;for(var e=t.clone(),i=this.curve.redN.redMul(this.z);;){if(e.iadd(this.curve.n),e.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add; -},{"../utils":166,"./base":153,"bn.js":167,"inherits":258}],155:[function(require,module,exports){ +},{"../utils":172,"./base":159,"bn.js":173,"inherits":264}],161:[function(require,module,exports){ "use strict";var curve=exports;curve.base=require("./base"),curve.short=require("./short"),curve.mont=require("./mont"),curve.edwards=require("./edwards"); -},{"./base":153,"./edwards":154,"./mont":156,"./short":157}],156:[function(require,module,exports){ +},{"./base":159,"./edwards":160,"./mont":162,"./short":163}],162:[function(require,module,exports){ "use strict";var BN=require("bn.js"),inherits=require("inherits"),Base=require("./base"),utils=require("../utils");function MontCurve(t){Base.call(this,"mont",t),this.a=new BN(t.a,16).toRed(this.red),this.b=new BN(t.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,r,e){Base.BasePoint.call(this,t,"projective"),null===r&&null===e?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(r,16),this.z=new BN(e,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(t){var r=t.normalize().x,e=r.redSqr(),i=e.redMul(r).redAdd(e.redMul(this.a)).redAdd(r);return 0===i.redSqrt().redSqr().cmp(i)},inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(t,r){return this.point(utils.toArray(t,r),1)},MontCurve.prototype.point=function(t,r){return new Point(this,t,r)},MontCurve.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,r){return new Point(t,r[0],r[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),r=this.x.redSub(this.z).redSqr(),e=t.redSub(r),i=t.redMul(r),o=e.redMul(r.redAdd(this.curve.a24.redMul(e)));return this.curve.point(i,o)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,r){var e=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=t.x.redAdd(t.z),n=t.x.redSub(t.z).redMul(e),d=o.redMul(i),u=r.z.redMul(n.redAdd(d).redSqr()),s=r.x.redMul(n.redISub(d).redSqr());return this.curve.point(u,s)},Point.prototype.mul=function(t){for(var r=t.clone(),e=this,i=this.curve.point(null,null),o=[];0!==r.cmpn(0);r.iushrn(1))o.push(r.andln(1));for(var n=o.length-1;n>=0;n--)0===o[n]?(e=e.diffAdd(i,this),i=i.dbl()):(i=e.diffAdd(i,this),e=e.dbl());return i},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}; -},{"../utils":166,"./base":153,"bn.js":167,"inherits":258}],157:[function(require,module,exports){ +},{"../utils":172,"./base":159,"bn.js":173,"inherits":264}],163:[function(require,module,exports){ "use strict";var utils=require("../utils"),BN=require("bn.js"),inherits=require("inherits"),Base=require("./base"),assert=utils.assert;function ShortCurve(r){Base.call(this,"short",r),this.a=new BN(r.a,16).toRed(this.red),this.b=new BN(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(r,e,t,d){Base.BasePoint.call(this,r,"affine"),null===e&&null===t?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN(e,16),this.y=new BN(t,16),d&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function JPoint(r,e,t,d){Base.BasePoint.call(this,r,"jacobian"),null===e&&null===t&&null===d?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(e,16),this.y=new BN(t,16),this.z=new BN(d,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits(ShortCurve,Base),module.exports=ShortCurve,ShortCurve.prototype._getEndomorphism=function(r){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,t;if(r.beta)e=new BN(r.beta,16).toRed(this.red);else{var d=this._getEndoRoots(this.p);e=(e=d[0].cmp(d[1])<0?d[0]:d[1]).toRed(this.red)}if(r.lambda)t=new BN(r.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?t=i[0]:(t=i[1],assert(0===this.g.mul(t).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:t,basis:r.basis?r.basis.map(function(r){return{a:new BN(r.a,16),b:new BN(r.b,16)}}):this._getEndoBasis(t)}}},ShortCurve.prototype._getEndoRoots=function(r){var e=r===this.p?this.red:BN.mont(r),t=new BN(2).toRed(e).redInvm(),d=t.redNeg(),i=new BN(3).toRed(e).redNeg().redSqrt().redMul(t);return[d.redAdd(i).fromRed(),d.redSub(i).fromRed()]},ShortCurve.prototype._getEndoBasis=function(r){for(var e,t,d,i,n,u,s,o,h,p=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=r,a=this.n.clone(),f=new BN(1),c=new BN(0),S=new BN(0),v=new BN(1),b=0;0!==l.cmpn(0);){var I=a.div(l);o=a.sub(I.mul(l)),h=S.sub(I.mul(f));var y=v.sub(I.mul(c));if(!d&&o.cmp(p)<0)e=s.neg(),t=f,d=o.neg(),i=h;else if(d&&2==++b)break;s=o,a=l,l=o,S=f,f=h,v=c,c=y}n=o.neg(),u=h;var A=d.sqr().add(i.sqr());return n.sqr().add(u.sqr()).cmp(A)>=0&&(n=e,u=t),d.negative&&(d=d.neg(),i=i.neg()),n.negative&&(n=n.neg(),u=u.neg()),[{a:d,b:i},{a:n,b:u}]},ShortCurve.prototype._endoSplit=function(r){var e=this.endo.basis,t=e[0],d=e[1],i=d.b.mul(r).divRound(this.n),n=t.b.neg().mul(r).divRound(this.n),u=i.mul(t.a),s=n.mul(d.a),o=i.mul(t.b),h=n.mul(d.b);return{k1:r.sub(u).sub(s),k2:o.add(h).neg()}},ShortCurve.prototype.pointFromX=function(r,e){(r=new BN(r,16)).red||(r=r.toRed(this.red));var t=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),d=t.redSqrt();if(0!==d.redSqr().redSub(t).cmp(this.zero))throw new Error("invalid point");var i=d.fromRed().isOdd();return(e&&!i||!e&&i)&&(d=d.redNeg()),this.point(r,d)},ShortCurve.prototype.validate=function(r){if(r.inf)return!0;var e=r.x,t=r.y,d=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(d).redIAdd(this.b);return 0===t.redSqr().redISub(i).cmpn(0)},ShortCurve.prototype._endoWnafMulAdd=function(r,e,t){for(var d=this._endoWnafT1,i=this._endoWnafT2,n=0;n":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(0===this.x.cmp(r.x))return this.curve.point(null,null);var e=this.y.redSub(r.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(r.x).redInvm()));var t=e.redSqr().redISub(this.x).redISub(r.x),d=e.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,d)},Point.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(0===r.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,t=this.x.redSqr(),d=r.redInvm(),i=t.redAdd(t).redIAdd(t).redIAdd(e).redMul(d),n=i.redSqr().redISub(this.x.redAdd(this.x)),u=i.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,u)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(r){return r=new BN(r,16),this.isInfinity()?this:this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},Point.prototype.mulAdd=function(r,e,t){var d=[this,e],i=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(d,i):this.curve._wnafMulAdd(1,d,i,2)},Point.prototype.jmulAdd=function(r,e,t){var d=[this,e],i=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(d,i,!0):this.curve._wnafMulAdd(1,d,i,2,!0)},Point.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||0===this.x.cmp(r.x)&&0===this.y.cmp(r.y))},Point.prototype.neg=function(r){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var t=this.precomputed,d=function(r){return r.neg()};e.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(d)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(d)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(r,e,t){return new JPoint(this,r,e,t)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),e=r.redSqr(),t=this.x.redMul(e),d=this.y.redMul(e).redMul(r);return this.curve.point(t,d)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var e=r.z.redSqr(),t=this.z.redSqr(),d=this.x.redMul(e),i=r.x.redMul(t),n=this.y.redMul(e.redMul(r.z)),u=r.y.redMul(t.redMul(this.z)),s=d.redSub(i),o=n.redSub(u);if(0===s.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),p=h.redMul(s),l=d.redMul(h),a=o.redSqr().redIAdd(p).redISub(l).redISub(l),f=o.redMul(l.redISub(a)).redISub(n.redMul(p)),c=this.z.redMul(r.z).redMul(s);return this.curve.jpoint(a,f,c)},JPoint.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var e=this.z.redSqr(),t=this.x,d=r.x.redMul(e),i=this.y,n=r.y.redMul(e).redMul(this.z),u=t.redSub(d),s=i.redSub(n);if(0===u.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var o=u.redSqr(),h=o.redMul(u),p=t.redMul(o),l=s.redSqr().redIAdd(h).redISub(p).redISub(p),a=s.redMul(p.redISub(l)).redISub(i.redMul(h)),f=this.z.redMul(u);return this.curve.jpoint(l,a,f)},JPoint.prototype.dblp=function(r){if(0===r)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var t=this;for(e=0;e=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},JPoint.prototype.inspect=function(){return this.isInfinity()?"":""},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}; -},{"../utils":166,"./base":153,"bn.js":167,"inherits":258}],158:[function(require,module,exports){ +},{"../utils":172,"./base":159,"bn.js":173,"inherits":264}],164:[function(require,module,exports){ "use strict";var pre,curves=exports,hash=require("hash.js"),curve=require("./curve"),utils=require("./utils"),assert=utils.assert;function PresetCurve(f){"short"===f.type?this.curve=new curve.short(f):"edwards"===f.type?this.curve=new curve.edwards(f):this.curve=new curve.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,assert(this.g.validate(),"Invalid curve"),assert(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(f,e){Object.defineProperty(curves,f,{configurable:!0,enumerable:!0,get:function(){var a=new PresetCurve(e);return Object.defineProperty(curves,f,{configurable:!0,enumerable:!0,value:a}),a}})}curves.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hash.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hash.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hash.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hash.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{pre=require("./precomputed/secp256k1")}catch(f){pre=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",pre]}); -},{"./curve":155,"./precomputed/secp256k1":165,"./utils":166,"hash.js":225}],159:[function(require,module,exports){ +},{"./curve":161,"./precomputed/secp256k1":171,"./utils":172,"hash.js":231}],165:[function(require,module,exports){ "use strict";var BN=require("bn.js"),HmacDRBG=require("hmac-drbg"),utils=require("../utils"),curves=require("../curves"),rand=require("brorand"),assert=utils.assert,KeyPair=require("./key"),Signature=require("./signature");function EC(r){if(!(this instanceof EC))return new EC(r);"string"==typeof r&&(assert(Object.prototype.hasOwnProperty.call(curves,r),"Unknown curve "+r),r=curves[r]),r instanceof curves.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}module.exports=EC,EC.prototype.keyPair=function(r){return new KeyPair(this,r)},EC.prototype.keyFromPrivate=function(r,e){return KeyPair.fromPrivate(this,r,e)},EC.prototype.keyFromPublic=function(r,e){return KeyPair.fromPublic(this,r,e)},EC.prototype.genKeyPair=function(r){r||(r={});for(var e=new HmacDRBG({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||rand(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),n=this.n.sub(new BN(2));;){var i=new BN(e.generate(t));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},EC.prototype._truncateToN=function(r,e){var t=8*r.byteLength()-this.n.bitLength();return t>0&&(r=r.ushrn(t)),!e&&r.cmp(this.n)>=0?r.sub(this.n):r},EC.prototype.sign=function(r,e,t,n){"object"==typeof t&&(n=t,t=null),n||(n={}),e=this.keyFromPrivate(e,t),r=this._truncateToN(new BN(r,16));for(var i=this.n.byteLength(),s=e.getPrivate().toArray("be",i),u=r.toArray("be",i),o=new HmacDRBG({hash:this.hash,entropy:s,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),a=this.n.sub(new BN(1)),c=0;;c++){var h=n.k?n.k(c):new BN(o.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(a)>=0)){var m=this.g.mul(h);if(!m.isInfinity()){var p=m.getX(),v=p.umod(this.n);if(0!==v.cmpn(0)){var y=h.invm(this.n).mul(v.mul(e.getPrivate()).iadd(r));if(0!==(y=y.umod(this.n)).cmpn(0)){var f=(m.getY().isOdd()?1:0)|(0!==p.cmp(v)?2:0);return n.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),f^=1),new Signature({r:v,s:y,recoveryParam:f})}}}}}},EC.prototype.verify=function(r,e,t,n){r=this._truncateToN(new BN(r,16)),t=this.keyFromPublic(t,n);var i=(e=new Signature(e,"hex")).r,s=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var u,o=s.invm(this.n),a=o.mul(r).umod(this.n),c=o.mul(i).umod(this.n);return this.curve._maxwellTrick?!(u=this.g.jmulAdd(a,t.getPublic(),c)).isInfinity()&&u.eqXToP(i):!(u=this.g.mulAdd(a,t.getPublic(),c)).isInfinity()&&0===u.getX().umod(this.n).cmp(i)},EC.prototype.recoverPubKey=function(r,e,t,n){assert((3&t)===t,"The recovery param is more than two bits"),e=new Signature(e,n);var i=this.n,s=new BN(r),u=e.r,o=e.s,a=1&t,c=t>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");u=c?this.curve.pointFromX(u.add(this.curve.n),a):this.curve.pointFromX(u,a);var h=e.r.invm(i),m=i.sub(s).mul(h).umod(i),p=o.mul(h).umod(i);return this.g.mulAdd(m,u,p)},EC.prototype.getKeyRecoveryParam=function(r,e,t,n){if(null!==(e=new Signature(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(r,e,i)}catch(r){continue}if(s.eq(t))return i}throw new Error("Unable to find valid recovery factor")}; -},{"../curves":158,"../utils":166,"./key":160,"./signature":161,"bn.js":167,"brorand":54,"hmac-drbg":240}],160:[function(require,module,exports){ +},{"../curves":164,"../utils":172,"./key":166,"./signature":167,"bn.js":173,"brorand":59,"hmac-drbg":246}],166:[function(require,module,exports){ "use strict";var BN=require("bn.js"),utils=require("../utils"),assert=utils.assert;function KeyPair(i,t){this.ec=i,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}module.exports=KeyPair,KeyPair.fromPublic=function(i,t,e){return t instanceof KeyPair?t:new KeyPair(i,{pub:t,pubEnc:e})},KeyPair.fromPrivate=function(i,t,e){return t instanceof KeyPair?t:new KeyPair(i,{priv:t,privEnc:e})},KeyPair.prototype.validate=function(){var i=this.getPublic();return i.isInfinity()?{result:!1,reason:"Invalid public key"}:i.validate()?i.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},KeyPair.prototype.getPublic=function(i,t){return"string"==typeof i&&(t=i,i=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,i):this.pub},KeyPair.prototype.getPrivate=function(i){return"hex"===i?this.priv.toString(16,2):this.priv},KeyPair.prototype._importPrivate=function(i,t){this.priv=new BN(i,t||16),this.priv=this.priv.umod(this.ec.curve.n)},KeyPair.prototype._importPublic=function(i,t){if(i.x||i.y)return"mont"===this.ec.curve.type?assert(i.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||assert(i.x&&i.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(i.x,i.y));this.pub=this.ec.curve.decodePoint(i,t)},KeyPair.prototype.derive=function(i){return i.validate()||assert(i.validate(),"public point not validated"),i.mul(this.priv).getX()},KeyPair.prototype.sign=function(i,t,e){return this.ec.sign(i,this,t,e)},KeyPair.prototype.verify=function(i,t){return this.ec.verify(i,t,this)},KeyPair.prototype.inspect=function(){return""}; -},{"../utils":166,"bn.js":167}],161:[function(require,module,exports){ +},{"../utils":172,"bn.js":173}],167:[function(require,module,exports){ "use strict";var BN=require("bn.js"),utils=require("../utils"),assert=utils.assert;function Signature(r,t){if(r instanceof Signature)return r;this._importDER(r,t)||(assert(r.r&&r.s,"Signature without r or s"),this.r=new BN(r.r,16),this.s=new BN(r.s,16),void 0===r.recoveryParam?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}function Position(){this.place=0}function getLength(r,t){var e=r[t.place++];if(!(128&e))return e;var n=15&e;if(0===n||n>4)return!1;for(var i=0,a=0,c=t.place;a>>=0;return!(i<=127)&&(t.place=c,i)}function rmPadding(r){for(var t=0,e=r.length-1;!r[t]&&!(128&r[t+1])&&t>>3);for(r.push(128|e);--e;)r.push(t>>>(e<<3)&255);r.push(t)}}module.exports=Signature,Signature.prototype._importDER=function(r,t){r=utils.toArray(r,t);var e=new Position;if(48!==r[e.place++])return!1;var n=getLength(r,e);if(!1===n)return!1;if(n+e.place!==r.length)return!1;if(2!==r[e.place++])return!1;var i=getLength(r,e);if(!1===i)return!1;var a=r.slice(e.place,i+e.place);if(e.place+=i,2!==r[e.place++])return!1;var c=getLength(r,e);if(!1===c)return!1;if(r.length!==c+e.place)return!1;var s=r.slice(e.place,c+e.place);if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new BN(a),this.s=new BN(s),this.recoveryParam=null,!0},Signature.prototype.toDER=function(r){var t=this.r.toArray(),e=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&e[0]&&(e=[0].concat(e)),t=rmPadding(t),e=rmPadding(e);!(e[0]||128&e[1]);)e=e.slice(1);var n=[2];constructLength(n,t.length),(n=n.concat(t)).push(2),constructLength(n,e.length);var i=n.concat(e),a=[48];return constructLength(a,i.length),a=a.concat(i),utils.encode(a,r)}; -},{"../utils":166,"bn.js":167}],162:[function(require,module,exports){ +},{"../utils":172,"bn.js":173}],168:[function(require,module,exports){ "use strict";var hash=require("hash.js"),curves=require("../curves"),utils=require("../utils"),assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require("./key"),Signature=require("./signature");function EDDSA(t){if(assert("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(t);t=curves[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hash.sha512}module.exports=EDDSA,EDDSA.prototype.sign=function(t,e){t=parseBytes(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),s=this.encodePoint(n),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),u=i.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:u,Rencoded:s})},EDDSA.prototype.verify=function(t,e,r){t=parseBytes(t),e=this.makeSignature(e);var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(s)},EDDSA.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(e>>1)-1?(e>>1)-o:o,s.isubn(u)):u=0,n[l]=u,s.iushrn(1)}return n}function getJSF(t,r){var i=[[],[]];t=t.clone(),r=r.clone();for(var n,e=0,s=0;t.cmpn(-e)>0||r.cmpn(-s)>0;){var l,u,o=t.andln(3)+e&3,a=r.andln(3)+s&3;3===o&&(o=-1),3===a&&(a=-1),l=0==(1&o)?0:3!==(n=t.andln(7)+e&7)&&5!==n||2!==a?o:-o,i[0].push(l),u=0==(1&a)?0:3!==(n=r.andln(7)+s&7)&&5!==n||2!==o?a:-a,i[1].push(u),2*e===l+1&&(e=1-e),2*s===u+1&&(s=1-s),t.iushrn(1),r.iushrn(1)}return i}function cachedProperty(t,r,i){var n="_"+r;t.prototype[r]=function(){return void 0!==this[n]?this[n]:this[n]=i.call(this)}}function parseBytes(t){return"string"==typeof t?utils.toArray(t,"hex"):t}function intFromLE(t){return new BN(t,"hex","le")}utils.assert=minAssert,utils.toArray=minUtils.toArray,utils.zero2=minUtils.zero2,utils.toHex=minUtils.toHex,utils.encode=minUtils.encode,utils.getNAF=getNAF,utils.getJSF=getJSF,utils.cachedProperty=cachedProperty,utils.parseBytes=parseBytes,utils.intFromLE=intFromLE; -},{"bn.js":167,"minimalistic-assert":343,"minimalistic-crypto-utils":344}],167:[function(require,module,exports){ +},{"bn.js":173,"minimalistic-assert":348,"minimalistic-crypto-utils":349}],173:[function(require,module,exports){ !function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function h(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,i,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var e;"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;try{e=require("buffer").Buffer}catch(t){}function o(t,i,r){for(var h=0,n=Math.min(t.length,r),e=i;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return h}function s(t,i,r,h){for(var n=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,h){if("number"==typeof t)return this._initNumber(t,i,h);if("object"==typeof t)return this._initArray(t,i,h);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===i?this._parseHex(t,n):this._parseBase(t,i,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initNumber=function(t,i,h){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initArray=function(t,i,h){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===h)for(n=0,e=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},n.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)n=o(t,r,r+6),this.words[h]|=n<>>26-e&4194303,(e+=24)>=26&&(e-=26,h++);r+6!==i&&(n=o(t,i,r+6),this.words[h]|=n<>>26-e&4194303),this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,u=Math.min(e,e-o)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}n.prototype.toString=function(t,i){var h;if(i=0|i||1,16===(t=t||10)||"hex"===t){h="";for(var n=0,e=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-m.length]+m+h:m+h,(n+=2)>=26&&(n-=26,o--)}for(0!==e&&(h=e.toString(16)+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}if(t===(0|t)&&t>=2&&t<=36){var f=a[t],d=l[t];h="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);h=(p=p.idivn(d)).isZero()?M+h:u[f-M.length]+M+h}for(this.isZero()&&(h="0"+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,h){var n=this.byteLength(),e=h||Math.max(1,n);r(n<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0"),this.strip();var o,s,u="le"===i,a=new t(e),l=this.clone();if(u){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),a[s]=o;for(;s=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;ht.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),h=t%26;this._expand(i),h>0&&i--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-h),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var h=t/26|0,n=t%26;return this._expand(h+1),this.words[h]=i?this.words[h]|1<t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e>>26;for(;0!==n&&e>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],R=8191&q,B=q>>>13,N=0|o[7],L=8191&N,I=N>>>13,z=0|o[8],T=8191&z,E=z>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,C=P>>>13,D=0|s[1],H=8191&D,J=D>>>13,U=0|s[2],G=8191&U,Q=U>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(h=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,F),n=(n=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,F),n=(n=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|0;var ct=(a+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,F),n=(n=Math.imul(y,C))+Math.imul(b,F)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,F),n=(n=Math.imul(k,C))+Math.imul(A,F)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(S,F),n=(n=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(R,F),n=(n=Math.imul(R,C))+Math.imul(B,F)|0,e=Math.imul(B,C),h=h+Math.imul(S,H)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(a+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(L,F),n=(n=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),h=h+Math.imul(R,H)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(B,H)|0,e=e+Math.imul(B,J)|0,h=h+Math.imul(S,G)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(T,F),n=(n=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),h=h+Math.imul(L,H)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,h=h+Math.imul(R,G)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(B,G)|0,e=e+Math.imul(B,Q)|0,h=h+Math.imul(S,W)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,F),n=(n=Math.imul(j,C))+Math.imul(K,F)|0,e=Math.imul(K,C),h=h+Math.imul(T,H)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,h=h+Math.imul(L,G)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,h=h+Math.imul(R,W)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(B,W)|0,e=e+Math.imul(B,X)|0,h=h+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var xt=(a+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),h=h+Math.imul(T,G)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(L,W)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,h=h+Math.imul(R,$)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,tt)|0,h=h+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var St=(a+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(T,W)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,h=h+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(B,rt)|0,e=e+Math.imul(B,ht)|0,h=h+Math.imul(S,et)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var Zt=(a+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,ht)|0,h=h+Math.imul(R,et)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(B,et)|0,e=e+Math.imul(B,ot)|0,h=h+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var qt=(a+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(L,et)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,h=h+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(B,ut)|0,e=e+Math.imul(B,at)|0,h=h+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Rt=(a+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(T,et)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,h=h+Math.imul(R,mt)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(B,mt)|0,e=e+Math.imul(B,ft)|0;var Bt=(a+(h=h+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,h=h+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(h=h+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,Mt)|0)+Math.imul(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),h=h+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(h=h+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(h=h+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(a+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=xt,u[10]=St,u[11]=Zt,u[12]=qt,u[13]=Rt,u[14]=Bt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function d(t,i,r){return(new p).mulp(t,i,r)}function p(t,i){this.x=t,this.y=i}Math.imul||(f=m),n.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,i):r<63?m(this,t,i):r<1024?function(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r.strip()}(this,t,i):d(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),r=n.prototype._countBits(t)-1,h=0;h>=1;return h},p.prototype.permute=function(t,i,r,h,n,e){for(var o=0;o>>=1)n++;return 1<>>=13,h[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,i+=n/67108864|0,i+=e>>>26,this.words[h]=67108863&e}return 0!==i&&(this.words[h]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r>>n}return i}(t);if(0===i.length)return new n(1);for(var r=this,h=0;h=0);var i,h=t%26,n=(t-h)/26,e=67108863>>>26-h<<26-h;if(0!==h){var o=0;for(i=0;i>>26-h}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,h){return r(0===this.negative),this.iushrn(t,i,h)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,h=(t-i)/26,n=1<=0);var i=t%26,h=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=h)return this;if(0!==i&&h++,this.length=Math.min(h,this.length),0!==i){var n=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[n+h]=67108863&e}for(;n>26,this.words[n+h]=67108863&e;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&e;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),h.iushln(r),o=0|e.words[e.length-1]);var s,u=h.length-e.length;if("mod"!==i){(s=new n(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|h.words[e.length+m])+(0|h.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(e,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(e,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s.strip(),h.strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},n.prototype.divmod=function(t,i,h){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i);var e,o,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,h=0,n=this.length-1;n>=0;n--)h=(i*h+(0|this.words[n]))%t;return h},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,h=this.length-1;h>=0;h--){var n=(0|this.words[h])+67108864*i;this.words[h]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=new n(0),u=new n(1),a=0;i.isEven()&&h.isEven();)i.iushrn(1),h.iushrn(1),++a;for(var l=h.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(h.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(h.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(s),o.isub(u)):(h.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:h.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e,o=new n(1),s=new n(0),u=h.clone();i.cmpn(1)>0&&h.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(h.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(h.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(h)>=0?(i.isub(h),o.isub(s)):(h.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,h=(t-i)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,h=t<0;if(0!==this.negative&&!h)return-1;if(0===this.negative&&h)return 1;if(this.strip(),this.length>1)i=1;else{h&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:nt.length)return 1;if(this.length=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){hn&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new b(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},h(g,v),g.prototype.split=function(t,i){for(var r=Math.min(t.length,9),h=0;h>>22,n=e}n>>>=22,t.words[h-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(M[t])return M[t];var i;if("k256"===t)i=new g;else if("p224"===t)i=new c;else if("p192"===t)i=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new y}return M[t]=i,i},b.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},b.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var h=this.m.add(new n(1)).iushrn(2);return this.pow(t,h)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new n(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;h--){for(var a=i.words[h],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===h&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new _(t)},h(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(h).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":55}],168:[function(require,module,exports){ +},{"buffer":60}],174:[function(require,module,exports){ module.exports={ "name": "elliptic", "version": "6.5.4", @@ -1003,339 +1029,341 @@ module.exports={ } } -},{}],169:[function(require,module,exports){ +},{}],175:[function(require,module,exports){ "use strict";const anyMap=new WeakMap,eventsMap=new WeakMap,producersMap=new WeakMap,anyProducer=Symbol("anyProducer"),resolvedPromise=Promise.resolve(),listenerAdded=Symbol("listenerAdded"),listenerRemoved=Symbol("listenerRemoved");function assertEventName(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new TypeError("eventName must be a string or a symbol")}function assertListener(e){if("function"!=typeof e)throw new TypeError("listener must be a function")}function getListeners(e,t){const r=eventsMap.get(e);return r.has(t)||r.set(t,new Set),r.get(t)}function getEventProducers(e,t){const r="string"==typeof t?t:anyProducer,s=producersMap.get(e);return s.has(r)||s.set(r,new Set),s.get(r)}function enqueueProducers(e,t,r){const s=producersMap.get(e);if(s.has(t))for(const e of s.get(t))e.enqueue(r);if(s.has(anyProducer)){const e=Promise.all([t,r]);for(const t of s.get(anyProducer))t.enqueue(e)}}function iterator(e,t){let r=!1,s=()=>{},n=[];const o={enqueue(e){n.push(e),s()},finish(){r=!0,s()}};return getEventProducers(e,t).add(o),{async next(){return n?0===n.length?r?(n=void 0,this.next()):(await new Promise(e=>{s=e}),this.next()):{done:!1,value:await n.shift()}:{done:!0}},async return(r){return n=void 0,getEventProducers(e,t).delete(o),s(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function defaultMethodNamesOrAssert(e){if(void 0===e)return allEmitteryMethods;if(!Array.isArray(e))throw new TypeError("`methodNames` must be an array of strings");for(const t of e)if(!allEmitteryMethods.includes(t)){if("string"!=typeof t)throw new TypeError("`methodNames` element must be a string");throw new Error(`${t} is not Emittery method`)}return e}const isListenerSymbol=e=>e===listenerAdded||e===listenerRemoved;class Emittery{static mixin(e,t){return t=defaultMethodNamesOrAssert(t),r=>{if("function"!=typeof r)throw new TypeError("`target` must be function");for(const e of t)if(void 0!==r.prototype[e])throw new Error(`The property \`${e}\` already exists on \`target\``);Object.defineProperty(r.prototype,e,{enumerable:!1,get:function(){return Object.defineProperty(this,e,{enumerable:!1,value:new Emittery}),this[e]}});const s=t=>(function(...r){return this[e][t](...r)});for(const e of t)Object.defineProperty(r.prototype,e,{enumerable:!1,value:s(e)});return r}}constructor(){anyMap.set(this,new Set),eventsMap.set(this,new Map),producersMap.set(this,new Map)}on(e,t){return assertEventName(e),assertListener(t),getListeners(this,e).add(t),isListenerSymbol(e)||this.emit(listenerAdded,{eventName:e,listener:t}),this.off.bind(this,e,t)}off(e,t){assertEventName(e),assertListener(t),isListenerSymbol(e)||this.emit(listenerRemoved,{eventName:e,listener:t}),getListeners(this,e).delete(t)}once(e){return new Promise(t=>{assertEventName(e);const r=this.on(e,e=>{r(),t(e)})})}events(e){return assertEventName(e),iterator(this,e)}async emit(e,t){assertEventName(e),enqueueProducers(this,e,t);const r=getListeners(this,e),s=anyMap.get(this),n=[...r],o=isListenerSymbol(e)?[]:[...s];return await resolvedPromise,Promise.all([...n.map(async e=>{if(r.has(e))return e(t)}),...o.map(async r=>{if(s.has(r))return r(e,t)})])}async emitSerial(e,t){assertEventName(e);const r=getListeners(this,e),s=anyMap.get(this),n=[...r],o=[...s];await resolvedPromise;for(const e of n)r.has(e)&&await e(t);for(const r of o)s.has(r)&&await r(e,t)}onAny(e){return assertListener(e),anyMap.get(this).add(e),this.emit(listenerAdded,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return iterator(this)}offAny(e){assertListener(e),this.emit(listenerRemoved,{listener:e}),anyMap.get(this).delete(e)}clearListeners(e){if("string"==typeof e){getListeners(this,e).clear();const t=getEventProducers(this,e);for(const e of t)e.finish();t.clear()}else{anyMap.get(this).clear();for(const e of eventsMap.get(this).values())e.clear();for(const e of producersMap.get(this).values()){for(const t of e)t.finish();e.clear()}}}listenerCount(e){if("string"==typeof e)return anyMap.get(this).size+getListeners(this,e).size+getEventProducers(this,e).size+getEventProducers(this).size;void 0!==e&&assertEventName(e);let t=anyMap.get(this).size;for(const e of eventsMap.get(this).values())t+=e.size;for(const e of producersMap.get(this).values())t+=e.size;return t}bindMethods(e,t){if("object"!=typeof e||null===e)throw new TypeError("`target` must be an object");t=defaultMethodNamesOrAssert(t);for(const r of t){if(void 0!==e[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(e,r,{enumerable:!1,value:this[r].bind(this)})}}}const allEmitteryMethods=Object.getOwnPropertyNames(Emittery.prototype).filter(e=>"constructor"!==e);Emittery.Typed=class extends Emittery{},Object.defineProperty(Emittery.Typed,"Typed",{enumerable:!1,value:void 0}),Object.defineProperty(Emittery,"listenerAdded",{value:listenerAdded,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Emittery,"listenerRemoved",{value:listenerRemoved,writable:!1,enumerable:!0,configurable:!1}),module.exports=Emittery; -},{}],170:[function(require,module,exports){ +},{}],176:[function(require,module,exports){ "use strict";var AbstractLevelDOWN=require("abstract-leveldown").AbstractLevelDOWN,AbstractChainedBatch=require("abstract-leveldown").AbstractChainedBatch,AbstractIterator=require("abstract-leveldown").AbstractIterator,inherits=require("inherits"),Codec=require("level-codec"),EncodingError=require("level-errors").EncodingError,rangeMethods=["approximateSize","compactRange"];function DB(t,e){if(!(this instanceof DB))return new DB(t,e);var o=t.supports||{},c=o.additionalMethods||{};AbstractLevelDOWN.call(this,o),this.supports.encodings=!0,this.supports.additionalMethods={},rangeMethods.forEach(function(e){var o="function"==typeof t[e];(c[e]||o)&&(this.supports.additionalMethods[e]=!0,this[e]=function(t,o,c,i){return t=this.codec.encodeKey(t,c),o=this.codec.encodeKey(o,c),this.db[e](t,o,c,i)})},this),void 0===(e=e||{}).keyEncoding&&(e.keyEncoding="utf8"),void 0===e.valueEncoding&&(e.valueEncoding="utf8"),this.db=t,this.codec=new Codec(e)}function Iterator(t,e){AbstractIterator.call(this,t),this.codec=t.codec,this.keys=e.keys,this.values=e.values,this.opts=this.codec.encodeLtgt(e),this.it=t.db.iterator(this.opts)}function Batch(t,e){AbstractChainedBatch.call(this,t),this.codec=t.codec,this.batch=t.db.batch()}module.exports=DB.default=DB,inherits(DB,AbstractLevelDOWN),DB.prototype.type="encoding-down",DB.prototype._serializeKey=DB.prototype._serializeValue=function(t){return t},DB.prototype._open=function(t,e){this.db.open(t,e)},DB.prototype._close=function(t){this.db.close(t)},DB.prototype._put=function(t,e,o,c){t=this.codec.encodeKey(t,o),e=this.codec.encodeValue(e,o),this.db.put(t,e,o,c)},DB.prototype._get=function(t,e,o){var c=this;t=this.codec.encodeKey(t,e),e.asBuffer=this.codec.valueAsBuffer(e),this.db.get(t,e,function(t,i){if(t)return o(t);try{i=c.codec.decodeValue(i,e)}catch(t){return o(new EncodingError(t))}o(null,i)})},DB.prototype._del=function(t,e,o){t=this.codec.encodeKey(t,e),this.db.del(t,e,o)},DB.prototype._chainedBatch=function(){return new Batch(this)},DB.prototype._batch=function(t,e,o){t=this.codec.encodeBatch(t,e),this.db.batch(t,e,o)},DB.prototype._iterator=function(t){return t.keyAsBuffer=this.codec.keyAsBuffer(t),t.valueAsBuffer=this.codec.valueAsBuffer(t),new Iterator(this,t)},DB.prototype._clear=function(t,e){t=this.codec.encodeLtgt(t),this.db.clear(t,e)},inherits(Iterator,AbstractIterator),Iterator.prototype._next=function(t){var e=this;this.it.next(function(o,c,i){if(o)return t(o);try{c=e.keys&&void 0!==c?e.codec.decodeKey(c,e.opts):void 0,i=e.values&&void 0!==i?e.codec.decodeValue(i,e.opts):void 0}catch(o){return t(new EncodingError(o))}t(null,c,i)})},Iterator.prototype._seek=function(t){t=this.codec.encodeKey(t,this.opts),this.it.seek(t)},Iterator.prototype._end=function(t){this.it.end(t)},inherits(Batch,AbstractChainedBatch),Batch.prototype._put=function(t,e){t=this.codec.encodeKey(t),e=this.codec.encodeValue(e),this.batch.put(t,e)},Batch.prototype._del=function(t){t=this.codec.encodeKey(t),this.batch.del(t)},Batch.prototype._clear=function(){this.batch.clear()},Batch.prototype._write=function(t,e){this.batch.write(t,e)}; -},{"abstract-leveldown":17,"inherits":258,"level-codec":171,"level-errors":298}],171:[function(require,module,exports){ +},{"abstract-leveldown":17,"inherits":264,"level-codec":177,"level-errors":304}],177:[function(require,module,exports){ var encodings=require("./lib/encodings");function Codec(e){if(!(this instanceof Codec))return new Codec(e);this.opts=e||{},this.encodings=encodings}module.exports=Codec,Codec.prototype._encoding=function(e){return"string"==typeof e&&(e=encodings[e]),e||(e=encodings.id),e},Codec.prototype._keyEncoding=function(e,n){return this._encoding(n&&n.keyEncoding||e&&e.keyEncoding||this.opts.keyEncoding)},Codec.prototype._valueEncoding=function(e,n){return this._encoding(n&&(n.valueEncoding||n.encoding)||e&&(e.valueEncoding||e.encoding)||this.opts.valueEncoding||this.opts.encoding)},Codec.prototype.encodeKey=function(e,n,o){return this._keyEncoding(n,o).encode(e)},Codec.prototype.encodeValue=function(e,n,o){return this._valueEncoding(n,o).encode(e)},Codec.prototype.decodeKey=function(e,n){return this._keyEncoding(n).decode(e)},Codec.prototype.decodeValue=function(e,n){return this._valueEncoding(n).decode(e)},Codec.prototype.encodeBatch=function(e,n){var o=this;return e.map(function(e){var t={type:e.type,key:o.encodeKey(e.key,n,e)};return o.keyAsBuffer(n,e)&&(t.keyEncoding="binary"),e.prefix&&(t.prefix=e.prefix),"value"in e&&(t.value=o.encodeValue(e.value,n,e),o.valueAsBuffer(n,e)&&(t.valueEncoding="binary")),t})};var ltgtKeys=["lt","gt","lte","gte","start","end"];Codec.prototype.encodeLtgt=function(e){var n=this,o={};return Object.keys(e).forEach(function(t){o[t]=ltgtKeys.indexOf(t)>-1?n.encodeKey(e[t],e):e[t]}),o},Codec.prototype.createStreamDecoder=function(e){var n=this;return e.keys&&e.values?function(o,t){return{key:n.decodeKey(o,e),value:n.decodeValue(t,e)}}:e.keys?function(o){return n.decodeKey(o,e)}:e.values?function(o,t){return n.decodeValue(t,e)}:function(){}},Codec.prototype.keyAsBuffer=function(e){return this._keyEncoding(e).buffer},Codec.prototype.valueAsBuffer=function(e){return this._valueEncoding(e).buffer}; -},{"./lib/encodings":172}],172:[function(require,module,exports){ +},{"./lib/encodings":178}],178:[function(require,module,exports){ var Buffer=require("buffer").Buffer;exports.utf8=exports["utf-8"]={encode:function(e){return isBinary(e)?e:String(e)},decode:identity,buffer:!1,type:"utf8"},exports.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},exports.binary={encode:function(e){return isBinary(e)?e:Buffer.from(e)},decode:identity,buffer:!0,type:"binary"},exports.none={encode:identity,decode:identity,buffer:!1,type:"id"},exports.id=exports.none;var bufferEncodings=["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"];function identity(e){return e}function isBinary(e){return null==e||Buffer.isBuffer(e)}bufferEncodings.forEach(function(e){exports[e]={encode:function(r){return isBinary(r)?r:Buffer.from(r,e)},decode:function(r){return r.toString(e)},buffer:!0,type:e}}); -},{"buffer":99}],173:[function(require,module,exports){ +},{"buffer":104}],179:[function(require,module,exports){ var eos=require("end-of-stream");module.exports=function(e,o={}){return new Promise((r,n)=>{eos(e,o,function(e){e?n(e):r()})})}; -},{"end-of-stream":174}],174:[function(require,module,exports){ +},{"end-of-stream":180}],180:[function(require,module,exports){ (function (process){(function (){ var once=require("once"),noop=function(){},isRequest=function(e){return e.setHeader&&"function"==typeof e.abort},isChildProcess=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},eos=function(e,r,n){if("function"==typeof r)return eos(e,null,r);r||(r={}),n=once(n||noop);var o=e._writableState,t=e._readableState,i=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,c=!1,l=function(){e.writable||a()},a=function(){s=!1,i||n.call(e)},u=function(){i=!1,s||n.call(e)},d=function(r){n.call(e,r?new Error("exited with error code: "+r):null)},f=function(r){n.call(e,r)},m=function(){process.nextTick(v)},v=function(){if(!c)return(!i||t&&t.ended&&!t.destroyed)&&(!s||o&&o.ended&&!o.destroyed)?void 0:n.call(e,new Error("premature close"))},b=function(){e.req.on("finish",a)};return isRequest(e)?(e.on("complete",a),e.on("abort",m),e.req?b():e.on("request",b)):s&&!o&&(e.on("end",l),e.on("close",l)),isChildProcess(e)&&e.on("exit",d),e.on("end",u),e.on("finish",a),!1!==r.error&&e.on("error",f),e.on("close",m),function(){c=!0,e.removeListener("complete",a),e.removeListener("abort",m),e.removeListener("request",b),e.req&&e.req.removeListener("finish",a),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",a),e.removeListener("exit",d),e.removeListener("end",u),e.removeListener("error",f),e.removeListener("close",m)}};module.exports=eos; }).call(this)}).call(this,require('_process')) -},{"_process":443,"once":406}],175:[function(require,module,exports){ +},{"_process":449,"once":412}],181:[function(require,module,exports){ "use strict";module.exports=function(e){const{note:r,getReceive:t,getReplicate:i,getSequence:n}=e;var c={note:r,getReceive:t,getReplicate:i,getSequence:n};function o(e,r,t){return e.blocks[r]&&e.blocks[r][t]}function l(e,r,t){return e.follows[r]&&!o(e,r,t)}function s(e,r,i){for(var n in e.peers)if(n!==i){var c=e.peers[n];if(c.notes&&t(c.notes[n]))return n;var o=c.replicating&&c.replicating[n]&&-1!=c.replicating[n].sent;if(c.replicating&&c.replicating[r]&&c.replicating[r].rx&&o)return n}return!1}function a(e,r,t){for(var i in e.peers)if(i!=t){var n=e.peers[i];if((n.clock&&n.clock[r]||0)>(e.clock[r]||0)&&l(e,r,i))return!0}}function u(e,r,t){var i=e.indexOf(r);if(~i)for(var n=1;nf?(u.msgs.push(r),g.sent++):(n=s,-1!==(o=f)&&(null==o||n>o)&&(g?!g.tx&&null!=g.sent:e.follows[t])&&p(u,t,i,!1))}}return e},c.receive=function(e,r){var t=r.value;if(!e.peers[r.id])throw new Error("lost peer state:"+r.id);const i=c.getMsgAuthor(t),n=c.getMsgSequence(t);var o=e.peers[r.id],s=o.replicating[i];return s?(o.clock[i]=Math.max(o.clock[i],n),s.sent=Math.max(s.sent,n),e.clock[i]>=n?(s.rx&&p(o,i,e.clock[i],!1),e):(e.peers[r.id].ts=r.ts,l(e,c.getMsgAuthor(r.value),r.id)&&e.receive.push(r),e)):e},c.notes=function(e,r){var o,a=r.value;(o=r.value.clock)&&"object"==typeof o&&(a=r.value.clock);var u=e.peers[r.id];if(!u)throw new Error("lost state of peer:"+r.id);if(!u.clock)throw new Error("received notes, but has not set the peer's clock yet");var f,g,v=0;for(var d in u.replicating||(u.replicating={},e=c.peerClock(e,{id:r.id,value:e.peers[r.id].clock})),a){v++;var k=u.clock[d]=(f=u.clock[d],g=n(a[d]),null==f?g:-1==f||-1==g?g:0==g?0:g>0&&f>0&&gb)if(q){var M=e.peers[q];k>(M.clock[d]||0)&&(u.ts=r.ts,p(u,d,b,!0),p(M,d,b,!1))}else u.ts=r.ts,p(u,d,b,!0)}else w=u.replicating[d]={tx:!0,rx:!0,sent:k,requested:b},p(u,d,b,bk&&(x?u.retrive.push(d):h&&p(u,d,b,w.rx))}else u.replicating[d]||p(u,d,-1),u.replicating[d]={tx:!1,rx:!1,sent:-1,requested:-1}}return u.recvNotes=(u.recvNotes||0)+v,e},c.timeout=function(e,r){var t={};for(var i in e.peers){var n=e.peers[i];if((n.ts||0)+e.timeoute.clock[l])return i.replicating=i.replicating||{},i.replicating[l]=i.replicating[l]||{tx:!1,rx:!0,sent:-1,requested:e.clock[l]},p(i,l,e.clock[l],!0),i.ts=r.ts,!0})}return e},c.block=function(e,r){for(var t in r.value?(e.blocks[r.id]=e.blocks[r.id]||{},e.blocks[r.id][r.target]=!0):(e.blocks[r.id]&&delete e.blocks[r.id][r.target],function(e){for(var r in e)return!1;return!0}(e.blocks[r.id])&&delete e.blocks[r.id]),e.id===r.id&&e.peers[r.target]&&(e.peers[r.target].blocked=r.value),e.peers){var i=e.peers[t];i.replicating&&(t===r.target&&i.replicating[r.id]&&p(i,r.id,-1,!1))}return e},c}; -},{}],176:[function(require,module,exports){ -var events=require("./events")(require("./v3")),Stream=require("./stream")(events),progress=require("./progress");function timestamp(){return Date.now()}function createValidate(e){return function(t){for(var r in t)if(!e(r)){var s={};for(var n in t)e(n)&&(s[n]=t[n]);return s}return t}}module.exports=function(e){var t=events.initialize(e.id,e.getMsgAuthor,e.getMsgSequence);t.timeout=e.timeout||3e3,t.clock={},e.isMsg||(e.isMsg=function(e){return Number.isInteger(e.sequence)&&e.sequence>0&&"string"==typeof e.author&&e.content});var r={id:e.id,streams:{},state:t,logging:e.logging,progress:function(){return progress(t)},request:function(t,s){e.isFeed&&!e.isFeed(t)||(r.state=events.follow(r.state,{id:t,value:!1!==s,ts:timestamp()}),r.update())},pause:function(e,t){r.state=events.pause(r.state,{id:e,paused:!1!==t}),r.update()},block:function(e,t,s){r.state=events.block(r.state,{id:e,target:t,value:!1!==s,ts:timestamp()}),r.update()},createStream:function(t,s,n){this.streams[t]&&this.streams[t].end(new Error("reconnected to peer")),this.logging&&console.log("EBT:conn",t);var i=this.streams[t]=new Stream(this,t,s,n,e.isMsg,function(r){e.setClock(t,r.clock)});return e.isFeed&&(i._validate=createValidate(e.isFeed)),e.getClock(t,function(e,s){r.state.peers[t]&&i.clock(e?{}:s)}),i},_retrive:function(e,t){t?(r.state=events.retrive(r.state,t),r.update()):console.log("could not retrive msg:",e)},onAppend:function(e){r.state=events.append(r.state,e),r.update()},update:function(){for(var t in this.state.peers)for(var s=this.state.peers[t];s.retrive.length;){var n=s.retrive.shift();s.replicating[n]&&e.getAt({id:n,sequence:s.replicating[n].sent+1},this._retrive)}if(this.state.receive.length){var i=this.state.receive.shift();e.append(i.value,function(e){e?(this.logging&&console.error("EBT:err",e),r.block(i.value.author,i.id,!0)):r.onAppend(i.value)})}for(var a in this.streams)this.streams[a].resume()}},s=setInterval(function(){r.state=events.timeout(r.state,{ts:timestamp()}),r.update()},t.timeout);return s.unref&&s.unref(),r}; +},{}],182:[function(require,module,exports){ +const Events=require("./events"),v3=require("./v3"),StreamModule=require("./stream"),progress=require("./progress");function timestamp(){return Date.now()}module.exports=function(e){const t=Events(v3),r=StreamModule(t);var s=t.initialize(e.id,e.getMsgAuthor,e.getMsgSequence);s.timeout=e.timeout||3e3,s.clock={},e.isMsg||(e.isMsg=function(e){return Number.isInteger(e.sequence)&&e.sequence>0&&"string"==typeof e.author&&e.content});var n={id:e.id,streams:{},state:s,logging:e.logging,progress:function(){return progress(s)},request:function(r,s){e.isFeed&&!e.isFeed(r)||(n.state=t.follow(n.state,{id:r,value:!1!==s,ts:timestamp()}),n.update())},pause:function(e,r){n.state=t.pause(n.state,{id:e,paused:!1!==r}),n.update()},block:function(e,r,s){n.state=t.block(n.state,{id:e,target:r,value:!1!==s,ts:timestamp()}),n.update()},createStream:function(t,s,i){n.streams[t]&&n.streams[t].end(new Error("reconnected to peer")),n.logging&&console.log("EBT:conn",t);var o=n.streams[t]=new r(this,t,s,i,e.isMsg,function(r){e.setClock(t,r.clock)});return e.getClock(t,function(e,r){n.state.peers[t]&&o.clock(e?{}:r)}),o},_retrive:function(e,r){r?(n.state=t.retrive(n.state,r),n.update()):console.log("could not retrive msg:",e)},onAppend:function(e){n.state=t.append(n.state,e),n.update()},update:function(){for(var t in n.state.peers)for(var r=n.state.peers[t];r.retrive.length;){var s=r.retrive.shift();r.replicating[s]&&e.getAt({id:s,sequence:r.replicating[s].sent+1},n._retrive)}if(n.state.receive.length){var i=n.state.receive.shift();e.append(i.value,function(e){e&&(n.logging&&console.error("EBT:err",e),n.block(i.value.author,i.id,!0))})}for(var o in n.streams)n.streams[o].resume()}},i=setInterval(function(){n.state=t.timeout(n.state,{ts:timestamp()}),n.update()},s.timeout);return i.unref&&i.unref(),n}; -},{"./events":175,"./progress":177,"./stream":178,"./v3":179}],177:[function(require,module,exports){ +},{"./events":181,"./progress":183,"./stream":184,"./v3":185}],183:[function(require,module,exports){ module.exports=function(r){var e={start:0,current:0,target:0};for(var t in r.peers){var n=r.peers[t];for(var u in n.replicating){var a=n.replicating[u];e.target++,null!=a.sent&&e.current++,e.target++,null!=a.requested&&e.current++;var c=n.clock[u],l=r.clock[u]||0;a.rx&&null!=a.requested&&a.requested>-1&&l-1&&c>1:-1},exports.getReplicate=function(e){return-1!==e},exports.getReceive=function(e){return!(1&e)}; -},{}],180:[function(require,module,exports){ +},{}],186:[function(require,module,exports){ "use strict";function assign(e,r){for(const t in r)Object.defineProperty(e,t,{value:r[t],enumerable:!0,configurable:!0});return e}function createError(e,r,t){if(!e||"string"==typeof e)throw new TypeError("Please pass an Error to err-code");t||(t={}),"object"==typeof r&&(t=r,r=void 0),null!=r&&(t.code=r);try{return assign(e,t)}catch(r){t.message=e.message,t.stack=e.stack;const o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),assign(new o,t)}}module.exports=createError; -},{}],181:[function(require,module,exports){ +},{}],187:[function(require,module,exports){ var prr=require("prr");function init(r,t,e){t&&"string"!=typeof t&&(t=t.message||t.name),prr(this,{type:r,name:r,cause:"string"!=typeof t?t:e,message:t},"ewr")}function CustomError(r,t){Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),init.call(this,"CustomError",r,t)}function createError(r,t,e){var s=function(e,o){init.call(this,t,e,o),"FilesystemError"==t&&(this.code=this.cause.code,this.path=this.cause.path,this.errno=this.cause.errno,this.message=(r.errno[this.cause.errno]?r.errno[this.cause.errno].description:this.cause.message)+(this.cause.path?" ["+this.cause.path+"]":"")),Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,s)};return s.prototype=e?new e:new CustomError,s}CustomError.prototype=new Error,module.exports=function(r){var t=function(t,e){return createError(r,t,e)};return{CustomError:CustomError,FilesystemError:t("FilesystemError"),createError:t}}; -},{"prr":453}],182:[function(require,module,exports){ +},{"prr":459}],188:[function(require,module,exports){ var all=module.exports.all=[{errno:-2,code:"ENOENT",description:"no such file or directory"},{errno:-1,code:"UNKNOWN",description:"unknown error"},{errno:0,code:"OK",description:"success"},{errno:1,code:"EOF",description:"end of file"},{errno:2,code:"EADDRINFO",description:"getaddrinfo error"},{errno:3,code:"EACCES",description:"permission denied"},{errno:4,code:"EAGAIN",description:"resource temporarily unavailable"},{errno:5,code:"EADDRINUSE",description:"address already in use"},{errno:6,code:"EADDRNOTAVAIL",description:"address not available"},{errno:7,code:"EAFNOSUPPORT",description:"address family not supported"},{errno:8,code:"EALREADY",description:"connection already in progress"},{errno:9,code:"EBADF",description:"bad file descriptor"},{errno:10,code:"EBUSY",description:"resource busy or locked"},{errno:11,code:"ECONNABORTED",description:"software caused connection abort"},{errno:12,code:"ECONNREFUSED",description:"connection refused"},{errno:13,code:"ECONNRESET",description:"connection reset by peer"},{errno:14,code:"EDESTADDRREQ",description:"destination address required"},{errno:15,code:"EFAULT",description:"bad address in system call argument"},{errno:16,code:"EHOSTUNREACH",description:"host is unreachable"},{errno:17,code:"EINTR",description:"interrupted system call"},{errno:18,code:"EINVAL",description:"invalid argument"},{errno:19,code:"EISCONN",description:"socket is already connected"},{errno:20,code:"EMFILE",description:"too many open files"},{errno:21,code:"EMSGSIZE",description:"message too long"},{errno:22,code:"ENETDOWN",description:"network is down"},{errno:23,code:"ENETUNREACH",description:"network is unreachable"},{errno:24,code:"ENFILE",description:"file table overflow"},{errno:25,code:"ENOBUFS",description:"no buffer space available"},{errno:26,code:"ENOMEM",description:"not enough memory"},{errno:27,code:"ENOTDIR",description:"not a directory"},{errno:28,code:"EISDIR",description:"illegal operation on a directory"},{errno:29,code:"ENONET",description:"machine is not on the network"},{errno:31,code:"ENOTCONN",description:"socket is not connected"},{errno:32,code:"ENOTSOCK",description:"socket operation on non-socket"},{errno:33,code:"ENOTSUP",description:"operation not supported on socket"},{errno:34,code:"ENOENT",description:"no such file or directory"},{errno:35,code:"ENOSYS",description:"function not implemented"},{errno:36,code:"EPIPE",description:"broken pipe"},{errno:37,code:"EPROTO",description:"protocol error"},{errno:38,code:"EPROTONOSUPPORT",description:"protocol not supported"},{errno:39,code:"EPROTOTYPE",description:"protocol wrong type for socket"},{errno:40,code:"ETIMEDOUT",description:"connection timed out"},{errno:41,code:"ECHARSET",description:"invalid Unicode character"},{errno:42,code:"EAIFAMNOSUPPORT",description:"address family for hostname not supported"},{errno:44,code:"EAISERVICE",description:"servname not supported for ai_socktype"},{errno:45,code:"EAISOCKTYPE",description:"ai_socktype not supported"},{errno:46,code:"ESHUTDOWN",description:"cannot send after transport endpoint shutdown"},{errno:47,code:"EEXIST",description:"file already exists"},{errno:48,code:"ESRCH",description:"no such process"},{errno:49,code:"ENAMETOOLONG",description:"name too long"},{errno:50,code:"EPERM",description:"operation not permitted"},{errno:51,code:"ELOOP",description:"too many symbolic links encountered"},{errno:52,code:"EXDEV",description:"cross-device link not permitted"},{errno:53,code:"ENOTEMPTY",description:"directory not empty"},{errno:54,code:"ENOSPC",description:"no space left on device"},{errno:55,code:"EIO",description:"i/o error"},{errno:56,code:"EROFS",description:"read-only file system"},{errno:57,code:"ENODEV",description:"no such device"},{errno:58,code:"ESPIPE",description:"invalid seek"},{errno:59,code:"ECANCELED",description:"operation canceled"}];module.exports.errno={},module.exports.code={},all.forEach(function(e){module.exports.errno[e.errno]=e,module.exports.code[e.code]=e}),module.exports.custom=require("./custom")(module.exports),module.exports.create=module.exports.custom.createError; -},{"./custom":181}],183:[function(require,module,exports){ +},{"./custom":187}],189:[function(require,module,exports){ "use strict";module.exports=require("call-bind"); -},{"call-bind":107}],184:[function(require,module,exports){ +},{"call-bind":112}],190:[function(require,module,exports){ "use strict";var GetIntrinsic=require("get-intrinsic"),$gOPD=GetIntrinsic("%Object.getOwnPropertyDescriptor%");if($gOPD)try{$gOPD([],"length")}catch(t){$gOPD=null}module.exports=$gOPD; -},{"get-intrinsic":203}],185:[function(require,module,exports){ +},{"get-intrinsic":209}],191:[function(require,module,exports){ "use strict";var has=Object.prototype.hasOwnProperty,prefix="~";function Events(){}function EE(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function addListener(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new EE(n,r||e,i),s=prefix?prefix+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function clearEvent(e,t){0==--e._eventsCount?e._events=new Events:delete e._events[t]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(prefix=!1)),EventEmitter.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)has.call(e,t)&&n.push(prefix?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},EventEmitter.prototype.listeners=function(e){var t=prefix?prefix+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,o=new Array(i);r0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,ProcessEmitWarning(u)}return e}function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=onceWrapper.bind(r);return i.listener=n,r.wrapFn=i,i}function _listeners(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?unwrapListeners(i):arrayClone(i,i.length)}function listenerCount(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function arrayClone(e,t){for(var n=new Array(t),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)ReflectApply(u,this,t);else{var v=u.length,a=arrayClone(u,v);for(n=0;n=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():spliceOne(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r=0;r--)this.removeListener(e,t[r]);return this},EventEmitter.prototype.listeners=function(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]}; -},{}],187:[function(require,module,exports){ +},{}],193:[function(require,module,exports){ var Buffer=require("safe-buffer").Buffer,MD5=require("md5.js");function EVP_BytesToKey(e,f,r,t){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),f&&(Buffer.isBuffer(f)||(f=Buffer.from(f,"binary")),8!==f.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var u=r/8,a=Buffer.alloc(u),l=Buffer.alloc(t||0),n=Buffer.alloc(0);u>0||t>0;){var i=new MD5;i.update(n),i.update(e),f&&i.update(f),n=i.digest();var o=0;if(u>0){var B=a.length-u;o=Math.min(u,n.length),n.copy(a,B,0,o),u-=o}if(o0){var h=l.length-t,s=Math.min(t,n.length-o);n.copy(l,h,o,o+s),t-=s}}return n.fill(0),{key:a,iv:l}}module.exports=EVP_BytesToKey; -},{"md5.js":340,"safe-buffer":629}],188:[function(require,module,exports){ +},{"md5.js":345,"safe-buffer":638}],194:[function(require,module,exports){ function getStack(e){return e.stack&&e.name&&e.message?e.stack.substring(e.name.length+3+e.message.length).split("\n"):e.stack?e.stack.split("\n"):void 0}function removePrefix(e,r){return e.filter(function(e){return!~r.indexOf(e)})}var explain=module.exports=function(e,r){if(!(e.stack&&e.name&&e.message))return console.error(new Error("stackless error")),e;var n=new Error(r),t=removePrefix(getStack(n).slice(1),getStack(e)).join("\n");return n.__proto__=e,n.stack=n.name+": "+n.message+"\n"+t+"\n "+e.stack,n}; -},{}],189:[function(require,module,exports){ +},{}],195:[function(require,module,exports){ "use strict";function FastIntegerCompression(){}function bytelog(e){return e<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5}function zigzag_encode(e){return e+e^e>>31}function zigzag_decode(e){return e>>1^-(1&e)}FastIntegerCompression.computeCompressedSizeInBytes=function(e){for(var n=e.length,r=0,t=0;t>>7):g<1<<21?(t[o++]=127&g|128,t[o++]=g>>>7&127|128,t[o++]=g>>>14):g<1<<28?(t[o++]=127&g|128,t[o++]=g>>>7&127|128,t[o++]=g>>>14&127|128,t[o++]=g>>>21):(t[o++]=127&g|128,t[o++]=g>>>7&127|128,t[o++]=g>>>14&127|128,t[o++]=g>>>21&127|128,t[o++]=g>>>28)}return r},FastIntegerCompression.computeHowManyIntegers=function(e){for(var n=new Int8Array(e).length,r=0,t=0;t>>7;return n-r},FastIntegerCompression.uncompress=function(e){for(var n=[],r=new Int8Array(e),t=r.length,o=0;t>o;){var s=r[o++],g=127&s;s>=0?n.push(g):(g|=(127&(s=r[o++]))<<7,s>=0?n.push(g):(g|=(127&(s=r[o++]))<<14,s>=0?n.push(g):(g|=(127&(s=r[o++]))<<21,s>=0?n.push(g):(g|=(s=r[o++])<<28,g>>>=0,n.push(g)))))}return n},FastIntegerCompression.compressSigned=function(e){for(var n=e.length,r=new ArrayBuffer(FastIntegerCompression.computeCompressedSizeInBytesSigned(e)),t=new Int8Array(r),o=0,s=0;s>>7):g<1<<21?(t[o++]=127&g|128,t[o++]=g>>>7&127|128,t[o++]=g>>>14):g<1<<28?(t[o++]=127&g|128,t[o++]=g>>>7&127|128,t[o++]=g>>>14&127|128,t[o++]=g>>>21):(t[o++]=127&g|128,t[o++]=g>>>7&127|128,t[o++]=g>>>14&127|128,t[o++]=g>>>21&127|128,t[o++]=g>>>28)}return r},FastIntegerCompression.uncompressSigned=function(e){for(var n=[],r=new Int8Array(e),t=r.length,o=0;t>o;){var s=r[o++],g=127&s;s>=0?n.push(zigzag_decode(g)):(g|=(127&(s=r[o++]))<<7,s>=0?n.push(zigzag_decode(g)):(g|=(127&(s=r[o++]))<<14,s>=0?n.push(zigzag_decode(g)):(g|=(127&(s=r[o++]))<<21,s>=0?n.push(zigzag_decode(g)):(g|=(s=r[o++])<<28,n.push(zigzag_decode(g))))))}return n},module.exports=FastIntegerCompression; -},{}],190:[function(require,module,exports){ +},{}],196:[function(require,module,exports){ "use strict";var defaultcomparator=function(t,r){return t0&&(r=e-1>>1,i=this.array[r],this.compare(t,i));)this.array[e]=i,e=r;this.array[e]=t},FastPriorityQueue.prototype.heapify=function(t){var r;for(this.array=t,this.size=t.length,r=this.size>>1;r>=0;r--)this._percolateDown(r)},FastPriorityQueue.prototype._percolateUp=function(t,r){for(var i,e,s=this.array[t];t>0&&(i=t-1>>1,e=this.array[i],r||this.compare(s,e));)this.array[t]=e,t=i;this.array[t]=s},FastPriorityQueue.prototype._percolateDown=function(t){for(var r,i,e,s=this.size,a=this.size>>>1,o=this.array[t];tthis.size-1||t<0))return this._percolateUp(t,!0),this.poll()},FastPriorityQueue.prototype.remove=function(t){for(var r=0;r1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,t}},FastPriorityQueue.prototype.replaceTop=function(t){if(0!=this.size){var r=this.array[0];return this.array[0]=t,this._percolateDown(0),r}},FastPriorityQueue.prototype.trim=function(){this.array=this.array.slice(0,this.size)},FastPriorityQueue.prototype.isEmpty=function(){return 0===this.size},FastPriorityQueue.prototype.forEach=function(t){if(!this.isEmpty()&&"function"==typeof t)for(var r=0,i=this.clone();!i.isEmpty();)t(i.poll(),r++)},FastPriorityQueue.prototype.kSmallest=function(t){if(0==this.size)return[];t=Math.min(this.size,t);var r=new FastPriorityQueue(this.compare);const i=Math.min((t>0?Math.pow(2,t-1):0)+1,this.size);r.size=i,r.array=this.array.slice(0,i);for(var e=new Array(t),s=0;s{};return{since:f,value:m,methods:{get:"async",stream:"source",value:"sync"},get:function(e,t){"function"==typeof e&&(t=e,e=null),!e||isEmpty(e)?t(null,m.value):isObject(e)&&f.once(function(u){t(null,!1===e.values?{seq:u,version:n,size:v&&v.size||null}:!1===e.meta?m.value:{seq:u,version:n,value:m.value})})},stream:function(e){if(!0!==(e=e||{}).live)return Once(m.value);var n=o.listen();return n.push(m.value),n},createSink:function(e){d=e;let n=0;return Drain(function(e){var i=u(e.value,e.seq);null!=i&&m.set(t(m.value,i,e.seq)),f.set(e.seq),o(i),(f.value===a.since.value||s&&n%s==0)&&q(),n+=1},e)},destroy:function(e){m.set(r),f.set(-1),p.write(r),d(),p.close(e)},close:function(e){if(o.abort(!0),!f.value||!v)return e();p.close(e)}}}}}; -},{"async-single":41,"deep-equal":195,"obv":402,"path":424,"pull-notify":518,"pull-stream/sinks/drain":530,"pull-stream/sources/once":542}],195:[function(require,module,exports){ +},{"async-single":41,"deep-equal":201,"obv":408,"path":430,"pull-notify":524,"pull-stream/sinks/drain":537,"pull-stream/sources/once":549}],201:[function(require,module,exports){ var objectKeys=require("object-keys"),isArguments=require("is-arguments"),is=require("object-is"),isRegex=require("is-regex"),flags=require("regexp.prototype.flags"),isDate=require("is-date-object"),getTime=Date.prototype.getTime;function deepEqual(e,r,t){var i=t||{};return!(i.strict?!is(e,r):e!==r)||(!e||!r||"object"!=typeof e&&"object"!=typeof r?i.strict?is(e,r):e==r:objEquiv(e,r,i))}function isUndefinedOrNull(e){return null==e}function isBuffer(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&!(e.length>0&&"number"!=typeof e[0]))}function objEquiv(e,r,t){var i,n;if(typeof e!=typeof r)return!1;if(isUndefinedOrNull(e)||isUndefinedOrNull(r))return!1;if(e.prototype!==r.prototype)return!1;if(isArguments(e)!==isArguments(r))return!1;var u=isRegex(e),f=isRegex(r);if(u!==f)return!1;if(u||f)return e.source===r.source&&flags(e)===flags(r);if(isDate(e)&&isDate(r))return getTime.call(e)===getTime.call(r);var o=isBuffer(e),s=isBuffer(r);if(o!==s)return!1;if(o||s){if(e.length!==r.length)return!1;for(i=0;i=0;i--)if(l[i]!=g[i])return!1;for(i=l.length-1;i>=0;i--)if(!deepEqual(e[n=l[i]],r[n],t))return!1;return!0}module.exports=deepEqual; -},{"is-arguments":260,"is-date-object":263,"is-regex":266,"object-is":396,"object-keys":400,"regexp.prototype.flags":623}],196:[function(require,module,exports){ +},{"is-arguments":266,"is-date-object":269,"is-regex":272,"object-is":402,"object-keys":406,"regexp.prototype.flags":631}],202:[function(require,module,exports){ module.exports=require("level-codec/lib/encodings").json; -},{"level-codec/lib/encodings":297}],197:[function(require,module,exports){ +},{"level-codec/lib/encodings":303}],203:[function(require,module,exports){ var path=require("path"),AtomicFile=require("atomic-file");function id(e){return e}var none={encode:id,decode:id};module.exports=function(e,n,t){t=t||require("flumecodec/json");var i,o=AtomicFile(path.join(e,n+".json"),"~",none);return i={size:null,get:function(e){o.get(function(n,o){if(n)return e(n);if(null==o)return e();try{i.size=o.length,(o=t.decode(o)).size=i.size}catch(n){return e(n)}e(null,o)})},set:function(e,n){e=t.encode(e),i.size=e.length,o.set(e,n)},destroy:function(e){value=null,i.size=0,o.destroy(e)}}}; -},{"atomic-file":45,"flumecodec/json":196,"path":424}],198:[function(require,module,exports){ +},{"atomic-file":45,"flumecodec/json":202,"path":430}],204:[function(require,module,exports){ module.exports=require("./fs"); -},{"./fs":197}],199:[function(require,module,exports){ +},{"./fs":203}],205:[function(require,module,exports){ var hasOwn=Object.prototype.hasOwnProperty,toString=Object.prototype.toString;module.exports=function(t,r,o){if("[object Function]"!==toString.call(r))throw new TypeError("iterator must be a function");var e=t.length;if(e===+e)for(var n=0;n1&&"boolean"!=typeof e)throw new $TypeError('"allowMissing" argument must be a boolean');var t=stringToPath(r),o=t.length>0?t[0]:"",n=getBaseIntrinsic("%"+o+"%",e),a=n.name,y=n.value,i=!1,p=n.alias;p&&(o=p[0],$spliceApply(t,$concat([0,1],p)));for(var d=1,f=!0;d=t.length){var l=$gOPD(y,s);y=(f=!!l)&&"get"in l&&!("originalValue"in l.get)?l.get:y[s]}else f=hasOwn(y,s),y=y[s];f&&!i&&(INTRINSICS[a]=y)}}return y}; -},{"function-bind":201,"has":208,"has-symbols":206}],204:[function(require,module,exports){ +},{"function-bind":207,"has":214,"has-symbols":212}],210:[function(require,module,exports){ "use strict";var Obv=require("obv"),STATES={queried:1,checking:2,checked:3,responded:5,processing:6,processed:7};function each(e,t){for(var r in e)t(e[r],r,e)}function isEmpty(e){for(var t in e)return!1;return!0}module.exports=function(e){var t={},r={},n=e.initialWeight||-1,u=e.increment||function(e){return Number(e)-1},s=e.isRequest||function(e){return"number"==typeof e&&e<0},o=e.isResponse||function(e){return!s(e)},i=e.isQuery||function(){return!0},c=e.process||function(e,t,r){r(null,t)},a=e.compare||function(e,t){return t-e},d=e.maximum||-3,f=e.timeout||3e4,l=Obv();function T(e){e?l.once(e,!1):l.set(t)}function S(){return Date.now()}function v(e,t,n){if(r[e]){var u=r[e];for(delete r[e];u.length;)u.shift()(n,t)}}function p(e){return{state:STATES.queried,weight:e,value:null,requestedBy:{},requestedFrom:{},respondedTo:{},ts:S()}}return l.set(t),l(function(){each(t,function(r,n){r.state===STATES.queried&&(r.state=STATES.checking,r.ts=S(),e.check(n,function(e,u){u&&!r.value?(r.state=STATES.processed,v(n,r.value=u)):r.state=STATES.checked,r.ts=S(),l.set(t)})),null!=r.value&&r.state===STATES.responded&&(r.state=STATES.processing,r.ts=S(),c(n,r.value,function(e,u){e||(r.state=STATES.processed,r.ts=S(),u&&v(n,r.value=u),l.set(t))}))})}),{state:t,createStream:function(e){return{source:function(r,n){if(r)for(var u in t)delete t[u].respondedTo[e],delete t[u].requestedFrom[e];else!function r(){var u={};for(var s in t)t[s].state===STATES.processed&&t[s].requestedBy[e]&&!t[s].respondedTo[e]?(t[s].respondedTo[e]=!0,u[s]=t[s].value):t[s].state!==STATES.checked||t[s].requestedFrom[e]||(t[s].requestedFrom[e]=!0,u[s]=t[s].weight);isEmpty(u)?T(r):n(null,u)}()},sink:function(r){r(null,function n(c,f){if(c)for(var l in t)delete t[l].requestedBy[e];else{var S=!1;for(var l in f){var v=f[l];i(l)&&(s(v)||o(v,l))&&(s(f[l])?a(f[l],d)<0&&(t[l]?a(f[l],t[l].weight)<0&&(S=!0,t[l].requestedBy[e]=!0,t[l].weight=u(f[l])):(S=!0,t[l]=p(u(f[l])),t[l].requestedBy[e]=!0)):o(f[l])&&t[l].state==STATES.checked&&(t[l].state=STATES.responded,t[l].value=f[l],S=!0))}S&&T(),r(null,n)}})}}},query:function(e,u){var s;t[e]?t[e].state==STATES.processed?u(null,t[e].value):(r[e]=r[e]||[]).push(u):(s=!0,t[e]=p(n),r[e]=[u]),s&&T()},checkTimeout:function(){var e,r=Date.now();for(var n in t)t[n].ts+f=this._blockSize;){for(var i=this._blockOffset;i0;++f)this._length[f]+=o,(o=this._length[f]/4294967296|0)>0&&(this._length[f]-=4294967296*o);return this},HashBase.prototype._update=function(){throw new Error("_update is not implemented")},HashBase.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},HashBase.prototype._digest=function(){throw new Error("_digest is not implemented")},module.exports=HashBase; -},{"inherits":258,"readable-stream":224,"safe-buffer":629}],210:[function(require,module,exports){ +},{"inherits":264,"readable-stream":230,"safe-buffer":638}],216:[function(require,module,exports){ "use strict";function _inheritsLoose(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}var codes={};function createErrorType(e,r,t){t||(t=Error);var n=function(e){function t(t,n,o){return e.call(this,function(e,t,n){return"string"==typeof r?r:r(e,t,n)}(t,n,o))||this}return _inheritsLoose(t,e),t}(t);n.prototype.name=t.name,n.prototype.code=e,codes[e]=n}function oneOf(e,r){if(Array.isArray(e)){var t=e.length;return e=e.map(function(e){return String(e)}),t>2?"one of ".concat(r," ").concat(e.slice(0,t-1).join(", "),", or ")+e[t-1]:2===t?"one of ".concat(r," ").concat(e[0]," or ").concat(e[1]):"of ".concat(r," ").concat(e[0])}return"of ".concat(r," ").concat(String(e))}function startsWith(e,r,t){return e.substr(!t||t<0?0:+t,r.length)===r}function endsWith(e,r,t){return(void 0===t||t>e.length)&&(t=e.length),e.substring(t-r.length,t)===r}function includes(e,r,t){return"number"!=typeof t&&(t=0),!(t+r.length>e.length)&&-1!==e.indexOf(r,t)}createErrorType("ERR_INVALID_OPT_VALUE",function(e,r){return'The value "'+r+'" is invalid for option "'+e+'"'},TypeError),createErrorType("ERR_INVALID_ARG_TYPE",function(e,r,t){var n,o;if("string"==typeof r&&startsWith(r,"not ")?(n="must not be",r=r.replace(/^not /,"")):n="must be",endsWith(e," argument"))o="The ".concat(e," ").concat(n," ").concat(oneOf(r,"type"));else{var c=includes(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(oneOf(r,"type"))}return o+=". Received type ".concat(typeof t)},TypeError),createErrorType("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),createErrorType("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),createErrorType("ERR_STREAM_PREMATURE_CLOSE","Premature close"),createErrorType("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),createErrorType("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),createErrorType("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),createErrorType("ERR_STREAM_WRITE_AFTER_END","write after end"),createErrorType("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),createErrorType("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),module.exports.codes=codes; -},{}],211:[function(require,module,exports){ +},{}],217:[function(require,module,exports){ (function (process){(function (){ "use strict";var objectKeys=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};module.exports=Duplex;var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");require("inherits")(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v0)if("string"==typeof t||d.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=_uint8ArrayToBuffer(t)),a)d.endEmitted?errorOrDestroy(e,new ERR_STREAM_UNSHIFT_AFTER_END_EVENT):addChunk(e,d,t,!0);else if(d.ended)errorOrDestroy(e,new ERR_STREAM_PUSH_AFTER_EOF);else{if(d.destroyed)return!1;d.reading=!1,d.decoder&&!r?(t=d.decoder.write(t),d.objectMode||0!==t.length?addChunk(e,d,t,!1):maybeReadMore(e,d)):addChunk(e,d,t,!1)}else a||(d.reading=!1,maybeReadMore(e,d));return!d.ended&&(d.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function onEofChunk(e,t){if(debug("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?emitReadable(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,emitReadable_(e)))}}function emitReadable(e){var t=e._readableState;debug("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(emitReadable_,e))}function emitReadable_(e){var t=e._readableState;debug("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function nReadingNextTick(e){debug("readable nexttick read 0"),e.read(0)}function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(resume_,e,t))}function resume_(e,t){debug("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}function flow(e){var t=e._readableState;for(debug("flow",t.flowing);t.flowing&&null!==e.read(););}function fromList(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function endReadable(e){var t=e._readableState;debug("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(endReadableNT,t,e))}function endReadableNT(e,t){if(debug("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function indexOf(e,t){for(var r=0,a=e.length;r=t.highWaterMark:t.length>0)||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var a,n=t.needReadable;return debug("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&endReadable(this)),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){errorOrDestroy(this,new ERR_METHOD_NOT_IMPLEMENTED("_read()"))},Readable.prototype.pipe=function(e,t){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e)}a.pipesCount+=1,debug("pipe count=%d opts=%j",a.pipesCount,t);var n=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?d:f;function i(t,n){debug("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,debug("cleanup"),e.removeListener("close",b),e.removeListener("finish",p),e.removeListener("drain",o),e.removeListener("error",u),e.removeListener("unpipe",i),r.removeListener("end",d),r.removeListener("end",f),r.removeListener("data",l),s=!0,!a.awaitDrain||e._writableState&&!e._writableState.needDrain||o())}function d(){debug("onend"),e.end()}a.endEmitted?process.nextTick(n):r.once("end",n),e.on("unpipe",i);var o=pipeOnDrain(r);e.on("drain",o);var s=!1;function l(t){debug("ondata");var n=e.write(t);debug("dest.write",n),!1===n&&((1===a.pipesCount&&a.pipes===e||a.pipesCount>1&&-1!==indexOf(a.pipes,e))&&!s&&(debug("false write response, pause",a.awaitDrain),a.awaitDrain++),r.pause())}function u(t){debug("onerror",t),f(),e.removeListener("error",u),0===EElistenerCount(e,"error")&&errorOrDestroy(e,t)}function b(){e.removeListener("finish",p),f()}function p(){debug("onfinish"),e.removeListener("close",b),f()}function f(){debug("unpipe"),r.unpipe(e)}return r.on("data",l),prependListener(e,"error",u),e.once("close",b),e.once("finish",p),e.emit("pipe",r),a.flowing||(debug("pipe resume"),r.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var a=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i0,!1!==a.flowing&&this.resume()):"readable"===e&&(a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.flowing=!1,a.emittedReadable=!1,debug("on readable",a.length,a.reading),a.length?emitReadable(this):a.reading||process.nextTick(nReadingNextTick,this))),r},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.removeListener=function(e,t){var r=Stream.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(updateReadableListening,this),r},Readable.prototype.removeAllListeners=function(e){var t=Stream.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(updateReadableListening,this),t},Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(debug("resume"),e.flowing=!e.readableListening,resume(this,e)),e.paused=!1,this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Readable.prototype.wrap=function(e){var t=this,r=this._readableState,a=!1;for(var n in e.on("end",function(){if(debug("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){(debug("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(a=!0,e.pause()))}),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var i=0;i-1))throw new ERR_UNKNOWN_ENCODING(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Writable.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Writable.prototype._write=function(e,t,r){r(new ERR_METHOD_NOT_IMPLEMENTED("_write()"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||endWritable(this,i,r),this},Object.defineProperty(Writable.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(Writable.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(e,t){t(e)}; }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../errors":210,"./_stream_duplex":211,"./internal/streams/destroy":218,"./internal/streams/state":222,"./internal/streams/stream":223,"_process":443,"buffer":99,"inherits":258,"util-deprecate":844}],216:[function(require,module,exports){ +},{"../errors":216,"./_stream_duplex":217,"./internal/streams/destroy":224,"./internal/streams/state":228,"./internal/streams/stream":229,"_process":449,"buffer":104,"inherits":264,"util-deprecate":869}],222:[function(require,module,exports){ (function (process){(function (){ "use strict";var _Object$setPrototypeO;function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var finished=require("./end-of-stream"),kLastResolve=Symbol("lastResolve"),kLastReject=Symbol("lastReject"),kError=Symbol("error"),kEnded=Symbol("ended"),kLastPromise=Symbol("lastPromise"),kHandlePromise=Symbol("handlePromise"),kStream=Symbol("stream");function createIterResult(e,t){return{value:e,done:t}}function readAndResolve(e){var t=e[kLastResolve];if(null!==t){var r=e[kStream].read();null!==r&&(e[kLastPromise]=null,e[kLastResolve]=null,e[kLastReject]=null,t(createIterResult(r,!1)))}}function onReadable(e){process.nextTick(readAndResolve,e)}function wrapForNext(e,t){return function(r,o){e.then(function(){t[kEnded]?r(createIterResult(void 0,!0)):t[kHandlePromise](r,o)},o)}}var AsyncIteratorPrototype=Object.getPrototypeOf(function(){}),ReadableStreamAsyncIteratorPrototype=Object.setPrototypeOf((_defineProperty(_Object$setPrototypeO={get stream(){return this[kStream]},next:function(){var e=this,t=this[kError];if(null!==t)return Promise.reject(t);if(this[kEnded])return Promise.resolve(createIterResult(void 0,!0));if(this[kStream].destroyed)return new Promise(function(t,r){process.nextTick(function(){e[kError]?r(e[kError]):t(createIterResult(void 0,!0))})});var r,o=this[kLastPromise];if(o)r=new Promise(wrapForNext(o,this));else{var n=this[kStream].read();if(null!==n)return Promise.resolve(createIterResult(n,!1));r=new Promise(this[kHandlePromise])}return this[kLastPromise]=r,r}},Symbol.asyncIterator,function(){return this}),_defineProperty(_Object$setPrototypeO,"return",function(){var e=this;return new Promise(function(t,r){e[kStream].destroy(null,function(e){e?r(e):t(createIterResult(void 0,!0))})})}),_Object$setPrototypeO),AsyncIteratorPrototype),createReadableStreamAsyncIterator=function(e){var t,r=Object.create(ReadableStreamAsyncIteratorPrototype,(_defineProperty(t={},kStream,{value:e,writable:!0}),_defineProperty(t,kLastResolve,{value:null,writable:!0}),_defineProperty(t,kLastReject,{value:null,writable:!0}),_defineProperty(t,kError,{value:null,writable:!0}),_defineProperty(t,kEnded,{value:e._readableState.endEmitted,writable:!0}),_defineProperty(t,kHandlePromise,{value:function(e,t){var o=r[kStream].read();o?(r[kLastPromise]=null,r[kLastResolve]=null,r[kLastReject]=null,e(createIterResult(o,!1))):(r[kLastResolve]=e,r[kLastReject]=t)},writable:!0}),t));return r[kLastPromise]=null,finished(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[kLastReject];return null!==t&&(r[kLastPromise]=null,r[kLastResolve]=null,r[kLastReject]=null,t(e)),void(r[kError]=e)}var o=r[kLastResolve];null!==o&&(r[kLastPromise]=null,r[kLastResolve]=null,r[kLastReject]=null,o(createIterResult(void 0,!0))),r[kEnded]=!0}),e.on("readable",onReadable.bind(null,r)),r};module.exports=createReadableStreamAsyncIterator; }).call(this)}).call(this,require('_process')) -},{"./end-of-stream":219,"_process":443}],217:[function(require,module,exports){ +},{"./end-of-stream":225,"_process":449}],223:[function(require,module,exports){ "use strict";function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return Buffer.alloc(0);for(var t=Buffer.allocUnsafe(e>>>0),n=this.head,r=0;n;)copyBuffer(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return ea.length?a.length:e;if(i===a.length?r+=a:r+=a.slice(0,e),0===(e-=i)){i===a.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=a.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=Buffer.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var a=n.data,i=e>a.length?a.length:e;if(a.copy(t,t.length-e,0,i),0===(e-=i)){i===a.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=a.slice(i));break}++r}return this.length-=r,t}},{key:custom,value:function(e,t){return inspect(this,_objectSpread({},t,{depth:0,customInspect:!1}))}}]),e}(); -},{"buffer":99,"util":55}],218:[function(require,module,exports){ +},{"buffer":104,"util":60}],224:[function(require,module,exports){ (function (process){(function (){ "use strict";function destroy(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(emitErrorNT,this,t)):process.nextTick(emitErrorNT,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?process.nextTick(emitCloseNT,r):(r._writableState.errorEmitted=!0,process.nextTick(emitErrorAndCloseNT,r,t)):process.nextTick(emitErrorAndCloseNT,r,t):e?(process.nextTick(emitCloseNT,r),e(t)):process.nextTick(emitCloseNT,r)}),this)}function emitErrorAndCloseNT(t,e){emitErrorNT(t,e),emitCloseNT(t)}function emitCloseNT(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function undestroy(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function emitErrorNT(t,e){t.emit("error",e)}function errorOrDestroy(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}module.exports={destroy:destroy,undestroy:undestroy,errorOrDestroy:errorOrDestroy}; }).call(this)}).call(this,require('_process')) -},{"_process":443}],219:[function(require,module,exports){ +},{"_process":449}],225:[function(require,module,exports){ "use strict";var ERR_STREAM_PREMATURE_CLOSE=require("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function once(e){var r=!1;return function(){if(!r){r=!0;for(var t=arguments.length,n=new Array(t),o=0;o0,function(e){o||(o=e),e&&i.forEach(call),u||(i.forEach(call),t(o))})});return r.reduce(pipe)}module.exports=pipeline; -},{"../../../errors":210,"./end-of-stream":219}],222:[function(require,module,exports){ +},{"../../../errors":216,"./end-of-stream":225}],228:[function(require,module,exports){ "use strict";var ERR_INVALID_OPT_VALUE=require("../../../errors").codes.ERR_INVALID_OPT_VALUE;function highWaterMarkFrom(r,e,t){return null!=r.highWaterMark?r.highWaterMark:e?r[t]:null}function getHighWaterMark(r,e,t,a){var i=highWaterMarkFrom(e,a,t);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new ERR_INVALID_OPT_VALUE(a?t:"highWaterMark",i);return Math.floor(i)}return r.objectMode?16:16384}module.exports={getHighWaterMark:getHighWaterMark}; -},{"../../../errors":210}],223:[function(require,module,exports){ +},{"../../../errors":216}],229:[function(require,module,exports){ module.exports=require("events").EventEmitter; -},{"events":186}],224:[function(require,module,exports){ +},{"events":192}],230:[function(require,module,exports){ exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),exports.finished=require("./lib/internal/streams/end-of-stream.js"),exports.pipeline=require("./lib/internal/streams/pipeline.js"); -},{"./lib/_stream_duplex.js":211,"./lib/_stream_passthrough.js":212,"./lib/_stream_readable.js":213,"./lib/_stream_transform.js":214,"./lib/_stream_writable.js":215,"./lib/internal/streams/end-of-stream.js":219,"./lib/internal/streams/pipeline.js":221}],225:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":217,"./lib/_stream_passthrough.js":218,"./lib/_stream_readable.js":219,"./lib/_stream_transform.js":220,"./lib/_stream_writable.js":221,"./lib/internal/streams/end-of-stream.js":225,"./lib/internal/streams/pipeline.js":227}],231:[function(require,module,exports){ var hash=exports;hash.utils=require("./hash/utils"),hash.common=require("./hash/common"),hash.sha=require("./hash/sha"),hash.ripemd=require("./hash/ripemd"),hash.hmac=require("./hash/hmac"),hash.sha1=hash.sha.sha1,hash.sha256=hash.sha.sha256,hash.sha224=hash.sha.sha224,hash.sha384=hash.sha.sha384,hash.sha512=hash.sha.sha512,hash.ripemd160=hash.ripemd.ripemd160; -},{"./hash/common":226,"./hash/hmac":227,"./hash/ripemd":228,"./hash/sha":229,"./hash/utils":236}],226:[function(require,module,exports){ +},{"./hash/common":232,"./hash/hmac":233,"./hash/ripemd":234,"./hash/sha":235,"./hash/utils":242}],232:[function(require,module,exports){ "use strict";var utils=require("./utils"),assert=require("minimalistic-assert");function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}exports.BlockHash=BlockHash,BlockHash.prototype.update=function(t,i){if(t=utils.toArray(t,i),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=utils.join32(t,0,t.length-n,this.endian);for(var s=0;s>>24&255,s[e++]=t>>>16&255,s[e++]=t>>>8&255,s[e++]=255&t}else for(s[e++]=255&t,s[e++]=t>>>8&255,s[e++]=t>>>16&255,s[e++]=t>>>24&255,s[e++]=0,s[e++]=0,s[e++]=0,s[e++]=0,h=8;hthis.blockSize&&(t=(new this.Hash).update(t).digest()),assert(t.length<=this.blockSize);for(var i=t.length;i>>3}function g1_256(r){return rotr32(r,17)^rotr32(r,19)^r>>>10}exports.ft_1=ft_1,exports.ch32=ch32,exports.maj32=maj32,exports.p32=p32,exports.s0_256=s0_256,exports.s1_256=s1_256,exports.g0_256=g0_256,exports.g1_256=g1_256; -},{"../utils":236}],236:[function(require,module,exports){ +},{"../utils":242}],242:[function(require,module,exports){ "use strict";var assert=require("minimalistic-assert"),inherits=require("inherits");function isSurrogatePair(r,t){return 55296==(64512&r.charCodeAt(t))&&(!(t<0||t+1>=r.length)&&56320==(64512&r.charCodeAt(t+1)))}function toArray(r,t){if(Array.isArray(r))return r.slice();if(!r)return[];var o=[];if("string"==typeof r)if(t){if("hex"===t)for((r=r.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(r="0"+r),n=0;n>6|192,o[e++]=63&u|128):isSurrogatePair(r,n)?(u=65536+((1023&u)<<10)+(1023&r.charCodeAt(++n)),o[e++]=u>>18|240,o[e++]=u>>12&63|128,o[e++]=u>>6&63|128,o[e++]=63&u|128):(o[e++]=u>>12|224,o[e++]=u>>6&63|128,o[e++]=63&u|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(255&r)<<24)>>>0}function toHex32(r,t){for(var o="",e=0;e>>0}return u}function split32(r,t){for(var o=new Array(4*r.length),e=0,n=0;e>>24,o[n+1]=u>>>16&255,o[n+2]=u>>>8&255,o[n+3]=255&u):(o[n+3]=u>>>24,o[n+2]=u>>>16&255,o[n+1]=u>>>8&255,o[n]=255&u)}return o}function rotr32(r,t){return r>>>t|r<<32-t}function rotl32(r,t){return r<>>32-t}function sum32(r,t){return r+t>>>0}function sum32_3(r,t,o){return r+t+o>>>0}function sum32_4(r,t,o,e){return r+t+o+e>>>0}function sum32_5(r,t,o,e,n){return r+t+o+e+n>>>0}function sum64(r,t,o,e){var n=r[t],u=e+r[t+1]>>>0,s=(u>>0,r[t+1]=u}function sum64_hi(r,t,o,e){return(t+e>>>0>>0}function sum64_lo(r,t,o,e){return t+e>>>0}function sum64_4_hi(r,t,o,e,n,u,s,i){var h=0,_=t;return h+=(_=_+e>>>0)>>0)>>0)>>0}function sum64_4_lo(r,t,o,e,n,u,s,i){return t+e+u+i>>>0}function sum64_5_hi(r,t,o,e,n,u,s,i,h,_){var l=0,f=t;return l+=(f=f+e>>>0)>>0)>>0)>>0)<_?1:0)>>>0}function sum64_5_lo(r,t,o,e,n,u,s,i,h,_){return t+e+u+i+_>>>0}function rotr64_hi(r,t,o){return(t<<32-o|r>>>o)>>>0}function rotr64_lo(r,t,o){return(r<<32-o|t>>>o)>>>0}function shr64_hi(r,t,o){return r>>>o}function shr64_lo(r,t,o){return(r<<32-o|t>>>o)>>>0}exports.inherits=inherits,exports.toArray=toArray,exports.toHex=toHex,exports.htonl=htonl,exports.toHex32=toHex32,exports.zero2=zero2,exports.zero8=zero8,exports.join32=join32,exports.split32=split32,exports.rotr32=rotr32,exports.rotl32=rotl32,exports.sum32=sum32,exports.sum32_3=sum32_3,exports.sum32_4=sum32_4,exports.sum32_5=sum32_5,exports.sum64=sum64,exports.sum64_hi=sum64_hi,exports.sum64_lo=sum64_lo,exports.sum64_4_hi=sum64_4_hi,exports.sum64_4_lo=sum64_4_lo,exports.sum64_5_hi=sum64_5_hi,exports.sum64_5_lo=sum64_5_lo,exports.rotr64_hi=rotr64_hi,exports.rotr64_lo=rotr64_lo,exports.shr64_hi=shr64_hi,exports.shr64_lo=shr64_lo; -},{"inherits":258,"minimalistic-assert":343}],237:[function(require,module,exports){ +},{"inherits":264,"minimalistic-assert":348}],243:[function(require,module,exports){ module.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,n=Object.create(null),r=Object.create(null);function o(o,u){n[o]=u,++t>=e&&(t=0,r=n,n=Object.create(null))}return{has:function(e){return void 0!==n[e]||void 0!==r[e]},remove:function(e){void 0!==n[e]&&(n[e]=void 0),void 0!==r[e]&&(r[e]=void 0)},get:function(e){var t=n[e];return void 0!==t?t:void 0!==(t=r[e])?(o(e,t),t):void 0},set:function(e,t){void 0!==n[e]?n[e]=t:o(e,t)},clear:function(){n=Object.create(null),r=Object.create(null)}}}; -},{}],238:[function(require,module,exports){ +},{}],244:[function(require,module,exports){ module.exports=require("./lib/heap"); -},{"./lib/heap":239}],239:[function(require,module,exports){ +},{"./lib/heap":245}],245:[function(require,module,exports){ (function(){var t,n,e,o,r,p,u,i,s,l,c,h,f,a,y,d,g;e=Math.floor,l=Math.min,n=function(t,n){return tn?1:0},s=function(t,o,r,p,u){var i;if(null==r&&(r=0),null==u&&(u=n),r<0)throw new Error("lo must be non-negative");for(null==p&&(p=t.length);ro;0<=o?n++:n--)l.push(n);return l}.apply(this).reverse()).length;pd;0<=d?++f:--f)g.push(r(t,p));return g},a=function(t,e,o,r){var p,u,i;for(null==r&&(r=n),p=t[o];o>e&&r(p,u=t[i=o-1>>1])<0;)t[o]=u,o=i;return t[o]=p},y=function(t,e,o){var r,p,u,i,s;for(null==o&&(o=n),p=t.length,s=e,u=t[e],r=2*e+1;r=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,i,s)}module.exports=HmacDRBG,HmacDRBG.prototype._init=function(t,e,i){var s=t.concat(e).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var h=0;h=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(i||[])),this._reseed=1},HmacDRBG.prototype.generate=function(t,e,i,s){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(s=i,i=e,e=null),i&&(i=utils.toArray(i,s||"hex"),this._update(i));for(var h=[];h.lengththis.emit("connection-error",e)),e.once("error",()=>{const e=websocket(this.proxy);e.on("error",e=>this.emit("connection-error",e)),e.once("close",()=>{setTimeout(()=>{this.destroyed||this.reconnect()},this.reconnectDelay)}),super.reconnect(e)}),super.reconnect(e)}_nextUrl(){return this.proxy=this._urls[this._urlIndex++%this._urls.length],this.proxy}}module.exports=HyperswarmProxyWSClient; -},{"hyperswarm-proxy/client":244,"websocket-stream":853}],244:[function(require,module,exports){ +},{"hyperswarm-proxy/client":250,"websocket-stream":878}],250:[function(require,module,exports){ (function (process){(function (){ const EventEmitter=require("events"),HyperswarmProxyStream=require("./"),NOT_CONNECTED="Not connected to proxy";function noop(){}module.exports=class extends EventEmitter{constructor(e={}){super();const{connection:t,autoconnect:o=!0,maxPeers:s=24}=e;this.maxPeers=s,this._handleStream=this._handleStream.bind(this),this._handleClose=this._handleClose.bind(this),this._handlePeer=this._handlePeer.bind(this),this._handleError=this._handleError.bind(this),this._reJoin=this._reJoin.bind(this),this._protocol=null,this._connection=null,this._topics=[],this._connectedPeers=new Set,this._seenPeers=[],this._autoconnect=o,this.destroyed=!1,t&&this.reconnect(t)}disconnect(){this._protocol&&(this._protocol.removeListener("close",this._handleClose),this._connection.end(),this._protocol.end(),this._connection=null,this._protocol=null)}reconnect(e){this.disconnect(),this._connection=e,this._protocol=new HyperswarmProxyStream(e),this._protocol.on("stream",this._handleStream),this._protocol.on("on_peer",this._handlePeer),this._protocol.once("close",this._handleClose),this._protocol.on("error",this._handleError),this._protocol.once("ready",this._reJoin),this._protocol.ready()}_handleStream(e,{topic:t,peer:o}){if(this.destroyed)return void e.end();const s=new Details(o,t);this._connectedPeers.add(o),this.emit("connection",e,s),e.once("close",()=>{this.destroyed||(this.emit("disconnection",e,s),this._connectedPeers.delete(o))})}_handleClose(){this._protocol=null;for(const e of this._connectedPeers)e.end();this.emit("disconnected")}_handleError(e){this.emit("error",e)}_handlePeer({topic:e,peer:t}){const o={host:t,port:0,local:!1,topic:e};this.emit("peer",o);const s=this._connectedPeers.has(t),n=this._connectedPeers.size>=this.maxPeers;this._autoconnect&&!s&&!n?this.connect(o):this._seenPeers.find(e=>e.peer===t)||this._seenPeers.push(o)}_reJoin(){for(const e of this._topics)this.join(e)}get connections(){return this._protocol?this._protocol.connections:new Set}join(e){if(!this._protocol)throw new Error(NOT_CONNECTED);this._protocol.join(e),this._topics.some(t=>t.equals(e))||this._topics.push(e)}leave(e){if(!this._protocol)throw new Error(NOT_CONNECTED);this._protocol.leave(e),this._topics=this._topics.filter(t=>!t.equals(e)),this._seenPeers=this._seenPeers.filter(({topic:t})=>!t.equals(e))}connect(e,t=noop){if(!this._protocol)return setTimeout(()=>t(new Error(NOT_CONNECTED)),0);const o=e.host,s=(e,n)=>{n.peer.host===o&&(t(null,e,n),this.removeListener("connection",s))};t&&this.on("connection",s),this._protocol.connect(o)}flush(e=noop){e&&process.nextTick(e)}status(){return{lookup:!0,announce:!1}}destroy(e){this.destroyed=!0,this.disconnect(),this._topics=null,this._connectedPeers=null,this._seenPeers=null,e&&process.nextTick(e)}};class Details{constructor(e,t){this.type="proxy",this.client=!0,this.peer={host:e,port:0,local:!1,topic:t}}deduplicate(){return!1}} }).call(this)}).call(this,require('_process')) -},{"./":245,"_process":443,"events":186}],245:[function(require,module,exports){ +},{"./":251,"_process":449,"events":192}],251:[function(require,module,exports){ (function (Buffer){(function (){ const Duplex=require("stream").Duplex,lps=require("length-prefixed-stream"),{SwarmEvent:SwarmEvent,EventType:EventType}=require("./messages"),ProxyStream=require("./proxystream"),pump=require("pump");module.exports=class extends Duplex{constructor(e){super({emitClose:!0}),this.connections=new Set,this.setMaxListeners(256),pump(e,lps.decode(),this,lps.encode(),e,()=>{this._closeAllStreams()}),this.on("on_stream_open",this._handleStreamOpen.bind(this))}ready(){this.sendMessage("READY")}join(e){this.sendMessage("JOIN",{topic:e})}leave(e){this.sendMessage("LEAVE",{topic:e})}onPeer(e,t){this.sendMessage("ON_PEER",{topic:e,peer:t})}connect(e){this.sendMessage("CONNECT",{peer:e})}onStreamOpen(e,t,s){this.sendMessage("ON_STREAM_OPEN",{topic:e,peer:t,stream:s})}onStreamData(e,t){"string"==typeof t&&(t=Buffer.from(t,"utf8")),this.sendMessage("ON_STREAM_DATA",{stream:e,data:t})}onStreamClose(e){this.sendMessage("ON_STREAM_CLOSE",{stream:e})}onStreamError(e,t,s){const r=Buffer.from(t,"utf8");this.sendMessage("ON_STREAM_ERROR",{stream:e,data:r})}openStream(e,t,s){const r=new ProxyStream(this,s);return this._addStream(r),this.onStreamOpen(e,t,s),r}_closeAllStreams(){for(const e of this.connections)e.end()}_addStream(e){this.connections.add(e),e.once("close",()=>{this.connections.delete(e)})}_handleStreamOpen({topic:e,peer:t,stream:s}){const r=new ProxyStream(this,s);this._addStream(r),this.emit("stream",r,{topic:e,peer:t})}sendMessage(e,t={}){this.push(SwarmEvent.encode({type:EventType[e],...t}))}_write(e,t,s){try{const t=SwarmEvent.decode(e),{type:r}=t;for(const e of Object.keys(EventType))EventType[e]===r&&this.emit(e.toLowerCase(),t);s()}catch(e){s(e)}}_read(){}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./messages":246,"./proxystream":247,"buffer":99,"length-prefixed-stream":281,"pump":570,"stream":792}],246:[function(require,module,exports){ +},{"./messages":252,"./proxystream":253,"buffer":104,"length-prefixed-stream":287,"pump":577,"stream":814}],252:[function(require,module,exports){ (function (Buffer){(function (){ var encodings=require("protocol-buffers-encodings"),varint=encodings.varint,skip=encodings.skip;exports.EventType={READY:1,JOIN:2,LEAVE:3,ON_STREAM_OPEN:4,ON_STREAM_CLOSE:5,ON_STREAM_DATA:6,ON_STREAM_ERROR:7,ON_PEER:8,CONNECT:9};var SwarmEvent=exports.SwarmEvent={buffer:!0,encodingLength:null,encode:null,decode:null};function defineSwarmEvent(){var e=[encodings.enum,encodings.bytes,encodings.string,encodings.int32];function n(n){var d=0;if(!defined(n.type))throw new Error("type is required");(d+=1+e[0].encodingLength(n.type),defined(n.topic))&&(d+=1+e[1].encodingLength(n.topic));defined(n.data)&&(d+=1+e[1].encodingLength(n.data));defined(n.peer)&&(d+=1+e[2].encodingLength(n.peer));defined(n.stream)&&(d+=1+e[3].encodingLength(n.stream));return d}SwarmEvent.encodingLength=n,SwarmEvent.encode=function d(t,r,o){o||(o=0);r||(r=Buffer.allocUnsafe(n(t)));var i=o;if(!defined(t.type))throw new Error("type is required");r[o++]=8;e[0].encode(t.type,r,o);o+=e[0].encode.bytes;defined(t.topic)&&(r[o++]=18,e[1].encode(t.topic,r,o),o+=e[1].encode.bytes);defined(t.data)&&(r[o++]=26,e[1].encode(t.data,r,o),o+=e[1].encode.bytes);defined(t.peer)&&(r[o++]=34,e[2].encode(t.peer,r,o),o+=e[2].encode.bytes);defined(t.stream)&&(r[o++]=40,e[3].encode(t.stream,r,o),o+=e[3].encode.bytes);d.bytes=o-i;return r},SwarmEvent.decode=function n(d,t,r){t||(t=0);r||(r=d.length);if(!(r<=d.length&&t<=d.length))throw new Error("Decoded message is not valid");var o=t;var i={type:1,topic:null,data:null,peer:"",stream:0};var c=!1;for(;;){if(r<=t){if(!c)throw new Error("Decoded message is not valid");return n.bytes=t-o,i}var a=varint.decode(d,t);t+=varint.decode.bytes;var s=a>>3;switch(s){case 1:i.type=e[0].decode(d,t),t+=e[0].decode.bytes,c=!0;break;case 2:i.topic=e[1].decode(d,t),t+=e[1].decode.bytes;break;case 3:i.data=e[1].decode(d,t),t+=e[1].decode.bytes;break;case 4:i.peer=e[2].decode(d,t),t+=e[2].decode.bytes;break;case 5:i.stream=e[3].decode(d,t),t+=e[3].decode.bytes;break;default:t=skip(7&a,d,t)}}}}function defined(e){return null!=e&&("number"!=typeof e||!isNaN(e))}defineSwarmEvent(); }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":99,"protocol-buffers-encodings":448}],247:[function(require,module,exports){ +},{"buffer":104,"protocol-buffers-encodings":454}],253:[function(require,module,exports){ var Duplex=require("stream").Duplex;module.exports=class extends Duplex{constructor(t,s){super({emitClose:!0}),this._secretId=Math.random(),this._id=s,this._protocol=t,this._isClosed=!1,this._handle_data=this._handleData.bind(this),this._handle_close=this._handleClose.bind(this),this._handle_error=this._handleError.bind(this),this._protocol.on("on_stream_data",this._handle_data),this._protocol.on("on_stream_close",this._handle_close),this._protocol.on("on_stream_error",this._handle_error)}_handleData({stream:t,data:s}){this._isId(t)&&this.push(s)}_handleClose({stream:t}){this._isId(t)&&(this.destroy(),this._cleanup())}_handleError({stream:t,data:s}){if(this._isId(t)){const t=s.toString("utf8");this.emit("error",new Error(t)),this.destroy(),this._cleanup()}}_cleanup(){this._isClosed=!0,this._protocol.removeListener("on_stream_data",this._handle_data),this._protocol.removeListener("on_stream_close",this._handle_close),this._protocol.removeListener("on_stream_error",this._handle_error)}_isId(t){return t===this._id}_read(){}_write(t,s,e){this._protocol.onStreamData(this._id,t),e()}_final(t){this._isClosed||(this._protocol.onStreamClose(this._id),this._cleanup()),t()}}; -},{"stream":792}],248:[function(require,module,exports){ +},{"stream":814}],254:[function(require,module,exports){ (function (process){(function (){ const{EventEmitter:EventEmitter}=require("events"),webRTCSwarm=require("@geut/discovery-swarm-webrtc"),HyperswarmClient=require("hyperswarm-proxy-ws/client"),DuplexPair=require("duplexpair"),DEFAULT_WEBRTC_BOOTSTRAP=["wss://geut-webrtc-signal-v3.herokuapp.com","wss://signal.dat-web.eu","wss://geut-webrtc-signal-v3.glitch.me"],DEFAULT_PROXY_SERVER="wss://hyperswarm.mauve.moe";function getBootstrapUrls(e,t=[],s=[]){let i=t.map(t=>(t.endsWith("/")&&(t=t.slice(0,-1)),`${t}/${e}`));if(0!==(i=i.concat(s)).length)return i}module.exports=function(e){return new HyperswarmWeb(e)};class HyperswarmWeb extends EventEmitter{constructor(e={}){super();const{bootstrap:t,webrtcBootstrap:s,wsProxy:i,maxPeers:r,simplePeer:n,wsReconnectDelay:o}=e;this.webrtcOpts={maxPeers:r,simplePeer:n,bootstrap:getBootstrapUrls("signal",t,s)||DEFAULT_WEBRTC_BOOTSTRAP},this.wsOpts={maxPeers:r,proxy:getBootstrapUrls("proxy",t,i)||DEFAULT_PROXY_SERVER},o&&(this.wsOpts.reconnectDelay=o),this.isListening=!1,this.destroyed=!1}_handleWS(e,t){this.emit("connection",e,t)}_handleWebRTC(e,t){const{id:s,channel:i,initiator:r}=t,n={type:"webrtc",client:r,peer:{port:0,host:s,topic:i},deduplicate:()=>!1};this.emit("connection",e,n)}address(){return{port:0,family:"IPv4",address:"127.0.0.1"}}listen(e,t){if(this.isListening)return setTimeout(t,0);this.isListening=!0,this.webrtc=webRTCSwarm(this.webrtcOpts),this.ws=new HyperswarmClient(this.wsOpts),this.ws.on("connection",(e,t)=>this._handleWS(e,t)),this.webrtc.on("connection",(e,t)=>this._handleWebRTC(e,t))}join(e,t){this.listen(),this.webrtc.join(e),this.ws.join(e,t)}leave(e){this.listen(),this.webrtc.leave(e),this.ws.leave(e)}connect(e,t){this.listen(),this.ws.connect(e,t)}connectivity(e){this.listen(()=>{e(null,{bound:!0,bootstrapped:!0,holepunched:!0})})}flush(e){process.nextTick(e)}status(){return{lookup:!0,announce:!1}}destroy(e){this.destroyed=!0,this.webrtc.close(()=>{this.ws.destroy(e)})}} }).call(this)}).call(this,require('_process')) -},{"@geut/discovery-swarm-webrtc":6,"_process":443,"duplexpair":149,"events":186,"hyperswarm-proxy-ws/client":243}],249:[function(require,module,exports){ +},{"@geut/discovery-swarm-webrtc":6,"_process":449,"duplexpair":154,"events":192,"hyperswarm-proxy-ws/client":249}],255:[function(require,module,exports){ module.exports=IdbKvStore;var EventEmitter=require("events").EventEmitter,inherits=require("inherits"),promisize=require("promisize"),global="undefined"==typeof window?self:window,IDB=global.indexedDB||global.mozIndexedDB||global.webkitIndexedDB||global.msIndexedDB;function IdbKvStore(t,r,e){var n=this;if("string"!=typeof t)throw new Error("A name must be supplied of type string");if(!IDB)throw new Error("IndexedDB not supported");if("function"==typeof r)return new IdbKvStore(t,null,r);if(!(n instanceof IdbKvStore))return new IdbKvStore(t,r,e);if(r||(r={}),EventEmitter.call(n),n._db=null,n._closed=!1,n._channel=null,n._waiters=[],!0!==r.disableBroadcast){var o=r.channel||global.BroadcastChannel;o&&(n._channel=new o(t),n._channel.onmessage=function(t){"add"===t.data.method?n.emit("add",t.data):"set"===t.data.method?n.emit("set",t.data):"remove"===t.data.method&&n.emit("remove",t.data)})}var i=IDB.open(t);function s(t){handleError(t),n._close(t.target.error)}function a(){n._close()}i.onerror=function(t){handleError(t),n._close(t.target.error),e&&e(t.target.error)},i.onsuccess=function(t){if(n._closed)t.target.result.close();else{for(var r in n._db=t.target.result,n._db.onclose=a,n._db.onerror=s,n._waiters)n._waiters[r]._init(null);n._waiters=null,e&&e(null),n.emit("open")}},i.onupgradeneeded=function(t){t.target.result.createObjectStore("kv",{autoIncrement:!0})},n.on("newListener",function(t){if("add"!==t&&"set"!==t&&"remove"!==t)return;if(!n._channel)return n.emit("error",new Error("No BroadcastChannel support"))})}function Transaction(t,r,e){if("function"==typeof r)return new Transaction(t,null,r);if(this._kvStore=t,this._mode=r||"readwrite",this._objectStore=null,this._waiters=null,this.finished=!1,this.onfinish=promisize(e),this.done=this.onfinish.promise,"readonly"!==this._mode&&"readwrite"!==this._mode)throw new Error('mode must be either "readonly" or "readwrite"')}function handleError(t,r){if(null==r)return handleError(null,t);r.preventDefault(),r.stopPropagation(),t&&t(r.target.error)}IdbKvStore.INDEXEDDB_SUPPORT=null!=IDB,IdbKvStore.BROADCAST_SUPPORT=null!=global.BroadcastChannel,inherits(IdbKvStore,EventEmitter),IdbKvStore.prototype.get=function(t,r){return this.transaction("readonly").get(t,r)},IdbKvStore.prototype.getMultiple=function(t,r){return this.transaction("readonly").getMultiple(t,r)},IdbKvStore.prototype.set=function(t,r,e){e=promisize(e);var n=null;return this.transaction("readwrite",function(t){e(n=n||t)}).set(t,r,function(t){n=t}),e.promise},IdbKvStore.prototype.json=function(t,r){return this.transaction("readonly").json(t,r)},IdbKvStore.prototype.keys=function(t,r){return this.transaction("readonly").keys(t,r)},IdbKvStore.prototype.values=function(t,r){return this.transaction("readonly").values(t,r)},IdbKvStore.prototype.remove=function(t,r){r=promisize(r);var e=null;return this.transaction("readwrite",function(t){r(e=e||t)}).remove(t,function(t){e=t}),r.promise},IdbKvStore.prototype.clear=function(t){t=promisize(t);var r=null;return this.transaction("readwrite",function(e){t(r=r||e)}).clear(function(t){r=t}),t.promise},IdbKvStore.prototype.count=function(t,r){return this.transaction("readonly").count(t,r)},IdbKvStore.prototype.add=function(t,r,e){e=promisize(e);var n=null;return this.transaction("readwrite",function(t){e(n=n||t)}).add(t,r,function(t){n=t}),e.promise},IdbKvStore.prototype.iterator=function(t,r){return this.transaction("readonly").iterator(t,r)},IdbKvStore.prototype.transaction=function(t,r){if(this._closed)throw new Error("Database is closed");var e=new Transaction(this,t,r);return this._db?e._init(null):this._waiters.push(e),e},IdbKvStore.prototype.close=function(){this._close()},IdbKvStore.prototype._close=function(t){if(!this._closed){for(var r in this._closed=!0,this._db&&this._db.close(),this._channel&&this._channel.close(),this._db=null,this._channel=null,t&&this.emit("error",t),this.emit("close"),this._waiters)this._waiters[r]._init(t||new Error("Database is closed"));this._waiters=null,this.removeAllListeners()}},Transaction.prototype._init=function(t){var r=this;if(!r.finished){if(t)return r._close(t);var e=r._kvStore._db.transaction("kv",r._mode);for(var n in e.oncomplete=function(){r._close(null)},e.onerror=o,e.onabort=o,r._objectStore=e.objectStore("kv"),r._waiters)r._waiters[n](null,r._objectStore);r._waiters=null}function o(t){handleError(t),r._close(t.target.error)}},Transaction.prototype._getObjectStore=function(t){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)return t(null,this._objectStore);this._waiters=this._waiters||[],this._waiters.push(t)},Transaction.prototype.set=function(t,r,e){var n=this;if(null==t||null==r)throw new Error("A key and value must be given");return e=promisize(e),n._getObjectStore(function(o,i){if(o)return e(o);try{var s=i.put(r,t)}catch(t){return e(t)}s.onerror=handleError.bind(this,e),s.onsuccess=function(){n._kvStore._channel&&n._kvStore._channel.postMessage({method:"set",key:t,value:r}),e(null)}}),e.promise},Transaction.prototype.add=function(t,r,e){var n=this;if(null==r&&null!=t)return n.add(void 0,t,e);if("function"==typeof r||null==r&&null==e)return n.add(void 0,t,r);if(null==r)throw new Error("A value must be provided as an argument");return e=promisize(e),n._getObjectStore(function(o,i){if(o)return e(o);try{var s=null==t?i.add(r):i.add(r,t)}catch(t){return e(t)}s.onerror=handleError.bind(this,e),s.onsuccess=function(){n._kvStore._channel&&n._kvStore._channel.postMessage({method:"add",key:t,value:r}),e(null)}}),e.promise},Transaction.prototype.get=function(t,r){if(null==t)throw new Error("A key must be given as an argument");return r=promisize(r),this._getObjectStore(function(e,n){if(e)return r(e);try{var o=n.get(t)}catch(t){return r(t)}o.onerror=handleError.bind(this,r),o.onsuccess=function(t){r(null,t.target.result)}}),r.promise},Transaction.prototype.getMultiple=function(t,r){if(null==t)throw new Error("An array of keys must be given as an argument");return r=promisize(r),0===t.length?(r(null,[]),r.promise):(this._getObjectStore(function(e,n){if(e)return r(e);var o=t.slice().sort(),i=0,s={},a=function(){return t.map(function(t){return s[t]})},u=n.openCursor();u.onerror=handleError.bind(this,r),u.onsuccess=function(t){var e=t.target.result;if(e){for(var n=e.key;n>o[i];)if(++i===o.length)return void r(null,a());n===o[i]?(s[n]=e.value,e.continue()):e.continue(o[i])}else r(null,a())}}),r.promise)},Transaction.prototype.json=function(t,r){if("function"==typeof t)return this.json(null,t);r=promisize(r);var e={};return this.iterator(t,function(t,n){if(t)return r(t);n?(e[n.key]=n.value,n.continue()):r(null,e)}),r.promise},Transaction.prototype.keys=function(t,r){if("function"==typeof t)return this.keys(null,t);r=promisize(r);var e=[];return this.iterator(t,function(t,n){if(t)return r(t);n?(e.push(n.key),n.continue()):r(null,e)}),r.promise},Transaction.prototype.values=function(t,r){if("function"==typeof t)return this.values(null,t);r=promisize(r);var e=[];return this.iterator(t,function(t,n){if(t)return r(t);n?(e.push(n.value),n.continue()):r(null,e)}),r.promise},Transaction.prototype.remove=function(t,r){var e=this;if(null==t)throw new Error("A key must be given as an argument");return r=promisize(r),e._getObjectStore(function(n,o){if(n)return r(n);try{var i=o.delete(t)}catch(t){return r(t)}i.onerror=handleError.bind(this,r),i.onsuccess=function(){e._kvStore._channel&&e._kvStore._channel.postMessage({method:"remove",key:t}),r(null)}}),r.promise},Transaction.prototype.clear=function(t){return t=promisize(t),this._getObjectStore(function(r,e){if(r)return t(r);try{var n=e.clear()}catch(r){return t(r)}n.onerror=handleError.bind(this,t),n.onsuccess=function(){t(null)}}),t.promise},Transaction.prototype.count=function(t,r){return"function"==typeof t?this.count(null,t):(r=promisize(r),this._getObjectStore(function(e,n){if(e)return r(e);try{var o=null==t?n.count():n.count(t)}catch(t){return r(t)}o.onerror=handleError.bind(this,r),o.onsuccess=function(t){r(null,t.target.result)}}),r.promise)},Transaction.prototype.iterator=function(t,r){if("function"==typeof t)return this.iterator(null,t);if("function"!=typeof r)throw new Error("A function must be given");this._getObjectStore(function(e,n){if(e)return r(e);try{var o=null==t?n.openCursor():n.openCursor(t)}catch(t){return r(t)}o.onerror=handleError.bind(this,r),o.onsuccess=function(t){var e=t.target.result;r(null,e)}})},Transaction.prototype.abort=function(){if(this.finished)throw new Error("Transaction is finished");this._objectStore&&this._objectStore.transaction.abort(),this._close(new Error("Transaction aborted"))},Transaction.prototype._close=function(t){if(!this.finished){for(var r in this.finished=!0,this._kvStore=null,this._objectStore=null,this._waiters)this._waiters[r](t||new Error("Transaction is finished"));this._waiters=null,this.onfinish&&this.onfinish(t),this.onfinish=null}}; -},{"events":186,"inherits":258,"promisize":447}],250:[function(require,module,exports){ +},{"events":192,"inherits":264,"promisize":453}],256:[function(require,module,exports){ exports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l}; -},{}],251:[function(require,module,exports){ +},{}],257:[function(require,module,exports){ "use strict";var draining,currentQueue,scheduleDrain,types=[require("./nextTick"),require("./queueMicrotask"),require("./mutation.js"),require("./messageChannel"),require("./stateChange"),require("./timeout")],queueIndex=-1,queue=[],scheduled=!1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&nextTick())}function nextTick(){if(!draining){scheduled=!1,draining=!0;for(var e=queue.length,u=setTimeout(cleanUpNextTick);e;){for(currentQueue=queue,queue=[];currentQueue&&++queueIndex1)for(var n=1;n=0&&255===r[e];e--)r[e]=0;return~e&&(r[e]=r[e]+1),r}; -},{}],258:[function(require,module,exports){ +},{}],264:[function(require,module,exports){ "function"==typeof Object.create?module.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:module.exports=function(t,e){if(e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}}; -},{}],259:[function(require,module,exports){ +},{}],265:[function(require,module,exports){ "use strict";var ip=exports,Buffer=require("buffer").Buffer,os=require("os");ip.toBuffer=function(r,t,e){var i;if(e=~~e,this.isV4Format(r))i=t||new Buffer(e+4),r.split(/\./g).map(function(r){i[e++]=255&parseInt(r,10)});else if(this.isV6Format(r)){var n,f=r.split(":",8);for(n=0;n0;n--)s.push("0");f.splice.apply(f,s)}for(i=t||new Buffer(e+16),n=0;n>8&255,i[e++]=255&a}}if(!i)throw Error("Invalid ip address: "+r);return i},ip.toString=function(r,t,e){t=~~t;var i=[];if(4===(e=e||r.length-t)){for(var n=0;n32?"ipv6":_normalizeFamily(t))&&(e=16);for(var i=new Buffer(e),n=0,f=i.length;n>o)}return ip.toString(i)},ip.mask=function(r,t){r=ip.toBuffer(r),t=ip.toBuffer(t);var e=new Buffer(Math.max(r.length,t.length)),i=0;if(r.length===t.length)for(i=0;ir.length&&(i=t,n=r);var f=i.length-n.length;for(e=f;e>>0},ip.fromLong=function(r){return(r>>>24)+"."+(r>>16&255)+"."+(r>>8&255)+"."+(255&r)}; -},{"buffer":99,"os":407}],260:[function(require,module,exports){ +},{"buffer":104,"os":413}],266:[function(require,module,exports){ "use strict";var hasToStringTag="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),isStandardArguments=function(t){return!(hasToStringTag&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===$toString(t)},isLegacyArguments=function(t){return!!isStandardArguments(t)||null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==$toString(t)&&"[object Function]"===$toString(t.callee)},supportsStandardArguments=function(){return isStandardArguments(arguments)}();isStandardArguments.isLegacyArguments=isLegacyArguments,module.exports=supportsStandardArguments?isStandardArguments:isLegacyArguments; -},{"call-bind/callBound":106}],261:[function(require,module,exports){ +},{"call-bind/callBound":111}],267:[function(require,module,exports){ function isBuffer(f){return!!f.constructor&&"function"==typeof f.constructor.isBuffer&&f.constructor.isBuffer(f)}function isSlowBuffer(f){return"function"==typeof f.readFloatLE&&"function"==typeof f.slice&&isBuffer(f.slice(0,0))}module.exports=function(f){return null!=f&&(isBuffer(f)||isSlowBuffer(f)||!!f._isBuffer)}; -},{}],262:[function(require,module,exports){ +},{}],268:[function(require,module,exports){ var char="[a-zA-Z0-9/+]",trail2="[AQgw]==",trail4="[AEIMQUYcgkosw048]=",rx="(?:"+char+"{4})*(?:"+char+"(?:(?:"+trail2+")|(?:"+char+trail4+")))?";module.exports=function(r,a,e){if(!Number.isInteger(e))return new RegExp("^"+(r||"")+rx+(a||"")+"$");var t=e%3;return new RegExp("^"+(r||"")+char+"{"+~~(8*e/6)+"}"+(0===t?"":1===t?trail2:trail4)+(a||"")+"$")}; -},{}],263:[function(require,module,exports){ +},{}],269:[function(require,module,exports){ "use strict";var getDay=Date.prototype.getDay,tryDateObject=function(t){try{return getDay.call(t),!0}catch(t){return!1}},toStr=Object.prototype.toString,dateClass="[object Date]",hasToStringTag="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;module.exports=function(t){return"object"==typeof t&&null!==t&&(hasToStringTag?tryDateObject(t):toStr.call(t)===dateClass)}; -},{}],264:[function(require,module,exports){ +},{}],270:[function(require,module,exports){ "use strict";var toStr=Object.prototype.toString,fnToStr=Function.prototype.toString,isFnRegex=/^\s*(?:function)?\*/,hasToStringTag="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,getProto=Object.getPrototypeOf,getGeneratorFunc=function(){if(!hasToStringTag)return!1;try{return Function("return function*() {}")()}catch(t){}},generatorFunc=getGeneratorFunc(),GeneratorFunction=!(!getProto||!generatorFunc)&&getProto(generatorFunc);module.exports=function(t){return"function"==typeof t&&(!!isFnRegex.test(fnToStr.call(t))||(hasToStringTag?getProto&&getProto(t)===GeneratorFunction:"[object GeneratorFunction]"===toStr.call(t)))}; -},{}],265:[function(require,module,exports){ +},{}],271:[function(require,module,exports){ (function (Buffer){(function (){ function isOptions(e){return"object"==typeof e&&e&&!Buffer.isBuffer(e)}module.exports=isOptions; }).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":261}],266:[function(require,module,exports){ +},{"../is-buffer/index.js":267}],272:[function(require,module,exports){ "use strict";var has,$exec,isRegexMarker,badStringifier,callBound=require("call-bind/callBound"),hasSymbols=require("has-symbols/shams")(),hasToStringTag=hasSymbols&&!!Symbol.toStringTag;if(hasToStringTag){has=callBound("Object.prototype.hasOwnProperty"),$exec=callBound("RegExp.prototype.exec"),isRegexMarker={};var throwRegexMarker=function(){throw isRegexMarker};badStringifier={toString:throwRegexMarker,valueOf:throwRegexMarker},"symbol"==typeof Symbol.toPrimitive&&(badStringifier[Symbol.toPrimitive]=throwRegexMarker)}var $toString=callBound("Object.prototype.toString"),gOPD=Object.getOwnPropertyDescriptor,regexClass="[object RegExp]";module.exports=hasToStringTag?function(e){if(!e||"object"!=typeof e)return!1;var r=gOPD(e,"lastIndex");if(!(r&&has(r,"value")))return!1;try{$exec(e,badStringifier)}catch(e){return e===isRegexMarker}}:function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&$toString(e)===regexClass}; -},{"call-bind/callBound":106,"has-symbols/shams":207}],267:[function(require,module,exports){ +},{"call-bind/callBound":111,"has-symbols/shams":213}],273:[function(require,module,exports){ (function (global){(function (){ "use strict";var forEach=require("foreach"),availableTypedArrays=require("available-typed-arrays"),callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),hasSymbols=require("has-symbols")(),hasToStringTag=hasSymbols&&"symbol"==typeof Symbol.toStringTag,typedArrays=availableTypedArrays(),$indexOf=callBound("Array.prototype.indexOf",!0)||function(r,t){for(var e=0;e-1}return!!gOPD&&tryTypedArrays(r)}; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"available-typed-arrays":48,"call-bind/callBound":106,"es-abstract/helpers/getOwnPropertyDescriptor":184,"foreach":199,"has-symbols":206}],268:[function(require,module,exports){ +},{"available-typed-arrays":48,"call-bind/callBound":111,"es-abstract/helpers/getOwnPropertyDescriptor":190,"foreach":205,"has-symbols":212}],274:[function(require,module,exports){ module.exports=isTypedArray,isTypedArray.strict=isStrictTypedArray,isTypedArray.loose=isLooseTypedArray;var toString=Object.prototype.toString,names={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function isTypedArray(r){return isStrictTypedArray(r)||isLooseTypedArray(r)}function isStrictTypedArray(r){return r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array}function isLooseTypedArray(r){return names[toString.call(r)]} -},{}],269:[function(require,module,exports){ +},{}],275:[function(require,module,exports){ module.exports={ "com.ac": true, "net.ac": true, @@ -2781,532 +2809,534 @@ module.exports={ "org.zm": true, "sch.zm": true } -},{}],270:[function(require,module,exports){ +},{}],276:[function(require,module,exports){ const sldMap=require("./data/sldMap.json");module.exports=function(t,e){if("string"!=typeof t)return!1;if(e instanceof Object||(e={}),(t=t.toLowerCase()).endsWith(".")&&(t=t.slice(0,t.length-1)),t.length>253)return!1;if(!/^([a-z0-9-._*]+)$/g.test(t))return!1;const n=t.match(/(.*)\.(([a-z0-9]+)(\.[a-z0-9]+))/);var r=null,l=null;if(n&&n.length>2&&sldMap[n[2]]&&(r=n[2],l=n[1].split(".")),!l){if((l=t.split(".")).length<=1)return!1;if(r=l.pop(),!/^(?:xn--)?(?!^\d+$)[a-z0-9]+$/gi.test(r))return!1}if(!1===e.subdomain&&l.length>1)return!1;return l.every(function(t,n){if(e.wildcard&&0===n&&"*"===t&&l.length>1)return!0;let r=/^([a-zA-Z0-9-_]+)$/g;return n===l.length-1&&(r=/^([a-zA-Z0-9-]+)$/g),(t.match(/--/g)||[]).length===(t.match(/xn--/g)||[]).length&&(r.test(t)&&t.length<64&&!t.startsWith("-")&&!t.endsWith("-"))})}; -},{"./data/sldMap.json":269}],271:[function(require,module,exports){ +},{"./data/sldMap.json":275}],277:[function(require,module,exports){ var toString={}.toString;module.exports=Array.isArray||function(r){return"[object Array]"==toString.call(r)}; -},{}],272:[function(require,module,exports){ +},{}],278:[function(require,module,exports){ (function (global){(function (){ var ws=null;"undefined"!=typeof WebSocket?ws=WebSocket:"undefined"!=typeof MozWebSocket?ws=MozWebSocket:"undefined"!=typeof global?ws=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?ws=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(ws=self.WebSocket||self.MozWebSocket),module.exports=ws; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],273:[function(require,module,exports){ +},{}],279:[function(require,module,exports){ (function (Buffer){(function (){ -const jsesc=require("jsesc"),sanitize=require("sanitize-filename"),TypedFastBitSet=require("typedfastbitset"),{readFile:readFile,writeFile:writeFile}=require("atomic-file-rw"),toBuffer=require("typedarray-to-buffer"),crcCalculate=require("crc/lib/crc32"),FIELD_SIZE=4;function calculateCRCAndWriteFile(e,r,i){const t=crcCalculate(e);e.writeUInt32LE(t,3*FIELD_SIZE),writeFile(r,e,i)}function readFileAndCheckCRC(e,r){readFile(e,(e,i)=>{if(e)return r(e);const t=i.readUInt32LE(3*FIELD_SIZE);i.writeUInt32LE(0,3*FIELD_SIZE);const l=crcCalculate(i);if(0!==t&&l!==t)return r("crc check failed");r(null,i)})}function saveTypedArrayFile(e,r,i,t,l,a){a||(a=(e=>{e&&console.error(e)}));const n=toBuffer(l),s=Math.min(1.1*t,l.length),c=Buffer.alloc(4*FIELD_SIZE+s*l.BYTES_PER_ELEMENT);c.writeUInt32LE(r,0),c.writeUInt32LE(i,FIELD_SIZE),c.writeUInt32LE(t,2*FIELD_SIZE),n.copy(c,4*FIELD_SIZE),calculateCRCAndWriteFile(c,e,a)}function loadTypedArrayFile(e,r,i){readFileAndCheckCRC(e,(e,t)=>{if(e)return i(e);const l=t.readUInt32LE(0),a=t.readUInt32LE(FIELD_SIZE),n=t.readUInt32LE(2*FIELD_SIZE),s=t.slice(4*FIELD_SIZE);i(null,{version:l,offset:a,count:n,tarr:new r(s.buffer,s.offset,s.byteLength/(r===Float64Array?8:4))})})}function savePrefixMapFile(e,r,i,t,l,a){a||(a=(e=>{e&&console.error(e)}));const n=JSON.stringify(l),s=Buffer.alloc(4*FIELD_SIZE+n.length);s.writeUInt32LE(r,0),s.writeUInt32LE(i,FIELD_SIZE),s.writeUInt32LE(t,2*FIELD_SIZE),Buffer.from(n).copy(s,4*FIELD_SIZE),calculateCRCAndWriteFile(s,e,a)}function loadPrefixMapFile(e,r){readFileAndCheckCRC(e,(e,i)=>{if(e)return r(e);const t=i.readUInt32LE(0),l=i.readUInt32LE(FIELD_SIZE),a=i.readUInt32LE(2*FIELD_SIZE),n=i.slice(4*FIELD_SIZE),s=JSON.parse(n);r(null,{version:t,offset:l,count:a,map:s})})}function saveBitsetFile(e,r,i,t,l){t.trim(),saveTypedArrayFile(e,r,i,t.words.length,t.words,l)}function loadBitsetFile(e,r){loadTypedArrayFile(e,Uint32Array,(e,i)=>{if(e)return r(e);const{version:t,offset:l,count:a,tarr:n}=i,s=new TypedFastBitSet;s.words=n,r(null,{version:t,offset:l,bitset:s})})}function listFilesIDB(e,r){new(require("idb-kv-store"))(e,{disableBroadcast:!0}).keys(r)}function listFilesFS(e,r){const i=require("fs");require("mkdirp")(e).then(()=>{i.readdir(e,r)},r)}function safeFilename(e){let r=jsesc(e);return r=(r=(r=(r=(r=(r=(r=(r=r.replace(/\./g,"x2E")).replace(/\//g,"x2F")).replace(/\?/g,"x3F")).replace(/\/g,"x3E")).replace(/\:/g,"x3A")).replace(/\*/g,"x2A")).replace(/\|/g,"x7C"),sanitize(r)}module.exports={saveTypedArrayFile:saveTypedArrayFile,loadTypedArrayFile:loadTypedArrayFile,savePrefixMapFile:savePrefixMapFile,loadPrefixMapFile:loadPrefixMapFile,saveBitsetFile:saveBitsetFile,loadBitsetFile:loadBitsetFile,listFilesIDB:listFilesIDB,listFilesFS:listFilesFS,safeFilename:safeFilename}; +const jsesc=require("jsesc"),sanitize=require("sanitize-filename"),TypedFastBitSet=require("typedfastbitset"),{readFile:readFile,writeFile:writeFile}=require("atomic-file-rw"),toBuffer=require("typedarray-to-buffer"),crcCalculate=require("crc/lib/crc32"),FIELD_SIZE=4;function calculateCRCAndWriteFile(e,r,i){const t=crcCalculate(e);e.writeUInt32LE(t,3*FIELD_SIZE),writeFile(r,e,i)}function readFileAndCheckCRC(e,r){readFile(e,(e,i)=>{if(e)return r(e);const t=i.readUInt32LE(3*FIELD_SIZE);i.writeUInt32LE(0,3*FIELD_SIZE);const l=crcCalculate(i);if(0!==t&&l!==t)return r("crc check failed");r(null,i)})}function saveTypedArrayFile(e,r,i,t,l,a){if(a||(a=(e=>{e&&console.error(e)})),"number"!=typeof r)return a(new Error("cannot save file "+e+" without version"));const n=toBuffer(l),s=Math.min(1.1*t,l.length),o=Buffer.alloc(4*FIELD_SIZE+s*l.BYTES_PER_ELEMENT);o.writeUInt32LE(r,0),o.writeUInt32LE(i,FIELD_SIZE),o.writeUInt32LE(t,2*FIELD_SIZE),n.copy(o,4*FIELD_SIZE),calculateCRCAndWriteFile(o,e,a)}function loadTypedArrayFile(e,r,i){readFileAndCheckCRC(e,(e,t)=>{if(e)return i(e);const l=t.readUInt32LE(0),a=t.readUInt32LE(FIELD_SIZE),n=t.readUInt32LE(2*FIELD_SIZE),s=t.slice(4*FIELD_SIZE);i(null,{version:l,offset:a,count:n,tarr:new r(s.buffer,s.offset,s.byteLength/(r===Float64Array?8:4))})})}function savePrefixMapFile(e,r,i,t,l,a){if(a||(a=(e=>{e&&console.error(e)})),"number"!=typeof r)return a(new Error("cannot save file "+e+" without version"));const n=JSON.stringify(l),s=Buffer.alloc(4*FIELD_SIZE+n.length);s.writeUInt32LE(r,0),s.writeUInt32LE(i,FIELD_SIZE),s.writeUInt32LE(t,2*FIELD_SIZE),Buffer.from(n).copy(s,4*FIELD_SIZE),calculateCRCAndWriteFile(s,e,a)}function loadPrefixMapFile(e,r){readFileAndCheckCRC(e,(e,i)=>{if(e)return r(e);const t=i.readUInt32LE(0),l=i.readUInt32LE(FIELD_SIZE),a=i.readUInt32LE(2*FIELD_SIZE),n=i.slice(4*FIELD_SIZE),s=JSON.parse(n);r(null,{version:t,offset:l,count:a,map:s})})}function saveBitsetFile(e,r,i,t,l){t.trim(),saveTypedArrayFile(e,r,i,t.words.length,t.words,l)}function loadBitsetFile(e,r){loadTypedArrayFile(e,Uint32Array,(e,i)=>{if(e)return r(e);const{version:t,offset:l,count:a,tarr:n}=i,s=new TypedFastBitSet;s.words=n,r(null,{version:t,offset:l,bitset:s})})}function listFilesIDB(e,r){new(require("idb-kv-store"))(e,{disableBroadcast:!0}).keys(r)}function listFilesFS(e,r){const i=require("fs");require("mkdirp")(e).then(()=>{i.readdir(e,r)},r)}function safeFilename(e){let r=jsesc(e);return r=(r=(r=(r=(r=(r=(r=(r=r.replace(/\./g,"x2E")).replace(/\//g,"x2F")).replace(/\?/g,"x3F")).replace(/\/g,"x3E")).replace(/\:/g,"x3A")).replace(/\*/g,"x2A")).replace(/\|/g,"x7C"),sanitize(r)}module.exports={saveTypedArrayFile:saveTypedArrayFile,loadTypedArrayFile:loadTypedArrayFile,savePrefixMapFile:savePrefixMapFile,loadPrefixMapFile:loadPrefixMapFile,saveBitsetFile:saveBitsetFile,loadBitsetFile:loadBitsetFile,listFilesIDB:listFilesIDB,listFilesFS:listFilesFS,safeFilename:safeFilename}; }).call(this)}).call(this,require("buffer").Buffer) -},{"atomic-file-rw":44,"buffer":99,"crc/lib/crc32":112,"fs":98,"idb-kv-store":249,"jsesc":277,"mkdirp":345,"sanitize-filename":631,"typedarray-to-buffer":839,"typedfastbitset":840}],274:[function(require,module,exports){ +},{"atomic-file-rw":44,"buffer":104,"crc/lib/crc32":117,"fs":103,"idb-kv-store":255,"jsesc":283,"mkdirp":350,"sanitize-filename":640,"typedarray-to-buffer":863,"typedfastbitset":864}],280:[function(require,module,exports){ (function (Buffer){(function (){ -const path=require("path"),bipf=require("bipf"),push=require("push-stream"),pull=require("pull-stream"),toPull=require("push-stream-to-pull-stream"),pullAsync=require("pull-async"),TypedFastBitSet=require("typedfastbitset"),bsb=require("binary-search-bounds"),multicb=require("multicb"),FastPriorityQueue=require("fastpriorityqueue"),debug=require("debug")("jitdb"),debugQuery=debug.extend("query"),Status=require("./status"),{saveTypedArrayFile:saveTypedArrayFile,loadTypedArrayFile:loadTypedArrayFile,savePrefixMapFile:savePrefixMapFile,loadPrefixMapFile:loadPrefixMapFile,saveBitsetFile:saveBitsetFile,loadBitsetFile:loadBitsetFile,safeFilename:safeFilename,listFilesIDB:listFilesIDB,listFilesFS:listFilesFS}=require("./files");module.exports=function(e,t){debug("indexes path",t);let n=new WeakMap,a={ascending:new WeakMap,descending:new WeakMap},i=-1;const s=Status(),r={};let o=!1,u=[];function f(e){o?e():u.push(e)}!function(e){function n(n,a){push(push.values(a),push.asyncMap((e,n)=>{const a=path.parse(e).name;"seq.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||(r[a]=t),n()}):"timestamp.index"===e?loadTypedArrayFile(path.join(t,e),Float64Array,(e,t)=>{e||(r[a]=t),n()}):"sequence.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||(r[a]=t),n()}):e.endsWith(".32prefix")?(r[a]={offset:-1,count:0,tarr:new Uint32Array(16e3),lazy:!0,prefix:32,filepath:path.join(t,e)},n()):e.endsWith(".32prefixmap")?(r[a]={offset:-1,count:0,map:{},lazy:!0,prefix:32,filepath:path.join(t,e)},n()):e.endsWith(".index")?(r[a]={offset:0,bitset:new TypedFastBitSet,lazy:!0,filepath:path.join(t,e)},n()):n()}),push.collect(e))}"undefined"!=typeof window?listFilesIDB(t,n):listFilesFS(t,n)}(()=>{debug("loaded indexes",Object.keys(r)),r.seq||(r.seq={offset:-1,count:0,tarr:new Uint32Array(16e3)}),r.timestamp||(r.timestamp={offset:-1,count:0,tarr:new Float64Array(16e3)}),r.sequence||(r.sequence={offset:-1,count:0,tarr:new Uint32Array(16e3)}),s.batchUpdate(r,["seq","timestamp","sequence"]),o=!0;for(let e=0;ei&&(i=e.since.value,n=new WeakMap,a.ascending=new WeakMap,a.descending=new WeakMap)}function y(e,n,a){if(n.offset<0)return;debug("saving core index: %s",e);const i=path.join(t,e+".index");saveTypedArrayFile(i,n.version||1,n.offset,a,n.tarr)}function m(e,n,a){if(n.offset<0||0===n.bitset.size())return;debug("saving index: %s",e);const i=path.join(t,e+".index");saveBitsetFile(i,n.version||1,n.offset,n.bitset,a)}function g(e,n,a,i){if(n.offset<0)return;debug("saving prefix index: %s",e);const s=n.prefix,r=path.join(t,e+`.${s}prefix`);saveTypedArrayFile(r,n.version||1,n.offset,a,n.tarr,i)}function h(e,n,a,i){if(n.offset<0)return;debug("saving prefix map index: %s",e);const s=n.prefix,r=path.join(t,e+`.${s}prefixmap`);savePrefixMapFile(r,n.version||1,n.offset,a,n.map,i)}function b(e,t){debug("growing index");const n=new t(2*e.tarr.length);n.set(e.tarr),e.tarr=n}function x(e,t){if(e>r.seq.count-1)return e>r.seq.tarr.length-1&&b(r.seq,Uint32Array),r.seq.offset=t,r.seq.tarr[e]=t,r.seq.count=e+1,!0}function q(e,t,n){if(e>r.timestamp.count-1){e>r.timestamp.tarr.length-1&&b(r.timestamp,Float64Array),r.timestamp.offset=t;var a=0;a=bipf.seekKey(n,a,d);const i=bipf.decode(n,a);a=0,a=bipf.seekKey(n,a,l),a=bipf.seekKey(n,a,d);const s=bipf.decode(n,a),o=Math.min(i,s);return r.timestamp.tarr[e]=o,r.timestamp.count=e+1,!0}}function v(e,t,n){if(e>r.sequence.count-1){e>r.sequence.tarr.length-1&&b(r.sequence,Uint32Array),r.sequence.offset=t;var a=0;return a=bipf.seekKey(n,a,l),a=bipf.seekKey(n,a,p),r.sequence.tarr[e]=bipf.decode(n,a),r.sequence.count=e+1,!0}}function F(e,t){const n=e.seek(t);return e.value?!(!~n||0!==bipf.compareString(t,n,e.value)):-1===n}function S(e,t){const n=e.seek(t);if(!~n)return!1;const a=bipf.getEncodedType(t,n);if(a===bipf.types.string)return F(e,t);if(a===bipf.types.array){let a=!1;return bipf.iterate(t,n,(n,i)=>{const s=e.pluck?e.pluck(t,i):i;if(0===bipf.compareString(t,s,e.value))return a=!0,!0}),a}return!1}function w(e,t=0){if(e.length<4){const t=Buffer.alloc(4);return e.copy(t),t.readUInt32LE(0)}return 4===e.length?e.readUInt32LE(0):e.readUInt32LE(t)}function E(e,t,n,a,i){if(a>t.count-1){const s=e.seek(n);if(~s){const i=bipf.slice(n,s);if(i.length){const n=w(i,e.prefixOffset);!function(e,t,n){if(0===n)return;(e[n]||(e[n]=[])).push(t)}(t.map,a,n)}}t.offset=i,t.count=a+1}}function N(e,t,n,a,i){if(a>t.count-1){a>t.tarr.length-1&&b(t,Uint32Array);const s=e.seek(n);if(~s){const i=bipf.slice(n,s);t.tarr[a]=i.length?w(i,e.prefixOffset):0}else t.tarr[a]=0;t.offset=i,t.count=a+1}}function T(e,t,n,a){"EQUAL"===e.type&&F(e.data,n)?t.bitset.add(a):"INCLUDES"===e.type&&S(e.data,n)&&t.bitset.add(a)}function A(e,t,n){if(e.has(t))return e.get(t).push(n),!0;e.set(t,[])}function $(e,t){e.get(t).forEach(e=>e()),e.delete(t)}const M=new Map;const U=new Map;function D(t,n){const a={},i=["seq","timestamp","sequence"],o=t.map(e=>e.data.indexName),u=o.join("|");if(A(U,u,n))return;t.forEach(e=>{e.data.prefix&&e.data.useMap?a[e.data.indexName]={offset:0,count:0,map:{},prefix:"number"==typeof e.data.prefix?e.data.prefix:32}:e.data.prefix?a[e.data.indexName]={offset:0,count:0,tarr:new Uint32Array(16e3),prefix:"number"==typeof e.data.prefix?e.data.prefix:32}:a[e.data.indexName]={offset:0,bitset:new TypedFastBitSet}});let f=0,d=!1,p=!1,l=!1;const c=Date.now();let b=c;function F(e,t,n){for(var i in d&&y("seq",r.seq,e),p&&y("timestamp",r.timestamp,e),l&&y("sequence",r.sequence,e),a){const s=a[i];n&&(r[i]=s),s.offset=t,s.prefix&&s.map?h(i,s,e):s.prefix?g(i,s,e):m(i,s)}}const S=Math.ceil(1e3*Math.random());debug(`log.stream #${S} started, to create indexes ${u}`),e.stream({}).pipe({paused:!1,write:function(e){const n=e.offset,u=e.value;if(x(f,n)&&(d=!0),u){if(q(f,n,u)&&(p=!0),v(f,n,u)&&(l=!0),t.forEach(e=>{e.data.prefix&&e.data.useMap?E(e.data,a[e.data.indexName],u,f,n):e.data.prefix?N(e.data,a[e.data.indexName],u,f,n):e.data.indexAll?function(e,t,n,a){const i=e.seek(n),s=bipf.decode(n,i),r=safeFilename(e.indexType+"_"+s);t[r]||(t[r]={offset:0,bitset:new TypedFastBitSet}),t[r].bitset.add(a)}(e.data,a,u,f):T(e,a[e.data.indexName],u,f)}),f%1e3==0){s.batchUpdate(r,i),s.batchUpdate(a,o);const e=Date.now();e-b>=6e4&&(b=e,F(f,n,!1))}f++}else f++},end:()=>{const e=f;debug(`log.stream #${S} done ${e} records in ${Date.now()-c}ms`),F(e,r.seq.offset,!0),s.batchUpdate(r,i),s.batchUpdate(a,o),$(U,u),n()}})}const k=new Map;function L(e,t){if(A(k,e,t))return;debug("lazy loading %s",e);let n=r[e];n.prefix&&n.map?loadPrefixMapFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete r[e],t();const{version:s,offset:o,count:u,map:f}=i;n.version=s,n.offset=o,n.count=u,n.map=f,n.lazy=!1,$(k,e),t()}):n.prefix?loadTypedArrayFile(n.filepath,Uint32Array,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete r[e],t();const{version:s,offset:o,count:u,tarr:f}=i;n.version=s,n.offset=o,n.count=u,n.tarr=f,n.lazy=!1,$(k,e),t()}):loadBitsetFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete r[e],t();const{version:s,offset:o,bitset:u}=i;n.version=s,n.offset=o,n.bitset=u,n.lazy=!1,$(k,e),t()})}function Q(t,n){e.since.value>r[t.data.indexName].offset?function(t,n){const a=r[t.data.indexName],i=["seq","timestamp","sequence",t.data.indexName],o=t.data.indexName;if(A(M,o,n))return;let u=0;if(-1!==a.offset){const{tarr:e}=r.seq,t=a.offset;for(const n=e.length;u=6e4&&(b=e,S(u,n))}u++}else u++},end:()=>{const e=u;debug(`log.stream #${w} done ${u-l} records in ${Date.now()-c}ms`),S(e,r.seq.offset),s.batchUpdate(r,i),$(M,o),n()}})}(t,n):(debug("ensureIndexSync %s is already synced",t.data.indexName),n())}function B(e){Q({data:{indexName:"seq"}},e)}function O(e,t,n){Q(e,()=>{if("sequence"===e.data.indexName){const a=new TypedFastBitSet,{tarr:i,count:s}=r.sequence;for(let n=0;n{const t=new TypedFastBitSet,{count:n}=r.sequence;t.addRange(0,n),e(t)})}function z(e,t){let n=e[0];return e.slice(1).forEach(e=>{n={type:t,data:[n,e]}}),n}function j(e){if("EQUAL"===e.type||"INCLUDES"===e.type){const t=e.data.value?e.data.value.toString().substring(0,10):"";return`${e.data.indexType}(${t})`}if("GT"===e.type||"GTE"===e.type||"LT"===e.type||"LTE"===e.type){const t=e.data.value?e.data.value.toString().substring(0,10):"";return`${e.type}(${t})`}if("SEQS"===e.type)return`SEQS(${e.seqs.toString().substring(0,10)})`;if("OFFSETS"===e.type)return`OFFSETS(${e.offsets.toString().substring(0,10)})`;if("LIVESEQS"===e.type)return"LIVESEQS()";if("AND"===e.type){e.data.length>2&&(e=z(e.data,"AND"));const t=j(e.data[0]),n=j(e.data[1]);return t?n?`AND(${t},${n})`:t:n}if("OR"===e.type){e.data.length>2&&(e=z(e.data,"AND"));const t=j(e.data[0]),n=j(e.data[1]);return t?n?`OR(${t},${n})`:t:n}return"NOT"===e.type?`NOT(${j(e.data[0])})`:"*"}function P(e,t){if(e||t){if(e&&!t)return e;if(!e&&t)return t;{const n=new Map(e);for(let a of t.keys()){const i=e.get(a)||[],s=t.get(a);n.set(a,[...i,...s])}return n}}return null}function R(e,t){"EQUAL"===e.type||"INCLUDES"===e.type?e.data.prefix?Q(e,()=>{!function(e,t,n){const a=e.data.value,i=a?w(a,e.data.prefixOffset):0,s=new TypedFastBitSet,r=new Map,o=e.data.seek;function u(e){if(!e)return!1;const t=o(e),n=bipf.slice(e,t);if(a){if(Buffer.compare(n,a))return!1}else if(~t)return!1;return!0}if(t.map)t.map[i]&&t.map[i].forEach(e=>{s.add(e),r.set(e,[u])});else{const e=t.count,n=t.tarr;for(let t=0;t{t(r[e.data.indexName].bitset)}):"GT"===e.type?O(e,(e,t)=>e>t.data.value,t):"GTE"===e.type?O(e,(e,t)=>e>=t.data.value,t):"LT"===e.type?O(e,(e,t)=>ee<=t.data.value,t):"OFFSETS"===e.type?B(()=>{!function(e,t){const n=[];e.sort((e,t)=>e-t);const a=e.length,{tarr:i}=r.seq;for(let t=0,s=i.length;t{t(new TypedFastBitSet(e.seqs))}):"LIVESEQS"===e.type?t(new TypedFastBitSet):"AND"===e.type?(e.data.length>2&&(e=z(e.data,"AND")),R(e.data[0],(n,a)=>{R(e.data[1],(e,i)=>{t(n.new_intersection(e),P(a,i))})})):"OR"===e.type?(e.data.length>2&&(e=z(e.data,"OR")),R(e.data[0],(n,a)=>{R(e.data[1],(e,i)=>{t(n.new_union(e),P(a,i))})})):"NOT"===e.type?R(e.data[0],(e,n)=>{I(a=>{t(a.difference(e),n)})}):e.type?console.error("Unknown type",e):I(t)}function W(e,t){!function e(n){n.forEach(n=>{"EQUAL"===n.type||"INCLUDES"===n.type?t(n):"AND"===n.type||"OR"===n.type||"NOT"===n.type?e(n.data):"SEQS"!==n.type&&"LIVESEQS"!==n.type&&"OFFSETS"!==n.type&&"LT"!==n.type&&"LTE"!==n.type&&"GT"!==n.type&&"GTE"!==n.type&&n.type&&debug("Unknown operator type: "+n.type)})}([e])}function C(e,t){if(c(),n.has(e))return t(null,n.get(e));push(push.values([null]),push.asyncMap((e,t)=>B(t)),push.asyncMap((t,n)=>{const a=function(e){const t=[];return W(e,e=>{const n=e.data.indexName;r[n]&&r[n].lazy&&t.push(n)}),t}(e);if(0===a.length)return n();push(push.values(a),push.asyncMap(L),push.collect(n))}),push.asyncMap((t,n)=>{const a=function(e){const t=[];return W(e,e=>{r[e.data.indexName]||t.push(e)}),t}(e);if(0===a.length)return n();debug("missing indexes: %o",a),D(a,n)}),push.asyncMap((t,a)=>{R(e,(t,i)=>{n.set(e,[t,i]),a(null,[t,i])})}),push.collect((e,n)=>{e?t(e):t(null,n[0])}))}function G(t,n){const a=r.seq.tarr[t];e.get(a,(e,i)=>{e&&"flumelog:deleted"===e.code?n(null,{seq:t,offset:a}):n(e,{offset:a,value:i,seq:t})})}function V(e,t){return t.timestamp>e.timestamp}function K(e,t){return e.timestamp>t.timestamp}function _(e,t,n,a){const i=t.get(e);if(!i)return a(null,e);G(e,(t,s)=>{if(t)return a(t);const r=s.value;let o=!0;i&&(o=i.every(e=>e(r))),o?(n[e]=r,a(null,e)):a()})}function H(e,t,n){if(0===e.size||n<=0)return[];if(0===t&&1===n)return[e.peek()];if(t>0){e=e.clone();for(let n=0;n{i.add({seq:e,timestamp:r.timestamp.tarr[e]})}),i.trim(),a[n].set(e,i),i}(t,o),p=d.size,l={};function y(t,n){push(push.values(t),push.asyncMap((t,n)=>{u?n(null,r.seq.tarr[t]):function(t,n,a){if(n[t]){const e=n[t],i=bipf.decode(e,0);return void a(null,i)}const i=r.seq.tarr[t];e.get(i,(e,t)=>{e&&"flumelog:deleted"===e.code?a():a(e,bipf.decode(t,0))})}(t,l,n)}),push.filter(e=>!!u||e),push.collect((e,t)=>{f(e,{results:t,total:n})}))}if(n){function m(e,t,a,i){const s=multicb({pluck:1});for(let e=0;e(function e(t,n,a){if(t)return f(t);const i=a.length;a=a.filter(e=>void 0!==e);const r=n+a.lengthe(t,n+i,a)):y(a,p)})(e,i,t))}else{y(H(d,i,s).map(e=>e.seq),p)}}return{onReady:f,paginate:function(e,t,n,a,i,s){f(()=>{const r=Date.now();C(e,(o,u)=>{if(o)return s(o);const[f,d]=u;J(f,d,t,n,a,i,(a,i)=>{a?s(a):(i.duration=Date.now()-r,debugQuery.enabled&&debugQuery(`paginate(${j(e)}), seq: ${t}, limit: ${n}: ${i.duration}ms, total messages: ${i.total}`.replace(/%/g,"%% ")),s(null,i))})})})},all:function(e,t,n,a,i){f(()=>{const s=Date.now();C(e,(r,o)=>{if(r)return i(r);const[u,f]=o;J(u,f,t,1/0,n,a,(t,n)=>{t?i(t):(n.duration=Date.now()-s,debugQuery.enabled&&debugQuery(`all(${j(e)}): ${n.duration}ms, total messages: ${n.total}`.replace(/%/g,"%% ")),i(null,n.results))})})})},count:function(e,t,n,a){f(()=>{const n=Date.now();C(e,(i,s)=>{if(i)return a(i);const[r]=s,o=function(e,t,n){return t?e.size()-t:e.size()}(r,t),u=Date.now()-n;debugQuery.enabled&&debugQuery(`count(${j(e)}): ${u}ms, total messages: ${o}`.replace(/%/g,"%% ")),a(null,o)})})},live:function(t){return pull(pullAsync(e=>f(()=>{C(t,t=>e(t))})),pull.map(()=>{let n,a,i=-1;if(function e(t){t.forEach(t=>{if("EQUAL"===t.type||"INCLUDES"===t.type)i=r[t.data.indexName]?r[t.data.indexName].offset:-1;else if("AND"===t.type||"OR"===t.type||"NOT"===t.type)e(t.data);else if("LIVESEQS"===t.type){if(n)throw new Error("Only one seq stream in live supported");n=t.stream}})}([t]),n)a=pull(n,pull.asyncMap((e,t)=>{B(()=>{G(e,t)})}));else{const t=-1===i?{live:!0,gt:r.seq.offset}:{live:!0,gt:i},n=Math.ceil(1e3*Math.random());debug(`log.stream #${n} started, for a live query`),a=toPull(e.stream(t))}return a}),pull.flatten(),pull.filter(e=>(function e(t,n,a){for(let i=0;i{debugQuery.enabled&&debugQuery(`live(${j(t)}): 1 new msg`.replace(/%/g,"%% "))}),pull.map(e=>bipf.decode(e.value,0)))},status:s.obv,indexes:r}}; +const path=require("path"),bipf=require("bipf"),push=require("push-stream"),pull=require("pull-stream"),toPull=require("push-stream-to-pull-stream"),pullAsync=require("pull-async"),TypedFastBitSet=require("typedfastbitset"),bsb=require("binary-search-bounds"),multicb=require("multicb"),FastPriorityQueue=require("fastpriorityqueue"),debug=require("debug")("jitdb"),debugQuery=debug.extend("query"),Status=require("./status"),{saveTypedArrayFile:saveTypedArrayFile,loadTypedArrayFile:loadTypedArrayFile,savePrefixMapFile:savePrefixMapFile,loadPrefixMapFile:loadPrefixMapFile,saveBitsetFile:saveBitsetFile,loadBitsetFile:loadBitsetFile,safeFilename:safeFilename,listFilesIDB:listFilesIDB,listFilesFS:listFilesFS}=require("./files");module.exports=function(e,t){debug("indexes path",t);let n=new WeakMap,a={ascending:new WeakMap,descending:new WeakMap},i=-1;const s=Status(),r={};let o=!1,u=[];function f(e){o?e():u.push(e)}!function(e){function n(n,a){push(push.values(a),push.asyncMap((e,n)=>{const a=path.parse(e).name;"seq.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||(r[a]=t),n()}):"timestamp.index"===e?loadTypedArrayFile(path.join(t,e),Float64Array,(e,t)=>{e||(r[a]=t),n()}):"sequence.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||(r[a]=t),n()}):e.endsWith(".32prefix")?(r[a]={offset:-1,count:0,tarr:new Uint32Array(16e3),lazy:!0,prefix:32,filepath:path.join(t,e)},n()):e.endsWith(".32prefixmap")?(r[a]={offset:-1,count:0,map:{},lazy:!0,prefix:32,filepath:path.join(t,e)},n()):e.endsWith(".index")?(r[a]={offset:0,bitset:new TypedFastBitSet,lazy:!0,filepath:path.join(t,e)},n()):n()}),push.collect(e))}"undefined"!=typeof window?listFilesIDB(t,n):listFilesFS(t,n)}(()=>{debug("loaded indexes",Object.keys(r)),r.seq||(r.seq={offset:-1,count:0,tarr:new Uint32Array(16e3),version:1}),r.timestamp||(r.timestamp={offset:-1,count:0,tarr:new Float64Array(16e3),version:1}),r.sequence||(r.sequence={offset:-1,count:0,tarr:new Uint32Array(16e3),version:1}),s.batchUpdate(r,["seq","timestamp","sequence"]),o=!0;for(let e=0;ei&&(i=e.since.value,n=new WeakMap,a.ascending=new WeakMap,a.descending=new WeakMap)}function y(e,n,a){if(n.offset<0)return;debug("saving core index: %s",e);const i=path.join(t,e+".index");saveTypedArrayFile(i,n.version,n.offset,a,n.tarr)}function m(e,n,a){if(n.offset<0||0===n.bitset.size())return;debug("saving index: %s",e);const i=path.join(t,e+".index");saveBitsetFile(i,n.version,n.offset,n.bitset,a)}function g(e,n,a,i){if(n.offset<0)return;debug("saving prefix index: %s",e);const s=n.prefix,r=path.join(t,e+`.${s}prefix`);saveTypedArrayFile(r,n.version,n.offset,a,n.tarr,i)}function h(e,n,a,i){if(n.offset<0)return;debug("saving prefix map index: %s",e);const s=n.prefix,r=path.join(t,e+`.${s}prefixmap`);savePrefixMapFile(r,n.version,n.offset,a,n.map,i)}function b(e,t){debug("growing index");const n=new t(2*e.tarr.length);n.set(e.tarr),e.tarr=n}function x(e,t){if(e>r.seq.count-1)return e>r.seq.tarr.length-1&&b(r.seq,Uint32Array),r.seq.offset=t,r.seq.tarr[e]=t,r.seq.count=e+1,!0}function v(e){var t=0;t=bipf.seekKey(e,t,d);const n=bipf.decode(e,t);t=0,t=bipf.seekKey(e,t,l),t=bipf.seekKey(e,t,d);const a=bipf.decode(e,t);return Math.min(n,a)}function q(e){var t=0;return t=bipf.seekKey(e,t,l),t=bipf.seekKey(e,t,p),bipf.decode(e,t)}function E(e,t,n){if(e>r.timestamp.count-1){e>r.timestamp.tarr.length-1&&b(r.timestamp,Float64Array),r.timestamp.offset=t;const a=v(n);return r.timestamp.tarr[e]=a,r.timestamp.count=e+1,!0}}function T(e,t,n){if(e>r.sequence.count-1){e>r.sequence.tarr.length-1&&b(r.sequence,Uint32Array),r.sequence.offset=t;const a=q(n);return r.sequence.tarr[e]=a,r.sequence.count=e+1,!0}}function w(e,t){const n=e.seek(t);return e.value?!(!~n||0!==bipf.compareString(t,n,e.value)):-1===n}function F(e,t){return"GT"===e.type?t>e.data.value:"GTE"===e.type?t>=e.data.value:"LT"===e.type?t{const s=e.pluck?e.pluck(t,i):i;if(0===bipf.compareString(t,s,e.value))return a=!0,!0}),a}return!1}function $(e,t=0){if(e.length<4){const t=Buffer.alloc(4);return e.copy(t),t.readUInt32LE(0)}return 4===e.length?e.readUInt32LE(0):e.readUInt32LE(t)}function D(e,t,n,a,i){if(a>t.count-1){const s=e.seek(n);if(~s){const i=bipf.slice(n,s);if(i.length){const n=$(i,e.prefixOffset);!function(e,t,n){if(0===n)return;(e[n]||(e[n]=[])).push(t)}(t.map,a,n)}}t.offset=i,t.count=a+1}}function M(e,t,n,a,i){if(a>t.count-1){a>t.tarr.length-1&&b(t,Uint32Array);const s=e.seek(n);if(~s){const i=bipf.slice(n,s);t.tarr[a]=i.length?$(i,e.prefixOffset):0}else t.tarr[a]=0;t.offset=i,t.count=a+1}}function U(e,t,n,a){"EQUAL"===e.type&&w(e.data,n)?t.bitset.add(a):"PREDICATE"===e.type&&N(e.data,n)?t.bitset.add(a):"INCLUDES"===e.type&&A(e.data,n)&&t.bitset.add(a)}function L(e,t,n){if(e.has(t))return e.get(t).push(n),!0;e.set(t,[])}function k(e,t){e.get(t).forEach(e=>e()),e.delete(t)}const Q=new Map;const I=new Map;function B(t,n){const a={},i=["seq","timestamp","sequence"],o=t.map(e=>e.data.indexName),u=o.join("|");if(L(I,u,n))return;t.forEach(e=>{e.data.prefix&&e.data.useMap?a[e.data.indexName]={offset:0,count:0,map:{},prefix:"number"==typeof e.data.prefix?e.data.prefix:32,version:e.data.version||1}:e.data.prefix?a[e.data.indexName]={offset:0,count:0,tarr:new Uint32Array(16e3),prefix:"number"==typeof e.data.prefix?e.data.prefix:32,version:e.data.version||1}:a[e.data.indexName]={offset:0,bitset:new TypedFastBitSet,version:e.data.version||1}});let f=0,d=!1,p=!1,l=!1;const c=Date.now();let b=c;function v(e,t,n){for(var i in d&&y("seq",r.seq,e),p&&y("timestamp",r.timestamp,e),l&&y("sequence",r.sequence,e),a){const s=a[i];n&&(r[i]=s),s.offset=t,s.prefix&&s.map?h(i,s,e):s.prefix?g(i,s,e):m(i,s)}}const q=Math.ceil(1e3*Math.random());debug(`log.stream #${q} started, to create indexes ${u}`),e.stream({}).pipe({paused:!1,write:function(e){const n=e.offset,u=e.value;if(x(f,n)&&(d=!0),u){if(E(f,n,u)&&(p=!0),T(f,n,u)&&(l=!0),t.forEach(e=>{e.data.prefix&&e.data.useMap?D(e.data,a[e.data.indexName],u,f,n):e.data.prefix?M(e.data,a[e.data.indexName],u,f,n):e.data.indexAll?function(e,t,n,a){const i=e.seek(n),s=bipf.decode(n,i),r=safeFilename(e.indexType+"_"+s);t[r]||(t[r]={offset:0,bitset:new TypedFastBitSet,version:e.version||1}),t[r].bitset.add(a)}(e.data,a,u,f):U(e,a[e.data.indexName],u,f)}),f%1e3==0){s.batchUpdate(r,i),s.batchUpdate(a,o);const e=Date.now();e-b>=6e4&&(b=e,v(f,n,!1))}f++}else f++},end:()=>{const e=f;debug(`log.stream #${q} done ${e} records in ${Date.now()-c}ms`),v(e,r.seq.offset,!0),s.batchUpdate(r,i),s.batchUpdate(a,o),k(I,u),n()}})}const O=new Map;function P(e,t){if(L(O,e,t))return;debug("lazy loading %s",e);let n=r[e];n.prefix&&n.map?loadPrefixMapFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete r[e],t();const{version:s,offset:o,count:u,map:f}=i;n.version=s,n.offset=o,n.count=u,n.map=f,n.lazy=!1,k(O,e),t()}):n.prefix?loadTypedArrayFile(n.filepath,Uint32Array,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete r[e],t();const{version:s,offset:o,count:u,tarr:f}=i;n.version=s,n.offset=o,n.count=u,n.tarr=f,n.lazy=!1,k(O,e),t()}):loadBitsetFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete r[e],t();const{version:s,offset:o,bitset:u}=i;n.version=s,n.offset=o,n.bitset=u,n.lazy=!1,k(O,e),t()})}function R(t,n){const a=r[t.data.indexName];e.since.value>a.offset||t.data.version>a.version?function(t,n){const a=r[t.data.indexName],i=["seq","timestamp","sequence",t.data.indexName],o=t.data.indexName;if(L(Q,o,n))return;t.data.version>a.version&&(a.offset=-1,a.count=0);let u=0;if(-1!==a.offset){const{tarr:e}=r.seq,t=a.offset;for(const n=e.length;ua.version&&(a.version=t.data.version),v&&(a.prefix&&a.map?h(t.data.indexName,a,e):a.prefix?g(t.data.indexName,a,e):m(t.data.indexName,a))}const w=Math.ceil(1e3*Math.random());debug(`log.stream #${w} started, to update index ${o}`),e.stream({gt:a.offset}).pipe({paused:!1,write:function(e){const n=e.offset,o=e.value;if(x(u,n)&&(f=!0),o){if(E(u,n,o)&&(d=!0),T(u,n,o)&&(p=!0),v&&(t.data.prefix&&t.data.useMap?D(t.data,a,o,u,n):t.data.prefix?M(t.data,a,o,u,n):U(t,a,o,u)),u%1e3==0){s.batchUpdate(r,i);const e=Date.now();e-b>=6e4&&(b=e,q(u,n))}u++}else u++},end:()=>{const e=u;debug(`log.stream #${w} done ${u-l} records in ${Date.now()-c}ms`),q(e,r.seq.offset),s.batchUpdate(r,i),k(Q,o),n()}})}(t,n):(debug("ensureIndexSync %s is already synced",t.data.indexName),n())}function z(e){R({data:{indexName:"seq"}},e)}function j(e,t,n){R(e,()=>{if("sequence"===e.data.indexName){const a=new TypedFastBitSet,{tarr:i,count:s}=r.sequence;for(let n=0;n{const t=new TypedFastBitSet,{count:n}=r.sequence;t.addRange(0,n),e(t)})}function G(e,t){let n=e[0];return e.slice(1).forEach(e=>{n={type:t,data:[n,e]}}),n}function W(e){if("EQUAL"===e.type||"INCLUDES"===e.type||"PREDICATE"===e.type){const t=e.data.value?e.data.value.toString().substring(0,10):"";return`${e.data.indexType}(${t})`}if("GT"===e.type||"GTE"===e.type||"LT"===e.type||"LTE"===e.type){const t=e.data.value?e.data.value.toString().substring(0,10):"";return`${e.type}(${t})`}if("SEQS"===e.type)return`SEQS(${e.seqs.toString().substring(0,10)})`;if("OFFSETS"===e.type)return`OFFSETS(${e.offsets.toString().substring(0,10)})`;if("LIVESEQS"===e.type)return"LIVESEQS()";if("AND"===e.type){e.data.length>2&&(e=G(e.data,"AND"));const t=W(e.data[0]),n=W(e.data[1]);return t?n?`AND(${t},${n})`:t:n}if("OR"===e.type){e.data.length>2&&(e=G(e.data,"AND"));const t=W(e.data[0]),n=W(e.data[1]);return t?n?`OR(${t},${n})`:t:n}return"NOT"===e.type?`NOT(${W(e.data[0])})`:"*"}function V(e,t){if(e||t){if(e&&!t)return e;if(!e&&t)return t;{const n=new Map(e);for(let a of t.keys()){const i=e.get(a)||[],s=t.get(a);n.set(a,[...i,...s])}return n}}return null}function K(e,t){"EQUAL"===e.type||"INCLUDES"===e.type||"PREDICATE"===e.type?e.data.prefix?R(e,()=>{!function(e,t,n){const a=e.data.value,i=a?$(a,e.data.prefixOffset):0,s=new TypedFastBitSet,r=new Map,o=e.data.seek;function u(e){if(!e)return!1;const t=o(e),n=bipf.slice(e,t);if(a){if(Buffer.compare(n,a))return!1}else if(~t)return!1;return!0}if(t.map)t.map[i]&&t.map[i].forEach(e=>{s.add(e),r.set(e,[u])});else{const e=t.count,n=t.tarr;for(let t=0;t{t(r[e.data.indexName].bitset)}):"GT"===e.type?j(e,(e,t)=>e>t.data.value,t):"GTE"===e.type?j(e,(e,t)=>e>=t.data.value,t):"LT"===e.type?j(e,(e,t)=>ee<=t.data.value,t):"OFFSETS"===e.type?z(()=>{!function(e,t){const n=[];e.sort((e,t)=>e-t);const a=e.length,{tarr:i}=r.seq;for(let t=0,s=i.length;t{t(new TypedFastBitSet(e.seqs))}):"LIVESEQS"===e.type?t(new TypedFastBitSet):"AND"===e.type?(e.data.length>2&&(e=G(e.data,"AND")),K(e.data[0],(n,a)=>{K(e.data[1],(e,i)=>{t(n.new_intersection(e),V(a,i))})})):"OR"===e.type?(e.data.length>2&&(e=G(e.data,"OR")),K(e.data[0],(n,a)=>{K(e.data[1],(e,i)=>{t(n.new_union(e),V(a,i))})})):"NOT"===e.type?K(e.data[0],(e,n)=>{C(a=>{t(a.difference(e),n)})}):e.type?console.error("Unknown type",e):C(t)}function _(e,t){!function e(n){n.forEach(n=>{"EQUAL"===n.type||"INCLUDES"===n.type||"PREDICATE"===n.type?t(n):"AND"===n.type||"OR"===n.type||"NOT"===n.type?e(n.data):"SEQS"!==n.type&&"LIVESEQS"!==n.type&&"OFFSETS"!==n.type&&"LT"!==n.type&&"LTE"!==n.type&&"GT"!==n.type&&"GTE"!==n.type&&n.type&&debug("Unknown operator type: "+n.type)})}([e])}function H(e,t){if(c(),n.has(e))return t(null,n.get(e));push(push.values([null]),push.asyncMap((e,t)=>z(t)),push.asyncMap((t,n)=>{const a=function(e){const t=[];return _(e,e=>{const n=e.data.indexName;r[n]&&r[n].lazy&&t.push(n)}),t}(e);if(0===a.length)return n();push(push.values(a),push.asyncMap(P),push.collect(n))}),push.asyncMap((t,n)=>{const a=function(e){const t=[];return _(e,e=>{r[e.data.indexName]||t.push(e)}),t}(e);if(0===a.length)return n();debug("missing indexes: %o",a),B(a,n)}),push.asyncMap((t,a)=>{K(e,(t,i)=>{n.set(e,[t,i]),a(null,[t,i])})}),push.collect((e,n)=>{e?t(e):t(null,n[0])}))}function J(t,n){const a=r.seq.tarr[t];e.get(a,(e,i)=>{e&&"flumelog:deleted"===e.code?n(null,{seq:t,offset:a}):n(e,{offset:a,value:i,seq:t})})}function X(e,t){return t.timestamp>e.timestamp}function Y(e,t){return e.timestamp>t.timestamp}function Z(e,t,n,a){const i=t.get(e);if(!i)return a(null,e);J(e,(t,s)=>{if(t)return a(t);const r=s.value;let o=!0;i&&(o=i.every(e=>e(r))),o?(n[e]=r,a(null,e)):a()})}function ee(e,t,n){if(0===e.size||n<=0)return[];if(0===t&&1===n)return[e.peek()];if(t>0){e=e.clone();for(let n=0;n{i.add({seq:e,timestamp:r.timestamp.tarr[e]})}),i.trim(),a[n].set(e,i),i}(t,o),p=d.size,l={};function y(t,n){push(push.values(t),push.asyncMap((t,n)=>{u?n(null,r.seq.tarr[t]):function(t,n,a){if(n[t]){const e=n[t],i=bipf.decode(e,0);return void a(null,i)}const i=r.seq.tarr[t];e.get(i,(e,t)=>{e&&"flumelog:deleted"===e.code?a():a(e,bipf.decode(t,0))})}(t,l,n)}),push.filter(e=>!!u||e),push.collect((e,t)=>{f(e,{results:t,total:n})}))}if(n){function m(e,t,a,i){const s=multicb({pluck:1});for(let e=0;e(function e(t,n,a){if(t)return f(t);const i=a.length;a=a.filter(e=>void 0!==e);const r=n+a.lengthe(t,n+i,a)):y(a,p)})(e,i,t))}else{y(ee(d,i,s).map(e=>e.seq),p)}}return{onReady:f,paginate:function(e,t,n,a,i,s){f(()=>{const r=Date.now();H(e,(o,u)=>{if(o)return s(o);const[f,d]=u;te(f,d,t,n,a,i,(a,i)=>{a?s(a):(i.duration=Date.now()-r,debugQuery.enabled&&debugQuery(`paginate(${W(e)}), seq: ${t}, limit: ${n}: ${i.duration}ms, total messages: ${i.total}`.replace(/%/g,"%% ")),s(null,i))})})})},all:function(e,t,n,a,i){f(()=>{const s=Date.now();H(e,(r,o)=>{if(r)return i(r);const[u,f]=o;te(u,f,t,1/0,n,a,(t,n)=>{t?i(t):(n.duration=Date.now()-s,debugQuery.enabled&&debugQuery(`all(${W(e)}): ${n.duration}ms, total messages: ${n.total}`.replace(/%/g,"%% ")),i(null,n.results))})})})},count:function(e,t,n,a){f(()=>{const n=Date.now();H(e,(i,s)=>{if(i)return a(i);const[r]=s,o=function(e,t,n){return t?e.size()-t:e.size()}(r,t),u=Date.now()-n;debugQuery.enabled&&debugQuery(`count(${W(e)}): ${u}ms, total messages: ${o}`.replace(/%/g,"%% ")),a(null,o)})})},live:function(t){return pull(pullAsync(e=>f(()=>{H(t,t=>e(t))})),pull.map(()=>{let n,a,i=-1;if(function e(t){t.forEach(t=>{if("EQUAL"===t.type||"INCLUDES"===t.type||"PREDICATE"===t.type)i=r[t.data.indexName]?r[t.data.indexName].offset:-1;else if("AND"===t.type||"OR"===t.type||"NOT"===t.type)e(t.data);else if("LIVESEQS"===t.type){if(n)throw new Error("Only one seq stream in live supported");n=t.stream}})}([t]),n)a=pull(n,pull.asyncMap((e,t)=>{z(()=>{J(e,t)})}));else{const t=-1===i?{live:!0,gt:r.seq.offset}:{live:!0,gt:i},n=Math.ceil(1e3*Math.random());debug(`log.stream #${n} started, for a live query`),a=toPull(e.stream(t))}return a}),pull.flatten(),pull.filter(e=>(function e(t,n,a){for(let i=0;i{debugQuery.enabled&&debugQuery(`live(${W(t)}): 1 new msg`.replace(/%/g,"%% "))}),pull.map(e=>bipf.decode(e.value,0)))},status:s.obv,indexes:r}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./files":273,"./status":276,"binary-search-bounds":51,"bipf":52,"buffer":99,"debug":131,"fastpriorityqueue":190,"multicb":355,"path":424,"pull-async":462,"pull-stream":526,"push-stream":576,"push-stream-to-pull-stream":573,"typedfastbitset":840}],275:[function(require,module,exports){ +},{"./files":279,"./status":282,"binary-search-bounds":56,"bipf":57,"buffer":104,"debug":136,"fastpriorityqueue":196,"multicb":360,"path":430,"pull-async":468,"pull-stream":533,"push-stream":583,"push-stream-to-pull-stream":580,"typedfastbitset":864}],281:[function(require,module,exports){ (function (Buffer){(function (){ -const bipf=require("bipf"),traverse=require("traverse"),promisify=require("promisify-4loc"),pull=require("pull-stream"),pullAsync=require("pull-async"),pullAwaitable=require("pull-awaitable"),cat=require("pull-cat"),{safeFilename:safeFilename}=require("./files");function copyMeta(e,t){e.meta&&(t.meta=e.meta)}function updateMeta(e,t,n){const r=Object.assign({},e);return r.meta[t]=n,r}function extractMeta(e){return e.meta}function toBufferOrFalsy(e){return e?Buffer.isBuffer(e)?e:Buffer.from(e):e}const seekFromDescCache=new Map;function seekFromDesc(e){if(seekFromDescCache.has(e))return seekFromDescCache.get(e);const t=e.split(".").map(Buffer.from),n=function(e,n=0){var r=n;for(let n of t)if(!~(r=bipf.seekKey(e,r,n)))return;return r};return seekFromDescCache.set(e,n),n}function getIndexName(e,t,n){return safeFilename(e.prefix?e.useMap?t+"__map":t:t+"_"+n)}function query(...e){let t=e[0];for(let n=1,r=e.length;n{const t=JSON.stringify(e.meta,(e,t)=>"jitdb"===e?void 0:t);return console.log("debug",JSON.stringify(e,(e,t)=>"meta"===e?void 0:"task"===e&&"function"==typeof t?"[Function]":"value"===e&&"Buffer"===t.type?Buffer.from(t.data).toString():t,2),"{}"===t?"":"meta: "+t),e}}function slowEqual(e,t,n){n=n||{};const r=seekFromDesc(e),a=toBufferOrFalsy(t),u=a?a.toString():"",i=e.replace(/\./g,"_");return{type:"EQUAL",data:{seek:r,value:a,indexType:i,indexName:getIndexName(n,i,u),useMap:n.useMap,indexAll:n.indexAll,prefix:n.prefix,prefixOffset:n.prefixOffset}}}function equal(e,t,n){if(!(n=n||{}).indexType)throw new Error("equal() operator needs an indexType in the 3rd arg");const r=toBufferOrFalsy(t),a=r?r.toString():"",u=n.indexType;return{type:"EQUAL",data:{seek:e,value:r,indexType:u,indexName:getIndexName(n,u,a),useMap:n.useMap,indexAll:n.indexAll,prefix:n.prefix,prefixOffset:n.prefixOffset}}}function slowIncludes(e,t,n){n=n||{};const r=seekFromDesc(e),a=toBufferOrFalsy(t);if(!a)throw new Error("slowIncludes() 2nd arg needs to be truthy");const u=a.toString(),i=e.replace(/\./g,"_"),o=safeFilename(i+"_"+u),s=n.pluck&&"string"==typeof n.pluck?seekFromDesc(n.pluck):n.pluck;return{type:"INCLUDES",data:{seek:r,value:a,indexType:i,indexName:o,indexAll:n.indexAll,pluck:s}}}function includes(e,t,n){if(!(n=n||{}).indexType)throw new Error("includes() operator needs an indexType in the 3rd arg");const r=toBufferOrFalsy(t);if(!r)throw new Error("includes() 2nd arg needs to be truthy");const a=r.toString(),u=n.indexType;return{type:"INCLUDES",data:{seek:e,value:r,indexType:u,indexName:safeFilename(u+"_"+a),indexAll:n.indexAll,pluck:n.pluck}}}function gt(e,t){if("number"!=typeof e)throw new Error("gt() needs a number arg");return{type:"GT",data:{value:e,indexName:t}}}function gte(e,t){if("number"!=typeof e)throw new Error("gte() needs a number arg");return{type:"GTE",data:{value:e,indexName:t}}}function lt(e,t){if("number"!=typeof e)throw new Error("lt() needs a number arg");return{type:"LT",data:{value:e,indexName:t}}}function lte(e,t){if("number"!=typeof e)throw new Error("lte() needs a number arg");return{type:"LTE",data:{value:e,indexName:t}}}function seqs(e){return{type:"SEQS",seqs:e}}function liveSeqs(e){return{type:"LIVESEQS",stream:e}}function offsets(e){return{type:"OFFSETS",offsets:e}}function deferred(e){return{type:"DEFERRED",task:e}}function not(e){return{type:"NOT",data:[e]}}function and(...e){const t=e.filter(e=>!!e);return 0===t.length?{}:1===t.length?t[0]:{type:"AND",data:t}}function or(...e){const t=e.filter(e=>!!e);return 0===t.length?{}:1===t.length?t[0]:{type:"OR",data:t}}function where(...e){return t=>{if(1!==e.length)throw new Error("where() accepts only one argument");const n=e[0];if(!n)return t;const r=t.type?{type:"AND",data:[t,n]}:n;return copyMeta(t,r),r}}function fromDB(e){return{meta:{jitdb:e}}}function live(e){return e&&e.old?e=>updateMeta(e,"live","liveAndOld"):e=>updateMeta(e,"live","liveOnly")}function count(){return e=>updateMeta(e,"count",!0)}function descending(){return e=>updateMeta(e,"descending",!0)}function startFrom(e){return t=>updateMeta(t,"seq",e)}function paginate(e){return t=>updateMeta(t,"pageSize",e)}function asOffsets(){return e=>updateMeta(e,"asOffsets",!0)}async function executeDeferredOps(e,t){const n=[];return traverse.forEach(e,function(e){if(e){if("meta"===this.key&&e.jitdb)return this.block();"DEFERRED"===e.type&&e.task&&n.push([this.path,e]),Array.isArray(e)||"AND"===e.type||"OR"===e.type||this.block()}}),0===n.length?e:((await Promise.all(n.map(([e,n])=>promisify(n.task)(t).then(t=>t?"function"==typeof t?[e,t()]:[e,t]:[e,{}])))).forEach(([n,r])=>{r.meta=t,0===n.length?e=r:traverse.set(e,n,r)}),e)}function toCallback(e){return t=>{const n=extractMeta(t);executeDeferredOps(t,n).then(t=>{const r=n.seq||0,{pageSize:a,descending:u,asOffsets:i}=n;n.count?n.jitdb.count(t,r,u,e):a?n.jitdb.paginate(t,r,a,u,i,e):n.jitdb.all(t,r,u,i,e)}).catch(t=>{e(t)})}}function toPromise(){return e=>promisify(t=>toCallback(t)(e))()}function toPullStream(){return e=>{const t=extractMeta(e);function n(e){let n=t.seq||0,r=1/0;const a=t.pageSize||1;let u=!1;return function(i,o){return i?o(i):n>=r||u?o(!0):void(t.count?(u=!0,t.jitdb.count(e,n,t.descending,o)):t.jitdb.paginate(e,n,a,t.descending,t.asOffsets,(e,u)=>{if(e)return o(e);0===u.total?o(!0):(r=u.total,n+=a,o(null,t.pageSize?u.results:u.results[0]))}))}}return pull(pullAsync(n=>{executeDeferredOps(e,t).then(e=>n(null,e),e=>n(e))}),pull.map(e=>"liveOnly"===t.live?t.jitdb.live(e):"liveAndOld"===t.live?cat([n(e),t.jitdb.live(e)]):n(e)),pull.flatten())}}function toAsyncIter(){return async function*(e){const t=toPullStream()(e);for await(let e of pullAwaitable(t))yield e}}module.exports={fromDB:fromDB,query:query,live:live,slowEqual:slowEqual,equal:equal,slowIncludes:slowIncludes,includes:includes,where:where,not:not,gt:gt,gte:gte,lt:lt,lte:lte,and:and,or:or,deferred:deferred,liveSeqs:liveSeqs,seqs:seqs,offsets:offsets,descending:descending,count:count,startFrom:startFrom,paginate:paginate,asOffsets:asOffsets,toCallback:toCallback,toPullStream:toPullStream,toPromise:toPromise,toAsyncIter:toAsyncIter,debug:debug}; +const bipf=require("bipf"),traverse=require("traverse"),promisify=require("promisify-4loc"),pull=require("pull-stream"),multicb=require("multicb"),pullAwaitable=require("pull-awaitable"),cat=require("pull-cat"),{safeFilename:safeFilename}=require("./files");function copyMeta(e,t){e.meta&&(t.meta=e.meta)}function updateMeta(e,t,n){const r=Object.assign({},e);return r.meta[t]=n,r}function extractMeta(e){return e.meta}function toBufferOrFalsy(e){return e?Buffer.isBuffer(e)?e:Buffer.from(e):e}const seekFromDescCache=new Map;function seekFromDesc(e){if(seekFromDescCache.has(e))return seekFromDescCache.get(e);const t=e.split(".").map(e=>Buffer.from(e)),n=function(e,n=0){var r=n;for(let n of t)if(!~(r=bipf.seekKey(e,r,n)))return;return r};return seekFromDescCache.set(e,n),n}function getIndexName(e,t,n){return safeFilename(e.prefix?e.useMap?t+"__map":t:t+"_"+n)}function query(...e){let t=e[0];for(let n=1,r=e.length;n{const t=JSON.stringify(e.meta,(e,t)=>"jitdb"===e?void 0:t);return console.log("debug",JSON.stringify(e,(e,t)=>"meta"===e?void 0:"task"===e&&"function"==typeof t?"[Function]":"value"===e&&"Buffer"===t.type?Buffer.from(t.data).toString():t,2),"{}"===t?"":"meta: "+t),e}}function slowEqual(e,t,n){n=n||{};const r=seekFromDesc(e),a=toBufferOrFalsy(t),i=a?a.toString():"",o=e.replace(/\./g,"_");return{type:"EQUAL",data:{seek:r,value:a,indexType:o,indexName:getIndexName(n,o,i),useMap:n.useMap,indexAll:n.indexAll,prefix:n.prefix,prefixOffset:n.prefixOffset}}}function equal(e,t,n){if(!(n=n||{}).indexType)throw new Error("equal() operator needs an indexType in the 3rd arg");const r=toBufferOrFalsy(t),a=r?r.toString():"",i=n.indexType;return{type:"EQUAL",data:{seek:e,value:r,indexType:i,indexName:getIndexName(n,i,a),useMap:n.useMap,indexAll:n.indexAll,prefix:n.prefix,prefixOffset:n.prefixOffset}}}function slowPredicate(e,t,n){n=n||{};const r=seekFromDesc(e);if("function"!=typeof t)throw new Error("predicate() needs a predicate function in the 2rd arg");const a=t,i=e.replace(/\./g,"_"),o=n.name||t.name;if(!o)throw new Error("predicate() needs opts.name");return{type:"PREDICATE",data:{seek:r,value:a,indexType:i,indexName:safeFilename(i+"__pred_"+o)}}}function predicate(e,t,n){if(!(n=n||{}).indexType)throw new Error("predicate() operator needs an indexType in the 3rd arg");if("function"!=typeof t)throw new Error("predicate() needs a predicate function in the 2rd arg");const r=t,a=n.indexType,i=n.name||t.name;if(!i)throw new Error("predicate() needs opts.name");return{type:"PREDICATE",data:{seek:e,value:r,indexType:a,indexName:safeFilename(a+"__pred_"+i)}}}function slowIncludes(e,t,n){n=n||{};const r=seekFromDesc(e),a=toBufferOrFalsy(t);if(!a)throw new Error("slowIncludes() 2nd arg needs to be truthy");const i=a.toString(),o=e.replace(/\./g,"_"),u=safeFilename(o+"_"+i),s=n.pluck&&"string"==typeof n.pluck?seekFromDesc(n.pluck):n.pluck;return{type:"INCLUDES",data:{seek:r,value:a,indexType:o,indexName:u,indexAll:n.indexAll,pluck:s}}}function includes(e,t,n){if(!(n=n||{}).indexType)throw new Error("includes() operator needs an indexType in the 3rd arg");const r=toBufferOrFalsy(t);if(!r)throw new Error("includes() 2nd arg needs to be truthy");const a=r.toString(),i=n.indexType;return{type:"INCLUDES",data:{seek:e,value:r,indexType:i,indexName:safeFilename(i+"_"+a),indexAll:n.indexAll,pluck:n.pluck}}}function gt(e,t){if("number"!=typeof e)throw new Error("gt() needs a number arg");return{type:"GT",data:{value:e,indexName:t}}}function gte(e,t){if("number"!=typeof e)throw new Error("gte() needs a number arg");return{type:"GTE",data:{value:e,indexName:t}}}function lt(e,t){if("number"!=typeof e)throw new Error("lt() needs a number arg");return{type:"LT",data:{value:e,indexName:t}}}function lte(e,t){if("number"!=typeof e)throw new Error("lte() needs a number arg");return{type:"LTE",data:{value:e,indexName:t}}}function seqs(e){return{type:"SEQS",seqs:e}}function liveSeqs(e){return{type:"LIVESEQS",stream:e}}function offsets(e){return{type:"OFFSETS",offsets:e}}function deferred(e){return{type:"DEFERRED",task:e}}function not(e){return{type:"NOT",data:[e]}}function and(...e){const t=e.filter(e=>!!e);return 0===t.length?{}:1===t.length?t[0]:{type:"AND",data:t}}function or(...e){const t=e.filter(e=>!!e);return 0===t.length?{}:1===t.length?t[0]:{type:"OR",data:t}}function where(...e){return t=>{if(1!==e.length)throw new Error("where() accepts only one argument");const n=e[0];if(!n)return t;const r=t.type?{type:"AND",data:[t,n]}:n;return copyMeta(t,r),r}}function fromDB(e){return{meta:{jitdb:e}}}function live(e){return e&&e.old?e=>updateMeta(e,"live","liveAndOld"):e=>updateMeta(e,"live","liveOnly")}function count(){return e=>updateMeta(e,"count",!0)}function descending(){return e=>updateMeta(e,"descending",!0)}function startFrom(e){return t=>updateMeta(t,"seq",e)}function paginate(e){return t=>updateMeta(t,"pageSize",e)}function batch(e){return t=>updateMeta(t,"batchSize",e)}function asOffsets(){return e=>updateMeta(e,"asOffsets",!0)}function executeDeferredOps(e,t){const n=[];if(traverse.forEach(e,function(e){if(e){if("meta"===this.key&&e.jitdb)return this.block();"DEFERRED"===e.type&&e.task&&n.push([this.path,e.task]),Array.isArray(e)||"AND"===e.type||"OR"===e.type||this.block()}}),0===n.length)return pull.values([e]);const r=multicb({pluck:1});let a=!1;const i=[];function o(e){i.push(e)}return function(u,s){if(u){for(;i.length;)i.shift()();s(u)}else if(a)s(!0);else{for(const[e,a]of n){const n=r();a(t,(t,r)=>{t?n(t):n(null,r?"function"==typeof r?[e,r()]:[e,r]:[e,{}])},o)}r((n,r)=>{if(n)return s(n);for(const[n,a]of r)a.meta=t,0===n.length?e=a:traverse.set(e,n,a);a=!0,s(null,e)})}}}function toCallback(e){return t=>{const n=extractMeta(t);executeDeferredOps(t,n)(null,(t,r)=>{if(t)return e(t);const a=n.seq||0,{pageSize:i,descending:o,asOffsets:u}=n;n.count?n.jitdb.count(r,a,o,e):i?n.jitdb.paginate(r,a,i,o,u,e):n.jitdb.all(r,a,o,u,e)})}}function toPromise(){return e=>promisify(t=>toCallback(t)(e))()}function toPullStream(){return e=>{const t=extractMeta(e);function n(e){let n=t.seq||0,r=1/0;const a=t.pageSize||t.batchSize||20;let i=!1;function o(o,u){return o?u(o):n>=r||i?u(!0):void(t.count?(i=!0,t.jitdb.count(e,n,t.descending,u)):t.jitdb.paginate(e,n,a,t.descending,t.asOffsets,(e,t)=>{if(e)return u(e);0===t.total?u(!0):(r=t.total,n+=a,u(null,t.results))}))}return t.pageSize||t.count?o:pull(o,pull.map(pull.values),pull.flatten())}return pull(executeDeferredOps(e,t),pull.map(e=>"liveOnly"===t.live?t.jitdb.live(e):"liveAndOld"===t.live?cat([n(e),t.jitdb.live(e)]):n(e)),pull.flatten())}}function toAsyncIter(){return async function*(e){const t=toPullStream()(e);for await(let e of pullAwaitable(t))yield e}}module.exports={fromDB:fromDB,query:query,live:live,slowEqual:slowEqual,equal:equal,slowPredicate:slowPredicate,predicate:predicate,slowIncludes:slowIncludes,includes:includes,where:where,not:not,gt:gt,gte:gte,lt:lt,lte:lte,and:and,or:or,deferred:deferred,liveSeqs:liveSeqs,seqs:seqs,offsets:offsets,descending:descending,count:count,startFrom:startFrom,paginate:paginate,batch:batch,asOffsets:asOffsets,toCallback:toCallback,toPullStream:toPullStream,toPromise:toPromise,toAsyncIter:toAsyncIter,debug:debug}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./files":273,"bipf":52,"buffer":99,"promisify-4loc":445,"pull-async":462,"pull-awaitable":463,"pull-cat":465,"pull-stream":526,"traverse":836}],276:[function(require,module,exports){ +},{"./files":279,"bipf":57,"buffer":104,"multicb":360,"promisify-4loc":451,"pull-awaitable":469,"pull-cat":471,"pull-stream":533,"traverse":858}],282:[function(require,module,exports){ const Obv=require("obz");module.exports=function(){const t={},e={},n=Obv();n.set(t);const o=1e3,s=2e3;let c=0,r=0,f=null;function l(){const n=Date.now();for(const o in t)e[o]+s{c===r?(clearInterval(f),f=null,c=r=0):(r=c,l(),n.set(t))},o)).unref&&f.unref())}}}; -},{"obz":403}],277:[function(require,module,exports){ +},{"obz":409}],283:[function(require,module,exports){ (function (Buffer){(function (){ "use strict";const object={},hasOwnProperty=object.hasOwnProperty,forOwn=(e,t)=>{for(const r in e)hasOwnProperty.call(e,r)&&t(r,e[r])},extend=(e,t)=>t?(forOwn(t,(t,r)=>{e[t]=r}),e):e,forEach=(e,t)=>{const r=e.length;let i=-1;for(;++i"\\u"+("0000"+e).slice(-4),hexadecimal=(e,t)=>{let r=e.toString(16);return t?r:r.toUpperCase()},toString=object.toString,isArray=Array.isArray,isBuffer=e=>"function"==typeof Buffer&&Buffer.isBuffer(e),isObject=e=>"[object Object]"==toString.call(e),isString=e=>"string"==typeof e||"[object String]"==toString.call(e),isNumber=e=>"number"==typeof e||"[object Number]"==toString.call(e),isFunction=e=>"function"==typeof e,isMap=e=>"[object Map]"==toString.call(e),isSet=e=>"[object Set]"==toString.call(e),singleEscapes={"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},regexSingleEscape=/[\\\b\f\n\r\t]/,regexDigit=/[0-9]/,regexWhitespace=/[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,escapeEverythingRegex=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g,escapeNonAsciiRegex=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g,jsesc=(e,t)=>{const r=()=>{u=a,++t.indentLevel,a=t.indent.repeat(t.indentLevel)},i={escapeEverything:!1,minimal:!1,isScriptContext:!1,quotes:"single",wrap:!1,es6:!1,json:!1,compact:!0,lowercaseHex:!1,numbers:"decimal",indent:"\t",indentLevel:0,__inline1__:!1,__inline2__:!1},n=t&&t.json;n&&(i.quotes="double",i.wrap=!0),"single"!=(t=extend(i,t)).quotes&&"double"!=t.quotes&&"backtick"!=t.quotes&&(t.quotes="single");const s="double"==t.quotes?'"':"backtick"==t.quotes?"`":"'",c=t.compact,o=t.lowercaseHex;let a=t.indent.repeat(t.indentLevel),u="";const l=t.__inline1__,f=t.__inline2__,p=c?"":"\n";let g,_=!0;const x="binary"==t.numbers,m="octal"==t.numbers,b="decimal"==t.numbers,h="hexadecimal"==t.numbers;if(n&&e&&isFunction(e.toJSON)&&(e=e.toJSON()),!isString(e)){if(isMap(e))return 0==e.size?"new Map()":(c||(t.__inline1__=!0,t.__inline2__=!1),"new Map("+jsesc(Array.from(e),t)+")");if(isSet(e))return 0==e.size?"new Set()":"new Set("+jsesc(Array.from(e),t)+")";if(isBuffer(e))return 0==e.length?"Buffer.from([])":"Buffer.from("+jsesc(Array.from(e),t)+")";if(isArray(e))return g=[],t.wrap=!0,l&&(t.__inline1__=!1,t.__inline2__=!0),f||r(),forEach(e,e=>{_=!1,f&&(t.__inline2__=!1),g.push((c||f?"":a)+jsesc(e,t))}),_?"[]":f?"["+g.join(", ")+"]":"["+p+g.join(","+p)+p+(c?"":u)+"]";if(!isNumber(e))return isObject(e)?(g=[],t.wrap=!0,r(),forOwn(e,(e,r)=>{_=!1,g.push((c?"":a)+jsesc(e,t)+":"+(c?"":" ")+jsesc(r,t))}),_?"{}":"{"+p+g.join(","+p)+p+(c?"":u)+"}"):n?JSON.stringify(e)||"null":String(e);if(n)return JSON.stringify(e);if(b)return String(e);if(h){let t=e.toString(16);return o||(t=t.toUpperCase()),"0x"+t}if(x)return"0b"+e.toString(2);if(m)return"0o"+e.toString(8)}const S=t.escapeEverything?escapeEverythingRegex:escapeNonAsciiRegex;return g=e.replace(S,(e,r,i,c,a,u)=>{if(r){if(t.minimal)return r;const e=r.charCodeAt(0),i=r.charCodeAt(1);if(t.es6){return"\\u{"+hexadecimal(1024*(e-55296)+i-56320+65536,o)+"}"}return fourHexEscape(hexadecimal(e,o))+fourHexEscape(hexadecimal(i,o))}if(i)return fourHexEscape(hexadecimal(i.charCodeAt(0),o));if("\0"==e&&!n&&!regexDigit.test(u.charAt(a+1)))return"\\0";if(c)return c==s||t.escapeEverything?"\\"+c:c;if(regexSingleEscape.test(e))return singleEscapes[e];if(t.minimal&&!regexWhitespace.test(e))return e;const l=hexadecimal(e.charCodeAt(0),o);return n||l.length>2?fourHexEscape(l):"\\x"+("00"+l).slice(-2)}),"`"==s&&(g=g.replace(/\$\{/g,"\\${")),t.isScriptContext&&(g=g.replace(/<\/(script|style)/gi,"<\\/$1").replace(/