From 7e1502bfd3f1644871e5e32f025bf2f5fee2e137 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Thu, 12 Jan 2023 13:47:12 +0100 Subject: [PATCH] 14.0.0 --- dist/bundle-core.js | 2255 ++++++++++++++++++++------------ package-lock.json | 20 +- package.json | 2 +- patches/sodium-universal.patch | 12 + 4 files changed, 1467 insertions(+), 822 deletions(-) create mode 100644 patches/sodium-universal.patch diff --git a/dist/bundle-core.js b/dist/bundle-core.js index 28b3930..40742d8 100644 --- a/dist/bundle-core.js +++ b/dist/bundle-core.js @@ -1,65 +1,65 @@ (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.connectAndRemember=function(e,t){SSB.conn.connect(e,t,(r,n)=>{SSB.conn.remember(e,Object.assign(t,{autoconnect:!0}))})},exports.getPeer=function(){let e=Array.from(SSB.conn.hub().entries());var t=(e=e.filter(([,e])=>!!e.key).map(([e,t])=>({address:e,data:t}))).find(e=>"room"!=e.data.type);let r=Object.values(SSB.peers).flat();return t?r.find(e=>e.id==t.data.key):r.length>0?r[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(t,r){t.root.getDirectory(r,{},function(r){r.createReader().readEntries(function(r){for(var n=0;n{if(t)return console.error(t);e.destroy()})}}})})}(e,"/.ssb-lite/blobs")})},exports.convertHopsIntoGraph=function(e){const t=[],r=[],n=[],o=Object.keys(e);for(var i=0;i0&&e[s]<=SSB.config.friends.hops?n.push(s):-1==e[s]&&r.push(s)}return{following:t,extended:n,blocking:r}},exports.getGraphForFeed=function(e,t){SSB.friends.hops({start:e},(r,n)=>{if(r)return t(r);t(null,exports.convertHopsIntoGraph(n,e==SSB.id))})}; -},{"idb-kv-store":241,"path":373,"polyraf":389,"pull-stream":438,"ssb-keys":601,"ssb-validate":628}],3:[function(require,module,exports){ +},{"idb-kv-store":283,"path":423,"polyraf":439,"pull-stream":494,"ssb-keys":732,"ssb-validate":768}],3:[function(require,module,exports){ exports.init=function(e,o,r){const n=require("events");SSBLOADER=new n,require("sodium-browserify").events.on("sodium-browserify:wasm loaded",()=>{console.log("wasm loaded"),SSB=require("./net").init(e,o,r),console.log("my id: ",SSB.id);const n=require("./core-helpers");SSB.helpers={box:require("ssb-keys").box,connectAndRemember:n.connectAndRemember,getPeer:n.getPeer,convertHopsIntoGraph:n.convertHopsIntoGraph,getGraphForFeed:n.getGraphForFeed,removeDB:n.removeDB,removeIndexes:n.removeIndexes,removeBlobs:n.removeBlobs},o&&o.core&&o.core.startOffline||setTimeout(()=>{SSB.conn.start()},2500),SSBLOADER.emit("ready")})}; -},{"./core-helpers":2,"./net":4,"events":181,"sodium-browserify":552,"ssb-keys":601}],4:[function(require,module,exports){ +},{"./core-helpers":2,"./net":4,"events":214,"sodium-browserify":621,"ssb-keys":732}],4:[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 t=ssbKeys.loadOrCreateSync(path.join(e,"secret")),n=Object.assign({caps:{shs:Buffer.from(caps.shs,"base64")},keys:t,friends:{hops:2},connections:{incoming:{tunnel:[{scope:"public",transform:"shs"}]},outgoing:{net:[{transform:"shs"}],ws:[{transform:"shs"},{transform:"noauth"}],tunnel:[{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 i=SecretStack(n).use(require("ssb-db2/db")).use(require("ssb-db2/compat")).use(require("ssb-conn")).use(require("ssb-friends")).use(require("ssb-ebt")).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"));r&&(i=r(i));var o=i();return o.on("rpc:connect",function(e,s){let r;console.log("connected to:",e.id),function s(){e.tunnel.ping(function(e,t){if(e)return console.error(e);clearTimeout(r),r=setTimeout(s,1e4)})}()}),o}; +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 t=ssbKeys.loadOrCreateSync(path.join(e,"secret")),u=Object.assign({caps:{shs:Buffer.from(caps.shs,"base64")},keys:t,friends:{hops:2},connections:{incoming:{tunnel:[{scope:"public",transform:"shs"}]},outgoing:{net:[{transform:"shs"}],ws:[{transform:"shs"},{transform:"noauth"}],tunnel:[{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 i=SecretStack(u).use(require("ssb-db2/core")).use(require("ssb-classic")).use(require("ssb-box")).use(require("ssb-box2")).use(require("ssb-db2/compat/publish")).use(require("ssb-db2/compat/post")).use(require("ssb-db2/compat")).use(require("ssb-conn")).use(require("ssb-friends")).use(require("ssb-ebt")).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"));r&&(i=r(i));var o=i();return o.on("rpc:connect",function(e,s){let r;console.log("connected to:",e.id),function s(){e.tunnel.ping(function(e,t){if(e)return console.error(e);clearTimeout(r),r=setTimeout(s,1e4)})}()}),o}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./core-helpers":2,"./simple-blobs":701,"./simple-ooo":702,"./ssb-partial-replication":703,"buffer":101,"path":373,"secret-stack":538,"ssb-caps":558,"ssb-conn":571,"ssb-db2/compat":576,"ssb-db2/db":578,"ssb-ebt":595,"ssb-friends":600,"ssb-keys":601,"ssb-no-auth":609,"ssb-replication-scheduler":611,"ssb-room-client":616,"ssb-ws":631}],5:[function(require,module,exports){ +},{"./core-helpers":2,"./simple-blobs":837,"./simple-ooo":838,"./ssb-partial-replication":839,"buffer":117,"path":423,"secret-stack":596,"ssb-box":656,"ssb-box2":658,"ssb-caps":660,"ssb-classic":663,"ssb-conn":677,"ssb-db2/compat":682,"ssb-db2/compat/post":684,"ssb-db2/compat/publish":685,"ssb-db2/core":686,"ssb-ebt":705,"ssb-friends":710,"ssb-keys":732,"ssb-no-auth":741,"ssb-replication-scheduler":751,"ssb-room-client":756,"ssb-ws":769}],5:[function(require,module,exports){ +"use strict";class QuickLRU{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if("function"==typeof this.onEviction)for(const[t,i]of e)this.onEviction(t,i.value)}_deleteIfExpired(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}_getOrDeleteIfExpired(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const i=t.get(e);return this._getItemValue(e,i)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,i]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,i)&&(yield e)}}for(const e of this.cache){const[t,i]=e;!1===this._deleteIfExpired(t,i)&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,t))return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:i=(this.maxAge===1/0?void 0:Date.now()+this.maxAge)}={}){this.cache.has(e)?this.cache.set(e,{value:t,maxAge:i}):this._set(e,{value:t,expiry:i})}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}peek(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],i=t.length-e;i<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(i>0&&this._emitEvictions(t.slice(0,i)),this.oldCache=new Map(t.slice(i)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,i]=e;!1===this._deleteIfExpired(t,i)&&(yield[t,i.value])}for(const e of this.oldCache){const[t,i]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,i)&&(yield[t,i.value])}}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const i=e[t],[s,h]=i;!1===this._deleteIfExpired(s,h)&&(yield[s,h.value])}for(let t=(e=[...this.oldCache]).length-1;t>=0;--t){const i=e[t],[s,h]=i;if(!this.cache.has(s)){!1===this._deleteIfExpired(s,h)&&(yield[s,h.value])}}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}}module.exports=QuickLRU; + +},{}],6:[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":6}],6:[function(require,module,exports){ +},{"@minireq/common":7}],7:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const defaultSerializers={"application/json":{parse:JSON.parse,convert:JSON.stringify}},defaults={contentType:"application/json",responseType:"parsed",accept:"*/*"};function makeQueryString(e){if(!e)return"";if("string"==typeof e)return"?"===e.charAt(0)?e:"?"+e;let t="?";for(const r of Object.keys(e))t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r])+"&";if("?"===t)throw new Error("An empty object is not valid as query parameter");return t}exports.defaultSerializers=defaultSerializers,exports.defaults=defaults,exports.makeQueryString=makeQueryString; -},{}],7:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ (function (Buffer){(function (){ "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":6,"buffer":101,"http":652,"https":240}],8:[function(require,module,exports){ +},{"@minireq/common":7,"buffer":117,"http":790,"https":282}],9:[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":12}],9:[function(require,module,exports){ +},{"./next-tick":13}],10:[function(require,module,exports){ var nextTick=require("./next-tick");function AbstractIterator(t){if("object"!=typeof t||null===t)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=t,this._ended=!1,this._nexting=!1}AbstractIterator.prototype.next=function(t){var e=this;if("function"!=typeof t)throw new Error("next() requires a callback argument");return e._ended?(nextTick(t,new Error("cannot call next() after end()")),e):e._nexting?(nextTick(t,new Error("cannot call next() before previous next() has completed")),e):(e._nexting=!0,e._next(function(){e._nexting=!1,t.apply(null,arguments)}),e)},AbstractIterator.prototype._next=function(t){nextTick(t)},AbstractIterator.prototype.seek=function(t){if(this._ended)throw new Error("cannot call seek() after end()");if(this._nexting)throw new Error("cannot call seek() before next() has completed");t=this.db._serializeKey(t),this._seek(t)},AbstractIterator.prototype._seek=function(t){},AbstractIterator.prototype.end=function(t){if("function"!=typeof t)throw new Error("end() requires a callback argument");if(this._ended)return nextTick(t,new Error("end() already called on iterator"));this._ended=!0,this._end(t)},AbstractIterator.prototype._end=function(t){nextTick(t)},AbstractIterator.prototype._nextTick=nextTick,module.exports=AbstractIterator; -},{"./next-tick":12}],10:[function(require,module,exports){ +},{"./next-tick":13}],11:[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=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,i,r){var n=o(t,r);return r-1>=i&&(n|=o(t,r-1)<<4),n}function u(t,i,r,n){for(var h=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return h}h.isBN=function(t){return t instanceof h||null!==t&&"object"==typeof t&&t.constructor.wordSize===h.wordSize&&Array.isArray(t.words)},h.max=function(t,i){return t.cmp(i)>0?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++,this.negative=1),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,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var n=0;n=i;n-=2)h=s(t,i,n)<=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;else for(n=(t.length-i)%2==0?i+1:i;n=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;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,s=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},h.prototype.inspect=function(){return(this.red?""};var a=["","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"],l=[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],m=[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 f(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.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?a[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 f=l[t],d=m[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?M+n:a[f-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)},h.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},h.prototype.toArrayLike=function(t,i,n){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"),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},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,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],B=8191&q,R=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,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,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,F),h=(h=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(n=n+Math.imul(m,H)|0)|0)+((8191&(h=(h=h+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(h>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,F),h=(h=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),n=n+Math.imul(p,H)|0,h=(h=h+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|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,C))+Math.imul(b,F)|0,e=Math.imul(b,C),n=n+Math.imul(g,H)|0,h=(h=h+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|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,C))+Math.imul(A,F)|0,e=Math.imul(A,C),n=n+Math.imul(y,H)|0,h=(h=h+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|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(S,F),h=(h=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),n=n+Math.imul(k,H)|0,h=(h=h+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|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(B,F),h=(h=Math.imul(B,C))+Math.imul(R,F)|0,e=Math.imul(R,C),n=n+Math.imul(S,H)|0,h=(h=h+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|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(L,F),h=(h=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),n=n+Math.imul(B,H)|0,h=(h=h+Math.imul(B,J)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,J)|0,n=n+Math.imul(S,G)|0,h=(h=h+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,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(T,F),h=(h=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),n=n+Math.imul(L,H)|0,h=(h=h+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,n=n+Math.imul(B,G)|0,h=(h=h+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,n=n+Math.imul(S,W)|0,h=(h=h+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,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,C))+Math.imul(K,F)|0,e=Math.imul(K,C),n=n+Math.imul(T,H)|0,h=(h=h+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,n=n+Math.imul(L,G)|0,h=(h=h+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,n=n+Math.imul(B,W)|0,h=(h=h+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,n=n+Math.imul(S,$)|0,h=(h=h+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,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 xt=(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)+(xt>>>26)|0,xt&=67108863,n=Math.imul(j,H),h=(h=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),n=n+Math.imul(T,G)|0,h=(h=h+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,n=n+Math.imul(L,W)|0,h=(h=h+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,n=n+Math.imul(B,$)|0,h=(h=h+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,n=n+Math.imul(S,rt)|0,h=(h=h+Math.imul(S,nt)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,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 St=(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)+(St>>>26)|0,St&=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(T,W)|0,h=(h=h+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,n=n+Math.imul(L,$)|0,h=(h=h+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,n=n+Math.imul(B,rt)|0,h=(h=h+Math.imul(B,nt)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,nt)|0,n=n+Math.imul(S,et)|0,h=(h=h+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,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 Zt=(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)+(Zt>>>26)|0,Zt&=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(T,$)|0,h=(h=h+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,n=n+Math.imul(L,rt)|0,h=(h=h+Math.imul(L,nt)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,nt)|0,n=n+Math.imul(B,et)|0,h=(h=h+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,n=n+Math.imul(S,ut)|0,h=(h=h+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,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 qt=(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)+(qt>>>26)|0,qt&=67108863,n=Math.imul(j,$),h=(h=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),n=n+Math.imul(T,rt)|0,h=(h=h+Math.imul(T,nt)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,nt)|0,n=n+Math.imul(L,et)|0,h=(h=h+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,n=n+Math.imul(B,ut)|0,h=(h=h+Math.imul(B,at)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,at)|0,n=n+Math.imul(S,mt)|0,h=(h=h+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Bt=(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)+(Bt>>>26)|0,Bt&=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(T,et)|0,h=(h=h+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,n=n+Math.imul(L,ut)|0,h=(h=h+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,n=n+Math.imul(B,mt)|0,h=(h=h+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(a+(n=n+Math.imul(S,pt)|0)|0)+((8191&(h=(h=h+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(h>>>13)|0)+(Rt>>>26)|0,Rt&=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(T,ut)|0,h=(h=h+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,n=n+Math.imul(L,mt)|0,h=(h=h+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(n=n+Math.imul(B,pt)|0)|0)+((8191&(h=(h=h+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;a=((e=e+Math.imul(R,Mt)|0)+(h>>>13)|0)+(Nt>>>26)|0,Nt&=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(T,mt)|0,h=(h=h+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(n=n+Math.imul(L,pt)|0)|0)+((8191&(h=(h=h+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(h>>>13)|0)+(Lt>>>26)|0,Lt&=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(T,pt)|0)|0)+((8191&(h=(h=h+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(h>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(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)+(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]=Bt,u[14]=Rt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function p(t,i,r){return(new M).mulp(t,i,r)}function M(t,i){this.x=t,this.y=i}Math.imul||(d=f),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):r<63?f(this,t,i):r<1024?function(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()}(this,t,i):p(this,t,i)},M.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},M.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,i+=h/67108864|0,i+=e>>>26,this.words[n]=67108863&e}return 0!==i&&(this.words[n]=i,this.length++),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}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.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modn(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.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,n=0,h=this.length-1;h>=0;h--)n=(i*n+(0|this.words[h]))%t;return n},h.prototype.idivn=function(t){r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var h=(0|this.words[n])+67108864*i;this.words[n]=h/t|0,i=h%t}return this.strip()},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 _(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 v={k256:null,p224:null,p192:null,p25519:null};function g(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 c(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function y(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(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 k(t){_.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)}g.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.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},g.prototype.split=function(t,i){t.iushrn(this.n,0,i)},g.prototype.imulK=function(t){return t.imul(this.k)},n(c,g),c.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},c.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(v[t])return v[t];var i;if("k256"===t)i=new c;else if("p224"===t)i=new w;else if("p192"===t)i=new y;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new b}return v[t]=i,i},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.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")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.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)},_.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},_.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)},_.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},_.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},_.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.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},_.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},_.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new k(t)},n(k,_),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},k.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)},k.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)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":57}],29:[function(require,module,exports){ +},{"buffer":73}],29:[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":349,"util/":32}],30:[function(require,module,exports){ +},{"object-assign":399,"util/":32}],30:[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}; },{}],31:[function(require,module,exports){ @@ -102,143 +102,197 @@ 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":31,"_process":391,"inherits":30}],33:[function(require,module,exports){ +},{"./support/isBuffer":31,"_process":447,"inherits":30}],33:[function(require,module,exports){ +(function (Buffer,setImmediate){(function (){ +const RAF=require("polyraf"),fs=require("fs"),Obv=require("obz"),push=require("push-stream"),mutexify=require("mutexify"),debug=require("debug")("async-append-only-log"),Record=require("./record");function getStateFilename(t){return t+".compaction"}function stateFileExists(t){return fs.existsSync(getStateFilename(t))}const NO_TRUNCATE=4294967295;function PersistentState(t,e){const n=RAF(getStateFilename(t)),i=mutexify(),o=20+e;return{load:function(t){n.stat(function(e,i){(!e&&i?i.size:-1)<=0?t(null,{version:1,startOffset:0,truncateBlockIndex:NO_TRUNCATE,compactedBlockIndex:0,unshiftedOffset:0,unshiftedBlockBuffer:null,initial:!0}):n.read(0,o,function(e,n){if(e)return t(e);const i={version:n.readUInt32LE(0),startOffset:n.readUInt32LE(4),truncateBlockIndex:n.readUInt32LE(8),compactedBlockIndex:n.readUInt32LE(12),unshiftedOffset:n.readUInt32LE(16),unshiftedBlockBuf:n.slice(20),initial:!1};t(null,i)})})},save:function(t,e){const f=Buffer.alloc(o);f.writeUInt32LE(t.version,0),f.writeUint32LE(t.startOffset,4),f.writeUInt32LE(t.truncateBlockIndex,8),f.writeUInt32LE(t.compactedBlockIndex,12),f.writeUInt32LE(t.unshiftedOffset,16),t.unshiftedBlockBuf.copy(f,20),i(i=>{n.write(0,f,function(o){if(o)return i(e,o);n.fd?fs.fsync(n.fd,function(n){n?i(e,n):i(e,null,t)}):i(e,null,t)})})},destroy:function(e){stateFileExists(t)?n.close(function(t){if(t)return e(t);fs.unlink(n.filename,e)}):e()}}}function Compaction(t,e){const n=PersistentState(t.filename,t.blockSize),i=Obv();let o=0,f=0,u=0,r=!0,c=-1,s=null,l=0,a=!0,d=0,k=null,B=0,p=NO_TRUNCATE;var h;function m(t){function e(){n.save({version:f,startOffset:o,truncateBlockIndex:p,compactedBlockIndex:c,unshiftedOffset:B,unshiftedBlockBuf:k},t)}k?e():x(e)}function v(){for(;;){if(!k)return void x(v);if(-1===d)return void O(function(t){if(t)return e(t);S()});const[n,i]=I();if(!n){u+=1,E();continue}const o=c*t.blockSize,f=l-o;if(t.hasNoSpaceFor(n,f))return O(),void setImmediate(b);c===d&&l===B||(a=!1),Record.write(s,f,n),E(),l+=i}}function O(n){if(a)n&&n();else{const i=c;t.overwrite(i,s,function(t){if(t&&n)n(t);else{if(t)return e(t);debug("compacted block %d",i),n&&n()}})}}function x(n){const i=d*t.blockSize;t.getBlock(i,function(t,i){if(t)return e(t);k=i,n()})}function I(){const[,e,n]=t.getDataNextOffset(k,B,!0);return[e,n]}function E(){let[e]=t.getDataNextOffset(k,B,!0);-1===e?d=-1:0===e?(k=null,B=(d+=1)*t.blockSize):B=e}function b(){c+=1,s=Buffer.alloc(t.blockSize),l=c*t.blockSize,a=!0,i.set(function(){const e=(B-o)/(t.since.value-o);return{startOffset:o,compactedOffset:l,unshiftedOffset:B,percent:e}}()),m(function(t){if(t)return e(t);v()})}function S(){s=null,k=null;const t={version:f,startOffset:o,truncateBlockIndex:p=c,compactedBlockIndex:0,unshiftedOffset:0,unshiftedBlockBuf:Buffer.alloc(0)};n.save(t,function(t){if(t)return e(t);z()})}function z(){if(p===NO_TRUNCATE)return e(new Error("Cannot truncate log yet"));t.truncate(p,function(t,i){if(t)return e(t);n.destroy(function(t){if(t)return e(t);e(null,0===i&&r?{sizeDiff:1,holesFound:u}:{sizeDiff:i,holesFound:u})})})}return h=function(t){if(t)return e(t);p!==NO_TRUNCATE?z():(c-=1,b())},n.load(function(e,n){return e?h(e):1!==n.version?h(new Error("unsupported state version")):(f=n.version,o=n.startOffset,p=n.truncateBlockIndex,c=n.compactedBlockIndex,B=n.unshiftedOffset,k=n.unshiftedBlockBuf,d=Math.floor(n.unshiftedOffset/t.blockSize),void(n.initial?function(e){!function(e){t.stream({offsets:!0,values:!0}).pipe(push.drain(function(t){if(null===t.value)return e(null,t.offset),!1},function(){e(null,-1)}))}(function(n,i){if(n)return e(n);if(-1===i)return c=Math.floor(t.since.value/t.blockSize),r=!1,void S();const o=i-i%t.blockSize,f=Math.floor(i/t.blockSize);!function(e,n){t.stream({gte:e,offsets:!0,values:!0}).pipe(push.drain(function(t){if(null!==t.value)return n(null,t.offset),!1},function(){n(null,-1)}))}(o,function(n,o){if(n)return e(n);if(-1===o)return c=Math.floor((i-1)/t.blockSize),void S();u=o>i?1:0;const r={compactedBlockIndex:f,unshiftedOffset:o,unshiftedBlockBuf:null};e(null,r)})})}(function(e,n){if(e)return h(e);c=n.compactedBlockIndex,o=c*t.blockSize,B=n.unshiftedOffset,k=n.unshiftedBlockBuf,d=Math.floor(B/t.blockSize),m(h)}):h()))}),{progress:i}}Compaction.stateFileExists=stateFileExists,module.exports=Compaction; + +}).call(this)}).call(this,require("buffer").Buffer,require("timers").setImmediate) +},{"./record":36,"buffer":117,"debug":154,"fs":116,"mutexify":386,"obz":408,"polyraf":439,"push-stream":544,"timers":813}],34:[function(require,module,exports){ +class ErrorWithCode extends Error{constructor(r,e){super(r),this.code=e}}function nanOffsetErr(r){return new ErrorWithCode(`Offset ${r} is not a number`,"ERR_AAOL_INVALID_OFFSET")}function negativeOffsetErr(r){return new ErrorWithCode(`Offset ${r} is negative`,"ERR_AAOL_INVALID_OFFSET")}function outOfBoundsOffsetErr(r,e){return new ErrorWithCode(`Offset ${r} is beyond log size ${e}`,"ERR_AAOL_OFFSET_OUT_OF_BOUNDS")}function deletedRecordErr(){return new ErrorWithCode("Record has been deleted","ERR_AAOL_DELETED_RECORD")}function delDuringCompactErr(){return new Error("Cannot delete while compaction is in progress")}function compactWithMaxLiveStreamErr(){return new Error("Compaction cannot run if there are live streams configured with opts.lt or opts.lte")}function appendLargerThanBlockErr(){return new Error("Data to be appended is larger than block size")}function appendTransactionWantsArrayErr(){return new Error("appendTransaction expects first argument to be an array")}function unexpectedTruncationErr(){return new Error("truncate() is trying to *increase* the log size, which is totally unexpected. There may be a logic bug in async-append-only-log")}module.exports={ErrorWithCode:ErrorWithCode,nanOffsetErr:nanOffsetErr,negativeOffsetErr:negativeOffsetErr,outOfBoundsOffsetErr:outOfBoundsOffsetErr,deletedRecordErr:deletedRecordErr,delDuringCompactErr:delDuringCompactErr,compactWithMaxLiveStreamErr:compactWithMaxLiveStreamErr,appendLargerThanBlockErr:appendLargerThanBlockErr,appendTransactionWantsArrayErr:appendTransactionWantsArrayErr,unexpectedTruncationErr:unexpectedTruncationErr}; + +},{}],35:[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-append-only-log"),fs=require("fs"),mutexify=require("mutexify"),Stream=require("./stream"),Record=require("./record"),EOB={SIZE:Record.HEADER_SIZE,asNumber:0},DEFAULT_BLOCK_SIZE=65536,DEFAULT_CODEC={encode:e=>e,decode:e=>e},DEFAULT_WRITE_TIMEOUT=250,DEFAULT_VALIDATE=()=>!0;module.exports=function(e,t){const n=new Cache(1024),r=RAF(e),o=t&&t.blockSize||65536,i=t&&t.codec||DEFAULT_CODEC,s=t&&t.writeTimeout||250,u=t&&t.validateRecord||DEFAULT_VALIDATE;let f;const c=[],l=new Map,d=new Map;let a=-1,g=null,b=null,h=null;const E=Obv();function m(e){return e%o}function R(e){return e-m(e)}function p(e){return R(e)+o}r.stat(function(t,i){t&&debug("failed to stat "+e,t);const s=i?i.size:-1;if(s<=0)for(debug("empty file"),g=Buffer.alloc(o),b=0,h=0,n.set(0,g),E.set(-1);c.length;)c.shift()();else{const e=s-o;r.read(e,o,(t,n)=>{if(t)throw t;!function(e,t,n){let r=0;for(let i=0;io)return void A(e,i,t,r,n);if(!u(s))return void A(e,i,t,r,n);r=i,i+=f}}n(null,r)}(n,e,(t,r)=>{if(t)throw t;g=n,b=s/o-1;const i=Record.readSize(n,r);for(h=r+i,E.set(e+r),debug("opened file, since: %d",E.value);c.length;)c.shift()()})})}});const w=mutexify();function y(e,t,n,o){w(i=>{r.write(e,t,e=>{if(e)return i(o,e);r.fd?fs.fsync(r.fd,e=>{e?i(o,e):i(o,null,n)}):i(o,null,n)})})}function A(e,t,n,r,i){debug("found invalid record at %d, fixing last block",t),e.fill(0,t,o),y(n,e,r,i)}function D(e,t){const i=R(e),s=function(e){return R(e)/o}(e),u=n.get(s);u?(debug("getting offset %d from cache",e),t(null,u)):(debug("getting offset %d from disc",e),r.read(i,o,(e,r)=>{n.set(s,r),t(e,r)}))}function B(e){let t=i.encode(e);if("string"==typeof t&&(t=Buffer.from(t)),Record.size(t)+EOB.SIZE>o)throw new Error("data larger than block size");if(h+Record.size(t)+EOB.SIZE>o){const e=Buffer.alloc(o);g=e,b+=1,h=0,debug("data doesn't fit current block, creating new")}Record.write(g,h,t),n.set(b,g);const r=b*o+h;return d.set(b,{blockBuf:g,offset:r}),h+=Record.size(t),O(),debug("data inserted at offset %d",r),r}const O=debounce(k,s);function k(){d.size>0&&function(e){if(!d.has(e))return;a=e;const{blockBuf:t,offset:n}=d.get(e);d.delete(e),debug("writing block of size: %d, to offset: %d",t.length,e*o),y(e*o,t,null,t=>{const r=(l.get(e)||[]).slice(0);if(a=-1,t)throw debug("failed to write block %d",e),t;{E.set(n),f.streams.forEach(e=>{e.live&&e.liveResume()}),debug("draining the waiting queue for %d, items: %d",e,r.length);for(let e=0;e= 0`):void D(e,(n,r)=>{if(n)return t(n);!function(e,t,n){const[r]=Record.read(e,t);if(r.every(e=>0===e)){const e=new Error("item has been deleted");return e.code="ERR_AAOL_DELETED_RECORD",n(e)}n(null,i.decode(r))}(r,m(e),t)})}),del:v(function(e,t){D(e,(n,r)=>{if(n)return t(n);Record.overwriteWithZeroes(r,m(e)),y(R(e),r,null,t)})}),append:v(function(e,t){if(Array.isArray(e)){let n=0;for(let t=0,r=e.length;t{let t=i.encode(e);return"string"==typeof t&&(t=Buffer.from(t)),r+=Record.size(t),t});if((r+=EOB.SIZE)>o)return t(new Error("data larger than block size"));if(h+r>o){const e=Buffer.alloc(o);g=e,b+=1,h=0,debug("data doesn't fit current block, creating new")}const u=[];for(const e of s){Record.write(g,h,e),n.set(b,g);const t=b*o+h;u.push(t),d.set(b,{blockBuf:g,offset:t}),h+=Record.size(e),debug("data inserted at offset %d",t)}return O(),t(null,u)}),close:v(function(e){f.onDrain(function(){for(;f.streams.length;)f.streams.shift().abort(new Error("async-append-only-log closed"));r.close(e)})}),onDrain:v(function(e){if(0===d.size&&-1===a)e();else{const t=d.size>0?function(e){let t=null;for(let n of e)t=n;return t}(d.keys()):a,n=l.get(t)||[];n.push(e),l.set(t,n)}}),since:E,stream(e){const t=new Stream(f,e);return f.streams.push(t),t},filename:e,onLoad:v,getNextBlockStart:p,getDataNextOffset:function(e,t){const n=m(t),[r,o]=Record.read(e,n);let s;return s=Record.readDataLength(e,n+o)===EOB.asNumber?p(t)>E.value?-1:0:t+o,r.every(e=>0===e)?[s,null]:[s,i.decode(r)]},getBlock:D,streams:[]}}; +const Cache=require("@alloc/quick-lru"),RAF=require("polyraf"),Obv=require("obz"),AtomicFile=require("atomic-file-rw"),debounce=require("lodash.debounce"),isBufferZero=require("is-buffer-zero"),debug=require("debug")("async-append-only-log"),fs=require("fs"),mutexify=require("mutexify"),{deletedRecordErr:deletedRecordErr,nanOffsetErr:nanOffsetErr,negativeOffsetErr:negativeOffsetErr,outOfBoundsOffsetErr:outOfBoundsOffsetErr,delDuringCompactErr:delDuringCompactErr,appendLargerThanBlockErr:appendLargerThanBlockErr,appendTransactionWantsArrayErr:appendTransactionWantsArrayErr,unexpectedTruncationErr:unexpectedTruncationErr,compactWithMaxLiveStreamErr:compactWithMaxLiveStreamErr}=require("./errors"),Stream=require("./stream"),Record=require("./record"),Compaction=require("./compaction"),EOB={SIZE:Record.HEADER_SIZE,asNumber:0},DEFAULT_BLOCK_SIZE=65536,DEFAULT_CODEC={encode:e=>e,decode:e=>e},DEFAULT_WRITE_TIMEOUT=250,DEFAULT_VALIDATE=()=>!0,COMPACTION_PROGRESS_EMIT_INTERVAL=1e3;module.exports=function(e,t){const n=new Cache({maxSize:1024}),r=RAF(e),o=e+".stats",i=t&&t.blockSize||65536,s=t&&t.codec||DEFAULT_CODEC,c=t&&t.writeTimeout||250,f=t&&t.validateRecord||DEFAULT_VALIDATE;let u;const a=[],l=new Map,d=[],g=new Map,p=new Map;let m=!1,E=-1,h=null,b=null,v=null,O=0;const y=Obv();let B=null;const R=Obv();"undefined"!=typeof window?R.set({percent:1,done:!0,sizeDiff:0}):R.set(Compaction.stateFileExists(e)?{percent:0,done:!1}:{percent:1,done:!0,sizeDiff:0});const T=[];function w(e,t){r.read(e,i,function(n,r){if(n)return t(n);!function(e,t,n){let r=0;for(let o=0;oi,l=!f(c);if(a||l)return void L(e,o,t,r,n);r=o,o+=u}n(null,r)}(r,e,function(n,o){if(n)return t(n);h=r,b=e/i;const s=Record.readSize(r,o);v=o+s,y.set(e+o),t()})})}function A(e){return e%i}function S(e){return e-A(e)}function x(e){return S(e)+i}function D(e){return S(e)/i}W(function(){Compaction.stateFileExists(e)&&Z(function(e){if(e)throw e})})(),AtomicFile.readFile(o,"utf8",function(t,o){if(t)debug("error loading stats: %s",t.message),O=0;else try{const e=JSON.parse(o);O=e.deletedBytes}catch(t){debug("error parsing stats: %s",t.message),O=0}r.stat(function(t,r){t&&debug("failed to stat "+e,t);const o=r?r.size:-1;if(o<=0)for(debug("empty file"),h=Buffer.alloc(i),b=0,v=0,n.set(0,h),y.set(-1);a.length;)a.shift()();else{w(o-i,function(e){if(e)throw e;for(debug("opened file, since: %d",y.value);a.length;)a.shift()()})}})});const k=mutexify();function z(e,t,n,o){k(function(i){r.write(e,t,function(e){if(e)return i(o,e);r.fd?fs.fsync(r.fd,function(e){e?i(o,e):i(o,null,n)}):i(o,null,n)})})}function L(e,t,n,r,o){debug("found invalid record at %d, fixing last block",t),e.fill(0,t,i),z(n,e,r,o)}function C(e,t){const o=D(e);if(n.has(o)){debug("getting offset %d from cache",e);const r=n.get(o);t(null,r)}else{debug("getting offset %d from disc",e);const s=S(e);r.read(s,i,function(e,r){n.set(o,r),t(e,r)})}}function I(e,t){return t+Record.size(e)+EOB.SIZE>i}const F=debounce(function e(){if(0===p.size){for(const e of d)e();return void(d.length=0)}const t=p.keys().next().value;const n=t*i;const r=p.get(t);p.delete(t);m=!0;z(n,r,null,function(t){M(function(t){if(t&&debug("error saving stats: %s",t.message),m=!1,t){for(const e of d)e(t);d.length=0}else e()})})},c);function _(e){m||p.size>0?d.push(e):e()}function q(e){let t=s.encode(e);if("string"==typeof t&&(t=Buffer.from(t)),Record.size(t)+EOB.SIZE>i)throw appendLargerThanBlockErr();if(I(t,v)){const e=Buffer.alloc(i);h=e,b+=1,v=0,debug("data doesn't fit current block, creating new")}Record.write(h,v,t),n.set(b,h);const r=b*i+v;return g.set(b,{blockBuf:h,offset:r}),v+=Record.size(t),N(),debug("data inserted at offset %d",r),r}const N=debounce(function e(){if(0===g.size)return;const t=g.keys().next().value;const n=t*i;const{blockBuf:r,offset:o}=g.get(t);g.delete(t);debug("writing block of size: %d, to offset: %d",r.length,t*i);E=t;z(n,r,null,function(n){const r=(l.get(t)||[]).slice(0);if(E=-1,n)throw debug("failed to write block %d",t),n;{y.set(o);for(const e of u.streams)e.live&&e.liveResume();debug("draining the waiting queue for %d, items: %d",t,r.length);for(let e=0;ee.cursor===y.value))return e();const t=setInterval(function(){for(const e of u.streams)if(e.cursor{if(B=null,t)return e(t);O=0,M(function(e){e&&debug("error saving stats after compaction: %s",e.message)});for(const e of u.streams)e.live&&e.postCompactionReset(y.value);R.set({...n,percent:1,done:!0});for(const e of T)e();T.length=0,e()});let t=0;B.progress(e=>{const n=Date.now();n-t>COMPACTION_PROGRESS_EMIT_INTERVAL&&(t=n,R.set({...e,done:!1}))})})})})}function W(e){return function(...t){null===h?a.push(e.bind(null,...t)):e(...t)}}function U(e){if(B)T.push(e);else if(0===g.size&&-1===E)e();else{const t=g.size>0?function(e){let t=null;for(let n of e)t=n;return t}(g.keys()):E,n=l.get(t)||[];n.push(e),l.set(t,n)}}return u={get:W(function(e,t){const n=b*i+v;return"number"!=typeof e?t(nanOffsetErr(e)):isNaN(e)?t(nanOffsetErr(e)):e<0?t(negativeOffsetErr(e)):e>=n?t(outOfBoundsOffsetErr(e,n)):void C(e,function(n,r){if(n)return t(n);const[o]=Record.read(r,A(e));if(isBufferZero(o))return t(deletedRecordErr());t(null,s.decode(o))})}),del:W(function e(t,n){if(B)return void n(delDuringCompactErr());const r=D(t);g.has(r)?U(function(){e(t,n)}):p.has(r)?o(null,p.get(r)):C(t,o);function o(e,o){if(e)return n(e);const i=p.get(r)||o;Record.overwriteWithZeroes(i,A(t)),O+=Record.readSize(i,A(t)),p.set(r,i),F(),n()}}),append:W(function e(t,n){if(B)T.push(()=>e(t,n));else if(Array.isArray(t)){let e=0;for(let n=0,r=t.length;ne(t,r));let o=0;const c=t.map(e=>{let t=s.encode(e);return"string"==typeof t&&(t=Buffer.from(t)),o+=Record.size(t),t});if((o+=EOB.SIZE)>i)return r(appendLargerThanBlockErr());if(v+o>i){const e=Buffer.alloc(i);h=e,b+=1,v=0,debug("data doesn't fit current block, creating new")}const f=[];for(const e of c){Record.write(h,v,e),n.set(b,h);const t=b*i+v;f.push(t),g.set(b,{blockBuf:h,offset:t}),v+=Record.size(e),debug("data inserted at offset %d",t)}return N(),r(null,f)}),close:W(function(e){U(function(){_(function(){for(const e of u.streams)e.abort(!0);u.streams.clear(),r.close(e)})})}),onDrain:W(U),onDeletesFlushed:W(_),compact:W(Z),since:y,stats:function(e){null==y.value?y(t=>(e(null,{totalBytes:Math.max(0,t),deletedBytes:O}),!1)):e(null,{totalBytes:Math.max(0,y.value),deletedBytes:O})},compactionProgress:R,stream(e){const t=new Stream(u,e);return u.streams.add(t),t},filename:e,blockSize:i,overwrite:function(e,t,r){n.set(e,t),z(e*i,t,null,r)},truncate:function(e,t){if(e>b)return t(unexpectedTruncationErr());if(e===b)return void w(b*i,function(e){e?t(e):t(null,0)});const o=(b+1)*i,s=(e+1)*i;for(let t=e+1;ty.value?-1:0:t+i,isBufferZero(o)?[c,null,i]:[c,n?o:s.decode(o),i]},getBlock:C,streams:new Set}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./record":34,"./stream":35,"buffer":101,"debug":134,"fs":100,"hashlru":235,"lodash.debounce":307,"mutexify":336,"obz":358,"polyraf":389}],34:[function(require,module,exports){ +},{"./compaction":33,"./errors":34,"./record":36,"./stream":37,"@alloc/quick-lru":5,"atomic-file-rw":41,"buffer":117,"debug":154,"fs":116,"is-buffer-zero":296,"lodash.debounce":357,"mutexify":386,"obz":408,"polyraf":439}],36:[function(require,module,exports){ const HEADER_SIZE=2;function size(e){return HEADER_SIZE+e.length}function readDataLength(e,t){return e.readUInt16LE(t)}function readSize(e,t){const r=readDataLength(e,t);return HEADER_SIZE+r}function read(e,t){const r=readDataLength(e,t),n=t+HEADER_SIZE;return[e.slice(n,n+r),HEADER_SIZE+r]}function write(e,t,r){e.writeUInt16LE(r.length,t),r.copy(e,t+HEADER_SIZE)}function overwriteWithZeroes(e,t){const r=readDataLength(e,t),n=t+HEADER_SIZE,E=n+r;e.fill(0,n,E)}module.exports={HEADER_SIZE:HEADER_SIZE,size:size,readDataLength:readDataLength,readSize:readSize,read:read,write:write,overwriteWithZeroes:overwriteWithZeroes}; -},{}],35:[function(require,module,exports){ -const ltgt=require("ltgt"),looper=require("looper");module.exports=Stream;const BLOCK_STATE=Object.freeze({GET_NEXT_BLOCK:0,END_OF_STREAM:1,PAUSED:2}),STREAM_STATE=Object.freeze({INITIALIZING:0,LOADED:1,RUNNING:2,PAUSED:3,ENDED:4});function Stream(t,s){s=s||{},this.log=t,this.live=!!s.live,this.offsets=!1!==s.offsets,this.values=!1!==s.values,this.limit=s.limit||0,this.state=STREAM_STATE.INITIALIZING,this.min=ltgt.lowerBound(s,null),ltgt.lowerBoundInclusive(s)&&(this.min_inclusive=this.min),this.max=ltgt.upperBound(s,null),ltgt.upperBoundInclusive(s)&&(this.max_inclusive=this.max),this.cursor=-1,this.count=0,this.skip_next=!1,this.opts=s,this._resumeCallback=this._resumeCallback.bind(this),this._resume=this._resume.bind(this),this.log.onLoad(this._ready.bind(this))()}Stream.prototype._ready=function(){this.cursor=ltgt.lowerBound(this.opts,0),this.cursor<0&&(this.cursor=0),this.opts.gt>=0&&(this.skip_next=!0),0===this.cursor&&-1===this.log.since.value?this.live?this.state=STREAM_STATE.INITIALIZING:this.state=STREAM_STATE.ENDED:this.state=STREAM_STATE.LOADED,this.resume()},Stream.prototype._writeToSink=function(t){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 BLOCK_STATE.PAUSED;const[s,i]=this.log.getDataNextOffset(t,this.cursor);if(this.skip_next){if(this.skip_next=!1,s>0){this.cursor=s;continue}if(0===s)return BLOCK_STATE.GET_NEXT_BLOCK;if(-1===s)return BLOCK_STATE.END_OF_STREAM}this.count++;const e=this.cursor;if(!(null===this.min||this.mine||this.max_inclusive===e))return BLOCK_STATE.END_OF_STREAM;if(this._writeToSink(i),s>0)this.cursor=s;else{if(0===s)return BLOCK_STATE.GET_NEXT_BLOCK;if(-1===s)return BLOCK_STATE.END_OF_STREAM}if(this.limit>0&&this.count>=this.limit)return BLOCK_STATE.END_OF_STREAM}},Stream.prototype._resume=function(){this.state!==STREAM_STATE.ENDED?this.state!==STREAM_STATE.INITIALIZING&&(this.sink&&!this.sink.paused?(this.state=STREAM_STATE.RUNNING,this.log.getBlock(this.cursor,this._resumeCallback)):this.state=STREAM_STATE.PAUSED):this.sink&&!this.sink.ended&&this.abort()},Stream.prototype._resumeCallback=function(t,s){if(t)return void console.error(t);const i=this._handleBlock(s);i===BLOCK_STATE.GET_NEXT_BLOCK?(this.cursor=this.log.getNextBlockStart(this.cursor),this._next()):i===BLOCK_STATE.PAUSED?this.state=STREAM_STATE.PAUSED:i===BLOCK_STATE.END_OF_STREAM&&(this.live?(this.state=STREAM_STATE.PAUSED,this.skip_next=!0):this.abort())},Stream.prototype.resume=function(){this.state!==STREAM_STATE.RUNNING&&(this._next=looper(this._resume),this._next())},Stream.prototype.liveResume=function(){this.state===STREAM_STATE.INITIALIZING&&(this.state=STREAM_STATE.LOADED),this.resume()},Stream.prototype.abort=function(t){this.state=STREAM_STATE.ENDED;const s=this.log.streams.indexOf(this);~s&&this.log.streams.splice(s,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"); +},{}],37:[function(require,module,exports){ +const ltgt=require("ltgt"),looper=require("looper");module.exports=Stream;const BLOCK_STATE=Object.freeze({GET_NEXT_BLOCK:0,END_OF_STREAM:1,PAUSED:2}),STREAM_STATE=Object.freeze({INITIALIZING:0,LOADED:1,RUNNING:2,PAUSED:3,ENDED:4});function Stream(t,s){s=s||{},this.log=t,this.live=!!s.live,this.offsets=!1!==s.offsets,this.values=!1!==s.values,this.sizes=!0===s.sizes,this.limit=s.limit||0,this.state=STREAM_STATE.INITIALIZING,this.min=ltgt.lowerBound(s,null),ltgt.lowerBoundInclusive(s)&&(this.min_inclusive=this.min),this.max=ltgt.upperBound(s,null),ltgt.upperBoundInclusive(s)&&(this.max_inclusive=this.max),this.cursor=-1,this.count=0,this.skip_next=!1,this.opts=s,this._resumeCallback=this._resumeCallback.bind(this),this._resume=this._resume.bind(this),this.log.onLoad(this._ready.bind(this))()}Stream.prototype._ready=function(){this.cursor=ltgt.lowerBound(this.opts,0),this.cursor<0&&(this.cursor=0),this.opts.gt>=0&&(this.skip_next=!0),0===this.cursor&&-1===this.log.since.value?this.live?this.state=STREAM_STATE.INITIALIZING:this.state=STREAM_STATE.ENDED:this.state=STREAM_STATE.LOADED,this.resume()},Stream.prototype._writeToSink=function(t,s){const i=this.cursor,e=this.offsets,r=this.values,h=this.sizes;e&&r&&h?this.sink.write({offset:i,value:t,size:s}):e&&r?this.sink.write({offset:i,value:t}):e&&h?this.sink.write({offset:i,size:s}):r&&h?this.sink.write({value:t,size:s}):e?this.sink.write(i):r?this.sink.write(t):h?this.sink.write(s):this.sink.write(i)},Stream.prototype._handleBlock=function(t){for(;;){if(this.sink.paused||this.sink.ended)return BLOCK_STATE.PAUSED;const[s,i,e]=this.log.getDataNextOffset(t,this.cursor);if(this.skip_next){if(this.skip_next=!1,s>0){this.cursor=s;continue}if(0===s)return BLOCK_STATE.GET_NEXT_BLOCK;if(-1===s)return BLOCK_STATE.END_OF_STREAM}this.count++;const r=this.cursor;if(!(null===this.min||this.minr||this.max_inclusive===r))return BLOCK_STATE.END_OF_STREAM;if(this._writeToSink(i,e),s>0)this.cursor=s;else{if(0===s)return BLOCK_STATE.GET_NEXT_BLOCK;if(-1===s)return BLOCK_STATE.END_OF_STREAM}if(this.limit>0&&this.count>=this.limit)return BLOCK_STATE.END_OF_STREAM}},Stream.prototype._resume=function(){this.state!==STREAM_STATE.ENDED?this.state!==STREAM_STATE.INITIALIZING&&(this.sink&&!this.sink.paused?(this.state=STREAM_STATE.RUNNING,this.log.getBlock(this.cursor,this._resumeCallback)):this.state=STREAM_STATE.PAUSED):this.sink&&!this.sink.ended&&this.abort()},Stream.prototype._resumeCallback=function(t,s){if(t)return void console.error(t);const i=this._handleBlock(s);i===BLOCK_STATE.GET_NEXT_BLOCK?(this.cursor=this.log.getNextBlockStart(this.cursor),this._next()):i===BLOCK_STATE.PAUSED?this.state=STREAM_STATE.PAUSED:i===BLOCK_STATE.END_OF_STREAM&&(this.live?(this.state=STREAM_STATE.PAUSED,this.skip_next=!0):this.abort())},Stream.prototype.resume=function(){this.state!==STREAM_STATE.RUNNING&&(this._next=looper(this._resume),this._next())},Stream.prototype.liveResume=function(){this.state===STREAM_STATE.INITIALIZING&&(this.state=STREAM_STATE.LOADED),this.resume()},Stream.prototype.postCompactionReset=function(t){this.cursor=Math.min(t,this.cursor),this.min=null,this.min_inclusive=null},Stream.prototype.abort=function(t){this.state=STREAM_STATE.ENDED,this.log.streams.delete(this),!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":308,"ltgt":309,"push-stream/pipe":488}],36:[function(require,module,exports){ +},{"looper":358,"ltgt":359,"push-stream/pipe":545}],38:[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()}; -},{}],37:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ (function (Buffer){(function (){ -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)}}; +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)},deleteFile:function(e,t){const{store:r,key:n}=getStoreAndKey(e);r.remove(n,t)}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":101,"idb-kv-store":241}],38:[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)})})})})})})}}; +},{"buffer":117,"idb-kv-store":283}],40:[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={_map:new Map,getOrCreate:function(e){if(this._map.has(e))return this._map.get(e);{const n=mutexify();return this._map.set(e,n),n}}};module.exports={readFile:function(e,n,t){t||(t=n),fs.readFile(e,getEncoding(n),t)},writeFile:function(e,n,t,r){r||(r=t),locks.getOrCreate(e)(i=>{const u=e+"~";fs.mkdirSync(path.dirname(u),{recursive:!0}),fs.open(u,"w",(f,s)=>{if(f)return i(r,f);fs.writeFile(s,n,getEncoding(t),t=>{if(t)return i(r,t);fs.fsync(s,t=>{if(t)return i(r,t);fs.close(s,t=>{if(t)return i(r,t);fs.rename(u,e,e=>{if(e)return i(r,e);i(r,null,n)})})})})})})},deleteFile:function(e,n){locks.getOrCreate(e)(t=>{fs.unlink(e,e=>{if(e)return t(n,e);t(n,null,null)})})}}; -},{"fs":100,"mutexify":336,"path":373}],39:[function(require,module,exports){ +},{"fs":116,"mutexify":386,"path":423}],41:[function(require,module,exports){ "undefined"==typeof localStorage||null===localStorage?module.exports=require("./fs"):module.exports=require("./browser"); -},{"./browser":37,"./fs":38}],40:[function(require,module,exports){ +},{"./browser":39,"./fs":40}],42:[function(require,module,exports){ const Store=require("./store/idb"),Inject=require("./inject");module.exports=function(e,r,t){return Inject(Store(e,r,t&&t.buffer),t)}; -},{"./inject":41,"./store/idb":42}],41:[function(require,module,exports){ +},{"./inject":43,"./store/idb":44}],43:[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":185,"mutexify":336}],42:[function(require,module,exports){ +},{"flumecodec/json":222,"mutexify":386}],44:[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":101,"idb-kv-store":241}],43:[function(require,module,exports){ +},{"buffer":117,"idb-kv-store":283}],45:[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]})}; +"use strict";var possibleNames=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],g="undefined"==typeof globalThis?global:globalThis;module.exports=function(){for(var r=[],a=0;af)return 1}return e.byteLength>t.byteLength?1:e.byteLengthe+t.byteLength,0));const n=new Uint8Array(t);return e.reduce((e,t)=>(n.set(t,e),e+t.byteLength),0),n}function copy(e,t,n=0,r=0,f=e.byteLength){if(f>0&&f=e.byteLength)throw new RangeError("sourceStart is out of range");if(f<0)throw new RangeError("sourceEnd is out of range");n>=t.byteLength&&(n=t.byteLength),f>e.byteLength&&(f=e.byteLength),t.byteLength-n=e.byteLength){if(f)return-1;n=e.byteLength-1}else if(n<0){if(!f)return-1;n=0}if("string"==typeof t)t=from(t,r);else if("number"==typeof t)return t&=255,f?e.indexOf(t,n):e.lastIndexOf(t,n);if(0===t.byteLength)return-1;if(f){let r=-1;for(let f=n;fe.byteLength&&(n=e.byteLength-t.byteLength);for(let r=n;r>=0;r--){let n=!0;for(let f=0;f=f?"":r<=n?"":(n<0&&(n=0),r>f&&(r=f),(0!==n||r1&&61===t.charCodeAt(e-1)&&e--,3*e>>>2}function toString(t){const e=t.byteLength;let n="";for(let o=0;o>2]+alphabet[(3&t[o])<<4|t[o+1]>>4]+alphabet[(15&t[o+1])<<2|t[o+2]>>6]+alphabet[63&t[o+2]];return e%3==2?n=n.substring(0,n.length-1)+"=":e%3==1&&(n=n.substring(0,n.length-2)+"=="),n}function write(t,e,n=0,o=byteLength(e)){const r=Math.min(o,t.byteLength-n);for(let n=0,o=0;n>4,t[o++]=(15&h)<<4|a>>2,t[o++]=(3&a)<<6|63&c}return r}codes[45]=62,codes[95]=63,module.exports={byteLength:byteLength,toString:toString,write:write}; + +},{}],49:[function(require,module,exports){ +function byteLength(t){return t.length>>>1}function toString(t){const e=t.byteLength;t=new DataView(t.buffer,t.byteOffset,e);let n="",r=0;for(let o=e-e%4;r=48&&t<=57?t-48:t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:void 0}module.exports={byteLength:byteLength,toString:toString,write:write}; + +},{}],50:[function(require,module,exports){ +function byteLength(t){return 2*t.length}function toString(t){const e=t.byteLength;let n="";for(let r=0;r>8,h=o%256;t[n+2*r]=h,t[n+2*r+1]=g}return o}module.exports={byteLength:byteLength,toString:toString,write:write}; + +},{}],51:[function(require,module,exports){ +function byteLength(t){let e=0;for(let n=0,o=t.length;n=55296&&r<=56319&&n+1=56320&&o<=57343){e+=4,n++;continue}}e+=r<=127?1:r<=2047?2:3}return e}let toString,write;if("undefined"!=typeof TextDecoder){const t=new TextDecoder;toString=function(e){return t.decode(e)}}else toString=function(t){const e=t.byteLength;let n="",o=0;for(;o0){let e=0;for(;e>o,o-=6;o>=0;)t[c++]=128|n>>o&63,o-=6;i+=n>=65536?2:1}return r};module.exports={byteLength:byteLength,toString:toString,write:write}; + +},{}],52:[function(require,module,exports){ "use strict";function balanced(e,n,a){e instanceof RegExp&&(e=maybeMatch(e,a)),n instanceof RegExp&&(n=maybeMatch(n,a));var t=range(e,n,a);return t&&{start:t[0],end:t[1],pre:a.slice(0,t[0]),body:a.slice(t[0]+e.length,t[1]),post:a.slice(t[1]+n.length)}}function maybeMatch(e,n){var a=n.match(e);return a?a[0]:null}function range(e,n,a){var t,r,c,i,l,o=a.indexOf(e),f=a.indexOf(n,o+1),g=o;if(o>=0&&f>0){for(t=[],c=a.length;g>=0&&!l;)g==o?(t.push(g),o=a.indexOf(e,g+1)):1==t.length?l=[t.pop(),f]:((r=t.pop())=0?o:f;t.length&&(l=[c,i])}return l}module.exports=balanced,balanced.range=range; -},{}],45:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ "use strict";exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function byteLength(o){var r=getLens(o),e=r[0],t=r[1];return 3*(e+t)/4-t}function _byteLength(o,r,e){return 3*(r+e)/4-e}function toByteArray(o){var r,e,t=getLens(o),n=t[0],u=t[1],p=new Arr(_byteLength(o,n,u)),a=0,h=u>0?n-4:n;for(e=0;e>16&255,p[a++]=r>>8&255,p[a++]=255&r;return 2===u&&(r=revLookup[o.charCodeAt(e)]<<2|revLookup[o.charCodeAt(e+1)]>>4,p[a++]=255&r),1===u&&(r=revLookup[o.charCodeAt(e)]<<10|revLookup[o.charCodeAt(e+1)]<<4|revLookup[o.charCodeAt(e+2)]>>2,p[a++]=r>>8&255,p[a++]=255&r),p}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,n=[],u=r;up?p:u+16383));return 1===t?(r=o[e-1],n.push(lookup[r>>2]+lookup[r<<4&63]+"==")):2===t&&(r=(o[e-2]<<8)+o[e-1],n.push(lookup[r>>10]+lookup[r>>4&63]+lookup[r<<2&63]+"=")),n.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63; -},{}],46:[function(require,module,exports){ +},{}],54:[function(require,module,exports){ (function (Buffer){(function (){ "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":101}],47:[function(require,module,exports){ +},{"buffer":117}],55:[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)}}; -},{}],53:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ +(function (Buffer){(function (){ +const varint=require("fast-varint"),{INT:INT,DOUBLE:DOUBLE,STRING:STRING,TAG_SIZE:TAG_SIZE,TAG_MASK:TAG_MASK}=require("./constants"),{createSeekPath:createSeekPath}=require("./seekers");function isNull(e){return 6===e}function isUndefined(e,r){return 14===e&&2===r}function compare(e,r,t,n){if(-1===r||-1===n)return r-n;const a=varint.decode(e,r),o=varint.decode.bytes,i=varint.decode(t,n),c=varint.decode.bytes,u=a&TAG_MASK,d=i&TAG_MASK;return isNull(a)?isNull(i)?0:-1:isNull(i)?1:isUndefined(a,e[r+1])?isUndefined(i,t[n+1])?0:1:isUndefined(i,t[n+1])?-1:u===INT&&d===DOUBLE?e.readInt32LE(r+o)-t.readDoubleLE(n+c):u===DOUBLE&&d===INT?e.readDoubleLE(r+o)-t.readInt32LE(n+c):u!==d?u-d:u===DOUBLE?e.readDoubleLE(r+o)-t.readDoubleLE(n+c):u===INT?e.readInt32LE(r+o)-t.readInt32LE(n+c):e.compare(t,n+c,n+c+(i>>TAG_SIZE),r+o,r+o+(a>>TAG_SIZE))}function compareString(e,r,t){if(-1===r)return null;t=Buffer.isBuffer(t)?t:Buffer.from(t);const n=varint.decode(e,r);if((n&TAG_MASK)!==STRING)return null;const a=n>>TAG_SIZE,o=Math.min(t.length,a);return e.compare(t,0,o,r+varint.decode.bytes,r+varint.decode.bytes+o)||t.length-a}function createCompareAt(e){const r=e.map(createSeekPath);return function(e,t){for(let n=0;n>TAG_SIZE,u=decodeType(d,e,r+(n+=varint.decode.bytes),c);o.push(u),n+=c}return o}function decodeObject(e,r,t){const o={};for(let n=0;n>TAG_SIZE,c=decodeString(e,r+(n+=varint.decode.bytes),d);n+=d;const u=varint.decode(e,r+n),i=u&TAG_MASK;if(7===i)throw new Error("reserved type:value");const s=u>>TAG_SIZE,a=decodeType(i,e,r+(n+=varint.decode.bytes),s);n+=s,o[c]=a}return o}function decodeBoolnull(e,r,t){if(0===t)return null;if(e[r]>2)throw new Error("invalid boolnull");if(t>1)throw new Error("invalid boolnull, length must = 1");return 0!==e[r]&&(1===e[r]||void 0)}function decodeType(e,r,t,o){switch(e){case STRING:return decodeString(r,t,o);case BUFFER:return decodeBuffer(r,t,o);case INT:return decodeInteger(r,t,o);case DOUBLE:return decodeDouble(r,t,o);case ARRAY:return decodeArray(r,t,o);case OBJECT:return decodeObject(r,t,o);case BOOLNULL:return decodeBoolnull(r,t,o);default:throw new Error("unable to decode type="+e+" "+r)}}function decode(e,r){r|=0;const t=varint.decode(e,r),o=t&TAG_MASK,n=t>>TAG_SIZE,d=varint.decode.bytes,c=decodeType(o,e,r+=d,n);return decode.bytes=n+d,c}module.exports={decode:decode}; + +},{"./constants":62,"fast-varint":218}],64:[function(require,module,exports){ +(function (Buffer){(function (){ +const varint=require("fast-varint"),{TAG_SIZE:TAG_SIZE,TAG_MASK:TAG_MASK}=require("./constants"),{STRING:STRING,BUFFER:BUFFER,INT:INT,DOUBLE:DOUBLE,ARRAY:ARRAY,OBJECT:OBJECT,BOOLNULL:BOOLNULL,ALREADY_BIPF:ALREADY_BIPF}=require("./constants"),encoders=[function(n,e,t){return e.write(n,t)},function(n,e,t){return n.copy(e,t,0,n.length),n.length},function(n,e,t){return e.writeInt32LE(n,t),4},function(n,e,t){return e.writeDoubleLE(n,t),8},function(n,e,t){let o=t;for(let t=0;t>TAG_SIZE}function getEncodedType(n,e){return varint.decode(n,e)&TAG_MASK}function allocAndEncode(n){const e=encodingLength(n),t=Buffer.allocUnsafe(e);return encode(n,t,0),t}function allocAndEncodeIdempotent(n){const e=encodingLength(n),t=Buffer.allocUnsafe(e);return encodeIdempotent(n,t,0),t}module.exports={encode:encode,encodeIdempotent:encodeIdempotent,markIdempotent:markIdempotent,isIdempotent:isIdempotent,getType:getType,getEncodedLength:getEncodedLength,getEncodedType:getEncodedType,encodingLength:encodingLength,allocAndEncode:allocAndEncode,allocAndEncodeIdempotent:allocAndEncodeIdempotent}; + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./constants":62,"buffer":117,"fast-varint":218}],65:[function(require,module,exports){ +const varint=require("fast-varint"),{types:types,TAG_SIZE:TAG_SIZE,TAG_MASK:TAG_MASK,STRING:STRING,BUFFER:BUFFER,INT:INT,DOUBLE:DOUBLE,OBJECT:OBJECT,ARRAY:ARRAY,BOOLNULL:BOOLNULL}=require("./constants"),{decode:decode}=require("./decode"),{encode:encode,encodeIdempotent:encodeIdempotent,markIdempotent:markIdempotent,isIdempotent:isIdempotent,encodingLength:encodingLength,allocAndEncode:allocAndEncode,allocAndEncodeIdempotent:allocAndEncodeIdempotent,getEncodedLength:getEncodedLength,getEncodedType:getEncodedType,getType:getType}=require("./encode"),{seekKey:seekKey,seekKey2:seekKey2,seekKeyCached:seekKeyCached,createSeekPath:createSeekPath,seekPath:seekPath}=require("./seekers"),{compareString:compareString,compare:compare,createCompareAt:createCompareAt}=require("./compare");function slice(e,t){const n=varint.decode(e,t)>>TAG_SIZE;return e.slice(t+varint.decode.bytes,t+varint.decode.bytes+n)}function pluck(e,t){const n=varint.decode(e,t)>>TAG_SIZE;return e.slice(t,t+varint.decode.bytes+n)}function iterate(e,t,n){const d=varint.decode(e,t),o=d>>TAG_SIZE,c=d&TAG_MASK;if(c===OBJECT){for(let d=varint.decode.bytes;d>TAG_SIZE),a=varint.decode(e,r),i=varint.decode.bytes+(a>>TAG_SIZE);if(n(e,r,o))return t;d+=i}return t}if(c===ARRAY){let d=0;for(let c=varint.decode.bytes;c>TAG_SIZE)}return t}return-1}module.exports={encode:encode,encodeIdempotent:encodeIdempotent,markIdempotent:markIdempotent,isIdempotent:isIdempotent,decode:decode,allocAndEncode:allocAndEncode,allocAndEncodeIdempotent:allocAndEncodeIdempotent,encodingLength:encodingLength,buffer:!0,slice:slice,pluck:pluck,getValueType:getType,getEncodedLength:getEncodedLength,getEncodedType:getEncodedType,seekKey:seekKey,seekKeyCached:seekKeyCached,seekKey2:seekKey2,createSeekPath:createSeekPath,seekPath:seekPath,compareString:compareString,compare:compare,createCompareAt:createCompareAt,iterate:iterate,types:types}; + +},{"./compare":61,"./constants":62,"./decode":63,"./encode":64,"./seekers":66,"fast-varint":218}],66:[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,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(c,e,r+(o+=varint.decode.bytes),i);t.push(a),o+=i}return t}function decode_object(e,r,n){for(var t={},o=0;o>TAG_SIZE,i=decode_string(e,r+(o+=varint.decode.bytes),c);o+=c;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,s=decode_type(u,e,r+(o+=varint.decode.bytes),f);o+=f,t[i]=s}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)<=2147483647?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);if(void 0===r)throw new Error("unknown type: "+JSON.stringify(e));var 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(void 0===o)throw new Error("unknown type: "+JSON.stringify(e));var d=void 0===t?encodingLengthers[o](e):t;varint.encode(d<>TAG_SIZE,d=varint.decode.bytes,c=decode_type(t,e,r+=d,o);return decode.bytes=o+d,c}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,c=varint.decode.bytes;c>TAG_SIZE;if((i&TAG_MASK)===STRING&&o===a&&0===e.compare(n,0,o,r+c,r+c+o))return r+c+a;c+=a;var u=varint.decode(e,r+c);c+=varint.decode.bytes,c+=u>>TAG_SIZE}return-1}const cache1=new WeakMap;function seekKeyCached(e,r,n){let t=cache1.get(e);t||cache1.set(e,t=new Map);let o=t.get(r);if(o||t.set(r,o=new Map),"string"!=typeof n)throw new Error("seekKeyCached only supports string target");if(o.has(n))return o.get(n);{const t=seekKey(e,r,n);return o.set(n,t),t}}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,c=o>>TAG_SIZE,i=varint.decode(n,t),a=(i>>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,c=varint.decode(n,t),i=varint.decode.bytes,a=o&TAG_MASK,u=c&TAG_MASK;return isNull(o)?isNull(c)?0:-1:isNull(c)?1:isUndefined(o,e[r+1])?isUndefined(c,n[t+1])?0:1:isUndefined(c,n[t+1])?-1:a===INT&&u===DOUBLE?e.readInt32LE(r+d)-n.readDoubleLE(t+i):a===DOUBLE&&u===INT?e.readDoubleLE(r+d)-n.readInt32LE(t+i):a!==u?a-u:a===DOUBLE?e.readDoubleLE(r+d)-n.readDoubleLE(t+i):a===INT?e.readInt32LE(r+d)-n.readInt32LE(t+i):e.compare(n,t+i,t+i+(c>>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 c=varint.decode.bytes;c>TAG_SIZE),f=varint.decode(e,u),s=varint.decode.bytes+(f>>TAG_SIZE);if(n(e,u,i))return r;c+=s}return r}if(d===ARRAY){var v=0;for(c=varint.decode.bytes;c>TAG_SIZE)}return r}return-1}function createCompareAt(e){var r=e.map(createSeekPath);return function(e,n){for(var t=0;t>TAG_SIZE;for(let n=varint.decode.bytes;n>TAG_SIZE;if((a&TAG_MASK)===STRING&&c===o&&0===e.compare(r,0,c,t+n,t+n+c))return t+n+o;n+=o;const s=varint.decode(e,t+n);n+=varint.decode.bytes,n+=s>>TAG_SIZE}return-1}function createSeekPathSrc(e){return'"use strict";\n'+e.map(function(e,t){return" var k"+t+" = Buffer.from("+JSON.stringify(e)+");"}).join("\n")+"\n return function (buffer, start) {\n"+e.map(function(e,t){return" start = seekKey(buffer, start, k"+t+")"}).join("\n")+"\n return start;\n}\n"}function seekKey2(e,t,r,n){const c=varint.decode(e,t);if((c&TAG_MASK)!==OBJECT)return-1;let a=varint.decode.bytes;const o=c>>TAG_SIZE,s=varint.decode(r,n),i=(s>>TAG_SIZE)+varint.decode.bytes;for(;a>TAG_SIZE;const o=varint.decode(e,t+a);a+=varint.decode.bytes,a+=o>>TAG_SIZE}return-1}function seekKeyCached(e,t,r){let n=cache1.get(e);n||cache1.set(e,n=new Map);let c=n.get(t);if(c||n.set(t,c=new Map),"string"!=typeof r)throw new Error("seekKeyCached only supports string target");if(c.has(r))return c.get(r);{const n=seekKey(e,t,r);return c.set(r,n),n}}function seekPath(e,t,r,n){const c=decode(r,n=n||0);if(!Array.isArray(c))throw new Error("path must be encoded array");for(let r=0;r=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+t)}function s(t,i,r){var n=o(t,r);return r-1>=i&&(n|=o(t,r-1)<<4),n}function u(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++,this.negative=1),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,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var n=0;n=i;n-=2)h=s(t,i,n)<=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;else for(n=(t.length-i)%2==0?i+1:i;n=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;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,s=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")]=l}catch(t){h.prototype.inspect=l}else h.prototype.inspect=l;function l(){return(this.red?""}var m=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[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?m[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=f[t],l=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modrn(l).toString(t);n=(p=p.idivn(l)).isZero()?M+n:m[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 p(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,B=S>>>13,q=0|o[6],R=8191&q,Z=q>>>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(B,F)|0,e=Math.imul(B,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(B,D)|0,e=e+Math.imul(B,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(B,G)|0,e=e+Math.imul(B,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(B,W)|0,e=e+Math.imul(B,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(B,$)|0,e=e+Math.imul(B,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(B,rt)|0,e=e+Math.imul(B,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(B,et)|0,e=e+Math.imul(B,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 Bt=(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)+(Bt>>>26)|0,Bt&=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(B,ut)|0,e=e+Math.imul(B,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 qt=(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)+(qt>>>26)|0,qt&=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(B,mt)|0,e=e+Math.imul(B,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(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,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]=Bt,u[12]=qt,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 v(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 g(t,i,r){return v(t,i,r)}function c(t,i){this.x=t,this.y=i}Math.imul||(M=p),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?M(this,t,i):r<63?p(this,t,i):r<1024?v(this,t,i):g(this,t,i)},c.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},c.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 S(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 w={k256:null,p224:null,p192:null,p25519:null};function y(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 b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(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 x(t){S.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)}y.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.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},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.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},b.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(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new _;else if("p192"===t)i=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new A}return w[t]=i,i},S.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},S.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")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.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)},S.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},S.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)},S.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},S.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},S.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.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},S.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},S.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new x(t)},n(x,S),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},x.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)},x.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)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); +},{"./constants":62,"./decode":63,"buffer":117,"fast-varint":218}],67:[function(require,module,exports){ +var __commonJS=(A,I)=>(function(){return I||(0,A[Object.keys(A)[0]])((I={exports:{}}).exports,I),I.exports}),__toBinary=(()=>{for(var A=new Uint8Array(128),I=0;I<64;I++)A[I<26?I+65:I<52?I+71:I<62?I-4:4*I-205]=I;return I=>{for(var C=I.length,g=new Uint8Array(3*(C-("="==I[C-1])-("="==I[C-2]))/4|0),Q=0,i=0;Q>4,g[i++]=E<<4|B>>2,g[i++]=B<<6|D}return g}})(),require_blake2b=__commonJS({"wasm-binary:./blake2b.wat"(A,I){I.exports=__toBinary("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMKvz8EwAIAIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGCAAQgA3AyAgAEIANwMoIABCADcDMCAAQgA3AzggAEIANwNAIABCADcDSCAAQgA3A1AgAEIANwNYIABCADcDYCAAQgA3A2ggAEIANwNwIABCADcDeCAAQoiS853/zPmE6gBBACkDAIU3A4ABIABCu86qptjQ67O7f0EIKQMAhTcDiAEgAEKr8NP0r+68tzxBECkDAIU3A5ABIABC8e30+KWn/aelf0EYKQMAhTcDmAEgAELRhZrv+s+Uh9EAQSApAwCFNwOgASAAQp/Y+dnCkdqCm39BKCkDAIU3A6gBIABC6/qG2r+19sEfQTApAwCFNwOwASAAQvnC+JuRo7Pw2wBBOCkDAIU3A7gBIABCADcDwAEgAEIANwPIASAAQgA3A9ABC20BA38gAEHAAWohAyAAQcgBaiEEIAQpAwCnIQUCQANAIAEgAkYNASAFQYABRgRAIAMgAykDACAFrXw3AwBBACEFIAAQAwsgACAFaiABLQAAOgAAIAVBAWohBSABQQFqIQEMAAsLIAQgBa03AwALYQEDfyAAQcABaiEBIABByAFqIQIgASABKQMAIAIpAwB8NwMAIABCfzcD0AEgAikDAKchAwJAA0AgA0GAAUYNASAAIANqQQA6AAAgA0EBaiEDDAALCyACIAOtNwMAIAAQAwuqOwIgfgl/IABBgAFqISEgAEGIAWohIiAAQZABaiEjIABBmAFqISQgAEGgAWohJSAAQagBaiEmIABBsAFqIScgAEG4AWohKCAhKQMAIQEgIikDACECICMpAwAhAyAkKQMAIQQgJSkDACEFICYpAwAhBiAnKQMAIQcgKCkDACEIQoiS853/zPmE6gAhCUK7zqqm2NDrs7t/IQpCq/DT9K/uvLc8IQtC8e30+KWn/aelfyEMQtGFmu/6z5SH0QAhDUKf2PnZwpHagpt/IQ5C6/qG2r+19sEfIQ9C+cL4m5Gjs/DbACEQIAApAwAhESAAKQMIIRIgACkDECETIAApAxghFCAAKQMgIRUgACkDKCEWIAApAzAhFyAAKQM4IRggACkDQCEZIAApA0ghGiAAKQNQIRsgACkDWCEcIAApA2AhHSAAKQNoIR4gACkDcCEfIAApA3ghICANIAApA8ABhSENIA8gACkD0AGFIQ8gASAFIBF8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSASfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgE3x8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBR8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAVfHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgFnx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBd8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAYfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgGXx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBp8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAbfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgHHx8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIB18fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAefHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgH3x8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFICB8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAffHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgG3x8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBV8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAZfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgGnx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHICB8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAefHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggF3x8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBJ8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiAdfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgEXx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBN8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAcfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggGHx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBZ8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAUfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgHHx8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIBl8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAdfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgEXx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBZ8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByATfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggIHx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIB58fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAbfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgH3x8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBR8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAXfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggGHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBJ8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAafHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFXx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIBh8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSAafHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgFHx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBJ8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAefHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgHXx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBx8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAffHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgE3x8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBd8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAWfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgG3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBV8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCARfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgIHx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBl8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAafHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEXx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBZ8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAYfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgE3x8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBV8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAbfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggIHx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIB98fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiASfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgHHx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIB18fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAXfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggGXx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBR8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAefHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgE3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIB18fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAXfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgG3x8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBF8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAcfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggGXx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBR8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAVfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgHnx8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBh8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAWfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggIHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIB98fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSASfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgGnx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIB18fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSAWfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgEnx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGICB8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAffHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgHnx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBV8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAbfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgEXx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBh8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAXfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgFHx8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBp8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCATfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgGXx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBx8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAefHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgHHx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBh8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAffHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgHXx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBJ8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAUfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggGnx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBZ8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiARfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgIHx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBV8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAZfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggF3x8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBN8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAbfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgF3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFICB8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAffHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgGnx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBx8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAUfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggEXx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBl8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAdfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgE3x8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIB58fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAYfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggEnx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBV8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAbfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFnx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIBt8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSATfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgGXx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBV8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAYfHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgF3x8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBJ8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAWfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgIHx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBx8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAafHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgH3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBR8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAdfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgHnx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBF8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSARfHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEnx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBN8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAUfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgFXx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBZ8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAXfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggGHx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBl8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiAafHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgG3x8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBx8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAdfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggHnx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIB98fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAgfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgH3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIBt8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAVfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgGXx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBp8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAgfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggHnx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBd8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiASfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgHXx8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBF8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByATfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggHHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBh8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAWfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFHx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgISAhKQMAIAEgCYWFNwMAICIgIikDACACIAqFhTcDACAjICMpAwAgAyALhYU3AwAgJCAkKQMAIAQgDIWFNwMAICUgJSkDACAFIA2FhTcDACAmICYpAwAgBiAOhYU3AwAgJyAnKQMAIAcgD4WFNwMAICggKCkDACAIIBCFhTcDAAs=")}}),bytes=require_blake2b(),compiled=WebAssembly.compile(bytes);module.exports=(async A=>{return(await WebAssembly.instantiate(await compiled,A)).exports}); -},{"buffer":57}],55:[function(require,module,exports){ +},{}],68:[function(require,module,exports){ +var assert=require("nanoassert"),b4a=require("b4a"),wasm=null,wasmPromise="undefined"!=typeof WebAssembly&&require("./blake2b")().then(e=>{wasm=e}),head=64,freeList=[];module.exports=Blake2b;var BYTES_MIN=module.exports.BYTES_MIN=16,BYTES_MAX=module.exports.BYTES_MAX=64,BYTES=module.exports.BYTES=32,KEYBYTES_MIN=module.exports.KEYBYTES_MIN=16,KEYBYTES_MAX=module.exports.KEYBYTES_MAX=64,KEYBYTES=module.exports.KEYBYTES=32,SALTBYTES=module.exports.SALTBYTES=16,PERSONALBYTES=module.exports.PERSONALBYTES=16;function Blake2b(e,t,s,r,i){if(!(this instanceof Blake2b))return new Blake2b(e,t,s,r,i);if(!wasm)throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");e||(e=32),!0!==i&&(assert(e>=BYTES_MIN,"digestLength must be at least "+BYTES_MIN+", was given "+e),assert(e<=BYTES_MAX,"digestLength must be at most "+BYTES_MAX+", was given "+e),null!=t&&(assert(t instanceof Uint8Array,"key must be Uint8Array or Buffer"),assert(t.length>=KEYBYTES_MIN,"key must be at least "+KEYBYTES_MIN+", was given "+t.length),assert(t.length<=KEYBYTES_MAX,"key must be at least "+KEYBYTES_MAX+", was given "+t.length)),null!=s&&(assert(s instanceof Uint8Array,"salt must be Uint8Array or Buffer"),assert(s.length===SALTBYTES,"salt must be exactly "+SALTBYTES+", was given "+s.length)),null!=r&&(assert(r instanceof Uint8Array,"personal must be Uint8Array or Buffer"),assert(r.length===PERSONALBYTES,"personal must be exactly "+PERSONALBYTES+", was given "+r.length))),freeList.length||(freeList.push(head),head+=216),this.digestLength=e,this.finalized=!1,this.pointer=freeList.pop(),this._memory=new Uint8Array(wasm.memory.buffer),this._memory.fill(0,0,64),this._memory[0]=this.digestLength,this._memory[1]=t?t.length:0,this._memory[2]=1,this._memory[3]=1,s&&this._memory.set(s,32),r&&this._memory.set(r,48),this.pointer+216>this._memory.length&&this._realloc(this.pointer+216),wasm.blake2b_init(this.pointer,this.digestLength),t&&(this.update(t),this._memory.fill(0,head,head+t.length),this._memory[this.pointer+200]=128)}function noop(){}Blake2b.prototype._realloc=function(e){wasm.memory.grow(Math.max(0,Math.ceil(Math.abs(e-this._memory.length)/65536))),this._memory=new Uint8Array(wasm.memory.buffer)},Blake2b.prototype.update=function(e){return assert(!1===this.finalized,"Hash instance finalized"),assert(e instanceof Uint8Array,"input must be Uint8Array or Buffer"),head+e.length>this._memory.length&&this._realloc(head+e.length),this._memory.set(e,head),wasm.blake2b_update(this.pointer,head,head+e.length),this},Blake2b.prototype.digest=function(e){if(assert(!1===this.finalized,"Hash instance finalized"),this.finalized=!0,freeList.push(this.pointer),wasm.blake2b_final(this.pointer),!e||"binary"===e)return this._memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if("string"==typeof e)return b4a.toString(this._memory,e,this.pointer+128,this.pointer+128+this.digestLength);assert(e instanceof Uint8Array&&e.length>=this.digestLength,"input must be Uint8Array or Buffer");for(var t=0;te(),e):e(new Error("WebAssembly not supported"))},Blake2b.prototype.ready=Blake2b.ready,Blake2b.prototype.getPartialHash=function(){return this._memory.slice(this.pointer,this.pointer+216)},Blake2b.prototype.setPartialHash=function(e){this._memory.set(e,this.pointer)}; + +},{"./blake2b":67,"b4a":46,"nanoassert":395}],69:[function(require,module,exports){ +var assert=require("nanoassert"),b2wasm=require("blake2b-wasm");function ADD64AA(e,t,r){var a=e[t]+e[r],n=e[t+1]+e[r+1];a>=4294967296&&n++,e[t]=a,e[t+1]=n}function ADD64AC(e,t,r,a){var n=e[t]+r;r<0&&(n+=4294967296);var o=e[t+1]+a;n>=4294967296&&o++,e[t]=n,e[t+1]=o}function B2B_GET32(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function B2B_G(e,t,r,a,n,o){var s=m[n],A=m[n+1],l=m[o],i=m[o+1];ADD64AA(v,e,t),ADD64AC(v,e,s,A);var u=v[a]^v[e],B=v[a+1]^v[e+1];v[a]=B,v[a+1]=u,ADD64AA(v,r,a),u=v[t]^v[r],B=v[t+1]^v[r+1],v[t]=u>>>24^B<<8,v[t+1]=B>>>24^u<<8,ADD64AA(v,e,t),ADD64AC(v,e,l,i),u=v[a]^v[e],B=v[a+1]^v[e+1],v[a]=u>>>16^B<<16,v[a+1]=B>>>16^u<<16,ADD64AA(v,r,a),u=v[t]^v[r],B=v[t+1]^v[r+1],v[t]=B>>>31^u<<1,v[t+1]=u>>>31^B<<1}var BLAKE2B_IV32=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),SIGMA8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],SIGMA82=new Uint8Array(SIGMA8.map(function(e){return 2*e})),v=new Uint32Array(32),m=new Uint32Array(32);function blake2bCompress(e,t){var r=0;for(r=0;r<16;r++)v[r]=e.h[r],v[r+16]=BLAKE2B_IV32[r];for(v[24]=v[24]^e.t,v[25]=v[25]^e.t/4294967296,t&&(v[28]=~v[28],v[29]=~v[29]),r=0;r<32;r++)m[r]=B2B_GET32(e.b,4*r);for(r=0;r<12;r++)B2B_G(0,8,16,24,SIGMA82[16*r+0],SIGMA82[16*r+1]),B2B_G(2,10,18,26,SIGMA82[16*r+2],SIGMA82[16*r+3]),B2B_G(4,12,20,28,SIGMA82[16*r+4],SIGMA82[16*r+5]),B2B_G(6,14,22,30,SIGMA82[16*r+6],SIGMA82[16*r+7]),B2B_G(0,10,20,30,SIGMA82[16*r+8],SIGMA82[16*r+9]),B2B_G(2,12,22,24,SIGMA82[16*r+10],SIGMA82[16*r+11]),B2B_G(4,14,16,26,SIGMA82[16*r+12],SIGMA82[16*r+13]),B2B_G(6,8,18,28,SIGMA82[16*r+14],SIGMA82[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^v[r]^v[r+16]}var parameter_block=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function Blake2b(e,t,r,a){parameter_block.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=e,parameter_block[0]=e,t&&(parameter_block[1]=t.length),parameter_block[2]=1,parameter_block[3]=1,r&¶meter_block.set(r,32),a&¶meter_block.set(a,48);for(var n=0;n<16;n++)this.h[n]=BLAKE2B_IV32[n]^B2B_GET32(parameter_block,4*n);t&&(blake2bUpdate(this,t),this.c=128)}function blake2bUpdate(e,t){for(var r=0;r>2]>>8*(3&r);return t}function hexSlice(e){for(var t="",r=0;r=this.outlen,"out must have at least outlen bytes of space"),blake2bFinal(this,t),"hex"===e?hexSlice(t):t},Blake2b.prototype.final=Blake2b.prototype.digest,Blake2b.ready=function(e){b2wasm.ready(function(){e()})};var Proto=Blake2b;module.exports=function(e,t,r,a,n){return!0!==n&&(assert(e>=BYTES_MIN,"outlen must be at least "+BYTES_MIN+", was given "+e),assert(e<=BYTES_MAX,"outlen must be at most "+BYTES_MAX+", was given "+e),null!=t&&(assert(t instanceof Uint8Array,"key must be Uint8Array or Buffer"),assert(t.length>=KEYBYTES_MIN,"key must be at least "+KEYBYTES_MIN+", was given "+t.length),assert(t.length<=KEYBYTES_MAX,"key must be at most "+KEYBYTES_MAX+", was given "+t.length)),null!=r&&(assert(r instanceof Uint8Array,"salt must be Uint8Array or Buffer"),assert(r.length===SALTBYTES,"salt must be exactly "+SALTBYTES+", was given "+r.length)),null!=a&&(assert(a instanceof Uint8Array,"personal must be Uint8Array or Buffer"),assert(a.length===PERSONALBYTES,"personal must be exactly "+PERSONALBYTES+", was given "+a.length))),new Proto(e,t,r,a)},module.exports.ready=function(e){b2wasm.ready(function(){e()})},module.exports.WASM_SUPPORTED=b2wasm.SUPPORTED,module.exports.WASM_LOADED=!1;var BYTES_MIN=module.exports.BYTES_MIN=16,BYTES_MAX=module.exports.BYTES_MAX=64,BYTES=module.exports.BYTES=32,KEYBYTES_MIN=module.exports.KEYBYTES_MIN=16,KEYBYTES_MAX=module.exports.KEYBYTES_MAX=64,KEYBYTES=module.exports.KEYBYTES=32,SALTBYTES=module.exports.SALTBYTES=16,PERSONALBYTES=module.exports.PERSONALBYTES=16;b2wasm.ready(function(e){e||(module.exports.WASM_LOADED=!0,module.exports=b2wasm)}); + +},{"blake2b-wasm":68,"nanoassert":395}],70:[function(require,module,exports){ +!function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function h(t,i,r){if(h.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=h:i.BN=h,h.BN=h,h.wordSize=26;try{e="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function o(t,i){var n=t.charCodeAt(i);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+t)}function s(t,i,r){var n=o(t,r);return r-1>=i&&(n|=o(t,r-1)<<4),n}function u(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++,this.negative=1),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,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var n=0;n=i;n-=2)h=s(t,i,n)<=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;else for(n=(t.length-i)%2==0?i+1:i;n=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;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,s=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")]=l}catch(t){h.prototype.inspect=l}else h.prototype.inspect=l;function l(){return(this.red?""}var m=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[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,(h+=2)>=26&&(h-=26,o--),n=0!==e||o!==this.length-1?m[6-u.length]+u+n:u+n}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=f[t],l=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modrn(l).toString(t);n=(p=p.idivn(l)).isZero()?M+n:m[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 p(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,B=S>>>13,q=0|o[6],R=8191&q,Z=q>>>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(B,F)|0,e=Math.imul(B,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(B,D)|0,e=e+Math.imul(B,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(B,G)|0,e=e+Math.imul(B,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(B,W)|0,e=e+Math.imul(B,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(B,$)|0,e=e+Math.imul(B,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(B,rt)|0,e=e+Math.imul(B,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(B,et)|0,e=e+Math.imul(B,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 Bt=(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)+(Bt>>>26)|0,Bt&=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(B,ut)|0,e=e+Math.imul(B,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 qt=(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)+(qt>>>26)|0,qt&=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(B,mt)|0,e=e+Math.imul(B,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(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,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]=Bt,u[12]=qt,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 v(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 g(t,i,r){return v(t,i,r)}function c(t,i){this.x=t,this.y=i}Math.imul||(M=p),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?M(this,t,i):r<63?p(this,t,i):r<1024?v(this,t,i):g(this,t,i)},c.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},c.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 S(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 w={k256:null,p224:null,p192:null,p25519:null};function y(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 b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(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 x(t){S.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)}y.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.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},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.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},b.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(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new _;else if("p192"===t)i=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new A}return w[t]=i,i},S.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},S.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")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.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)},S.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},S.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)},S.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},S.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},S.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.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},S.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},S.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new x(t)},n(x,S),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},x.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)},x.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)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); + +},{"buffer":73}],71:[function(require,module,exports){ var concatMap=require("concat-map"),balanced=require("balanced-match");module.exports=expandTop;var escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function escapeBraces(e){return e.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(e){return e.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(e){if(!e)return[""];var n=[],t=balanced("{","}",e);if(!t)return e.split(",");var r=t.pre,a=t.body,s=t.post,o=r.split(",");o[o.length-1]+="{"+a+"}";var i=parseCommaParts(s);return s.length&&(o[o.length-1]+=i.shift(),o.push.apply(o,i)),n.push.apply(n,o),n}function expandTop(e){return e?("{}"===e.substr(0,2)&&(e="\\{\\}"+e.substr(2)),expand(escapeBraces(e),!0).map(unescapeBraces)):[]}function identity(e){return e}function embrace(e){return"{"+e+"}"}function isPadded(e){return/^-?0\d/.test(e)}function lte(e,n){return e<=n}function gte(e,n){return e>=n}function expand(e,n){var t=[],r=balanced("{","}",e);if(!r||/\$$/.test(r.pre))return[e];var a,s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),o=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),i=s||o,p=r.body.indexOf(",")>=0;if(!i&&!p)return r.post.match(/,.*\}/)?expand(e=r.pre+"{"+r.body+escClose+r.post):[e];if(i)a=r.body.split(/\.\./);else if(1===(a=parseCommaParts(r.body)).length&&1===(a=expand(a[0],!1).map(embrace)).length)return(u=r.post.length?expand(r.post,!1):[""]).map(function(e){return r.pre+a[0]+e});var c,l=r.pre,u=r.post.length?expand(r.post,!1):[""];if(i){var d=numeric(a[0]),m=numeric(a[1]),h=Math.max(a[0].length,a[1].length),f=3==a.length?Math.abs(numeric(a[2])):1,g=lte;m0){var j=new Array(x+1).join("0");C=b<0?"-"+j+C.slice(1):j+C}}c.push(C)}}else c=concatMap(a,function(e){return expand(e,!1)});for(var y=0;y>>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":527}],59:[function(require,module,exports){ +},{"safe-buffer":585}],75:[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":58,"./authCipher":59,"./modes":71,"./streamCipher":74,"cipher-base":111,"evp_bytestokey":182,"inherits":251,"safe-buffer":527}],62:[function(require,module,exports){ +},{"./aes":74,"./authCipher":75,"./modes":87,"./streamCipher":90,"cipher-base":131,"evp_bytestokey":215,"inherits":293,"safe-buffer":585}],78:[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":527}],64:[function(require,module,exports){ +},{"safe-buffer":585}],80:[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; -},{}],65:[function(require,module,exports){ +},{}],81:[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":106}],66:[function(require,module,exports){ +},{"buffer-xor":122}],82:[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":106,"safe-buffer":527}],67:[function(require,module,exports){ +},{"buffer-xor":122,"safe-buffer":585}],83:[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":54,"buffer":101,"randombytes":518}],79:[function(require,module,exports){ +},{"bn.js":70,"buffer":117,"randombytes":576}],95:[function(require,module,exports){ module.exports=require("./browser/algorithms.json"); -},{"./browser/algorithms.json":80}],80:[function(require,module,exports){ +},{"./browser/algorithms.json":96}],96:[function(require,module,exports){ module.exports={ "sha224WithRSAEncryption": { "sign": "rsa", @@ -610,7 +664,7 @@ module.exports={ } } -},{}],81:[function(require,module,exports){ +},{}],97:[function(require,module,exports){ module.exports={ "1.3.132.0.10": "secp256k1", "1.3.132.0.33": "p224", @@ -620,236 +674,248 @@ module.exports={ "1.3.132.0.35": "p521" } -},{}],82:[function(require,module,exports){ +},{}],98:[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":80,"./sign":83,"./verify":84,"create-hash":121,"inherits":251,"readable-stream":99,"safe-buffer":527}],83:[function(require,module,exports){ +},{"./algorithms.json":96,"./sign":99,"./verify":100,"create-hash":141,"inherits":293,"readable-stream":115,"safe-buffer":585}],99:[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":81,"bn.js":54,"elliptic":152,"parse-asn1":372,"safe-buffer":527}],85:[function(require,module,exports){ +},{"./curves.json":97,"bn.js":70,"elliptic":172,"parse-asn1":422,"safe-buffer":585}],101:[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; -},{}],86:[function(require,module,exports){ +},{}],102:[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":85,"./_stream_duplex":86,"./internal/streams/destroy":93,"./internal/streams/state":97,"./internal/streams/stream":98,"_process":391,"buffer":101,"inherits":251,"util-deprecate":688}],91:[function(require,module,exports){ +},{"../errors":101,"./_stream_duplex":102,"./internal/streams/destroy":109,"./internal/streams/state":113,"./internal/streams/stream":114,"_process":447,"buffer":117,"inherits":293,"util-deprecate":826}],107:[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":94,"_process":391}],92:[function(require,module,exports){ +},{"./end-of-stream":110,"_process":447}],108:[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":101,"util":57}],93:[function(require,module,exports){ +},{"buffer":117,"util":73}],109:[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":391}],94:[function(require,module,exports){ +},{"_process":447}],110:[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":85,"./end-of-stream":94}],97:[function(require,module,exports){ +},{"../../../errors":101,"./end-of-stream":110}],113:[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":85}],98:[function(require,module,exports){ +},{"../../../errors":101}],114:[function(require,module,exports){ module.exports=require("events").EventEmitter; -},{"events":181}],99:[function(require,module,exports){ +},{"events":214}],115:[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":86,"./lib/_stream_passthrough.js":87,"./lib/_stream_readable.js":88,"./lib/_stream_transform.js":89,"./lib/_stream_writable.js":90,"./lib/internal/streams/end-of-stream.js":94,"./lib/internal/streams/pipeline.js":96}],100:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":102,"./lib/_stream_passthrough.js":103,"./lib/_stream_readable.js":104,"./lib/_stream_transform.js":105,"./lib/_stream_writable.js":106,"./lib/internal/streams/end-of-stream.js":110,"./lib/internal/streams/pipeline.js":112}],116:[function(require,module,exports){ -},{}],101:[function(require,module,exports){ +},{}],117:[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":45,"buffer":101,"ieee754":242}],102:[function(require,module,exports){ +},{"base64-js":53,"buffer":117,"ieee754":284}],118:[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":101}],103:[function(require,module,exports){ +},{"buffer":117}],119:[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":101,"buffer-alloc-unsafe":102,"buffer-fill":104}],104:[function(require,module,exports){ +},{"buffer":117,"buffer-alloc-unsafe":118,"buffer-fill":120}],120:[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":101}],105:[function(require,module,exports){ +},{"buffer":117}],121:[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":101}],106:[function(require,module,exports){ +},{"buffer":117}],122:[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}; -},{"./":109,"get-intrinsic":197}],109:[function(require,module,exports){ +},{"./":125,"get-intrinsic":238}],125:[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":196,"get-intrinsic":197}],110:[function(require,module,exports){ +},{"function-bind":233,"get-intrinsic":238}],126:[function(require,module,exports){ +const assert=require("nanoassert");module.exports=Chacha20;const constant=[1634760805,857760878,2036477234,1797285236];function Chacha20(t,e,s){assert(32===e.byteLength),assert(8===t.byteLength||12===t.byteLength);const n=new Uint32Array(t.buffer,t.byteOffset,t.byteLength/4),a=new Uint32Array(e.buffer,e.byteOffset,e.byteLength/4);s||(s=0),assert(s>32,this.state[14]=n[0],this.state[15]=n[1]):(this.state[13]=n[0],this.state[14]=n[1],this.state[15]=n[2]),this}function chacha20Block(t){const e=new Uint32Array(16);for(let s=16;s--;)e[s]=t[s];for(let t=0;t<20;t+=2)QR(e,0,4,8,12),QR(e,1,5,9,13),QR(e,2,6,10,14),QR(e,3,7,11,15),QR(e,0,5,10,15),QR(e,1,6,11,12),QR(e,2,7,8,13),QR(e,3,4,9,14);for(let s=0;s<16;s++)e[s]+=t[s];return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function rotl(t,e){return t<>>32-e}function QR(t,e,s,n,a){t[e]+=t[s],t[a]^=t[e],t[a]=rotl(t[a],16),t[n]+=t[a],t[s]^=t[n],t[s]=rotl(t[s],12),t[e]+=t[s],t[a]^=t[e],t[a]=rotl(t[a],8),t[n]+=t[a],t[s]^=t[n],t[s]=rotl(t[s],7)}Chacha20.prototype.update=function(t,e){assert(!this.finalized,"cipher finalized."),assert(t.byteLength>=e.byteLength,"output cannot be shorter than input.");let s=e.length,n=this.pos%64;this.pos+=s;let a=0,r=chacha20Block(this.state);for(;n>0&&s>0;)t[a]=e[a++]^r[n],(n=n+1&63)||this.state[12]++,s--;for(;s>0;){if(r=chacha20Block(this.state),s<64){for(let h=0;h0?"F"+i:"D"+flip(i)},exports.decode=function(r){if("DaN"===r)return NaN;if("FF"===r)return 1/0;if("DD"===r)return-1/0;var t="D"===r[0],e=(t?flip(r):r).slice(2).split("M");return Number((t?"-":"")+e[1]+"e"+String(Number(e[0])-500))}; + +},{}],128:[function(require,module,exports){ +var dictEscape={"?":"?@","!":"??",'"':"?%"};function escape(r){return/[!"]/.test(r)?r.replace(/[\?!"]/g,function(r){return dictEscape[r]}):r}var dictUnescape={"?@":"?","??":"!","?%":'"'};function unescape(r){return/\?[%\?@]/.test(r)?r.replace(/\?[%\?@]/g,function(r){return dictUnescape[r]}):r}exports.factory=function(r){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,t=e.split('"'),c=[[]],o=0,u=t.length,a=0;a>>8}return-1^f});exports.default=crc32; -},{"./create_buffer":117,"./define_crc":118,"buffer":101}],117:[function(require,module,exports){ +},{"./create_buffer":137,"./define_crc":138,"buffer":117}],137:[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":101}],118:[function(require,module,exports){ +},{"buffer":117}],138:[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}; -},{}],119:[function(require,module,exports){ +},{}],139:[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=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,i,r){var n=o(t,r);return r-1>=i&&(n|=o(t,r-1)<<4),n}function u(t,i,r,n){for(var h=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return h}h.isBN=function(t){return t instanceof h||null!==t&&"object"==typeof t&&t.constructor.wordSize===h.wordSize&&Array.isArray(t.words)},h.max=function(t,i){return t.cmp(i)>0?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++,this.negative=1),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,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var n=0;n=i;n-=2)h=s(t,i,n)<=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;else for(n=(t.length-i)%2==0?i+1:i;n=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;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,s=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},h.prototype.inspect=function(){return(this.red?""};var a=["","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"],l=[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],m=[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 f(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.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?a[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 f=l[t],d=m[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?M+n:a[f-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)},h.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},h.prototype.toArrayLike=function(t,i,n){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"),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},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,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],B=8191&q,R=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,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,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,F),h=(h=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(n=n+Math.imul(m,H)|0)|0)+((8191&(h=(h=h+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(h>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,F),h=(h=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),n=n+Math.imul(p,H)|0,h=(h=h+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|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,C))+Math.imul(b,F)|0,e=Math.imul(b,C),n=n+Math.imul(g,H)|0,h=(h=h+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|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,C))+Math.imul(A,F)|0,e=Math.imul(A,C),n=n+Math.imul(y,H)|0,h=(h=h+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|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(S,F),h=(h=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),n=n+Math.imul(k,H)|0,h=(h=h+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|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(B,F),h=(h=Math.imul(B,C))+Math.imul(R,F)|0,e=Math.imul(R,C),n=n+Math.imul(S,H)|0,h=(h=h+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|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(L,F),h=(h=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),n=n+Math.imul(B,H)|0,h=(h=h+Math.imul(B,J)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,J)|0,n=n+Math.imul(S,G)|0,h=(h=h+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,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(T,F),h=(h=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),n=n+Math.imul(L,H)|0,h=(h=h+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,n=n+Math.imul(B,G)|0,h=(h=h+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,n=n+Math.imul(S,W)|0,h=(h=h+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,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,C))+Math.imul(K,F)|0,e=Math.imul(K,C),n=n+Math.imul(T,H)|0,h=(h=h+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,n=n+Math.imul(L,G)|0,h=(h=h+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,n=n+Math.imul(B,W)|0,h=(h=h+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,n=n+Math.imul(S,$)|0,h=(h=h+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,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 xt=(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)+(xt>>>26)|0,xt&=67108863,n=Math.imul(j,H),h=(h=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),n=n+Math.imul(T,G)|0,h=(h=h+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,n=n+Math.imul(L,W)|0,h=(h=h+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,n=n+Math.imul(B,$)|0,h=(h=h+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,n=n+Math.imul(S,rt)|0,h=(h=h+Math.imul(S,nt)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,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 St=(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)+(St>>>26)|0,St&=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(T,W)|0,h=(h=h+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,n=n+Math.imul(L,$)|0,h=(h=h+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,n=n+Math.imul(B,rt)|0,h=(h=h+Math.imul(B,nt)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,nt)|0,n=n+Math.imul(S,et)|0,h=(h=h+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,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 Zt=(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)+(Zt>>>26)|0,Zt&=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(T,$)|0,h=(h=h+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,n=n+Math.imul(L,rt)|0,h=(h=h+Math.imul(L,nt)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,nt)|0,n=n+Math.imul(B,et)|0,h=(h=h+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,n=n+Math.imul(S,ut)|0,h=(h=h+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,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 qt=(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)+(qt>>>26)|0,qt&=67108863,n=Math.imul(j,$),h=(h=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),n=n+Math.imul(T,rt)|0,h=(h=h+Math.imul(T,nt)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,nt)|0,n=n+Math.imul(L,et)|0,h=(h=h+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,n=n+Math.imul(B,ut)|0,h=(h=h+Math.imul(B,at)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,at)|0,n=n+Math.imul(S,mt)|0,h=(h=h+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Bt=(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)+(Bt>>>26)|0,Bt&=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(T,et)|0,h=(h=h+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,n=n+Math.imul(L,ut)|0,h=(h=h+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,n=n+Math.imul(B,mt)|0,h=(h=h+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(a+(n=n+Math.imul(S,pt)|0)|0)+((8191&(h=(h=h+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(h>>>13)|0)+(Rt>>>26)|0,Rt&=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(T,ut)|0,h=(h=h+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,n=n+Math.imul(L,mt)|0,h=(h=h+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(n=n+Math.imul(B,pt)|0)|0)+((8191&(h=(h=h+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;a=((e=e+Math.imul(R,Mt)|0)+(h>>>13)|0)+(Nt>>>26)|0,Nt&=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(T,mt)|0,h=(h=h+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(n=n+Math.imul(L,pt)|0)|0)+((8191&(h=(h=h+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(h>>>13)|0)+(Lt>>>26)|0,Lt&=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(T,pt)|0)|0)+((8191&(h=(h=h+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(h>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(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)+(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]=Bt,u[14]=Rt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function p(t,i,r){return(new M).mulp(t,i,r)}function M(t,i){this.x=t,this.y=i}Math.imul||(d=f),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):r<63?f(this,t,i):r<1024?function(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()}(this,t,i):p(this,t,i)},M.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},M.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,i+=h/67108864|0,i+=e>>>26,this.words[n]=67108863&e}return 0!==i&&(this.words[n]=i,this.length++),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}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.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modn(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.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,n=0,h=this.length-1;h>=0;h--)n=(i*n+(0|this.words[h]))%t;return n},h.prototype.idivn=function(t){r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var h=(0|this.words[n])+67108864*i;this.words[n]=h/t|0,i=h%t}return this.strip()},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 _(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 v={k256:null,p224:null,p192:null,p25519:null};function g(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 c(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function y(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(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 k(t){_.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)}g.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.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},g.prototype.split=function(t,i){t.iushrn(this.n,0,i)},g.prototype.imulK=function(t){return t.imul(this.k)},n(c,g),c.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},c.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(v[t])return v[t];var i;if("k256"===t)i=new c;else if("p224"===t)i=new w;else if("p192"===t)i=new y;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new b}return v[t]=i,i},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.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")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.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)},_.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},_.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)},_.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},_.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},_.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.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},_.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},_.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new k(t)},n(k,_),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},k.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)},k.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)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":57}],121:[function(require,module,exports){ +},{"buffer":73}],141:[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":111,"inherits":251,"md5.js":311,"ripemd160":526,"sha.js":544}],122:[function(require,module,exports){ +},{"cipher-base":131,"inherits":293,"md5.js":361,"ripemd160":584,"sha.js":602}],142:[function(require,module,exports){ var MD5=require("md5.js");module.exports=function(e){return(new MD5).update(e).digest()}; -},{"md5.js":311}],123:[function(require,module,exports){ +},{"md5.js":361}],143:[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":527}],126:[function(require,module,exports){ +},{"safe-buffer":585}],146:[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":127,"./sha1":128,"./sha224":129,"./sha256":130,"./sha384":131,"./sha512":132}],127:[function(require,module,exports){ +},{"./sha":147,"./sha1":148,"./sha224":149,"./sha256":150,"./sha384":151,"./sha512":152}],147:[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":125,"inherits":251,"safe-buffer":527}],128:[function(require,module,exports){ +},{"./hash":145,"inherits":293,"safe-buffer":585}],148:[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":125,"inherits":251,"safe-buffer":527}],129:[function(require,module,exports){ +},{"./hash":145,"inherits":293,"safe-buffer":585}],149:[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":125,"./sha256":130,"inherits":251,"safe-buffer":527}],130:[function(require,module,exports){ +},{"./hash":145,"./sha256":150,"inherits":293,"safe-buffer":585}],150:[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":125,"inherits":251,"safe-buffer":527}],131:[function(require,module,exports){ +},{"./hash":145,"inherits":293,"safe-buffer":585}],151:[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":125,"./sha512":132,"inherits":251,"safe-buffer":527}],132:[function(require,module,exports){ +},{"./hash":145,"./sha512":152,"inherits":293,"safe-buffer":585}],152:[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":125,"inherits":251,"safe-buffer":527}],133:[function(require,module,exports){ +},{"./hash":145,"inherits":293,"safe-buffer":585}],153:[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":75,"browserify-sign":82,"browserify-sign/algos":79,"create-ecdh":119,"create-hash":121,"create-hmac":123,"diffie-hellman":145,"pbkdf2":375,"public-encrypt":396,"randombytes":518,"randomfill":519}],134:[function(require,module,exports){ +},{"browserify-cipher":91,"browserify-sign":98,"browserify-sign/algos":95,"create-ecdh":139,"create-hash":141,"create-hmac":143,"diffie-hellman":165,"pbkdf2":425,"public-encrypt":452,"randombytes":576,"randomfill":577}],154:[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":135,"_process":391}],135:[function(require,module,exports){ +},{"./common":155,"_process":447}],155:[function(require,module,exports){ function setup(e){function n(e){let r,s,o,l=null;function a(...e){if(!a.enabled)return;const t=a,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let l=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if("%%"===r)return"%";l++;const o=n.formatters[s];if("function"==typeof o){const n=e[l];r=o.call(t,n),e.splice(l,1),l--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return a.namespace=e,a.useColors=n.useColors(),a.color=n.selectColor(e),a.extend=t,a.destroy=n.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==l?l:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{l=e}}),"function"==typeof n.init&&n.init(a),a}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;n2?arguments[2]:{},t=keys(r);hasSymbols&&(t=concat.call(t,Object.getOwnPropertySymbols(r)));for(var s=0;s0;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":141,"./utils":144,"inherits":251,"minimalistic-assert":314}],143:[function(require,module,exports){ +},{"./cipher":161,"./utils":164,"inherits":293,"minimalistic-assert":364}],163:[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":141,"./des":142,"inherits":251,"minimalistic-assert":314}],144:[function(require,module,exports){ +},{"./cipher":161,"./des":162,"inherits":293,"minimalistic-assert":364}],164:[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":149,"miller-rabin":312,"randombytes":518}],148:[function(require,module,exports){ +},{"bn.js":169,"miller-rabin":362,"randombytes":576}],168:[function(require,module,exports){ module.exports={ "modp1": { "gen": "02", @@ -884,64 +950,64 @@ module.exports={ "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" } } -},{}],149:[function(require,module,exports){ +},{}],169:[function(require,module,exports){ !function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function h(t,i,r){if(h.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=h:i.BN=h,h.BN=h,h.wordSize=26;try{e="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function o(t,i){var r=t.charCodeAt(i);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,i,r){var n=o(t,r);return r-1>=i&&(n|=o(t,r-1)<<4),n}function u(t,i,r,n){for(var h=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return h}h.isBN=function(t){return t instanceof h||null!==t&&"object"==typeof t&&t.constructor.wordSize===h.wordSize&&Array.isArray(t.words)},h.max=function(t,i){return t.cmp(i)>0?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++,this.negative=1),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,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var n=0;n=i;n-=2)h=s(t,i,n)<=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;else for(n=(t.length-i)%2==0?i+1:i;n=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;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,s=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},h.prototype.inspect=function(){return(this.red?""};var a=["","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"],l=[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],m=[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 f(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.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?a[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 f=l[t],d=m[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?M+n:a[f-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)},h.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},h.prototype.toArrayLike=function(t,i,n){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"),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},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,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],B=8191&q,R=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,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,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,F),h=(h=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(n=n+Math.imul(m,H)|0)|0)+((8191&(h=(h=h+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(h>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,F),h=(h=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),n=n+Math.imul(p,H)|0,h=(h=h+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|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,C))+Math.imul(b,F)|0,e=Math.imul(b,C),n=n+Math.imul(g,H)|0,h=(h=h+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|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,C))+Math.imul(A,F)|0,e=Math.imul(A,C),n=n+Math.imul(y,H)|0,h=(h=h+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|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(S,F),h=(h=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),n=n+Math.imul(k,H)|0,h=(h=h+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|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(B,F),h=(h=Math.imul(B,C))+Math.imul(R,F)|0,e=Math.imul(R,C),n=n+Math.imul(S,H)|0,h=(h=h+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|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(L,F),h=(h=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),n=n+Math.imul(B,H)|0,h=(h=h+Math.imul(B,J)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,J)|0,n=n+Math.imul(S,G)|0,h=(h=h+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,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(T,F),h=(h=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),n=n+Math.imul(L,H)|0,h=(h=h+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,n=n+Math.imul(B,G)|0,h=(h=h+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,n=n+Math.imul(S,W)|0,h=(h=h+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,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,C))+Math.imul(K,F)|0,e=Math.imul(K,C),n=n+Math.imul(T,H)|0,h=(h=h+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,n=n+Math.imul(L,G)|0,h=(h=h+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,n=n+Math.imul(B,W)|0,h=(h=h+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,n=n+Math.imul(S,$)|0,h=(h=h+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,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 xt=(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)+(xt>>>26)|0,xt&=67108863,n=Math.imul(j,H),h=(h=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),n=n+Math.imul(T,G)|0,h=(h=h+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,n=n+Math.imul(L,W)|0,h=(h=h+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,n=n+Math.imul(B,$)|0,h=(h=h+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,n=n+Math.imul(S,rt)|0,h=(h=h+Math.imul(S,nt)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,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 St=(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)+(St>>>26)|0,St&=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(T,W)|0,h=(h=h+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,n=n+Math.imul(L,$)|0,h=(h=h+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,n=n+Math.imul(B,rt)|0,h=(h=h+Math.imul(B,nt)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,nt)|0,n=n+Math.imul(S,et)|0,h=(h=h+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,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 Zt=(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)+(Zt>>>26)|0,Zt&=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(T,$)|0,h=(h=h+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,n=n+Math.imul(L,rt)|0,h=(h=h+Math.imul(L,nt)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,nt)|0,n=n+Math.imul(B,et)|0,h=(h=h+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,n=n+Math.imul(S,ut)|0,h=(h=h+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,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 qt=(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)+(qt>>>26)|0,qt&=67108863,n=Math.imul(j,$),h=(h=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),n=n+Math.imul(T,rt)|0,h=(h=h+Math.imul(T,nt)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,nt)|0,n=n+Math.imul(L,et)|0,h=(h=h+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,n=n+Math.imul(B,ut)|0,h=(h=h+Math.imul(B,at)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,at)|0,n=n+Math.imul(S,mt)|0,h=(h=h+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Bt=(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)+(Bt>>>26)|0,Bt&=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(T,et)|0,h=(h=h+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,n=n+Math.imul(L,ut)|0,h=(h=h+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,n=n+Math.imul(B,mt)|0,h=(h=h+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(a+(n=n+Math.imul(S,pt)|0)|0)+((8191&(h=(h=h+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(h>>>13)|0)+(Rt>>>26)|0,Rt&=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(T,ut)|0,h=(h=h+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,n=n+Math.imul(L,mt)|0,h=(h=h+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(n=n+Math.imul(B,pt)|0)|0)+((8191&(h=(h=h+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;a=((e=e+Math.imul(R,Mt)|0)+(h>>>13)|0)+(Nt>>>26)|0,Nt&=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(T,mt)|0,h=(h=h+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(n=n+Math.imul(L,pt)|0)|0)+((8191&(h=(h=h+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(h>>>13)|0)+(Lt>>>26)|0,Lt&=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(T,pt)|0)|0)+((8191&(h=(h=h+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(h>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(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)+(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]=Bt,u[14]=Rt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function p(t,i,r){return(new M).mulp(t,i,r)}function M(t,i){this.x=t,this.y=i}Math.imul||(d=f),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):r<63?f(this,t,i):r<1024?function(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()}(this,t,i):p(this,t,i)},M.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},M.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,i+=h/67108864|0,i+=e>>>26,this.words[n]=67108863&e}return 0!==i&&(this.words[n]=i,this.length++),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}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.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modn(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.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,n=0,h=this.length-1;h>=0;h--)n=(i*n+(0|this.words[h]))%t;return n},h.prototype.idivn=function(t){r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var h=(0|this.words[n])+67108864*i;this.words[n]=h/t|0,i=h%t}return this.strip()},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 _(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 v={k256:null,p224:null,p192:null,p25519:null};function g(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 c(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function y(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(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 k(t){_.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)}g.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.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},g.prototype.split=function(t,i){t.iushrn(this.n,0,i)},g.prototype.imulK=function(t){return t.imul(this.k)},n(c,g),c.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},c.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(v[t])return v[t];var i;if("k256"===t)i=new c;else if("p224"===t)i=new w;else if("p192"===t)i=new y;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new b}return v[t]=i,i},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.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")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.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)},_.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},_.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)},_.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},_.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},_.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.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},_.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},_.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new k(t)},n(k,_),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},k.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)},k.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)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":57}],150:[function(require,module,exports){ +},{"buffer":73}],170:[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":236}],151:[function(require,module,exports){ +},{"heap":278}],171:[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){ +},{}],172:[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":56}],153:[function(require,module,exports){ +},{"../package.json":188,"./elliptic/curve":175,"./elliptic/curves":178,"./elliptic/ec":179,"./elliptic/eddsa":182,"./elliptic/utils":186,"brorand":72}],173:[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":251}],155:[function(require,module,exports){ +},{"../utils":186,"./base":173,"bn.js":187,"inherits":293}],175:[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":173,"./edwards":174,"./mont":176,"./short":177}],176:[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":251}],157:[function(require,module,exports){ +},{"../utils":186,"./base":173,"bn.js":187,"inherits":293}],177:[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":251}],158:[function(require,module,exports){ +},{"../utils":186,"./base":173,"bn.js":187,"inherits":293}],178:[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":223}],159:[function(require,module,exports){ +},{"./curve":175,"./precomputed/secp256k1":185,"./utils":186,"hash.js":266}],179:[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":56,"hmac-drbg":238}],160:[function(require,module,exports){ +},{"../curves":178,"../utils":186,"./key":180,"./signature":181,"bn.js":187,"brorand":72,"hmac-drbg":280}],180:[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":186,"bn.js":187}],181:[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":186,"bn.js":187}],182:[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":314,"minimalistic-crypto-utils":315}],167:[function(require,module,exports){ +},{"bn.js":187,"minimalistic-assert":364,"minimalistic-crypto-utils":365}],187:[function(require,module,exports){ !function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function h(t,i,r){if(h.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=h:i.BN=h,h.BN=h,h.wordSize=26;try{e="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function o(t,i){var r=t.charCodeAt(i);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,i,r){var n=o(t,r);return r-1>=i&&(n|=o(t,r-1)<<4),n}function u(t,i,r,n){for(var h=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return h}h.isBN=function(t){return t instanceof h||null!==t&&"object"==typeof t&&t.constructor.wordSize===h.wordSize&&Array.isArray(t.words)},h.max=function(t,i){return t.cmp(i)>0?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++,this.negative=1),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,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var n=0;n=i;n-=2)h=s(t,i,n)<=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;else for(n=(t.length-i)%2==0?i+1:i;n=18?(e-=18,o+=1,this.words[o]|=h>>>26):e+=8;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,s=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},h.prototype.inspect=function(){return(this.red?""};var a=["","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"],l=[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],m=[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 f(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.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?a[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 f=l[t],d=m[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?M+n:a[f-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)},h.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},h.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},h.prototype.toArrayLike=function(t,i,n){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"),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},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,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],B=8191&q,R=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,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,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,F),h=(h=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(n=n+Math.imul(m,H)|0)|0)+((8191&(h=(h=h+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(h>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,F),h=(h=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),n=n+Math.imul(p,H)|0,h=(h=h+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|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,C))+Math.imul(b,F)|0,e=Math.imul(b,C),n=n+Math.imul(g,H)|0,h=(h=h+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|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,C))+Math.imul(A,F)|0,e=Math.imul(A,C),n=n+Math.imul(y,H)|0,h=(h=h+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|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(S,F),h=(h=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),n=n+Math.imul(k,H)|0,h=(h=h+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|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(B,F),h=(h=Math.imul(B,C))+Math.imul(R,F)|0,e=Math.imul(R,C),n=n+Math.imul(S,H)|0,h=(h=h+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|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(L,F),h=(h=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),n=n+Math.imul(B,H)|0,h=(h=h+Math.imul(B,J)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,J)|0,n=n+Math.imul(S,G)|0,h=(h=h+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,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(T,F),h=(h=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),n=n+Math.imul(L,H)|0,h=(h=h+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,n=n+Math.imul(B,G)|0,h=(h=h+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,n=n+Math.imul(S,W)|0,h=(h=h+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,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,C))+Math.imul(K,F)|0,e=Math.imul(K,C),n=n+Math.imul(T,H)|0,h=(h=h+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,n=n+Math.imul(L,G)|0,h=(h=h+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,n=n+Math.imul(B,W)|0,h=(h=h+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,n=n+Math.imul(S,$)|0,h=(h=h+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,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 xt=(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)+(xt>>>26)|0,xt&=67108863,n=Math.imul(j,H),h=(h=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),n=n+Math.imul(T,G)|0,h=(h=h+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,n=n+Math.imul(L,W)|0,h=(h=h+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,n=n+Math.imul(B,$)|0,h=(h=h+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,n=n+Math.imul(S,rt)|0,h=(h=h+Math.imul(S,nt)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,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 St=(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)+(St>>>26)|0,St&=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(T,W)|0,h=(h=h+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,n=n+Math.imul(L,$)|0,h=(h=h+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,n=n+Math.imul(B,rt)|0,h=(h=h+Math.imul(B,nt)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,nt)|0,n=n+Math.imul(S,et)|0,h=(h=h+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,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 Zt=(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)+(Zt>>>26)|0,Zt&=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(T,$)|0,h=(h=h+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,n=n+Math.imul(L,rt)|0,h=(h=h+Math.imul(L,nt)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,nt)|0,n=n+Math.imul(B,et)|0,h=(h=h+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,n=n+Math.imul(S,ut)|0,h=(h=h+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,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 qt=(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)+(qt>>>26)|0,qt&=67108863,n=Math.imul(j,$),h=(h=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),n=n+Math.imul(T,rt)|0,h=(h=h+Math.imul(T,nt)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,nt)|0,n=n+Math.imul(L,et)|0,h=(h=h+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,n=n+Math.imul(B,ut)|0,h=(h=h+Math.imul(B,at)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,at)|0,n=n+Math.imul(S,mt)|0,h=(h=h+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Bt=(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)+(Bt>>>26)|0,Bt&=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(T,et)|0,h=(h=h+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,n=n+Math.imul(L,ut)|0,h=(h=h+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,n=n+Math.imul(B,mt)|0,h=(h=h+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(a+(n=n+Math.imul(S,pt)|0)|0)+((8191&(h=(h=h+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(h>>>13)|0)+(Rt>>>26)|0,Rt&=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(T,ut)|0,h=(h=h+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,n=n+Math.imul(L,mt)|0,h=(h=h+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(n=n+Math.imul(B,pt)|0)|0)+((8191&(h=(h=h+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;a=((e=e+Math.imul(R,Mt)|0)+(h>>>13)|0)+(Nt>>>26)|0,Nt&=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(T,mt)|0,h=(h=h+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(n=n+Math.imul(L,pt)|0)|0)+((8191&(h=(h=h+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(h>>>13)|0)+(Lt>>>26)|0,Lt&=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(T,pt)|0)|0)+((8191&(h=(h=h+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(h>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(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)+(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]=Bt,u[14]=Rt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function p(t,i,r){return(new M).mulp(t,i,r)}function M(t,i){this.x=t,this.y=i}Math.imul||(d=f),h.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,i):r<63?f(this,t,i):r<1024?function(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()}(this,t,i):p(this,t,i)},M.prototype.makeRBT=function(t){for(var i=new Array(t),r=h.prototype._countBits(t)-1,n=0;n>=1;return n},M.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,i+=h/67108864|0,i+=e>>>26,this.words[n]=67108863&e}return 0!==i&&(this.words[n]=i,this.length++),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}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.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new h(this.modn(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.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,n=0,h=this.length-1;h>=0;h--)n=(i*n+(0|this.words[h]))%t;return n},h.prototype.idivn=function(t){r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var h=(0|this.words[n])+67108864*i;this.words[n]=h/t|0,i=h%t}return this.strip()},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 _(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 v={k256:null,p224:null,p192:null,p25519:null};function g(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 c(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function y(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(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 k(t){_.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)}g.prototype._tmp=function(){var t=new h(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.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},g.prototype.split=function(t,i){t.iushrn(this.n,0,i)},g.prototype.imulK=function(t){return t.imul(this.k)},n(c,g),c.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},c.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(v[t])return v[t];var i;if("k256"===t)i=new c;else if("p224"===t)i=new w;else if("p192"===t)i=new y;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new b}return v[t]=i,i},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.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")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.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)},_.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},_.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)},_.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},_.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},_.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.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},_.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},_.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},h.mont=function(t){return new k(t)},n(k,_),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},k.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)},k.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)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":57}],168:[function(require,module,exports){ +},{"buffer":73}],188:[function(require,module,exports){ module.exports={ "name": "elliptic", "version": "6.5.4", @@ -999,319 +1065,430 @@ module.exports={ } } -},{}],169:[function(require,module,exports){ +},{}],189:[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":11,"inherits":251,"level-codec":170,"level-errors":273}],170:[function(require,module,exports){ +},{"abstract-leveldown":12,"inherits":293,"level-codec":190,"level-errors":323}],190:[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":171}],171:[function(require,module,exports){ +},{"./lib/encodings":191}],191:[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":101}],172:[function(require,module,exports){ +},{"buffer":117}],192:[function(require,module,exports){ +const{Buffer:Buffer}=require("buffer"),na=require("sodium-universal"),LABELS=require("envelope-spec/derive_secret/constants.json"),{DeriveSecret:DeriveSecret,KeySlot:KeySlot,error:error}=require("./util"),zerodNonce=Buffer.alloc(na.crypto_secretbox_NONCEBYTES),zerodMsgKey=Buffer.alloc(na.crypto_secretbox_KEYBYTES);module.exports=function(e,r,o,t,c){if(!e.length)throw error("boxEmptyPlainText");if(t.equals(zerodMsgKey))throw error("boxZerodMsgKey");const s=DeriveSecret(r,o),n=s(t,[LABELS.read_key]),l=s(n,[LABELS.header_key]),i=s(n,[LABELS.body_key]),a=32+32*c.length,u=Buffer.alloc(a+e.length+16),y=u.slice(0,32),f=y.slice(16);f.writeUInt16LE(a,0),na.crypto_secretbox_easy(y,f,zerodNonce,l);const{slot:d}=KeySlot(s);c.forEach((e,r)=>{d(u.slice(32+32*r,64+32*r),t,e)});const S=u.slice(a);return na.crypto_secretbox_easy(S,e,zerodNonce,i),u}; + +},{"./util":201,"buffer":117,"envelope-spec/derive_secret/constants.json":205,"sodium-universal":640}],193:[function(require,module,exports){ +(function (Buffer){(function (){ +const na=require("sodium-universal"),hkdf=require("futoin-hkdf"),labels=require("envelope-spec/cloaked_msg_id/constants.json"),encode=require("./util/slp-encode"),hash="sha256",hash_len=hkdf.hash_length(hash),length=32;module.exports=class{constructor(e,s){if(!e&&!s)return void(this.key=null);const r=[Buffer.from(labels.cloaked_msg_id,"utf8"),e];this.key=hkdf.expand(hash,hash_len,s,32,encode(r))}toBuffer(){if(null===this.key)throw new Error("CloakedMsgId had null key value");return this.key}toString(e="base64"){if(null===this.key)throw new Error("CloakedMsgId had null key value");return this.key.toString(e)}mock(){return this.key=Buffer.alloc(32),na.randombytes_buf(this.key),this}}; + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./util/slp-encode":203,"buffer":117,"envelope-spec/cloaked_msg_id/constants.json":204,"futoin-hkdf":235,"sodium-universal":640}],194:[function(require,module,exports){ +const box=require("./box"),{unbox:unbox,unboxKey:unboxKey,unboxBody:unboxBody}=require("./unbox"),{DeriveSecret:DeriveSecret,slpEncode:slpEncode,Cipherlink:Cipherlink}=require("./util"),CloakedMsgId=require("./cloaked-msg-id");module.exports={box:box,unbox:unbox,unboxKey:unboxKey,unboxBody:unboxBody,DeriveSecret:DeriveSecret,slp:{encode:slpEncode},Cipherlink:Cipherlink,CloakedMsgId:CloakedMsgId}; + +},{"./box":192,"./cloaked-msg-id":193,"./unbox":196,"./util":201}],195:[function(require,module,exports){ +module.exports=function(n,t){for(var e=Math.min(n.length,t.length),r=0;r0===e.length))throw new Error("DeriveSecret: zero length info buffer found");return hkdf.expand(hash,hash_len,n,o,encode(t))}}; + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./bfe-nil-msg":197,"./slp-encode":203,"buffer":117,"futoin-hkdf":235}],200:[function(require,module,exports){ +const error_codes=require("envelope-spec/error_codes.json");module.exports=function(r){if(!(r in error_codes))throw new Error(`trying to throw error with unknown code: ${r}`);const o=new Error(`${r}: ${error_codes[r]}`);return o.code=r,o}; + +},{"envelope-spec/error_codes.json":206}],201:[function(require,module,exports){ +const DeriveSecret=require("./derive-secret"),KeySlot=require("./key-slot"),slpEncode=require("./slp-encode"),Cipherlink=require("./cipherlink"),error=require("./error");module.exports={DeriveSecret:DeriveSecret,KeySlot:KeySlot,slpEncode:slpEncode,Cipherlink:Cipherlink,error:error}; + +},{"./cipherlink":198,"./derive-secret":199,"./error":200,"./key-slot":202,"./slp-encode":203}],202:[function(require,module,exports){ +const xor=require("buffer-xor/inplace"),labels=require("envelope-spec/derive_secret/constants.json");module.exports=function(e){if("function"!=typeof e)throw new Error(`KeySlot requires a derive function, got: '${typeof e}'`);let o=null;function t(o){if(!o.key)throw new Error("envelope/key-slot: recipient is expected to have a key");if(!o.scheme)throw new Error("envelope/key-slot: recipient is expected to have a scheme");return e(o.key,[labels.slot_key,o.scheme])}return{slot:function(e,o,r){o.copy(e),xor(e,t(r))},setFlip:function(e){o=t(e)},unslot:function(e,r,n){o?o.copy(e):t(n).copy(e),xor(e,r)}}}; + +},{"buffer-xor/inplace":195,"envelope-spec/derive_secret/constants.json":205}],203:[function(require,module,exports){ +(function (Buffer){(function (){ +module.exports=function(e){const r=e.map(e=>2+e.length).reduce((e,r)=>e+r,0),t=Buffer.alloc(r);let o=0;return e.forEach(e=>{if(!Buffer.isBuffer(e))throw new Error(`slp.encode expects Buffers, got ${e}`);const r=e.length;t.writeInt16LE(r,o),e.copy(t,o+2),o+=2+r}),t}; + +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":117}],204:[function(require,module,exports){ +module.exports={ + "description": "labels used for the Cloaked Id derivation", + "cloaked_msg_id": "cloaked_msg_id" +} + +},{}],205:[function(require,module,exports){ +module.exports={ + "description": "labels used for the Derive Secret function", + "read_key": "read_key", + "header_key": "header_key", + "body_key": "body_key", + "slot_key": "slot_key" +} + +},{}],206:[function(require,module,exports){ +module.exports={ + "boxEmptyPlainText": "box requires a non-empty plain_text", + "boxZerodMsgKey": "box requires a non-empty msg_key" +} + +},{}],207:[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,!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){if(r.value)for(var t in e.blocks[r.id]=e.blocks[r.id]||{},e.blocks[r.id][r.target]=!0,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))}else 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];return e},c}; -},{}],173:[function(require,module,exports){ +},{}],208:[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,a){n.streams[t]&&n.streams[t].end({name:"Error",message:"reconnected to peer",stack:""}),n.logging&&console.log("EBT:conn",t);var i=new r(this,t,s,a,e.isMsg,function(r){e.setClock(t,r.clock)});return n.streams[t]=i,e.getClock(t,(e,r)=>{n.state.peers[t]&&i.clock(e?{}:r)}),i},_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 a=n.state.receive.shift();e.append(a.value,function(e){e&&(n.logging&&console.error("EBT:err",e),n.block(a.value.author,a.id,!0))})}for(var i in n.streams)n.streams[i].resume()}},a=setInterval(()=>{n.state=t.timeout(n.state,{ts:timestamp()}),n.update()},s.timeout);return a.unref&&a.unref(),n}; -},{"./events":172,"./progress":174,"./stream":175,"./v3":176}],174:[function(require,module,exports){ +},{"./events":207,"./progress":209,"./stream":210,"./v3":211}],209:[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)}; -},{}],177:[function(require,module,exports){ +},{}],212:[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":395}],178:[function(require,module,exports){ +},{"prr":451}],213:[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":177}],179:[function(require,module,exports){ -"use strict";module.exports=require("call-bind"); - -},{"call-bind":109}],180:[function(require,module,exports){ -"use strict";var GetIntrinsic=require("get-intrinsic"),$gOPD=GetIntrinsic("%Object.getOwnPropertyDescriptor%",!0);if($gOPD)try{$gOPD([],"length")}catch(t){$gOPD=null}module.exports=$gOPD; - -},{"get-intrinsic":197}],181:[function(require,module,exports){ +},{"./custom":212}],214:[function(require,module,exports){ "use strict";var ReflectOwnKeys,R="object"==typeof Reflect?Reflect:null,ReflectApply=R&&"function"==typeof R.apply?R.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}ReflectOwnKeys=R&&"function"==typeof R.ownKeys?R.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var NumberIsNaN=Number.isNaN||function(e){return e!=e};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter,module.exports.once=once,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function _getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function _addListener(e,t,n,r){var i,o,s;if(checkListener(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=_getMaxListeners(e))>0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.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&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)ReflectApply(u,this,t);else{var f=u.length,v=arrayClone(u,f);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;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,s||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,o=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):[]}; -},{}],182:[function(require,module,exports){ +},{}],215:[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":311,"safe-buffer":527}],183:[function(require,module,exports){ +},{"md5.js":361,"safe-buffer":585}],216:[function(require,module,exports){ +module.exports=read;const MSB=128,REST=127,MATH_POW_4=Math.pow(2,28),MATH_POW_5=Math.pow(2,35),MATH_POW_6=Math.pow(2,42),MATH_POW_7=Math.pow(2,49);function read(e,r){let t=e[r=r||0],M=0;if(M+=t&REST,tNumber.MAX_SAFE_INTEGER)throw encode.bytes=0,new RangeError("Could not encode varint");o=o||[];for(var n=r=r||0;e>=INT;)o[r++]=255&e|MSB,e/=128;for(;e&MSBALL;)o[r++]=255&e|MSB,e>>>=7;return o[r]=0|e,encode.bytes=r-n+1,o} + +},{}],218:[function(require,module,exports){ +module.exports={encode:require("./encode.js"),decode:require("./decode.js"),encodingLength:require("./length.js")}; + +},{"./decode.js":216,"./encode.js":217,"./length.js":219}],219:[function(require,module,exports){ +var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63);module.exports=function(N){return N>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; -},{}],184:[function(require,module,exports){ +},{}],221:[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":36,"deep-equal":188,"obv":357,"path":373,"pull-notify":429,"pull-stream/sinks/drain":442,"pull-stream/sources/once":454}],188:[function(require,module,exports){ +},{"async-single":38,"deep-equal":225,"obv":407,"path":423,"pull-notify":485,"pull-stream/sinks/drain":499,"pull-stream/sources/once":511}],225:[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":253,"is-date-object":256,"is-regex":259,"object-is":351,"object-keys":355,"regexp.prototype.flags":521}],189:[function(require,module,exports){ +},{"is-arguments":295,"is-date-object":300,"is-regex":308,"object-is":401,"object-keys":405,"regexp.prototype.flags":579}],226:[function(require,module,exports){ module.exports=require("level-codec/lib/encodings").json; -},{"level-codec/lib/encodings":272}],190:[function(require,module,exports){ +},{"level-codec/lib/encodings":322}],227:[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":40,"flumecodec/json":189,"path":373}],191:[function(require,module,exports){ +},{"atomic-file":42,"flumecodec/json":226,"path":423}],228:[function(require,module,exports){ module.exports=require("./fs"); -},{"./fs":190}],192:[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;n=3&&(o=a),"[object Array]"===toStr.call(r)?forEachArray(r,t,o):"string"==typeof r?forEachString(r,t,o):forEachObject(r,t,o)};module.exports=forEach; -},{}],193:[function(require,module,exports){ +},{"is-callable":298}],230:[function(require,module,exports){ (function (process){(function (){ module.exports=realpath,realpath.realpath=realpath,realpath.sync=realpathSync,realpath.realpathSync=realpathSync,realpath.monkeypatch=monkeypatch,realpath.unmonkeypatch=unmonkeypatch;var fs=require("fs"),origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version),old=require("./old.js");function newError(a){return a&&"realpath"===a.syscall&&("ELOOP"===a.code||"ENOMEM"===a.code||"ENAMETOOLONG"===a.code)}function realpath(a,r,e){if(ok)return origRealpath(a,r,e);"function"==typeof r&&(e=r,r=null),origRealpath(a,r,function(t,n){newError(t)?old.realpath(a,r,e):e(t,n)})}function realpathSync(a,r){if(ok)return origRealpathSync(a,r);try{return origRealpathSync(a,r)}catch(e){if(newError(e))return old.realpathSync(a,r);throw e}}function monkeypatch(){fs.realpath=realpath,fs.realpathSync=realpathSync}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync} }).call(this)}).call(this,require('_process')) -},{"./old.js":194,"_process":391,"fs":100}],194:[function(require,module,exports){ +},{"./old.js":231,"_process":447,"fs":116}],231:[function(require,module,exports){ (function (process){(function (){ var pathModule=require("path"),isWindows="win32"===process.platform,fs=require("fs"),DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var e;if(DEBUG){var t=new Error;e=function(e){e&&(t.message=e.message,n(e=t))}}else e=n;return e;function n(e){if(e){if(process.throwDeprecation)throw e;if(!process.noDeprecation){var t="fs: missing callback "+(e.stack||e.message);process.traceDeprecation?console.trace(t):console.error(t)}}}}function maybeCallback(e){return"function"==typeof e?e:rethrow()}var normalize=pathModule.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;exports.realpathSync=function(e,t){if(e=pathModule.resolve(e),t&&Object.prototype.hasOwnProperty.call(t,e))return t[e];var n,r,o,s,i=e,a={},l={};function c(){var t=splitRootRe.exec(e);n=t[0].length,r=t[0],o=t[0],s="",isWindows&&!l[o]&&(fs.lstatSync(o),l[o]=!0)}for(c();n=e.length)return t&&(t[a]=e),n(null,e);nextPartRe.lastIndex=r;var l=nextPartRe.exec(e);return i=o,o+=l[0],s=i+l[1],r=nextPartRe.lastIndex,c[s]||t&&t[s]===s?process.nextTick(u):t&&Object.prototype.hasOwnProperty.call(t,s)?d(t[s]):fs.lstat(s,p)}function p(e,r){if(e)return n(e);if(!r.isSymbolicLink())return c[s]=!0,t&&(t[s]=s),process.nextTick(u);if(!isWindows){var o=r.dev.toString(32)+":"+r.ino.toString(32);if(l.hasOwnProperty(o))return v(null,l[o],s)}fs.stat(s,function(e){if(e)return n(e);fs.readlink(s,function(e,t){isWindows||(l[o]=t),v(e,t)})})}function v(e,r,o){if(e)return n(e);var s=pathModule.resolve(i,r);t&&(t[o]=s),d(s)}function d(t){e=pathModule.resolve(t,e.slice(r)),f()}f()}; }).call(this)}).call(this,require('_process')) -},{"_process":391,"fs":100,"path":373}],195:[function(require,module,exports){ +},{"_process":447,"fs":116,"path":423}],232:[function(require,module,exports){ "use strict";var ERROR_MESSAGE="Function.prototype.bind called on incompatible ",slice=Array.prototype.slice,toStr=Object.prototype.toString,funcType="[object Function]";module.exports=function(t){var n=this;if("function"!=typeof n||toStr.call(n)!==funcType)throw new TypeError(ERROR_MESSAGE+n);for(var o,e=slice.call(arguments,1),r=Math.max(0,n.length-e.length),c=[],i=0;i1&&"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}; +},{"./implementation":232}],234:[function(require,module,exports){ +"use strict";var functionsHaveNames=function(){return"string"==typeof function(){}.name},gOPD=Object.getOwnPropertyDescriptor;if(gOPD)try{gOPD([],"length")}catch(n){gOPD=null}functionsHaveNames.functionsHaveConfigurableNames=function(){if(!functionsHaveNames()||!gOPD)return!1;var n=gOPD(function(){},"name");return!!n&&!!n.configurable};var $bind=Function.prototype.bind;functionsHaveNames.boundFunctionsHaveNames=function(){return functionsHaveNames()&&"function"==typeof $bind&&""!==function(){}.bind().name},module.exports=functionsHaveNames; + +},{}],235:[function(require,module,exports){ +"use strict";const{Buffer:Buffer}=require("buffer"),{createHash:createHash,createHmac:createHmac}=require("crypto"),g_digestLenCache={},hash_length=e=>{switch(e){case"sha256":return 32;case"sha512":return 64;case"sha224":return 28;case"sha384":return 48;case"sha3-256":return 32;case"sha3-512":return 64;case"sha3-224":return 28;case"sha3-384":return 48;case"blake2s256":return 32;case"blake2b512":return 64;case"sha1":return 20;case"md5":return 16;default:{let r=g_digestLenCache[e];return void 0===r&&(r=createHash(e).digest().length,g_digestLenCache[e]=r),r}}},hkdf_extract=(e,r,a,t)=>{const s=Buffer.isBuffer(a)?a:Buffer.from(a),c=t&&t.length?Buffer.from(t):Buffer.alloc(r,0);return createHmac(e,c).update(s).digest()},hkdf_expand=(e,r,a,t,s)=>{const c=Buffer.isBuffer(s)?s:Buffer.from(s||""),n=c.length,h=Math.ceil(t/r);if(h>255)throw new Error(`OKM length ${t} is too long for ${e} hash`);const f=Buffer.alloc(r*h+n+1);for(let t=1,s=0,u=0;t<=h;++t)c.copy(f,u),f[u+n]=t,createHmac(e,a).update(f.slice(s,u+n+1)).digest().copy(f,u),s=u,u+=r;return f.slice(0,t)};function hkdf(e,r,{salt:a="",info:t="",hash:s="SHA-256"}={}){s=s.toLowerCase().replace("-","");const c=hash_length(s),n=hkdf_extract(s,c,e,a);return hkdf_expand(s,c,n,r,t)}Object.defineProperties(hkdf,{hash_length:{configurable:!1,enumerable:!1,writable:!1,value:hash_length},extract:{configurable:!1,enumerable:!1,writable:!1,value:hkdf_extract},expand:{configurable:!1,enumerable:!1,writable:!1,value:hkdf_expand}}),module.exports=hkdf; + +},{"buffer":117,"crypto":153}],236:[function(require,module,exports){ +for(var util=require("util"),isProperty=require("is-property"),INDENT_START=/[\{\[]/,INDENT_END=/[\}\]]/,RESERVED=["do","if","in","for","let","new","try","var","case","else","enum","eval","null","this","true","void","with","await","break","catch","class","const","false","super","throw","while","yield","delete","export","import","public","return","static","switch","typeof","default","extends","finally","package","private","continue","debugger","function","arguments","interface","protected","implements","instanceof","NaN","undefined"],RESERVED_MAP={},i=0;i-1)for(var n=t.trim().split("\n"),e=0;e1&&"boolean"!=typeof e)throw new $TypeError('"allowMissing" argument must be a boolean');if(null===$exec(/^%?[^%]*%?$/,r))throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name");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":233,"has":249,"has-symbols":246}],239:[function(require,module,exports){ (function (process){(function (){ -function ownProp(e,r){return Object.prototype.hasOwnProperty.call(e,r)}exports.setopts=setopts,exports.ownProp=ownProp,exports.makeAbs=makeAbs,exports.finish=finish,exports.mark=mark,exports.isIgnored=isIgnored,exports.childrenIgnored=childrenIgnored;var fs=require("fs"),path=require("path"),minimatch=require("minimatch"),isAbsolute=require("path-is-absolute"),Minimatch=minimatch.Minimatch;function alphasort(e,r){return e.localeCompare(r,"en")}function setupIgnores(e,r){e.ignore=r.ignore||[],Array.isArray(e.ignore)||(e.ignore=[e.ignore]),e.ignore.length&&(e.ignore=e.ignore.map(ignoreMap))}function ignoreMap(e){var r=null;if("/**"===e.slice(-3)){var t=e.replace(/(\/\*\*)+$/,"");r=new Minimatch(t,{dot:!0})}return{matcher:new Minimatch(e,{dot:!0}),gmatcher:r}}function setopts(e,r,t){if(t||(t={}),t.matchBase&&-1===r.indexOf("/")){if(t.noglobstar)throw new Error("base matching requires globstar");r="**/"+r}e.silent=!!t.silent,e.pattern=r,e.strict=!1!==t.strict,e.realpath=!!t.realpath,e.realpathCache=t.realpathCache||Object.create(null),e.follow=!!t.follow,e.dot=!!t.dot,e.mark=!!t.mark,e.nodir=!!t.nodir,e.nodir&&(e.mark=!0),e.sync=!!t.sync,e.nounique=!!t.nounique,e.nonull=!!t.nonull,e.nosort=!!t.nosort,e.nocase=!!t.nocase,e.stat=!!t.stat,e.noprocess=!!t.noprocess,e.absolute=!!t.absolute,e.fs=t.fs||fs,e.maxLength=t.maxLength||1/0,e.cache=t.cache||Object.create(null),e.statCache=t.statCache||Object.create(null),e.symlinks=t.symlinks||Object.create(null),setupIgnores(e,t),e.changedCwd=!1;var n=process.cwd();ownProp(t,"cwd")?(e.cwd=path.resolve(t.cwd),e.changedCwd=e.cwd!==n):e.cwd=n,e.root=t.root||path.resolve(e.cwd,"/"),e.root=path.resolve(e.root),"win32"===process.platform&&(e.root=e.root.replace(/\\/g,"/")),e.cwdAbs=isAbsolute(e.cwd)?e.cwd:makeAbs(e,e.cwd),"win32"===process.platform&&(e.cwdAbs=e.cwdAbs.replace(/\\/g,"/")),e.nomount=!!t.nomount,t.nonegate=!0,t.nocomment=!0,e.minimatch=new Minimatch(r,t),e.options=e.minimatch.options}function finish(e){for(var r=e.nounique,t=r?[]:Object.create(null),n=0,o=e.matches.length;n1)return!0;for(var s=0;sthis.maxLength)return i();if(!this.stat&&ownProp(this.cache,e)){var s=this.cache[e];if(Array.isArray(s)&&(s="DIR"),!r||"DIR"===s)return i(null,s);if(r&&"FILE"===s)return i()}var o=this.statCache[e];if(void 0!==o){if(!1===o)return i(null,o);var n=o.isDirectory()?"DIR":"FILE";return r&&"FILE"===n?i():i(null,n,o)}var h=this,a=inflight("stat\0"+e,function(r,s){if(s&&s.isSymbolicLink())return h.fs.stat(e,function(r,o){r?h._stat2(t,e,null,s,i):h._stat2(t,e,r,o,i)});h._stat2(t,e,r,s,i)});a&&h.fs.lstat(e,a)},Glob.prototype._stat2=function(t,i,e,r,s){if(e&&("ENOENT"===e.code||"ENOTDIR"===e.code))return this.statCache[i]=!1,s();var o="/"===t.slice(-1);if(this.statCache[i]=r,"/"===i.slice(-1)&&r&&!r.isDirectory())return s(null,!1,r);var n=!0;return r&&(n=r.isDirectory()?"DIR":"FILE"),this.cache[i]=this.cache[i]||n,o&&"FILE"===n?s():s(null,n,r)}; +module.exports=glob;var rp=require("fs.realpath"),minimatch=require("minimatch"),Minimatch=minimatch.Minimatch,inherits=require("inherits"),EE=require("events").EventEmitter,path=require("path"),assert=require("assert"),isAbsolute=require("path-is-absolute"),globSync=require("./sync.js"),common=require("./common.js"),setopts=common.setopts,ownProp=common.ownProp,inflight=require("inflight"),util=require("util"),childrenIgnored=common.childrenIgnored,isIgnored=common.isIgnored,once=require("once");function glob(t,i,e){if("function"==typeof i&&(e=i,i={}),i||(i={}),i.sync){if(e)throw new TypeError("callback provided to sync glob");return globSync(t,i)}return new Glob(t,i,e)}glob.sync=globSync;var GlobSync=glob.GlobSync=globSync.GlobSync;function extend(t,i){if(null===i||"object"!=typeof i)return t;for(var e=Object.keys(i),r=e.length;r--;)t[e[r]]=i[e[r]];return t}function Glob(t,i,e){if("function"==typeof i&&(e=i,i=null),i&&i.sync){if(e)throw new TypeError("callback provided to sync glob");return new GlobSync(t,i)}if(!(this instanceof Glob))return new Glob(t,i,e);setopts(this,t,i),this._didRealPath=!1;var r=this.minimatch.set.length;this.matches=new Array(r),"function"==typeof e&&(e=once(e),this.on("error",e),this.on("end",function(t){e(null,t)}));var s=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(0===r)return h();for(var o=!0,n=0;n1)return!0;for(var s=0;sthis.maxLength)return i();if(!this.stat&&ownProp(this.cache,e)){var s=this.cache[e];if(Array.isArray(s)&&(s="DIR"),!r||"DIR"===s)return i(null,s);if(r&&"FILE"===s)return i()}var o=this.statCache[e];if(void 0!==o){if(!1===o)return i(null,o);var n=o.isDirectory()?"DIR":"FILE";return r&&"FILE"===n?i():i(null,n,o)}var h=this,a=inflight("stat\0"+e,function(r,s){if(s&&s.isSymbolicLink())return h.fs.stat(e,function(r,o){r?h._stat2(t,e,null,s,i):h._stat2(t,e,r,o,i)});h._stat2(t,e,r,s,i)});a&&h.fs.lstat(e,a)},Glob.prototype._stat2=function(t,i,e,r,s){if(e&&("ENOENT"===e.code||"ENOTDIR"===e.code))return this.statCache[i]=!1,s();var o="/"===t.slice(-1);if(this.statCache[i]=r,"/"===i.slice(-1)&&r&&!r.isDirectory())return s(null,!1,r);var n=!0;return r&&(n=r.isDirectory()?"DIR":"FILE"),this.cache[i]=this.cache[i]||n,o&&"FILE"===n?s():s(null,n,r)}; }).call(this)}).call(this,require('_process')) -},{"./common.js":198,"./sync.js":200,"_process":391,"assert":29,"events":181,"fs.realpath":193,"inflight":250,"inherits":251,"minimatch":316,"once":361,"path":373,"path-is-absolute":374,"util":691}],200:[function(require,module,exports){ +},{"./common.js":239,"./sync.js":241,"_process":447,"assert":29,"events":214,"fs.realpath":230,"inflight":292,"inherits":293,"minimatch":366,"once":411,"path":423,"path-is-absolute":424,"util":829}],241:[function(require,module,exports){ (function (process){(function (){ -module.exports=globSync,globSync.GlobSync=GlobSync;var rp=require("fs.realpath"),minimatch=require("minimatch"),Minimatch=minimatch.Minimatch,Glob=require("./glob.js").Glob,util=require("util"),path=require("path"),assert=require("assert"),isAbsolute=require("path-is-absolute"),common=require("./common.js"),setopts=common.setopts,ownProp=common.ownProp,childrenIgnored=common.childrenIgnored,isIgnored=common.isIgnored;function globSync(t,r){if("function"==typeof r||3===arguments.length)throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");return new GlobSync(t,r).found}function GlobSync(t,r){if(!t)throw new Error("must provide pattern");if("function"==typeof r||3===arguments.length)throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");if(!(this instanceof GlobSync))return new GlobSync(t,r);if(setopts(this,t,r),this.noprocess)return this;var i=this.minimatch.set.length;this.matches=new Array(i);for(var s=0;sthis.maxLength)return!1;if(!this.stat&&ownProp(this.cache,r)){var s=this.cache[r];if(Array.isArray(s)&&(s="DIR"),!i||"DIR"===s)return s;if(i&&"FILE"===s)return!1}var e=this.statCache[r];if(!e){var o;try{o=this.fs.lstatSync(r)}catch(t){if(t&&("ENOENT"===t.code||"ENOTDIR"===t.code))return this.statCache[r]=!1,!1}if(o&&o.isSymbolicLink())try{e=this.fs.statSync(r)}catch(t){e=o}else e=o}this.statCache[r]=e;s=!0;return e&&(s=e.isDirectory()?"DIR":"FILE"),this.cache[r]=this.cache[r]||s,(!i||"FILE"!==s)&&s},GlobSync.prototype._mark=function(t){return common.mark(this,t)},GlobSync.prototype._makeAbs=function(t){return common.makeAbs(this,t)}; +module.exports=globSync,globSync.GlobSync=GlobSync;var rp=require("fs.realpath"),minimatch=require("minimatch"),Minimatch=minimatch.Minimatch,Glob=require("./glob.js").Glob,util=require("util"),path=require("path"),assert=require("assert"),isAbsolute=require("path-is-absolute"),common=require("./common.js"),setopts=common.setopts,ownProp=common.ownProp,childrenIgnored=common.childrenIgnored,isIgnored=common.isIgnored;function globSync(t,r){if("function"==typeof r||3===arguments.length)throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");return new GlobSync(t,r).found}function GlobSync(t,r){if(!t)throw new Error("must provide pattern");if("function"==typeof r||3===arguments.length)throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");if(!(this instanceof GlobSync))return new GlobSync(t,r);if(setopts(this,t,r),this.noprocess)return this;var i=this.minimatch.set.length;this.matches=new Array(i);for(var s=0;sthis.maxLength)return!1;if(!this.stat&&ownProp(this.cache,r)){var s=this.cache[r];if(Array.isArray(s)&&(s="DIR"),!i||"DIR"===s)return s;if(i&&"FILE"===s)return!1}var e=this.statCache[r];if(!e){var o;try{o=this.fs.lstatSync(r)}catch(t){if(t&&("ENOENT"===t.code||"ENOTDIR"===t.code))return this.statCache[r]=!1,!1}if(o&&o.isSymbolicLink())try{e=this.fs.statSync(r)}catch(t){e=o}else e=o}this.statCache[r]=e;s=!0;return e&&(s=e.isDirectory()?"DIR":"FILE"),this.cache[r]=this.cache[r]||s,(!i||"FILE"!==s)&&s},GlobSync.prototype._mark=function(t){return common.mark(this,t)},GlobSync.prototype._makeAbs=function(t){return common.makeAbs(this,t)}; }).call(this)}).call(this,require('_process')) -},{"./common.js":198,"./glob.js":199,"_process":391,"assert":29,"fs.realpath":193,"minimatch":316,"path":373,"path-is-absolute":374,"util":691}],201:[function(require,module,exports){ +},{"./common.js":239,"./glob.js":240,"_process":447,"assert":29,"fs.realpath":230,"minimatch":366,"path":423,"path-is-absolute":424,"util":829}],242:[function(require,module,exports){ +"use strict";var GetIntrinsic=require("get-intrinsic"),$gOPD=GetIntrinsic("%Object.getOwnPropertyDescriptor%",!0);if($gOPD)try{$gOPD([],"length")}catch(t){$gOPD=null}module.exports=$gOPD; + +},{"get-intrinsic":238}],243:[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":251,"readable-stream":222,"safe-buffer":527}],208:[function(require,module,exports){ +},{"inherits":293,"readable-stream":265,"safe-buffer":585}],251:[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; -},{}],209:[function(require,module,exports){ +},{}],252:[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":208,"./_stream_duplex":209,"./internal/streams/destroy":216,"./internal/streams/state":220,"./internal/streams/stream":221,"_process":391,"buffer":101,"inherits":251,"util-deprecate":688}],214:[function(require,module,exports){ +},{"../errors":251,"./_stream_duplex":252,"./internal/streams/destroy":259,"./internal/streams/state":263,"./internal/streams/stream":264,"_process":447,"buffer":117,"inherits":293,"util-deprecate":826}],257:[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":217,"_process":391}],215:[function(require,module,exports){ +},{"./end-of-stream":260,"_process":447}],258:[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":101,"util":57}],216:[function(require,module,exports){ +},{"buffer":117,"util":73}],259:[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":391}],217:[function(require,module,exports){ +},{"_process":447}],260:[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":208,"./end-of-stream":217}],220:[function(require,module,exports){ +},{"../../../errors":251,"./end-of-stream":260}],263:[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":208}],221:[function(require,module,exports){ +},{"../../../errors":251}],264:[function(require,module,exports){ module.exports=require("events").EventEmitter; -},{"events":181}],222:[function(require,module,exports){ +},{"events":214}],265:[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":209,"./lib/_stream_passthrough.js":210,"./lib/_stream_readable.js":211,"./lib/_stream_transform.js":212,"./lib/_stream_writable.js":213,"./lib/internal/streams/end-of-stream.js":217,"./lib/internal/streams/pipeline.js":219}],223:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":252,"./lib/_stream_passthrough.js":253,"./lib/_stream_readable.js":254,"./lib/_stream_transform.js":255,"./lib/_stream_writable.js":256,"./lib/internal/streams/end-of-stream.js":260,"./lib/internal/streams/pipeline.js":262}],266:[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":224,"./hash/hmac":225,"./hash/ripemd":226,"./hash/sha":227,"./hash/utils":234}],224:[function(require,module,exports){ +},{"./hash/common":267,"./hash/hmac":268,"./hash/ripemd":269,"./hash/sha":270,"./hash/utils":277}],267:[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":234}],234:[function(require,module,exports){ +},{"../utils":277}],277:[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":251,"minimalistic-assert":314}],235:[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)}}}; - -},{}],236:[function(require,module,exports){ +},{"inherits":293,"minimalistic-assert":364}],278:[function(require,module,exports){ module.exports=require("./lib/heap"); -},{"./lib/heap":237}],237:[function(require,module,exports){ +},{"./lib/heap":279}],279:[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.lengtho[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":181,"inherits":251,"promisize":394}],242:[function(require,module,exports){ +},{"events":214,"inherits":293,"promisize":450}],284:[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}; -},{}],243:[function(require,module,exports){ +},{}],285:[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}; -},{}],250:[function(require,module,exports){ +},{}],292:[function(require,module,exports){ (function (process){(function (){ var wrappy=require("wrappy"),reqs=Object.create(null),once=require("once");function inflight(e,r){return reqs[e]?(reqs[e].push(r),null):(reqs[e]=[r],makeres(e))}function makeres(e){return once(function r(){var n=reqs[e],l=n.length,t=slice(arguments);try{for(var i=0;il?(n.splice(0,l),process.nextTick(function(){r.apply(null,t)})):delete reqs[e]}})}function slice(e){for(var r=e.length,n=[],l=0;l0;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":101,"os":362}],253:[function(require,module,exports){ +},{"buffer":117,"os":412}],295:[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":108}],254:[function(require,module,exports){ +},{"call-bind/callBound":124}],296:[function(require,module,exports){ +(function (Buffer){(function (){ +let blank=Buffer.alloc(8192);function realloc(l){let e=blank.length;for(;l>e;)e*=2;blank=Buffer.alloc(e)}function isZeroBuffer(l,e=8){if(l.length>blank.length&&realloc(l.length),e){const n=Math.min(e,l.length);for(let e=0;e1)return!1;if("0"===e[1][0]&&e[1].length>1)return!1;if("0"===e[2][0]&&e[2].length>1)return!1;if("0"===e[3][0]&&e[3].length>1)return!1;var t=Number(e[0]),n=Number(e[1]),a=Number(e[2]),i=Number(e[3]);return t>=0&&t<256&&n>=0&&n<256&&a>=0&&a<256&&i>=0&&i<256}function validate6(r){var e=r.replace(reSubnetString,""),t=r.length!==e.length;if(t)return!1;if(!t&&reForwardSlash.test(r))return!1;var n=e.replace(reZone,""),a=n.lastIndexOf(":");if(-1===a)return!1;var i=validate4(n.substring(a+1))?n.substring(0,a+1)+"1234:5678":n;if(reBadCharacters.test(i))return!1;if(reBadAddress.test(i))return!1;var s=i.split("::");if(s.length>2)return!1;if(2===s.length){var l=""===s[0]?[]:s[0].split(":"),u=""===s[1]?[]:s[1].split(":");if(8-(l.length+u.length)<=0)return!1}else if(8!==i.split(":").length)return!1;return!0}function validate(r){return validate4(r)||validate6(r)}module.exports=function(r){if(r||(r={}),4===r.version)return validate4;if(6===r.version)return validate6;if(null==r.version)return validate;throw new Error("Unknown version: "+r.version)},module.exports.__all_regexes__=[reIpv4FirstPass,reSubnetString,reForwardSlash,reZone,reBadCharacters,reBadAddress]; + +},{}],303:[function(require,module,exports){ +var createIpValidator=require("is-my-ip-valid"),reEmailWhitespace=/\s/,reHostnameFirstPass=/^[a-zA-Z0-9.-]+$/,reHostnamePart=/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$/,rePhoneFirstPass=/^\+[0-9][0-9 ]{5,27}[0-9]$/,rePhoneDoubleSpace=/ {2}/,rePhoneGlobalSpace=/ /g;exports["date-time"]=/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}[tT ]\d{2}:\d{2}:\d{2}(?:\.\d+|)([zZ]|[+-]\d{2}:\d{2})$/,exports.date=/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}$/,exports.time=/^\d{2}:\d{2}:\d{2}$/,exports.email=function(e){return-1!==e.indexOf("@")&&!reEmailWhitespace.test(e)},exports["ip-address"]=exports.ipv4=createIpValidator({version:4}),exports.ipv6=createIpValidator({version:6}),exports.uri=/^[a-zA-Z][a-zA-Z0-9+\-.]*:[^\s]*$/,exports.color=/(#?([0-9A-Fa-f]{3,6})\b)|(aqua)|(black)|(blue)|(fuchsia)|(gray)|(green)|(lime)|(maroon)|(navy)|(olive)|(orange)|(purple)|(red)|(silver)|(teal)|(white)|(yellow)|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\))/,exports.hostname=function(e){if(!reHostnameFirstPass.test(e))return!1;for(var r=e.split("."),t=0;t=7&&r<=15},exports["utc-millisec"]=/^[0-9]{1,15}\.?[0-9]{0,15}$/; + +},{"is-my-ip-valid":302}],304:[function(require,module,exports){ +var genobj=require("generate-object-property"),genfun=require("generate-function"),jsonpointer=require("jsonpointer"),xtend=require("xtend"),formats=require("./formats"),get=function(e,r,t){var n=function(e){return e&&e.id===t?e:"object"==typeof e&&e?Object.keys(e).reduce(function(r,t){return r||n(e[t])},null):null},i=n(e);if(i)return i;t=(t=t.replace(/^#/,"")).replace(/\/$/,"");try{return jsonpointer.get(e,decodeURI(t))}catch(e){var s,o=t.indexOf("#");if(0!==o)if(-1===o)s=r[t];else{s=r[t.slice(0,o)];var a=t.slice(o).replace(/^#/,"");try{return jsonpointer.get(s,a)}catch(e){}}else s=r[t];return s||null}},types={any:function(){return"true"},null:function(e){return e+" === null"},boolean:function(e){return"typeof "+e+' === "boolean"'},array:function(e){return"Array.isArray("+e+")"},object:function(e){return"typeof "+e+' === "object" && '+e+" && !Array.isArray("+e+")"},number:function(e){return"typeof "+e+' === "number" && isFinite('+e+")"},integer:function(e){return"typeof "+e+' === "number" && (Math.floor('+e+") === "+e+" || "+e+" > 9007199254740992 || "+e+" < -9007199254740992)"},string:function(e){return"typeof "+e+' === "string"'}},unique=function(e,r){r=Math.min(-1===r?e.length:r,e.length);for(var t=[],n=0;n1?t=((0|e)!==e?Math.pow(10,e.toString().split(".").pop().length):1)>n||Math.round(n*e)%(n*r):t=e%r;return!t},testLimitedRegex=function(e,r,t){return t>-1&&r.length>t||e.test(r)},compile=function(e,r,t,n,i){var s=i?xtend(formats,i.formats):formats,o={unique:unique,formats:s,isMultipleOf:isMultipleOf,testLimitedRegex:testLimitedRegex},a=!!i&&!!i.verbose,f=!(!i||void 0===i.greedy)&&i.greedy,u={},c=[],l=function(e){var r=e+(u[e]=(u[e]||0)+1);return c.push(r),r},m=function(e){var r=JSON.stringify(e);try{for(var t=/\[([^\[\]"]+)\]/;t.test(r);)r=r.replace(t,n);return r}catch(r){return JSON.stringify(e)}function n(e,r){if(-1===c.indexOf(r))throw new Error("Unreplaceable");return'." + '+r+' + "'}},p={},d=function(e){if(p[e])return p[e];var r=l("pattern");return o[r]=new RegExp(e),p[e]=r,r},y=["i","j","k","l","m","n","o","p","q","r","s","t","u","v","x","y","z"],g=function(){var e=y.shift();return y.push(e+e[0]),c.push(e),e},h=function(e,n,u,c,p){var y=n.properties,b=n.type,j=!1;Array.isArray(n.items)&&(y={},n.items.forEach(function(e,r){y[r]=e}),b="array",j=!0);var O=0,x=function(r,t,n){v("errors++"),!0===u&&(v("if (validate.errors === null) validate.errors = []"),a?v("validate.errors.push({field:%s,message:%s,value:%s,type:%s,schemaPath:%s})",m(t||e),JSON.stringify(r),n||e,JSON.stringify(b),JSON.stringify(p)):v("validate.errors.push({field:%s,message:%s})",m(t||e),JSON.stringify(r)))};!0===n.required?(O++,v("if (%s === undefined) {",e),x("is required"),v("} else {")):(O++,v("if (%s !== undefined) {",e));var P=[].concat(b).map(function(r){if(r&&!types.hasOwnProperty(r))throw new Error("Unknown type: "+r);return types[r||"any"](e)}).join(" || ")||"true";if("true"!==P&&(O++,v("if (!(%s)) {",P),x("is the wrong type"),v("} else {")),j)if(!1===n.additionalItems)v("if (%s.length > %d) {",e,n.items.length),x("has additional items"),v("}");else if(n.additionalItems){var q=g();v("for (var %s = %d; %s < %s.length; %s++) {",q,n.items.length,q,e,q),h(e+"["+q+"]",n.additionalItems,u,c,p.concat("additionalItems")),v("}")}if(n.format&&s[n.format]){"string"!==b&&formats[n.format]&&v("if (%s) {",types.string(e));var S=l("format");o[S]=s[n.format],"function"==typeof o[S]?v("if (!%s(%s)) {",S,e):v("if (!testLimitedRegex(%s, %s, %d)) {",S,e,void 0===n.maxLength?-1:n.maxLength),x("must be "+n.format+" format"),v("}"),"string"!==b&&formats[n.format]&&v("}")}if(Array.isArray(n.required)){S=l("missing");v("var %s = 0",S);v("if ((%s)) {","object"!==b?types.object(e):"true"),n.required.map(function(r){var t=genobj(e,r);v("if (%s === undefined) {",t),x("is required",t),v("%s++",S),v("}")}),v("}"),f||(v("if (%s === 0) {",S),O++)}if(n.uniqueItems&&("array"!==b&&v("if (%s) {",types.array(e)),v("if (!(unique(%s, %d))) {",e,n.maxItems||-1),x("must be unique"),v("}"),"array"!==b&&v("}")),n.enum){var w=n.enum.some(function(e){return"object"==typeof e})?function(r){return"JSON.stringify("+e+") !== JSON.stringify("+JSON.stringify(r)+")"}:function(r){return e+" !== "+JSON.stringify(r)};v("if (%s) {",n.enum.map(w).join(" && ")||"false"),x("must be an enum value"),v("}")}if(n.dependencies&&("object"!==b&&v("if (%s) {",types.object(e)),Object.keys(n.dependencies).forEach(function(r){var t=n.dependencies[r];"string"==typeof t&&(t=[t]);Array.isArray(t)&&(v("if (%s !== undefined && !(%s)) {",genobj(e,r),t.map(function(r){return genobj(e,r)+" !== undefined"}).join(" && ")||"true"),x("dependencies not set"),v("}")),"object"==typeof t&&(v("if (%s !== undefined) {",genobj(e,r)),h(e,t,u,c,p.concat(["dependencies",r])),v("}"))}),"object"!==b&&v("}")),n.additionalProperties||!1===n.additionalProperties){"object"!==b&&v("if (%s) {",types.object(e));q=g();var J=l("keys"),N=Object.keys(y||{}).map(function(e){return J+"["+q+"] !== "+JSON.stringify(e)}).concat(Object.keys(n.patternProperties||{}).map(function(e){return"!"+d(e)+".test("+J+"["+q+"])"})).join(" && ")||"true";v("var %s = Object.keys(%s)",J,e)("for (var %s = 0; %s < %s.length; %s++) {",q,q,J,q)("if (%s) {",N),!1===n.additionalProperties?(c&&v("delete %s",e+"["+J+"["+q+"]]"),x("has additional properties",null,JSON.stringify(e+".")+" + "+J+"["+q+"]")):h(e+"["+J+"["+q+"]]",n.additionalProperties,u,c,p.concat(["additionalProperties"])),v("}")("}"),"object"!==b&&v("}")}if(n.$ref){var k=get(t,i&&i.schemas||{},n.$ref);if(k){var A=r[n.$ref];A||(r[n.$ref]=function(e){return A(e)},A=compile(k,r,t,!1,i));S=l("ref");o[S]=A,v("if (!(%s(%s))) {",S,e),x("referenced schema does not match"),v("}")}}if(n.not){var L=l("prev");v("var %s = errors",L),h(e,n.not,!1,c,p.concat("not")),v("if (%s === errors) {",L),x("negative schema matches"),v("} else {")("errors = %s",L)("}")}if(n.items&&!j){"array"!==b&&v("if (%s) {",types.array(e));q=g();v("for (var %s = 0; %s < %s.length; %s++) {",q,q,e,q),h(e+"["+q+"]",n.items,u,c,p.concat("items")),v("}"),"array"!==b&&v("}")}if(n.patternProperties){"object"!==b&&v("if (%s) {",types.object(e));J=l("keys"),q=g();v("var %s = Object.keys(%s)",J,e)("for (var %s = 0; %s < %s.length; %s++) {",q,q,J,q),Object.keys(n.patternProperties).forEach(function(r){var t=d(r);v("if (%s.test(%s)) {",t,J+"["+q+"]"),h(e+"["+J+"["+q+"]]",n.patternProperties[r],u,c,p.concat(["patternProperties",r])),v("}")}),v("}"),"object"!==b&&v("}")}if(n.pattern){var E=d(n.pattern);"string"!==b&&v("if (%s) {",types.string(e)),v("if (!(testLimitedRegex(%s, %s, %d))) {",E,e,void 0===n.maxLength?-1:n.maxLength),x("pattern mismatch"),v("}"),"string"!==b&&v("}")}if(n.allOf&&n.allOf.forEach(function(r,t){h(e,r,u,c,p.concat(["allOf",t]))}),n.anyOf&&n.anyOf.length){L=l("prev");n.anyOf.forEach(function(r,t){0===t?v("var %s = errors",L):v("if (errors !== %s) {",L)("errors = %s",L),h(e,r,!1,!1,p)}),n.anyOf.forEach(function(e,r){r&&v("}")}),v("if (%s !== errors) {",L),x("no schemas match"),v("}")}if(n.oneOf&&n.oneOf.length){L=l("prev");var I=l("passes");v("var %s = errors",L)("var %s = 0",I),n.oneOf.forEach(function(r,t){h(e,r,!1,!1,p),v("if (%s === errors) {",L)("%s++",I)("} else {")("errors = %s",L)("}")}),v("if (%s !== 1) {",I),x("no (or more than one) schemas match"),v("}")}for(void 0!==n.multipleOf&&("number"!==b&&"integer"!==b&&v("if (%s) {",types.number(e)),v("if (!isMultipleOf(%s, %d)) {",e,n.multipleOf),x("has a remainder"),v("}"),"number"!==b&&"integer"!==b&&v("}")),void 0!==n.maxProperties&&("object"!==b&&v("if (%s) {",types.object(e)),v("if (Object.keys(%s).length > %d) {",e,n.maxProperties),x("has more properties than allowed"),v("}"),"object"!==b&&v("}")),void 0!==n.minProperties&&("object"!==b&&v("if (%s) {",types.object(e)),v("if (Object.keys(%s).length < %d) {",e,n.minProperties),x("has less properties than allowed"),v("}"),"object"!==b&&v("}")),void 0!==n.maxItems&&("array"!==b&&v("if (%s) {",types.array(e)),v("if (%s.length > %d) {",e,n.maxItems),x("has more items than allowed"),v("}"),"array"!==b&&v("}")),void 0!==n.minItems&&("array"!==b&&v("if (%s) {",types.array(e)),v("if (%s.length < %d) {",e,n.minItems),x("has less items than allowed"),v("}"),"array"!==b&&v("}")),void 0!==n.maxLength&&("string"!==b&&v("if (%s) {",types.string(e)),v("if (%s.length > %d) {",e,n.maxLength),x("has longer length than allowed"),v("}"),"string"!==b&&v("}")),void 0!==n.minLength&&("string"!==b&&v("if (%s) {",types.string(e)),v("if (%s.length < %d) {",e,n.minLength),x("has less length than allowed"),v("}"),"string"!==b&&v("}")),void 0!==n.minimum&&("number"!==b&&"integer"!==b&&v("if (%s) {",types.number(e)),v("if (%s %s %d) {",e,n.exclusiveMinimum?"<=":"<",n.minimum),x("is less than minimum"),v("}"),"number"!==b&&"integer"!==b&&v("}")),void 0!==n.maximum&&("number"!==b&&"integer"!==b&&v("if (%s) {",types.number(e)),v("if (%s %s %d) {",e,n.exclusiveMaximum?">=":">",n.maximum),x("is more than maximum"),v("}"),"number"!==b&&"integer"!==b&&v("}")),y&&Object.keys(y).forEach(function(r){Array.isArray(b)&&-1!==b.indexOf("null")&&v("if (%s !== null) {",e),h(genobj(e,r),y[r],u,c,p.concat(j?r:["properties",r])),Array.isArray(b)&&-1!==b.indexOf("null")&&v("}")});O--;)v("}")},v=genfun("function validate(data) {")("if (data === undefined) data = null")("validate.errors = null")("var errors = 0");return h("data",e,n,i&&i.filter,[]),v("return errors === 0")("}"),(v=v.toFunction(o)).errors=null,Object.defineProperty&&Object.defineProperty(v,"error",{get:function(){return v.errors?v.errors.map(function(e){return e.field+" "+e.message}).join("\n"):""}}),v.toJSON=function(){return e},v};module.exports=function(e,r){return"string"==typeof e&&(e=JSON.parse(e)),compile(e,{},e,!0,r)},module.exports.filter=function(e,r){var t=module.exports(e,xtend(r,{filter:!0}));return function(e){return t(e),e}}; + +},{"./formats":303,"generate-function":236,"generate-object-property":237,"jsonpointer":317,"xtend":834}],305:[function(require,module,exports){ +const Validator=require("is-my-json-valid"),getContent=require("ssb-msg-content");function stringify(r){return r?r.map(r=>{if(r.field&&r.message){let e=`${r.field} ${r.message}`;return r.message.endsWith("has additional properties")&&(e+=` (${r.value})`),e}return r.toString()}).join("; "):""}module.exports=function(r,e=[]){if(!Array.isArray(e))throw new Error("BuildValidator extras should be an Array");const t=Validator(r,{verbose:!0});return function r(n){let o=t(getContent(n));return r.errors=t.errors,e.forEach(e=>{const t=e(getContent(n));!0!==t&&(r.errors||(r.errors=[]),r.errors.push(t),o=!1)}),r.errorsString=stringify(r.errors),o}}; + +},{"is-my-json-valid":304,"ssb-msg-content":739}],306:[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":254}],259:[function(require,module,exports){ +},{"../is-buffer/index.js":297}],307:[function(require,module,exports){ +"use strict";function isProperty(u){return/^[$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc][$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc0-9\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19b0-\u19c0\u19c8\u19c9\u19d0-\u19d9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f]*$/.test(u)}module.exports=isProperty; + +},{}],308:[function(require,module,exports){ "use strict";var has,$exec,isRegexMarker,badStringifier,callBound=require("call-bind/callBound"),hasToStringTag=require("has-tostringtag/shams")();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":108,"has-tostringtag/shams":205}],260:[function(require,module,exports){ +},{"call-bind/callBound":124,"has-tostringtag/shams":248}],309:[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)}; +"use strict";var forEach=require("for-each"),availableTypedArrays=require("available-typed-arrays"),callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),hasToStringTag=require("has-tostringtag/shams")(),gOPD=require("gopd"),g="undefined"==typeof globalThis?global:globalThis,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":43,"call-bind/callBound":108,"es-abstract/helpers/getOwnPropertyDescriptor":180,"foreach":192,"has-symbols":203}],261:[function(require,module,exports){ +},{"available-typed-arrays":45,"call-bind/callBound":124,"for-each":229,"gopd":242,"has-tostringtag/shams":248}],310:[function(require,module,exports){ module.exports={ "com.ac": true, "net.ac": true, @@ -2757,377 +2934,376 @@ module.exports={ "org.zm": true, "sch.zm": true } -},{}],262:[function(require,module,exports){ +},{}],311:[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":261}],263:[function(require,module,exports){ +},{"./data/sldMap.json":310}],312:[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){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}; +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,t){try{const r=crcCalculate(e);e.writeUInt32LE(r,3*FIELD_SIZE)}catch(e){return t(e)}writeFile(r,e,t)}function readFileAndCheckCRC(e,r){readFile(e,(e,t)=>{if(e)return r(e);if(t.length<16)return r(Error("file too short"));let i,l;try{i=t.readUInt32LE(3*FIELD_SIZE),t.writeUInt32LE(0,3*FIELD_SIZE),l=crcCalculate(t)}catch(e){return r(e)}if(0!==i&&l!==i)return r(Error("crc check failed"));r(null,t)})}function saveTypedArrayFile(e,r,t,i,l,n){if(n||(n=(e=>{e&&console.error(e)})),"number"!=typeof r)return n(Error("cannot save file "+e+" without version"));let a;try{const e=toBuffer(l),s=Math.min(1.1*i,l.length);(a=Buffer.alloc(4*FIELD_SIZE+s*l.BYTES_PER_ELEMENT)).writeUInt32LE(r,0),a.writeUInt32LE(t,FIELD_SIZE),a.writeUInt32LE(i,2*FIELD_SIZE),e.copy(a,4*FIELD_SIZE)}catch(e){return n(e)}calculateCRCAndWriteFile(a,e,n)}function loadTypedArrayFile(e,r,t){readFileAndCheckCRC(e,(e,i)=>{if(e)return t(e);let l,n,a,s;try{l=i.readUInt32LE(0),n=i.readUInt32LE(FIELD_SIZE),a=i.readUInt32LE(2*FIELD_SIZE);const c=i.slice(4*FIELD_SIZE);s=new r(c.buffer,c.offset,c.byteLength/(r===Float64Array?8:4))}catch(e){return t(e)}t(null,{version:l,offset:n,count:a,tarr:s})})}function savePrefixMapFile(e,r,t,i,l,n){if(n||(n=(e=>{e&&console.error(e)})),"number"!=typeof r)return n(Error("cannot save file "+e+" without version"));let a;try{const e=JSON.stringify(l);(a=Buffer.alloc(4*FIELD_SIZE+e.length)).writeUInt32LE(r,0),a.writeUInt32LE(t,FIELD_SIZE),a.writeUInt32LE(i,2*FIELD_SIZE),Buffer.from(e).copy(a,4*FIELD_SIZE)}catch(e){return n(e)}calculateCRCAndWriteFile(a,e,n)}function loadPrefixMapFile(e,r){readFileAndCheckCRC(e,(e,t)=>{if(e)return r(e);let i,l,n,a;try{i=t.readUInt32LE(0),l=t.readUInt32LE(FIELD_SIZE),n=t.readUInt32LE(2*FIELD_SIZE);const s=t.slice(4*FIELD_SIZE);a=JSON.parse(s)}catch(e){return r(e)}r(null,{version:i,offset:l,count:n,map:a})})}function saveBitsetFile(e,r,t,i,l){let n;try{i.trim(),n=i.words.length}catch(e){return l(e)}saveTypedArrayFile(e,r,t,n,i.words,l)}function loadBitsetFile(e,r){loadTypedArrayFile(e,Uint32Array,(e,t)=>{if(e)return r(e);const{version:i,offset:l,count:n,tarr:a}=t,s=new TypedFastBitSet;s.words=a,r(null,{version:i,offset:l,bitset:s})})}function listFiles(e,r){if("undefined"!=typeof window){new(require("idb-kv-store"))(e,{disableBroadcast:!0}).keys(r)}else{const t=require("fs");require("mkdirp")(e).then(()=>{t.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)}const EmptyFile={create(e){if("undefined"!=typeof window){new(require("idb-kv-store"))(e,{disableBroadcast:!0}).set("x","y",()=>{})}else{const r=require("fs");r.closeSync(r.openSync(e,"w"))}},exists(e,r){if("undefined"!=typeof window){new(require("idb-kv-store"))(e,{disableBroadcast:!0}).get("x",(e,t)=>{if(e)return r(null,!1);r(null,"y"===t)})}else{const t=require("fs");r(null,t.existsSync(e))}},delete(e,r){EmptyFile.exists(e,(t,i)=>{if(t)return r(t);i?EmptyFile._actuallyDelete(e,r):r(null)})},_actuallyDelete(e,r){if("undefined"!=typeof window){new(require("idb-kv-store"))(e,{disableBroadcast:!0}).remove("x",r)}else{r(null,require("rimraf").sync(e))}}};module.exports={saveTypedArrayFile:saveTypedArrayFile,loadTypedArrayFile:loadTypedArrayFile,savePrefixMapFile:savePrefixMapFile,loadPrefixMapFile:loadPrefixMapFile,saveBitsetFile:saveBitsetFile,loadBitsetFile:loadBitsetFile,listFiles:listFiles,EmptyFile:EmptyFile,safeFilename:safeFilename}; }).call(this)}).call(this,require("buffer").Buffer) -},{"atomic-file-rw":39,"buffer":101,"crc/lib/crc32":115,"fs":100,"idb-kv-store":241,"jsesc":267,"mkdirp":317,"sanitize-filename":529,"typedarray-to-buffer":683,"typedfastbitset":684}],264:[function(require,module,exports){ +},{"atomic-file-rw":41,"buffer":117,"crc/lib/crc32":135,"fs":116,"idb-kv-store":283,"jsesc":316,"mkdirp":367,"rimraf":583,"sanitize-filename":587,"typedarray-to-buffer":821,"typedfastbitset":822}],313:[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={ascending:new WeakMap,descending:new WeakMap},s=-1;const r=Status(),o={};let u=!1,f=[];const d=["seq","timestamp","sequence"];function p(e){u?e():f.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||(o[a]=t),n()}):"timestamp.index"===e?loadTypedArrayFile(path.join(t,e),Float64Array,(e,t)=>{e||(o[a]=t),n()}):"sequence.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||(o[a]=t),n()}):e.endsWith(".32prefix")?(o[a]={offset:-1,count:0,tarr:new Uint32Array(16e3),lazy:!0,prefix:32,filepath:path.join(t,e)},n()):e.endsWith(".32prefixmap")?(o[a]={offset:-1,count:0,map:{},lazy:!0,prefix:32,filepath:path.join(t,e)},n()):e.endsWith(".index")?(o[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(o)),o.seq||(o.seq={offset:-1,count:0,tarr:new Uint32Array(16e3),version:1}),o.timestamp||(o.timestamp={offset:-1,count:0,tarr:new Float64Array(16e3),version:1}),o.sequence||(o.sequence={offset:-1,count:0,tarr:new Uint32Array(16e3),version:1}),r.update(o,d),u=!0;for(let e=0;es&&(s=e.since.value,m())}function h(e,n,a,i){if(n.offset<0)return;debug("saving core index: %s",e);const s=path.join(t,e+".index");saveTypedArrayFile(s,n.version,n.offset,a,n.tarr,i)}function b(e,n,a,i){n.prefix&&n.map?function(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)}(e,n,a,i):n.prefix?function(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)}(e,n,a,i):function(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)}(e,n,i)}function x(e,t){debug("growing index");const n=new t(2*e.tarr.length);n.set(e.tarr),e.tarr=n}function v(e,t){if(e>o.seq.count-1)return e>o.seq.tarr.length-1&&x(o.seq,Uint32Array),o.seq.offset=t,o.seq.tarr[e]=t,o.seq.count=e+1,!0}function E(e,t){var n=0;n=bipf.seekKey(e,n,c);const a=bipf.decode(e,n);n=bipf.seekKey(e,t,c);const i=bipf.decode(e,n);return Math.min(a,i)}function q(e,t){var n=bipf.seekKey(e,t,l);return bipf.decode(e,n)}function T(e,t,n,a){if(e>o.timestamp.count-1){e>o.timestamp.tarr.length-1&&x(o.timestamp,Float64Array),o.timestamp.offset=t;const i=E(n,a);return o.timestamp.tarr[e]=i,o.timestamp.count=e+1,!0}}function w(e,t,n,a){if(e>o.sequence.count-1){e>o.sequence.tarr.length-1&&x(o.sequence,Uint32Array),o.sequence.offset=t;const i=q(n,a);return o.sequence.tarr[e]=i,o.sequence.count=e+1,!0}}function S(e){if(-1===e)return 0;const{tarr:t,count:n}=o.seq,a=bsb.eq(t,e,0,n-1);return a<0?0:a}const A=bipf.allocAndEncode(void 0);function N(e,t,n){const a=e.seek(t,0,n);return!(-1!==a||!e.value.equals(A))||0===bipf.compare(t,a,e.value,0)}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.compare(t,s,e.value,0))return n=!0,!0}),n}return N(e,t,n)}function L(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 B(e,t,n,a,i,s){if(a>t.count-1){const r=e.seek(n,0,s);if(~r){const i=bipf.slice(n,r);if(i.length){const n=L(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 O(e,t,n,a,i,s){if(a>t.count-1){a>t.tarr.length-1&&x(t,Uint32Array);const r=e.seek(n,0,s);if(~r){const i=bipf.slice(n,r);t.tarr[a]=i.length?L(i,e.prefixOffset):0}else t.tarr[a]=0;t.offset=i,t.count=a+1}}function U(e,t,n,a,i){"EQUAL"===e.type&&N(e.data,n,i)?t.bitset.add(a):"PREDICATE"===e.type&&k(e.data,n,i)?t.bitset.add(a):"ABSENT"===e.type&&$(e.data,n,i)?t.bitset.add(a):"INCLUDES"===e.type&&M(e.data,n,i)&&t.bitset.add(a)}function Q(e,t,n){if(e.has(t))return e.get(t).push(n),!0;e.set(t,[])}function I(e,t){e.get(t).forEach(e=>e()),e.delete(t)}const R=new Map;const z=new Map;function C(t,n){const a={},i=t.map(e=>e.data.indexName),s=i.join("|");if(Q(z,s,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 u=0,f=!1,p=!1,c=!1;const l=Date.now();let m=l;function g(e,t,n){const i=multicb({pluck:1});for(var s in f&&h("seq",o.seq,e,i()),p&&h("timestamp",o.timestamp,e,i()),c&&h("sequence",o.sequence,e,i()),a){const e=a[s];n&&(o[s]=e),e.offset=t}i(()=>{for(var t in a){b(t,a[t],e)}})}const x=Math.ceil(1e3*Math.random());debug(`log.stream #${x} started, to create indexes ${s}`),r.update(o,d),r.update(a,i),e.stream({}).pipe({paused:!1,write:function(e){const n=e.offset,s=e.value;if(v(u,n)&&(f=!0),!s)return void u++;const l=bipf.seekKey(s,0,y);if(T(u,n,s,l)&&(p=!0),w(u,n,s,l)&&(c=!0),t.forEach(e=>{e.data.prefix&&e.data.useMap?B(e.data,a[e.data.indexName],s,u,n,l):e.data.prefix?O(e.data,a[e.data.indexName],s,u,n,l):e.data.indexAll?function(e,t,n,a,i){const s=e.seek(n,0,i),r=bipf.decode(n,s),o=safeFilename(e.indexType+"_"+r);t[o]||(t[o]={offset:0,bitset:new TypedFastBitSet,version:e.version||1}),t[o].bitset.add(a)}(e.data,a,s,u,l):U(e,a[e.data.indexName],s,u,l)}),u%1e3==0){r.update(o,d),r.update(a,i);const e=Date.now();e-m>=6e4&&(m=e,g(u,n,!1))}u++},end:()=>{const e=u;debug(`log.stream #${x} done ${e} records in ${Date.now()-l}ms`),g(e,o.seq.offset,!0),r.update(o,d),r.update(a,i),r.done(d),r.done(i),I(z,s),n()}})}const P=new Map;function j(e,t){if(Q(P,e,t))return;debug("lazy loading %s",e);let n=o[e];n.prefix&&n.map?loadPrefixMapFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete o[e],t();const{version:s,offset:r,count:u,map:f}=i;n.version=s,n.offset=r,n.count=u,n.map=f,n.lazy=!1,I(P,e),t()}):n.prefix?loadTypedArrayFile(n.filepath,Uint32Array,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete o[e],t();const{version:s,offset:r,count:u,tarr:f}=i;n.version=s,n.offset=r,n.count=u,n.tarr=f,n.lazy=!1,I(P,e),t()}):loadBitsetFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),delete o[e],t();const{version:s,offset:r,bitset:u}=i;n.version=s,n.offset=r,n.bitset=u,n.lazy=!1,I(P,e),t()})}function W(t,n){const a=o[t.data.indexName];e.since.value>a.offset||t.data.version>a.version?function(t,n){const a=o[t.data.indexName],i=[...d,t.data.indexName],s=t.data.indexName;if(Q(R,s,n))return;t.data.version>a.version&&(a.offset=-1,a.count=0);let u=-1===a.offset?0:S(a.offset)+1,f=!1,p=!1,c=!1;const l=u,m=Date.now();let g=m;const x=!d.includes(t.data.indexName);function E(e,n){const i=multicb({pluck:1});f&&h("seq",o.seq,e,i()),p&&h("timestamp",o.timestamp,e,i()),c&&h("sequence",o.sequence,e,i()),a.offset=n,t.data.version>a.version&&(a.version=t.data.version),x&&i(()=>{b(t.data.indexName,a,e)})}const q=Math.ceil(1e3*Math.random());debug(`log.stream #${q} started, to update index ${s}`),r.update(o,i),e.stream({gt:a.offset}).pipe({paused:!1,write:function(e){const n=e.offset,s=e.value;if(v(u,n)&&(f=!0),!s)return void u++;const d=bipf.seekKey(s,0,y);if(T(u,n,s,d)&&(p=!0),w(u,n,s,d)&&(c=!0),x&&(t.data.prefix&&t.data.useMap?B(t.data,a,s,u,n,d):t.data.prefix?O(t.data,a,s,u,n,d):U(t,a,s,u,d)),u%1e3==0){r.update(o,i);const e=Date.now();e-g>=6e4&&(g=e,E(u,n))}u++},end:()=>{const e=u;debug(`log.stream #${q} done ${u-l} records in ${Date.now()-m}ms`),E(e,o.seq.offset),r.update(o,i),r.done(i),I(R,s),n()}})}(t,n):(debug("ensureIndexSync %s is already synced",t.data.indexName),n())}function G(e){W({data:{indexName:"seq"}},e)}function _(e,t,n){W(e,()=>{if("sequence"===e.data.indexName){const a=new TypedFastBitSet,{tarr:i,count:s}=o.sequence;for(let n=0;n{const t=new TypedFastBitSet,{count:n}=o.sequence;t.addRange(0,n),e(t)})}function V(e,t){let n=e[0];return e.slice(1).forEach(e=>{n={type:t,data:[n,e]}}),n}function H(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("ABSENT"===e.type)return`ABSENT(${e.data.indexType})`;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=V(e.data,"AND"));const t=H(e.data[0]),n=H(e.data[1]);return t?n?`AND(${t},${n})`:t:n}if("OR"===e.type){e.data.length>2&&(e=V(e.data,"AND"));const t=H(e.data[0]),n=H(e.data[1]);return t?n?`OR(${t},${n})`:t:n}return"NOT"===e.type?`NOT(${H(e.data[0])})`:"*"}function J(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 X(e,t){"EQUAL"===e.type||"INCLUDES"===e.type||"PREDICATE"===e.type||"ABSENT"===e.type?e.data.prefix?W(e,()=>{!function(e,t,n){const a=e.data.value,i=a?L(bipf.slice(a,0),e.data.prefixOffset):0,s=new TypedFastBitSet,r=new Map,o=e.data.seek;function u(e){if(!e)return!1;const t=bipf.seekKey(e,0,y),n=o(e,0,t);return a?0===bipf.compare(e,n,a,0):!~n}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(o[e.data.indexName].bitset)}):"GT"===e.type?_(e,(e,t)=>e>t.data.value,t):"GTE"===e.type?_(e,(e,t)=>e>=t.data.value,t):"LT"===e.type?_(e,(e,t)=>ee<=t.data.value,t):"OFFSETS"===e.type?G(()=>{!function(e,t){const n=[];e.sort((e,t)=>e-t);const a=e.length,{tarr:i,count:s}=o.seq;for(let t=0;t{t(new TypedFastBitSet(e.seqs))}):"LIVESEQS"===e.type?t(new TypedFastBitSet):"AND"===e.type?(e.data.length>2&&(e=V(e.data,"AND")),X(e.data[0],(n,a)=>{X(e.data[1],(e,i)=>{t(n.new_intersection(e),J(a,i))})})):"OR"===e.type?(e.data.length>2&&(e=V(e.data,"OR")),X(e.data[0],(n,a)=>{X(e.data[1],(e,i)=>{t(n.new_union(e),J(a,i))})})):"NOT"===e.type?X(e.data[0],(e,n)=>{K(a=>{t(a.difference(e),n)})}):e.type?console.error("Unknown type",e):K(t)}function Y(e,t){!function e(n){n.forEach(n=>{"EQUAL"===n.type||"INCLUDES"===n.type||"PREDICATE"===n.type||"ABSENT"===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 Z(e,t){if(g(),n.has(e))return t(null,n.get(e));push(push.values([null]),push.asyncMap((t,n)=>{const a=function(e){const t=[];return Y(e,e=>{const n=e.data.indexName;o[n]&&o[n].lazy&&t.push(n)}),t}(e);if(0===a.length)return n();push(push.values(a),push.asyncMap(j),push.collect(n))}),push.asyncMap((t,n)=>{const a=function(e){const t=[];return Y(e,e=>{o[e.data.indexName]||t.push(e)}),t}(e);if(0===a.length)return n();debug("missing indexes: %o",a),C(a,n)}),push.asyncMap((e,t)=>G(t)),push.asyncMap((t,a)=>{X(e,(t,i)=>{n.set(e,[t,i]),a(null,[t,i])})}),push.collect((e,n)=>{e?t(e):t(null,n[0])}))}function ee(t,n){const a=o.seq.tarr[t];e.get(a,(e,i)=>{e&&"ERR_AAOL_DELETED_RECORD"===e.code?n(null,{seq:t,offset:a}):e?n(e):n(null,{offset:a,value:i,seq:t})})}function te(e,t){return t.timestamp>e.timestamp}function ne(e,t){return e.timestamp>t.timestamp}function ae(e,t){return t.seq>e.seq}function ie(e,t){return e.seq>t.seq}function se(e,t,n,a){const i=t.get(e);if(!i)return a(null,e);ee(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 re(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({seq:e,timestamp:o.timestamp.tarr[e]}))),r[s].set(e,f),f}(t,u,d),l=c.size,y={};function m(t,n){push(push.values(t),push.asyncMap((t,n)=>{f?n(null,o.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=o.seq.tarr[t];e.get(i,(e,t)=>{e&&"ERR_AAOL_DELETED_RECORD"===e.code?a():e?a(e):a(null,bipf.decode(t,0))})}(t,y,n)}),push.filter(e=>!!f||e),push.collect((e,t)=>{p(e,{results:t,total:n})}))}if(n){function h(e,t,a,i){const s=multicb({pluck:1});for(let e=0;e(function e(t,n,a){if(t)return p(t);const i=a.length;a=a.filter(e=>void 0!==e);const s=n+a.lengthe(t,n+i,a)):m(a,l)})(e,s,t))}else{m(re(c,s,r).map(e=>e.seq),l)}}return{onReady:p,paginate:function(e,t,n,a,i,s,r){p(()=>{const o=Date.now();Z(e,(u,f)=>{if(u)return r(u);const[d,p]=f;oe(d,p,t,n,a,i,s,(a,i)=>{a?r(a):(i.duration=Date.now()-o,debugQuery.enabled&&debugQuery(`paginate(${H(e)}), seq: ${t}, limit: ${n}: ${i.duration}ms, total messages: ${i.total}`.replace(/%/g,"%% ")),r(null,i))})})})},all:function(e,t,n,a,i,s){p(()=>{const r=Date.now();Z(e,(o,u)=>{if(o)return s(o);const[f,d]=u;oe(f,d,t,1/0,n,a,i,(t,n)=>{t?s(t):(n.duration=Date.now()-r,debugQuery.enabled&&debugQuery(`all(${H(e)}): ${n.duration}ms, total messages: ${n.total}`.replace(/%/g,"%% ")),s(null,n.results))})})})},count:function(e,t,n,a){p(()=>{const n=Date.now();Z(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(${H(e)}): ${u}ms, total messages: ${o}`.replace(/%/g,"%% ")),a(null,o)})})},prepare:function(e,t){p(()=>{const n=Date.now(),a=[],i={};Y(e,e=>{const t=e.data.indexName;o[t]||(a.push(t),i[t]={offset:-1})}),r.update(i,a),Z(e,e=>{if(e)return t(e);const a=Date.now()-n;t(null,a)})})},lookup:function(e,t,n){const a="string"==typeof e?{data:{indexName:e}}:e;p(()=>{const e=a.data.indexName;return o[e]?o[e].lazy?n(new Error(`Cannot lookup, index ${e} not loaded`)):void W(a,()=>{const a=o[e].tarr[t];n(null,a)}):n(new Error(`Cannot lookup, index ${e} not found`))})},live:function(t){return pull(pullAsync(e=>p(()=>{Z(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||"ABSENT"===t.type)i=o[t.data.indexName]?o[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)=>{G(()=>{ee(e,t)})}));else{const t=-1===i?{live:!0,gt:o.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){const i=bipf.seekKey(n,0,y);for(let s=0;s{debugQuery.enabled&&debugQuery(`live(${H(t)}): 1 new msg`.replace(/%/g,"%% "))}),pull.map(e=>bipf.decode(e.value,0)))},status:r.obv,reindex:function(e,t){let n=0,a=0;function i(e){if(e.offset>=a){if(e.count&&(e.count=n),e.map)for(let[t,a]of Object.entries(e.map))e.map[t]=a.filter(e=>e{if(d.includes(e))return a();t.lazy?j(e,s=>{if(s)return a(s);i(t),b(e,t,n),a()}):(i(t),b(e,t,n),a())}),push.collect(e=>{if(e)return t(e);m(),t()}))},indexes:o}}; +const path=require("path"),bipf=require("bipf"),push=require("push-stream"),pull=require("pull-stream"),mutexify=require("mutexify"),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"),Obv=require("obz"),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,listFiles:listFiles,EmptyFile:EmptyFile}=require("./files");module.exports=function(e,t){debug("indexes path",t);let n=new WeakMap,a={ascending:new WeakMap,descending:new WeakMap},i={ascending:new WeakMap,descending:new WeakMap},s=-1;const r=Status(),o=new Map;let u,f,d,p=!1;const l=new Set;let c=!1,y=null;const m=path.join(t,"post-compact-reindex"),g=new Set,h=["seq","timestamp","sequence"],v=Obv().set(0),b=Obv().set(0);var x;function E(e){p?e():l.add(e)}x=(()=>{debug("loaded indexes",[...o.keys()]),o.has("seq")||o.set("seq",{offset:-1,count:0,tarr:new Uint32Array(16e3),version:1}),o.has("timestamp")||o.set("timestamp",{offset:-1,count:0,tarr:new Float64Array(16e3),version:1}),o.has("sequence")||o.set("sequence",{offset:-1,count:0,tarr:new Uint32Array(16e3),version:1}),u=o.get("seq"),f=o.get("timestamp"),d=o.get("sequence"),r.update(o,h),p=!0;for(const e of l)e();l.clear()}),listFiles(t,function(e,n){push(push.values(n),push.asyncMap((e,n)=>{const a=path.parse(e).name;"seq.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||o.set(a,t),n()}):"timestamp.index"===e?loadTypedArrayFile(path.join(t,e),Float64Array,(e,t)=>{e||o.set(a,t),n()}):"sequence.index"===e?loadTypedArrayFile(path.join(t,e),Uint32Array,(e,t)=>{e||o.set(a,t),n()}):e.endsWith(".32prefix")?(o.set(a,{offset:-1,count:0,tarr:new Uint32Array(16e3),lazy:!0,prefix:32,filepath:path.join(t,e)}),n()):e.endsWith(".32prefixmap")?(o.set(a,{offset:-1,count:0,map:{},lazy:!0,prefix:32,filepath:path.join(t,e)}),n()):e.endsWith(".index")?(o.set(a,{offset:0,bitset:new TypedFastBitSet,lazy:!0,filepath:path.join(t,e)}),n()):n()}),push.collect(x))}),e.compactionProgress(e=>{if("number"==typeof e.startOffset&&null===y&&(y=e.startOffset),e.done||c){if(e.done&&c){c=!1;const n=y||0;function t(){EmptyFile.delete(m,()=>{if(0!==g.size){for(const e of g)e();g.clear()}})}y=null,e.sizeDiff>0?EmptyFile.exists(m,(e,a)=>{a?ye(n,e=>{e&&console.error("reindex jitdb after compact",e),t()}):t()}):t()}}else c=!0,EmptyFile.create(m)});const T=bipf.allocAndEncode("timestamp"),A=bipf.allocAndEncode("sequence"),w=bipf.allocAndEncode("value"),S=bipf.allocAndEncode("key");function N(){n=new WeakMap,a.ascending=new WeakMap,a.descending=new WeakMap,i.ascending=new WeakMap,i.descending=new WeakMap}function F(){e.since.value>s&&(s=e.since.value,N())}function q(e,n,a,i){if(n.offset<0)return;debug("saving core index: %s",e);const s=path.join(t,e+".index");saveTypedArrayFile(s,n.version,n.offset,a,n.tarr,i)}function k(e,n,a,i){n.prefix&&n.map?function(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)}(e,n,a,i):n.prefix?function(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)}(e,n,a,i):function(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)}(e,n,i)}function D(e,t){debug("growing index %s",e.name);const n=new t(2*e.tarr.length);n.set(e.tarr),e.tarr=n}function M(e,t){const n=bipf.seekKey2(e,0,T,0),a=bipf.decode(e,n),i=bipf.seekKey2(e,t,T,0),s=bipf.decode(e,i);return Math.min(a,s)}function $(e,t){const n=bipf.seekKey2(e,t,A,0);return bipf.decode(e,n)}function L(e){if(-1===e)return-1;const{tarr:t,count:n}=u;if(t[n-1]===e)return n-1;const a=bsb.eq(t,e,0,n-1);return a<0?0:a}const O=bipf.allocAndEncode(void 0);function U(e,t,n){const a=e.seek(t,0,n);return!(-1!==a||!e.value.equals(O))||0===bipf.compare(t,a,e.value,0)}function Q(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.compare(t,s,e.value,0))return n=!0,!0}),n}return U(e,t,n)}function z(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 C(e,t,n,a,i,s){if(a>t.count-1){const r=e.seek(n,0,s);if(~r){const i=bipf.slice(n,r);if(i.length){const n=z(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 j(e,t,n,a,i,s){if(a>t.count-1){a>t.tarr.length-1&&D(t,Uint32Array);const r=e.seek(n,0,s);if(~r){const i=bipf.slice(n,r);t.tarr[a]=i.length?z(i,e.prefixOffset):0}else t.tarr[a]=0;t.offset=i,t.count=a+1}}function W(e,t,n,a,i){"EQUAL"===e.type&&U(e.data,n,i)?t.bitset.add(a):"PREDICATE"===e.type&&R(e.data,n,i)?t.bitset.add(a):"ABSENT"===e.type&&I(e.data,n,i)?t.bitset.add(a):"INCLUDES"===e.type&&P(e.data,n,i)&&t.bitset.add(a)}function G(e,t,n,a,i){const s=e.seek(n,0,i),r=bipf.decode(n,s),o=safeFilename(e.indexType+"_"+r);t.has(o)||t.set(o,{offset:0,bitset:new TypedFastBitSet,version:e.version||1}),t.get(o).bitset.add(a)}function K(e,t){e.get(t).forEach(e=>e()),e.delete(t)}const _=mutexify();function V(t,n){_(function(a){const i=t.filter(e=>o.has(e.data.indexName)).map(e=>(h.includes(e.data.indexName)&&(e.isCore=!0),e)),s=t.filter(e=>!o.has(e.data.indexName)),p=i.map(e=>e.data.indexName),l=s.map(e=>e.data.indexName),c=[...h,...p];for(const e of i){const t=o.get(e.data.indexName);e.data.version>t.version&&(t.offset=-1,t.count=0)}const y=new Map;for(const e of s)e.data.prefix&&e.data.useMap?y.set(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?y.set(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}):y.set(e.data.indexName,{offset:0,bitset:new TypedFastBitSet,version:e.data.version||1});const m=s.length>0?-1:Math.min(...p.map(e=>o.get(e).offset));if(m===e.since.value&&m>=0)return void a(n);let g=L(m)+1,b=!1,x=!1,E=!1;const T=g,A=Date.now();let S=A;function N(e,t,n){const a=multicb({pluck:1});b&&q("seq",u,e,a()),x&&q("timestamp",f,e,a()),E&&q("sequence",d,e,a());for(const e of i){const n=e.data.indexName,a=o.get(n);a.offseta.version&&(a.version=e.data.version))}for(const[e,a]of y)a.offset=t,n&&o.set(e,a);a(()=>{for(const t of i){if(t.isCore)continue;const n=t.data.indexName;k(n,o.get(n),e)}for(const[t,n]of y)k(t,n,e)})}const F=Math.ceil(1e3*Math.random());debug(`log.stream #${F} started, updating indexes ${p.concat(l).join("|")} from offset ${m}`),r.update(o,c),r.update(y,l),v.set(v.value+1),e.stream({gt:m}).pipe({paused:!1,write(e){const t=e.offset,n=e.value;if(function(e,t){if(e>u.count-1)return e>u.tarr.length-1&&D(u,Uint32Array),u.tarr[e]=t,u.offset=t,u.count=e+1,!0}(g,t)&&(b=!0),!n)return void g++;const a=bipf.seekKey2(n,0,w,0);(function(e,t,n,a){if(e>f.count-1)return e>f.tarr.length-1&&D(f,Float64Array),f.tarr[e]=M(n,a),f.offset=t,f.count=e+1,!0})(g,t,n,a)&&(x=!0),function(e,t,n,a){if(e>d.count-1)return e>d.tarr.length-1&&D(d,Uint32Array),d.tarr[e]=$(n,a),d.offset=t,d.count=e+1,!0}(g,t,n,a)&&(E=!0);for(const e of i){if(e.isCore)continue;const i=o.get(e.data.indexName);e.data.prefix&&e.data.useMap?C(e.data,i,n,g,t,a):e.data.prefix?j(e.data,i,n,g,t,a):W(e,i,n,g,a)}for(const e of s){const i=y.get(e.data.indexName);e.data.prefix&&e.data.useMap?C(e.data,i,n,g,t,a):e.data.prefix?j(e.data,i,n,g,t,a):e.data.indexAll?G(e.data,y,n,g,a):W(e,i,n,g,a)}if(g%1e3==0){r.update(o,c),r.update(y,l);const e=Date.now();e-S>=6e4&&(S=e,N(g+1,t,!1))}g++},end(){debug(`log.stream #${F} ended, scanned ${g-T} records in ${Date.now()-A}ms`),N(g,u.offset,!0),r.update(o,c),r.update(y,l),r.done(c),r.done(l),v.set(v.value-1),a(n)}})})}const H=new Map;function J(e,t){if(function(e,t,n){if(e.has(t))return e.get(t).push(n),!0;e.set(t,[])}(H,e,t))return;debug("lazy loading %s",e);let n=o.get(e);n.prefix&&n.map?loadPrefixMapFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),o.delete(e),t();const{version:s,offset:r,count:u,map:f}=i;n.version=s,n.offset=r,n.count=u,n.map=f,n.lazy=!1,K(H,e),t()}):n.prefix?loadTypedArrayFile(n.filepath,Uint32Array,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),o.delete(e),t();const{version:s,offset:r,count:u,tarr:f}=i;n.version=s,n.offset=r,n.count=u,n.tarr=f,n.lazy=!1,K(H,e),t()}):loadBitsetFile(n.filepath,(a,i)=>{if(a)return debug("index %s failed to load with %s",e,a),o.delete(e),t();const{version:s,offset:r,bitset:u}=i;n.version=s,n.offset=r,n.bitset=u,n.lazy=!1,K(H,e),t()})}function X(t,n){const a=o.get(t.data.indexName);e.since.value>a.offset||t.data.version>a.version?V([t],n):n()}function Y(e,t,n){if("sequence"===e.data.indexName){const a=new TypedFastBitSet,{tarr:i,count:s}=d;for(let n=0;n{n={type:t,data:[n,e]}}),n}function te(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("ABSENT"===e.type)return`ABSENT(${e.data.indexType})`;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=ee(e.data,"AND"));const t=te(e.data[0]),n=te(e.data[1]);return t?n?`AND(${t},${n})`:t:n}if("OR"===e.type){e.data.length>2&&(e=ee(e.data,"AND"));const t=te(e.data[0]),n=te(e.data[1]);return t?n?`OR(${t},${n})`:t:n}return"NOT"===e.type?`NOT(${te(e.data[0])})`:"*"}function ne(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 ae(e,t){"EQUAL"===e.type||"INCLUDES"===e.type||"PREDICATE"===e.type||"ABSENT"===e.type?e.data.prefix?function(e,t,n){const a=e.data.value,i=a?z(bipf.slice(a,0),e.data.prefixOffset):0,s=new TypedFastBitSet,r=new Map,o=e.data.seek;function u(e){if(!e)return!1;const t=bipf.seekKey2(e,0,w,0),n=o(e,0,t);return a?0===bipf.compare(e,n,a,0):!~n}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;te>t.data.value,t):"GTE"===e.type?Y(e,(e,t)=>e>=t.data.value,t):"LT"===e.type?Y(e,(e,t)=>ee<=t.data.value,t):"OFFSETS"===e.type?function(e,t){const n=[];e.sort((e,t)=>e-t);const a=e.length,{tarr:i,count:s}=u;for(let t=0;t2&&(e=ee(e.data,"AND")),ae(e.data[0],(n,a)=>{ae(e.data[1],(e,i)=>{t(n.new_intersection(e),ne(a,i))})})):"OR"===e.type?(e.data.length>2&&(e=ee(e.data,"OR")),ae(e.data[0],(n,a)=>{ae(e.data[1],(e,i)=>{t(n.new_union(e),ne(a,i))})})):"NOT"===e.type?ae(e.data[0],(e,n)=>{Z(a=>{t(a.difference(e),n)})}):e.type?console.error("Unknown type",e):Z(t)}function ie(e,t){!function e(n){n.forEach(n=>{"EQUAL"===n.type||"INCLUDES"===n.type||"PREDICATE"===n.type||"ABSENT"===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 se(e,t){if(F(),n.has(e))return t(null,n.get(e));push(push.values([null]),push.asyncMap((t,n)=>{const a=function(e){const t=[];return ie(e,e=>{const n=e.data.indexName;o.has(n)&&o.get(n).lazy&&t.push(n)}),t}(e);if(0===a.length)return n();push(push.values(a),push.asyncMap(J),push.collect(n))}),push.asyncMap((t,n)=>{const a=[];a.push({data:{indexName:"seq"}}),ie(e,e=>{a.push(e)}),V(a,n)}),push.asyncMap((t,a)=>{ae(e,(t,i)=>{n.set(e,[t,i]),a(null,[t,i])})}),push.collect((e,n)=>{e?t(e):t(null,n[0])}))}function re(t,n){const a=u.tarr[t];e.get(a,(e,i)=>{e&&"ERR_AAOL_DELETED_RECORD"===e.code?n(null,{seq:t,offset:a}):e?n(e):n(null,{offset:a,value:i,seq:t})})}function oe(e,t){return t.timestamp>e.timestamp}function ue(e,t){return e.timestamp>t.timestamp}function fe(e,t){return t.seq>e.seq}function de(e,t){return e.seq>t.seq}function pe(e,t,n,a){const i=t.get(e);if(!i)return a(null,e);re(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 le(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({seq:e,timestamp:f.tarr[e]}))),r[s].set(e,u),u}(t,o,p),y=c.size,m={};function g(t){push(push.values(t),push.asyncMap((t,n)=>{d?n(null,u.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=u.tarr[t];e.get(i,(e,t)=>{e&&"ERR_AAOL_DELETED_RECORD"===e.code?a():e?a(e):a(null,bipf.decode(t,0))})}(t,m,n)}),push.filter(e=>!!d||e),push.collect((e,n)=>{const a=t.length||r;l(e,{results:n,total:y,nextSeq:s+a})}))}if(n){function h(e,t,a,i){const s=multicb({pluck:1});for(let e=0;e(function e(t,n,a){if(t)return l(t);const i=a.length;a=a.filter(e=>void 0!==e);const s=n+a.lengthe(t,n+i,a)):g(a)})(e,s,t))}else{g(le(c,s,r).map(e=>e.seq))}}function ye(e,t){let n=0,a=0;function i(e){if(e.offset>=a){if(e.count&&(e.count=n),e.map)for(let[t,a]of Object.entries(e.map))0===n?e.map[t].length=0:e.map[t]=a.filter(e=>e{h.includes(e)?(i(t),q(e,t,n),a()):t.lazy?J(e,s=>{if(s)return a(s);i(t),k(e,t,n),a()}):(i(t),k(e,t,n),a())}),push.collect(e=>{if(e)return t(e);N(),t()}))}return{onReady:E,paginate:function t(n,a,i,s,r,o,u,f){e.compactionProgress.value.done?(b.set(b.value+1),E(()=>{const e=Date.now();se(n,(t,u)=>{if(t)return f(t);const[d,p]=u;ce(d,p,a,i,s,r,o,(t,s)=>{if(b.set(b.value-1),t)return f(t);s.duration=Date.now()-e,debugQuery.enabled&&debugQuery(`paginate(${te(n)}), seq: ${a}, limit: ${i}: ${s.duration}ms, total messages: ${s.total}`.replace(/%/g,"%% ")),f(null,s)})})})):g.add(()=>{u?function(t,n){let a=0;e.stream({offsets:!1,values:!0,decrypt:!1}).pipe(push.drain(function(e){if(!e)return void(a+=1);const i=bipf.seekKey2(e,0,S,0);if(bipf.decode(e,i)===t)return n(null,a),!1;a+=1},function(){n(new Error("msgKey not found"))}))}(u,(e,a)=>{if(e)return f(e);t(n,a+1,i,s,r,o,null,f)}):t(n,a,i,s,r,o,null,f)})},all:function t(n,a,i,s,r,o){e.compactionProgress.value.done?(b.set(b.value+1),E(()=>{const e=Date.now();se(n,(t,u)=>{if(t)return o(t);const[f,d]=u;ce(f,d,a,1/0,i,s,r,(t,a)=>{if(b.set(b.value-1),t)return o(t);a.duration=Date.now()-e,debugQuery.enabled&&debugQuery(`all(${te(n)}): ${a.duration}ms, total messages: ${a.total}`.replace(/%/g,"%% ")),o(null,a.results)})})})):g.add(()=>t(n,a,i,s,r,o))},count:function t(n,a,i,s){e.compactionProgress.value.done?(b.set(b.value+1),E(()=>{const e=Date.now();se(n,(t,i)=>{if(b.set(b.value-1),t)return s(t);const[r]=i,o=function(e,t,n){return t?e.size()-t:e.size()}(r,a),u=Date.now()-e;debugQuery.enabled&&debugQuery(`count(${te(n)}): ${u}ms, total messages: ${o}`.replace(/%/g,"%% ")),s(null,o)})})):g.add(()=>t(n,a,i,s))},prepare:function t(n,a){e.compactionProgress.value.done?(b.set(b.value+1),E(()=>{const e=Date.now(),t=[],i=new Map;ie(n,e=>{const n=e.data.indexName;o.has(n)||(t.push(n),i.set(n,{offset:-1}))}),r.update(i,t),se(n,t=>{if(b.set(b.value-1),t)return a(t);const n=Date.now()-e;a(null,n)})})):g.add(()=>t(n,a))},lookup:function(e,t,n){const a="string"==typeof e?{data:{indexName:e}}:e;E(()=>{const e=a.data.indexName;return o.has(e)?o.get(e).lazy?n(new Error(`Cannot lookup, index ${e} not loaded`)):void X(a,()=>{const a=o.get(e).tarr[t];n(null,a)}):n(new Error(`Cannot lookup, index ${e} not found`))})},live:function(t){return pull(pullAsync(e=>E(()=>{se(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||"ABSENT"===t.type)i=o.has(t.data.indexName)?o.get(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)=>{X({data:{indexName:"seq"}},()=>{re(e,t)})}));else{const t=-1===i?{live:!0,gt:u.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){if(!n)return!1;const i=bipf.seekKey2(n,0,w,0);for(let s=0;s{debugQuery.enabled&&debugQuery(`live(${te(t)}): 1 new msg`.replace(/%/g,"%% "))}),pull.map(e=>bipf.decode(e.value,0)))},status:r.obv,reindex:ye,indexingActive:v,queriesActive:b,indexes:o}}; }).call(this)}).call(this,require("buffer").Buffer) -},{"./files":263,"./status":266,"binary-search-bounds":52,"bipf":53,"buffer":101,"debug":134,"fastpriorityqueue":184,"multicb":326,"path":373,"pull-async":404,"pull-stream":438,"push-stream":487,"push-stream-to-pull-stream":484,"typedfastbitset":684}],265:[function(require,module,exports){ +},{"./files":312,"./status":315,"binary-search-bounds":60,"bipf":65,"buffer":117,"debug":154,"fastpriorityqueue":221,"multicb":376,"mutexify":386,"obz":408,"path":423,"pull-async":460,"pull-stream":494,"push-stream":544,"push-stream-to-pull-stream":541,"typedfastbitset":822}],314:[function(require,module,exports){ (function (Buffer){(function (){ -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}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))<0)return-1;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=bipf.allocAndEncode(t),i=t?`${t}`:"",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=bipf.allocAndEncode(t),a=t?`${t}`:"",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 slowAbsent(e){const t=seekFromDesc(e),n=e.replace(/\./g,"_");return{type:"ABSENT",data:{seek:t,indexType:n,indexName:safeFilename(n+"__absent")}}}function absent(e,t){if(!(t=t||{}).indexType)throw new Error("absent() operator needs an indexType in the 3rd arg");const n=t.indexType;return{type:"ABSENT",data:{seek:e,indexType:n,indexName:safeFilename(n+"__absent")}}}function slowIncludes(e,t,n){n=n||{};const r=seekFromDesc(e),a=bipf.allocAndEncode(t);if(!a)throw new Error("slowIncludes() 2nd arg needs to be truthy");const i=t?`${t}`:"",o=e.replace(/\./g,"_"),s=safeFilename(o+"_"+i),u=n.pluck&&"string"==typeof n.pluck?seekFromDesc(n.pluck):n.pluck;return{type:"INCLUDES",data:{seek:r,value:a,indexType:o,indexName:s,indexAll:n.indexAll,pluck:u}}}function includes(e,t,n){if(!(n=n||{}).indexType)throw new Error("includes() operator needs an indexType in the 3rd arg");const r=bipf.allocAndEncode(t);if(!r)throw new Error("includes() 2nd arg needs to be truthy");const a=t?`${t}`:"",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 sortByArrival(){return e=>updateMeta(e,"sortBy","arrival")}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(s,u){if(s){for(;i.length;)i.shift()();u(s)}else if(a)u(!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 u(n);for(const[n,a]of r)a.meta=t,0===n.length?e=a:traverse.set(e,n,a);a=!0,u(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:s,sortBy:u}=n;n.count?n.jitdb.count(r,a,o,e):i?n.jitdb.paginate(r,a,i,o,s,u,e):n.jitdb.all(r,a,o,s,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,s){return o?s(o):n>=r||i?s(!0):void(t.count?(i=!0,t.jitdb.count(e,n,t.descending,s)):t.jitdb.paginate(e,n,a,t.descending,t.asOffsets,t.sortBy,(e,t)=>{if(e)return s(e);0===t.total?s(!0):(r=t.total,n+=a,s(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,slowAbsent:slowAbsent,absent:absent,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,sortByArrival:sortByArrival,count:count,startFrom:startFrom,paginate:paginate,batch:batch,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}const seekFromDescCache=new Map;function seekFromDesc(e){if(seekFromDescCache.has(e))return seekFromDescCache.get(e);const t=e.split(".").map(e=>bipf.allocAndEncode(e)),n=function(e,n=0){var r=n;for(let n of t)if((r=bipf.seekKey2(e,r,n,0))<0)return-1;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=bipf.allocAndEncode(t),i=t?`${t}`:"",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=bipf.allocAndEncode(t),a=t?`${t}`:"",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 slowAbsent(e){const t=seekFromDesc(e),n=e.replace(/\./g,"_");return{type:"ABSENT",data:{seek:t,indexType:n,indexName:safeFilename(n+"__absent")}}}function absent(e,t){if(!(t=t||{}).indexType)throw new Error("absent() operator needs an indexType in the 3rd arg");const n=t.indexType;return{type:"ABSENT",data:{seek:e,indexType:n,indexName:safeFilename(n+"__absent")}}}function slowIncludes(e,t,n){n=n||{};const r=seekFromDesc(e),a=bipf.allocAndEncode(t);if(!a)throw new Error("slowIncludes() 2nd arg needs to be truthy");const i=t?`${t}`:"",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=bipf.allocAndEncode(t);if(!r)throw new Error("includes() 2nd arg needs to be truthy");const a=t?`${t}`:"",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 sortByArrival(){return e=>updateMeta(e,"sortBy","arrival")}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,sortBy:s}=n;n.count?n.jitdb.count(r,a,o,e):i?n.jitdb.paginate(r,a,i,o,u,s,null,e):n.jitdb.all(r,a,o,u,s,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,o=null;function u(u,s){return u?s(u):n>=r||i?s(!0):void(t.count?(i=!0,t.jitdb.count(e,n,t.descending,s)):t.jitdb.paginate(e,n,a,t.descending,t.asOffsets,t.sortBy,o,(e,t)=>{if(e)return s(e);0===t.total?s(!0):(r=t.total,n=t.nextSeq,t.results.length>0&&(o=t.results[t.results.length-1].key),s(null,t.results))}))}return t.count?u:t.pageSize?pull(u,pull.filter(e=>e.length>0)):pull(u,pull.filter(e=>e.length>0),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,slowAbsent:slowAbsent,absent:absent,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,sortByArrival:sortByArrival,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":263,"bipf":53,"buffer":101,"multicb":326,"promisify-4loc":392,"pull-awaitable":405,"pull-cat":407,"pull-stream":438,"traverse":680}],266:[function(require,module,exports){ -const Obv=require("obz");module.exports=function(){let e={};const t=Obv();t.set(e);const n=1e3;let o=0,s=0,f=null;const c=new Set;function l(){(f=setInterval(()=>{o===s?(clearInterval(f),f=null,o=s=0):(s=o,t.set(e))},n)).unref&&f.unref()}return{obv:t,done:function(n){for(const e of n)c.delete(e);0===c.size&&(e={},++o,f||(s=o,t.set(e),l()))},update:function(n,r){let u=!1;for(const t of r){const o=n[t],s=e[t]||-1/0;o.offset>s&&(e[t]=o.offset,c.add(t),u=!0)}u&&(++o,f||(s=o,t.set(e),l()))}}}; +},{"./files":312,"bipf":65,"buffer":117,"multicb":376,"promisify-4loc":448,"pull-awaitable":461,"pull-cat":463,"pull-stream":494,"traverse":818}],315:[function(require,module,exports){ +const Obv=require("obz");module.exports=function(){let e={};const t=Obv();t.set(e);const n=1e3;let o=0,s=0,f=null;const c=new Set;function l(){(f=setInterval(()=>{o===s?(clearInterval(f),f=null,o=s=0):(s=o,t.set(e))},n)).unref&&f.unref()}return{obv:t,done:function(n){for(const e of n)c.delete(e);0===c.size&&(e={},++o,f||(s=o,t.set(e),l()))},update:function(n,r){let u=!1;for(const t of r){const o=n.get(t),s=e[t]||-1/0;o.offset>s&&(e[t]=o.offset,c.add(t),u=!0)}u&&(++o,f||(s=o,t.set(e),l()))}}}; -},{"obz":358}],267:[function(require,module,exports){ +},{"obz":408}],316:[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(/