diff --git a/bin/bundle.js b/bin/bundle.js index 108ab30..3847b42 100644 --- a/bin/bundle.js +++ b/bin/bundle.js @@ -1907,7 +1907,7 @@ exports.preventOverflow = preventOverflow$1; }).call(this)}).call(this,require('_process')) -},{"_process":189}],2:[function(require,module,exports){ +},{"_process":333}],2:[function(require,module,exports){ (function (Buffer){(function (){ if ('undefined' === typeof Buffer) { // implicit global @@ -2009,7 +2009,7 @@ if ('undefined' === typeof Buffer) { }()); }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],3:[function(require,module,exports){ +},{"buffer":114}],3:[function(require,module,exports){ const ADDR_RE = /^\[?([^\]]+)\]?:(\d+)$/ // ipv4/ipv6/hostname + port let cache = {} @@ -2035,6 +2035,5267 @@ module.exports.reset = function reset () { } },{}],4:[function(require,module,exports){ +'use strict'; + +const asn1 = exports; + +asn1.bignum = require('bn.js'); + +asn1.define = require('./asn1/api').define; +asn1.base = require('./asn1/base'); +asn1.constants = require('./asn1/constants'); +asn1.decoders = require('./asn1/decoders'); +asn1.encoders = require('./asn1/encoders'); + +},{"./asn1/api":5,"./asn1/base":7,"./asn1/constants":11,"./asn1/decoders":13,"./asn1/encoders":16,"bn.js":18}],5:[function(require,module,exports){ +'use strict'; + +const encoders = require('./encoders'); +const decoders = require('./decoders'); +const inherits = require('inherits'); + +const api = exports; + +api.define = function define(name, body) { + return new Entity(name, body); +}; + +function Entity(name, body) { + this.name = name; + this.body = body; + + this.decoders = {}; + this.encoders = {}; +} + +Entity.prototype._createNamed = function createNamed(Base) { + const name = this.name; + + function Generated(entity) { + this._initNamed(entity, name); + } + inherits(Generated, Base); + Generated.prototype._initNamed = function _initNamed(entity, name) { + Base.call(this, entity, name); + }; + + return new Generated(this); +}; + +Entity.prototype._getDecoder = function _getDecoder(enc) { + enc = enc || 'der'; + // Lazily create decoder + if (!this.decoders.hasOwnProperty(enc)) + this.decoders[enc] = this._createNamed(decoders[enc]); + return this.decoders[enc]; +}; + +Entity.prototype.decode = function decode(data, enc, options) { + return this._getDecoder(enc).decode(data, options); +}; + +Entity.prototype._getEncoder = function _getEncoder(enc) { + enc = enc || 'der'; + // Lazily create encoder + if (!this.encoders.hasOwnProperty(enc)) + this.encoders[enc] = this._createNamed(encoders[enc]); + return this.encoders[enc]; +}; + +Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { + return this._getEncoder(enc).encode(data, reporter); +}; + +},{"./decoders":13,"./encoders":16,"inherits":245}],6:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Reporter = require('../base/reporter').Reporter; +const Buffer = require('safer-buffer').Buffer; + +function DecoderBuffer(base, options) { + Reporter.call(this, options); + if (!Buffer.isBuffer(base)) { + this.error('Input not Buffer'); + return; + } + + this.base = base; + this.offset = 0; + this.length = base.length; +} +inherits(DecoderBuffer, Reporter); +exports.DecoderBuffer = DecoderBuffer; + +DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + Buffer.isBuffer(data.base) && + data.constructor.name === 'DecoderBuffer' && + typeof data.offset === 'number' && + typeof data.length === 'number' && + typeof data.save === 'function' && + typeof data.restore === 'function' && + typeof data.isEmpty === 'function' && + typeof data.readUInt8 === 'function' && + typeof data.skip === 'function' && + typeof data.raw === 'function'; + + return isCompatible; +}; + +DecoderBuffer.prototype.save = function save() { + return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; +}; + +DecoderBuffer.prototype.restore = function restore(save) { + // Return skipped data + const res = new DecoderBuffer(this.base); + res.offset = save.offset; + res.length = this.offset; + + this.offset = save.offset; + Reporter.prototype.restore.call(this, save.reporter); + + return res; +}; + +DecoderBuffer.prototype.isEmpty = function isEmpty() { + return this.offset === this.length; +}; + +DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { + if (this.offset + 1 <= this.length) + return this.base.readUInt8(this.offset++, true); + else + return this.error(fail || 'DecoderBuffer overrun'); +}; + +DecoderBuffer.prototype.skip = function skip(bytes, fail) { + if (!(this.offset + bytes <= this.length)) + return this.error(fail || 'DecoderBuffer overrun'); + + const res = new DecoderBuffer(this.base); + + // Share reporter state + res._reporterState = this._reporterState; + + res.offset = this.offset; + res.length = this.offset + bytes; + this.offset += bytes; + return res; +}; + +DecoderBuffer.prototype.raw = function raw(save) { + return this.base.slice(save ? save.offset : this.offset, this.length); +}; + +function EncoderBuffer(value, reporter) { + if (Array.isArray(value)) { + this.length = 0; + this.value = value.map(function(item) { + if (!EncoderBuffer.isEncoderBuffer(item)) + item = new EncoderBuffer(item, reporter); + this.length += item.length; + return item; + }, this); + } else if (typeof value === 'number') { + if (!(0 <= value && value <= 0xff)) + return reporter.error('non-byte EncoderBuffer value'); + this.value = value; + this.length = 1; + } else if (typeof value === 'string') { + this.value = value; + this.length = Buffer.byteLength(value); + } else if (Buffer.isBuffer(value)) { + this.value = value; + this.length = value.length; + } else { + return reporter.error('Unsupported type: ' + typeof value); + } +} +exports.EncoderBuffer = EncoderBuffer; + +EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + data.constructor.name === 'EncoderBuffer' && + typeof data.length === 'number' && + typeof data.join === 'function'; + + return isCompatible; +}; + +EncoderBuffer.prototype.join = function join(out, offset) { + if (!out) + out = Buffer.alloc(this.length); + if (!offset) + offset = 0; + + if (this.length === 0) + return out; + + if (Array.isArray(this.value)) { + this.value.forEach(function(item) { + item.join(out, offset); + offset += item.length; + }); + } else { + if (typeof this.value === 'number') + out[offset] = this.value; + else if (typeof this.value === 'string') + out.write(this.value, offset); + else if (Buffer.isBuffer(this.value)) + this.value.copy(out, offset); + offset += this.length; + } + + return out; +}; + +},{"../base/reporter":9,"inherits":245,"safer-buffer":377}],7:[function(require,module,exports){ +'use strict'; + +const base = exports; + +base.Reporter = require('./reporter').Reporter; +base.DecoderBuffer = require('./buffer').DecoderBuffer; +base.EncoderBuffer = require('./buffer').EncoderBuffer; +base.Node = require('./node'); + +},{"./buffer":6,"./node":8,"./reporter":9}],8:[function(require,module,exports){ +'use strict'; + +const Reporter = require('../base/reporter').Reporter; +const EncoderBuffer = require('../base/buffer').EncoderBuffer; +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const assert = require('minimalistic-assert'); + +// Supported tags +const tags = [ + 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', + 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', + 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', + 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr' +]; + +// Public methods list +const methods = [ + 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', + 'any', 'contains' +].concat(tags); + +// Overrided methods list +const overrided = [ + '_peekTag', '_decodeTag', '_use', + '_decodeStr', '_decodeObjid', '_decodeTime', + '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', + + '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', + '_encodeNull', '_encodeInt', '_encodeBool' +]; + +function Node(enc, parent, name) { + const state = {}; + this._baseState = state; + + state.name = name; + state.enc = enc; + + state.parent = parent || null; + state.children = null; + + // State + state.tag = null; + state.args = null; + state.reverseArgs = null; + state.choice = null; + state.optional = false; + state.any = false; + state.obj = false; + state.use = null; + state.useDecoder = null; + state.key = null; + state['default'] = null; + state.explicit = null; + state.implicit = null; + state.contains = null; + + // Should create new instance on each method + if (!state.parent) { + state.children = []; + this._wrap(); + } +} +module.exports = Node; + +const stateProps = [ + 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', + 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', + 'implicit', 'contains' +]; + +Node.prototype.clone = function clone() { + const state = this._baseState; + const cstate = {}; + stateProps.forEach(function(prop) { + cstate[prop] = state[prop]; + }); + const res = new this.constructor(cstate.parent); + res._baseState = cstate; + return res; +}; + +Node.prototype._wrap = function wrap() { + const state = this._baseState; + methods.forEach(function(method) { + this[method] = function _wrappedMethod() { + const clone = new this.constructor(this); + state.children.push(clone); + return clone[method].apply(clone, arguments); + }; + }, this); +}; + +Node.prototype._init = function init(body) { + const state = this._baseState; + + assert(state.parent === null); + body.call(this); + + // Filter children + state.children = state.children.filter(function(child) { + return child._baseState.parent === this; + }, this); + assert.equal(state.children.length, 1, 'Root node can have only one child'); +}; + +Node.prototype._useArgs = function useArgs(args) { + const state = this._baseState; + + // Filter children and args + const children = args.filter(function(arg) { + return arg instanceof this.constructor; + }, this); + args = args.filter(function(arg) { + return !(arg instanceof this.constructor); + }, this); + + if (children.length !== 0) { + assert(state.children === null); + state.children = children; + + // Replace parent to maintain backward link + children.forEach(function(child) { + child._baseState.parent = this; + }, this); + } + if (args.length !== 0) { + assert(state.args === null); + state.args = args; + state.reverseArgs = args.map(function(arg) { + if (typeof arg !== 'object' || arg.constructor !== Object) + return arg; + + const res = {}; + Object.keys(arg).forEach(function(key) { + if (key == (key | 0)) + key |= 0; + const value = arg[key]; + res[value] = key; + }); + return res; + }); + } +}; + +// +// Overrided methods +// + +overrided.forEach(function(method) { + Node.prototype[method] = function _overrided() { + const state = this._baseState; + throw new Error(method + ' not implemented for encoding: ' + state.enc); + }; +}); + +// +// Public methods +// + +tags.forEach(function(tag) { + Node.prototype[tag] = function _tagMethod() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + + assert(state.tag === null); + state.tag = tag; + + this._useArgs(args); + + return this; + }; +}); + +Node.prototype.use = function use(item) { + assert(item); + const state = this._baseState; + + assert(state.use === null); + state.use = item; + + return this; +}; + +Node.prototype.optional = function optional() { + const state = this._baseState; + + state.optional = true; + + return this; +}; + +Node.prototype.def = function def(val) { + const state = this._baseState; + + assert(state['default'] === null); + state['default'] = val; + state.optional = true; + + return this; +}; + +Node.prototype.explicit = function explicit(num) { + const state = this._baseState; + + assert(state.explicit === null && state.implicit === null); + state.explicit = num; + + return this; +}; + +Node.prototype.implicit = function implicit(num) { + const state = this._baseState; + + assert(state.explicit === null && state.implicit === null); + state.implicit = num; + + return this; +}; + +Node.prototype.obj = function obj() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + + state.obj = true; + + if (args.length !== 0) + this._useArgs(args); + + return this; +}; + +Node.prototype.key = function key(newKey) { + const state = this._baseState; + + assert(state.key === null); + state.key = newKey; + + return this; +}; + +Node.prototype.any = function any() { + const state = this._baseState; + + state.any = true; + + return this; +}; + +Node.prototype.choice = function choice(obj) { + const state = this._baseState; + + assert(state.choice === null); + state.choice = obj; + this._useArgs(Object.keys(obj).map(function(key) { + return obj[key]; + })); + + return this; +}; + +Node.prototype.contains = function contains(item) { + const state = this._baseState; + + assert(state.use === null); + state.contains = item; + + return this; +}; + +// +// Decoding +// + +Node.prototype._decode = function decode(input, options) { + const state = this._baseState; + + // Decode root node + if (state.parent === null) + return input.wrapResult(state.children[0]._decode(input, options)); + + let result = state['default']; + let present = true; + + let prevKey = null; + if (state.key !== null) + prevKey = input.enterKey(state.key); + + // Check if tag is there + if (state.optional) { + let tag = null; + if (state.explicit !== null) + tag = state.explicit; + else if (state.implicit !== null) + tag = state.implicit; + else if (state.tag !== null) + tag = state.tag; + + if (tag === null && !state.any) { + // Trial and Error + const save = input.save(); + try { + if (state.choice === null) + this._decodeGeneric(state.tag, input, options); + else + this._decodeChoice(input, options); + present = true; + } catch (e) { + present = false; + } + input.restore(save); + } else { + present = this._peekTag(input, tag, state.any); + + if (input.isError(present)) + return present; + } + } + + // Push object on stack + let prevObj; + if (state.obj && present) + prevObj = input.enterObject(); + + if (present) { + // Unwrap explicit values + if (state.explicit !== null) { + const explicit = this._decodeTag(input, state.explicit); + if (input.isError(explicit)) + return explicit; + input = explicit; + } + + const start = input.offset; + + // Unwrap implicit and normal values + if (state.use === null && state.choice === null) { + let save; + if (state.any) + save = input.save(); + const body = this._decodeTag( + input, + state.implicit !== null ? state.implicit : state.tag, + state.any + ); + if (input.isError(body)) + return body; + + if (state.any) + result = input.raw(save); + else + input = body; + } + + if (options && options.track && state.tag !== null) + options.track(input.path(), start, input.length, 'tagged'); + + if (options && options.track && state.tag !== null) + options.track(input.path(), input.offset, input.length, 'content'); + + // Select proper method for tag + if (state.any) { + // no-op + } else if (state.choice === null) { + result = this._decodeGeneric(state.tag, input, options); + } else { + result = this._decodeChoice(input, options); + } + + if (input.isError(result)) + return result; + + // Decode children + if (!state.any && state.choice === null && state.children !== null) { + state.children.forEach(function decodeChildren(child) { + // NOTE: We are ignoring errors here, to let parser continue with other + // parts of encoded data + child._decode(input, options); + }); + } + + // Decode contained/encoded by schema, only in bit or octet strings + if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { + const data = new DecoderBuffer(result); + result = this._getUse(state.contains, input._reporterState.obj) + ._decode(data, options); + } + } + + // Pop object + if (state.obj && present) + result = input.leaveObject(prevObj); + + // Set key + if (state.key !== null && (result !== null || present === true)) + input.leaveKey(prevKey, state.key, result); + else if (prevKey !== null) + input.exitKey(prevKey); + + return result; +}; + +Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { + const state = this._baseState; + + if (tag === 'seq' || tag === 'set') + return null; + if (tag === 'seqof' || tag === 'setof') + return this._decodeList(input, tag, state.args[0], options); + else if (/str$/.test(tag)) + return this._decodeStr(input, tag, options); + else if (tag === 'objid' && state.args) + return this._decodeObjid(input, state.args[0], state.args[1], options); + else if (tag === 'objid') + return this._decodeObjid(input, null, null, options); + else if (tag === 'gentime' || tag === 'utctime') + return this._decodeTime(input, tag, options); + else if (tag === 'null_') + return this._decodeNull(input, options); + else if (tag === 'bool') + return this._decodeBool(input, options); + else if (tag === 'objDesc') + return this._decodeStr(input, tag, options); + else if (tag === 'int' || tag === 'enum') + return this._decodeInt(input, state.args && state.args[0], options); + + if (state.use !== null) { + return this._getUse(state.use, input._reporterState.obj) + ._decode(input, options); + } else { + return input.error('unknown tag: ' + tag); + } +}; + +Node.prototype._getUse = function _getUse(entity, obj) { + + const state = this._baseState; + // Create altered use decoder if implicit is set + state.useDecoder = this._use(entity, obj); + assert(state.useDecoder._baseState.parent === null); + state.useDecoder = state.useDecoder._baseState.children[0]; + if (state.implicit !== state.useDecoder._baseState.implicit) { + state.useDecoder = state.useDecoder.clone(); + state.useDecoder._baseState.implicit = state.implicit; + } + return state.useDecoder; +}; + +Node.prototype._decodeChoice = function decodeChoice(input, options) { + const state = this._baseState; + let result = null; + let match = false; + + Object.keys(state.choice).some(function(key) { + const save = input.save(); + const node = state.choice[key]; + try { + const value = node._decode(input, options); + if (input.isError(value)) + return false; + + result = { type: key, value: value }; + match = true; + } catch (e) { + input.restore(save); + return false; + } + return true; + }, this); + + if (!match) + return input.error('Choice not matched'); + + return result; +}; + +// +// Encoding +// + +Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { + return new EncoderBuffer(data, this.reporter); +}; + +Node.prototype._encode = function encode(data, reporter, parent) { + const state = this._baseState; + if (state['default'] !== null && state['default'] === data) + return; + + const result = this._encodeValue(data, reporter, parent); + if (result === undefined) + return; + + if (this._skipDefault(result, reporter, parent)) + return; + + return result; +}; + +Node.prototype._encodeValue = function encode(data, reporter, parent) { + const state = this._baseState; + + // Decode root node + if (state.parent === null) + return state.children[0]._encode(data, reporter || new Reporter()); + + let result = null; + + // Set reporter to share it with a child class + this.reporter = reporter; + + // Check if data is there + if (state.optional && data === undefined) { + if (state['default'] !== null) + data = state['default']; + else + return; + } + + // Encode children first + let content = null; + let primitive = false; + if (state.any) { + // Anything that was given is translated to buffer + result = this._createEncoderBuffer(data); + } else if (state.choice) { + result = this._encodeChoice(data, reporter); + } else if (state.contains) { + content = this._getUse(state.contains, parent)._encode(data, reporter); + primitive = true; + } else if (state.children) { + content = state.children.map(function(child) { + if (child._baseState.tag === 'null_') + return child._encode(null, reporter, data); + + if (child._baseState.key === null) + return reporter.error('Child should have a key'); + const prevKey = reporter.enterKey(child._baseState.key); + + if (typeof data !== 'object') + return reporter.error('Child expected, but input is not object'); + + const res = child._encode(data[child._baseState.key], reporter, data); + reporter.leaveKey(prevKey); + + return res; + }, this).filter(function(child) { + return child; + }); + content = this._createEncoderBuffer(content); + } else { + if (state.tag === 'seqof' || state.tag === 'setof') { + // TODO(indutny): this should be thrown on DSL level + if (!(state.args && state.args.length === 1)) + return reporter.error('Too many args for : ' + state.tag); + + if (!Array.isArray(data)) + return reporter.error('seqof/setof, but data is not Array'); + + const child = this.clone(); + child._baseState.implicit = null; + content = this._createEncoderBuffer(data.map(function(item) { + const state = this._baseState; + + return this._getUse(state.args[0], data)._encode(item, reporter); + }, child)); + } else if (state.use !== null) { + result = this._getUse(state.use, parent)._encode(data, reporter); + } else { + content = this._encodePrimitive(state.tag, data); + primitive = true; + } + } + + // Encode data itself + if (!state.any && state.choice === null) { + const tag = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? 'universal' : 'context'; + + if (tag === null) { + if (state.use === null) + reporter.error('Tag could be omitted only for .use()'); + } else { + if (state.use === null) + result = this._encodeComposite(tag, primitive, cls, content); + } + } + + // Wrap in explicit + if (state.explicit !== null) + result = this._encodeComposite(state.explicit, false, 'context', result); + + return result; +}; + +Node.prototype._encodeChoice = function encodeChoice(data, reporter) { + const state = this._baseState; + + const node = state.choice[data.type]; + if (!node) { + assert( + false, + data.type + ' not found in ' + + JSON.stringify(Object.keys(state.choice))); + } + return node._encode(data.value, reporter); +}; + +Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { + const state = this._baseState; + + if (/str$/.test(tag)) + return this._encodeStr(data, tag); + else if (tag === 'objid' && state.args) + return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); + else if (tag === 'objid') + return this._encodeObjid(data, null, null); + else if (tag === 'gentime' || tag === 'utctime') + return this._encodeTime(data, tag); + else if (tag === 'null_') + return this._encodeNull(); + else if (tag === 'int' || tag === 'enum') + return this._encodeInt(data, state.args && state.reverseArgs[0]); + else if (tag === 'bool') + return this._encodeBool(data); + else if (tag === 'objDesc') + return this._encodeStr(data, tag); + else + throw new Error('Unsupported tag: ' + tag); +}; + +Node.prototype._isNumstr = function isNumstr(str) { + return /^[0-9 ]*$/.test(str); +}; + +Node.prototype._isPrintstr = function isPrintstr(str) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); +}; + +},{"../base/buffer":6,"../base/reporter":9,"minimalistic-assert":278}],9:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); + +function Reporter(options) { + this._reporterState = { + obj: null, + path: [], + options: options || {}, + errors: [] + }; +} +exports.Reporter = Reporter; + +Reporter.prototype.isError = function isError(obj) { + return obj instanceof ReporterError; +}; + +Reporter.prototype.save = function save() { + const state = this._reporterState; + + return { obj: state.obj, pathLen: state.path.length }; +}; + +Reporter.prototype.restore = function restore(data) { + const state = this._reporterState; + + state.obj = data.obj; + state.path = state.path.slice(0, data.pathLen); +}; + +Reporter.prototype.enterKey = function enterKey(key) { + return this._reporterState.path.push(key); +}; + +Reporter.prototype.exitKey = function exitKey(index) { + const state = this._reporterState; + + state.path = state.path.slice(0, index - 1); +}; + +Reporter.prototype.leaveKey = function leaveKey(index, key, value) { + const state = this._reporterState; + + this.exitKey(index); + if (state.obj !== null) + state.obj[key] = value; +}; + +Reporter.prototype.path = function path() { + return this._reporterState.path.join('/'); +}; + +Reporter.prototype.enterObject = function enterObject() { + const state = this._reporterState; + + const prev = state.obj; + state.obj = {}; + return prev; +}; + +Reporter.prototype.leaveObject = function leaveObject(prev) { + const state = this._reporterState; + + const now = state.obj; + state.obj = prev; + return now; +}; + +Reporter.prototype.error = function error(msg) { + let err; + const state = this._reporterState; + + const inherited = msg instanceof ReporterError; + if (inherited) { + err = msg; + } else { + err = new ReporterError(state.path.map(function(elem) { + return '[' + JSON.stringify(elem) + ']'; + }).join(''), msg.message || msg, msg.stack); + } + + if (!state.options.partial) + throw err; + + if (!inherited) + state.errors.push(err); + + return err; +}; + +Reporter.prototype.wrapResult = function wrapResult(result) { + const state = this._reporterState; + if (!state.options.partial) + return result; + + return { + result: this.isError(result) ? null : result, + errors: state.errors + }; +}; + +function ReporterError(path, msg) { + this.path = path; + this.rethrow(msg); +} +inherits(ReporterError, Error); + +ReporterError.prototype.rethrow = function rethrow(msg) { + this.message = msg + ' at: ' + (this.path || '(shallow)'); + if (Error.captureStackTrace) + Error.captureStackTrace(this, ReporterError); + + if (!this.stack) { + try { + // IE only adds stack when thrown + throw new Error(this.message); + } catch (e) { + this.stack = e.stack; + } + } + return this; +}; + +},{"inherits":245}],10:[function(require,module,exports){ +'use strict'; + +// Helper +function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; +} + +exports.tagClass = { + 0: 'universal', + 1: 'application', + 2: 'context', + 3: 'private' +}; +exports.tagClassByName = reverse(exports.tagClass); + +exports.tag = { + 0x00: 'end', + 0x01: 'bool', + 0x02: 'int', + 0x03: 'bitstr', + 0x04: 'octstr', + 0x05: 'null_', + 0x06: 'objid', + 0x07: 'objDesc', + 0x08: 'external', + 0x09: 'real', + 0x0a: 'enum', + 0x0b: 'embed', + 0x0c: 'utf8str', + 0x0d: 'relativeOid', + 0x10: 'seq', + 0x11: 'set', + 0x12: 'numstr', + 0x13: 'printstr', + 0x14: 't61str', + 0x15: 'videostr', + 0x16: 'ia5str', + 0x17: 'utctime', + 0x18: 'gentime', + 0x19: 'graphstr', + 0x1a: 'iso646str', + 0x1b: 'genstr', + 0x1c: 'unistr', + 0x1d: 'charstr', + 0x1e: 'bmpstr' +}; +exports.tagByName = reverse(exports.tag); + +},{}],11:[function(require,module,exports){ +'use strict'; + +const constants = exports; + +// Helper +constants._reverse = function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; +}; + +constants.der = require('./der'); + +},{"./der":10}],12:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); + +const bignum = require('bn.js'); +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const Node = require('../base/node'); + +// Import DER constants +const der = require('../constants/der'); + +function DERDecoder(entity) { + this.enc = 'der'; + this.name = entity.name; + this.entity = entity; + + // Construct base tree + this.tree = new DERNode(); + this.tree._init(entity.body); +} +module.exports = DERDecoder; + +DERDecoder.prototype.decode = function decode(data, options) { + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } + + return this.tree._decode(data, options); +}; + +// Tree methods + +function DERNode(parent) { + Node.call(this, 'der', parent); +} +inherits(DERNode, Node); + +DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { + if (buffer.isEmpty()) + return false; + + const state = buffer.save(); + const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); + if (buffer.isError(decodedTag)) + return decodedTag; + + buffer.restore(state); + + return decodedTag.tag === tag || decodedTag.tagStr === tag || + (decodedTag.tagStr + 'of') === tag || any; +}; + +DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { + const decodedTag = derDecodeTag(buffer, + 'Failed to decode tag of "' + tag + '"'); + if (buffer.isError(decodedTag)) + return decodedTag; + + let len = derDecodeLen(buffer, + decodedTag.primitive, + 'Failed to get length of "' + tag + '"'); + + // Failure + if (buffer.isError(len)) + return len; + + if (!any && + decodedTag.tag !== tag && + decodedTag.tagStr !== tag && + decodedTag.tagStr + 'of' !== tag) { + return buffer.error('Failed to match tag: "' + tag + '"'); + } + + if (decodedTag.primitive || len !== null) + return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); + + // Indefinite length... find END tag + const state = buffer.save(); + const res = this._skipUntilEnd( + buffer, + 'Failed to skip indefinite length body: "' + this.tag + '"'); + if (buffer.isError(res)) + return res; + + len = buffer.offset - state.offset; + buffer.restore(state); + return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); +}; + +DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { + for (;;) { + const tag = derDecodeTag(buffer, fail); + if (buffer.isError(tag)) + return tag; + const len = derDecodeLen(buffer, tag.primitive, fail); + if (buffer.isError(len)) + return len; + + let res; + if (tag.primitive || len !== null) + res = buffer.skip(len); + else + res = this._skipUntilEnd(buffer, fail); + + // Failure + if (buffer.isError(res)) + return res; + + if (tag.tagStr === 'end') + break; + } +}; + +DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, + options) { + const result = []; + while (!buffer.isEmpty()) { + const possibleEnd = this._peekTag(buffer, 'end'); + if (buffer.isError(possibleEnd)) + return possibleEnd; + + const res = decoder.decode(buffer, 'der', options); + if (buffer.isError(res) && possibleEnd) + break; + result.push(res); + } + return result; +}; + +DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { + if (tag === 'bitstr') { + const unused = buffer.readUInt8(); + if (buffer.isError(unused)) + return unused; + return { unused: unused, data: buffer.raw() }; + } else if (tag === 'bmpstr') { + const raw = buffer.raw(); + if (raw.length % 2 === 1) + return buffer.error('Decoding of string type: bmpstr length mismatch'); + + let str = ''; + for (let i = 0; i < raw.length / 2; i++) { + str += String.fromCharCode(raw.readUInt16BE(i * 2)); + } + return str; + } else if (tag === 'numstr') { + const numstr = buffer.raw().toString('ascii'); + if (!this._isNumstr(numstr)) { + return buffer.error('Decoding of string type: ' + + 'numstr unsupported characters'); + } + return numstr; + } else if (tag === 'octstr') { + return buffer.raw(); + } else if (tag === 'objDesc') { + return buffer.raw(); + } else if (tag === 'printstr') { + const printstr = buffer.raw().toString('ascii'); + if (!this._isPrintstr(printstr)) { + return buffer.error('Decoding of string type: ' + + 'printstr unsupported characters'); + } + return printstr; + } else if (/str$/.test(tag)) { + return buffer.raw().toString(); + } else { + return buffer.error('Decoding of string type: ' + tag + ' unsupported'); + } +}; + +DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { + let result; + const identifiers = []; + let ident = 0; + let subident = 0; + while (!buffer.isEmpty()) { + subident = buffer.readUInt8(); + ident <<= 7; + ident |= subident & 0x7f; + if ((subident & 0x80) === 0) { + identifiers.push(ident); + ident = 0; + } + } + if (subident & 0x80) + identifiers.push(ident); + + const first = (identifiers[0] / 40) | 0; + const second = identifiers[0] % 40; + + if (relative) + result = identifiers; + else + result = [first, second].concat(identifiers.slice(1)); + + if (values) { + let tmp = values[result.join(' ')]; + if (tmp === undefined) + tmp = values[result.join('.')]; + if (tmp !== undefined) + result = tmp; + } + + return result; +}; + +DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { + const str = buffer.raw().toString(); + + let year; + let mon; + let day; + let hour; + let min; + let sec; + if (tag === 'gentime') { + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; + } else if (tag === 'utctime') { + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; + if (year < 70) + year = 2000 + year; + else + year = 1900 + year; + } else { + return buffer.error('Decoding ' + tag + ' time is not supported yet'); + } + + return Date.UTC(year, mon - 1, day, hour, min, sec, 0); +}; + +DERNode.prototype._decodeNull = function decodeNull() { + return null; +}; + +DERNode.prototype._decodeBool = function decodeBool(buffer) { + const res = buffer.readUInt8(); + if (buffer.isError(res)) + return res; + else + return res !== 0; +}; + +DERNode.prototype._decodeInt = function decodeInt(buffer, values) { + // Bigint, return as it is (assume big endian) + const raw = buffer.raw(); + let res = new bignum(raw); + + if (values) + res = values[res.toString(10)] || res; + + return res; +}; + +DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === 'function') + entity = entity(obj); + return entity._getDecoder('der').tree; +}; + +// Utility methods + +function derDecodeTag(buf, fail) { + let tag = buf.readUInt8(fail); + if (buf.isError(tag)) + return tag; + + const cls = der.tagClass[tag >> 6]; + const primitive = (tag & 0x20) === 0; + + // Multi-octet tag - load + if ((tag & 0x1f) === 0x1f) { + let oct = tag; + tag = 0; + while ((oct & 0x80) === 0x80) { + oct = buf.readUInt8(fail); + if (buf.isError(oct)) + return oct; + + tag <<= 7; + tag |= oct & 0x7f; + } + } else { + tag &= 0x1f; + } + const tagStr = der.tag[tag]; + + return { + cls: cls, + primitive: primitive, + tag: tag, + tagStr: tagStr + }; +} + +function derDecodeLen(buf, primitive, fail) { + let len = buf.readUInt8(fail); + if (buf.isError(len)) + return len; + + // Indefinite form + if (!primitive && len === 0x80) + return null; + + // Definite form + if ((len & 0x80) === 0) { + // Short form + return len; + } + + // Long form + const num = len & 0x7f; + if (num > 4) + return buf.error('length octect is too long'); + + len = 0; + for (let i = 0; i < num; i++) { + len <<= 8; + const j = buf.readUInt8(fail); + if (buf.isError(j)) + return j; + len |= j; + } + + return len; +} + +},{"../base/buffer":6,"../base/node":8,"../constants/der":10,"bn.js":18,"inherits":245}],13:[function(require,module,exports){ +'use strict'; + +const decoders = exports; + +decoders.der = require('./der'); +decoders.pem = require('./pem'); + +},{"./der":12,"./pem":14}],14:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; + +const DERDecoder = require('./der'); + +function PEMDecoder(entity) { + DERDecoder.call(this, entity); + this.enc = 'pem'; +} +inherits(PEMDecoder, DERDecoder); +module.exports = PEMDecoder; + +PEMDecoder.prototype.decode = function decode(data, options) { + const lines = data.toString().split(/[\r\n]+/g); + + const label = options.label.toUpperCase(); + + const re = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i = 0; i < lines.length; i++) { + const match = lines[i].match(re); + if (match === null) + continue; + + if (match[2] !== label) + continue; + + if (start === -1) { + if (match[1] !== 'BEGIN') + break; + start = i; + } else { + if (match[1] !== 'END') + break; + end = i; + break; + } + } + if (start === -1 || end === -1) + throw new Error('PEM section not found for: ' + label); + + const base64 = lines.slice(start + 1, end).join(''); + // Remove excessive symbols + base64.replace(/[^a-z0-9+/=]+/gi, ''); + + const input = Buffer.from(base64, 'base64'); + return DERDecoder.prototype.decode.call(this, input, options); +}; + +},{"./der":12,"inherits":245,"safer-buffer":377}],15:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; +const Node = require('../base/node'); + +// Import DER constants +const der = require('../constants/der'); + +function DEREncoder(entity) { + this.enc = 'der'; + this.name = entity.name; + this.entity = entity; + + // Construct base tree + this.tree = new DERNode(); + this.tree._init(entity.body); +} +module.exports = DEREncoder; + +DEREncoder.prototype.encode = function encode(data, reporter) { + return this.tree._encode(data, reporter).join(); +}; + +// Tree methods + +function DERNode(parent) { + Node.call(this, 'der', parent); +} +inherits(DERNode, Node); + +DERNode.prototype._encodeComposite = function encodeComposite(tag, + primitive, + cls, + content) { + const encodedTag = encodeTag(tag, primitive, cls, this.reporter); + + // Short form + if (content.length < 0x80) { + const header = Buffer.alloc(2); + header[0] = encodedTag; + header[1] = content.length; + return this._createEncoderBuffer([ header, content ]); + } + + // Long form + // Count octets required to store length + let lenOctets = 1; + for (let i = content.length; i >= 0x100; i >>= 8) + lenOctets++; + + const header = Buffer.alloc(1 + 1 + lenOctets); + header[0] = encodedTag; + header[1] = 0x80 | lenOctets; + + for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) + header[i] = j & 0xff; + + return this._createEncoderBuffer([ header, content ]); +}; + +DERNode.prototype._encodeStr = function encodeStr(str, tag) { + if (tag === 'bitstr') { + return this._createEncoderBuffer([ str.unused | 0, str.data ]); + } else if (tag === 'bmpstr') { + const buf = Buffer.alloc(str.length * 2); + for (let i = 0; i < str.length; i++) { + buf.writeUInt16BE(str.charCodeAt(i), i * 2); + } + return this._createEncoderBuffer(buf); + } else if (tag === 'numstr') { + if (!this._isNumstr(str)) { + return this.reporter.error('Encoding of string type: numstr supports ' + + 'only digits and space'); + } + return this._createEncoderBuffer(str); + } else if (tag === 'printstr') { + if (!this._isPrintstr(str)) { + return this.reporter.error('Encoding of string type: printstr supports ' + + 'only latin upper and lower case letters, ' + + 'digits, space, apostrophe, left and rigth ' + + 'parenthesis, plus sign, comma, hyphen, ' + + 'dot, slash, colon, equal sign, ' + + 'question mark'); + } + return this._createEncoderBuffer(str); + } else if (/str$/.test(tag)) { + return this._createEncoderBuffer(str); + } else if (tag === 'objDesc') { + return this._createEncoderBuffer(str); + } else { + return this.reporter.error('Encoding of string type: ' + tag + + ' unsupported'); + } +}; + +DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { + if (typeof id === 'string') { + if (!values) + return this.reporter.error('string objid given, but no values map found'); + if (!values.hasOwnProperty(id)) + return this.reporter.error('objid not found in values map'); + id = values[id].split(/[\s.]+/g); + for (let i = 0; i < id.length; i++) + id[i] |= 0; + } else if (Array.isArray(id)) { + id = id.slice(); + for (let i = 0; i < id.length; i++) + id[i] |= 0; + } + + if (!Array.isArray(id)) { + return this.reporter.error('objid() should be either array or string, ' + + 'got: ' + JSON.stringify(id)); + } + + if (!relative) { + if (id[1] >= 40) + return this.reporter.error('Second objid identifier OOB'); + id.splice(0, 2, id[0] * 40 + id[1]); + } + + // Count number of octets + let size = 0; + for (let i = 0; i < id.length; i++) { + let ident = id[i]; + for (size++; ident >= 0x80; ident >>= 7) + size++; + } + + const objid = Buffer.alloc(size); + let offset = objid.length - 1; + for (let i = id.length - 1; i >= 0; i--) { + let ident = id[i]; + objid[offset--] = ident & 0x7f; + while ((ident >>= 7) > 0) + objid[offset--] = 0x80 | (ident & 0x7f); + } + + return this._createEncoderBuffer(objid); +}; + +function two(num) { + if (num < 10) + return '0' + num; + else + return num; +} + +DERNode.prototype._encodeTime = function encodeTime(time, tag) { + let str; + const date = new Date(time); + + if (tag === 'gentime') { + str = [ + two(date.getUTCFullYear()), + two(date.getUTCMonth() + 1), + two(date.getUTCDate()), + two(date.getUTCHours()), + two(date.getUTCMinutes()), + two(date.getUTCSeconds()), + 'Z' + ].join(''); + } else if (tag === 'utctime') { + str = [ + two(date.getUTCFullYear() % 100), + two(date.getUTCMonth() + 1), + two(date.getUTCDate()), + two(date.getUTCHours()), + two(date.getUTCMinutes()), + two(date.getUTCSeconds()), + 'Z' + ].join(''); + } else { + this.reporter.error('Encoding ' + tag + ' time is not supported yet'); + } + + return this._encodeStr(str, 'octstr'); +}; + +DERNode.prototype._encodeNull = function encodeNull() { + return this._createEncoderBuffer(''); +}; + +DERNode.prototype._encodeInt = function encodeInt(num, values) { + if (typeof num === 'string') { + if (!values) + return this.reporter.error('String int or enum given, but no values map'); + if (!values.hasOwnProperty(num)) { + return this.reporter.error('Values map doesn\'t contain: ' + + JSON.stringify(num)); + } + num = values[num]; + } + + // Bignum, assume big endian + if (typeof num !== 'number' && !Buffer.isBuffer(num)) { + const numArray = num.toArray(); + if (!num.sign && numArray[0] & 0x80) { + numArray.unshift(0); + } + num = Buffer.from(numArray); + } + + if (Buffer.isBuffer(num)) { + let size = num.length; + if (num.length === 0) + size++; + + const out = Buffer.alloc(size); + num.copy(out); + if (num.length === 0) + out[0] = 0; + return this._createEncoderBuffer(out); + } + + if (num < 0x80) + return this._createEncoderBuffer(num); + + if (num < 0x100) + return this._createEncoderBuffer([0, num]); + + let size = 1; + for (let i = num; i >= 0x100; i >>= 8) + size++; + + const out = new Array(size); + for (let i = out.length - 1; i >= 0; i--) { + out[i] = num & 0xff; + num >>= 8; + } + if(out[0] & 0x80) { + out.unshift(0); + } + + return this._createEncoderBuffer(Buffer.from(out)); +}; + +DERNode.prototype._encodeBool = function encodeBool(value) { + return this._createEncoderBuffer(value ? 0xff : 0); +}; + +DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === 'function') + entity = entity(obj); + return entity._getEncoder('der').tree; +}; + +DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { + const state = this._baseState; + let i; + if (state['default'] === null) + return false; + + const data = dataBuffer.join(); + if (state.defaultBuffer === undefined) + state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); + + if (data.length !== state.defaultBuffer.length) + return false; + + for (i=0; i < data.length; i++) + if (data[i] !== state.defaultBuffer[i]) + return false; + + return true; +}; + +// Utility methods + +function encodeTag(tag, primitive, cls, reporter) { + let res; + + if (tag === 'seqof') + tag = 'seq'; + else if (tag === 'setof') + tag = 'set'; + + if (der.tagByName.hasOwnProperty(tag)) + res = der.tagByName[tag]; + else if (typeof tag === 'number' && (tag | 0) === tag) + res = tag; + else + return reporter.error('Unknown tag: ' + tag); + + if (res >= 0x1f) + return reporter.error('Multi-octet tag encoding unsupported'); + + if (!primitive) + res |= 0x20; + + res |= (der.tagClassByName[cls || 'universal'] << 6); + + return res; +} + +},{"../base/node":8,"../constants/der":10,"inherits":245,"safer-buffer":377}],16:[function(require,module,exports){ +'use strict'; + +const encoders = exports; + +encoders.der = require('./der'); +encoders.pem = require('./pem'); + +},{"./der":15,"./pem":17}],17:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); + +const DEREncoder = require('./der'); + +function PEMEncoder(entity) { + DEREncoder.call(this, entity); + this.enc = 'pem'; +} +inherits(PEMEncoder, DEREncoder); +module.exports = PEMEncoder; + +PEMEncoder.prototype.encode = function encode(data, options) { + const buf = DEREncoder.prototype.encode.call(this, data); + + const p = buf.toString('base64'); + const out = [ '-----BEGIN ' + options.label + '-----' ]; + for (let i = 0; i < p.length; i += 64) + out.push(p.slice(i, i + 64)); + out.push('-----END ' + options.label + '-----'); + return out.join('\n'); +}; + +},{"./der":15,"inherits":245}],18:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } + + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; + + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // 'A' - 'F' + if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + // '0' - '9' + } else { + return (c - 48) & 0xf; + } + } + + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + // 24-bits chunks + var off = 0; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } + + this.strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; + + // '0' - '9' + } else { + r += c; + } + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + this.strip(); + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + BN.prototype.inspect = function inspect () { + return (this.red ? ''; + }; + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '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' + ]; + + var groupSizes = [ + 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 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; + + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); + + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } + + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[i] = b; + } + + for (; i < reqLength; i++) { + res[i] = 0; + } + } + + return res; + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this.strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this.strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this.strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this.strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this.strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this.strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out.strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out.strip(); + } + + function jumboMulTo (self, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out.strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this.strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this.strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this.strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) < num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this.strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this.strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this.strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q.strip(); + } + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modn = function modn (num) { + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return acc; + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + return this.strip(); + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this.strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is BN v4 instance + r.strip(); + } else { + // r is BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(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); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); + +},{"buffer":71}],19:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -2186,7 +7447,7 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],5:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer const INTEGER_START = 0x69 // 'i' @@ -2358,7 +7619,7 @@ decode.buffer = function () { module.exports = decode -},{"safe-buffer":222}],6:[function(require,module,exports){ +},{"safe-buffer":376}],21:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer /** @@ -2475,7 +7736,7 @@ encode.list = function (buffers, data) { module.exports = encode -},{"safe-buffer":222}],7:[function(require,module,exports){ +},{"safe-buffer":376}],22:[function(require,module,exports){ var bencode = module.exports bencode.encode = require('./encode') @@ -2491,7 +7752,7 @@ bencode.byteLength = bencode.encodingLength = function (value) { return bencode.encode(value).length } -},{"./decode":5,"./encode":6}],8:[function(require,module,exports){ +},{"./decode":20,"./encode":21}],23:[function(require,module,exports){ module.exports = parseRange module.exports.parse = parseRange module.exports.compose = composeRange @@ -2518,7 +7779,7 @@ function parseRange (range) { }, []) } -},{}],9:[function(require,module,exports){ +},{}],24:[function(require,module,exports){ module.exports = function(haystack, needle, comparator, low, high) { var mid, cmp; @@ -2565,7 +7826,7 @@ module.exports = function(haystack, needle, comparator, low, high) { return ~low; } -},{}],10:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function getByteSize(num) { @@ -2645,16 +7906,19 @@ var BitField = /** @class */ (function () { }()); exports.default = BitField; -},{}],11:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ (function (Buffer){(function (){ /*! bittorrent-protocol. MIT License. WebTorrent LLC */ const arrayRemove = require('unordered-array-remove') const bencode = require('bencode') const BitField = require('bitfield').default +const crypto = require('crypto') const debug = require('debug')('bittorrent-protocol') const randombytes = require('randombytes') +const sha1 = require('simple-sha1') const speedometer = require('speedometer') const stream = require('readable-stream') +const RC4 = require('rc4') const BITFIELD_GROW = 400000 const KEEP_ALIVE_TIMEOUT = 55000 @@ -2669,6 +7933,17 @@ const MESSAGE_UNINTERESTED = Buffer.from([0x00, 0x00, 0x00, 0x01, 0x03]) const MESSAGE_RESERVED = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] const MESSAGE_PORT = [0x00, 0x00, 0x00, 0x03, 0x09, 0x00, 0x00] +const DH_PRIME = 'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a36210000000000090563' +const DH_GENERATOR = 2 +const VC = Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]) +const CRYPTO_PROVIDE = Buffer.from([0x00, 0x00, 0x01, 0x02]) +const CRYPTO_SELECT = Buffer.from([0x00, 0x00, 0x00, 0x02]) // always try to choose RC4 encryption instead of plaintext + +function xor (a, b) { + for (let len = a.length; len--;) a[len] ^= b[len] + return a +} + class Request { constructor (piece, offset, length, callback) { this.piece = piece @@ -2679,7 +7954,7 @@ class Request { } class Wire extends stream.Duplex { - constructor () { + constructor (type = null, retries = 0, peEnabled = false) { super() this._debugId = randombytes(4).toString('hex') @@ -2687,7 +7962,7 @@ class Wire extends stream.Duplex { this.peerId = null // remote peer id (hex string) this.peerIdBuffer = null // remote peer id (buffer) - this.type = null // connection type ('webrtc', 'tcpIncoming', 'tcpOutgoing', 'webSeed') + this.type = type // connection type ('webrtc', 'tcpIncoming', 'tcpOutgoing', 'webSeed') this.amChoking = true // are we choking the peer? this.amInterested = false // are we interested in the peer? @@ -2736,9 +8011,39 @@ class Wire extends stream.Duplex { this._buffer = [] // incomplete message data this._bufferSize = 0 // cached total length of buffers in `this._buffer` + this._peEnabled = peEnabled + if (peEnabled) { + this._dh = crypto.createDiffieHellman(DH_PRIME, 'hex', DH_GENERATOR) // crypto object used to generate keys/secret + this._myPubKey = this._dh.generateKeys('hex') // my DH public key + } else { + this._myPubKey = null + } + this._peerPubKey = null // peer's DH public key + this._sharedSecret = null // shared DH secret + this._peerCryptoProvide = [] // encryption methods provided by peer; we expect this to always contain 0x02 + this._cryptoHandshakeDone = false + + this._cryptoSyncPattern = null // the pattern to search for when resynchronizing after receiving pe1/pe2 + this._waitMaxBytes = null // the maximum number of bytes resynchronization must occur within + this._encryptionMethod = null // 1 for plaintext, 2 for RC4 + this._encryptGenerator = null // RC4 keystream generator for encryption + this._decryptGenerator = null // RC4 keystream generator for decryption + this._setGenerators = false // a flag for whether setEncrypt() has successfully completed + this.once('finish', () => this._onFinish()) - this._parseHandshake() + this.on('finish', this._onFinish) + this._debug('type:', this.type) + + if (this.type === 'tcpIncoming' && this._peEnabled) { + // If we are not the initiator, we should wait to see if the client begins + // with PE/MSE handshake or the standard bittorrent handshake. + this._determineHandshakeType() + } else if (this.type === 'tcpOutgoing' && this._peEnabled && retries === 0) { + this._parsePe2() + } else { + this._parseHandshake(null) + } } /** @@ -2826,6 +8131,60 @@ class Wire extends stream.Duplex { this._push(MESSAGE_KEEP_ALIVE) } + sendPe1 () { + if (this._peEnabled) { + const padALen = Math.floor(Math.random() * 513) + const padA = randombytes(padALen) + this._push(Buffer.concat([Buffer.from(this._myPubKey, 'hex'), padA])) + } + } + + sendPe2 () { + const padBLen = Math.floor(Math.random() * 513) + const padB = randombytes(padBLen) + this._push(Buffer.concat([Buffer.from(this._myPubKey, 'hex'), padB])) + } + + sendPe3 (infoHash) { + this.setEncrypt(this._sharedSecret, infoHash) + + const hash1Buffer = Buffer.from(sha1.sync(Buffer.from(this._utfToHex('req1') + this._sharedSecret, 'hex')), 'hex') + + const hash2Buffer = Buffer.from(sha1.sync(Buffer.from(this._utfToHex('req2') + infoHash, 'hex')), 'hex') + const hash3Buffer = Buffer.from(sha1.sync(Buffer.from(this._utfToHex('req3') + this._sharedSecret, 'hex')), 'hex') + const hashesXorBuffer = xor(hash2Buffer, hash3Buffer) + + const padCLen = randombytes(2).readUInt16BE(0) % 512 + const padCBuffer = randombytes(padCLen) + + let vcAndProvideBuffer = Buffer.alloc(8 + 4 + 2 + padCLen + 2) + VC.copy(vcAndProvideBuffer) + CRYPTO_PROVIDE.copy(vcAndProvideBuffer, 8) + + vcAndProvideBuffer.writeInt16BE(padCLen, 12) // pad C length + padCBuffer.copy(vcAndProvideBuffer, 14) + vcAndProvideBuffer.writeInt16BE(0, 14 + padCLen) // IA length + vcAndProvideBuffer = this._encryptHandshake(vcAndProvideBuffer) + + this._push(Buffer.concat([hash1Buffer, hashesXorBuffer, vcAndProvideBuffer])) + } + + sendPe4 (infoHash) { + this.setEncrypt(this._sharedSecret, infoHash) + + const padDLen = randombytes(2).readUInt16BE(0) % 512 + const padDBuffer = randombytes(padDLen) + let vcAndSelectBuffer = Buffer.alloc(8 + 4 + 2 + padDLen) + VC.copy(vcAndSelectBuffer) + CRYPTO_SELECT.copy(vcAndSelectBuffer, 8) + vcAndSelectBuffer.writeInt16BE(padDLen, 12) // lenD? + padDBuffer.copy(vcAndSelectBuffer, 14) + vcAndSelectBuffer = this._encryptHandshake(vcAndSelectBuffer) + this._push(vcAndSelectBuffer) + this._cryptoHandshakeDone = true + this._debug('completed crypto handshake') + } + /** * Message: "handshake" * @param {Buffer|string} infoHash (as Buffer or *hex* string) @@ -2849,6 +8208,8 @@ class Wire extends stream.Duplex { peerId = peerIdBuffer.toString('hex') } + this._infoHash = infoHashBuffer + if (infoHashBuffer.length !== 20 || peerIdBuffer.length !== 20) { throw new Error('infoHash and peerId MUST have length 20') } @@ -2983,10 +8344,10 @@ class Wire extends stream.Duplex { */ piece (index, offset, buffer) { this._debug('piece index=%d offset=%d', index, offset) + this._message(7, [index, offset], buffer) this.uploaded += buffer.length this.uploadSpeed(buffer.length) this.emit('upload', buffer.length) - this._message(7, [index, offset], buffer) } /** @@ -3036,6 +8397,68 @@ class Wire extends stream.Duplex { } } + /** + * Sets the encryption method for this wire, as per PSE/ME specification + * + * @param {string} sharedSecret: A hex-encoded string, which is the shared secret agreed + * upon from DH key exchange + * @param {string} infoHash: A hex-encoded info hash + * @returns boolean, true if encryption setting succeeds, false if it fails. + */ + setEncrypt (sharedSecret, infoHash) { + let encryptKey + let decryptKey + let encryptKeyBuf + let encryptKeyIntArray + let decryptKeyBuf + let decryptKeyIntArray + switch (this.type) { + case 'tcpIncoming': + encryptKey = sha1.sync(Buffer.from(this._utfToHex('keyB') + sharedSecret + infoHash, 'hex')) + decryptKey = sha1.sync(Buffer.from(this._utfToHex('keyA') + sharedSecret + infoHash, 'hex')) + encryptKeyBuf = Buffer.from(encryptKey, 'hex') + encryptKeyIntArray = [] + for (const value of encryptKeyBuf.values()) { + encryptKeyIntArray.push(value) + } + decryptKeyBuf = Buffer.from(decryptKey, 'hex') + decryptKeyIntArray = [] + for (const value of decryptKeyBuf.values()) { + decryptKeyIntArray.push(value) + } + this._encryptGenerator = new RC4(encryptKeyIntArray) + this._decryptGenerator = new RC4(decryptKeyIntArray) + break + case 'tcpOutgoing': + encryptKey = sha1.sync(Buffer.from(this._utfToHex('keyA') + sharedSecret + infoHash, 'hex')) + decryptKey = sha1.sync(Buffer.from(this._utfToHex('keyB') + sharedSecret + infoHash, 'hex')) + encryptKeyBuf = Buffer.from(encryptKey, 'hex') + encryptKeyIntArray = [] + for (const value of encryptKeyBuf.values()) { + encryptKeyIntArray.push(value) + } + decryptKeyBuf = Buffer.from(decryptKey, 'hex') + decryptKeyIntArray = [] + for (const value of decryptKeyBuf.values()) { + decryptKeyIntArray.push(value) + } + this._encryptGenerator = new RC4(encryptKeyIntArray) + this._decryptGenerator = new RC4(decryptKeyIntArray) + break + default: + return false + } + + // Discard the first 1024 bytes, as per MSE/PE implementation + for (let i = 0; i < 1024; i++) { + this._encryptGenerator.randomByte() + this._decryptGenerator.randomByte() + } + + this._setGenerators = true + return true + } + /** * Duplex stream method. Called whenever the remote peer stream wants data. No-op * since we'll just push data whenever we get it. @@ -3061,6 +8484,9 @@ class Wire extends stream.Duplex { _push (data) { if (this._finished) return + if (this._encryptionMethod === 2 && this._cryptoHandshakeDone) { + data = this._encrypt(data) + } return this.push(data) } @@ -3073,6 +8499,55 @@ class Wire extends stream.Duplex { this.emit('keep-alive') } + _onPe1 (pubKeyBuffer) { + this._peerPubKey = pubKeyBuffer.toString('hex') + this._sharedSecret = this._dh.computeSecret(this._peerPubKey, 'hex', 'hex') + this.emit('pe1') + } + + _onPe2 (pubKeyBuffer) { + this._peerPubKey = pubKeyBuffer.toString('hex') + this._sharedSecret = this._dh.computeSecret(this._peerPubKey, 'hex', 'hex') + this.emit('pe2') + } + + _onPe3 (hashesXorBuffer) { + const hash3 = sha1.sync(Buffer.from(this._utfToHex('req3') + this._sharedSecret, 'hex')) + const sKeyHash = xor(Buffer.from(hash3, 'hex'), hashesXorBuffer).toString('hex') + this.emit('pe3', sKeyHash) + } + + _onPe3Encrypted (vcBuffer, peerProvideBuffer) { + if (!vcBuffer.equals(VC)) { + this._debug('Error: verification constant did not match') + this.destroy() + return + } + + for (const provideByte of peerProvideBuffer.values()) { + if (provideByte !== 0) { + this._peerCryptoProvide.push(provideByte) + } + } + if (this._peerCryptoProvide.includes(2)) { + this._encryptionMethod = 2 + } else { + this._debug('Error: RC4 encryption method not provided by peer') + this.destroy() + } + } + + _onPe4 (peerSelectBuffer) { + this._encryptionMethod = peerSelectBuffer.readUInt8(3) + if (!CRYPTO_PROVIDE.includes(this._encryptionMethod)) { + this._debug('Error: peer selected invalid crypto method') + this.destroy() + } + this._cryptoHandshakeDone = true + this._debug('crypto handshake done') + this.emit('pe4') + } + _onHandshake (infoHashBuffer, peerIdBuffer, extensions) { const infoHash = infoHashBuffer.toString('hex') const peerId = peerIdBuffer.toString('hex') @@ -3085,8 +8560,7 @@ class Wire extends stream.Duplex { this.emit('handshake', infoHash, peerId, extensions) - let name - for (name in this._ext) { + for (const name in this._ext) { this._ext[name].onHandshake(infoHash, peerId, extensions) } @@ -3185,13 +8659,12 @@ class Wire extends stream.Duplex { if (!info) return this.peerExtendedHandshake = info - let name if (typeof info.m === 'object') { - for (name in info.m) { + for (const name in info.m) { this.peerExtendedMapping[name] = Number(info.m[name].toString()) } } - for (name in this._ext) { + for (const name in this._ext) { if (this.peerExtendedMapping[name]) { this._ext[name].onExtendedHandshake(this.peerExtendedHandshake) } @@ -3228,18 +8701,40 @@ class Wire extends stream.Duplex { * @param {function} cb */ _write (data, encoding, cb) { + if (this._encryptionMethod === 2 && this._cryptoHandshakeDone) { + data = this._decrypt(data) + } this._bufferSize += data.length this._buffer.push(data) + if (this._buffer.length > 1) { + this._buffer = [Buffer.concat(this._buffer, this._bufferSize)] + } + // now this._buffer is an array containing a single Buffer + if (this._cryptoSyncPattern) { + const index = this._buffer[0].indexOf(this._cryptoSyncPattern) + if (index !== -1) { + this._buffer[0] = this._buffer[0].slice(index + this._cryptoSyncPattern.length) + this._bufferSize -= (index + this._cryptoSyncPattern.length) + this._cryptoSyncPattern = null + } else if (this._bufferSize + data.length > this._waitMaxBytes + this._cryptoSyncPattern.length) { + this._debug('Error: could not resynchronize') + this.destroy() + return + } + } - while (this._bufferSize >= this._parserSize) { - const buffer = (this._buffer.length === 1) - ? this._buffer[0] - : Buffer.concat(this._buffer, this._bufferSize) - this._bufferSize -= this._parserSize - this._buffer = this._bufferSize - ? [buffer.slice(this._parserSize)] - : [] - this._parser(buffer.slice(0, this._parserSize)) + while (this._bufferSize >= this._parserSize && !this._cryptoSyncPattern) { + if (this._parserSize === 0) { + this._parser(Buffer.from([])) + } else { + const buffer = this._buffer[0] + // console.log('buffer:', this._buffer) + this._bufferSize -= this._parserSize + this._buffer = this._bufferSize + ? [buffer.slice(this._parserSize)] + : [] + this._parser(buffer.slice(0, this._parserSize)) + } } cb(null) // Signal that we're ready for more data @@ -3288,6 +8783,11 @@ class Wire extends stream.Duplex { this._parser = parser } + _parseUntil (pattern, maxBytes) { + this._cryptoSyncPattern = pattern + this._waitMaxBytes = maxBytes + } + /** * Handle the first 4 bytes of a message, to determine the length of bytes that must be * waited for in order to have the whole message. @@ -3350,26 +8850,120 @@ class Wire extends stream.Duplex { } } + _determineHandshakeType () { + this._parse(1, pstrLenBuffer => { + const pstrlen = pstrLenBuffer.readUInt8(0) + if (pstrlen === 19) { + this._parse(pstrlen + 48, this._onHandshakeBuffer) + } else { + this._parsePe1(pstrLenBuffer) + } + }) + } + + _parsePe1 (pubKeyPrefix) { + this._parse(95, pubKeySuffix => { + this._onPe1(Buffer.concat([pubKeyPrefix, pubKeySuffix])) + this._parsePe3() + }) + } + + _parsePe2 () { + this._parse(96, pubKey => { + this._onPe2(pubKey) + while (!this._setGenerators) { + // Wait until generators have been set + } + this._parsePe4() + }) + } + + // Handles the unencrypted portion of step 4 + _parsePe3 () { + const hash1Buffer = Buffer.from(sha1.sync(Buffer.from(this._utfToHex('req1') + this._sharedSecret, 'hex')), 'hex') + // synchronize on HASH('req1', S) + this._parseUntil(hash1Buffer, 512) + this._parse(20, buffer => { + this._onPe3(buffer) + while (!this._setGenerators) { + // Wait until generators have been set + } + this._parsePe3Encrypted() + }) + } + + _parsePe3Encrypted () { + this._parse(14, buffer => { + const vcBuffer = this._decryptHandshake(buffer.slice(0, 8)) + const peerProvideBuffer = this._decryptHandshake(buffer.slice(8, 12)) + const padCLen = this._decryptHandshake(buffer.slice(12, 14)).readUInt16BE(0) + this._parse(padCLen, padCBuffer => { + padCBuffer = this._decryptHandshake(padCBuffer) + this._parse(2, iaLenBuf => { + const iaLen = this._decryptHandshake(iaLenBuf).readUInt16BE(0) + this._parse(iaLen, iaBuffer => { + iaBuffer = this._decryptHandshake(iaBuffer) + this._onPe3Encrypted(vcBuffer, peerProvideBuffer, padCBuffer, iaBuffer) + const pstrlen = iaLen ? iaBuffer.readUInt8(0) : null + const protocol = iaLen ? iaBuffer.slice(1, 20) : null + if (pstrlen === 19 && protocol.toString() === 'BitTorrent protocol') { + this._onHandshakeBuffer(iaBuffer.slice(1)) + } else { + this._parseHandshake() + } + }) + }) + }) + }) + } + + _parsePe4 () { + // synchronize on ENCRYPT(VC). + // since we encrypt using bitwise xor, decryption and encryption are the same operation. + // calling _decryptHandshake here advances the decrypt generator keystream forward 8 bytes + const vcBufferEncrypted = this._decryptHandshake(VC) + this._parseUntil(vcBufferEncrypted, 512) + this._parse(6, buffer => { + const peerSelectBuffer = this._decryptHandshake(buffer.slice(0, 4)) + const padDLen = this._decryptHandshake(buffer.slice(4, 6)).readUInt16BE(0) + this._parse(padDLen, padDBuf => { + this._decryptHandshake(padDBuf) + this._onPe4(peerSelectBuffer) + this._parseHandshake(null) + }) + }) + } + + /** + * Reads the handshake as specified by the bittorrent wire protocol. + */ _parseHandshake () { this._parse(1, buffer => { const pstrlen = buffer.readUInt8(0) - this._parse(pstrlen + 48, handshake => { - const protocol = handshake.slice(0, pstrlen) - if (protocol.toString() !== 'BitTorrent protocol') { - this._debug('Error: wire not speaking BitTorrent protocol (%s)', protocol.toString()) - this.end() - return - } - handshake = handshake.slice(pstrlen) - this._onHandshake(handshake.slice(8, 28), handshake.slice(28, 48), { - dht: !!(handshake[7] & 0x01), // see bep_0005 - extended: !!(handshake[5] & 0x10) // see bep_0010 - }) - this._parse(4, this._onMessageLength) - }) + if (pstrlen !== 19) { + this._debug('Error: wire not speaking BitTorrent protocol (%s)', pstrlen.toString()) + this.end() + return + } + this._parse(pstrlen + 48, this._onHandshakeBuffer) }) } + _onHandshakeBuffer (handshake) { + const protocol = handshake.slice(0, 19) + if (protocol.toString() !== 'BitTorrent protocol') { + this._debug('Error: wire not speaking BitTorrent protocol (%s)', protocol.toString()) + this.end() + return + } + handshake = handshake.slice(19) + this._onHandshake(handshake.slice(8, 28), handshake.slice(28, 48), { + dht: !!(handshake[7] & 0x01), // see bep_0005 + extended: !!(handshake[5] & 0x10) // see bep_0010 + }) + this._parse(4, this._onMessageLength) + } + _onFinish () { this._finished = true @@ -3404,12 +8998,74 @@ class Wire extends stream.Duplex { } return null } + + _encryptHandshake (buf) { + const crypt = Buffer.from(buf) + if (!this._encryptGenerator) { + this._debug('Warning: Encrypting without any generator') + return crypt + } + + for (let i = 0; i < buf.length; i++) { + const keystream = this._encryptGenerator.randomByte() + crypt[i] = crypt[i] ^ keystream + } + + return crypt + } + + _encrypt (buf) { + const crypt = Buffer.from(buf) + + if (!this._encryptGenerator || this._encryptionMethod !== 2) { + return crypt + } + for (let i = 0; i < buf.length; i++) { + const keystream = this._encryptGenerator.randomByte() + crypt[i] = crypt[i] ^ keystream + } + + return crypt + } + + _decryptHandshake (buf) { + const decrypt = Buffer.from(buf) + + if (!this._decryptGenerator) { + this._debug('Warning: Decrypting without any generator') + return decrypt + } + for (let i = 0; i < buf.length; i++) { + const keystream = this._decryptGenerator.randomByte() + decrypt[i] = decrypt[i] ^ keystream + } + + return decrypt + } + + _decrypt (buf) { + const decrypt = Buffer.from(buf) + + if (!this._decryptGenerator || this._encryptionMethod !== 2) { + return decrypt + } + for (let i = 0; i < buf.length; i++) { + const keystream = this._decryptGenerator.randomByte() + decrypt[i] = decrypt[i] ^ keystream + } + + return decrypt + } + + _utfToHex (str) { + return Buffer.from(str, 'utf8').toString('hex') + } } module.exports = Wire }).call(this)}).call(this,require("buffer").Buffer) -},{"bencode":7,"bitfield":10,"buffer":55,"debug":12,"randombytes":197,"readable-stream":29,"speedometer":265,"unordered-array-remove":300}],12:[function(require,module,exports){ +},{"bencode":22,"bitfield":25,"buffer":114,"crypto":163,"debug":27,"randombytes":348,"rc4":366,"readable-stream":44,"simple-sha1":407,"speedometer":428,"unordered-array-remove":478}],27:[function(require,module,exports){ (function (process){(function (){ /* eslint-env browser */ @@ -3682,7 +9338,7 @@ formatters.j = function (v) { }; }).call(this)}).call(this,require('_process')) -},{"./common":13,"_process":189}],13:[function(require,module,exports){ +},{"./common":28,"_process":333}],28:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -3745,6 +9401,8 @@ function setup(env) { function createDebug(namespace) { let prevTime; let enableOverride = null; + let namespacesCache; + let enabledCache; function debug(...args) { // Disabled? @@ -3805,7 +9463,17 @@ function setup(env) { Object.defineProperty(debug, 'enabled', { enumerable: true, configurable: false, - get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + + return enabledCache; + }, set: v => { enableOverride = v; } @@ -3834,6 +9502,7 @@ function setup(env) { */ function enable(namespaces) { createDebug.save(namespaces); + createDebug.namespaces = namespaces; createDebug.names = []; createDebug.skips = []; @@ -3945,7 +9614,7 @@ function setup(env) { module.exports = setup; -},{"ms":14}],14:[function(require,module,exports){ +},{"ms":29}],29:[function(require,module,exports){ /** * Helpers. */ @@ -4109,7 +9778,7 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],15:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ 'use strict'; function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } @@ -4238,7 +9907,7 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); module.exports.codes = codes; -},{}],16:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ (function (process){(function (){ // Copyright Joyent, Inc. and other Node contributors. // @@ -4380,7 +10049,7 @@ Object.defineProperty(Duplex.prototype, 'destroyed', { } }); }).call(this)}).call(this,require('_process')) -},{"./_stream_readable":18,"./_stream_writable":20,"_process":189,"inherits":118}],17:[function(require,module,exports){ +},{"./_stream_readable":33,"./_stream_writable":35,"_process":333,"inherits":245}],32:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -4420,7 +10089,7 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":19,"inherits":118}],18:[function(require,module,exports){ +},{"./_stream_transform":34,"inherits":245}],33:[function(require,module,exports){ (function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // @@ -5547,7 +11216,7 @@ function indexOf(xs, x) { return -1; } }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../errors":15,"./_stream_duplex":16,"./internal/streams/async_iterator":21,"./internal/streams/buffer_list":22,"./internal/streams/destroy":23,"./internal/streams/from":25,"./internal/streams/state":27,"./internal/streams/stream":28,"_process":189,"buffer":55,"events":97,"inherits":118,"string_decoder/":288,"util":54}],19:[function(require,module,exports){ +},{"../errors":30,"./_stream_duplex":31,"./internal/streams/async_iterator":36,"./internal/streams/buffer_list":37,"./internal/streams/destroy":38,"./internal/streams/from":40,"./internal/streams/state":42,"./internal/streams/stream":43,"_process":333,"buffer":114,"events":194,"inherits":245,"string_decoder/":466,"util":71}],34:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -5749,7 +11418,7 @@ function done(stream, er, data) { if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); return stream.push(null); } -},{"../errors":15,"./_stream_duplex":16,"inherits":118}],20:[function(require,module,exports){ +},{"../errors":30,"./_stream_duplex":31,"inherits":245}],35:[function(require,module,exports){ (function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // @@ -6449,7 +12118,7 @@ Writable.prototype._destroy = function (err, cb) { cb(err); }; }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,"_process":189,"buffer":55,"inherits":118,"util-deprecate":307}],21:[function(require,module,exports){ +},{"../errors":30,"./_stream_duplex":31,"./internal/streams/destroy":38,"./internal/streams/state":42,"./internal/streams/stream":43,"_process":333,"buffer":114,"inherits":245,"util-deprecate":485}],36:[function(require,module,exports){ (function (process){(function (){ 'use strict'; @@ -6659,7 +12328,7 @@ var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterat module.exports = createReadableStreamAsyncIterator; }).call(this)}).call(this,require('_process')) -},{"./end-of-stream":24,"_process":189}],22:[function(require,module,exports){ +},{"./end-of-stream":39,"_process":333}],37:[function(require,module,exports){ 'use strict'; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } @@ -6870,7 +12539,7 @@ function () { return BufferList; }(); -},{"buffer":55,"util":54}],23:[function(require,module,exports){ +},{"buffer":114,"util":71}],38:[function(require,module,exports){ (function (process){(function (){ 'use strict'; // undocumented cb() API, needed for core, not for public API @@ -6978,7 +12647,7 @@ module.exports = { errorOrDestroy: errorOrDestroy }; }).call(this)}).call(this,require('_process')) -},{"_process":189}],24:[function(require,module,exports){ +},{"_process":333}],39:[function(require,module,exports){ // Ported from https://github.com/mafintosh/end-of-stream with // permission from the author, Mathias Buus (@mafintosh). 'use strict'; @@ -7083,12 +12752,12 @@ function eos(stream, opts, callback) { } module.exports = eos; -},{"../../../errors":15}],25:[function(require,module,exports){ +},{"../../../errors":30}],40:[function(require,module,exports){ module.exports = function () { throw new Error('Readable.from is not available in the browser') }; -},{}],26:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ // Ported from https://github.com/mafintosh/pump with // permission from the author, Mathias Buus (@mafintosh). 'use strict'; @@ -7186,7 +12855,7 @@ function pipeline() { } module.exports = pipeline; -},{"../../../errors":15,"./end-of-stream":24}],27:[function(require,module,exports){ +},{"../../../errors":30,"./end-of-stream":39}],42:[function(require,module,exports){ 'use strict'; var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; @@ -7214,10 +12883,10 @@ function getHighWaterMark(state, options, duplexKey, isDuplex) { module.exports = { getHighWaterMark: getHighWaterMark }; -},{"../../../errors":15}],28:[function(require,module,exports){ +},{"../../../errors":30}],43:[function(require,module,exports){ module.exports = require('events').EventEmitter; -},{"events":97}],29:[function(require,module,exports){ +},{"events":194}],44:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -7228,7 +12897,7 @@ 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":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":31,"./lib/_stream_passthrough.js":32,"./lib/_stream_readable.js":33,"./lib/_stream_transform.js":34,"./lib/_stream_writable.js":35,"./lib/internal/streams/end-of-stream.js":39,"./lib/internal/streams/pipeline.js":41}],45:[function(require,module,exports){ (function (process,Buffer){(function (){ const debug = require('debug')('bittorrent-tracker:client') const EventEmitter = require('events') @@ -7318,7 +12987,7 @@ class Client extends EventEmitter { .map(announceUrl => { let parsedUrl try { - parsedUrl = new URL(announceUrl) + parsedUrl = common.parseUrl(announceUrl) } catch (err) { nextTickWarn(new Error(`Invalid tracker URL: ${announceUrl}`)) return null @@ -7513,9 +13182,7 @@ Client.scrape = (opts, cb) => { }) opts.infoHash = Array.isArray(opts.infoHash) - ? opts.infoHash.map(infoHash => { - return Buffer.from(infoHash, 'hex') - }) + ? opts.infoHash.map(infoHash => Buffer.from(infoHash, 'hex')) : Buffer.from(opts.infoHash, 'hex') client.scrape({ infoHash: opts.infoHash }) return client @@ -7524,7 +13191,7 @@ Client.scrape = (opts, cb) => { module.exports = Client }).call(this)}).call(this,require('_process'),require("buffer").Buffer) -},{"./lib/client/http-tracker":54,"./lib/client/udp-tracker":54,"./lib/client/websocket-tracker":32,"./lib/common":33,"_process":189,"buffer":55,"debug":34,"events":97,"once":185,"queue-microtask":195,"run-parallel":220,"simple-peer":225}],31:[function(require,module,exports){ +},{"./lib/client/http-tracker":71,"./lib/client/udp-tracker":71,"./lib/client/websocket-tracker":47,"./lib/common":48,"_process":333,"buffer":114,"debug":49,"events":194,"once":318,"queue-microtask":346,"run-parallel":374,"simple-peer":388}],46:[function(require,module,exports){ const EventEmitter = require('events') class Tracker extends EventEmitter { @@ -7554,7 +13221,7 @@ class Tracker extends EventEmitter { module.exports = Tracker -},{"events":97}],32:[function(require,module,exports){ +},{"events":194}],47:[function(require,module,exports){ const debug = require('debug')('bittorrent-tracker:websocket-tracker') const Peer = require('simple-peer') const randombytes = require('randombytes') @@ -7574,7 +13241,7 @@ const RECONNECT_VARIANCE = 5 * 60 * 1000 const OFFER_TIMEOUT = 50 * 1000 class WebSocketTracker extends Tracker { - constructor (client, announceUrl, opts) { + constructor (client, announceUrl) { super(client, announceUrl) debug('new websocket tracker %s', announceUrl) @@ -7633,9 +13300,7 @@ class WebSocketTracker extends Tracker { } const infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0) - ? opts.infoHash.map(infoHash => { - return infoHash.toString('binary') - }) + ? opts.infoHash.map(infoHash => infoHash.toString('binary')) : (opts.infoHash && opts.infoHash.toString('binary')) || this.client._infoHashBinary const params = { action: 'scrape', @@ -7990,7 +13655,7 @@ function noop () {} module.exports = WebSocketTracker -},{"../common":33,"./tracker":31,"debug":34,"randombytes":197,"simple-peer":225,"simple-websocket":246}],33:[function(require,module,exports){ +},{"../common":48,"./tracker":46,"debug":49,"randombytes":348,"simple-peer":388,"simple-websocket":409}],48:[function(require,module,exports){ (function (Buffer){(function (){ /** * Functions/constants needed by both the client and server. @@ -7999,31 +13664,57 @@ module.exports = WebSocketTracker exports.DEFAULT_ANNOUNCE_PEERS = 50 exports.MAX_ANNOUNCE_PEERS = 82 -exports.binaryToHex = function (str) { +exports.binaryToHex = str => { if (typeof str !== 'string') { str = String(str) } return Buffer.from(str, 'binary').toString('hex') } -exports.hexToBinary = function (str) { +exports.hexToBinary = str => { if (typeof str !== 'string') { str = String(str) } return Buffer.from(str, 'hex').toString('binary') } +// HACK: Fix for WHATWG URL object not parsing non-standard URL schemes like +// 'udp:'. Just replace it with 'http:' since we only need a few properties. +// +// Note: Only affects Chrome and Firefox. Works fine in Node.js, Safari, and +// Edge. +// +// Note: UDP trackers aren't used in the normal browser build, but they are +// used in a Chrome App build (i.e. by Brave Browser). +// +// Bug reports: +// - Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=734880 +// - Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1374505 +exports.parseUrl = str => { + const url = new URL(str.replace(/^udp:/, 'http:')) + + if (str.match(/^udp:/)) { + Object.defineProperties(url, { + href: { value: url.href.replace(/^http/, 'udp') }, + protocol: { value: url.protocol.replace(/^http/, 'udp') }, + origin: { value: url.origin.replace(/^http/, 'udp') } + }) + } + + return url +} + const config = require('./common-node') Object.assign(exports, config) }).call(this)}).call(this,require("buffer").Buffer) -},{"./common-node":54,"buffer":55}],34:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":35,"_process":189,"dup":12}],35:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":36}],36:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],37:[function(require,module,exports){ +},{"./common-node":71,"buffer":114}],49:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./common":50,"_process":333,"dup":27}],50:[function(require,module,exports){ +arguments[4][28][0].apply(exports,arguments) +},{"dup":28,"ms":51}],51:[function(require,module,exports){ +arguments[4][29][0].apply(exports,arguments) +},{"dup":29}],52:[function(require,module,exports){ (function (Buffer){(function (){ /*! blob-to-buffer. MIT License. Feross Aboukhadijeh */ /* global Blob, FileReader */ @@ -8049,7 +13740,7 @@ module.exports = function blobToBuffer (blob, cb) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],38:[function(require,module,exports){ +},{"buffer":114}],53:[function(require,module,exports){ (function (Buffer){(function (){ const { Transform } = require('readable-stream') @@ -8122,39 +13813,5505 @@ class Block extends Transform { module.exports = Block }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"readable-stream":53}],39:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],40:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":42,"./_stream_writable":44,"_process":189,"dup":16,"inherits":118}],41:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":43,"dup":17,"inherits":118}],42:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":39,"./_stream_duplex":40,"./internal/streams/async_iterator":45,"./internal/streams/buffer_list":46,"./internal/streams/destroy":47,"./internal/streams/from":49,"./internal/streams/state":51,"./internal/streams/stream":52,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],43:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":39,"./_stream_duplex":40,"dup":19,"inherits":118}],44:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":39,"./_stream_duplex":40,"./internal/streams/destroy":47,"./internal/streams/state":51,"./internal/streams/stream":52,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],45:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":48,"_process":189,"dup":21}],46:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],47:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],48:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":39,"dup":24}],49:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],50:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":39,"./end-of-stream":48,"dup":26}],51:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":39,"dup":27}],52:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],53:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":40,"./lib/_stream_passthrough.js":41,"./lib/_stream_readable.js":42,"./lib/_stream_transform.js":43,"./lib/_stream_writable.js":44,"./lib/internal/streams/end-of-stream.js":48,"./lib/internal/streams/pipeline.js":50,"dup":29}],54:[function(require,module,exports){ +},{"buffer":114,"readable-stream":68}],54:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],55:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":57,"./_stream_writable":59,"_process":333,"dup":31,"inherits":245}],56:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":58,"dup":32,"inherits":245}],57:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":54,"./_stream_duplex":55,"./internal/streams/async_iterator":60,"./internal/streams/buffer_list":61,"./internal/streams/destroy":62,"./internal/streams/from":64,"./internal/streams/state":66,"./internal/streams/stream":67,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],58:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":54,"./_stream_duplex":55,"dup":34,"inherits":245}],59:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":54,"./_stream_duplex":55,"./internal/streams/destroy":62,"./internal/streams/state":66,"./internal/streams/stream":67,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],60:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":63,"_process":333,"dup":36}],61:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],62:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],63:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":54,"dup":39}],64:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],65:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":54,"./end-of-stream":63,"dup":41}],66:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":54,"dup":42}],67:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],68:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":55,"./lib/_stream_passthrough.js":56,"./lib/_stream_readable.js":57,"./lib/_stream_transform.js":58,"./lib/_stream_writable.js":59,"./lib/internal/streams/end-of-stream.js":63,"./lib/internal/streams/pipeline.js":65,"dup":44}],69:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; -},{}],55:[function(require,module,exports){ + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } + + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [number & 0x3ffffff]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [0]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this._strip(); + }; + + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // '0' - '9' + if (c >= 48 && c <= 57) { + return c - 48; + // 'A' - 'F' + } else if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + } else { + assert(false, 'Invalid character in ' + string); + } + } + + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + // 24-bits chunks + var off = 0; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } + + this._strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var b = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + b = c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + b = c - 17 + 0xa; + + // '0' - '9' + } else { + b = c; + } + assert(c >= 0 && b < mul, 'Invalid character'); + r += b; + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [0]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + this._strip(); + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + function move (dest, src) { + dest.words = src.words; + dest.length = src.length; + dest.negative = src.negative; + dest.red = src.red; + } + + BN.prototype._move = function _move (dest) { + move(dest, this); + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype._strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } + } else { + BN.prototype.inspect = inspect; + } + + function inspect () { + return (this.red ? ''; + } + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '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' + ]; + + var groupSizes = [ + 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 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modrn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16, 2); + }; + + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + var allocate = function allocate (ArrayType, size) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size); + } + return new ArrayType(size); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + this._strip(); + + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + var res = allocate(ArrayType, reqLength); + var postfix = endian === 'le' ? 'LE' : 'BE'; + this['_toArrayLike' + postfix](res, byteLength); + return res; + }; + + BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { + var position = 0; + var carry = 0; + + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; + + res[position++] = word & 0xff; + if (position < res.length) { + res[position++] = (word >> 8) & 0xff; + } + if (position < res.length) { + res[position++] = (word >> 16) & 0xff; + } + + if (shift === 6) { + if (position < res.length) { + res[position++] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + + if (position < res.length) { + res[position++] = carry; + + while (position < res.length) { + res[position++] = 0; + } + } + }; + + BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { + var position = res.length - 1; + var carry = 0; + + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; + + res[position--] = word & 0xff; + if (position >= 0) { + res[position--] = (word >> 8) & 0xff; + } + if (position >= 0) { + res[position--] = (word >> 16) & 0xff; + } + + if (shift === 6) { + if (position >= 0) { + res[position--] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + + if (position >= 0) { + res[position--] = carry; + + while (position >= 0) { + res[position--] = 0; + } + } + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] >>> wbit) & 0x01; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this._strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this._strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this._strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this._strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this._strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this._strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out._strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out._strip(); + } + + function jumboMulTo (self, num, out) { + // Temporary disable, see https://github.com/indutny/bn.js/issues/211 + // var fftm = new FFTM(); + // return fftm.mulp(self, num, out); + return bigMulTo(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out._strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this._strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this._strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this._strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) <= num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this._strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this._strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this._strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q._strip(); + } + a._strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modrn = function modrn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return isNegNum ? -acc : acc; + }; + + // WARNING: DEPRECATED + BN.prototype.modn = function modn (num) { + return this.modrn(num); + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + this._strip(); + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this._strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is a BN v4 instance + r.strip(); + } else { + // r is a BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + + move(a, a.umod(this.m)._forceRed(this)); + return a; + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(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); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); + +},{"buffer":71}],70:[function(require,module,exports){ +var r; + +module.exports = function rand(len) { + if (!r) + r = new Rand(null); + + return r.generate(len); +}; + +function Rand(rand) { + this.rand = rand; +} +module.exports.Rand = Rand; + +Rand.prototype.generate = function generate(len) { + return this._rand(len); +}; + +// Emulate crypto API using randy +Rand.prototype._rand = function _rand(n) { + if (this.rand.getBytes) + return this.rand.getBytes(n); + + var res = new Uint8Array(n); + for (var i = 0; i < res.length; i++) + res[i] = this.rand.getByte(); + return res; +}; + +if (typeof self === 'object') { + if (self.crypto && self.crypto.getRandomValues) { + // Modern browsers + Rand.prototype._rand = function _rand(n) { + var arr = new Uint8Array(n); + self.crypto.getRandomValues(arr); + return arr; + }; + } else if (self.msCrypto && self.msCrypto.getRandomValues) { + // IE + Rand.prototype._rand = function _rand(n) { + var arr = new Uint8Array(n); + self.msCrypto.getRandomValues(arr); + return arr; + }; + + // Safari's WebWorkers do not have `crypto` + } else if (typeof window === 'object') { + // Old junk + Rand.prototype._rand = function() { + throw new Error('Not implemented yet'); + }; + } +} else { + // Node.js or Web worker with no crypto support + try { + var crypto = require('crypto'); + if (typeof crypto.randomBytes !== 'function') + throw new Error('Not supported'); + + Rand.prototype._rand = function _rand(n) { + return crypto.randomBytes(n); + }; + } catch (e) { + } +} + +},{"crypto":71}],71:[function(require,module,exports){ + +},{}],72:[function(require,module,exports){ +// based on the aes implimentation in triple sec +// https://github.com/keybase/triplesec +// which is in turn based on the one from crypto-js +// https://code.google.com/p/crypto-js/ + +var Buffer = require('safe-buffer').Buffer + +function asUInt32Array (buf) { + if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) + + var len = (buf.length / 4) | 0 + var out = new Array(len) + + for (var i = 0; i < len; i++) { + out[i] = buf.readUInt32BE(i * 4) + } + + return out +} + +function scrubVec (v) { + for (var i = 0; i < v.length; v++) { + v[i] = 0 + } +} + +function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) { + var SUB_MIX0 = SUB_MIX[0] + var SUB_MIX1 = SUB_MIX[1] + var SUB_MIX2 = SUB_MIX[2] + var SUB_MIX3 = SUB_MIX[3] + + var s0 = M[0] ^ keySchedule[0] + var s1 = M[1] ^ keySchedule[1] + var s2 = M[2] ^ keySchedule[2] + var s3 = M[3] ^ keySchedule[3] + var t0, t1, t2, t3 + var ksRow = 4 + + for (var round = 1; round < nRounds; round++) { + t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++] + t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++] + t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++] + t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++] + s0 = t0 + s1 = t1 + s2 = t2 + s3 = t3 + } + + t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] + t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] + t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] + t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++] + t0 = t0 >>> 0 + t1 = t1 >>> 0 + t2 = t2 >>> 0 + t3 = t3 >>> 0 + + return [t0, t1, t2, t3] +} + +// AES constants +var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] +var G = (function () { + // Compute double table + var d = new Array(256) + for (var j = 0; j < 256; j++) { + if (j < 128) { + d[j] = j << 1 + } else { + d[j] = (j << 1) ^ 0x11b + } + } + + var SBOX = [] + var INV_SBOX = [] + var SUB_MIX = [[], [], [], []] + var INV_SUB_MIX = [[], [], [], []] + + // Walk GF(2^8) + var x = 0 + var xi = 0 + for (var i = 0; i < 256; ++i) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4) + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63 + SBOX[x] = sx + INV_SBOX[sx] = x + + // Compute multiplication + var x2 = d[x] + var x4 = d[x2] + var x8 = d[x4] + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100) + SUB_MIX[0][x] = (t << 24) | (t >>> 8) + SUB_MIX[1][x] = (t << 16) | (t >>> 16) + SUB_MIX[2][x] = (t << 8) | (t >>> 24) + SUB_MIX[3][x] = t + + // Compute inv sub bytes, inv mix columns tables + t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100) + INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) + INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) + INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) + INV_SUB_MIX[3][sx] = t + + if (x === 0) { + x = xi = 1 + } else { + x = x2 ^ d[d[d[x8 ^ x2]]] + xi ^= d[d[xi]] + } + } + + return { + SBOX: SBOX, + INV_SBOX: INV_SBOX, + SUB_MIX: SUB_MIX, + INV_SUB_MIX: INV_SUB_MIX + } +})() + +function AES (key) { + this._key = asUInt32Array(key) + this._reset() +} + +AES.blockSize = 4 * 4 +AES.keySize = 256 / 8 +AES.prototype.blockSize = AES.blockSize +AES.prototype.keySize = AES.keySize +AES.prototype._reset = function () { + var keyWords = this._key + var keySize = keyWords.length + var nRounds = keySize + 6 + var ksRows = (nRounds + 1) * 4 + + var keySchedule = [] + for (var k = 0; k < keySize; k++) { + keySchedule[k] = keyWords[k] + } + + for (k = keySize; k < ksRows; k++) { + var t = keySchedule[k - 1] + + if (k % keySize === 0) { + t = (t << 8) | (t >>> 24) + t = + (G.SBOX[t >>> 24] << 24) | + (G.SBOX[(t >>> 16) & 0xff] << 16) | + (G.SBOX[(t >>> 8) & 0xff] << 8) | + (G.SBOX[t & 0xff]) + + t ^= RCON[(k / keySize) | 0] << 24 + } else if (keySize > 6 && k % keySize === 4) { + t = + (G.SBOX[t >>> 24] << 24) | + (G.SBOX[(t >>> 16) & 0xff] << 16) | + (G.SBOX[(t >>> 8) & 0xff] << 8) | + (G.SBOX[t & 0xff]) + } + + keySchedule[k] = keySchedule[k - keySize] ^ t + } + + var invKeySchedule = [] + for (var ik = 0; ik < ksRows; ik++) { + var ksR = ksRows - ik + var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)] + + if (ik < 4 || ksR <= 4) { + invKeySchedule[ik] = tt + } else { + invKeySchedule[ik] = + G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^ + G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^ + G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^ + G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]] + } + } + + this._nRounds = nRounds + this._keySchedule = keySchedule + this._invKeySchedule = invKeySchedule +} + +AES.prototype.encryptBlockRaw = function (M) { + M = asUInt32Array(M) + return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds) +} + +AES.prototype.encryptBlock = function (M) { + var out = this.encryptBlockRaw(M) + var buf = Buffer.allocUnsafe(16) + buf.writeUInt32BE(out[0], 0) + buf.writeUInt32BE(out[1], 4) + buf.writeUInt32BE(out[2], 8) + buf.writeUInt32BE(out[3], 12) + return buf +} + +AES.prototype.decryptBlock = function (M) { + M = asUInt32Array(M) + + // swap + var m1 = M[1] + M[1] = M[3] + M[3] = m1 + + var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds) + var buf = Buffer.allocUnsafe(16) + buf.writeUInt32BE(out[0], 0) + buf.writeUInt32BE(out[3], 4) + buf.writeUInt32BE(out[2], 8) + buf.writeUInt32BE(out[1], 12) + return buf +} + +AES.prototype.scrub = function () { + scrubVec(this._keySchedule) + scrubVec(this._invKeySchedule) + scrubVec(this._key) +} + +module.exports.AES = AES + +},{"safe-buffer":376}],73:[function(require,module,exports){ +var aes = require('./aes') +var Buffer = require('safe-buffer').Buffer +var Transform = require('cipher-base') +var inherits = require('inherits') +var GHASH = require('./ghash') +var xor = require('buffer-xor') +var incr32 = require('./incr32') + +function xorTest (a, b) { + var out = 0 + if (a.length !== b.length) out++ + + var len = Math.min(a.length, b.length) + for (var i = 0; i < len; ++i) { + out += (a[i] ^ b[i]) + } + + return out +} + +function calcIv (self, iv, ck) { + if (iv.length === 12) { + self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])]) + return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])]) + } + var ghash = new GHASH(ck) + var len = iv.length + var toPad = len % 16 + ghash.update(iv) + if (toPad) { + toPad = 16 - toPad + ghash.update(Buffer.alloc(toPad, 0)) + } + ghash.update(Buffer.alloc(8, 0)) + var ivBits = len * 8 + var tail = Buffer.alloc(8) + tail.writeUIntBE(ivBits, 0, 8) + ghash.update(tail) + self._finID = ghash.state + var out = Buffer.from(self._finID) + incr32(out) + return out +} +function StreamCipher (mode, key, iv, decrypt) { + Transform.call(this) + + var h = Buffer.alloc(4, 0) + + this._cipher = new aes.AES(key) + var ck = this._cipher.encryptBlock(h) + this._ghash = new GHASH(ck) + iv = calcIv(this, iv, ck) + + this._prev = Buffer.from(iv) + this._cache = Buffer.allocUnsafe(0) + this._secCache = Buffer.allocUnsafe(0) + this._decrypt = decrypt + this._alen = 0 + this._len = 0 + this._mode = mode + + this._authTag = null + this._called = false +} + +inherits(StreamCipher, Transform) + +StreamCipher.prototype._update = function (chunk) { + if (!this._called && this._alen) { + var rump = 16 - (this._alen % 16) + if (rump < 16) { + rump = Buffer.alloc(rump, 0) + this._ghash.update(rump) + } + } + + this._called = true + var out = this._mode.encrypt(this, chunk) + if (this._decrypt) { + this._ghash.update(chunk) + } else { + this._ghash.update(out) + } + this._len += chunk.length + return out +} + +StreamCipher.prototype._final = function () { + if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data') + + var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID)) + if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data') + + this._authTag = tag + this._cipher.scrub() +} + +StreamCipher.prototype.getAuthTag = function getAuthTag () { + if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state') + + return this._authTag +} + +StreamCipher.prototype.setAuthTag = function setAuthTag (tag) { + if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state') + + this._authTag = tag +} + +StreamCipher.prototype.setAAD = function setAAD (buf) { + if (this._called) throw new Error('Attempting to set AAD in unsupported state') + + this._ghash.update(buf) + this._alen += buf.length +} + +module.exports = StreamCipher + +},{"./aes":72,"./ghash":77,"./incr32":78,"buffer-xor":118,"cipher-base":138,"inherits":245,"safe-buffer":376}],74:[function(require,module,exports){ +var ciphers = require('./encrypter') +var deciphers = require('./decrypter') +var modes = require('./modes/list.json') + +function getCiphers () { + return Object.keys(modes) +} + +exports.createCipher = exports.Cipher = ciphers.createCipher +exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv +exports.createDecipher = exports.Decipher = deciphers.createDecipher +exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv +exports.listCiphers = exports.getCiphers = getCiphers + +},{"./decrypter":75,"./encrypter":76,"./modes/list.json":86}],75:[function(require,module,exports){ +var AuthCipher = require('./authCipher') +var Buffer = require('safe-buffer').Buffer +var MODES = require('./modes') +var StreamCipher = require('./streamCipher') +var Transform = require('cipher-base') +var aes = require('./aes') +var ebtk = require('evp_bytestokey') +var inherits = require('inherits') + +function Decipher (mode, key, iv) { + Transform.call(this) + + this._cache = new Splitter() + this._last = void 0 + this._cipher = new aes.AES(key) + this._prev = Buffer.from(iv) + this._mode = mode + this._autopadding = true +} + +inherits(Decipher, Transform) + +Decipher.prototype._update = function (data) { + this._cache.add(data) + var chunk + var thing + var out = [] + while ((chunk = this._cache.get(this._autopadding))) { + thing = this._mode.decrypt(this, chunk) + out.push(thing) + } + return Buffer.concat(out) +} + +Decipher.prototype._final = function () { + var chunk = this._cache.flush() + if (this._autopadding) { + return unpad(this._mode.decrypt(this, chunk)) + } else if (chunk) { + throw new Error('data not multiple of block length') + } +} + +Decipher.prototype.setAutoPadding = function (setTo) { + this._autopadding = !!setTo + return this +} + +function Splitter () { + this.cache = Buffer.allocUnsafe(0) +} + +Splitter.prototype.add = function (data) { + this.cache = Buffer.concat([this.cache, data]) +} + +Splitter.prototype.get = function (autoPadding) { + var out + if (autoPadding) { + if (this.cache.length > 16) { + out = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + return out + } + } else { + if (this.cache.length >= 16) { + out = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + return out + } + } + + return null +} + +Splitter.prototype.flush = function () { + if (this.cache.length) return this.cache +} + +function unpad (last) { + var padded = last[15] + if (padded < 1 || padded > 16) { + throw new Error('unable to decrypt data') + } + var i = -1 + while (++i < padded) { + if (last[(i + (16 - padded))] !== padded) { + throw new Error('unable to decrypt data') + } + } + if (padded === 16) return + + return last.slice(0, 16 - padded) +} + +function createDecipheriv (suite, password, iv) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + if (typeof iv === 'string') iv = Buffer.from(iv) + if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) + + if (typeof password === 'string') password = Buffer.from(password) + if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) + + if (config.type === 'stream') { + return new StreamCipher(config.module, password, iv, true) + } else if (config.type === 'auth') { + return new AuthCipher(config.module, password, iv, true) + } + + return new Decipher(config.module, password, iv) +} + +function createDecipher (suite, password) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + var keys = ebtk(password, false, config.key, config.iv) + return createDecipheriv(suite, keys.key, keys.iv) +} + +exports.createDecipher = createDecipher +exports.createDecipheriv = createDecipheriv + +},{"./aes":72,"./authCipher":73,"./modes":85,"./streamCipher":88,"cipher-base":138,"evp_bytestokey":195,"inherits":245,"safe-buffer":376}],76:[function(require,module,exports){ +var MODES = require('./modes') +var AuthCipher = require('./authCipher') +var Buffer = require('safe-buffer').Buffer +var StreamCipher = require('./streamCipher') +var Transform = require('cipher-base') +var aes = require('./aes') +var ebtk = require('evp_bytestokey') +var inherits = require('inherits') + +function Cipher (mode, key, iv) { + Transform.call(this) + + this._cache = new Splitter() + this._cipher = new aes.AES(key) + this._prev = Buffer.from(iv) + this._mode = mode + this._autopadding = true +} + +inherits(Cipher, Transform) + +Cipher.prototype._update = function (data) { + this._cache.add(data) + var chunk + var thing + var out = [] + + while ((chunk = this._cache.get())) { + thing = this._mode.encrypt(this, chunk) + out.push(thing) + } + + return Buffer.concat(out) +} + +var PADDING = Buffer.alloc(16, 0x10) + +Cipher.prototype._final = function () { + var chunk = this._cache.flush() + if (this._autopadding) { + chunk = this._mode.encrypt(this, chunk) + this._cipher.scrub() + return chunk + } + + if (!chunk.equals(PADDING)) { + this._cipher.scrub() + throw new Error('data not multiple of block length') + } +} + +Cipher.prototype.setAutoPadding = function (setTo) { + this._autopadding = !!setTo + return this +} + +function Splitter () { + this.cache = Buffer.allocUnsafe(0) +} + +Splitter.prototype.add = function (data) { + this.cache = Buffer.concat([this.cache, data]) +} + +Splitter.prototype.get = function () { + if (this.cache.length > 15) { + var out = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + return out + } + return null +} + +Splitter.prototype.flush = function () { + var len = 16 - this.cache.length + var padBuff = Buffer.allocUnsafe(len) + + var i = -1 + while (++i < len) { + padBuff.writeUInt8(len, i) + } + + return Buffer.concat([this.cache, padBuff]) +} + +function createCipheriv (suite, password, iv) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + if (typeof password === 'string') password = Buffer.from(password) + if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length) + + if (typeof iv === 'string') iv = Buffer.from(iv) + if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length) + + if (config.type === 'stream') { + return new StreamCipher(config.module, password, iv) + } else if (config.type === 'auth') { + return new AuthCipher(config.module, password, iv) + } + + return new Cipher(config.module, password, iv) +} + +function createCipher (suite, password) { + var config = MODES[suite.toLowerCase()] + if (!config) throw new TypeError('invalid suite type') + + var keys = ebtk(password, false, config.key, config.iv) + return createCipheriv(suite, keys.key, keys.iv) +} + +exports.createCipheriv = createCipheriv +exports.createCipher = createCipher + +},{"./aes":72,"./authCipher":73,"./modes":85,"./streamCipher":88,"cipher-base":138,"evp_bytestokey":195,"inherits":245,"safe-buffer":376}],77:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var ZEROES = Buffer.alloc(16, 0) + +function toArray (buf) { + return [ + buf.readUInt32BE(0), + buf.readUInt32BE(4), + buf.readUInt32BE(8), + buf.readUInt32BE(12) + ] +} + +function fromArray (out) { + var buf = Buffer.allocUnsafe(16) + buf.writeUInt32BE(out[0] >>> 0, 0) + buf.writeUInt32BE(out[1] >>> 0, 4) + buf.writeUInt32BE(out[2] >>> 0, 8) + buf.writeUInt32BE(out[3] >>> 0, 12) + return buf +} + +function GHASH (key) { + this.h = key + this.state = Buffer.alloc(16, 0) + this.cache = Buffer.allocUnsafe(0) +} + +// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html +// by Juho Vähä-Herttua +GHASH.prototype.ghash = function (block) { + var i = -1 + while (++i < block.length) { + this.state[i] ^= block[i] + } + this._multiply() +} + +GHASH.prototype._multiply = function () { + var Vi = toArray(this.h) + var Zi = [0, 0, 0, 0] + var j, xi, lsbVi + var i = -1 + while (++i < 128) { + xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0 + if (xi) { + // Z_i+1 = Z_i ^ V_i + Zi[0] ^= Vi[0] + Zi[1] ^= Vi[1] + Zi[2] ^= Vi[2] + Zi[3] ^= Vi[3] + } + + // Store the value of LSB(V_i) + lsbVi = (Vi[3] & 1) !== 0 + + // V_i+1 = V_i >> 1 + for (j = 3; j > 0; j--) { + Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31) + } + Vi[0] = Vi[0] >>> 1 + + // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R + if (lsbVi) { + Vi[0] = Vi[0] ^ (0xe1 << 24) + } + } + this.state = fromArray(Zi) +} + +GHASH.prototype.update = function (buf) { + this.cache = Buffer.concat([this.cache, buf]) + var chunk + while (this.cache.length >= 16) { + chunk = this.cache.slice(0, 16) + this.cache = this.cache.slice(16) + this.ghash(chunk) + } +} + +GHASH.prototype.final = function (abl, bl) { + if (this.cache.length) { + this.ghash(Buffer.concat([this.cache, ZEROES], 16)) + } + + this.ghash(fromArray([0, abl, 0, bl])) + return this.state +} + +module.exports = GHASH + +},{"safe-buffer":376}],78:[function(require,module,exports){ +function incr32 (iv) { + var len = iv.length + var item + while (len--) { + item = iv.readUInt8(len) + if (item === 255) { + iv.writeUInt8(0, len) + } else { + item++ + iv.writeUInt8(item, len) + break + } + } +} +module.exports = incr32 + +},{}],79:[function(require,module,exports){ +var xor = require('buffer-xor') + +exports.encrypt = function (self, block) { + var data = xor(block, self._prev) + + self._prev = self._cipher.encryptBlock(data) + return self._prev +} + +exports.decrypt = function (self, block) { + var pad = self._prev + + self._prev = block + var out = self._cipher.decryptBlock(block) + + return xor(out, pad) +} + +},{"buffer-xor":118}],80:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var xor = require('buffer-xor') + +function encryptStart (self, data, decrypt) { + var len = data.length + var out = xor(data, self._cache) + self._cache = self._cache.slice(len) + self._prev = Buffer.concat([self._prev, decrypt ? data : out]) + return out +} + +exports.encrypt = function (self, data, decrypt) { + var out = Buffer.allocUnsafe(0) + var len + + while (data.length) { + if (self._cache.length === 0) { + self._cache = self._cipher.encryptBlock(self._prev) + self._prev = Buffer.allocUnsafe(0) + } + + if (self._cache.length <= data.length) { + len = self._cache.length + out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)]) + data = data.slice(len) + } else { + out = Buffer.concat([out, encryptStart(self, data, decrypt)]) + break + } + } + + return out +} + +},{"buffer-xor":118,"safe-buffer":376}],81:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer + +function encryptByte (self, byteParam, decrypt) { + var pad + var i = -1 + var len = 8 + var out = 0 + var bit, value + while (++i < len) { + pad = self._cipher.encryptBlock(self._prev) + bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0 + value = pad[0] ^ bit + out += ((value & 0x80) >> (i % 8)) + self._prev = shiftIn(self._prev, decrypt ? bit : value) + } + return out +} + +function shiftIn (buffer, value) { + var len = buffer.length + var i = -1 + var out = Buffer.allocUnsafe(buffer.length) + buffer = Buffer.concat([buffer, Buffer.from([value])]) + + while (++i < len) { + out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) + } + + return out +} + +exports.encrypt = function (self, chunk, decrypt) { + var len = chunk.length + var out = Buffer.allocUnsafe(len) + var i = -1 + + while (++i < len) { + out[i] = encryptByte(self, chunk[i], decrypt) + } + + return out +} + +},{"safe-buffer":376}],82:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer + +function encryptByte (self, byteParam, decrypt) { + var pad = self._cipher.encryptBlock(self._prev) + var out = pad[0] ^ byteParam + + self._prev = Buffer.concat([ + self._prev.slice(1), + Buffer.from([decrypt ? byteParam : out]) + ]) + + return out +} + +exports.encrypt = function (self, chunk, decrypt) { + var len = chunk.length + var out = Buffer.allocUnsafe(len) + var i = -1 + + while (++i < len) { + out[i] = encryptByte(self, chunk[i], decrypt) + } + + return out +} + +},{"safe-buffer":376}],83:[function(require,module,exports){ +var xor = require('buffer-xor') +var Buffer = require('safe-buffer').Buffer +var incr32 = require('../incr32') + +function getBlock (self) { + var out = self._cipher.encryptBlockRaw(self._prev) + incr32(self._prev) + return out +} + +var blockSize = 16 +exports.encrypt = function (self, chunk) { + var chunkNum = Math.ceil(chunk.length / blockSize) + var start = self._cache.length + self._cache = Buffer.concat([ + self._cache, + Buffer.allocUnsafe(chunkNum * blockSize) + ]) + for (var i = 0; i < chunkNum; i++) { + var out = getBlock(self) + var offset = start + i * blockSize + self._cache.writeUInt32BE(out[0], offset + 0) + self._cache.writeUInt32BE(out[1], offset + 4) + self._cache.writeUInt32BE(out[2], offset + 8) + self._cache.writeUInt32BE(out[3], offset + 12) + } + var pad = self._cache.slice(0, chunk.length) + self._cache = self._cache.slice(chunk.length) + return xor(chunk, pad) +} + +},{"../incr32":78,"buffer-xor":118,"safe-buffer":376}],84:[function(require,module,exports){ +exports.encrypt = function (self, block) { + return self._cipher.encryptBlock(block) +} + +exports.decrypt = function (self, block) { + return self._cipher.decryptBlock(block) +} + +},{}],85:[function(require,module,exports){ +var modeModules = { + ECB: require('./ecb'), + CBC: require('./cbc'), + CFB: require('./cfb'), + CFB8: require('./cfb8'), + CFB1: require('./cfb1'), + OFB: require('./ofb'), + CTR: require('./ctr'), + GCM: require('./ctr') +} + +var modes = require('./list.json') + +for (var key in modes) { + modes[key].module = modeModules[modes[key].mode] +} + +module.exports = modes + +},{"./cbc":79,"./cfb":80,"./cfb1":81,"./cfb8":82,"./ctr":83,"./ecb":84,"./list.json":86,"./ofb":87}],86:[function(require,module,exports){ +module.exports={ + "aes-128-ecb": { + "cipher": "AES", + "key": 128, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-192-ecb": { + "cipher": "AES", + "key": 192, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-256-ecb": { + "cipher": "AES", + "key": 256, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-128-cbc": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-192-cbc": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-256-cbc": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes128": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes192": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes256": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-128-cfb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-192-cfb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-256-cfb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-128-cfb8": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-192-cfb8": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-256-cfb8": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-128-cfb1": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-192-cfb1": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-256-cfb1": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-128-ofb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-192-ofb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-256-ofb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-128-ctr": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-192-ctr": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-256-ctr": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-128-gcm": { + "cipher": "AES", + "key": 128, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-192-gcm": { + "cipher": "AES", + "key": 192, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-256-gcm": { + "cipher": "AES", + "key": 256, + "iv": 12, + "mode": "GCM", + "type": "auth" + } +} + +},{}],87:[function(require,module,exports){ +(function (Buffer){(function (){ +var xor = require('buffer-xor') + +function getBlock (self) { + self._prev = self._cipher.encryptBlock(self._prev) + return self._prev +} + +exports.encrypt = function (self, chunk) { + while (self._cache.length < chunk.length) { + self._cache = Buffer.concat([self._cache, getBlock(self)]) + } + + var pad = self._cache.slice(0, chunk.length) + self._cache = self._cache.slice(chunk.length) + return xor(chunk, pad) +} + +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":114,"buffer-xor":118}],88:[function(require,module,exports){ +var aes = require('./aes') +var Buffer = require('safe-buffer').Buffer +var Transform = require('cipher-base') +var inherits = require('inherits') + +function StreamCipher (mode, key, iv, decrypt) { + Transform.call(this) + + this._cipher = new aes.AES(key) + this._prev = Buffer.from(iv) + this._cache = Buffer.allocUnsafe(0) + this._secCache = Buffer.allocUnsafe(0) + this._decrypt = decrypt + this._mode = mode +} + +inherits(StreamCipher, Transform) + +StreamCipher.prototype._update = function (chunk) { + return this._mode.encrypt(this, chunk, this._decrypt) +} + +StreamCipher.prototype._final = function () { + this._cipher.scrub() +} + +module.exports = StreamCipher + +},{"./aes":72,"cipher-base":138,"inherits":245,"safe-buffer":376}],89:[function(require,module,exports){ +var DES = require('browserify-des') +var aes = require('browserify-aes/browser') +var aesModes = require('browserify-aes/modes') +var desModes = require('browserify-des/modes') +var ebtk = require('evp_bytestokey') + +function createCipher (suite, password) { + suite = suite.toLowerCase() + + var keyLen, ivLen + if (aesModes[suite]) { + keyLen = aesModes[suite].key + ivLen = aesModes[suite].iv + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8 + ivLen = desModes[suite].iv + } else { + throw new TypeError('invalid suite type') + } + + var keys = ebtk(password, false, keyLen, ivLen) + return createCipheriv(suite, keys.key, keys.iv) +} + +function createDecipher (suite, password) { + suite = suite.toLowerCase() + + var keyLen, ivLen + if (aesModes[suite]) { + keyLen = aesModes[suite].key + ivLen = aesModes[suite].iv + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8 + ivLen = desModes[suite].iv + } else { + throw new TypeError('invalid suite type') + } + + var keys = ebtk(password, false, keyLen, ivLen) + return createDecipheriv(suite, keys.key, keys.iv) +} + +function createCipheriv (suite, key, iv) { + suite = suite.toLowerCase() + if (aesModes[suite]) return aes.createCipheriv(suite, key, iv) + if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite }) + + throw new TypeError('invalid suite type') +} + +function createDecipheriv (suite, key, iv) { + suite = suite.toLowerCase() + if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv) + if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true }) + + throw new TypeError('invalid suite type') +} + +function getCiphers () { + return Object.keys(desModes).concat(aes.getCiphers()) +} + +exports.createCipher = exports.Cipher = createCipher +exports.createCipheriv = exports.Cipheriv = createCipheriv +exports.createDecipher = exports.Decipher = createDecipher +exports.createDecipheriv = exports.Decipheriv = createDecipheriv +exports.listCiphers = exports.getCiphers = getCiphers + +},{"browserify-aes/browser":74,"browserify-aes/modes":85,"browserify-des":90,"browserify-des/modes":91,"evp_bytestokey":195}],90:[function(require,module,exports){ +var CipherBase = require('cipher-base') +var des = require('des.js') +var inherits = require('inherits') +var Buffer = require('safe-buffer').Buffer + +var modes = { + 'des-ede3-cbc': des.CBC.instantiate(des.EDE), + 'des-ede3': des.EDE, + 'des-ede-cbc': des.CBC.instantiate(des.EDE), + 'des-ede': des.EDE, + 'des-cbc': des.CBC.instantiate(des.DES), + 'des-ecb': des.DES +} +modes.des = modes['des-cbc'] +modes.des3 = modes['des-ede3-cbc'] +module.exports = DES +inherits(DES, CipherBase) +function DES (opts) { + CipherBase.call(this) + var modeName = opts.mode.toLowerCase() + var mode = modes[modeName] + var type + if (opts.decrypt) { + type = 'decrypt' + } else { + type = 'encrypt' + } + var key = opts.key + if (!Buffer.isBuffer(key)) { + key = Buffer.from(key) + } + if (modeName === 'des-ede' || modeName === 'des-ede-cbc') { + key = Buffer.concat([key, key.slice(0, 8)]) + } + var iv = opts.iv + if (!Buffer.isBuffer(iv)) { + iv = Buffer.from(iv) + } + this._des = mode.create({ + key: key, + iv: iv, + type: type + }) +} +DES.prototype._update = function (data) { + return Buffer.from(this._des.update(data)) +} +DES.prototype._final = function () { + return Buffer.from(this._des.final()) +} + +},{"cipher-base":138,"des.js":164,"inherits":245,"safe-buffer":376}],91:[function(require,module,exports){ +exports['des-ecb'] = { + key: 8, + iv: 0 +} +exports['des-cbc'] = exports.des = { + key: 8, + iv: 8 +} +exports['des-ede3-cbc'] = exports.des3 = { + key: 24, + iv: 8 +} +exports['des-ede3'] = { + key: 24, + iv: 0 +} +exports['des-ede-cbc'] = { + key: 16, + iv: 8 +} +exports['des-ede'] = { + key: 16, + iv: 0 +} + +},{}],92:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js') +var randomBytes = require('randombytes') + +function blind (priv) { + var r = getr(priv) + var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed() + return { blinder: blinder, unblinder: r.invm(priv.modulus) } +} + +function getr (priv) { + var len = priv.modulus.byteLength() + var r + do { + r = new BN(randomBytes(len)) + } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) + return r +} + +function crt (msg, priv) { + var blinds = blind(priv) + var len = priv.modulus.byteLength() + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus) + var c1 = blinded.toRed(BN.mont(priv.prime1)) + var c2 = blinded.toRed(BN.mont(priv.prime2)) + var qinv = priv.coefficient + var p = priv.prime1 + var q = priv.prime2 + var m1 = c1.redPow(priv.exponent1).fromRed() + var m2 = c2.redPow(priv.exponent2).fromRed() + var h = m1.isub(m2).imul(qinv).umod(p).imul(q) + return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len) +} +crt.getr = getr + +module.exports = crt + +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":69,"buffer":114,"randombytes":348}],93:[function(require,module,exports){ +module.exports = require('./browser/algorithms.json') + +},{"./browser/algorithms.json":94}],94:[function(require,module,exports){ +module.exports={ + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } +} + +},{}],95:[function(require,module,exports){ +module.exports={ + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" +} + +},{}],96:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var createHash = require('create-hash') +var stream = require('readable-stream') +var inherits = require('inherits') +var sign = require('./sign') +var verify = require('./verify') + +var algorithms = require('./algorithms.json') +Object.keys(algorithms).forEach(function (key) { + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') + algorithms[key.toLowerCase()] = algorithms[key] +}) + +function Sign (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hashType = data.hash + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Sign, stream.Writable) + +Sign.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} + +Sign.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this +} + +Sign.prototype.sign = function signMethod (key, enc) { + this.end() + var hash = this._hash.digest() + var sig = sign(hash, key, this._hashType, this._signType, this._tag) + + return enc ? sig.toString(enc) : sig +} + +function Verify (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Verify, stream.Writable) + +Verify.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} + +Verify.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this +} + +Verify.prototype.verify = function verifyMethod (key, sig, enc) { + if (typeof sig === 'string') sig = Buffer.from(sig, enc) + + this.end() + var hash = this._hash.digest() + return verify(sig, hash, key, this._signType, this._tag) +} + +function createSign (algorithm) { + return new Sign(algorithm) +} + +function createVerify (algorithm) { + return new Verify(algorithm) +} + +module.exports = { + Sign: createSign, + Verify: createVerify, + createSign: createSign, + createVerify: createVerify +} + +},{"./algorithms.json":94,"./sign":97,"./verify":98,"create-hash":143,"inherits":245,"readable-stream":113,"safe-buffer":376}],97:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var createHmac = require('create-hmac') +var crt = require('browserify-rsa') +var EC = require('elliptic').ec +var BN = require('bn.js') +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') + +function sign (hash, key, hashType, signType, tag) { + var priv = parseKeys(key) + if (priv.curve) { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + return ecSign(hash, priv) + } else if (priv.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong private key type') + return dsaSign(hash, priv, hashType) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + } + hash = Buffer.concat([tag, hash]) + var len = priv.modulus.byteLength() + var pad = [0, 1] + while (hash.length + pad.length + 1 < len) pad.push(0xff) + pad.push(0x00) + var i = -1 + while (++i < hash.length) pad.push(hash[i]) + + var out = crt(pad, priv) + return out +} + +function ecSign (hash, priv) { + var curveId = curves[priv.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) + + var curve = new EC(curveId) + var key = curve.keyFromPrivate(priv.privateKey) + var out = key.sign(hash) + + return Buffer.from(out.toDER()) +} + +function dsaSign (hash, priv, algo) { + var x = priv.params.priv_key + var p = priv.params.p + var q = priv.params.q + var g = priv.params.g + var r = new BN(0) + var k + var H = bits2int(hash, q).mod(q) + var s = false + var kv = getKey(x, q, hash, algo) + while (s === false) { + k = makeKey(q, kv, algo) + r = makeR(g, k, p, q) + s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + if (s.cmpn(0) === 0) { + s = false + r = new BN(0) + } + } + return toDER(r, s) +} + +function toDER (r, s) { + r = r.toArray() + s = s.toArray() + + // Pad values + if (r[0] & 0x80) r = [0].concat(r) + if (s[0] & 0x80) s = [0].concat(s) + + var total = r.length + s.length + 4 + var res = [0x30, total, 0x02, r.length] + res = res.concat(r, [0x02, s.length], s) + return Buffer.from(res) +} + +function getKey (x, q, hash, algo) { + x = Buffer.from(x.toArray()) + if (x.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - x.length) + x = Buffer.concat([zeros, x]) + } + var hlen = hash.length + var hbits = bits2octets(hash, q) + var v = Buffer.alloc(hlen) + v.fill(1) + var k = Buffer.alloc(hlen) + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + return { k: k, v: v } +} + +function bits2int (obits, q) { + var bits = new BN(obits) + var shift = (obits.length << 3) - q.bitLength() + if (shift > 0) bits.ishrn(shift) + return bits +} + +function bits2octets (bits, q) { + bits = bits2int(bits, q) + bits = bits.mod(q) + var out = Buffer.from(bits.toArray()) + if (out.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - out.length) + out = Buffer.concat([zeros, out]) + } + return out +} + +function makeKey (q, kv, algo) { + var t + var k + + do { + t = Buffer.alloc(0) + + while (t.length * 8 < q.bitLength()) { + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + t = Buffer.concat([t, kv.v]) + } + + k = bits2int(t, q) + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + } while (k.cmp(q) !== -1) + + return k +} + +function makeR (g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) +} + +module.exports = sign +module.exports.getKey = getKey +module.exports.makeKey = makeKey + +},{"./curves.json":95,"bn.js":69,"browserify-rsa":92,"create-hmac":145,"elliptic":175,"parse-asn1":323,"safe-buffer":376}],98:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var BN = require('bn.js') +var EC = require('elliptic').ec +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') + +function verify (sig, hash, key, signType, tag) { + var pub = parseKeys(key) + if (pub.type === 'ec') { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + return ecVerify(sig, hash, pub) + } else if (pub.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong public key type') + return dsaVerify(sig, hash, pub) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + } + hash = Buffer.concat([tag, hash]) + var len = pub.modulus.byteLength() + var pad = [1] + var padNum = 0 + while (hash.length + pad.length + 2 < len) { + pad.push(0xff) + padNum++ + } + pad.push(0x00) + var i = -1 + while (++i < hash.length) { + pad.push(hash[i]) + } + pad = Buffer.from(pad) + var red = BN.mont(pub.modulus) + sig = new BN(sig).toRed(red) + + sig = sig.redPow(new BN(pub.publicExponent)) + sig = Buffer.from(sig.fromRed().toArray()) + var out = padNum < 8 ? 1 : 0 + len = Math.min(sig.length, pad.length) + if (sig.length !== pad.length) out = 1 + + i = -1 + while (++i < len) out |= sig[i] ^ pad[i] + return out === 0 +} + +function ecVerify (sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + + var curve = new EC(curveId) + var pubkey = pub.data.subjectPrivateKey.data + + return curve.verify(hash, sig, pubkey) +} + +function dsaVerify (sig, hash, pub) { + var p = pub.data.p + var q = pub.data.q + var g = pub.data.g + var y = pub.data.pub_key + var unpacked = parseKeys.signature.decode(sig, 'der') + var s = unpacked.s + var r = unpacked.r + checkValue(s, q) + checkValue(r, q) + var montp = BN.mont(p) + var w = s.invm(q) + var v = g.toRed(montp) + .redPow(new BN(hash).mul(w).mod(q)) + .fromRed() + .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) + .mod(p) + .mod(q) + return v.cmp(r) === 0 +} + +function checkValue (b, q) { + if (b.cmpn(0) <= 0) throw new Error('invalid sig') + if (b.cmp(q) >= q) throw new Error('invalid sig') +} + +module.exports = verify + +},{"./curves.json":95,"bn.js":69,"elliptic":175,"parse-asn1":323,"safe-buffer":376}],99:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],100:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":102,"./_stream_writable":104,"_process":333,"dup":31,"inherits":245}],101:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":103,"dup":32,"inherits":245}],102:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":99,"./_stream_duplex":100,"./internal/streams/async_iterator":105,"./internal/streams/buffer_list":106,"./internal/streams/destroy":107,"./internal/streams/from":109,"./internal/streams/state":111,"./internal/streams/stream":112,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],103:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":99,"./_stream_duplex":100,"dup":34,"inherits":245}],104:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":99,"./_stream_duplex":100,"./internal/streams/destroy":107,"./internal/streams/state":111,"./internal/streams/stream":112,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],105:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":108,"_process":333,"dup":36}],106:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],107:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],108:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":99,"dup":39}],109:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],110:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":99,"./end-of-stream":108,"dup":41}],111:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":99,"dup":42}],112:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],113:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":100,"./lib/_stream_passthrough.js":101,"./lib/_stream_readable.js":102,"./lib/_stream_transform.js":103,"./lib/_stream_writable.js":104,"./lib/internal/streams/end-of-stream.js":108,"./lib/internal/streams/pipeline.js":110,"dup":44}],114:[function(require,module,exports){ (function (Buffer){(function (){ /*! * The buffer module from node.js, for the browser. @@ -9935,7 +21092,7 @@ function numberIsNaN (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"base64-js":4,"buffer":55,"ieee754":116}],56:[function(require,module,exports){ +},{"base64-js":19,"buffer":114,"ieee754":243}],115:[function(require,module,exports){ (function (Buffer){(function (){ function allocUnsafe (size) { if (typeof size !== 'number') { @@ -9956,7 +21113,7 @@ function allocUnsafe (size) { module.exports = allocUnsafe }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],57:[function(require,module,exports){ +},{"buffer":114}],116:[function(require,module,exports){ (function (Buffer){(function (){ var bufferFill = require('buffer-fill') var allocUnsafe = require('buffer-alloc-unsafe') @@ -9992,7 +21149,7 @@ module.exports = function alloc (size, fill, encoding) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"buffer-alloc-unsafe":56,"buffer-fill":58}],58:[function(require,module,exports){ +},{"buffer":114,"buffer-alloc-unsafe":115,"buffer-fill":117}],117:[function(require,module,exports){ (function (Buffer){(function (){ /* Node.js 6.4.0 and up has full support */ var hasFullSupport = (function () { @@ -10109,7 +21266,21 @@ function fill (buffer, val, start, end, encoding) { module.exports = fill }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],59:[function(require,module,exports){ +},{"buffer":114}],118:[function(require,module,exports){ +(function (Buffer){(function (){ +module.exports = function xor (a, b) { + var length = Math.min(a.length, b.length) + var buffer = new Buffer(length) + + for (var i = 0; i < length; ++i) { + buffer[i] = a[i] ^ b[i] + } + + return buffer +} + +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":114}],119:[function(require,module,exports){ module.exports = { "100": "Continue", "101": "Switching Protocols", @@ -10175,7 +21346,7 @@ module.exports = { "511": "Network Authentication Required" } -},{}],60:[function(require,module,exports){ +},{}],120:[function(require,module,exports){ /*! * bytes * Copyright(c) 2012-2014 TJ Holowaychuk @@ -10339,37 +21510,141 @@ function parse(val) { return Math.floor(map[unit] * floatValue); } -},{}],61:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],62:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":64,"./_stream_writable":66,"_process":189,"dup":16,"inherits":118}],63:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":65,"dup":17,"inherits":118}],64:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":61,"./_stream_duplex":62,"./internal/streams/async_iterator":67,"./internal/streams/buffer_list":68,"./internal/streams/destroy":69,"./internal/streams/from":71,"./internal/streams/state":73,"./internal/streams/stream":74,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],65:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":61,"./_stream_duplex":62,"dup":19,"inherits":118}],66:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":61,"./_stream_duplex":62,"./internal/streams/destroy":69,"./internal/streams/state":73,"./internal/streams/stream":74,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],67:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":70,"_process":189,"dup":21}],68:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],69:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],70:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":61,"dup":24}],71:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],72:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":61,"./end-of-stream":70,"dup":26}],73:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":61,"dup":27}],74:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],75:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":62,"./lib/_stream_passthrough.js":63,"./lib/_stream_readable.js":64,"./lib/_stream_transform.js":65,"./lib/_stream_writable.js":66,"./lib/internal/streams/end-of-stream.js":70,"./lib/internal/streams/pipeline.js":72,"dup":29}],76:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ +/*! cache-chunk-store. MIT License. Feross Aboukhadijeh */ +const LRU = require('lru') +const queueMicrotask = require('queue-microtask') + +class CacheStore { + constructor (store, opts) { + this.store = store + this.chunkLength = store.chunkLength + this.inProgressGets = new Map() // Map from chunk index to info on callbacks waiting for that chunk + + if (!this.store || !this.store.get || !this.store.put) { + throw new Error('First argument must be abstract-chunk-store compliant') + } + + this.cache = new LRU(opts) + } + + put (index, buf, cb = () => {}) { + if (!this.cache) { + return queueMicrotask(() => cb(new Error('CacheStore closed'))) + } + + this.cache.remove(index) + this.store.put(index, buf, cb) + } + + get (index, opts, cb = () => {}) { + if (typeof opts === 'function') return this.get(index, null, opts) + + if (!this.cache) { + return queueMicrotask(() => cb(new Error('CacheStore closed'))) + } + + if (!opts) opts = {} + + let buf = this.cache.get(index) + if (buf) { + const offset = opts.offset || 0 + const len = opts.length || (buf.length - offset) + if (offset !== 0 || len !== buf.length) { + buf = buf.slice(offset, len + offset) + } + return queueMicrotask(() => cb(null, buf)) + } + + // See if a get for this index has already started + let waiters = this.inProgressGets.get(index) + const getAlreadyStarted = !!waiters + if (!waiters) { + waiters = [] + this.inProgressGets.set(index, waiters) + } + + waiters.push({ + opts, + cb + }) + + if (!getAlreadyStarted) { + this.store.get(index, (err, buf) => { + if (!err && this.cache != null) this.cache.set(index, buf) + + const inProgressEntry = this.inProgressGets.get(index) + this.inProgressGets.delete(index) + + for (const { opts, cb } of inProgressEntry) { + if (err) { + cb(err) + } else { + const offset = opts.offset || 0 + const len = opts.length || (buf.length - offset) + let slicedBuf = buf + if (offset !== 0 || len !== buf.length) { + slicedBuf = buf.slice(offset, len + offset) + } + cb(null, slicedBuf) + } + } + }) + } + } + + close (cb = () => {}) { + if (!this.cache) { + return queueMicrotask(() => cb(new Error('CacheStore closed'))) + } + + this.cache = null + this.store.close(cb) + } + + destroy (cb = () => {}) { + if (!this.cache) { + return queueMicrotask(() => cb(new Error('CacheStore closed'))) + } + + this.cache = null + this.store.destroy(cb) + } +} + +module.exports = CacheStore + +},{"lru":249,"queue-microtask":346}],122:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],123:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":125,"./_stream_writable":127,"_process":333,"dup":31,"inherits":245}],124:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":126,"dup":32,"inherits":245}],125:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":122,"./_stream_duplex":123,"./internal/streams/async_iterator":128,"./internal/streams/buffer_list":129,"./internal/streams/destroy":130,"./internal/streams/from":132,"./internal/streams/state":134,"./internal/streams/stream":135,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],126:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":122,"./_stream_duplex":123,"dup":34,"inherits":245}],127:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":122,"./_stream_duplex":123,"./internal/streams/destroy":130,"./internal/streams/state":134,"./internal/streams/stream":135,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],128:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":131,"_process":333,"dup":36}],129:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],130:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],131:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":122,"dup":39}],132:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],133:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":122,"./end-of-stream":131,"dup":41}],134:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":122,"dup":42}],135:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],136:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":123,"./lib/_stream_passthrough.js":124,"./lib/_stream_readable.js":125,"./lib/_stream_transform.js":126,"./lib/_stream_writable.js":127,"./lib/internal/streams/end-of-stream.js":131,"./lib/internal/streams/pipeline.js":133,"dup":44}],137:[function(require,module,exports){ const BlockStream = require('block-stream2') const stream = require('readable-stream') @@ -10438,7 +21713,108 @@ class ChunkStoreWriteStream extends stream.Writable { module.exports = ChunkStoreWriteStream -},{"block-stream2":38,"readable-stream":75}],77:[function(require,module,exports){ +},{"block-stream2":53,"readable-stream":136}],138:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var Transform = require('stream').Transform +var StringDecoder = require('string_decoder').StringDecoder +var inherits = require('inherits') + +function CipherBase (hashMode) { + Transform.call(this) + this.hashMode = typeof hashMode === 'string' + if (this.hashMode) { + this[hashMode] = this._finalOrDigest + } else { + this.final = this._finalOrDigest + } + if (this._final) { + this.__final = this._final + this._final = null + } + this._decoder = null + this._encoding = null +} +inherits(CipherBase, Transform) + +CipherBase.prototype.update = function (data, inputEnc, outputEnc) { + if (typeof data === 'string') { + data = Buffer.from(data, inputEnc) + } + + var outData = this._update(data) + if (this.hashMode) return this + + if (outputEnc) { + outData = this._toString(outData, outputEnc) + } + + return outData +} + +CipherBase.prototype.setAutoPadding = function () {} +CipherBase.prototype.getAuthTag = function () { + throw new Error('trying to get auth tag in unsupported state') +} + +CipherBase.prototype.setAuthTag = function () { + throw new Error('trying to set auth tag in unsupported state') +} + +CipherBase.prototype.setAAD = function () { + throw new Error('trying to set aad in unsupported state') +} + +CipherBase.prototype._transform = function (data, _, next) { + var err + try { + if (this.hashMode) { + this._update(data) + } else { + this.push(this._update(data)) + } + } catch (e) { + err = e + } finally { + next(err) + } +} +CipherBase.prototype._flush = function (done) { + var err + try { + this.push(this.__final()) + } catch (e) { + err = e + } + + done(err) +} +CipherBase.prototype._finalOrDigest = function (outputEnc) { + var outData = this.__final() || Buffer.alloc(0) + if (outputEnc) { + outData = this._toString(outData, outputEnc, true) + } + return outData +} + +CipherBase.prototype._toString = function (value, enc, fin) { + if (!this._decoder) { + this._decoder = new StringDecoder(enc) + this._encoding = enc + } + + if (this._encoding !== enc) throw new Error('can\'t switch encodings') + + var out = this._decoder.write(value) + if (fin) { + out += this._decoder.end() + } + + return out +} + +module.exports = CipherBase + +},{"inherits":245,"safe-buffer":376,"stream":429,"string_decoder":466}],139:[function(require,module,exports){ /*! * clipboard.js v2.0.8 * https://clipboardjs.com/ @@ -11393,7 +22769,7 @@ module.exports.TinyEmitter = E; /******/ })() .default; }); -},{}],78:[function(require,module,exports){ +},{}],140:[function(require,module,exports){ module.exports = function cpus () { var num = navigator.hardwareConcurrency || 1 var cpus = [] @@ -11407,7 +22783,288 @@ module.exports = function cpus () { return cpus } -},{}],79:[function(require,module,exports){ +},{}],141:[function(require,module,exports){ +(function (Buffer){(function (){ +var elliptic = require('elliptic') +var BN = require('bn.js') + +module.exports = function createECDH (curve) { + return new ECDH(curve) +} + +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 + } +} + +aliases.p224 = aliases.secp224r1 +aliases.p256 = aliases.secp256r1 = aliases.prime256v1 +aliases.p192 = aliases.secp192r1 = aliases.prime192v1 +aliases.p384 = aliases.secp384r1 +aliases.p521 = aliases.secp521r1 + +function ECDH (curve) { + this.curveType = aliases[curve] + if (!this.curveType) { + this.curveType = { + name: curve + } + } + this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap + this.keys = void 0 +} + +ECDH.prototype.generateKeys = function (enc, format) { + this.keys = this.curve.genKeyPair() + return this.getPublicKey(enc, format) +} + +ECDH.prototype.computeSecret = function (other, inenc, enc) { + inenc = inenc || 'utf8' + if (!Buffer.isBuffer(other)) { + other = new Buffer(other, inenc) + } + var otherPub = this.curve.keyFromPublic(other).getPublic() + var out = otherPub.mul(this.keys.getPrivate()).getX() + return formatReturnValue(out, enc, this.curveType.byteLength) +} + +ECDH.prototype.getPublicKey = function (enc, format) { + var key = this.keys.getPublic(format === 'compressed', true) + if (format === 'hybrid') { + if (key[key.length - 1] % 2) { + key[0] = 7 + } else { + key[0] = 6 + } + } + return formatReturnValue(key, enc) +} + +ECDH.prototype.getPrivateKey = function (enc) { + return formatReturnValue(this.keys.getPrivate(), enc) +} + +ECDH.prototype.setPublicKey = function (pub, enc) { + enc = enc || 'utf8' + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc) + } + this.keys._importPublic(pub) + return this +} + +ECDH.prototype.setPrivateKey = function (priv, enc) { + enc = enc || 'utf8' + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc) + } + + var _priv = new BN(priv) + _priv = _priv.toString(16) + this.keys = this.curve.genKeyPair() + this.keys._importPrivate(_priv) + return this +} + +function formatReturnValue (bn, enc, len) { + if (!Array.isArray(bn)) { + bn = bn.toArray() + } + var buf = new Buffer(bn) + if (len && buf.length < len) { + var zeros = new Buffer(len - buf.length) + zeros.fill(0) + buf = Buffer.concat([zeros, buf]) + } + if (!enc) { + return buf + } else { + return buf.toString(enc) + } +} + +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":142,"buffer":114,"elliptic":175}],142:[function(require,module,exports){ +arguments[4][18][0].apply(exports,arguments) +},{"buffer":71,"dup":18}],143:[function(require,module,exports){ +'use strict' +var inherits = require('inherits') +var MD5 = require('md5.js') +var RIPEMD160 = require('ripemd160') +var sha = require('sha.js') +var Base = require('cipher-base') + +function Hash (hash) { + Base.call(this, 'digest') + + this._hash = hash +} + +inherits(Hash, Base) + +Hash.prototype._update = function (data) { + this._hash.update(data) +} + +Hash.prototype._final = function () { + return this._hash.digest() +} + +module.exports = function createHash (alg) { + alg = alg.toLowerCase() + if (alg === 'md5') return new MD5() + if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160() + + return new Hash(sha(alg)) +} + +},{"cipher-base":138,"inherits":245,"md5.js":255,"ripemd160":372,"sha.js":379}],144:[function(require,module,exports){ +var MD5 = require('md5.js') + +module.exports = function (buffer) { + return new MD5().update(buffer).digest() +} + +},{"md5.js":255}],145:[function(require,module,exports){ +'use strict' +var inherits = require('inherits') +var Legacy = require('./legacy') +var Base = require('cipher-base') +var Buffer = require('safe-buffer').Buffer +var md5 = require('create-hash/md5') +var RIPEMD160 = require('ripemd160') + +var sha = require('sha.js') + +var ZEROS = Buffer.alloc(128) + +function Hmac (alg, key) { + Base.call(this, 'digest') + if (typeof key === 'string') { + key = Buffer.from(key) + } + + var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 + + this._alg = alg + this._key = key + if (key.length > blocksize) { + var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) + key = hash.update(key).digest() + } else if (key.length < blocksize) { + key = Buffer.concat([key, ZEROS], blocksize) + } + + var ipad = this._ipad = Buffer.allocUnsafe(blocksize) + var opad = this._opad = Buffer.allocUnsafe(blocksize) + + for (var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg) + this._hash.update(ipad) +} + +inherits(Hmac, Base) + +Hmac.prototype._update = function (data) { + this._hash.update(data) +} + +Hmac.prototype._final = function () { + var h = this._hash.digest() + var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg) + return hash.update(this._opad).update(h).digest() +} + +module.exports = function createHmac (alg, key) { + alg = alg.toLowerCase() + if (alg === 'rmd160' || alg === 'ripemd160') { + return new Hmac('rmd160', key) + } + if (alg === 'md5') { + return new Legacy(md5, key) + } + return new Hmac(alg, key) +} + +},{"./legacy":146,"cipher-base":138,"create-hash/md5":144,"inherits":245,"ripemd160":372,"safe-buffer":376,"sha.js":379}],146:[function(require,module,exports){ +'use strict' +var inherits = require('inherits') +var Buffer = require('safe-buffer').Buffer + +var Base = require('cipher-base') + +var ZEROS = Buffer.alloc(128) +var blocksize = 64 + +function Hmac (alg, key) { + Base.call(this, 'digest') + if (typeof key === 'string') { + key = Buffer.from(key) + } + + this._alg = alg + this._key = key + + if (key.length > blocksize) { + key = alg(key) + } else if (key.length < blocksize) { + key = Buffer.concat([key, ZEROS], blocksize) + } + + var ipad = this._ipad = Buffer.allocUnsafe(blocksize) + var opad = this._opad = Buffer.allocUnsafe(blocksize) + + for (var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + + this._hash = [ipad] +} + +inherits(Hmac, Base) + +Hmac.prototype._update = function (data) { + this._hash.push(data) +} + +Hmac.prototype._final = function () { + var h = this._alg(Buffer.concat(this._hash)) + return this._alg(Buffer.concat([this._opad, h])) +} +module.exports = Hmac + +},{"cipher-base":138,"inherits":245,"safe-buffer":376}],147:[function(require,module,exports){ (function (global,Buffer){(function (){ /*! create-torrent. MIT License. WebTorrent LLC */ const bencode = require('bencode') @@ -11876,37 +23533,5127 @@ module.exports.announceList = announceList module.exports.isJunkPath = isJunkPath }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./get-files":54,"bencode":7,"block-stream2":38,"buffer":55,"filestream/read":113,"is-file":54,"junk":121,"multistream":168,"once":185,"path":187,"piece-length":188,"queue-microtask":195,"readable-stream":94,"run-parallel":220,"simple-sha1":244}],80:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],81:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":83,"./_stream_writable":85,"_process":189,"dup":16,"inherits":118}],82:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":84,"dup":17,"inherits":118}],83:[function(require,module,exports){ +},{"./get-files":71,"bencode":22,"block-stream2":53,"buffer":114,"filestream/read":211,"is-file":71,"junk":248,"multistream":301,"once":318,"path":325,"piece-length":332,"queue-microtask":346,"readable-stream":162,"run-parallel":374,"simple-sha1":407}],148:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],149:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":151,"./_stream_writable":153,"_process":333,"dup":31,"inherits":245}],150:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":152,"dup":32,"inherits":245}],151:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":148,"./_stream_duplex":149,"./internal/streams/async_iterator":154,"./internal/streams/buffer_list":155,"./internal/streams/destroy":156,"./internal/streams/from":158,"./internal/streams/state":160,"./internal/streams/stream":161,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],152:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":148,"./_stream_duplex":149,"dup":34,"inherits":245}],153:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":148,"./_stream_duplex":149,"./internal/streams/destroy":156,"./internal/streams/state":160,"./internal/streams/stream":161,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],154:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":157,"_process":333,"dup":36}],155:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],156:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],157:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":148,"dup":39}],158:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],159:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":148,"./end-of-stream":157,"dup":41}],160:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":148,"dup":42}],161:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],162:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":149,"./lib/_stream_passthrough.js":150,"./lib/_stream_readable.js":151,"./lib/_stream_transform.js":152,"./lib/_stream_writable.js":153,"./lib/internal/streams/end-of-stream.js":157,"./lib/internal/streams/pipeline.js":159,"dup":44}],163:[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') +var algoKeys = Object.keys(algos) +var 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 + +// the least I can do is make error messages for the rest of the node.js/crypto api. +// ;[ +// 'createCredentials' +// ].forEach(function (name) { +// exports[name] = function () { +// throw new Error([ +// 'sorry, ' + name + ' is not implemented yet', +// 'we accept pull requests', +// 'https://github.com/crypto-browserify/crypto-browserify' +// ].join('\n')) +// } +// }) + +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":89,"browserify-sign":96,"browserify-sign/algos":93,"create-ecdh":141,"create-hash":143,"create-hmac":145,"diffie-hellman":170,"pbkdf2":326,"public-encrypt":334,"randombytes":348,"randomfill":349}],164:[function(require,module,exports){ +'use strict'; + +exports.utils = require('./des/utils'); +exports.Cipher = require('./des/cipher'); +exports.DES = require('./des/des'); +exports.CBC = require('./des/cbc'); +exports.EDE = require('./des/ede'); + +},{"./des/cbc":165,"./des/cipher":166,"./des/des":167,"./des/ede":168,"./des/utils":169}],165:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var proto = {}; + +function CBCState(iv) { + assert.equal(iv.length, 8, 'Invalid IV length'); + + this.iv = new Array(8); + for (var i = 0; i < this.iv.length; i++) + this.iv[i] = iv[i]; +} + +function instantiate(Base) { + function CBC(options) { + Base.call(this, options); + this._cbcInit(); + } + inherits(CBC, Base); + + var keys = Object.keys(proto); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + CBC.prototype[key] = proto[key]; + } + + CBC.create = function create(options) { + return new CBC(options); + }; + + return CBC; +} + +exports.instantiate = instantiate; + +proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; +}; + +proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + + var iv = state.iv; + if (this.type === 'encrypt') { + for (var i = 0; i < this.blockSize; i++) + iv[i] ^= inp[inOff + i]; + + superProto._update.call(this, iv, 0, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + iv[i] = out[outOff + i]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + out[outOff + i] ^= iv[i]; + + for (var i = 0; i < this.blockSize; i++) + iv[i] = inp[inOff + i]; + } +}; + +},{"inherits":245,"minimalistic-assert":278}],166:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); + +function Cipher(options) { + this.options = options; + + this.type = this.options.type; + this.blockSize = 8; + this._init(); + + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; +} +module.exports = Cipher; + +Cipher.prototype._init = function _init() { + // Might be overrided +}; + +Cipher.prototype.update = function update(data) { + if (data.length === 0) + return []; + + if (this.type === 'decrypt') + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); +}; + +Cipher.prototype._buffer = function _buffer(data, off) { + // Append data to buffer + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i = 0; i < min; i++) + this.buffer[this.bufferOff + i] = data[off + i]; + this.bufferOff += min; + + // Shift next + return min; +}; + +Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; +}; + +Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; + + var count = ((this.bufferOff + data.length) / this.blockSize) | 0; + var out = new Array(count * this.blockSize); + + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); + + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } + + // Write blocks + var max = data.length - ((data.length - inputOff) % this.blockSize); + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } + + // Queue rest + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; + + return out; +}; + +Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; + + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); + + // TODO(indutny): optimize it, this is far from optimal + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } + + // Buffer rest of the input + inputOff += this._buffer(data, inputOff); + + return out; +}; + +Cipher.prototype.final = function final(buffer) { + var first; + if (buffer) + first = this.update(buffer); + + var last; + if (this.type === 'encrypt') + last = this._finalEncrypt(); + else + last = this._finalDecrypt(); + + if (first) + return first.concat(last); + else + return last; +}; + +Cipher.prototype._pad = function _pad(buffer, off) { + if (off === 0) + return false; + + while (off < buffer.length) + buffer[off++] = 0; + + return true; +}; + +Cipher.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; +}; + +Cipher.prototype._unpad = function _unpad(buffer) { + return buffer; +}; + +Cipher.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); + + return this._unpad(out); +}; + +},{"minimalistic-assert":278}],167:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var utils = require('./utils'); +var Cipher = require('./cipher'); + +function DESState() { + this.tmp = new Array(2); + this.keys = null; +} + +function DES(options) { + Cipher.call(this, options); + + var state = new DESState(); + this._desState = state; + + this.deriveKeys(state, options.key); +} +inherits(DES, Cipher); +module.exports = DES; + +DES.create = function create(options) { + return new DES(options); +}; + +var shiftTable = [ + 1, 1, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 1 +]; + +DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); + + assert.equal(key.length, this.blockSize, 'Invalid key length'); + + var kL = utils.readUInt32BE(key, 0); + var kR = utils.readUInt32BE(key, 4); + + utils.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i = 0; i < state.keys.length; i += 2) { + var shift = shiftTable[i >>> 1]; + kL = utils.r28shl(kL, shift); + kR = utils.r28shl(kR, shift); + utils.pc2(kL, kR, state.keys, i); + } +}; + +DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; + + var l = utils.readUInt32BE(inp, inOff); + var r = utils.readUInt32BE(inp, inOff + 4); + + // Initial Permutation + utils.ip(l, r, state.tmp, 0); + l = state.tmp[0]; + r = state.tmp[1]; + + if (this.type === 'encrypt') + this._encrypt(state, l, r, state.tmp, 0); + else + this._decrypt(state, l, r, state.tmp, 0); + + l = state.tmp[0]; + r = state.tmp[1]; + + utils.writeUInt32BE(out, l, outOff); + utils.writeUInt32BE(out, r, outOff + 4); +}; + +DES.prototype._pad = function _pad(buffer, off) { + var value = buffer.length - off; + for (var i = off; i < buffer.length; i++) + buffer[i] = value; + + return true; +}; + +DES.prototype._unpad = function _unpad(buffer) { + var pad = buffer[buffer.length - 1]; + for (var i = buffer.length - pad; i < buffer.length; i++) + assert.equal(buffer[i], pad); + + return buffer.slice(0, buffer.length - pad); +}; + +DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l = lStart; + var r = rStart; + + // Apply f() x16 times + for (var i = 0; i < state.keys.length; i += 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; + + // f(r, k) + utils.expand(r, state.tmp, 0); + + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); + + var t = r; + r = (l ^ f) >>> 0; + l = t; + } + + // Reverse Initial Permutation + utils.rip(r, l, out, off); +}; + +DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l = rStart; + var r = lStart; + + // Apply f() x16 times + for (var i = state.keys.length - 2; i >= 0; i -= 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; + + // f(r, k) + utils.expand(l, state.tmp, 0); + + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); + + var t = l; + l = (r ^ f) >>> 0; + r = t; + } + + // Reverse Initial Permutation + utils.rip(l, r, out, off); +}; + +},{"./cipher":166,"./utils":169,"inherits":245,"minimalistic-assert":278}],168:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var Cipher = require('./cipher'); +var DES = require('./des'); + +function EDEState(type, key) { + assert.equal(key.length, 24, 'Invalid key length'); + + var k1 = key.slice(0, 8); + var k2 = key.slice(8, 16); + var k3 = key.slice(16, 24); + + if (type === 'encrypt') { + this.ciphers = [ + DES.create({ type: 'encrypt', key: k1 }), + DES.create({ type: 'decrypt', key: k2 }), + DES.create({ type: 'encrypt', key: k3 }) + ]; + } else { + this.ciphers = [ + DES.create({ type: 'decrypt', key: k3 }), + DES.create({ type: 'encrypt', key: k2 }), + DES.create({ type: 'decrypt', key: k1 }) + ]; + } +} + +function EDE(options) { + Cipher.call(this, options); + + var state = new EDEState(this.type, this.options.key); + this._edeState = state; +} +inherits(EDE, Cipher); + +module.exports = EDE; + +EDE.create = function create(options) { + return new EDE(options); +}; + +EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; + + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); +}; + +EDE.prototype._pad = DES.prototype._pad; +EDE.prototype._unpad = DES.prototype._unpad; + +},{"./cipher":166,"./des":167,"inherits":245,"minimalistic-assert":278}],169:[function(require,module,exports){ +'use strict'; + +exports.readUInt32BE = function readUInt32BE(bytes, off) { + var res = (bytes[0 + off] << 24) | + (bytes[1 + off] << 16) | + (bytes[2 + off] << 8) | + bytes[3 + off]; + return res >>> 0; +}; + +exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { + bytes[0 + off] = value >>> 24; + bytes[1 + off] = (value >>> 16) & 0xff; + bytes[2 + off] = (value >>> 8) & 0xff; + bytes[3 + off] = value & 0xff; +}; + +exports.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + for (var i = 6; i >= 0; i -= 2) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + + for (var i = 6; i >= 0; i -= 2) { + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + } + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + for (var i = 0; i < 4; i++) { + for (var j = 24; j >= 0; j -= 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + for (var i = 4; i < 8; i++) { + for (var j = 24; j >= 0; j -= 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + // 7, 15, 23, 31, 39, 47, 55, 63 + // 6, 14, 22, 30, 39, 47, 55, 63 + // 5, 13, 21, 29, 39, 47, 55, 63 + // 4, 12, 20, 28 + for (var i = 7; i >= 5; i--) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } + + // 1, 9, 17, 25, 33, 41, 49, 57 + // 2, 10, 18, 26, 34, 42, 50, 58 + // 3, 11, 19, 27, 35, 43, 51, 59 + // 36, 44, 52, 60 + for (var i = 1; i <= 3; i++) { + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inR >> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.r28shl = function r28shl(num, shift) { + return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); +}; + +var pc2table = [ + // inL => outL + 14, 11, 17, 4, 27, 23, 25, 0, + 13, 22, 7, 18, 5, 9, 16, 24, + 2, 20, 12, 21, 1, 8, 15, 26, + + // inR => outR + 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 pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + var len = pc2table.length >>> 1; + for (var i = 0; i < len; i++) { + outL <<= 1; + outL |= (inL >>> pc2table[i]) & 0x1; + } + for (var i = len; i < pc2table.length; i++) { + outR <<= 1; + outR |= (inR >>> pc2table[i]) & 0x1; + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.expand = function expand(r, out, off) { + var outL = 0; + var outR = 0; + + outL = ((r & 1) << 5) | (r >>> 27); + for (var i = 23; i >= 15; i -= 4) { + outL <<= 6; + outL |= (r >>> i) & 0x3f; + } + for (var i = 11; i >= 3; i -= 4) { + outR |= (r >>> i) & 0x3f; + outR <<= 6; + } + outR |= ((r & 0x1f) << 1) | (r >>> 31); + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 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 substitute(inL, inR) { + var out = 0; + for (var i = 0; i < 4; i++) { + var b = (inL >>> (18 - i * 6)) & 0x3f; + var sb = sTable[i * 0x40 + b]; + + out <<= 4; + out |= sb; + } + for (var i = 0; i < 4; i++) { + var b = (inR >>> (18 - i * 6)) & 0x3f; + var sb = sTable[4 * 0x40 + i * 0x40 + b]; + + out <<= 4; + out |= sb; + } + return out >>> 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 permute(num) { + var out = 0; + for (var i = 0; i < permuteTable.length; i++) { + out <<= 1; + out |= (num >>> permuteTable[i]) & 0x1; + } + return out >>> 0; +}; + +exports.padSplit = function padSplit(num, size, group) { + var str = num.toString(2); + while (str.length < size) + str = '0' + str; + + var out = []; + for (var i = 0; i < size; i += group) + out.push(str.slice(i, i + group)); + return out.join(' '); +}; + +},{}],170:[function(require,module,exports){ +(function (Buffer){(function (){ +var generatePrime = require('./lib/generatePrime') +var primes = require('./lib/primes.json') + +var DH = require('./lib/dh') + +function getDiffieHellman (mod) { + var prime = new Buffer(primes[mod].prime, 'hex') + var gen = new Buffer(primes[mod].gen, 'hex') + + return new DH(prime, gen) +} + +var ENCODINGS = { + 'binary': true, 'hex': true, 'base64': true +} + +function createDiffieHellman (prime, enc, generator, genc) { + if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { + return createDiffieHellman(prime, 'binary', enc, generator) + } + + enc = enc || 'binary' + genc = genc || 'binary' + generator = generator || new Buffer([2]) + + if (!Buffer.isBuffer(generator)) { + generator = new Buffer(generator, genc) + } + + if (typeof prime === 'number') { + return new DH(generatePrime(prime, generator), generator, true) + } + + if (!Buffer.isBuffer(prime)) { + prime = new Buffer(prime, enc) + } + + return new DH(prime, generator, true) +} + +exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman +exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/dh":171,"./lib/generatePrime":172,"./lib/primes.json":173,"buffer":114}],171:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js'); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var TWENTYFOUR = new BN(24); +var ELEVEN = new BN(11); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var primes = require('./generatePrime'); +var randomBytes = require('randombytes'); +module.exports = DH; + +function setPublicKey(pub, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc); + } + this._pub = new BN(pub); + return this; +} + +function setPrivateKey(priv, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc); + } + this._priv = new BN(priv); + return this; +} + +var primeCache = {}; +function checkPrime(prime, generator) { + var gen = generator.toString('hex'); + var hex = [gen, prime.toString(16)].join('_'); + if (hex in primeCache) { + return primeCache[hex]; + } + var error = 0; + + if (prime.isEven() || + !primes.simpleSieve || + !primes.fermatTest(prime) || + !millerRabin.test(prime)) { + //not a prime so +1 + error += 1; + + if (gen === '02' || gen === '05') { + // we'd be able to check the generator + // it would fail so +8 + error += 8; + } else { + //we wouldn't be able to test the generator + // so +4 + error += 4; + } + primeCache[hex] = error; + return error; + } + if (!millerRabin.test(prime.shrn(1))) { + //not a safe prime + error += 2; + } + var rem; + switch (gen) { + case '02': + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + // unsuidable generator + error += 8; + } + break; + case '05': + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + // prime mod 10 needs to equal 3 or 7 + error += 8; + } + break; + default: + error += 4; + } + primeCache[hex] = error; + return error; +} + +function DH(prime, generator, malleable) { + this.setGenerator(generator); + this.__prime = new BN(prime); + this._prime = BN.mont(this.__prime); + this._primeLen = prime.length; + this._pub = undefined; + this._priv = undefined; + this._primeCode = undefined; + if (malleable) { + this.setPublicKey = setPublicKey; + this.setPrivateKey = setPrivateKey; + } else { + this._primeCode = 8; + } +} +Object.defineProperty(DH.prototype, 'verifyError', { + enumerable: true, + get: function () { + if (typeof this._primeCode !== 'number') { + this._primeCode = checkPrime(this.__prime, this.__gen); + } + return this._primeCode; + } +}); +DH.prototype.generateKeys = function () { + if (!this._priv) { + this._priv = new BN(randomBytes(this._primeLen)); + } + this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); + return this.getPublicKey(); +}; + +DH.prototype.computeSecret = function (other) { + other = new BN(other); + other = other.toRed(this._prime); + var secret = other.redPow(this._priv).fromRed(); + var out = new Buffer(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer(prime.length - out.length); + front.fill(0); + out = Buffer.concat([front, out]); + } + return out; +}; + +DH.prototype.getPublicKey = function getPublicKey(enc) { + return formatReturnValue(this._pub, enc); +}; + +DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue(this._priv, enc); +}; + +DH.prototype.getPrime = function (enc) { + return formatReturnValue(this.__prime, enc); +}; + +DH.prototype.getGenerator = function (enc) { + return formatReturnValue(this._gen, enc); +}; + +DH.prototype.setGenerator = function (gen, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(gen)) { + gen = new Buffer(gen, enc); + } + this.__gen = gen; + this._gen = new BN(gen); + return this; +}; + +function formatReturnValue(bn, enc) { + var buf = new Buffer(bn.toArray()); + if (!enc) { + return buf; + } else { + return buf.toString(enc); + } +} + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./generatePrime":172,"bn.js":174,"buffer":114,"miller-rabin":273,"randombytes":348}],172:[function(require,module,exports){ +var randomBytes = require('randombytes'); +module.exports = findPrime; +findPrime.simpleSieve = simpleSieve; +findPrime.fermatTest = fermatTest; +var BN = require('bn.js'); +var TWENTYFOUR = new BN(24); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var ONE = new BN(1); +var TWO = new BN(2); +var FIVE = new BN(5); +var SIXTEEN = new BN(16); +var EIGHT = new BN(8); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var ELEVEN = new BN(11); +var FOUR = new BN(4); +var TWELVE = new BN(12); +var primes = null; + +function _getPrimes() { + if (primes !== null) + return primes; + + var limit = 0x100000; + var res = []; + res[0] = 2; + for (var i = 1, k = 3; k < limit; k += 2) { + var sqrt = Math.ceil(Math.sqrt(k)); + for (var j = 0; j < i && res[j] <= sqrt; j++) + if (k % res[j] === 0) + break; + + if (i !== j && res[j] <= sqrt) + continue; + + res[i++] = k; + } + primes = res; + return res; +} + +function simpleSieve(p) { + var primes = _getPrimes(); + + for (var i = 0; i < primes.length; i++) + if (p.modn(primes[i]) === 0) { + if (p.cmpn(primes[i]) === 0) { + return true; + } else { + return false; + } + } + + return true; +} + +function fermatTest(p) { + var red = BN.mont(p); + return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; +} + +function findPrime(bits, gen) { + if (bits < 16) { + // this is what openssl does + if (gen === 2 || gen === 5) { + return new BN([0x8c, 0x7b]); + } else { + return new BN([0x8c, 0x27]); + } + } + gen = new BN(gen); + + var num, n2; + + while (true) { + num = new BN(randomBytes(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n2 = num.shrn(1); + if (simpleSieve(n2) && simpleSieve(num) && + fermatTest(n2) && fermatTest(num) && + millerRabin.test(n2) && millerRabin.test(num)) { + return num; + } + } + +} + +},{"bn.js":174,"miller-rabin":273,"randombytes":348}],173:[function(require,module,exports){ +module.exports={ + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } +} +},{}],174:[function(require,module,exports){ arguments[4][18][0].apply(exports,arguments) -},{"../errors":80,"./_stream_duplex":81,"./internal/streams/async_iterator":86,"./internal/streams/buffer_list":87,"./internal/streams/destroy":88,"./internal/streams/from":90,"./internal/streams/state":92,"./internal/streams/stream":93,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],84:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":80,"./_stream_duplex":81,"dup":19,"inherits":118}],85:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":80,"./_stream_duplex":81,"./internal/streams/destroy":88,"./internal/streams/state":92,"./internal/streams/stream":93,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],86:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":89,"_process":189,"dup":21}],87:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],88:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],89:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":80,"dup":24}],90:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],91:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":80,"./end-of-stream":89,"dup":26}],92:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":80,"dup":27}],93:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],94:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":81,"./lib/_stream_passthrough.js":82,"./lib/_stream_readable.js":83,"./lib/_stream_transform.js":84,"./lib/_stream_writable.js":85,"./lib/internal/streams/end-of-stream.js":89,"./lib/internal/streams/pipeline.js":91,"dup":29}],95:[function(require,module,exports){ +},{"buffer":71,"dup":18}],175:[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'); + +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); + +},{"../package.json":191,"./elliptic/curve":178,"./elliptic/curves":181,"./elliptic/ec":182,"./elliptic/eddsa":185,"./elliptic/utils":189,"brorand":70}],176:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; + +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); + + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + + // Useful for many curves + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); + + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + + // Temporary arrays + 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; + + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } +} +module.exports = BaseCurve; + +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); + + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + var j; + var nafW; + for (j = 0; j < naf.length; j += doubles.step) { + nafW = 0; + for (var l = j + doubles.step - 1; l >= j; l--) + nafW = (nafW << 1) + naf[l]; + repr.push(nafW); + } + + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (j = 0; j < repr.length; j++) { + nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); + } + return a.toP(); +}; + +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; + + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; + + // Get NAF form + var naf = getNAF(k, w, this._bitLength); + + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var l = 0; i >= 0 && naf[i] === 0; i--) + l++; + if (i >= 0) + l++; + acc = acc.dblp(l); + + if (i < 0) + break; + var z = naf[i]; + assert(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } + } + return p.type === 'affine' ? acc.toP() : acc; +}; + +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + var i; + var j; + var p; + for (i = 0; i < len; i++) { + p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; + } + + // Comb small window NAFs + for (i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength); + naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } + + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); + } else { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3, /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; + } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) + break; + + for (j = 0; j < len; j++) { + var z = tmp[j]; + p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); +}; + +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; + +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); +}; + +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; + +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); + } + throw new Error('Unknown point format'); +}; + +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; + +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); +}; + +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); +}; + +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null, + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; +}; + +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); +}; + +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step, + points: doubles, + }; +}; + +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res, + }; +}; + +BasePoint.prototype._getBeta = function _getBeta() { + return null; +}; + +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; +}; + +},{"../utils":189,"bn.js":190}],177:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); + +var assert = utils.assert; + +function EdwardsCurve(conf) { + // NOTE: Important as we are creating point in Base.call() + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; + + Base.call(this, 'edwards', conf); + + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; +} +inherits(EdwardsCurve, Base); +module.exports = EdwardsCurve; + +EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); +}; + +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); +}; + +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); +}; + +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var x2 = x.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x2)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); + + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); + + // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) + var y2 = y.redSqr(); + var lhs = y2.redSub(this.c2); + var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); + var x2 = lhs.redMul(rhs.redInvm()); + + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } + + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; + + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); + + var x2 = point.x.redSqr(); + var y2 = point.y.redSqr(); + var lhs = x2.redMul(this.a).redAdd(y2); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); + + return lhs.cmp(rhs) === 0; +}; + +function Point(curve, x, y, z, t) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && y === null && z === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = z ? new BN(z, 16) : this.curve.one; + this.t = t && new BN(t, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + + // Use extended coordinates + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); + } + } +} +inherits(Point, Base.BasePoint); + +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; + +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); +}; + +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.x.cmpn(0) === 0 && + (this.y.cmp(this.z) === 0 || + (this.zOne && this.y.cmp(this.curve.c) === 0)); +}; + +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = 2 * Z1^2 + var c = this.z.redSqr(); + c = c.redIAdd(c); + // D = a * A + var d = this.curve._mulA(a); + // E = (X1 + Y1)^2 - A - B + var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); + // G = D + B + var g = d.redAdd(b); + // F = G - C + var f = g.redSub(c); + // H = D - B + var h = d.redSub(b); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; + +Point.prototype._projDbl = function _projDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #doubling-dbl-2008-bbjlp + // #doubling-dbl-2007-bl + // and others + // Generally 3M + 4S or 2M + 4S + + // B = (X1 + Y1)^2 + var b = this.x.redAdd(this.y).redSqr(); + // C = X1^2 + var c = this.x.redSqr(); + // D = Y1^2 + var d = this.y.redSqr(); + + var nx; + var ny; + var nz; + var e; + var h; + var j; + if (this.curve.twisted) { + // E = a * C + e = this.curve._mulA(c); + // F = E + D + var f = e.redAdd(d); + if (this.zOne) { + // X3 = (B - C - D) * (F - 2) + nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F^2 - 2 * F + nz = f.redSqr().redSub(f).redSub(f); + } else { + // H = Z1^2 + h = this.z.redSqr(); + // J = F - 2 * H + j = f.redSub(h).redISub(h); + // X3 = (B-C-D)*J + nx = b.redSub(c).redISub(d).redMul(j); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F * J + nz = f.redMul(j); + } + } else { + // E = C + D + e = c.redAdd(d); + // H = (c * Z1)^2 + h = this.curve._mulC(this.z).redSqr(); + // J = E - 2 * H + j = e.redSub(h).redSub(h); + // X3 = c * (B - E) * J + nx = this.curve._mulC(b.redISub(e)).redMul(j); + // Y3 = c * E * (C - D) + ny = this.curve._mulC(e).redMul(c.redISub(d)); + // Z3 = E * J + nz = e.redMul(j); + } + return this.curve.point(nx, ny, nz); +}; + +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); +}; + +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M + + // A = (Y1 - X1) * (Y2 - X2) + var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); + // B = (Y1 + X1) * (Y2 + X2) + var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); + // C = T1 * k * T2 + var c = this.t.redMul(this.curve.dd).redMul(p.t); + // D = Z1 * 2 * Z2 + var d = this.z.redMul(p.z.redAdd(p.z)); + // E = B - A + var e = b.redSub(a); + // F = D - C + var f = d.redSub(c); + // G = D + C + var g = d.redAdd(c); + // H = B + A + var h = b.redAdd(a); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; + +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S + + // A = Z1 * Z2 + var a = this.z.redMul(p.z); + // B = A^2 + var b = a.redSqr(); + // C = X1 * X2 + var c = this.x.redMul(p.x); + // D = Y1 * Y2 + var d = this.y.redMul(p.y); + // E = d * C * D + var e = this.curve.d.redMul(c).redMul(d); + // F = B - E + var f = b.redSub(e); + // G = B + E + var g = b.redAdd(e); + // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) + var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); + var nx = a.redMul(f).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + // Y3 = A * G * (D - a * C) + ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); + // Z3 = F * G + nz = f.redMul(g); + } else { + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); + } + return this.curve.point(nx, ny, nz); +}; + +Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; + + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); +}; + +Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); +}; + +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); +}; + +Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); +}; + +Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; + + // Normalize coordinates + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; +}; + +Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); +}; + +Point.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); +}; + +Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); +}; + +Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; +}; + +Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(this.z); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; + +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; + +},{"../utils":189,"./base":176,"bn.js":190,"inherits":245}],178:[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":176,"./edwards":177,"./mont":179,"./short":180}],179:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); + +var utils = require('../utils'); + +function MontCurve(conf) { + Base.call(this, 'mont', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.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)); +} +inherits(MontCurve, Base); +module.exports = MontCurve; + +MontCurve.prototype.validate = function validate(point) { + var x = point.normalize().x; + var x2 = x.redSqr(); + var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); + var y = rhs.redSqrt(); + + return y.redSqr().cmp(rhs) === 0; +}; + +function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x, 16); + this.z = new BN(z, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + } +} +inherits(Point, Base.BasePoint); + +MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); +}; + +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); +}; + +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; + +Point.prototype.precompute = function precompute() { + // No-op +}; + +Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); +}; + +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; + +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A + + // A = X1 + Z1 + var a = this.x.redAdd(this.z); + // AA = A^2 + var aa = a.redSqr(); + // B = X1 - Z1 + var b = this.x.redSub(this.z); + // BB = B^2 + var bb = b.redSqr(); + // C = AA - BB + var c = aa.redSub(bb); + // X3 = AA * BB + var nx = aa.redMul(bb); + // Z3 = C * (BB + A24 * C) + var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); + return this.curve.point(nx, nz); +}; + +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; + +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A + + // A = X2 + Z2 + var a = this.x.redAdd(this.z); + // B = X2 - Z2 + var b = this.x.redSub(this.z); + // C = X3 + Z3 + var c = p.x.redAdd(p.z); + // D = X3 - Z3 + var d = p.x.redSub(p.z); + // DA = D * A + var da = d.redMul(a); + // CB = C * B + var cb = c.redMul(b); + // X5 = Z1 * (DA + CB)^2 + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + // Z5 = X1 * (DA - CB)^2 + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); +}; + +Point.prototype.mul = function mul(k) { + var t = k.clone(); + var a = this; // (N / 2) * Q + Q + var b = this.curve.point(null, null); // (N / 2) * Q + var c = this; // Q + + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); + + for (var i = bits.length - 1; i >= 0; i--) { + if (bits[i] === 0) { + // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q + a = a.diffAdd(b, c); + // N * Q = 2 * ((N / 2) * Q + Q)) + b = b.dbl(); + } else { + // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) + b = a.diffAdd(b, c); + // N * Q + Q = 2 * ((N / 2) * Q + Q) + a = a.dbl(); + } + } + return b; +}; + +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); +}; + +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; + +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; + +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; + +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); + + return this.x.fromRed(); +}; + +},{"../utils":189,"./base":176,"bn.js":190,"inherits":245}],180:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); + +var assert = utils.assert; + +function ShortCurve(conf) { + Base.call(this, 'short', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); +} +inherits(ShortCurve, Base); +module.exports = ShortCurve; + +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16), + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + + return { + beta: beta, + lambda: lambda, + basis: basis, + }; +}; + +ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; +}; + +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x2 = new BN(0); + var y2 = new BN(1); + + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; + + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); + + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; + + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; + + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } + + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } + + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; +}; + +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; + + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); + + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); + + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; +}; + +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; + + var x = point.x; + var y = point.y; + + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; +}; + +ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); + + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } + + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); + + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; + +function Point(curve, x, y, isRed) { + Base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } +} +inherits(Point, Base.BasePoint); + +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); +}; + +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); +}; + +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul), + }, + }; + } + return beta; +}; + +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1), + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1), + }, + } ]; +}; + +Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } + + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), + }, + }; + return res; +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; + +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; + + // P + O = P + if (p.inf) + return this; + + // P + P = 2P + if (this.eq(p)) + return this.dbl(); + + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); + + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); + + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; + + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + + var a = this.curve.a; + + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); + + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; + +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; + +Point.prototype.mul = function mul(k) { + k = new BN(k, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); + else + return this.curve._wnafMul(this, k); +}; + +Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); +}; + +Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); +}; + +Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); +}; + +Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate), + }, + }; + } + return res; +}; + +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; + +function JPoint(curve, x, y, z) { + Base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = new BN(z, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); + +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); +}; + +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + + return this.curve.point(ax, ay); +}; + +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; + +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) + return this; + + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); + + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; + } + + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; + + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + // Reuse results + var jyd = jy.redAdd(jy); + for (i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); + + jx = nx; + jz = nz; + jyd = dny; + } + + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +}; + +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); +}; + +JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; + + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); + + return this.curve._wnafMul(this, k); +}; + +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); + + if (this === p) + return true; + + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; + + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; +}; + +JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; + +JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; + +},{"../utils":189,"./base":176,"bn.js":190,"inherits":245}],181:[function(require,module,exports){ +'use strict'; + +var curves = exports; + +var hash = require('hash.js'); +var curve = require('./curve'); +var utils = require('./utils'); + +var assert = utils.assert; + +function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve.short(options); + else if (options.type === 'edwards') + this.curve = new curve.edwards(options); + else + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; + +function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve, + }); + return curve; + }, + }); +} + +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: false, + 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: false, + 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: false, + 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: false, + 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: false, + 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: false, + g: [ + '9', + ], +}); + +defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', + + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); + +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} + +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, + + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); + +},{"./curve":178,"./precomputed/secp256k1":188,"./utils":189,"hash.js":229}],182:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var HmacDRBG = require('hmac-drbg'); +var utils = require('../utils'); +var curves = require('../curves'); +var rand = require('brorand'); +var assert = utils.assert; + +var KeyPair = require('./key'); +var Signature = require('./signature'); + +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); + + options = curves[options]; + } + + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; + + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; + +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); +}; + +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); +}; + +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); +}; + +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray(), + }); + + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (;;) { + var priv = new BN(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; + + priv.iaddn(1); + return this.keyFromPrivate(priv); + } +}; + +EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; +}; + +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; + + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); + + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); + + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); + + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); + + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); + + for (var iter = 0; ; iter++) { + var k = options.k ? + options.k(iter) : + new BN(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; + + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; + + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; + + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; + + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); + + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } + + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + } +}; + +EC.prototype.verify = function verify(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature(signature, 'hex'); + + // Perform primitive values validation + var r = signature.r; + var s = signature.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; + + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + var p; + + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + return p.getX().umod(this.n).cmp(r) === 0; + } + + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K + + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); +}; + +EC.prototype.recoverPubKey = function(msg, signature, j, enc) { + assert((3 & j) === j, 'The recovery param is more than two bits'); + signature = new Signature(signature, enc); + + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; + + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); + + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); + + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); + + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; + +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; + + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; + } + + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; + +},{"../curves":181,"../utils":189,"./key":183,"./signature":184,"bn.js":190,"brorand":70,"hmac-drbg":241}],183:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; + +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); +} +module.exports = KeyPair; + +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); +}; + +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); +}; + +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); + + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; + + return { result: true, reason: null }; +}; + +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); +}; + +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; + +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); + + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); +}; + +KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); +}; + +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; + +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; + +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; + +KeyPair.prototype.inspect = function inspect() { + return ''; +}; + +},{"../utils":189,"bn.js":190}],184:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); + +var utils = require('../utils'); +var assert = utils.assert; + +function Signature(options, enc) { + if (options instanceof Signature) + return options; + + if (this._importDER(options, enc)) + return; + + assert(options.r && options.s, 'Signature without r or s'); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; +} +module.exports = Signature; + +function Position() { + this.place = 0; +} + +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; + + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } + + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } + + // Leading zeroes + if (val <= 0x7f) { + return false; + } + + p.place = off; + return val; +} + +function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; + } + if (i === 0) { + return buf; + } + return buf.slice(i); +} + +Signature.prototype._importDER = function _importDER(data, enc) { + data = utils.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if (len === false) { + return false; + } + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + if (rlen === false) { + return false; + } + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (slen === false) { + return false; + } + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0) { + if (r[1] & 0x80) { + r = r.slice(1); + } else { + // Leading zeroes + return false; + } + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } + + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; +}; + +function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); +} + +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); + + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); + + r = rmPadding(r); + s = rmPadding(s); + + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils.encode(res, enc); +}; + +},{"../utils":189,"bn.js":190}],185:[function(require,module,exports){ +'use strict'; + +var hash = require('hash.js'); +var curves = require('../curves'); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var KeyPair = require('./key'); +var Signature = require('./signature'); + +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); + + if (!(this instanceof EDDSA)) + return new EDDSA(curve); + + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); + + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} + +module.exports = EDDSA; + +/** +* @param {Array|String} message - message bytes +* @param {Array|String|KeyPair} secret - secret bytes or a keypair +* @returns {Signature} - signature +*/ +EDDSA.prototype.sign = function sign(message, secret) { + message = parseBytes(message); + var key = this.keyFromSecret(secret); + var r = this.hashInt(key.messagePrefix(), message); + var R = this.g.mul(r); + var Rencoded = this.encodePoint(R); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message) + .mul(key.priv()); + var S = r.add(s_).umod(this.curve.n); + return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); +}; + +/** +* @param {Array} message - message bytes +* @param {Array|String|Signature} sig - sig bytes +* @param {Array|String|Point|KeyPair} pub - public key +* @returns {Boolean} - true if public key matches sig of message +*/ +EDDSA.prototype.verify = function verify(message, sig, pub) { + message = parseBytes(message); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h)); + return RplusAh.eq(SG); +}; + +EDDSA.prototype.hashInt = function hashInt() { + var hash = this.hash(); + for (var i = 0; i < arguments.length; i++) + hash.update(arguments[i]); + return utils.intFromLE(hash.digest()).umod(this.curve.n); +}; + +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; + +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); +}; + +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; + +/** +* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 +* +* EDDSA defines methods for encoding and decoding points and integers. These are +* helper convenience methods, that pass along to utility functions implied +* parameters. +* +*/ +EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray('le', this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; + return enc; +}; + +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); + + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; + +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; + +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; + +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; +}; + +},{"../curves":181,"../utils":189,"./key":186,"./signature":187,"hash.js":229}],186:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; + +/** +* @param {EDDSA} eddsa - instance +* @param {Object} params - public/private key parameters +* +* @param {Array} [params.secret] - secret seed bytes +* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) +* @param {Array} [params.pub] - public key point encoded as bytes +* +*/ +function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; + else + this._pubBytes = parseBytes(params.pub); +} + +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); +}; + +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; + +KeyPair.prototype.secret = function secret() { + return this._secret; +}; + +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); + +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); + +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; + + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; + + return a; +}); + +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); + +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); + +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); + +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); +}; + +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); +}; + +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; + +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; + +module.exports = KeyPair; + +},{"../utils":189}],187:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; + +/** +* @param {EDDSA} eddsa - eddsa instance +* @param {Array|Object} sig - +* @param {Array|Point} [sig.R] - R point as Point or bytes +* @param {Array|bn} [sig.S] - S scalar as bn or bytes +* @param {Array} [sig.Rencoded] - R point encoded +* @param {Array} [sig.Sencoded] - S scalar encoded +*/ +function Signature(eddsa, sig) { + this.eddsa = eddsa; + + if (typeof sig !== 'object') + sig = parseBytes(sig); + + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } + + assert(sig.R && sig.S, 'Signature without R or S'); + + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; + + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} + +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); + +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); + +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); + +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); + +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); +}; + +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); +}; + +module.exports = Signature; + +},{"../utils":189,"bn.js":190}],188:[function(require,module,exports){ +module.exports = { + doubles: { + step: 4, + points: [ + [ + 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', + 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821', + ], + [ + '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', + '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf', + ], + [ + '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', + 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695', + ], + [ + '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', + '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9', + ], + [ + '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', + '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36', + ], + [ + '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', + '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f', + ], + [ + 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', + '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999', + ], + [ + '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', + 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09', + ], + [ + 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', + '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d', + ], + [ + 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', + 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088', + ], + [ + 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', + '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d', + ], + [ + '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', + '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8', + ], + [ + '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', + '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a', + ], + [ + '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', + '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453', + ], + [ + '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', + '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160', + ], + [ + '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', + '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0', + ], + [ + '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', + '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6', + ], + [ + '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', + '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589', + ], + [ + '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', + 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17', + ], + [ + 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', + '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda', + ], + [ + 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', + '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd', + ], + [ + '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', + '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2', + ], + [ + '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', + '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6', + ], + [ + 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', + '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f', + ], + [ + '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', + 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01', + ], + [ + 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', + '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3', + ], + [ + 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', + 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f', + ], + [ + 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', + '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7', + ], + [ + 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', + 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78', + ], + [ + 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', + '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1', + ], + [ + '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', + 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150', + ], + [ + '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', + '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82', + ], + [ + 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', + '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc', + ], + [ + '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', + 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b', + ], + [ + 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', + '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51', + ], + [ + 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', + '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45', + ], + [ + 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', + 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120', + ], + [ + '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', + '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84', + ], + [ + '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', + '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d', + ], + [ + '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', + 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d', + ], + [ + '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', + '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8', + ], + [ + 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', + '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8', + ], + [ + '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', + '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac', + ], + [ + '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', + 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f', + ], + [ + '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', + '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962', + ], + [ + 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', + '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907', + ], + [ + '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', + 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec', + ], + [ + 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', + 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d', + ], + [ + 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', + '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414', + ], + [ + '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', + 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd', + ], + [ + '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', + 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0', + ], + [ + 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', + '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811', + ], + [ + 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', + '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1', + ], + [ + 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', + '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c', + ], + [ + '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', + 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73', + ], + [ + '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', + '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd', + ], + [ + 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', + 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405', + ], + [ + '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', + 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589', + ], + [ + '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', + '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e', + ], + [ + '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', + '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27', + ], + [ + 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', + 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1', + ], + [ + '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', + '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482', + ], + [ + '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', + '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945', + ], + [ + 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', + '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573', + ], + [ + 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', + 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82', + ], + ], + }, + naf: { + wnd: 7, + points: [ + [ + 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', + '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672', + ], + [ + '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', + 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6', + ], + [ + '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', + '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da', + ], + [ + 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', + 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37', + ], + [ + '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', + 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b', + ], + [ + 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', + 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81', + ], + [ + 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', + '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58', + ], + [ + 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', + '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77', + ], + [ + '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', + '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a', + ], + [ + '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', + '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c', + ], + [ + '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', + '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67', + ], + [ + '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', + '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402', + ], + [ + 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', + 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55', + ], + [ + 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', + '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482', + ], + [ + '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', + 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82', + ], + [ + '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', + 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396', + ], + [ + '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', + '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49', + ], + [ + '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', + '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf', + ], + [ + '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', + '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a', + ], + [ + '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', + 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7', + ], + [ + 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', + 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933', + ], + [ + '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', + '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a', + ], + [ + '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', + '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6', + ], + [ + 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', + 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37', + ], + [ + '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', + '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e', + ], + [ + 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', + 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6', + ], + [ + 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', + 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476', + ], + [ + '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', + '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40', + ], + [ + '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', + '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61', + ], + [ + '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', + '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683', + ], + [ + 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', + '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5', + ], + [ + '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', + '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b', + ], + [ + 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', + '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417', + ], + [ + '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', + 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868', + ], + [ + '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', + 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a', + ], + [ + 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', + 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6', + ], + [ + '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', + '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996', + ], + [ + '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', + 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e', + ], + [ + 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', + 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d', + ], + [ + '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', + '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2', + ], + [ + '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', + 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e', + ], + [ + '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', + '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437', + ], + [ + '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', + 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311', + ], + [ + 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', + '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4', + ], + [ + '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', + '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575', + ], + [ + '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', + 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d', + ], + [ + '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', + 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d', + ], + [ + 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', + 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629', + ], + [ + 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', + 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06', + ], + [ + '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', + '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374', + ], + [ + '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', + '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee', + ], + [ + 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', + '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1', + ], + [ + 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', + 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b', + ], + [ + '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', + '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661', + ], + [ + '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', + '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6', + ], + [ + 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', + '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e', + ], + [ + '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', + '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d', + ], + [ + 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', + 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc', + ], + [ + '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', + 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4', + ], + [ + '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', + '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c', + ], + [ + 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', + '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b', + ], + [ + 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', + '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913', + ], + [ + '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', + '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154', + ], + [ + '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', + '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865', + ], + [ + '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', + 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc', + ], + [ + '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', + 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224', + ], + [ + '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', + '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e', + ], + [ + '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', + '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6', + ], + [ + '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', + '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511', + ], + [ + '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', + 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b', + ], + [ + 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', + 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2', + ], + [ + '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', + 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c', + ], + [ + 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', + '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3', + ], + [ + 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', + '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d', + ], + [ + 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', + '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700', + ], + [ + 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', + '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4', + ], + [ + '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', + 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196', + ], + [ + '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', + '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4', + ], + [ + '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', + 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257', + ], + [ + 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', + 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13', + ], + [ + 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', + '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096', + ], + [ + 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', + 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38', + ], + [ + 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', + '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f', + ], + [ + '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', + '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448', + ], + [ + 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', + '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a', + ], + [ + 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', + '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4', + ], + [ + '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', + '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437', + ], + [ + '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', + 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7', + ], + [ + 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', + '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d', + ], + [ + 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', + '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a', + ], + [ + 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', + '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54', + ], + [ + '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', + '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77', + ], + [ + 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', + 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517', + ], + [ + '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', + 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10', + ], + [ + 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', + 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125', + ], + [ + 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', + '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e', + ], + [ + '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', + 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1', + ], + [ + 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', + '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2', + ], + [ + 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', + '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423', + ], + [ + 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', + '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8', + ], + [ + '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', + 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758', + ], + [ + '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', + 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375', + ], + [ + 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', + '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d', + ], + [ + '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', + 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec', + ], + [ + '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', + '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0', + ], + [ + '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', + 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c', + ], + [ + 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', + 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4', + ], + [ + '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', + 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f', + ], + [ + '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', + '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649', + ], + [ + '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', + 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826', + ], + [ + '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', + '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5', + ], + [ + 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', + 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87', + ], + [ + '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', + '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b', + ], + [ + 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', + '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc', + ], + [ + '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', + '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c', + ], + [ + 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', + 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f', + ], + [ + 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', + '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a', + ], + [ + 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', + 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46', + ], + [ + '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', + 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f', + ], + [ + '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', + '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03', + ], + [ + '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', + 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08', + ], + [ + '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', + '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8', + ], + [ + '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', + '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373', + ], + [ + '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', + 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3', + ], + [ + '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', + '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8', + ], + [ + '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', + '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1', + ], + [ + '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', + '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9', + ], + ], + }, +}; + +},{}],189:[function(require,module,exports){ +'use strict'; + +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); + +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; + +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); + + var ws = 1 << (w + 1); + var k = num.clone(); + + for (var i = 0; i < naf.length; i++) { + var z; + var mod = k.andln(ws - 1); + if (k.isOdd()) { + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } + + naf[i] = z; + k.iushrn(1); + } + + return naf; +} +utils.getNAF = getNAF; + +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; + + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); + + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } + + return jsf; +} +utils.getJSF = getJSF; + +function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; +} +utils.cachedProperty = cachedProperty; + +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; + +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; + + +},{"bn.js":190,"minimalistic-assert":278,"minimalistic-crypto-utils":279}],190:[function(require,module,exports){ +arguments[4][18][0].apply(exports,arguments) +},{"buffer":71,"dup":18}],191:[function(require,module,exports){ +module.exports={ + "name": "elliptic", + "version": "6.5.4", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" + ], + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" + }, + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" + }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "homepage": "https://github.com/indutny/elliptic", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } +} + +},{}],192:[function(require,module,exports){ (function (process){(function (){ var once = require('once'); @@ -12004,7 +28751,7 @@ var eos = function(stream, opts, callback) { module.exports = eos; }).call(this)}).call(this,require('_process')) -},{"_process":189,"once":185}],96:[function(require,module,exports){ +},{"_process":333,"once":318}],193:[function(require,module,exports){ 'use strict'; /** @@ -12075,7 +28822,7 @@ function createError(err, code, props) { module.exports = createError; -},{}],97:[function(require,module,exports){ +},{}],194:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -12574,37 +29321,84 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) { } } -},{}],98:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],99:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":101,"./_stream_writable":103,"_process":189,"dup":16,"inherits":118}],100:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":102,"dup":17,"inherits":118}],101:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":98,"./_stream_duplex":99,"./internal/streams/async_iterator":104,"./internal/streams/buffer_list":105,"./internal/streams/destroy":106,"./internal/streams/from":108,"./internal/streams/state":110,"./internal/streams/stream":111,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],102:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":98,"./_stream_duplex":99,"dup":19,"inherits":118}],103:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":98,"./_stream_duplex":99,"./internal/streams/destroy":106,"./internal/streams/state":110,"./internal/streams/stream":111,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],104:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":107,"_process":189,"dup":21}],105:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],106:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],107:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":98,"dup":24}],108:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],109:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":98,"./end-of-stream":107,"dup":26}],110:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":98,"dup":27}],111:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],112:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":99,"./lib/_stream_passthrough.js":100,"./lib/_stream_readable.js":101,"./lib/_stream_transform.js":102,"./lib/_stream_writable.js":103,"./lib/internal/streams/end-of-stream.js":107,"./lib/internal/streams/pipeline.js":109,"dup":29}],113:[function(require,module,exports){ +},{}],195:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var MD5 = require('md5.js') + +/* eslint-disable camelcase */ +function EVP_BytesToKey (password, salt, keyBits, ivLen) { + if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') + if (salt) { + if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') + if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') + } + + var keyLen = keyBits / 8 + var key = Buffer.alloc(keyLen) + var iv = Buffer.alloc(ivLen || 0) + var tmp = Buffer.alloc(0) + + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5() + hash.update(tmp) + hash.update(password) + if (salt) hash.update(salt) + tmp = hash.digest() + + var used = 0 + + if (keyLen > 0) { + var keyStart = key.length - keyLen + used = Math.min(keyLen, tmp.length) + tmp.copy(key, keyStart, 0, used) + keyLen -= used + } + + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen + var length = Math.min(ivLen, tmp.length - used) + tmp.copy(iv, ivStart, used, used + length) + ivLen -= length + } + } + + tmp.fill(0) + return { key: key, iv: iv } +} + +module.exports = EVP_BytesToKey + +},{"md5.js":255,"safe-buffer":376}],196:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],197:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":199,"./_stream_writable":201,"_process":333,"dup":31,"inherits":245}],198:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":200,"dup":32,"inherits":245}],199:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":196,"./_stream_duplex":197,"./internal/streams/async_iterator":202,"./internal/streams/buffer_list":203,"./internal/streams/destroy":204,"./internal/streams/from":206,"./internal/streams/state":208,"./internal/streams/stream":209,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],200:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":196,"./_stream_duplex":197,"dup":34,"inherits":245}],201:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":196,"./_stream_duplex":197,"./internal/streams/destroy":204,"./internal/streams/state":208,"./internal/streams/stream":209,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],202:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":205,"_process":333,"dup":36}],203:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],204:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],205:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":196,"dup":39}],206:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],207:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":196,"./end-of-stream":205,"dup":41}],208:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":196,"dup":42}],209:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],210:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":197,"./lib/_stream_passthrough.js":198,"./lib/_stream_readable.js":199,"./lib/_stream_transform.js":200,"./lib/_stream_writable.js":201,"./lib/internal/streams/end-of-stream.js":205,"./lib/internal/streams/pipeline.js":207,"dup":44}],211:[function(require,module,exports){ /* global FileReader */ const { Readable } = require('readable-stream') @@ -12690,7 +29484,7 @@ class FileReadStream extends Readable { module.exports = FileReadStream -},{"readable-stream":112,"typedarray-to-buffer":298}],114:[function(require,module,exports){ +},{"readable-stream":210,"typedarray-to-buffer":476}],212:[function(require,module,exports){ // originally pulled out of simple-peer module.exports = function getBrowserRTC () { @@ -12707,7 +29501,1481 @@ module.exports = function getBrowserRTC () { return wrtc } -},{}],115:[function(require,module,exports){ +},{}],213:[function(require,module,exports){ +'use strict' +var Buffer = require('safe-buffer').Buffer +var Transform = require('readable-stream').Transform +var inherits = require('inherits') + +function throwIfNotStringOrBuffer (val, prefix) { + if (!Buffer.isBuffer(val) && typeof val !== 'string') { + throw new TypeError(prefix + ' must be a string or a buffer') + } +} + +function HashBase (blockSize) { + Transform.call(this) + + this._block = Buffer.allocUnsafe(blockSize) + this._blockSize = blockSize + this._blockOffset = 0 + this._length = [0, 0, 0, 0] + + this._finalized = false +} + +inherits(HashBase, Transform) + +HashBase.prototype._transform = function (chunk, encoding, callback) { + var error = null + try { + this.update(chunk, encoding) + } catch (err) { + error = err + } + + callback(error) +} + +HashBase.prototype._flush = function (callback) { + var error = null + try { + this.push(this.digest()) + } catch (err) { + error = err + } + + callback(error) +} + +HashBase.prototype.update = function (data, encoding) { + throwIfNotStringOrBuffer(data, 'Data') + if (this._finalized) throw new Error('Digest already called') + if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding) + + // consume data + var block = this._block + var offset = 0 + while (this._blockOffset + data.length - offset >= this._blockSize) { + for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++] + this._update() + this._blockOffset = 0 + } + while (offset < data.length) block[this._blockOffset++] = data[offset++] + + // update length + for (var j = 0, carry = data.length * 8; carry > 0; ++j) { + this._length[j] += carry + carry = (this._length[j] / 0x0100000000) | 0 + if (carry > 0) this._length[j] -= 0x0100000000 * carry + } + + return this +} + +HashBase.prototype._update = function () { + throw new Error('_update is not implemented') +} + +HashBase.prototype.digest = function (encoding) { + if (this._finalized) throw new Error('Digest already called') + this._finalized = true + + var digest = this._digest() + if (encoding !== undefined) digest = digest.toString(encoding) + + // reset state + this._block.fill(0) + this._blockOffset = 0 + for (var i = 0; i < 4; ++i) this._length[i] = 0 + + return digest +} + +HashBase.prototype._digest = function () { + throw new Error('_digest is not implemented') +} + +module.exports = HashBase + +},{"inherits":245,"readable-stream":228,"safe-buffer":376}],214:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],215:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":217,"./_stream_writable":219,"_process":333,"dup":31,"inherits":245}],216:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":218,"dup":32,"inherits":245}],217:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":214,"./_stream_duplex":215,"./internal/streams/async_iterator":220,"./internal/streams/buffer_list":221,"./internal/streams/destroy":222,"./internal/streams/from":224,"./internal/streams/state":226,"./internal/streams/stream":227,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],218:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":214,"./_stream_duplex":215,"dup":34,"inherits":245}],219:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":214,"./_stream_duplex":215,"./internal/streams/destroy":222,"./internal/streams/state":226,"./internal/streams/stream":227,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],220:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":223,"_process":333,"dup":36}],221:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],222:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],223:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":214,"dup":39}],224:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],225:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":214,"./end-of-stream":223,"dup":41}],226:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":214,"dup":42}],227:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],228:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":215,"./lib/_stream_passthrough.js":216,"./lib/_stream_readable.js":217,"./lib/_stream_transform.js":218,"./lib/_stream_writable.js":219,"./lib/internal/streams/end-of-stream.js":223,"./lib/internal/streams/pipeline.js":225,"dup":44}],229:[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'); + +// Proxy hash functions to the main object +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":230,"./hash/hmac":231,"./hash/ripemd":232,"./hash/sha":233,"./hash/utils":240}],230:[function(require,module,exports){ +'use strict'; + +var utils = require('./utils'); +var 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 update(msg, enc) { + // Convert message to array, pad it, and join into 32bit blocks + msg = utils.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + + // Enough data, try updating + if (this.pending.length >= this._delta8) { + msg = this.pending; + + // Process pending data in blocks + var r = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r, msg.length); + if (this.pending.length === 0) + this.pending = null; + + msg = utils.join32(msg, 0, msg.length - r, this.endian); + for (var i = 0; i < msg.length; i += this._delta32) + this._update(msg, i, i + this._delta32); + } + + return this; +}; + +BlockHash.prototype.digest = function digest(enc) { + this.update(this._pad()); + assert(this.pending === null); + + return this._digest(enc); +}; + +BlockHash.prototype._pad = function pad() { + var len = this.pendingTotal; + var bytes = this._delta8; + var k = bytes - ((len + this.padLength) % bytes); + var res = new Array(k + this.padLength); + res[0] = 0x80; + for (var i = 1; i < k; i++) + res[i] = 0; + + // Append length + len <<= 3; + if (this.endian === 'big') { + for (var t = 8; t < this.padLength; t++) + res[i++] = 0; + + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = (len >>> 24) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = len & 0xff; + } else { + res[i++] = len & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 24) & 0xff; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + + for (t = 8; t < this.padLength; t++) + res[i++] = 0; + } + + return res; +}; + +},{"./utils":240,"minimalistic-assert":278}],231:[function(require,module,exports){ +'use strict'; + +var utils = require('./utils'); +var assert = require('minimalistic-assert'); + +function Hmac(hash, key, enc) { + if (!(this instanceof Hmac)) + return new Hmac(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + + this._init(utils.toArray(key, enc)); +} +module.exports = Hmac; + +Hmac.prototype._init = function init(key) { + // Shorten key, if needed + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + assert(key.length <= this.blockSize); + + // Add padding to key + for (var i = key.length; i < this.blockSize; i++) + key.push(0); + + for (i = 0; i < key.length; i++) + key[i] ^= 0x36; + this.inner = new this.Hash().update(key); + + // 0x36 ^ 0x5c = 0x6a + for (i = 0; i < key.length; i++) + key[i] ^= 0x6a; + this.outer = new this.Hash().update(key); +}; + +Hmac.prototype.update = function update(msg, enc) { + this.inner.update(msg, enc); + return this; +}; + +Hmac.prototype.digest = function digest(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); +}; + +},{"./utils":240,"minimalistic-assert":278}],232:[function(require,module,exports){ +'use strict'; + +var utils = require('./utils'); +var common = require('./common'); + +var rotl32 = utils.rotl32; +var sum32 = utils.sum32; +var sum32_3 = utils.sum32_3; +var sum32_4 = utils.sum32_4; +var BlockHash = common.BlockHash; + +function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + + BlockHash.call(this); + + this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; + this.endian = 'little'; +} +utils.inherits(RIPEMD160, BlockHash); +exports.ripemd160 = RIPEMD160; + +RIPEMD160.blockSize = 512; +RIPEMD160.outSize = 160; +RIPEMD160.hmacStrength = 192; +RIPEMD160.padLength = 64; + +RIPEMD160.prototype._update = function update(msg, start) { + var A = this.h[0]; + var B = this.h[1]; + var C = this.h[2]; + var D = this.h[3]; + var E = this.h[4]; + var Ah = A; + var Bh = B; + var Ch = C; + var Dh = D; + var Eh = E; + for (var j = 0; j < 80; j++) { + var T = sum32( + rotl32( + sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), + s[j]), + E); + A = E; + E = D; + D = rotl32(C, 10); + C = B; + B = T; + T = sum32( + rotl32( + sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), + sh[j]), + Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32(Ch, 10); + Ch = Bh; + Bh = T; + } + T = sum32_3(this.h[1], C, Dh); + this.h[1] = sum32_3(this.h[2], D, Eh); + this.h[2] = sum32_3(this.h[3], E, Ah); + this.h[3] = sum32_3(this.h[4], A, Bh); + this.h[4] = sum32_3(this.h[0], B, Ch); + this.h[0] = T; +}; + +RIPEMD160.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'little'); + else + return utils.split32(this.h, 'little'); +}; + +function f(j, x, y, z) { + if (j <= 15) + return x ^ y ^ z; + else if (j <= 31) + return (x & y) | ((~x) & z); + else if (j <= 47) + return (x | (~y)) ^ z; + else if (j <= 63) + return (x & z) | (y & (~z)); + else + return x ^ (y | (~z)); +} + +function K(j) { + if (j <= 15) + return 0x00000000; + else if (j <= 31) + return 0x5a827999; + else if (j <= 47) + return 0x6ed9eba1; + else if (j <= 63) + return 0x8f1bbcdc; + else + return 0xa953fd4e; +} + +function Kh(j) { + if (j <= 15) + return 0x50a28be6; + else if (j <= 31) + return 0x5c4dd124; + else if (j <= 47) + return 0x6d703ef3; + else if (j <= 63) + return 0x7a6d76e9; + else + return 0x00000000; +} + +var r = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 +]; + +var rh = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 +]; + +var s = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 +]; + +var sh = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 +]; + +},{"./common":230,"./utils":240}],233:[function(require,module,exports){ +'use strict'; + +exports.sha1 = require('./sha/1'); +exports.sha224 = require('./sha/224'); +exports.sha256 = require('./sha/256'); +exports.sha384 = require('./sha/384'); +exports.sha512 = require('./sha/512'); + +},{"./sha/1":234,"./sha/224":235,"./sha/256":236,"./sha/384":237,"./sha/512":238}],234:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var common = require('../common'); +var shaCommon = require('./common'); + +var rotl32 = utils.rotl32; +var sum32 = utils.sum32; +var sum32_5 = utils.sum32_5; +var ft_1 = shaCommon.ft_1; +var BlockHash = common.BlockHash; + +var sha1_K = [ + 0x5A827999, 0x6ED9EBA1, + 0x8F1BBCDC, 0xCA62C1D6 +]; + +function SHA1() { + if (!(this instanceof SHA1)) + return new SHA1(); + + BlockHash.call(this); + this.h = [ + 0x67452301, 0xefcdab89, 0x98badcfe, + 0x10325476, 0xc3d2e1f0 ]; + this.W = new Array(80); +} + +utils.inherits(SHA1, BlockHash); +module.exports = SHA1; + +SHA1.blockSize = 512; +SHA1.outSize = 160; +SHA1.hmacStrength = 80; +SHA1.padLength = 64; + +SHA1.prototype._update = function _update(msg, start) { + var W = this.W; + + for (var i = 0; i < 16; i++) + W[i] = msg[start + i]; + + for(; i < W.length; i++) + W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); + + var a = this.h[0]; + var b = this.h[1]; + var c = this.h[2]; + var d = this.h[3]; + var e = this.h[4]; + + for (i = 0; i < W.length; i++) { + var s = ~~(i / 20); + var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]); + e = d; + d = c; + c = rotl32(b, 30); + b = a; + a = t; + } + + this.h[0] = sum32(this.h[0], a); + this.h[1] = sum32(this.h[1], b); + this.h[2] = sum32(this.h[2], c); + this.h[3] = sum32(this.h[3], d); + this.h[4] = sum32(this.h[4], e); +}; + +SHA1.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +},{"../common":230,"../utils":240,"./common":239}],235:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var SHA256 = require('./256'); + +function SHA224() { + if (!(this instanceof SHA224)) + return new SHA224(); + + SHA256.call(this); + this.h = [ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ]; +} +utils.inherits(SHA224, SHA256); +module.exports = SHA224; + +SHA224.blockSize = 512; +SHA224.outSize = 224; +SHA224.hmacStrength = 192; +SHA224.padLength = 64; + +SHA224.prototype._digest = function digest(enc) { + // Just truncate output + if (enc === 'hex') + return utils.toHex32(this.h.slice(0, 7), 'big'); + else + return utils.split32(this.h.slice(0, 7), 'big'); +}; + + +},{"../utils":240,"./256":236}],236:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var common = require('../common'); +var shaCommon = require('./common'); +var assert = require('minimalistic-assert'); + +var sum32 = utils.sum32; +var sum32_4 = utils.sum32_4; +var sum32_5 = utils.sum32_5; +var ch32 = shaCommon.ch32; +var maj32 = shaCommon.maj32; +var s0_256 = shaCommon.s0_256; +var s1_256 = shaCommon.s1_256; +var g0_256 = shaCommon.g0_256; +var g1_256 = shaCommon.g1_256; + +var BlockHash = common.BlockHash; + +var sha256_K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]; + +function SHA256() { + if (!(this instanceof SHA256)) + return new SHA256(); + + BlockHash.call(this); + this.h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ]; + this.k = sha256_K; + this.W = new Array(64); +} +utils.inherits(SHA256, BlockHash); +module.exports = SHA256; + +SHA256.blockSize = 512; +SHA256.outSize = 256; +SHA256.hmacStrength = 192; +SHA256.padLength = 64; + +SHA256.prototype._update = function _update(msg, start) { + var W = this.W; + + for (var i = 0; i < 16; i++) + W[i] = msg[start + i]; + for (; i < W.length; i++) + W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); + + var a = this.h[0]; + var b = this.h[1]; + var c = this.h[2]; + var d = this.h[3]; + var e = this.h[4]; + var f = this.h[5]; + var g = this.h[6]; + var h = this.h[7]; + + assert(this.k.length === W.length); + for (i = 0; i < W.length; i++) { + var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); + var T2 = sum32(s0_256(a), maj32(a, b, c)); + h = g; + g = f; + f = e; + e = sum32(d, T1); + d = c; + c = b; + b = a; + a = sum32(T1, T2); + } + + this.h[0] = sum32(this.h[0], a); + this.h[1] = sum32(this.h[1], b); + this.h[2] = sum32(this.h[2], c); + this.h[3] = sum32(this.h[3], d); + this.h[4] = sum32(this.h[4], e); + this.h[5] = sum32(this.h[5], f); + this.h[6] = sum32(this.h[6], g); + this.h[7] = sum32(this.h[7], h); +}; + +SHA256.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +},{"../common":230,"../utils":240,"./common":239,"minimalistic-assert":278}],237:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); + +var SHA512 = require('./512'); + +function SHA384() { + if (!(this instanceof SHA384)) + return new SHA384(); + + SHA512.call(this); + this.h = [ + 0xcbbb9d5d, 0xc1059ed8, + 0x629a292a, 0x367cd507, + 0x9159015a, 0x3070dd17, + 0x152fecd8, 0xf70e5939, + 0x67332667, 0xffc00b31, + 0x8eb44a87, 0x68581511, + 0xdb0c2e0d, 0x64f98fa7, + 0x47b5481d, 0xbefa4fa4 ]; +} +utils.inherits(SHA384, SHA512); +module.exports = SHA384; + +SHA384.blockSize = 1024; +SHA384.outSize = 384; +SHA384.hmacStrength = 192; +SHA384.padLength = 128; + +SHA384.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h.slice(0, 12), 'big'); + else + return utils.split32(this.h.slice(0, 12), 'big'); +}; + +},{"../utils":240,"./512":238}],238:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var common = require('../common'); +var assert = require('minimalistic-assert'); + +var rotr64_hi = utils.rotr64_hi; +var rotr64_lo = utils.rotr64_lo; +var shr64_hi = utils.shr64_hi; +var shr64_lo = utils.shr64_lo; +var sum64 = utils.sum64; +var sum64_hi = utils.sum64_hi; +var sum64_lo = utils.sum64_lo; +var sum64_4_hi = utils.sum64_4_hi; +var sum64_4_lo = utils.sum64_4_lo; +var sum64_5_hi = utils.sum64_5_hi; +var sum64_5_lo = utils.sum64_5_lo; + +var BlockHash = common.BlockHash; + +var sha512_K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 +]; + +function SHA512() { + if (!(this instanceof SHA512)) + return new SHA512(); + + BlockHash.call(this); + this.h = [ + 0x6a09e667, 0xf3bcc908, + 0xbb67ae85, 0x84caa73b, + 0x3c6ef372, 0xfe94f82b, + 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, + 0x9b05688c, 0x2b3e6c1f, + 0x1f83d9ab, 0xfb41bd6b, + 0x5be0cd19, 0x137e2179 ]; + this.k = sha512_K; + this.W = new Array(160); +} +utils.inherits(SHA512, BlockHash); +module.exports = SHA512; + +SHA512.blockSize = 1024; +SHA512.outSize = 512; +SHA512.hmacStrength = 192; +SHA512.padLength = 128; + +SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { + var W = this.W; + + // 32 x 32bit words + for (var i = 0; i < 32; i++) + W[i] = msg[start + i]; + for (; i < W.length; i += 2) { + var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 + var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); + var c1_hi = W[i - 14]; // i - 7 + var c1_lo = W[i - 13]; + var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 + var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); + var c3_hi = W[i - 32]; // i - 16 + var c3_lo = W[i - 31]; + + W[i] = sum64_4_hi( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + W[i + 1] = sum64_4_lo( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + } +}; + +SHA512.prototype._update = function _update(msg, start) { + this._prepareBlock(msg, start); + + var W = this.W; + + var ah = this.h[0]; + var al = this.h[1]; + var bh = this.h[2]; + var bl = this.h[3]; + var ch = this.h[4]; + var cl = this.h[5]; + var dh = this.h[6]; + var dl = this.h[7]; + var eh = this.h[8]; + var el = this.h[9]; + var fh = this.h[10]; + var fl = this.h[11]; + var gh = this.h[12]; + var gl = this.h[13]; + var hh = this.h[14]; + var hl = this.h[15]; + + assert(this.k.length === W.length); + for (var i = 0; i < W.length; i += 2) { + var c0_hi = hh; + var c0_lo = hl; + var c1_hi = s1_512_hi(eh, el); + var c1_lo = s1_512_lo(eh, el); + var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); + var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); + var c3_hi = this.k[i]; + var c3_lo = this.k[i + 1]; + var c4_hi = W[i]; + var c4_lo = W[i + 1]; + + var T1_hi = sum64_5_hi( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + var T1_lo = sum64_5_lo( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + + c0_hi = s0_512_hi(ah, al); + c0_lo = s0_512_lo(ah, al); + c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); + c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); + + var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); + var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); + + hh = gh; + hl = gl; + + gh = fh; + gl = fl; + + fh = eh; + fl = el; + + eh = sum64_hi(dh, dl, T1_hi, T1_lo); + el = sum64_lo(dl, dl, T1_hi, T1_lo); + + dh = ch; + dl = cl; + + ch = bh; + cl = bl; + + bh = ah; + bl = al; + + ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); + al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); + } + + sum64(this.h, 0, ah, al); + sum64(this.h, 2, bh, bl); + sum64(this.h, 4, ch, cl); + sum64(this.h, 6, dh, dl); + sum64(this.h, 8, eh, el); + sum64(this.h, 10, fh, fl); + sum64(this.h, 12, gh, gl); + sum64(this.h, 14, hh, hl); +}; + +SHA512.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +function ch64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ ((~xh) & zh); + if (r < 0) + r += 0x100000000; + return r; +} + +function ch64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ ((~xl) & zl); + if (r < 0) + r += 0x100000000; + return r; +} + +function maj64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); + if (r < 0) + r += 0x100000000; + return r; +} + +function maj64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); + if (r < 0) + r += 0x100000000; + return r; +} + +function s0_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 28); + var c1_hi = rotr64_hi(xl, xh, 2); // 34 + var c2_hi = rotr64_hi(xl, xh, 7); // 39 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function s0_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 28); + var c1_lo = rotr64_lo(xl, xh, 2); // 34 + var c2_lo = rotr64_lo(xl, xh, 7); // 39 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function s1_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 14); + var c1_hi = rotr64_hi(xh, xl, 18); + var c2_hi = rotr64_hi(xl, xh, 9); // 41 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function s1_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 14); + var c1_lo = rotr64_lo(xh, xl, 18); + var c2_lo = rotr64_lo(xl, xh, 9); // 41 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function g0_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 1); + var c1_hi = rotr64_hi(xh, xl, 8); + var c2_hi = shr64_hi(xh, xl, 7); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function g0_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 1); + var c1_lo = rotr64_lo(xh, xl, 8); + var c2_lo = shr64_lo(xh, xl, 7); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function g1_512_hi(xh, xl) { + var c0_hi = rotr64_hi(xh, xl, 19); + var c1_hi = rotr64_hi(xl, xh, 29); // 61 + var c2_hi = shr64_hi(xh, xl, 6); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function g1_512_lo(xh, xl) { + var c0_lo = rotr64_lo(xh, xl, 19); + var c1_lo = rotr64_lo(xl, xh, 29); // 61 + var c2_lo = shr64_lo(xh, xl, 6); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +},{"../common":230,"../utils":240,"minimalistic-assert":278}],239:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var rotr32 = utils.rotr32; + +function ft_1(s, x, y, z) { + if (s === 0) + return ch32(x, y, z); + if (s === 1 || s === 3) + return p32(x, y, z); + if (s === 2) + return maj32(x, y, z); +} +exports.ft_1 = ft_1; + +function ch32(x, y, z) { + return (x & y) ^ ((~x) & z); +} +exports.ch32 = ch32; + +function maj32(x, y, z) { + return (x & y) ^ (x & z) ^ (y & z); +} +exports.maj32 = maj32; + +function p32(x, y, z) { + return x ^ y ^ z; +} +exports.p32 = p32; + +function s0_256(x) { + return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); +} +exports.s0_256 = s0_256; + +function s1_256(x) { + return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); +} +exports.s1_256 = s1_256; + +function g0_256(x) { + return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3); +} +exports.g0_256 = g0_256; + +function g1_256(x) { + return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10); +} +exports.g1_256 = g1_256; + +},{"../utils":240}],240:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +exports.inherits = inherits; + +function isSurrogatePair(msg, i) { + if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) { + return false; + } + if (i < 0 || i + 1 >= msg.length) { + return false; + } + return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00; +} + +function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === 'string') { + if (!enc) { + // Inspired by stringToUtf8ByteArray() in closure-library by Google + // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143 + // Apache License 2.0 + // https://github.com/google/closure-library/blob/master/LICENSE + var p = 0; + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + if (c < 128) { + res[p++] = c; + } else if (c < 2048) { + res[p++] = (c >> 6) | 192; + res[p++] = (c & 63) | 128; + } else if (isSurrogatePair(msg, i)) { + c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF); + res[p++] = (c >> 18) | 240; + res[p++] = ((c >> 12) & 63) | 128; + res[p++] = ((c >> 6) & 63) | 128; + res[p++] = (c & 63) | 128; + } else { + res[p++] = (c >> 12) | 224; + res[p++] = ((c >> 6) & 63) | 128; + res[p++] = (c & 63) | 128; + } + } + } else if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } + } else { + for (i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + } + return res; +} +exports.toArray = toArray; + +function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; +} +exports.toHex = toHex; + +function htonl(w) { + var res = (w >>> 24) | + ((w >>> 8) & 0xff00) | + ((w << 8) & 0xff0000) | + ((w & 0xff) << 24); + return res >>> 0; +} +exports.htonl = htonl; + +function toHex32(msg, endian) { + var res = ''; + for (var i = 0; i < msg.length; i++) { + var w = msg[i]; + if (endian === 'little') + w = htonl(w); + res += zero8(w.toString(16)); + } + return res; +} +exports.toHex32 = toHex32; + +function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; +} +exports.zero2 = zero2; + +function zero8(word) { + if (word.length === 7) + return '0' + word; + else if (word.length === 6) + return '00' + word; + else if (word.length === 5) + return '000' + word; + else if (word.length === 4) + return '0000' + word; + else if (word.length === 3) + return '00000' + word; + else if (word.length === 2) + return '000000' + word; + else if (word.length === 1) + return '0000000' + word; + else + return word; +} +exports.zero8 = zero8; + +function join32(msg, start, end, endian) { + var len = end - start; + assert(len % 4 === 0); + var res = new Array(len / 4); + for (var i = 0, k = start; i < res.length; i++, k += 4) { + var w; + if (endian === 'big') + w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; + else + w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; + res[i] = w >>> 0; + } + return res; +} +exports.join32 = join32; + +function split32(msg, endian) { + var res = new Array(msg.length * 4); + for (var i = 0, k = 0; i < msg.length; i++, k += 4) { + var m = msg[i]; + if (endian === 'big') { + res[k] = m >>> 24; + res[k + 1] = (m >>> 16) & 0xff; + res[k + 2] = (m >>> 8) & 0xff; + res[k + 3] = m & 0xff; + } else { + res[k + 3] = m >>> 24; + res[k + 2] = (m >>> 16) & 0xff; + res[k + 1] = (m >>> 8) & 0xff; + res[k] = m & 0xff; + } + } + return res; +} +exports.split32 = split32; + +function rotr32(w, b) { + return (w >>> b) | (w << (32 - b)); +} +exports.rotr32 = rotr32; + +function rotl32(w, b) { + return (w << b) | (w >>> (32 - b)); +} +exports.rotl32 = rotl32; + +function sum32(a, b) { + return (a + b) >>> 0; +} +exports.sum32 = sum32; + +function sum32_3(a, b, c) { + return (a + b + c) >>> 0; +} +exports.sum32_3 = sum32_3; + +function sum32_4(a, b, c, d) { + return (a + b + c + d) >>> 0; +} +exports.sum32_4 = sum32_4; + +function sum32_5(a, b, c, d, e) { + return (a + b + c + d + e) >>> 0; +} +exports.sum32_5 = sum32_5; + +function sum64(buf, pos, ah, al) { + var bh = buf[pos]; + var bl = buf[pos + 1]; + + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + buf[pos] = hi >>> 0; + buf[pos + 1] = lo; +} +exports.sum64 = sum64; + +function sum64_hi(ah, al, bh, bl) { + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + return hi >>> 0; +} +exports.sum64_hi = sum64_hi; + +function sum64_lo(ah, al, bh, bl) { + var lo = al + bl; + return lo >>> 0; +} +exports.sum64_lo = sum64_lo; + +function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + + var hi = ah + bh + ch + dh + carry; + return hi >>> 0; +} +exports.sum64_4_hi = sum64_4_hi; + +function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { + var lo = al + bl + cl + dl; + return lo >>> 0; +} +exports.sum64_4_lo = sum64_4_lo; + +function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + lo = (lo + el) >>> 0; + carry += lo < el ? 1 : 0; + + var hi = ah + bh + ch + dh + eh + carry; + return hi >>> 0; +} +exports.sum64_5_hi = sum64_5_hi; + +function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var lo = al + bl + cl + dl + el; + + return lo >>> 0; +} +exports.sum64_5_lo = sum64_5_lo; + +function rotr64_hi(ah, al, num) { + var r = (al << (32 - num)) | (ah >>> num); + return r >>> 0; +} +exports.rotr64_hi = rotr64_hi; + +function rotr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; +} +exports.rotr64_lo = rotr64_lo; + +function shr64_hi(ah, al, num) { + return ah >>> num; +} +exports.shr64_hi = shr64_hi; + +function shr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; +} +exports.shr64_lo = shr64_lo; + +},{"inherits":245,"minimalistic-assert":278}],241:[function(require,module,exports){ +'use strict'; + +var hash = require('hash.js'); +var utils = require('minimalistic-crypto-utils'); +var assert = require('minimalistic-assert'); + +function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + + this._reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + + var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex'); + var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex'); + var pers = utils.toArray(options.pers, options.persEnc || 'hex'); + assert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + this._init(entropy, nonce, pers); +} +module.exports = HmacDRBG; + +HmacDRBG.prototype._init = function init(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i = 0; i < this.V.length; i++) { + this.K[i] = 0x00; + this.V[i] = 0x01; + } + + this._update(seed); + this._reseed = 1; + this.reseedInterval = 0x1000000000000; // 2^48 +}; + +HmacDRBG.prototype._hmac = function hmac() { + return new hash.hmac(this.hash, this.K); +}; + +HmacDRBG.prototype._update = function update(seed) { + var kmac = this._hmac() + .update(this.V) + .update([ 0x00 ]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + + this.K = this._hmac() + .update(this.V) + .update([ 0x01 ]) + .update(seed) + .digest(); + this.V = this._hmac().update(this.V).digest(); +}; + +HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { + // Optional entropy enc + if (typeof entropyEnc !== 'string') { + addEnc = add; + add = entropyEnc; + entropyEnc = null; + } + + entropy = utils.toArray(entropy, entropyEnc); + add = utils.toArray(add, addEnc); + + assert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + + this._update(entropy.concat(add || [])); + this._reseed = 1; +}; + +HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { + if (this._reseed > this.reseedInterval) + throw new Error('Reseed is required'); + + // Optional encoding + if (typeof enc !== 'string') { + addEnc = add; + add = enc; + enc = null; + } + + // Optional additional data + if (add) { + add = utils.toArray(add, addEnc || 'hex'); + this._update(add); + } + + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + + var res = temp.slice(0, len); + this._update(add); + this._reseed++; + return utils.encode(res, enc); +}; + +},{"hash.js":229,"minimalistic-assert":278,"minimalistic-crypto-utils":279}],242:[function(require,module,exports){ var http = require('http') var url = require('url') @@ -12740,7 +31008,7 @@ function validateParams (params) { return params } -},{"http":266,"url":301}],116:[function(require,module,exports){ +},{"http":444,"url":479}],243:[function(require,module,exports){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m @@ -12827,7 +31095,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],117:[function(require,module,exports){ +},{}],244:[function(require,module,exports){ /*! immediate-chunk-store. MIT License. Feross Aboukhadijeh */ // TODO: remove when window.queueMicrotask() is well supported const queueMicrotask = require('queue-microtask') @@ -12884,7 +31152,7 @@ class ImmediateStore { module.exports = ImmediateStore -},{"queue-microtask":195}],118:[function(require,module,exports){ +},{"queue-microtask":346}],245:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -12913,7 +31181,7 @@ if (typeof Object.create === 'function') { } } -},{}],119:[function(require,module,exports){ +},{}],246:[function(require,module,exports){ /* (c) 2016 Ari Porad (@ariporad) . License: ariporad.mit-license.org */ // Partially from http://stackoverflow.com/a/94049/1928484, and from another SO answer, which told me that the highest @@ -12928,7 +31196,7 @@ module.exports = function isAscii(str) { return true; }; -},{}],120:[function(require,module,exports){ +},{}],247:[function(require,module,exports){ module.exports = isTypedArray isTypedArray.strict = isStrictTypedArray isTypedArray.loose = isLooseTypedArray @@ -12971,7 +31239,7 @@ function isLooseTypedArray(arr) { return names[toString.call(arr)] } -},{}],121:[function(require,module,exports){ +},{}],248:[function(require,module,exports){ 'use strict'; const blacklist = [ @@ -13012,7 +31280,154 @@ exports.not = filename => !exports.is(filename); // TODO: Remove this for the next major release exports.default = module.exports; -},{}],122:[function(require,module,exports){ +},{}],249:[function(require,module,exports){ +var events = require('events') +var inherits = require('inherits') + +module.exports = LRU + +function LRU (opts) { + if (!(this instanceof LRU)) return new LRU(opts) + if (typeof opts === 'number') opts = {max: opts} + if (!opts) opts = {} + events.EventEmitter.call(this) + this.cache = {} + this.head = this.tail = null + this.length = 0 + this.max = opts.max || 1000 + this.maxAge = opts.maxAge || 0 +} + +inherits(LRU, events.EventEmitter) + +Object.defineProperty(LRU.prototype, 'keys', { + get: function () { return Object.keys(this.cache) } +}) + +LRU.prototype.clear = function () { + this.cache = {} + this.head = this.tail = null + this.length = 0 +} + +LRU.prototype.remove = function (key) { + if (typeof key !== 'string') key = '' + key + if (!this.cache.hasOwnProperty(key)) return + + var element = this.cache[key] + delete this.cache[key] + this._unlink(key, element.prev, element.next) + return element.value +} + +LRU.prototype._unlink = function (key, prev, next) { + this.length-- + + if (this.length === 0) { + this.head = this.tail = null + } else { + if (this.head === key) { + this.head = prev + this.cache[this.head].next = null + } else if (this.tail === key) { + this.tail = next + this.cache[this.tail].prev = null + } else { + this.cache[prev].next = next + this.cache[next].prev = prev + } + } +} + +LRU.prototype.peek = function (key) { + if (!this.cache.hasOwnProperty(key)) return + + var element = this.cache[key] + + if (!this._checkAge(key, element)) return + return element.value +} + +LRU.prototype.set = function (key, value) { + if (typeof key !== 'string') key = '' + key + + var element + + if (this.cache.hasOwnProperty(key)) { + element = this.cache[key] + element.value = value + if (this.maxAge) element.modified = Date.now() + + // If it's already the head, there's nothing more to do: + if (key === this.head) return value + this._unlink(key, element.prev, element.next) + } else { + element = {value: value, modified: 0, next: null, prev: null} + if (this.maxAge) element.modified = Date.now() + this.cache[key] = element + + // Eviction is only possible if the key didn't already exist: + if (this.length === this.max) this.evict() + } + + this.length++ + element.next = null + element.prev = this.head + + if (this.head) this.cache[this.head].next = key + this.head = key + + if (!this.tail) this.tail = key + return value +} + +LRU.prototype._checkAge = function (key, element) { + if (this.maxAge && (Date.now() - element.modified) > this.maxAge) { + this.remove(key) + this.emit('evict', {key: key, value: element.value}) + return false + } + return true +} + +LRU.prototype.get = function (key) { + if (typeof key !== 'string') key = '' + key + if (!this.cache.hasOwnProperty(key)) return + + var element = this.cache[key] + + if (!this._checkAge(key, element)) return + + if (this.head !== key) { + if (key === this.tail) { + this.tail = element.next + this.cache[this.tail].prev = null + } else { + // Set prev.next -> element.next: + this.cache[element.prev].next = element.next + } + + // Set element.next.prev -> element.prev: + this.cache[element.next].prev = element.prev + + // Element is the new head + this.cache[this.head].next = key + element.prev = this.head + element.next = null + this.head = key + } + + return element.value +} + +LRU.prototype.evict = function () { + if (!this.tail) return + var key = this.tail + var value = this.remove(this.tail) + this.emit('evict', {key: key, value: value}) +} + +},{"events":194,"inherits":245}],250:[function(require,module,exports){ (function (Buffer){(function (){ /*! lt_donthave. MIT License. WebTorrent LLC */ const arrayRemove = require('unordered-array-remove') @@ -13079,13 +31494,13 @@ module.exports = () => { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"debug":123,"events":97,"unordered-array-remove":300}],123:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":124,"_process":189,"dup":12}],124:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":125}],125:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],126:[function(require,module,exports){ +},{"buffer":114,"debug":251,"events":194,"unordered-array-remove":478}],251:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./common":252,"_process":333,"dup":27}],252:[function(require,module,exports){ +arguments[4][28][0].apply(exports,arguments) +},{"dup":28,"ms":253}],253:[function(require,module,exports){ +arguments[4][29][0].apply(exports,arguments) +},{"dup":29}],254:[function(require,module,exports){ (function (Buffer){(function (){ /*! magnet-uri. MIT License. WebTorrent LLC */ module.exports = magnetURIDecode @@ -13266,7 +31681,155 @@ function magnetURIEncode (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"bep53-range":8,"buffer":55,"thirty-two":289}],127:[function(require,module,exports){ +},{"bep53-range":23,"buffer":114,"thirty-two":467}],255:[function(require,module,exports){ +'use strict' +var inherits = require('inherits') +var HashBase = require('hash-base') +var Buffer = require('safe-buffer').Buffer + +var ARRAY16 = new Array(16) + +function MD5 () { + HashBase.call(this, 64) + + // state + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 +} + +inherits(MD5, HashBase) + +MD5.prototype._update = function () { + var M = ARRAY16 + for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4) + + var a = this._a + var b = this._b + var c = this._c + var d = this._d + + a = fnF(a, b, c, d, M[0], 0xd76aa478, 7) + d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12) + c = fnF(c, d, a, b, M[2], 0x242070db, 17) + b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22) + a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7) + d = fnF(d, a, b, c, M[5], 0x4787c62a, 12) + c = fnF(c, d, a, b, M[6], 0xa8304613, 17) + b = fnF(b, c, d, a, M[7], 0xfd469501, 22) + a = fnF(a, b, c, d, M[8], 0x698098d8, 7) + d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12) + c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17) + b = fnF(b, c, d, a, M[11], 0x895cd7be, 22) + a = fnF(a, b, c, d, M[12], 0x6b901122, 7) + d = fnF(d, a, b, c, M[13], 0xfd987193, 12) + c = fnF(c, d, a, b, M[14], 0xa679438e, 17) + b = fnF(b, c, d, a, M[15], 0x49b40821, 22) + + a = fnG(a, b, c, d, M[1], 0xf61e2562, 5) + d = fnG(d, a, b, c, M[6], 0xc040b340, 9) + c = fnG(c, d, a, b, M[11], 0x265e5a51, 14) + b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20) + a = fnG(a, b, c, d, M[5], 0xd62f105d, 5) + d = fnG(d, a, b, c, M[10], 0x02441453, 9) + c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14) + b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20) + a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5) + d = fnG(d, a, b, c, M[14], 0xc33707d6, 9) + c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14) + b = fnG(b, c, d, a, M[8], 0x455a14ed, 20) + a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5) + d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9) + c = fnG(c, d, a, b, M[7], 0x676f02d9, 14) + b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20) + + a = fnH(a, b, c, d, M[5], 0xfffa3942, 4) + d = fnH(d, a, b, c, M[8], 0x8771f681, 11) + c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16) + b = fnH(b, c, d, a, M[14], 0xfde5380c, 23) + a = fnH(a, b, c, d, M[1], 0xa4beea44, 4) + d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11) + c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16) + b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23) + a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4) + d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11) + c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16) + b = fnH(b, c, d, a, M[6], 0x04881d05, 23) + a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4) + d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11) + c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16) + b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23) + + a = fnI(a, b, c, d, M[0], 0xf4292244, 6) + d = fnI(d, a, b, c, M[7], 0x432aff97, 10) + c = fnI(c, d, a, b, M[14], 0xab9423a7, 15) + b = fnI(b, c, d, a, M[5], 0xfc93a039, 21) + a = fnI(a, b, c, d, M[12], 0x655b59c3, 6) + d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10) + c = fnI(c, d, a, b, M[10], 0xffeff47d, 15) + b = fnI(b, c, d, a, M[1], 0x85845dd1, 21) + a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6) + d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10) + c = fnI(c, d, a, b, M[6], 0xa3014314, 15) + b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21) + a = fnI(a, b, c, d, M[4], 0xf7537e82, 6) + d = fnI(d, a, b, c, M[11], 0xbd3af235, 10) + c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15) + b = fnI(b, c, d, a, M[9], 0xeb86d391, 21) + + this._a = (this._a + a) | 0 + this._b = (this._b + b) | 0 + this._c = (this._c + c) | 0 + this._d = (this._d + d) | 0 +} + +MD5.prototype._digest = function () { + // create padding and handle blocks + this._block[this._blockOffset++] = 0x80 + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64) + this._update() + this._blockOffset = 0 + } + + this._block.fill(0, this._blockOffset, 56) + this._block.writeUInt32LE(this._length[0], 56) + this._block.writeUInt32LE(this._length[1], 60) + this._update() + + // produce result + var buffer = Buffer.allocUnsafe(16) + buffer.writeInt32LE(this._a, 0) + buffer.writeInt32LE(this._b, 4) + buffer.writeInt32LE(this._c, 8) + buffer.writeInt32LE(this._d, 12) + return buffer +} + +function rotl (x, n) { + return (x << n) | (x >>> (32 - n)) +} + +function fnF (a, b, c, d, m, k, s) { + return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0 +} + +function fnG (a, b, c, d, m, k, s) { + return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0 +} + +function fnH (a, b, c, d, m, k, s) { + return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0 +} + +function fnI (a, b, c, d, m, k, s) { + return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0 +} + +module.exports = MD5 + +},{"hash-base":213,"inherits":245,"safe-buffer":376}],256:[function(require,module,exports){ /*! mediasource. MIT License. Feross Aboukhadijeh */ module.exports = MediaElementWrapper @@ -13558,37 +32121,37 @@ function downloadBuffers (bufs, name) { a.click() } -},{"inherits":118,"readable-stream":142,"to-arraybuffer":292}],128:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],129:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":131,"./_stream_writable":133,"_process":189,"dup":16,"inherits":118}],130:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":132,"dup":17,"inherits":118}],131:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":128,"./_stream_duplex":129,"./internal/streams/async_iterator":134,"./internal/streams/buffer_list":135,"./internal/streams/destroy":136,"./internal/streams/from":138,"./internal/streams/state":140,"./internal/streams/stream":141,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],132:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":128,"./_stream_duplex":129,"dup":19,"inherits":118}],133:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":128,"./_stream_duplex":129,"./internal/streams/destroy":136,"./internal/streams/state":140,"./internal/streams/stream":141,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],134:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":137,"_process":189,"dup":21}],135:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],136:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],137:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":128,"dup":24}],138:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],139:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":128,"./end-of-stream":137,"dup":26}],140:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":128,"dup":27}],141:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],142:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":129,"./lib/_stream_passthrough.js":130,"./lib/_stream_readable.js":131,"./lib/_stream_transform.js":132,"./lib/_stream_writable.js":133,"./lib/internal/streams/end-of-stream.js":137,"./lib/internal/streams/pipeline.js":139,"dup":29}],143:[function(require,module,exports){ +},{"inherits":245,"readable-stream":271,"to-arraybuffer":470}],257:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],258:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":260,"./_stream_writable":262,"_process":333,"dup":31,"inherits":245}],259:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":261,"dup":32,"inherits":245}],260:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":257,"./_stream_duplex":258,"./internal/streams/async_iterator":263,"./internal/streams/buffer_list":264,"./internal/streams/destroy":265,"./internal/streams/from":267,"./internal/streams/state":269,"./internal/streams/stream":270,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],261:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":257,"./_stream_duplex":258,"dup":34,"inherits":245}],262:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":257,"./_stream_duplex":258,"./internal/streams/destroy":265,"./internal/streams/state":269,"./internal/streams/stream":270,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],263:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":266,"_process":333,"dup":36}],264:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],265:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],266:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":257,"dup":39}],267:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],268:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":257,"./end-of-stream":266,"dup":41}],269:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":257,"dup":42}],270:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],271:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":258,"./lib/_stream_passthrough.js":259,"./lib/_stream_readable.js":260,"./lib/_stream_transform.js":261,"./lib/_stream_writable.js":262,"./lib/internal/streams/end-of-stream.js":266,"./lib/internal/streams/pipeline.js":268,"dup":44}],272:[function(require,module,exports){ module.exports = Storage const queueMicrotask = require('queue-microtask') @@ -13655,7 +32218,126 @@ Storage.prototype.close = Storage.prototype.destroy = function (cb = () => {}) { queueMicrotask(() => cb(null)) } -},{"queue-microtask":195}],144:[function(require,module,exports){ +},{"queue-microtask":346}],273:[function(require,module,exports){ +var bn = require('bn.js'); +var brorand = require('brorand'); + +function MillerRabin(rand) { + this.rand = rand || new brorand.Rand(); +} +module.exports = MillerRabin; + +MillerRabin.create = function create(rand) { + return new MillerRabin(rand); +}; + +MillerRabin.prototype._randbelow = function _randbelow(n) { + var len = n.bitLength(); + var min_bytes = Math.ceil(len / 8); + + // Generage random bytes until a number less than n is found. + // This ensures that 0..n-1 have an equal probability of being selected. + do + var a = new bn(this.rand.generate(min_bytes)); + while (a.cmp(n) >= 0); + + return a; +}; + +MillerRabin.prototype._randrange = function _randrange(start, stop) { + // Generate a random number greater than or equal to start and less than stop. + var size = stop.sub(start); + return start.add(this._randbelow(size)); +}; + +MillerRabin.prototype.test = function test(n, k, cb) { + var len = n.bitLength(); + var red = bn.mont(n); + var rone = new bn(1).toRed(red); + + if (!k) + k = Math.max(1, (len / 48) | 0); + + // Find d and s, (n - 1) = (2 ^ s) * d; + var n1 = n.subn(1); + for (var s = 0; !n1.testn(s); s++) {} + var d = n.shrn(s); + + var rn1 = n1.toRed(red); + + var prime = true; + for (; k > 0; k--) { + var a = this._randrange(new bn(2), n1); + if (cb) + cb(a); + + var x = a.toRed(red).redPow(d); + if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) + continue; + + for (var i = 1; i < s; i++) { + x = x.redSqr(); + + if (x.cmp(rone) === 0) + return false; + if (x.cmp(rn1) === 0) + break; + } + + if (i === s) + return false; + } + + return prime; +}; + +MillerRabin.prototype.getDivisor = function getDivisor(n, k) { + var len = n.bitLength(); + var red = bn.mont(n); + var rone = new bn(1).toRed(red); + + if (!k) + k = Math.max(1, (len / 48) | 0); + + // Find d and s, (n - 1) = (2 ^ s) * d; + var n1 = n.subn(1); + for (var s = 0; !n1.testn(s); s++) {} + var d = n.shrn(s); + + var rn1 = n1.toRed(red); + + for (; k > 0; k--) { + var a = this._randrange(new bn(2), n1); + + var g = n.gcd(a); + if (g.cmpn(1) !== 0) + return g; + + var x = a.toRed(red).redPow(d); + if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) + continue; + + for (var i = 1; i < s; i++) { + x = x.redSqr(); + + if (x.cmp(rone) === 0) + return x.fromRed().subn(1).gcd(n); + if (x.cmp(rn1) === 0) + break; + } + + if (i === s) { + x = x.redSqr(); + return x.fromRed().subn(1).gcd(n); + } + } + + return false; +}; + +},{"bn.js":274,"brorand":70}],274:[function(require,module,exports){ +arguments[4][18][0].apply(exports,arguments) +},{"buffer":71,"dup":18}],275:[function(require,module,exports){ module.exports={ "application/1d-interleaved-parityfec": { "source": "iana" @@ -13669,6 +32351,14 @@ module.exports={ "source": "iana", "compressible": true }, + "application/3gpphal+json": { + "source": "iana", + "compressible": true + }, + "application/3gpphalforms+json": { + "source": "iana", + "compressible": true + }, "application/a2l": { "source": "iana" }, @@ -14657,6 +33347,9 @@ module.exports={ "application/nss": { "source": "iana" }, + "application/oauth-authz-req+jwt": { + "source": "iana" + }, "application/ocsp-request": { "source": "iana" }, @@ -15000,6 +33693,10 @@ module.exports={ "source": "iana", "compressible": true }, + "application/sarif-external-properties+json": { + "source": "iana", + "compressible": true + }, "application/sbe": { "source": "iana" }, @@ -15354,6 +34051,9 @@ module.exports={ "application/vnd.3gpp-v2x-local-service-information": { "source": "iana" }, + "application/vnd.3gpp.5gnas": { + "source": "iana" + }, "application/vnd.3gpp.access-transfer-events+xml": { "source": "iana", "compressible": true @@ -15366,9 +34066,15 @@ module.exports={ "source": "iana", "compressible": true }, + "application/vnd.3gpp.gtpc": { + "source": "iana" + }, "application/vnd.3gpp.interworking-data": { "source": "iana" }, + "application/vnd.3gpp.lpp": { + "source": "iana" + }, "application/vnd.3gpp.mc-signalling-ear": { "source": "iana" }, @@ -15478,6 +34184,12 @@ module.exports={ "source": "iana", "compressible": true }, + "application/vnd.3gpp.ngap": { + "source": "iana" + }, + "application/vnd.3gpp.pfcp": { + "source": "iana" + }, "application/vnd.3gpp.pic-bw-large": { "source": "iana", "extensions": ["plb"] @@ -15490,6 +34202,9 @@ module.exports={ "source": "iana", "extensions": ["pvb"] }, + "application/vnd.3gpp.s1ap": { + "source": "iana" + }, "application/vnd.3gpp.sms": { "source": "iana" }, @@ -15980,6 +34695,9 @@ module.exports={ "application/vnd.cryptomator.encrypted": { "source": "iana" }, + "application/vnd.cryptomator.vault": { + "source": "iana" + }, "application/vnd.ctc-posml": { "source": "iana", "extensions": ["pml"] @@ -16475,6 +35193,19 @@ module.exports={ "source": "iana", "extensions": ["fsc"] }, + "application/vnd.fujifilm.fb.docuworks": { + "source": "iana" + }, + "application/vnd.fujifilm.fb.docuworks.binder": { + "source": "iana" + }, + "application/vnd.fujifilm.fb.docuworks.container": { + "source": "iana" + }, + "application/vnd.fujifilm.fb.jfi+xml": { + "source": "iana", + "compressible": true + }, "application/vnd.fujitsu.oasys": { "source": "iana", "extensions": ["oas"] @@ -17085,7 +35816,8 @@ module.exports={ "extensions": ["portpkg"] }, "application/vnd.mapbox-vector-tile": { - "source": "iana" + "source": "iana", + "extensions": ["mvt"] }, "application/vnd.marlin.drm.actiontoken+xml": { "source": "iana", @@ -19096,6 +37828,7 @@ module.exports={ "source": "iana" }, "application/wasm": { + "source": "iana", "compressible": true, "extensions": ["wasm"] }, @@ -21058,6 +39791,9 @@ module.exports={ "source": "iana", "extensions": ["x_t"] }, + "model/vnd.pytha.pyox": { + "source": "iana" + }, "model/vnd.rosette.annotated-data-model": { "source": "iana" }, @@ -21340,6 +40076,7 @@ module.exports={ "source": "iana" }, "text/shex": { + "source": "iana", "extensions": ["shex"] }, "text/slim": { @@ -21611,6 +40348,7 @@ module.exports={ "source": "iana" }, "text/yaml": { + "compressible": true, "extensions": ["yaml","yml"] }, "video/1d-interleaved-parityfec": { @@ -21980,7 +40718,7 @@ module.exports={ } } -},{}],145:[function(require,module,exports){ +},{}],276:[function(require,module,exports){ /*! * mime-db * Copyright(c) 2014 Jonathan Ong @@ -21993,7 +40731,7 @@ module.exports={ module.exports = require('./db.json') -},{"./db.json":144}],146:[function(require,module,exports){ +},{"./db.json":275}],277:[function(require,module,exports){ /*! * mime-types * Copyright(c) 2014 Jonathan Ong @@ -22183,7 +40921,80 @@ function populateMaps (extensions, types) { }) } -},{"mime-db":145,"path":187}],147:[function(require,module,exports){ +},{"mime-db":276,"path":325}],278:[function(require,module,exports){ +module.exports = assert; + +function assert(val, msg) { + if (!val) + throw new Error(msg || 'Assertion failed'); +} + +assert.equal = function assertEqual(l, r, msg) { + if (l != r) + throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); +}; + +},{}],279:[function(require,module,exports){ +'use strict'; + +var utils = exports; + +function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== 'string') { + for (var i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + return res; + } + if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (var i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } else { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } + return res; +} +utils.toArray = toArray; + +function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; +} +utils.zero2 = zero2; + +function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; +} +utils.toHex = toHex; + +utils.encode = function encode(arr, enc) { + if (enc === 'hex') + return toHex(arr); + else + return arr; +}; + +},{}],280:[function(require,module,exports){ (function (Buffer){(function (){ // This is an intentionally recursive require. I don't like it either. var Box = require('./index') @@ -23195,7 +42006,7 @@ function readString (buf, offset, length) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"./descriptor":148,"./index":149,"buffer":55,"uint64be":299}],148:[function(require,module,exports){ +},{"./descriptor":281,"./index":282,"buffer":114,"uint64be":477}],281:[function(require,module,exports){ (function (Buffer){(function (){ var tagToName = { 0x03: 'ESDescriptor', @@ -23271,7 +42082,7 @@ exports.DecoderConfigDescriptor.decode = function (buf, start, end) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],149:[function(require,module,exports){ +},{"buffer":114}],282:[function(require,module,exports){ (function (Buffer){(function (){ // var assert = require('assert') var uint64be = require('uint64be') @@ -23500,7 +42311,7 @@ Box.encodingLength = function (obj) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"./boxes":147,"buffer":55,"uint64be":299}],150:[function(require,module,exports){ +},{"./boxes":280,"buffer":114,"uint64be":477}],283:[function(require,module,exports){ (function (Buffer){(function (){ var stream = require('readable-stream') var nextEvent = require('next-event') @@ -23690,7 +42501,7 @@ class MediaData extends stream.PassThrough { module.exports = Decoder }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"mp4-box-encoding":149,"next-event":184,"readable-stream":167}],151:[function(require,module,exports){ +},{"buffer":114,"mp4-box-encoding":282,"next-event":317,"readable-stream":300}],284:[function(require,module,exports){ (function (Buffer){(function (){ var stream = require('readable-stream') var Box = require('mp4-box-encoding') @@ -23829,44 +42640,44 @@ class MediaData extends stream.PassThrough { module.exports = Encoder }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"mp4-box-encoding":149,"queue-microtask":195,"readable-stream":167}],152:[function(require,module,exports){ +},{"buffer":114,"mp4-box-encoding":282,"queue-microtask":346,"readable-stream":300}],285:[function(require,module,exports){ const Decoder = require('./decode') const Encoder = require('./encode') exports.decode = opts => new Decoder(opts) exports.encode = opts => new Encoder(opts) -},{"./decode":150,"./encode":151}],153:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],154:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":156,"./_stream_writable":158,"_process":189,"dup":16,"inherits":118}],155:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":157,"dup":17,"inherits":118}],156:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":153,"./_stream_duplex":154,"./internal/streams/async_iterator":159,"./internal/streams/buffer_list":160,"./internal/streams/destroy":161,"./internal/streams/from":163,"./internal/streams/state":165,"./internal/streams/stream":166,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],157:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":153,"./_stream_duplex":154,"dup":19,"inherits":118}],158:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":153,"./_stream_duplex":154,"./internal/streams/destroy":161,"./internal/streams/state":165,"./internal/streams/stream":166,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],159:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":162,"_process":189,"dup":21}],160:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],161:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],162:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":153,"dup":24}],163:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],164:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":153,"./end-of-stream":162,"dup":26}],165:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":153,"dup":27}],166:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],167:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":154,"./lib/_stream_passthrough.js":155,"./lib/_stream_readable.js":156,"./lib/_stream_transform.js":157,"./lib/_stream_writable.js":158,"./lib/internal/streams/end-of-stream.js":162,"./lib/internal/streams/pipeline.js":164,"dup":29}],168:[function(require,module,exports){ +},{"./decode":283,"./encode":284}],286:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],287:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":289,"./_stream_writable":291,"_process":333,"dup":31,"inherits":245}],288:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":290,"dup":32,"inherits":245}],289:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":286,"./_stream_duplex":287,"./internal/streams/async_iterator":292,"./internal/streams/buffer_list":293,"./internal/streams/destroy":294,"./internal/streams/from":296,"./internal/streams/state":298,"./internal/streams/stream":299,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],290:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":286,"./_stream_duplex":287,"dup":34,"inherits":245}],291:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":286,"./_stream_duplex":287,"./internal/streams/destroy":294,"./internal/streams/state":298,"./internal/streams/stream":299,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],292:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":295,"_process":333,"dup":36}],293:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],294:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],295:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":286,"dup":39}],296:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],297:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":286,"./end-of-stream":295,"dup":41}],298:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":286,"dup":42}],299:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],300:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":287,"./lib/_stream_passthrough.js":288,"./lib/_stream_readable.js":289,"./lib/_stream_transform.js":290,"./lib/_stream_writable.js":291,"./lib/internal/streams/end-of-stream.js":295,"./lib/internal/streams/pipeline.js":297,"dup":44}],301:[function(require,module,exports){ /*! multistream. MIT License. Feross Aboukhadijeh */ const stream = require('readable-stream') const once = require('once') @@ -24034,37 +42845,37 @@ function destroy (stream, err, cb) { } } -},{"once":185,"readable-stream":183}],169:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],170:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":172,"./_stream_writable":174,"_process":189,"dup":16,"inherits":118}],171:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":173,"dup":17,"inherits":118}],172:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":169,"./_stream_duplex":170,"./internal/streams/async_iterator":175,"./internal/streams/buffer_list":176,"./internal/streams/destroy":177,"./internal/streams/from":179,"./internal/streams/state":181,"./internal/streams/stream":182,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],173:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":169,"./_stream_duplex":170,"dup":19,"inherits":118}],174:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":169,"./_stream_duplex":170,"./internal/streams/destroy":177,"./internal/streams/state":181,"./internal/streams/stream":182,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],175:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":178,"_process":189,"dup":21}],176:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],177:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],178:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":169,"dup":24}],179:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],180:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":169,"./end-of-stream":178,"dup":26}],181:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":169,"dup":27}],182:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],183:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":170,"./lib/_stream_passthrough.js":171,"./lib/_stream_readable.js":172,"./lib/_stream_transform.js":173,"./lib/_stream_writable.js":174,"./lib/internal/streams/end-of-stream.js":178,"./lib/internal/streams/pipeline.js":180,"dup":29}],184:[function(require,module,exports){ +},{"once":318,"readable-stream":316}],302:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],303:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":305,"./_stream_writable":307,"_process":333,"dup":31,"inherits":245}],304:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":306,"dup":32,"inherits":245}],305:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":302,"./_stream_duplex":303,"./internal/streams/async_iterator":308,"./internal/streams/buffer_list":309,"./internal/streams/destroy":310,"./internal/streams/from":312,"./internal/streams/state":314,"./internal/streams/stream":315,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],306:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":302,"./_stream_duplex":303,"dup":34,"inherits":245}],307:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":302,"./_stream_duplex":303,"./internal/streams/destroy":310,"./internal/streams/state":314,"./internal/streams/stream":315,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],308:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":311,"_process":333,"dup":36}],309:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],310:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],311:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":302,"dup":39}],312:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],313:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":302,"./end-of-stream":311,"dup":41}],314:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":302,"dup":42}],315:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],316:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":303,"./lib/_stream_passthrough.js":304,"./lib/_stream_readable.js":305,"./lib/_stream_transform.js":306,"./lib/_stream_writable.js":307,"./lib/internal/streams/end-of-stream.js":311,"./lib/internal/streams/pipeline.js":313,"dup":44}],317:[function(require,module,exports){ module.exports = nextEvent function nextEvent (emitter, name) { @@ -24081,7 +42892,7 @@ function nextEvent (emitter, name) { } } -},{}],185:[function(require,module,exports){ +},{}],318:[function(require,module,exports){ var wrappy = require('wrappy') module.exports = wrappy(once) module.exports.strict = wrappy(onceStrict) @@ -24125,7 +42936,378 @@ function onceStrict (fn) { return f } -},{"wrappy":336}],186:[function(require,module,exports){ +},{"wrappy":514}],319:[function(require,module,exports){ +module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", +"2.16.840.1.101.3.4.1.2": "aes-128-cbc", +"2.16.840.1.101.3.4.1.3": "aes-128-ofb", +"2.16.840.1.101.3.4.1.4": "aes-128-cfb", +"2.16.840.1.101.3.4.1.21": "aes-192-ecb", +"2.16.840.1.101.3.4.1.22": "aes-192-cbc", +"2.16.840.1.101.3.4.1.23": "aes-192-ofb", +"2.16.840.1.101.3.4.1.24": "aes-192-cfb", +"2.16.840.1.101.3.4.1.41": "aes-256-ecb", +"2.16.840.1.101.3.4.1.42": "aes-256-cbc", +"2.16.840.1.101.3.4.1.43": "aes-256-ofb", +"2.16.840.1.101.3.4.1.44": "aes-256-cfb" +} +},{}],320:[function(require,module,exports){ +// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js +// Fedor, you are amazing. +'use strict' + +var asn1 = require('asn1.js') + +exports.certificate = require('./certificate') + +var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('modulus').int(), + this.key('publicExponent').int(), + this.key('privateExponent').int(), + this.key('prime1').int(), + this.key('prime2').int(), + this.key('exponent1').int(), + this.key('exponent2').int(), + this.key('coefficient').int() + ) +}) +exports.RSAPrivateKey = RSAPrivateKey + +var RSAPublicKey = asn1.define('RSAPublicKey', function () { + this.seq().obj( + this.key('modulus').int(), + this.key('publicExponent').int() + ) +}) +exports.RSAPublicKey = RSAPublicKey + +var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) +exports.PublicKey = PublicKey + +var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('none').null_().optional(), + this.key('curve').objid().optional(), + this.key('params').seq().obj( + this.key('p').int(), + this.key('q').int(), + this.key('g').int() + ).optional() + ) +}) + +var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { + this.seq().obj( + this.key('version').int(), + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPrivateKey').octstr() + ) +}) +exports.PrivateKey = PrivateKeyInfo +var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { + this.seq().obj( + this.key('algorithm').seq().obj( + this.key('id').objid(), + this.key('decrypt').seq().obj( + this.key('kde').seq().obj( + this.key('id').objid(), + this.key('kdeparams').seq().obj( + this.key('salt').octstr(), + this.key('iters').int() + ) + ), + this.key('cipher').seq().obj( + this.key('algo').objid(), + this.key('iv').octstr() + ) + ) + ), + this.key('subjectPrivateKey').octstr() + ) +}) + +exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + +var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('p').int(), + this.key('q').int(), + this.key('g').int(), + this.key('pub_key').int(), + this.key('priv_key').int() + ) +}) +exports.DSAPrivateKey = DSAPrivateKey + +exports.DSAparam = asn1.define('DSAparam', function () { + this.int() +}) + +var ECPrivateKey = asn1.define('ECPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('privateKey').octstr(), + this.key('parameters').optional().explicit(0).use(ECParameters), + this.key('publicKey').optional().explicit(1).bitstr() + ) +}) +exports.ECPrivateKey = ECPrivateKey + +var ECParameters = asn1.define('ECParameters', function () { + this.choice({ + namedCurve: this.objid() + }) +}) + +exports.signature = asn1.define('signature', function () { + this.seq().obj( + this.key('r').int(), + this.key('s').int() + ) +}) + +},{"./certificate":321,"asn1.js":4}],321:[function(require,module,exports){ +// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js +// thanks to @Rantanen + +'use strict' + +var asn = require('asn1.js') + +var Time = asn.define('Time', function () { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }) +}) + +var AttributeTypeValue = asn.define('AttributeTypeValue', function () { + this.seq().obj( + this.key('type').objid(), + this.key('value').any() + ) +}) + +var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('parameters').optional(), + this.key('curve').objid().optional() + ) +}) + +var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) + +var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { + this.setof(AttributeTypeValue) +}) + +var RDNSequence = asn.define('RDNSequence', function () { + this.seqof(RelativeDistinguishedName) +}) + +var Name = asn.define('Name', function () { + this.choice({ + rdnSequence: this.use(RDNSequence) + }) +}) + +var Validity = asn.define('Validity', function () { + this.seq().obj( + this.key('notBefore').use(Time), + this.key('notAfter').use(Time) + ) +}) + +var Extension = asn.define('Extension', function () { + this.seq().obj( + this.key('extnID').objid(), + this.key('critical').bool().def(false), + this.key('extnValue').octstr() + ) +}) + +var TBSCertificate = asn.define('TBSCertificate', function () { + this.seq().obj( + this.key('version').explicit(0).int().optional(), + this.key('serialNumber').int(), + this.key('signature').use(AlgorithmIdentifier), + this.key('issuer').use(Name), + this.key('validity').use(Validity), + this.key('subject').use(Name), + this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), + this.key('issuerUniqueID').implicit(1).bitstr().optional(), + this.key('subjectUniqueID').implicit(2).bitstr().optional(), + this.key('extensions').explicit(3).seqof(Extension).optional() + ) +}) + +var X509Certificate = asn.define('X509Certificate', function () { + this.seq().obj( + this.key('tbsCertificate').use(TBSCertificate), + this.key('signatureAlgorithm').use(AlgorithmIdentifier), + this.key('signatureValue').bitstr() + ) +}) + +module.exports = X509Certificate + +},{"asn1.js":4}],322:[function(require,module,exports){ +// adapted from https://github.com/apatil/pemstrip +var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m +var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m +var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m +var evp = require('evp_bytestokey') +var ciphers = require('browserify-aes') +var Buffer = require('safe-buffer').Buffer +module.exports = function (okey, password) { + var key = okey.toString() + var match = key.match(findProc) + var decrypted + if (!match) { + var match2 = key.match(fullRegex) + decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64') + } else { + var suite = 'aes' + match[1] + var iv = Buffer.from(match[2], 'hex') + var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64') + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key + var out = [] + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + decrypted = Buffer.concat(out) + } + var tag = key.match(startRegex)[1] + return { + tag: tag, + data: decrypted + } +} + +},{"browserify-aes":74,"evp_bytestokey":195,"safe-buffer":376}],323:[function(require,module,exports){ +var asn1 = require('./asn1') +var aesid = require('./aesid.json') +var fixProc = require('./fixProc') +var ciphers = require('browserify-aes') +var compat = require('pbkdf2') +var Buffer = require('safe-buffer').Buffer +module.exports = parseKeys + +function parseKeys (buffer) { + var password + if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { + password = buffer.passphrase + buffer = buffer.key + } + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer) + } + + var stripped = fixProc(buffer, password) + + var type = stripped.tag + var data = stripped.data + var subtype, ndata + switch (type) { + case 'CERTIFICATE': + ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo + // falls through + case 'PUBLIC KEY': + if (!ndata) { + ndata = asn1.PublicKey.decode(data, 'der') + } + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') + case '1.2.840.10045.2.1': + ndata.subjectPrivateKey = ndata.subjectPublicKey + return { + type: 'ec', + data: ndata + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') + return { + type: 'dsa', + data: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'ENCRYPTED PRIVATE KEY': + data = asn1.EncryptedPrivateKey.decode(data, 'der') + data = decrypt(data, password) + // falls through + case 'PRIVATE KEY': + ndata = asn1.PrivateKey.decode(data, 'der') + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') + case '1.2.840.10045.2.1': + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') + return { + type: 'dsa', + params: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'RSA PUBLIC KEY': + return asn1.RSAPublicKey.decode(data, 'der') + case 'RSA PRIVATE KEY': + return asn1.RSAPrivateKey.decode(data, 'der') + case 'DSA PRIVATE KEY': + return { + type: 'dsa', + params: asn1.DSAPrivateKey.decode(data, 'der') + } + case 'EC PRIVATE KEY': + data = asn1.ECPrivateKey.decode(data, 'der') + return { + curve: data.parameters.value, + privateKey: data.privateKey + } + default: throw new Error('unknown key type ' + type) + } +} +parseKeys.signature = asn1.signature +function decrypt (data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) + var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] + var iv = data.algorithm.decrypt.cipher.iv + var cipherText = data.subjectPrivateKey + var keylen = parseInt(algo.split('-')[1], 10) / 8 + var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1') + var cipher = ciphers.createDecipheriv(algo, key, iv) + var out = [] + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + return Buffer.concat(out) +} + +},{"./aesid.json":319,"./asn1":320,"./fixProc":322,"browserify-aes":74,"pbkdf2":326,"safe-buffer":376}],324:[function(require,module,exports){ (function (Buffer){(function (){ /*! parse-torrent. MIT License. WebTorrent LLC */ /* global Blob */ @@ -24398,7 +43580,7 @@ function ensure (bool, fieldName) { ;(() => { Buffer.alloc(0) })() }).call(this)}).call(this,require("buffer").Buffer) -},{"bencode":7,"blob-to-buffer":37,"buffer":55,"fs":54,"magnet-uri":126,"path":187,"queue-microtask":195,"simple-get":224,"simple-sha1":244}],187:[function(require,module,exports){ +},{"bencode":22,"blob-to-buffer":52,"buffer":114,"fs":71,"magnet-uri":254,"path":325,"queue-microtask":346,"simple-get":387,"simple-sha1":407}],325:[function(require,module,exports){ (function (process){(function (){ // 'path' module extracted from Node.js v8.11.1 (only the posix part) // transplited with Babel @@ -24931,14 +44113,299 @@ posix.posix = posix; module.exports = posix; }).call(this)}).call(this,require('_process')) -},{"_process":189}],188:[function(require,module,exports){ +},{"_process":333}],326:[function(require,module,exports){ +exports.pbkdf2 = require('./lib/async') +exports.pbkdf2Sync = require('./lib/sync') + +},{"./lib/async":327,"./lib/sync":330}],327:[function(require,module,exports){ +(function (global){(function (){ +var Buffer = require('safe-buffer').Buffer + +var checkParameters = require('./precondition') +var defaultEncoding = require('./default-encoding') +var sync = require('./sync') +var toBuffer = require('./to-buffer') + +var ZERO_BUF +var subtle = global.crypto && global.crypto.subtle +var toBrowser = { + sha: 'SHA-1', + 'sha-1': 'SHA-1', + sha1: 'SHA-1', + sha256: 'SHA-256', + 'sha-256': 'SHA-256', + sha384: 'SHA-384', + 'sha-384': 'SHA-384', + 'sha-512': 'SHA-512', + sha512: 'SHA-512' +} +var checks = [] +function checkNative (algo) { + if (global.process && !global.process.browser) { + return Promise.resolve(false) + } + if (!subtle || !subtle.importKey || !subtle.deriveBits) { + return Promise.resolve(false) + } + if (checks[algo] !== undefined) { + return checks[algo] + } + ZERO_BUF = ZERO_BUF || Buffer.alloc(8) + var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo) + .then(function () { + return true + }).catch(function () { + return false + }) + checks[algo] = prom + return prom +} +var nextTick +function getNextTick () { + if (nextTick) { + return nextTick + } + if (global.process && global.process.nextTick) { + nextTick = global.process.nextTick + } else if (global.queueMicrotask) { + nextTick = global.queueMicrotask + } else if (global.setImmediate) { + nextTick = global.setImmediate + } else { + nextTick = global.setTimeout + } + return nextTick +} +function browserPbkdf2 (password, salt, iterations, length, algo) { + return subtle.importKey( + 'raw', password, { name: 'PBKDF2' }, false, ['deriveBits'] + ).then(function (key) { + return subtle.deriveBits({ + name: 'PBKDF2', + salt: salt, + iterations: iterations, + hash: { + name: algo + } + }, key, length << 3) + }).then(function (res) { + return Buffer.from(res) + }) +} + +function resolvePromise (promise, callback) { + promise.then(function (out) { + getNextTick()(function () { + callback(null, out) + }) + }, function (e) { + getNextTick()(function () { + callback(e) + }) + }) +} +module.exports = function (password, salt, iterations, keylen, digest, callback) { + if (typeof digest === 'function') { + callback = digest + digest = undefined + } + + digest = digest || 'sha1' + var algo = toBrowser[digest.toLowerCase()] + + if (!algo || typeof global.Promise !== 'function') { + getNextTick()(function () { + var out + try { + out = sync(password, salt, iterations, keylen, digest) + } catch (e) { + return callback(e) + } + callback(null, out) + }) + return + } + + checkParameters(iterations, keylen) + password = toBuffer(password, defaultEncoding, 'Password') + salt = toBuffer(salt, defaultEncoding, 'Salt') + if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2') + + resolvePromise(checkNative(algo).then(function (resp) { + if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo) + + return sync(password, salt, iterations, keylen, digest) + }), callback) +} + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./default-encoding":328,"./precondition":329,"./sync":330,"./to-buffer":331,"safe-buffer":376}],328:[function(require,module,exports){ +(function (process,global){(function (){ +var defaultEncoding +/* istanbul ignore next */ +if (global.process && global.process.browser) { + defaultEncoding = 'utf-8' +} else if (global.process && global.process.version) { + var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10) + + defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary' +} else { + defaultEncoding = 'utf-8' +} +module.exports = defaultEncoding + +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":333}],329:[function(require,module,exports){ +var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs + +module.exports = function (iterations, keylen) { + if (typeof iterations !== 'number') { + throw new TypeError('Iterations not a number') + } + + if (iterations < 0) { + throw new TypeError('Bad iterations') + } + + if (typeof keylen !== 'number') { + throw new TypeError('Key length not a number') + } + + if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */ + throw new TypeError('Bad key length') + } +} + +},{}],330:[function(require,module,exports){ +var md5 = require('create-hash/md5') +var RIPEMD160 = require('ripemd160') +var sha = require('sha.js') +var Buffer = require('safe-buffer').Buffer + +var checkParameters = require('./precondition') +var defaultEncoding = require('./default-encoding') +var toBuffer = require('./to-buffer') + +var ZEROS = Buffer.alloc(128) +var sizes = { + md5: 16, + sha1: 20, + sha224: 28, + sha256: 32, + sha384: 48, + sha512: 64, + rmd160: 20, + ripemd160: 20 +} + +function Hmac (alg, key, saltLen) { + var hash = getDigest(alg) + var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 + + if (key.length > blocksize) { + key = hash(key) + } else if (key.length < blocksize) { + key = Buffer.concat([key, ZEROS], blocksize) + } + + var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]) + var opad = Buffer.allocUnsafe(blocksize + sizes[alg]) + for (var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + + var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4) + ipad.copy(ipad1, 0, 0, blocksize) + this.ipad1 = ipad1 + this.ipad2 = ipad + this.opad = opad + this.alg = alg + this.blocksize = blocksize + this.hash = hash + this.size = sizes[alg] +} + +Hmac.prototype.run = function (data, ipad) { + data.copy(ipad, this.blocksize) + var h = this.hash(ipad) + h.copy(this.opad, this.blocksize) + return this.hash(this.opad) +} + +function getDigest (alg) { + function shaFunc (data) { + return sha(alg).update(data).digest() + } + function rmd160Func (data) { + return new RIPEMD160().update(data).digest() + } + + if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func + if (alg === 'md5') return md5 + return shaFunc +} + +function pbkdf2 (password, salt, iterations, keylen, digest) { + checkParameters(iterations, keylen) + password = toBuffer(password, defaultEncoding, 'Password') + salt = toBuffer(salt, defaultEncoding, 'Salt') + + digest = digest || 'sha1' + + var hmac = new Hmac(digest, password, salt.length) + + var DK = Buffer.allocUnsafe(keylen) + var block1 = Buffer.allocUnsafe(salt.length + 4) + salt.copy(block1, 0, 0, salt.length) + + var destPos = 0 + var hLen = sizes[digest] + var l = Math.ceil(keylen / hLen) + + for (var i = 1; i <= l; i++) { + block1.writeUInt32BE(i, salt.length) + + var T = hmac.run(block1, hmac.ipad1) + var U = T + + for (var j = 1; j < iterations; j++) { + U = hmac.run(U, hmac.ipad2) + for (var k = 0; k < hLen; k++) T[k] ^= U[k] + } + + T.copy(DK, destPos) + destPos += hLen + } + + return DK +} + +module.exports = pbkdf2 + +},{"./default-encoding":328,"./precondition":329,"./to-buffer":331,"create-hash/md5":144,"ripemd160":372,"safe-buffer":376,"sha.js":379}],331:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer + +module.exports = function (thing, encoding, name) { + if (Buffer.isBuffer(thing)) { + return thing + } else if (typeof thing === 'string') { + return Buffer.from(thing, encoding) + } else if (ArrayBuffer.isView(thing)) { + return Buffer.from(thing.buffer) + } else { + throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView') + } +} + +},{"safe-buffer":376}],332:[function(require,module,exports){ module.exports = length function length (bytes) { return Math.max(16384, 1 << Math.log2(bytes < 1024 ? 1 : bytes / 1024) + 0.5 | 0) } -},{}],189:[function(require,module,exports){ +},{}],333:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -25124,7 +44591,263 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],190:[function(require,module,exports){ +},{}],334:[function(require,module,exports){ +exports.publicEncrypt = require('./publicEncrypt') +exports.privateDecrypt = require('./privateDecrypt') + +exports.privateEncrypt = function privateEncrypt (key, buf) { + return exports.publicEncrypt(key, buf, true) +} + +exports.publicDecrypt = function publicDecrypt (key, buf) { + return exports.privateDecrypt(key, buf, true) +} + +},{"./privateDecrypt":337,"./publicEncrypt":338}],335:[function(require,module,exports){ +var createHash = require('create-hash') +var Buffer = require('safe-buffer').Buffer + +module.exports = function (seed, len) { + var t = Buffer.alloc(0) + var i = 0 + var c + while (t.length < len) { + c = i2ops(i++) + t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]) + } + return t.slice(0, len) +} + +function i2ops (c) { + var out = Buffer.allocUnsafe(4) + out.writeUInt32BE(c, 0) + return out +} + +},{"create-hash":143,"safe-buffer":376}],336:[function(require,module,exports){ +arguments[4][18][0].apply(exports,arguments) +},{"buffer":71,"dup":18}],337:[function(require,module,exports){ +var parseKeys = require('parse-asn1') +var mgf = require('./mgf') +var xor = require('./xor') +var BN = require('bn.js') +var crt = require('browserify-rsa') +var createHash = require('create-hash') +var withPublic = require('./withPublic') +var Buffer = require('safe-buffer').Buffer + +module.exports = function privateDecrypt (privateKey, enc, reverse) { + var padding + if (privateKey.padding) { + padding = privateKey.padding + } else if (reverse) { + padding = 1 + } else { + padding = 4 + } + + var key = parseKeys(privateKey) + var k = key.modulus.byteLength() + if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) { + throw new Error('decryption error') + } + var msg + if (reverse) { + msg = withPublic(new BN(enc), key) + } else { + msg = crt(enc, key) + } + var zBuffer = Buffer.alloc(k - msg.length) + msg = Buffer.concat([zBuffer, msg], k) + if (padding === 4) { + return oaep(key, msg) + } else if (padding === 1) { + return pkcs1(key, msg, reverse) + } else if (padding === 3) { + return msg + } else { + throw new Error('unknown padding') + } +} + +function oaep (key, msg) { + var k = key.modulus.byteLength() + var iHash = createHash('sha1').update(Buffer.alloc(0)).digest() + var hLen = iHash.length + if (msg[0] !== 0) { + throw new Error('decryption error') + } + var maskedSeed = msg.slice(1, hLen + 1) + var maskedDb = msg.slice(hLen + 1) + var seed = xor(maskedSeed, mgf(maskedDb, hLen)) + var db = xor(maskedDb, mgf(seed, k - hLen - 1)) + if (compare(iHash, db.slice(0, hLen))) { + throw new Error('decryption error') + } + var i = hLen + while (db[i] === 0) { + i++ + } + if (db[i++] !== 1) { + throw new Error('decryption error') + } + return db.slice(i) +} + +function pkcs1 (key, msg, reverse) { + var p1 = msg.slice(0, 2) + var i = 2 + var status = 0 + while (msg[i++] !== 0) { + if (i >= msg.length) { + status++ + break + } + } + var ps = msg.slice(2, i - 1) + + if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) { + status++ + } + if (ps.length < 8) { + status++ + } + if (status) { + throw new Error('decryption error') + } + return msg.slice(i) +} +function compare (a, b) { + a = Buffer.from(a) + b = Buffer.from(b) + var dif = 0 + var len = a.length + if (a.length !== b.length) { + dif++ + len = Math.min(a.length, b.length) + } + var i = -1 + while (++i < len) { + dif += (a[i] ^ b[i]) + } + return dif +} + +},{"./mgf":335,"./withPublic":339,"./xor":340,"bn.js":336,"browserify-rsa":92,"create-hash":143,"parse-asn1":323,"safe-buffer":376}],338:[function(require,module,exports){ +var parseKeys = require('parse-asn1') +var randomBytes = require('randombytes') +var createHash = require('create-hash') +var mgf = require('./mgf') +var xor = require('./xor') +var BN = require('bn.js') +var withPublic = require('./withPublic') +var crt = require('browserify-rsa') +var Buffer = require('safe-buffer').Buffer + +module.exports = function publicEncrypt (publicKey, msg, reverse) { + var padding + if (publicKey.padding) { + padding = publicKey.padding + } else if (reverse) { + padding = 1 + } else { + padding = 4 + } + var key = parseKeys(publicKey) + var paddedMsg + if (padding === 4) { + paddedMsg = oaep(key, msg) + } else if (padding === 1) { + paddedMsg = pkcs1(key, msg, reverse) + } else if (padding === 3) { + paddedMsg = new BN(msg) + if (paddedMsg.cmp(key.modulus) >= 0) { + throw new Error('data too long for modulus') + } + } else { + throw new Error('unknown padding') + } + if (reverse) { + return crt(paddedMsg, key) + } else { + return withPublic(paddedMsg, key) + } +} + +function oaep (key, msg) { + var k = key.modulus.byteLength() + var mLen = msg.length + var iHash = createHash('sha1').update(Buffer.alloc(0)).digest() + var hLen = iHash.length + var hLen2 = 2 * hLen + if (mLen > k - hLen2 - 2) { + throw new Error('message too long') + } + var ps = Buffer.alloc(k - mLen - hLen2 - 2) + var dblen = k - hLen - 1 + var seed = randomBytes(hLen) + var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen)) + var maskedSeed = xor(seed, mgf(maskedDb, hLen)) + return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k)) +} +function pkcs1 (key, msg, reverse) { + var mLen = msg.length + var k = key.modulus.byteLength() + if (mLen > k - 11) { + throw new Error('message too long') + } + var ps + if (reverse) { + ps = Buffer.alloc(k - mLen - 3, 0xff) + } else { + ps = nonZero(k - mLen - 3) + } + return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k)) +} +function nonZero (len) { + var out = Buffer.allocUnsafe(len) + var i = 0 + var cache = randomBytes(len * 2) + var cur = 0 + var num + while (i < len) { + if (cur === cache.length) { + cache = randomBytes(len * 2) + cur = 0 + } + num = cache[cur++] + if (num) { + out[i++] = num + } + } + return out +} + +},{"./mgf":335,"./withPublic":339,"./xor":340,"bn.js":336,"browserify-rsa":92,"create-hash":143,"parse-asn1":323,"randombytes":348,"safe-buffer":376}],339:[function(require,module,exports){ +var BN = require('bn.js') +var Buffer = require('safe-buffer').Buffer + +function withPublic (paddedMsg, key) { + return Buffer.from(paddedMsg + .toRed(BN.mont(key.modulus)) + .redPow(new BN(key.publicExponent)) + .fromRed() + .toArray()) +} + +module.exports = withPublic + +},{"bn.js":336,"safe-buffer":376}],340:[function(require,module,exports){ +module.exports = function xor (a, b) { + var len = a.length + var i = -1 + while (++i < len) { + a[i] ^= b[i] + } + return a +} + +},{}],341:[function(require,module,exports){ (function (process){(function (){ var once = require('once') var eos = require('end-of-stream') @@ -25210,7 +44933,7 @@ var pump = function () { module.exports = pump }).call(this)}).call(this,require('_process')) -},{"_process":189,"end-of-stream":95,"fs":54,"once":185}],191:[function(require,module,exports){ +},{"_process":333,"end-of-stream":192,"fs":71,"once":318}],342:[function(require,module,exports){ (function (global){(function (){ /*! https://mths.be/punycode v1.4.1 by @mathias */ ;(function(root) { @@ -25747,7 +45470,7 @@ module.exports = pump }(this)); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],192:[function(require,module,exports){ +},{}],343:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -25833,7 +45556,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],193:[function(require,module,exports){ +},{}],344:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -25920,13 +45643,13 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],194:[function(require,module,exports){ +},{}],345:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":192,"./encode":193}],195:[function(require,module,exports){ +},{"./decode":343,"./encode":344}],346:[function(require,module,exports){ (function (global){(function (){ /*! queue-microtask. MIT License. Feross Aboukhadijeh */ let promise @@ -25939,7 +45662,7 @@ module.exports = typeof queueMicrotask === 'function' .catch(err => setTimeout(() => { throw err }, 0)) }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],196:[function(require,module,exports){ +},{}],347:[function(require,module,exports){ var iterate = function (list) { var offset = 0 return function () { @@ -25960,7 +45683,7 @@ var iterate = function (list) { module.exports = iterate -},{}],197:[function(require,module,exports){ +},{}],348:[function(require,module,exports){ (function (process,global){(function (){ 'use strict' @@ -26014,7 +45737,119 @@ function randomBytes (size, cb) { } }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":189,"safe-buffer":222}],198:[function(require,module,exports){ +},{"_process":333,"safe-buffer":376}],349:[function(require,module,exports){ +(function (process,global){(function (){ +'use strict' + +function oldBrowser () { + throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11') +} +var safeBuffer = require('safe-buffer') +var randombytes = require('randombytes') +var Buffer = safeBuffer.Buffer +var kBufferMaxLength = safeBuffer.kMaxLength +var crypto = global.crypto || global.msCrypto +var kMaxUint32 = Math.pow(2, 32) - 1 +function assertOffset (offset, length) { + if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare + throw new TypeError('offset must be a number') + } + + if (offset > kMaxUint32 || offset < 0) { + throw new TypeError('offset must be a uint32') + } + + if (offset > kBufferMaxLength || offset > length) { + throw new RangeError('offset out of range') + } +} + +function assertSize (size, offset, length) { + if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare + throw new TypeError('size must be a number') + } + + if (size > kMaxUint32 || size < 0) { + throw new TypeError('size must be a uint32') + } + + if (size + offset > length || size > kBufferMaxLength) { + throw new RangeError('buffer too small') + } +} +if ((crypto && crypto.getRandomValues) || !process.browser) { + exports.randomFill = randomFill + exports.randomFillSync = randomFillSync +} else { + exports.randomFill = oldBrowser + exports.randomFillSync = oldBrowser +} +function randomFill (buf, offset, size, cb) { + if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array') + } + + if (typeof offset === 'function') { + cb = offset + offset = 0 + size = buf.length + } else if (typeof size === 'function') { + cb = size + size = buf.length - offset + } else if (typeof cb !== 'function') { + throw new TypeError('"cb" argument must be a function') + } + assertOffset(offset, buf.length) + assertSize(size, offset, buf.length) + return actualFill(buf, offset, size, cb) +} + +function actualFill (buf, offset, size, cb) { + if (process.browser) { + var ourBuf = buf.buffer + var uint = new Uint8Array(ourBuf, offset, size) + crypto.getRandomValues(uint) + if (cb) { + process.nextTick(function () { + cb(null, buf) + }) + return + } + return buf + } + if (cb) { + randombytes(size, function (err, bytes) { + if (err) { + return cb(err) + } + bytes.copy(buf, offset) + cb(null, buf) + }) + return + } + var bytes = randombytes(size) + bytes.copy(buf, offset) + return buf +} +function randomFillSync (buf, offset, size) { + if (typeof offset === 'undefined') { + offset = 0 + } + if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array') + } + + assertOffset(offset, buf.length) + + if (size === undefined) size = buf.length - offset + + assertSize(size, offset, buf.length) + + return actualFill(buf, offset, size) +} + +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":333,"randombytes":348,"safe-buffer":376}],350:[function(require,module,exports){ /* Instance of writable stream. @@ -26131,37 +45966,243 @@ class RangeSliceStream extends Writable { module.exports = RangeSliceStream -},{"readable-stream":213}],199:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],200:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":202,"./_stream_writable":204,"_process":189,"dup":16,"inherits":118}],201:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":203,"dup":17,"inherits":118}],202:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":199,"./_stream_duplex":200,"./internal/streams/async_iterator":205,"./internal/streams/buffer_list":206,"./internal/streams/destroy":207,"./internal/streams/from":209,"./internal/streams/state":211,"./internal/streams/stream":212,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],203:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":199,"./_stream_duplex":200,"dup":19,"inherits":118}],204:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":199,"./_stream_duplex":200,"./internal/streams/destroy":207,"./internal/streams/state":211,"./internal/streams/stream":212,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],205:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":208,"_process":189,"dup":21}],206:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],207:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],208:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":199,"dup":24}],209:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],210:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":199,"./end-of-stream":208,"dup":26}],211:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":199,"dup":27}],212:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],213:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":200,"./lib/_stream_passthrough.js":201,"./lib/_stream_readable.js":202,"./lib/_stream_transform.js":203,"./lib/_stream_writable.js":204,"./lib/internal/streams/end-of-stream.js":208,"./lib/internal/streams/pipeline.js":210,"dup":29}],214:[function(require,module,exports){ +},{"readable-stream":365}],351:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],352:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":354,"./_stream_writable":356,"_process":333,"dup":31,"inherits":245}],353:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":355,"dup":32,"inherits":245}],354:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":351,"./_stream_duplex":352,"./internal/streams/async_iterator":357,"./internal/streams/buffer_list":358,"./internal/streams/destroy":359,"./internal/streams/from":361,"./internal/streams/state":363,"./internal/streams/stream":364,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],355:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":351,"./_stream_duplex":352,"dup":34,"inherits":245}],356:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":351,"./_stream_duplex":352,"./internal/streams/destroy":359,"./internal/streams/state":363,"./internal/streams/stream":364,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],357:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":360,"_process":333,"dup":36}],358:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],359:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],360:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":351,"dup":39}],361:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],362:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":351,"./end-of-stream":360,"dup":41}],363:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":351,"dup":42}],364:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],365:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":352,"./lib/_stream_passthrough.js":353,"./lib/_stream_readable.js":354,"./lib/_stream_transform.js":355,"./lib/_stream_writable.js":356,"./lib/internal/streams/end-of-stream.js":360,"./lib/internal/streams/pipeline.js":362,"dup":44}],366:[function(require,module,exports){ +"use strict"; + +// Based on RC4 algorithm, as described in +// http://en.wikipedia.org/wiki/RC4 + +function isInteger(n) { + return parseInt(n, 10) === n; +} + +function createRC4(N) { + function identityPermutation() { + var s = new Array(N); + for (var i = 0; i < N; i++) { + s[i] = i; + } + return s; + } + + // :: string | array integer -> array integer + function seed(key) { + if (key === undefined) { + key = new Array(N); + for (var k = 0; k < N; k++) { + key[k] = Math.floor(Math.random() * N); + } + } else if (typeof key === "string") { + // to string + key = "" + key; + key = key.split("").map(function (c) { return c.charCodeAt(0) % N; }); + } else if (Array.isArray(key)) { + if (!key.every(function (v) { + return typeof v === "number" && v === (v | 0); + })) { + throw new TypeError("invalid seed key specified: not array of integers"); + } + } else { + throw new TypeError("invalid seed key specified"); + } + + var keylen = key.length; + + // resed state + var s = identityPermutation(); + + var j = 0; + for (var i = 0; i < N; i++) { + j = (j + s[i] + key[i % keylen]) % N; + var tmp = s[i]; + s[i] = s[j]; + s[j] = tmp; + } + + return s; + } + + /* eslint-disable no-shadow */ + function RC4(key) { + this.s = seed(key); + this.i = 0; + this.j = 0; + } + /* eslint-enable no-shadow */ + + RC4.prototype.randomNative = function () { + this.i = (this.i + 1) % N; + this.j = (this.j + this.s[this.i]) % N; + + var tmp = this.s[this.i]; + this.s[this.i] = this.s[this.j]; + this.s[this.j] = tmp; + + var k = this.s[(this.s[this.i] + this.s[this.j]) % N]; + + return k; + }; + + RC4.prototype.randomUInt32 = function () { + var a = this.randomByte(); + var b = this.randomByte(); + var c = this.randomByte(); + var d = this.randomByte(); + + return ((a * 256 + b) * 256 + c) * 256 + d; + }; + + RC4.prototype.randomFloat = function () { + return this.randomUInt32() / 0x100000000; + }; + + RC4.prototype.random = function () { + var a; + var b; + + if (arguments.length === 1) { + a = 0; + b = arguments[0]; + } else if (arguments.length === 2) { + a = arguments[0]; + b = arguments[1]; + } else { + throw new TypeError("random takes one or two integer arguments"); + } + + if (!isInteger(a) || !isInteger(b)) { + throw new TypeError("random takes one or two integer arguments"); + } + + return a + this.randomUInt32() % (b - a + 1); + }; + + RC4.prototype.currentState = function () { + return { + i: this.i, + j: this.j, + s: this.s.slice(), // copy + }; + }; + + RC4.prototype.setState = function (state) { + var s = state.s; + var i = state.i; + var j = state.j; + + /* eslint-disable yoda */ + if (!(i === (i | 0) && 0 <= i && i < N)) { + throw new Error("state.i should be integer [0, " + (N - 1) + "]"); + } + + if (!(j === (j | 0) && 0 <= j && j < N)) { + throw new Error("state.j should be integer [0, " + (N - 1) + "]"); + } + /* eslint-enable yoda */ + + // check length + if (!Array.isArray(s) || s.length !== N) { + throw new Error("state should be array of length " + N); + } + + // check that all params are there + for (var k = 0; k < N; k++) { + if (s.indexOf(k) === -1) { + throw new Error("state should be permutation of 0.." + (N - 1) + ": " + k + " is missing"); + } + } + + this.i = i; + this.j = j; + this.s = s.slice(); // assign copy + }; + + return RC4; +} + +var RC4 = createRC4(256); +RC4.prototype.randomByte = RC4.prototype.randomNative; + +var RC4small = createRC4(16); +RC4small.prototype.randomByte = function () { + var a = this.randomNative(); + var b = this.randomNative(); + + return a * 16 + b; +}; + +var ordA = "a".charCodeAt(0); +var ord0 = "0".charCodeAt(0); + +function toHex(n) { + return n < 10 ? String.fromCharCode(ord0 + n) : String.fromCharCode(ordA + n - 10); +} + +function fromHex(c) { + return parseInt(c, 16); +} + +RC4small.prototype.currentStateString = function () { + var state = this.currentState(); + + var i = toHex(state.i); + var j = toHex(state.j); + + var res = i + j + state.s.map(toHex).join(""); + return res; +}; + +RC4small.prototype.setStateString = function (stateString) { + if (!stateString.match(/^[0-9a-f]{18}$/)) { + throw new TypeError("RC4small stateString should be 18 hex character string"); + } + + var i = fromHex(stateString[0]); + var j = fromHex(stateString[1]); + var s = stateString.split("").slice(2).map(fromHex); + + this.setState({ + i: i, + j: j, + s: s, + }); +}; + +RC4.RC4small = RC4small; + +module.exports = RC4; + +},{}],367:[function(require,module,exports){ /*! render-media. MIT License. Feross Aboukhadijeh */ exports.render = render exports.append = append @@ -26562,7 +46603,7 @@ function setMediaOpts (elem, opts) { elem.controls = !!opts.controls } -},{"./lib/mime.json":215,"debug":216,"is-ascii":119,"mediasource":127,"path":187,"stream-to-blob-url":285,"videostream":309}],215:[function(require,module,exports){ +},{"./lib/mime.json":368,"debug":369,"is-ascii":246,"mediasource":256,"path":325,"stream-to-blob-url":463,"videostream":487}],368:[function(require,module,exports){ module.exports={ ".3gp": "video/3gpp", ".aac": "audio/aac", @@ -26647,13 +46688,178 @@ module.exports={ ".zip": "application/zip" } -},{}],216:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":217,"_process":189,"dup":12}],217:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":218}],218:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],219:[function(require,module,exports){ +},{}],369:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./common":370,"_process":333,"dup":27}],370:[function(require,module,exports){ +arguments[4][28][0].apply(exports,arguments) +},{"dup":28,"ms":371}],371:[function(require,module,exports){ +arguments[4][29][0].apply(exports,arguments) +},{"dup":29}],372:[function(require,module,exports){ +'use strict' +var Buffer = require('buffer').Buffer +var inherits = require('inherits') +var HashBase = require('hash-base') + +var ARRAY16 = new Array(16) + +var zl = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 +] + +var zr = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 +] + +var sl = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 +] + +var sr = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 +] + +var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e] +var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000] + +function RIPEMD160 () { + HashBase.call(this, 64) + + // state + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + this._e = 0xc3d2e1f0 +} + +inherits(RIPEMD160, HashBase) + +RIPEMD160.prototype._update = function () { + var words = ARRAY16 + for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4) + + var al = this._a | 0 + var bl = this._b | 0 + var cl = this._c | 0 + var dl = this._d | 0 + var el = this._e | 0 + + var ar = this._a | 0 + var br = this._b | 0 + var cr = this._c | 0 + var dr = this._d | 0 + var er = this._e | 0 + + // computation + for (var i = 0; i < 80; i += 1) { + var tl + var tr + if (i < 16) { + tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]) + tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]) + } else if (i < 32) { + tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]) + tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]) + } else if (i < 48) { + tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]) + tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]) + } else if (i < 64) { + tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]) + tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]) + } else { // if (i<80) { + tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]) + tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]) + } + + al = el + el = dl + dl = rotl(cl, 10) + cl = bl + bl = tl + + ar = er + er = dr + dr = rotl(cr, 10) + cr = br + br = tr + } + + // update state + var t = (this._b + cl + dr) | 0 + this._b = (this._c + dl + er) | 0 + this._c = (this._d + el + ar) | 0 + this._d = (this._e + al + br) | 0 + this._e = (this._a + bl + cr) | 0 + this._a = t +} + +RIPEMD160.prototype._digest = function () { + // create padding and handle blocks + this._block[this._blockOffset++] = 0x80 + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64) + this._update() + this._blockOffset = 0 + } + + this._block.fill(0, this._blockOffset, 56) + this._block.writeUInt32LE(this._length[0], 56) + this._block.writeUInt32LE(this._length[1], 60) + this._update() + + // produce result + var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20) + buffer.writeInt32LE(this._a, 0) + buffer.writeInt32LE(this._b, 4) + buffer.writeInt32LE(this._c, 8) + buffer.writeInt32LE(this._d, 12) + buffer.writeInt32LE(this._e, 16) + return buffer +} + +function rotl (x, n) { + return (x << n) | (x >>> (32 - n)) +} + +function fn1 (a, b, c, d, e, m, k, s) { + return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0 +} + +function fn2 (a, b, c, d, e, m, k, s) { + return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0 +} + +function fn3 (a, b, c, d, e, m, k, s) { + return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0 +} + +function fn4 (a, b, c, d, e, m, k, s) { + return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0 +} + +function fn5 (a, b, c, d, e, m, k, s) { + return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0 +} + +module.exports = RIPEMD160 + +},{"buffer":114,"hash-base":213,"inherits":245}],373:[function(require,module,exports){ /*! run-parallel-limit. MIT License. Feross Aboukhadijeh */ module.exports = runParallelLimit @@ -26725,7 +46931,7 @@ function runParallelLimit (tasks, limit, cb) { isSync = false } -},{"queue-microtask":195}],220:[function(require,module,exports){ +},{"queue-microtask":346}],374:[function(require,module,exports){ /*! run-parallel. MIT License. Feross Aboukhadijeh */ module.exports = runParallel @@ -26778,7 +46984,7 @@ function runParallel (tasks, cb) { isSync = false } -},{"queue-microtask":195}],221:[function(require,module,exports){ +},{"queue-microtask":346}],375:[function(require,module,exports){ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -27442,88 +47648,88 @@ module.exports = function (moduleId, options) { // with the SHA1 spec at hand, it is obvious this almost a textbook // implementation that has a few functions hand-inlined and a few loops // hand-unrolled. -module.exports = function RushaCore(stdlib$846, foreign$847, heap$848) { +module.exports = function RushaCore(stdlib$840, foreign$841, heap$842) { 'use asm'; - var H$849 = new stdlib$846.Int32Array(heap$848); - function hash$850(k$851, x$852) { + var H$843 = new stdlib$840.Int32Array(heap$842); + function hash$844(k$845, x$846) { // k in bytes - k$851 = k$851 | 0; - x$852 = x$852 | 0; - var i$853 = 0, j$854 = 0, y0$855 = 0, z0$856 = 0, y1$857 = 0, z1$858 = 0, y2$859 = 0, z2$860 = 0, y3$861 = 0, z3$862 = 0, y4$863 = 0, z4$864 = 0, t0$865 = 0, t1$866 = 0; - y0$855 = H$849[x$852 + 320 >> 2] | 0; - y1$857 = H$849[x$852 + 324 >> 2] | 0; - y2$859 = H$849[x$852 + 328 >> 2] | 0; - y3$861 = H$849[x$852 + 332 >> 2] | 0; - y4$863 = H$849[x$852 + 336 >> 2] | 0; - for (i$853 = 0; (i$853 | 0) < (k$851 | 0); i$853 = i$853 + 64 | 0) { - z0$856 = y0$855; - z1$858 = y1$857; - z2$860 = y2$859; - z3$862 = y3$861; - z4$864 = y4$863; - for (j$854 = 0; (j$854 | 0) < 64; j$854 = j$854 + 4 | 0) { - t1$866 = H$849[i$853 + j$854 >> 2] | 0; - t0$865 = ((y0$855 << 5 | y0$855 >>> 27) + (y1$857 & y2$859 | ~y1$857 & y3$861) | 0) + ((t1$866 + y4$863 | 0) + 1518500249 | 0) | 0; - y4$863 = y3$861; - y3$861 = y2$859; - y2$859 = y1$857 << 30 | y1$857 >>> 2; - y1$857 = y0$855; - y0$855 = t0$865; - H$849[k$851 + j$854 >> 2] = t1$866; + k$845 = k$845 | 0; + x$846 = x$846 | 0; + var i$847 = 0, j$848 = 0, y0$849 = 0, z0$850 = 0, y1$851 = 0, z1$852 = 0, y2$853 = 0, z2$854 = 0, y3$855 = 0, z3$856 = 0, y4$857 = 0, z4$858 = 0, t0$859 = 0, t1$860 = 0; + y0$849 = H$843[x$846 + 320 >> 2] | 0; + y1$851 = H$843[x$846 + 324 >> 2] | 0; + y2$853 = H$843[x$846 + 328 >> 2] | 0; + y3$855 = H$843[x$846 + 332 >> 2] | 0; + y4$857 = H$843[x$846 + 336 >> 2] | 0; + for (i$847 = 0; (i$847 | 0) < (k$845 | 0); i$847 = i$847 + 64 | 0) { + z0$850 = y0$849; + z1$852 = y1$851; + z2$854 = y2$853; + z3$856 = y3$855; + z4$858 = y4$857; + for (j$848 = 0; (j$848 | 0) < 64; j$848 = j$848 + 4 | 0) { + t1$860 = H$843[i$847 + j$848 >> 2] | 0; + t0$859 = ((y0$849 << 5 | y0$849 >>> 27) + (y1$851 & y2$853 | ~y1$851 & y3$855) | 0) + ((t1$860 + y4$857 | 0) + 1518500249 | 0) | 0; + y4$857 = y3$855; + y3$855 = y2$853; + y2$853 = y1$851 << 30 | y1$851 >>> 2; + y1$851 = y0$849; + y0$849 = t0$859; + H$843[k$845 + j$848 >> 2] = t1$860; } - for (j$854 = k$851 + 64 | 0; (j$854 | 0) < (k$851 + 80 | 0); j$854 = j$854 + 4 | 0) { - t1$866 = (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) << 1 | (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) >>> 31; - t0$865 = ((y0$855 << 5 | y0$855 >>> 27) + (y1$857 & y2$859 | ~y1$857 & y3$861) | 0) + ((t1$866 + y4$863 | 0) + 1518500249 | 0) | 0; - y4$863 = y3$861; - y3$861 = y2$859; - y2$859 = y1$857 << 30 | y1$857 >>> 2; - y1$857 = y0$855; - y0$855 = t0$865; - H$849[j$854 >> 2] = t1$866; + for (j$848 = k$845 + 64 | 0; (j$848 | 0) < (k$845 + 80 | 0); j$848 = j$848 + 4 | 0) { + t1$860 = (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) << 1 | (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) >>> 31; + t0$859 = ((y0$849 << 5 | y0$849 >>> 27) + (y1$851 & y2$853 | ~y1$851 & y3$855) | 0) + ((t1$860 + y4$857 | 0) + 1518500249 | 0) | 0; + y4$857 = y3$855; + y3$855 = y2$853; + y2$853 = y1$851 << 30 | y1$851 >>> 2; + y1$851 = y0$849; + y0$849 = t0$859; + H$843[j$848 >> 2] = t1$860; } - for (j$854 = k$851 + 80 | 0; (j$854 | 0) < (k$851 + 160 | 0); j$854 = j$854 + 4 | 0) { - t1$866 = (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) << 1 | (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) >>> 31; - t0$865 = ((y0$855 << 5 | y0$855 >>> 27) + (y1$857 ^ y2$859 ^ y3$861) | 0) + ((t1$866 + y4$863 | 0) + 1859775393 | 0) | 0; - y4$863 = y3$861; - y3$861 = y2$859; - y2$859 = y1$857 << 30 | y1$857 >>> 2; - y1$857 = y0$855; - y0$855 = t0$865; - H$849[j$854 >> 2] = t1$866; + for (j$848 = k$845 + 80 | 0; (j$848 | 0) < (k$845 + 160 | 0); j$848 = j$848 + 4 | 0) { + t1$860 = (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) << 1 | (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) >>> 31; + t0$859 = ((y0$849 << 5 | y0$849 >>> 27) + (y1$851 ^ y2$853 ^ y3$855) | 0) + ((t1$860 + y4$857 | 0) + 1859775393 | 0) | 0; + y4$857 = y3$855; + y3$855 = y2$853; + y2$853 = y1$851 << 30 | y1$851 >>> 2; + y1$851 = y0$849; + y0$849 = t0$859; + H$843[j$848 >> 2] = t1$860; } - for (j$854 = k$851 + 160 | 0; (j$854 | 0) < (k$851 + 240 | 0); j$854 = j$854 + 4 | 0) { - t1$866 = (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) << 1 | (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) >>> 31; - t0$865 = ((y0$855 << 5 | y0$855 >>> 27) + (y1$857 & y2$859 | y1$857 & y3$861 | y2$859 & y3$861) | 0) + ((t1$866 + y4$863 | 0) - 1894007588 | 0) | 0; - y4$863 = y3$861; - y3$861 = y2$859; - y2$859 = y1$857 << 30 | y1$857 >>> 2; - y1$857 = y0$855; - y0$855 = t0$865; - H$849[j$854 >> 2] = t1$866; + for (j$848 = k$845 + 160 | 0; (j$848 | 0) < (k$845 + 240 | 0); j$848 = j$848 + 4 | 0) { + t1$860 = (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) << 1 | (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) >>> 31; + t0$859 = ((y0$849 << 5 | y0$849 >>> 27) + (y1$851 & y2$853 | y1$851 & y3$855 | y2$853 & y3$855) | 0) + ((t1$860 + y4$857 | 0) - 1894007588 | 0) | 0; + y4$857 = y3$855; + y3$855 = y2$853; + y2$853 = y1$851 << 30 | y1$851 >>> 2; + y1$851 = y0$849; + y0$849 = t0$859; + H$843[j$848 >> 2] = t1$860; } - for (j$854 = k$851 + 240 | 0; (j$854 | 0) < (k$851 + 320 | 0); j$854 = j$854 + 4 | 0) { - t1$866 = (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) << 1 | (H$849[j$854 - 12 >> 2] ^ H$849[j$854 - 32 >> 2] ^ H$849[j$854 - 56 >> 2] ^ H$849[j$854 - 64 >> 2]) >>> 31; - t0$865 = ((y0$855 << 5 | y0$855 >>> 27) + (y1$857 ^ y2$859 ^ y3$861) | 0) + ((t1$866 + y4$863 | 0) - 899497514 | 0) | 0; - y4$863 = y3$861; - y3$861 = y2$859; - y2$859 = y1$857 << 30 | y1$857 >>> 2; - y1$857 = y0$855; - y0$855 = t0$865; - H$849[j$854 >> 2] = t1$866; + for (j$848 = k$845 + 240 | 0; (j$848 | 0) < (k$845 + 320 | 0); j$848 = j$848 + 4 | 0) { + t1$860 = (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) << 1 | (H$843[j$848 - 12 >> 2] ^ H$843[j$848 - 32 >> 2] ^ H$843[j$848 - 56 >> 2] ^ H$843[j$848 - 64 >> 2]) >>> 31; + t0$859 = ((y0$849 << 5 | y0$849 >>> 27) + (y1$851 ^ y2$853 ^ y3$855) | 0) + ((t1$860 + y4$857 | 0) - 899497514 | 0) | 0; + y4$857 = y3$855; + y3$855 = y2$853; + y2$853 = y1$851 << 30 | y1$851 >>> 2; + y1$851 = y0$849; + y0$849 = t0$859; + H$843[j$848 >> 2] = t1$860; } - y0$855 = y0$855 + z0$856 | 0; - y1$857 = y1$857 + z1$858 | 0; - y2$859 = y2$859 + z2$860 | 0; - y3$861 = y3$861 + z3$862 | 0; - y4$863 = y4$863 + z4$864 | 0; + y0$849 = y0$849 + z0$850 | 0; + y1$851 = y1$851 + z1$852 | 0; + y2$853 = y2$853 + z2$854 | 0; + y3$855 = y3$855 + z3$856 | 0; + y4$857 = y4$857 + z4$858 | 0; } - H$849[x$852 + 320 >> 2] = y0$855; - H$849[x$852 + 324 >> 2] = y1$857; - H$849[x$852 + 328 >> 2] = y2$859; - H$849[x$852 + 332 >> 2] = y3$861; - H$849[x$852 + 336 >> 2] = y4$863; + H$843[x$846 + 320 >> 2] = y0$849; + H$843[x$846 + 324 >> 2] = y1$851; + H$843[x$846 + 328 >> 2] = y2$853; + H$843[x$846 + 332 >> 2] = y3$855; + H$843[x$846 + 336 >> 2] = y4$857; } - return { hash: hash$850 }; + return { hash: hash$844 }; }; /***/ }), @@ -27664,6 +47870,8 @@ module.exports = function (data, H8, H32, start, len, off) { /* 7 */ /***/ (function(module, exports, __webpack_require__) { +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* eslint-env commonjs, browser */ @@ -27697,6 +47905,16 @@ var Hash = function () { throw new Error('unsupported digest encoding'); }; + _createClass(Hash, [{ + key: 'state', + get: function () { + return this._rusha.getState(); + }, + set: function (state) { + this._rusha.setState(state); + } + }]); + return Hash; }(); @@ -27707,7 +47925,7 @@ module.exports = function () { /***/ }) /******/ ]); }); -},{}],222:[function(require,module,exports){ +},{}],376:[function(require,module,exports){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') @@ -27774,7 +47992,898 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":55}],223:[function(require,module,exports){ +},{"buffer":114}],377:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-disable node/no-deprecated-api */ + +'use strict' + +var buffer = require('buffer') +var Buffer = buffer.Buffer + +var safer = {} + +var key + +for (key in buffer) { + if (!buffer.hasOwnProperty(key)) continue + if (key === 'SlowBuffer' || key === 'Buffer') continue + safer[key] = buffer[key] +} + +var Safer = safer.Buffer = {} +for (key in Buffer) { + if (!Buffer.hasOwnProperty(key)) continue + if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue + Safer[key] = Buffer[key] +} + +safer.Buffer.prototype = Buffer.prototype + +if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value) + } + if (value && typeof value.length === 'undefined') { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value) + } + return Buffer(value, encodingOrOffset, length) + } +} + +if (!Safer.alloc) { + Safer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size) + } + if (size < 0 || size >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } + var buf = Buffer(size) + if (!fill || fill.length === 0) { + buf.fill(0) + } else if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + return buf + } +} + +if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process.binding('buffer').kStringMaxLength + } catch (e) { + // we can't determine kStringMaxLength in environments where process.binding + // is unsupported, so let's not set it + } +} + +if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + } + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength + } +} + +module.exports = safer + +}).call(this)}).call(this,require('_process')) +},{"_process":333,"buffer":114}],378:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer + +// prototype class for hash functions +function Hash (blockSize, finalSize) { + this._block = Buffer.alloc(blockSize) + this._finalSize = finalSize + this._blockSize = blockSize + this._len = 0 +} + +Hash.prototype.update = function (data, enc) { + if (typeof data === 'string') { + enc = enc || 'utf8' + data = Buffer.from(data, enc) + } + + var block = this._block + var blockSize = this._blockSize + var length = data.length + var accum = this._len + + for (var offset = 0; offset < length;) { + var assigned = accum % blockSize + var remainder = Math.min(length - offset, blockSize - assigned) + + for (var i = 0; i < remainder; i++) { + block[assigned + i] = data[offset + i] + } + + accum += remainder + offset += remainder + + if ((accum % blockSize) === 0) { + this._update(block) + } + } + + this._len += length + return this +} + +Hash.prototype.digest = function (enc) { + var rem = this._len % this._blockSize + + this._block[rem] = 0x80 + + // zero (rem + 1) trailing bits, where (rem + 1) is the smallest + // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize + this._block.fill(0, rem + 1) + + if (rem >= this._finalSize) { + this._update(this._block) + this._block.fill(0) + } + + var bits = this._len * 8 + + // uint32 + if (bits <= 0xffffffff) { + this._block.writeUInt32BE(bits, this._blockSize - 4) + + // uint64 + } else { + var lowBits = (bits & 0xffffffff) >>> 0 + var highBits = (bits - lowBits) / 0x100000000 + + this._block.writeUInt32BE(highBits, this._blockSize - 8) + this._block.writeUInt32BE(lowBits, this._blockSize - 4) + } + + this._update(this._block) + var hash = this._hash() + + return enc ? hash.toString(enc) : hash +} + +Hash.prototype._update = function () { + throw new Error('_update must be implemented by subclass') +} + +module.exports = Hash + +},{"safe-buffer":376}],379:[function(require,module,exports){ +var exports = module.exports = function SHA (algorithm) { + algorithm = algorithm.toLowerCase() + + var Algorithm = exports[algorithm] + if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') + + return new Algorithm() +} + +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":380,"./sha1":381,"./sha224":382,"./sha256":383,"./sha384":384,"./sha512":385}],380:[function(require,module,exports){ +/* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined + * in FIPS PUB 180-1 + * This source code is derived from sha1.js of the same repository. + * The difference between SHA-0 and SHA-1 is just a bitwise rotate left + * operation was added. + */ + +var inherits = require('inherits') +var Hash = require('./hash') +var Buffer = require('safe-buffer').Buffer + +var K = [ + 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 +] + +var W = new Array(80) + +function Sha () { + this.init() + this._w = W + + Hash.call(this, 64, 56) +} + +inherits(Sha, Hash) + +Sha.prototype.init = function () { + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + this._e = 0xc3d2e1f0 + + return this +} + +function rotl5 (num) { + return (num << 5) | (num >>> 27) +} + +function rotl30 (num) { + return (num << 30) | (num >>> 2) +} + +function ft (s, b, c, d) { + if (s === 0) return (b & c) | ((~b) & d) + if (s === 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d +} + +Sha.prototype._update = function (M) { + var W = this._w + + var a = this._a | 0 + var b = this._b | 0 + var c = this._c | 0 + var d = this._d | 0 + var e = this._e | 0 + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) + for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] + + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20) + var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 + + e = d + d = c + c = rotl30(b) + b = a + a = t + } + + this._a = (a + this._a) | 0 + this._b = (b + this._b) | 0 + this._c = (c + this._c) | 0 + this._d = (d + this._d) | 0 + this._e = (e + this._e) | 0 +} + +Sha.prototype._hash = function () { + var H = Buffer.allocUnsafe(20) + + H.writeInt32BE(this._a | 0, 0) + H.writeInt32BE(this._b | 0, 4) + H.writeInt32BE(this._c | 0, 8) + H.writeInt32BE(this._d | 0, 12) + H.writeInt32BE(this._e | 0, 16) + + return H +} + +module.exports = Sha + +},{"./hash":378,"inherits":245,"safe-buffer":376}],381:[function(require,module,exports){ +/* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined + * in FIPS PUB 180-1 + * Version 2.1a Copyright Paul Johnston 2000 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for details. + */ + +var inherits = require('inherits') +var Hash = require('./hash') +var Buffer = require('safe-buffer').Buffer + +var K = [ + 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 +] + +var W = new Array(80) + +function Sha1 () { + this.init() + this._w = W + + Hash.call(this, 64, 56) +} + +inherits(Sha1, Hash) + +Sha1.prototype.init = function () { + this._a = 0x67452301 + this._b = 0xefcdab89 + this._c = 0x98badcfe + this._d = 0x10325476 + this._e = 0xc3d2e1f0 + + return this +} + +function rotl1 (num) { + return (num << 1) | (num >>> 31) +} + +function rotl5 (num) { + return (num << 5) | (num >>> 27) +} + +function rotl30 (num) { + return (num << 30) | (num >>> 2) +} + +function ft (s, b, c, d) { + if (s === 0) return (b & c) | ((~b) & d) + if (s === 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d +} + +Sha1.prototype._update = function (M) { + var W = this._w + + var a = this._a | 0 + var b = this._b | 0 + var c = this._c | 0 + var d = this._d | 0 + var e = this._e | 0 + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) + for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) + + for (var j = 0; j < 80; ++j) { + var s = ~~(j / 20) + var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 + + e = d + d = c + c = rotl30(b) + b = a + a = t + } + + this._a = (a + this._a) | 0 + this._b = (b + this._b) | 0 + this._c = (c + this._c) | 0 + this._d = (d + this._d) | 0 + this._e = (e + this._e) | 0 +} + +Sha1.prototype._hash = function () { + var H = Buffer.allocUnsafe(20) + + H.writeInt32BE(this._a | 0, 0) + H.writeInt32BE(this._b | 0, 4) + H.writeInt32BE(this._c | 0, 8) + H.writeInt32BE(this._d | 0, 12) + H.writeInt32BE(this._e | 0, 16) + + return H +} + +module.exports = Sha1 + +},{"./hash":378,"inherits":245,"safe-buffer":376}],382:[function(require,module,exports){ +/** + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * + */ + +var inherits = require('inherits') +var Sha256 = require('./sha256') +var Hash = require('./hash') +var Buffer = require('safe-buffer').Buffer + +var W = new Array(64) + +function Sha224 () { + this.init() + + this._w = W // new Array(64) + + Hash.call(this, 64, 56) +} + +inherits(Sha224, Sha256) + +Sha224.prototype.init = function () { + this._a = 0xc1059ed8 + this._b = 0x367cd507 + this._c = 0x3070dd17 + this._d = 0xf70e5939 + this._e = 0xffc00b31 + this._f = 0x68581511 + this._g = 0x64f98fa7 + this._h = 0xbefa4fa4 + + return this +} + +Sha224.prototype._hash = function () { + var H = Buffer.allocUnsafe(28) + + H.writeInt32BE(this._a, 0) + H.writeInt32BE(this._b, 4) + H.writeInt32BE(this._c, 8) + H.writeInt32BE(this._d, 12) + H.writeInt32BE(this._e, 16) + H.writeInt32BE(this._f, 20) + H.writeInt32BE(this._g, 24) + + return H +} + +module.exports = Sha224 + +},{"./hash":378,"./sha256":383,"inherits":245,"safe-buffer":376}],383:[function(require,module,exports){ +/** + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * + */ + +var inherits = require('inherits') +var Hash = require('./hash') +var Buffer = require('safe-buffer').Buffer + +var K = [ + 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, + 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, + 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, + 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, + 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, + 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, + 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, + 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, + 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, + 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, + 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, + 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, + 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, + 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, + 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, + 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 +] + +var W = new Array(64) + +function Sha256 () { + this.init() + + this._w = W // new Array(64) + + Hash.call(this, 64, 56) +} + +inherits(Sha256, Hash) + +Sha256.prototype.init = function () { + this._a = 0x6a09e667 + this._b = 0xbb67ae85 + this._c = 0x3c6ef372 + this._d = 0xa54ff53a + this._e = 0x510e527f + this._f = 0x9b05688c + this._g = 0x1f83d9ab + this._h = 0x5be0cd19 + + return this +} + +function ch (x, y, z) { + return z ^ (x & (y ^ z)) +} + +function maj (x, y, z) { + return (x & y) | (z & (x | y)) +} + +function sigma0 (x) { + return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) +} + +function sigma1 (x) { + return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) +} + +function gamma0 (x) { + return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) +} + +function gamma1 (x) { + return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) +} + +Sha256.prototype._update = function (M) { + var W = this._w + + var a = this._a | 0 + var b = this._b | 0 + var c = this._c | 0 + var d = this._d | 0 + var e = this._e | 0 + var f = this._f | 0 + var g = this._g | 0 + var h = this._h | 0 + + for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) + for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 + + for (var j = 0; j < 64; ++j) { + var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 + var T2 = (sigma0(a) + maj(a, b, c)) | 0 + + h = g + g = f + f = e + e = (d + T1) | 0 + d = c + c = b + b = a + a = (T1 + T2) | 0 + } + + this._a = (a + this._a) | 0 + this._b = (b + this._b) | 0 + this._c = (c + this._c) | 0 + this._d = (d + this._d) | 0 + this._e = (e + this._e) | 0 + this._f = (f + this._f) | 0 + this._g = (g + this._g) | 0 + this._h = (h + this._h) | 0 +} + +Sha256.prototype._hash = function () { + var H = Buffer.allocUnsafe(32) + + H.writeInt32BE(this._a, 0) + H.writeInt32BE(this._b, 4) + H.writeInt32BE(this._c, 8) + H.writeInt32BE(this._d, 12) + H.writeInt32BE(this._e, 16) + H.writeInt32BE(this._f, 20) + H.writeInt32BE(this._g, 24) + H.writeInt32BE(this._h, 28) + + return H +} + +module.exports = Sha256 + +},{"./hash":378,"inherits":245,"safe-buffer":376}],384:[function(require,module,exports){ +var inherits = require('inherits') +var SHA512 = require('./sha512') +var Hash = require('./hash') +var Buffer = require('safe-buffer').Buffer + +var W = new Array(160) + +function Sha384 () { + this.init() + this._w = W + + Hash.call(this, 128, 112) +} + +inherits(Sha384, SHA512) + +Sha384.prototype.init = function () { + this._ah = 0xcbbb9d5d + this._bh = 0x629a292a + this._ch = 0x9159015a + this._dh = 0x152fecd8 + this._eh = 0x67332667 + this._fh = 0x8eb44a87 + this._gh = 0xdb0c2e0d + this._hh = 0x47b5481d + + this._al = 0xc1059ed8 + this._bl = 0x367cd507 + this._cl = 0x3070dd17 + this._dl = 0xf70e5939 + this._el = 0xffc00b31 + this._fl = 0x68581511 + this._gl = 0x64f98fa7 + this._hl = 0xbefa4fa4 + + return this +} + +Sha384.prototype._hash = function () { + var H = Buffer.allocUnsafe(48) + + function writeInt64BE (h, l, offset) { + H.writeInt32BE(h, offset) + H.writeInt32BE(l, offset + 4) + } + + writeInt64BE(this._ah, this._al, 0) + writeInt64BE(this._bh, this._bl, 8) + writeInt64BE(this._ch, this._cl, 16) + writeInt64BE(this._dh, this._dl, 24) + writeInt64BE(this._eh, this._el, 32) + writeInt64BE(this._fh, this._fl, 40) + + return H +} + +module.exports = Sha384 + +},{"./hash":378,"./sha512":385,"inherits":245,"safe-buffer":376}],385:[function(require,module,exports){ +var inherits = require('inherits') +var Hash = require('./hash') +var Buffer = require('safe-buffer').Buffer + +var K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 +] + +var W = new Array(160) + +function Sha512 () { + this.init() + this._w = W + + Hash.call(this, 128, 112) +} + +inherits(Sha512, Hash) + +Sha512.prototype.init = function () { + this._ah = 0x6a09e667 + this._bh = 0xbb67ae85 + this._ch = 0x3c6ef372 + this._dh = 0xa54ff53a + this._eh = 0x510e527f + this._fh = 0x9b05688c + this._gh = 0x1f83d9ab + this._hh = 0x5be0cd19 + + this._al = 0xf3bcc908 + this._bl = 0x84caa73b + this._cl = 0xfe94f82b + this._dl = 0x5f1d36f1 + this._el = 0xade682d1 + this._fl = 0x2b3e6c1f + this._gl = 0xfb41bd6b + this._hl = 0x137e2179 + + return this +} + +function Ch (x, y, z) { + return z ^ (x & (y ^ z)) +} + +function maj (x, y, z) { + return (x & y) | (z & (x | y)) +} + +function sigma0 (x, xl) { + return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) +} + +function sigma1 (x, xl) { + return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) +} + +function Gamma0 (x, xl) { + return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) +} + +function Gamma0l (x, xl) { + return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) +} + +function Gamma1 (x, xl) { + return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) +} + +function Gamma1l (x, xl) { + return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) +} + +function getCarry (a, b) { + return (a >>> 0) < (b >>> 0) ? 1 : 0 +} + +Sha512.prototype._update = function (M) { + var W = this._w + + var ah = this._ah | 0 + var bh = this._bh | 0 + var ch = this._ch | 0 + var dh = this._dh | 0 + var eh = this._eh | 0 + var fh = this._fh | 0 + var gh = this._gh | 0 + var hh = this._hh | 0 + + var al = this._al | 0 + var bl = this._bl | 0 + var cl = this._cl | 0 + var dl = this._dl | 0 + var el = this._el | 0 + var fl = this._fl | 0 + var gl = this._gl | 0 + var hl = this._hl | 0 + + for (var i = 0; i < 32; i += 2) { + W[i] = M.readInt32BE(i * 4) + W[i + 1] = M.readInt32BE(i * 4 + 4) + } + for (; i < 160; i += 2) { + var xh = W[i - 15 * 2] + var xl = W[i - 15 * 2 + 1] + var gamma0 = Gamma0(xh, xl) + var gamma0l = Gamma0l(xl, xh) + + xh = W[i - 2 * 2] + xl = W[i - 2 * 2 + 1] + var gamma1 = Gamma1(xh, xl) + var gamma1l = Gamma1l(xl, xh) + + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + var Wi7h = W[i - 7 * 2] + var Wi7l = W[i - 7 * 2 + 1] + + var Wi16h = W[i - 16 * 2] + var Wi16l = W[i - 16 * 2 + 1] + + var Wil = (gamma0l + Wi7l) | 0 + var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 + Wil = (Wil + gamma1l) | 0 + Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 + Wil = (Wil + Wi16l) | 0 + Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 + + W[i] = Wih + W[i + 1] = Wil + } + + for (var j = 0; j < 160; j += 2) { + Wih = W[j] + Wil = W[j + 1] + + var majh = maj(ah, bh, ch) + var majl = maj(al, bl, cl) + + var sigma0h = sigma0(ah, al) + var sigma0l = sigma0(al, ah) + var sigma1h = sigma1(eh, el) + var sigma1l = sigma1(el, eh) + + // t1 = h + sigma1 + ch + K[j] + W[j] + var Kih = K[j] + var Kil = K[j + 1] + + var chh = Ch(eh, fh, gh) + var chl = Ch(el, fl, gl) + + var t1l = (hl + sigma1l) | 0 + var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 + t1l = (t1l + chl) | 0 + t1h = (t1h + chh + getCarry(t1l, chl)) | 0 + t1l = (t1l + Kil) | 0 + t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 + t1l = (t1l + Wil) | 0 + t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 + + // t2 = sigma0 + maj + var t2l = (sigma0l + majl) | 0 + var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 + + hh = gh + hl = gl + gh = fh + gl = fl + fh = eh + fl = el + el = (dl + t1l) | 0 + eh = (dh + t1h + getCarry(el, dl)) | 0 + dh = ch + dl = cl + ch = bh + cl = bl + bh = ah + bl = al + al = (t1l + t2l) | 0 + ah = (t1h + t2h + getCarry(al, t1l)) | 0 + } + + this._al = (this._al + al) | 0 + this._bl = (this._bl + bl) | 0 + this._cl = (this._cl + cl) | 0 + this._dl = (this._dl + dl) | 0 + this._el = (this._el + el) | 0 + this._fl = (this._fl + fl) | 0 + this._gl = (this._gl + gl) | 0 + this._hl = (this._hl + hl) | 0 + + this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 + this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 + this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 + this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0 + this._eh = (this._eh + eh + getCarry(this._el, el)) | 0 + this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0 + this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 + this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 +} + +Sha512.prototype._hash = function () { + var H = Buffer.allocUnsafe(64) + + function writeInt64BE (h, l, offset) { + H.writeInt32BE(h, offset) + H.writeInt32BE(l, offset + 4) + } + + writeInt64BE(this._ah, this._al, 0) + writeInt64BE(this._bh, this._bl, 8) + writeInt64BE(this._ch, this._cl, 16) + writeInt64BE(this._dh, this._dl, 24) + writeInt64BE(this._eh, this._el, 32) + writeInt64BE(this._fh, this._fl, 40) + writeInt64BE(this._gh, this._gl, 48) + writeInt64BE(this._hh, this._hl, 56) + + return H +} + +module.exports = Sha512 + +},{"./hash":378,"inherits":245,"safe-buffer":376}],386:[function(require,module,exports){ (function (Buffer){(function (){ /*! simple-concat. MIT License. Feross Aboukhadijeh */ module.exports = function (stream, cb) { @@ -27793,7 +48902,7 @@ module.exports = function (stream, cb) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],224:[function(require,module,exports){ +},{"buffer":114}],387:[function(require,module,exports){ (function (Buffer){(function (){ /*! simple-get. MIT License. Feross Aboukhadijeh */ module.exports = simpleGet @@ -27897,7 +49006,7 @@ simpleGet.concat = (opts, cb) => { }) }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"decompress-response":54,"http":266,"https":115,"once":185,"querystring":194,"simple-concat":223,"url":301}],225:[function(require,module,exports){ +},{"buffer":114,"decompress-response":71,"http":444,"https":242,"once":318,"querystring":345,"simple-concat":386,"url":479}],388:[function(require,module,exports){ /*! simple-peer. MIT License. Feross Aboukhadijeh */ const debug = require('debug')('simple-peer') const getBrowserRTC = require('get-browser-rtc') @@ -28951,43 +50060,43 @@ Peer.channelConfig = {} module.exports = Peer -},{"buffer":55,"debug":226,"err-code":96,"get-browser-rtc":114,"queue-microtask":195,"randombytes":197,"readable-stream":243}],226:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":227,"_process":189,"dup":12}],227:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":228}],228:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],229:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],230:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":232,"./_stream_writable":234,"_process":189,"dup":16,"inherits":118}],231:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":233,"dup":17,"inherits":118}],232:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":229,"./_stream_duplex":230,"./internal/streams/async_iterator":235,"./internal/streams/buffer_list":236,"./internal/streams/destroy":237,"./internal/streams/from":239,"./internal/streams/state":241,"./internal/streams/stream":242,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],233:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":229,"./_stream_duplex":230,"dup":19,"inherits":118}],234:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":229,"./_stream_duplex":230,"./internal/streams/destroy":237,"./internal/streams/state":241,"./internal/streams/stream":242,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],235:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":238,"_process":189,"dup":21}],236:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],237:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],238:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":229,"dup":24}],239:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],240:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":229,"./end-of-stream":238,"dup":26}],241:[function(require,module,exports){ +},{"buffer":114,"debug":389,"err-code":193,"get-browser-rtc":212,"queue-microtask":346,"randombytes":348,"readable-stream":406}],389:[function(require,module,exports){ arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":229,"dup":27}],242:[function(require,module,exports){ +},{"./common":390,"_process":333,"dup":27}],390:[function(require,module,exports){ arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],243:[function(require,module,exports){ +},{"dup":28,"ms":391}],391:[function(require,module,exports){ arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":230,"./lib/_stream_passthrough.js":231,"./lib/_stream_readable.js":232,"./lib/_stream_transform.js":233,"./lib/_stream_writable.js":234,"./lib/internal/streams/end-of-stream.js":238,"./lib/internal/streams/pipeline.js":240,"dup":29}],244:[function(require,module,exports){ +},{"dup":29}],392:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],393:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":395,"./_stream_writable":397,"_process":333,"dup":31,"inherits":245}],394:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":396,"dup":32,"inherits":245}],395:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":392,"./_stream_duplex":393,"./internal/streams/async_iterator":398,"./internal/streams/buffer_list":399,"./internal/streams/destroy":400,"./internal/streams/from":402,"./internal/streams/state":404,"./internal/streams/stream":405,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],396:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":392,"./_stream_duplex":393,"dup":34,"inherits":245}],397:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":392,"./_stream_duplex":393,"./internal/streams/destroy":400,"./internal/streams/state":404,"./internal/streams/stream":405,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],398:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":401,"_process":333,"dup":36}],399:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],400:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],401:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":392,"dup":39}],402:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],403:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":392,"./end-of-stream":401,"dup":41}],404:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":392,"dup":42}],405:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],406:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":393,"./lib/_stream_passthrough.js":394,"./lib/_stream_readable.js":395,"./lib/_stream_transform.js":396,"./lib/_stream_writable.js":397,"./lib/internal/streams/end-of-stream.js":401,"./lib/internal/streams/pipeline.js":403,"dup":44}],407:[function(require,module,exports){ /* global self */ const Rusha = require('rusha') @@ -29065,7 +50174,7 @@ function hex (buf) { module.exports = sha1 module.exports.sync = sha1sync -},{"./rusha-worker-sha1":245,"rusha":221}],245:[function(require,module,exports){ +},{"./rusha-worker-sha1":408,"rusha":375}],408:[function(require,module,exports){ const Rusha = require('rusha') let worker @@ -29100,7 +50209,7 @@ function sha1 (buf, cb) { module.exports = sha1 -},{"rusha":221}],246:[function(require,module,exports){ +},{"rusha":375}],409:[function(require,module,exports){ (function (Buffer){(function (){ /*! simple-websocket. MIT License. Feross Aboukhadijeh */ /* global WebSocket */ @@ -29363,43 +50472,43 @@ Socket.WEBSOCKET_SUPPORT = !!_WebSocket module.exports = Socket }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"debug":247,"queue-microtask":195,"randombytes":197,"readable-stream":264,"ws":54}],247:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":248,"_process":189,"dup":12}],248:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":249}],249:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],250:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],251:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":253,"./_stream_writable":255,"_process":189,"dup":16,"inherits":118}],252:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":254,"dup":17,"inherits":118}],253:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":250,"./_stream_duplex":251,"./internal/streams/async_iterator":256,"./internal/streams/buffer_list":257,"./internal/streams/destroy":258,"./internal/streams/from":260,"./internal/streams/state":262,"./internal/streams/stream":263,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],254:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":250,"./_stream_duplex":251,"dup":19,"inherits":118}],255:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":250,"./_stream_duplex":251,"./internal/streams/destroy":258,"./internal/streams/state":262,"./internal/streams/stream":263,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],256:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":259,"_process":189,"dup":21}],257:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],258:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],259:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":250,"dup":24}],260:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],261:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":250,"./end-of-stream":259,"dup":26}],262:[function(require,module,exports){ +},{"buffer":114,"debug":410,"queue-microtask":346,"randombytes":348,"readable-stream":427,"ws":71}],410:[function(require,module,exports){ arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":250,"dup":27}],263:[function(require,module,exports){ +},{"./common":411,"_process":333,"dup":27}],411:[function(require,module,exports){ arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],264:[function(require,module,exports){ +},{"dup":28,"ms":412}],412:[function(require,module,exports){ arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":251,"./lib/_stream_passthrough.js":252,"./lib/_stream_readable.js":253,"./lib/_stream_transform.js":254,"./lib/_stream_writable.js":255,"./lib/internal/streams/end-of-stream.js":259,"./lib/internal/streams/pipeline.js":261,"dup":29}],265:[function(require,module,exports){ +},{"dup":29}],413:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],414:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":416,"./_stream_writable":418,"_process":333,"dup":31,"inherits":245}],415:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":417,"dup":32,"inherits":245}],416:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":413,"./_stream_duplex":414,"./internal/streams/async_iterator":419,"./internal/streams/buffer_list":420,"./internal/streams/destroy":421,"./internal/streams/from":423,"./internal/streams/state":425,"./internal/streams/stream":426,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],417:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":413,"./_stream_duplex":414,"dup":34,"inherits":245}],418:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":413,"./_stream_duplex":414,"./internal/streams/destroy":421,"./internal/streams/state":425,"./internal/streams/stream":426,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],419:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":422,"_process":333,"dup":36}],420:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],421:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],422:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":413,"dup":39}],423:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],424:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":413,"./end-of-stream":422,"dup":41}],425:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":413,"dup":42}],426:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],427:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":414,"./lib/_stream_passthrough.js":415,"./lib/_stream_readable.js":416,"./lib/_stream_transform.js":417,"./lib/_stream_writable.js":418,"./lib/internal/streams/end-of-stream.js":422,"./lib/internal/streams/pipeline.js":424,"dup":44}],428:[function(require,module,exports){ var tick = 1 var maxTick = 65535 var resolution = 4 @@ -29440,7 +50549,166 @@ module.exports = function (seconds) { } } -},{}],266:[function(require,module,exports){ +},{}],429:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +module.exports = Stream; + +var EE = require('events').EventEmitter; +var inherits = require('inherits'); + +inherits(Stream, EE); +Stream.Readable = require('readable-stream/lib/_stream_readable.js'); +Stream.Writable = require('readable-stream/lib/_stream_writable.js'); +Stream.Duplex = require('readable-stream/lib/_stream_duplex.js'); +Stream.Transform = require('readable-stream/lib/_stream_transform.js'); +Stream.PassThrough = require('readable-stream/lib/_stream_passthrough.js'); +Stream.finished = require('readable-stream/lib/internal/streams/end-of-stream.js') +Stream.pipeline = require('readable-stream/lib/internal/streams/pipeline.js') + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); +} + +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + +},{"events":194,"inherits":245,"readable-stream/lib/_stream_duplex.js":431,"readable-stream/lib/_stream_passthrough.js":432,"readable-stream/lib/_stream_readable.js":433,"readable-stream/lib/_stream_transform.js":434,"readable-stream/lib/_stream_writable.js":435,"readable-stream/lib/internal/streams/end-of-stream.js":439,"readable-stream/lib/internal/streams/pipeline.js":441}],430:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],431:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":433,"./_stream_writable":435,"_process":333,"dup":31,"inherits":245}],432:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":434,"dup":32,"inherits":245}],433:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":430,"./_stream_duplex":431,"./internal/streams/async_iterator":436,"./internal/streams/buffer_list":437,"./internal/streams/destroy":438,"./internal/streams/from":440,"./internal/streams/state":442,"./internal/streams/stream":443,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],434:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":430,"./_stream_duplex":431,"dup":34,"inherits":245}],435:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":430,"./_stream_duplex":431,"./internal/streams/destroy":438,"./internal/streams/state":442,"./internal/streams/stream":443,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],436:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":439,"_process":333,"dup":36}],437:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],438:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],439:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":430,"dup":39}],440:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],441:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":430,"./end-of-stream":439,"dup":41}],442:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":430,"dup":42}],443:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],444:[function(require,module,exports){ (function (global){(function (){ var ClientRequest = require('./lib/request') var response = require('./lib/response') @@ -29528,7 +50796,7 @@ http.METHODS = [ 'UNSUBSCRIBE' ] }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./lib/request":268,"./lib/response":269,"builtin-status-codes":59,"url":301,"xtend":337}],267:[function(require,module,exports){ +},{"./lib/request":446,"./lib/response":447,"builtin-status-codes":119,"url":479,"xtend":515}],445:[function(require,module,exports){ (function (global){(function (){ exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream) @@ -29591,7 +50859,7 @@ function isFunction (value) { xhr = null // Help gc }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],268:[function(require,module,exports){ +},{}],446:[function(require,module,exports){ (function (process,global,Buffer){(function (){ var capability = require('./capability') var inherits = require('inherits') @@ -29947,7 +51215,7 @@ var unsafeHeaders = [ ] }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./capability":267,"./response":269,"_process":189,"buffer":55,"inherits":118,"readable-stream":284}],269:[function(require,module,exports){ +},{"./capability":445,"./response":447,"_process":333,"buffer":114,"inherits":245,"readable-stream":462}],447:[function(require,module,exports){ (function (process,global,Buffer){(function (){ var capability = require('./capability') var inherits = require('inherits') @@ -30162,37 +51430,37 @@ IncomingMessage.prototype._onXHRProgress = function (resetTimers) { } }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./capability":267,"_process":189,"buffer":55,"inherits":118,"readable-stream":284}],270:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],271:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":273,"./_stream_writable":275,"_process":189,"dup":16,"inherits":118}],272:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":274,"dup":17,"inherits":118}],273:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":270,"./_stream_duplex":271,"./internal/streams/async_iterator":276,"./internal/streams/buffer_list":277,"./internal/streams/destroy":278,"./internal/streams/from":280,"./internal/streams/state":282,"./internal/streams/stream":283,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],274:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":270,"./_stream_duplex":271,"dup":19,"inherits":118}],275:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":270,"./_stream_duplex":271,"./internal/streams/destroy":278,"./internal/streams/state":282,"./internal/streams/stream":283,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],276:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":279,"_process":189,"dup":21}],277:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],278:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],279:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":270,"dup":24}],280:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],281:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":270,"./end-of-stream":279,"dup":26}],282:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":270,"dup":27}],283:[function(require,module,exports){ -arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],284:[function(require,module,exports){ -arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":271,"./lib/_stream_passthrough.js":272,"./lib/_stream_readable.js":273,"./lib/_stream_transform.js":274,"./lib/_stream_writable.js":275,"./lib/internal/streams/end-of-stream.js":279,"./lib/internal/streams/pipeline.js":281,"dup":29}],285:[function(require,module,exports){ +},{"./capability":445,"_process":333,"buffer":114,"inherits":245,"readable-stream":462}],448:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],449:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":451,"./_stream_writable":453,"_process":333,"dup":31,"inherits":245}],450:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":452,"dup":32,"inherits":245}],451:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":448,"./_stream_duplex":449,"./internal/streams/async_iterator":454,"./internal/streams/buffer_list":455,"./internal/streams/destroy":456,"./internal/streams/from":458,"./internal/streams/state":460,"./internal/streams/stream":461,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],452:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":448,"./_stream_duplex":449,"dup":34,"inherits":245}],453:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":448,"./_stream_duplex":449,"./internal/streams/destroy":456,"./internal/streams/state":460,"./internal/streams/stream":461,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],454:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":457,"_process":333,"dup":36}],455:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],456:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],457:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":448,"dup":39}],458:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],459:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":448,"./end-of-stream":457,"dup":41}],460:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":448,"dup":42}],461:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],462:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":449,"./lib/_stream_passthrough.js":450,"./lib/_stream_readable.js":451,"./lib/_stream_transform.js":452,"./lib/_stream_writable.js":453,"./lib/internal/streams/end-of-stream.js":457,"./lib/internal/streams/pipeline.js":459,"dup":44}],463:[function(require,module,exports){ /*! stream-to-blob-url. MIT License. Feross Aboukhadijeh */ module.exports = getBlobURL @@ -30204,7 +51472,7 @@ async function getBlobURL (stream, mimeType) { return url } -},{"stream-to-blob":286}],286:[function(require,module,exports){ +},{"stream-to-blob":464}],464:[function(require,module,exports){ /*! stream-to-blob. MIT License. Feross Aboukhadijeh */ /* global Blob */ @@ -30228,7 +51496,7 @@ function streamToBlob (stream, mimeType) { }) } -},{}],287:[function(require,module,exports){ +},{}],465:[function(require,module,exports){ (function (Buffer){(function (){ /*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh */ var once = require('once') @@ -30247,7 +51515,7 @@ module.exports = function getBuffer (stream, length, cb) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"once":185}],288:[function(require,module,exports){ +},{"buffer":114,"once":318}],466:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -30544,7 +51812,7 @@ function simpleWrite(buf) { function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } -},{"safe-buffer":222}],289:[function(require,module,exports){ +},{"safe-buffer":376}],467:[function(require,module,exports){ /* Copyright (c) 2011, Chris Umbel @@ -30572,7 +51840,7 @@ var base32 = require('./thirty-two'); exports.encode = base32.encode; exports.decode = base32.decode; -},{"./thirty-two":290}],290:[function(require,module,exports){ +},{"./thirty-two":468}],468:[function(require,module,exports){ (function (Buffer){(function (){ /* Copyright (c) 2011, Chris Umbel @@ -30704,7 +51972,7 @@ exports.decode = function(encoded) { }; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],291:[function(require,module,exports){ +},{"buffer":114}],469:[function(require,module,exports){ (function (process){(function (){ /**! * tippy.js v6.3.1 @@ -33152,7 +54420,7 @@ exports.sticky = sticky; }).call(this)}).call(this,require('_process')) -},{"@popperjs/core":1,"_process":189}],292:[function(require,module,exports){ +},{"@popperjs/core":1,"_process":333}],470:[function(require,module,exports){ var Buffer = require('buffer').Buffer module.exports = function (buf) { @@ -33181,7 +54449,7 @@ module.exports = function (buf) { } } -},{"buffer":55}],293:[function(require,module,exports){ +},{"buffer":114}],471:[function(require,module,exports){ (function (process){(function (){ /*! torrent-discovery. MIT License. WebTorrent LLC */ const debug = require('debug')('torrent-discovery') @@ -33407,13 +54675,13 @@ class Discovery extends EventEmitter { module.exports = Discovery }).call(this)}).call(this,require('_process')) -},{"_process":189,"bittorrent-dht/client":54,"bittorrent-lsd":54,"bittorrent-tracker/client":30,"debug":294,"events":97,"run-parallel":220}],294:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":295,"_process":189,"dup":12}],295:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":296}],296:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],297:[function(require,module,exports){ +},{"_process":333,"bittorrent-dht/client":71,"bittorrent-lsd":71,"bittorrent-tracker/client":45,"debug":472,"events":194,"run-parallel":374}],472:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./common":473,"_process":333,"dup":27}],473:[function(require,module,exports){ +arguments[4][28][0].apply(exports,arguments) +},{"dup":28,"ms":474}],474:[function(require,module,exports){ +arguments[4][29][0].apply(exports,arguments) +},{"dup":29}],475:[function(require,module,exports){ (function (Buffer){(function (){ /*! torrent-piece. MIT License. WebTorrent LLC */ const BLOCK_LENGTH = 1 << 14 @@ -33524,7 +54792,7 @@ Object.defineProperty(Piece, 'BLOCK_LENGTH', { value: BLOCK_LENGTH }) module.exports = Piece }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55}],298:[function(require,module,exports){ +},{"buffer":114}],476:[function(require,module,exports){ (function (Buffer){(function (){ /** * Convert a typed array to a Buffer without a copy @@ -33553,7 +54821,7 @@ module.exports = function typedarrayToBuffer (arr) { } }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":55,"is-typedarray":120}],299:[function(require,module,exports){ +},{"buffer":114,"is-typedarray":247}],477:[function(require,module,exports){ var bufferAlloc = require('buffer-alloc') var UINT_32_MAX = Math.pow(2, 32) @@ -33586,7 +54854,7 @@ exports.decode = function (buf, offset) { exports.encode.bytes = 8 exports.decode.bytes = 8 -},{"buffer-alloc":57}],300:[function(require,module,exports){ +},{"buffer-alloc":116}],478:[function(require,module,exports){ module.exports = remove function remove (arr, i) { @@ -33600,7 +54868,7 @@ function remove (arr, i) { return last } -},{}],301:[function(require,module,exports){ +},{}],479:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -34334,7 +55602,7 @@ Url.prototype.parseHost = function() { if (host) this.hostname = host; }; -},{"./util":302,"punycode":191,"querystring":194}],302:[function(require,module,exports){ +},{"./util":480,"punycode":342,"querystring":345}],480:[function(require,module,exports){ 'use strict'; module.exports = { @@ -34352,7 +55620,7 @@ module.exports = { } }; -},{}],303:[function(require,module,exports){ +},{}],481:[function(require,module,exports){ (function (Buffer){(function (){ /*! ut_metadata. MIT License. WebTorrent LLC */ const { EventEmitter } = require('events') @@ -34600,13 +55868,13 @@ module.exports = metadata => { } }).call(this)}).call(this,require("buffer").Buffer) -},{"bencode":7,"bitfield":10,"buffer":55,"debug":304,"events":97,"simple-sha1":244}],304:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":305,"_process":189,"dup":12}],305:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":306}],306:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],307:[function(require,module,exports){ +},{"bencode":22,"bitfield":25,"buffer":114,"debug":482,"events":194,"simple-sha1":407}],482:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./common":483,"_process":333,"dup":27}],483:[function(require,module,exports){ +arguments[4][28][0].apply(exports,arguments) +},{"dup":28,"ms":484}],484:[function(require,module,exports){ +arguments[4][29][0].apply(exports,arguments) +},{"dup":29}],485:[function(require,module,exports){ (function (global){(function (){ /** @@ -34677,7 +55945,7 @@ function config (name) { } }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],308:[function(require,module,exports){ +},{}],486:[function(require,module,exports){ (function (Buffer){(function (){ const bs = require('binary-search') const EventEmitter = require('events') @@ -35157,7 +56425,7 @@ const MIN_FRAGMENT_DURATION = 1 // second module.exports = MP4Remuxer }).call(this)}).call(this,require("buffer").Buffer) -},{"binary-search":9,"buffer":55,"events":97,"mp4-box-encoding":149,"mp4-stream":152,"range-slice-stream":198}],309:[function(require,module,exports){ +},{"binary-search":24,"buffer":114,"events":194,"mp4-box-encoding":282,"mp4-stream":285,"range-slice-stream":350}],487:[function(require,module,exports){ const MediaElementWrapper = require('mediasource') const pump = require('pump') @@ -35285,7 +56553,7 @@ VideoStream.prototype = { module.exports = VideoStream -},{"./mp4-remuxer":308,"mediasource":127,"pump":190}],310:[function(require,module,exports){ +},{"./mp4-remuxer":486,"mediasource":256,"pump":341}],488:[function(require,module,exports){ (function (global,Buffer){(function (){ /*! webtorrent. MIT License. WebTorrent LLC */ /* global FileList */ @@ -35363,7 +56631,7 @@ class WebTorrent extends EventEmitter { this.lsd = opts.lsd !== false this.torrents = [] this.maxConns = Number(opts.maxConns) || 55 - this.utp = opts.utp === true + this.utp = WebTorrent.UTP_SUPPORT && opts.utp !== false this._debug( 'new webtorrent (peerId %s, nodeId %s, port %s)', @@ -35372,19 +56640,7 @@ class WebTorrent extends EventEmitter { if (this.tracker) { if (typeof this.tracker !== 'object') this.tracker = {} - if (opts.rtcConfig) { - // TODO: remove in v1 - console.warn('WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead') - this.tracker.rtcConfig = opts.rtcConfig - } - if (opts.wrtc) { - // TODO: remove in v1 - console.warn('WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead') - this.tracker.wrtc = opts.wrtc - } - if (global.WRTC && !this.tracker.wrtc) { - this.tracker.wrtc = global.WRTC - } + if (global.WRTC && !this.tracker.wrtc) this.tracker.wrtc = global.WRTC } if (typeof ConnPool === 'function') { @@ -35486,12 +56742,6 @@ class WebTorrent extends EventEmitter { return null } - // TODO: remove in v1 - download (torrentId, opts, ontorrent) { - console.warn('WebTorrent: client.download() is deprecated. Use client.add() instead') - return this.add(torrentId, opts, ontorrent) - } - /** * Start downloading a new torrent. Aliased as `client.download`. * @param {string|Buffer|Object} torrentId @@ -35718,6 +56968,7 @@ class WebTorrent extends EventEmitter { } WebTorrent.WEBRTC_SUPPORT = Peer.WEBRTC_SUPPORT +WebTorrent.UTP_SUPPORT = ConnPool.UTP_SUPPORT WebTorrent.VERSION = VERSION /** @@ -35741,9 +56992,10 @@ function isFileList (obj) { module.exports = WebTorrent }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"./lib/conn-pool":54,"./lib/torrent":315,"./package.json":335,"bittorrent-dht/client":54,"buffer":55,"create-torrent":79,"debug":317,"events":97,"load-ip-set":54,"parse-torrent":186,"path":187,"queue-microtask":195,"randombytes":197,"run-parallel":220,"simple-concat":223,"simple-peer":225,"speedometer":265}],311:[function(require,module,exports){ +},{"./lib/conn-pool":71,"./lib/torrent":493,"./package.json":513,"bittorrent-dht/client":71,"buffer":114,"create-torrent":147,"debug":495,"events":194,"load-ip-set":71,"parse-torrent":324,"path":325,"queue-microtask":346,"randombytes":348,"run-parallel":374,"simple-concat":386,"simple-peer":388,"speedometer":428}],489:[function(require,module,exports){ const debug = require('debug')('webtorrent:file-stream') const stream = require('readable-stream') +const eos = require('end-of-stream') /** * Readable stream of a torrent file @@ -35757,7 +57009,6 @@ class FileStream extends stream.Readable { constructor (file, opts) { super(opts) - this.destroyed = false this._torrent = file._torrent const start = (opts && opts.start) || 0 @@ -35777,6 +57028,15 @@ class FileStream extends stream.Readable { this._reading = false this._notifying = false this._criticalLength = Math.min((1024 * 1024 / pieceLength) | 0, 2) + + this._torrent.select(this._startPiece, this._endPiece, true, () => { + this._notify() + }) + + // Ensure that cleanup happens even if destroy() is never called (readable-stream v3 currently doesn't call it automaticallly) + eos(this, (err) => { + this.destroy(err) + }) } _read () { @@ -35794,7 +57054,7 @@ class FileStream extends stream.Readable { if (this._notifying) return this._notifying = true - if (this._torrent.destroyed) return this._destroy(new Error('Torrent removed')) + if (this._torrent.destroyed) return this.destroy(new Error('Torrent removed')) const p = this._piece @@ -35808,7 +57068,7 @@ class FileStream extends stream.Readable { if (this.destroyed) return debug('read %s (length %s) (err %s)', p, buffer && buffer.length, err && err.message) - if (err) return this._destroy(err) + if (err) return this.destroy(err) if (this._offset) { buffer = buffer.slice(this._offset) @@ -35829,25 +57089,19 @@ class FileStream extends stream.Readable { this._piece += 1 } - _destroy (err) { - if (this.destroyed) return - this.destroyed = true - + _destroy (err, cb) { if (!this._torrent.destroyed) { this._torrent.deselect(this._startPiece, this._endPiece, true) } - - if (err) this.emit('error', err) - this.emit('close') + cb(err) } } module.exports = FileStream -},{"debug":317,"readable-stream":334}],312:[function(require,module,exports){ +},{"debug":495,"end-of-stream":192,"readable-stream":512}],490:[function(require,module,exports){ const { EventEmitter } = require('events') const { PassThrough } = require('readable-stream') -const eos = require('end-of-stream') const path = require('path') const render = require('render-media') const streamToBlob = require('stream-to-blob') @@ -35862,6 +57116,7 @@ class File extends EventEmitter { this._torrent = torrent this._destroyed = false + this._fileStreams = new Set() this.name = file.name this.path = file.path @@ -35950,15 +57205,12 @@ class File extends EventEmitter { } const fileStream = new FileStream(this, opts) - this._torrent.select(fileStream._startPiece, fileStream._endPiece, true, () => { - fileStream._notify() - }) - eos(fileStream, () => { - if (this._destroyed) return - if (!this._torrent.destroyed) { - this._torrent.deselect(fileStream._startPiece, fileStream._endPiece, true) - } + + this._fileStreams.add(fileStream) + fileStream.once('close', () => { + this._fileStreams.delete(fileStream) }) + return fileStream } @@ -36001,12 +57253,17 @@ class File extends EventEmitter { _destroy () { this._destroyed = true this._torrent = null + + for (const fileStream of this._fileStreams) { + fileStream.destroy() + } + this._fileStreams.clear() } } module.exports = File -},{"./file-stream":311,"end-of-stream":95,"events":97,"path":187,"queue-microtask":195,"readable-stream":334,"render-media":214,"stream-to-blob":286,"stream-to-blob-url":285,"stream-with-known-length-to-buffer":287}],313:[function(require,module,exports){ +},{"./file-stream":489,"events":194,"path":325,"queue-microtask":346,"readable-stream":512,"render-media":367,"stream-to-blob":464,"stream-to-blob-url":463,"stream-with-known-length-to-buffer":465}],491:[function(require,module,exports){ const arrayRemove = require('unordered-array-remove') const debug = require('debug')('webtorrent:peer') const Wire = require('bittorrent-protocol') @@ -36054,34 +57311,26 @@ exports.createWebRTCPeer = (conn, swarm) => { * listening port of the TCP server. Until the remote peer sends a handshake, we don't * know what swarm the connection is intended for. */ -exports.createTCPIncomingPeer = conn => { - return _createIncomingPeer(conn, 'tcpIncoming') -} +exports.createTCPIncomingPeer = conn => _createIncomingPeer(conn, 'tcpIncoming') /** * Incoming uTP peers start out connected, because the remote peer connected to the * listening port of the uTP server. Until the remote peer sends a handshake, we don't * know what swarm the connection is intended for. */ -exports.createUTPIncomingPeer = conn => { - return _createIncomingPeer(conn, 'utpIncoming') -} +exports.createUTPIncomingPeer = conn => _createIncomingPeer(conn, 'utpIncoming') /** * Outgoing TCP peers start out with just an IP address. At some point (when there is an * available connection), the client can attempt to connect to the address. */ -exports.createTCPOutgoingPeer = (addr, swarm) => { - return _createOutgoingPeer(addr, swarm, 'tcpOutgoing') -} +exports.createTCPOutgoingPeer = (addr, swarm) => _createOutgoingPeer(addr, swarm, 'tcpOutgoing') /** * Outgoing uTP peers start out with just an IP address. At some point (when there is an * available connection), the client can attempt to connect to the address. */ -exports.createUTPOutgoingPeer = (addr, swarm) => { - return _createOutgoingPeer(addr, swarm, 'utpOutgoing') -} +exports.createUTPOutgoingPeer = (addr, swarm) => _createOutgoingPeer(addr, swarm, 'utpOutgoing') const _createIncomingPeer = (conn, type) => { const addr = `${conn.remoteAddress}:${conn.remotePort}` @@ -36289,7 +57538,7 @@ class Peer { } } -},{"bittorrent-protocol":11,"debug":317,"unordered-array-remove":300}],314:[function(require,module,exports){ +},{"bittorrent-protocol":26,"debug":495,"unordered-array-remove":478}],492:[function(require,module,exports){ /** * Mapping of torrent pieces to their respective availability in the torrent swarm. Used @@ -36399,12 +57648,13 @@ class RarityMap { module.exports = RarityMap -},{}],315:[function(require,module,exports){ +},{}],493:[function(require,module,exports){ (function (process,global){(function (){ /* global Blob */ const addrToIPPort = require('addr-to-ip-port') const BitField = require('bitfield').default +const CacheChunkStore = require('cache-chunk-store') const ChunkStoreWriteStream = require('chunk-store-stream/write') const cpus = require('cpus') const debug = require('debug')('webtorrent:torrent') @@ -36415,6 +57665,7 @@ const FSChunkStore = require('fs-chunk-store') // browser: `memory-chunk-store` const get = require('simple-get') const ImmediateChunkStore = require('immediate-chunk-store') const ltDontHave = require('lt_donthave') +const MemoryChunkStore = require('memory-chunk-store') const MultiStream = require('multistream') const net = require('net') // browser exclude const os = require('os') // browser exclude @@ -36429,13 +57680,13 @@ const randomIterate = require('random-iterate') const sha1 = require('simple-sha1') const speedometer = require('speedometer') const utMetadata = require('ut_metadata') -const utp = require('utp-native') // browser exclude const utPex = require('ut_pex') // browser exclude const File = require('./file') const Peer = require('./peer') const RarityMap = require('./rarity-map') const Server = require('./server') // browser exclude +const utp = require('./utp') // browser exclude const WebConn = require('./webconn') const MAX_BLOCK_LENGTH = 128 * 1024 @@ -36478,6 +57729,7 @@ class Torrent extends EventEmitter { this.skipVerify = !!opts.skipVerify this._store = opts.store || FSChunkStore this._preloadedStore = opts.preloadedStore || null + this._storeCacheSlots = opts.storeCacheSlots !== undefined ? opts.storeCacheSlots : 20 this._destroyStoreOnDestroy = opts.destroyStoreOnDestroy || false this._getAnnounceOpts = opts.getAnnounceOpts @@ -36497,7 +57749,7 @@ class Torrent extends EventEmitter { this.ready = false this.destroyed = false - this.paused = false + this.paused = opts.paused || false this.done = false this.metadata = null @@ -36596,12 +57848,6 @@ class Torrent extends EventEmitter { return numConns } - // TODO: remove in v1 - get swarm () { - console.warn('WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead.') - return this - } - _onTorrentId (torrentId) { if (this.destroyed) return @@ -36879,8 +58125,11 @@ class Torrent extends EventEmitter { this._rarityMap = new RarityMap(this) - this.store = new ImmediateChunkStore( - this._preloadedStore || new this._store(this.pieceLength, { + let rawStore = this._preloadedStore + if (!rawStore) { + rawStore = new this._store(this.pieceLength, { + // opts.torrent is deprecated (replaced by the name property). + // it doesn't appear to be used by current versions of any stores on npm. torrent: { infoHash: this.infoHash }, @@ -36892,6 +58141,17 @@ class Torrent extends EventEmitter { length: this.length, name: this.infoHash }) + } + + // don't use the cache if the store is already in memory + if (this._storeCacheSlots > 0 && !(rawStore instanceof MemoryChunkStore)) { + rawStore = new CacheChunkStore(rawStore, { + max: this._storeCacheSlots + }) + } + + this.store = new ImmediateChunkStore( + rawStore ) this.files = this.files.map(file => new File(this, file)) @@ -37154,8 +58414,9 @@ class Torrent extends EventEmitter { if (this.destroyed) throw new Error('torrent is destroyed') if (!this.infoHash) throw new Error('addPeer() must not be called before the `infoHash` event') + let host + if (this.client.blocked) { - let host if (typeof peer === 'string') { let parts try { @@ -37179,7 +58440,10 @@ class Torrent extends EventEmitter { } // if the utp connection fails to connect, then it is replaced with a tcp connection to the same ip:port - const wasAdded = !!this._addPeer(peer, this.client.utp ? 'utp' : 'tcp') + + const type = (this.client.utp && this._isIPv4(host)) ? 'utp' : 'tcp' + const wasAdded = !!this._addPeer(peer, type) + if (wasAdded) { this.emit('peer', peer) } else { @@ -37657,7 +58921,7 @@ class Torrent extends EventEmitter { const self = this if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function') { - window.requestIdleCallback(function () { self._updateWire(wire) }, { timeout: 250 }) + window.requestIdleCallback(() => { self._updateWire(wire) }, { timeout: 250 }) } else { self._updateWire(wire) } @@ -38015,29 +59279,29 @@ class Torrent extends EventEmitter { if (self.destroyed) return if (hash === self._hashes[index]) { - if (!self.pieces[index]) return self._debug('piece verified %s', index) - self.pieces[index] = null - self._reservations[index] = null - self.bitfield.set(index, true) - self.store.put(index, buf, err => { - if (err) self._destroy(err) + if (err) { + self._destroy(err) + return + } else { + self.pieces[index] = null + self._markVerified(index) + self.wires.forEach(wire => { + wire.have(index) + }) + } + // We also check `self.destroyed` since `torrent.destroy()` could have been + // called in the `torrent.on('done')` handler, triggered by `_checkDone()`. + if (self._checkDone() && !self.destroyed) self.discovery.complete() + onUpdateTick() }) - - self.wires.forEach(wire => { - wire.have(index) - }) - - // We also check `self.destroyed` since `torrent.destroy()` could have been - // called in the `torrent.on('done')` handler, triggered by `_checkDone()`. - if (self._checkDone() && !self.destroyed) self.discovery.complete() } else { self.pieces[index] = new Piece(piece.length) self.emit('warning', new Error(`Piece ${index} failed verification`)) + onUpdateTick() } - onUpdateTick() }) }) @@ -38065,8 +59329,8 @@ class Torrent extends EventEmitter { // is the torrent done? (if all current selections are satisfied, or there are // no selections, then torrent is done) let done = true - for (let i = 0; i < this._selections.length; i++) { - const selection = this._selections[i] + + for (const selection of this._selections) { for (let piece = selection.from; piece <= selection.to; piece++) { if (!this.bitfield.get(piece)) { done = false @@ -38075,6 +59339,7 @@ class Torrent extends EventEmitter { } if (!done) break } + if (!this.done && done) { this.done = true this._debug(`torrent done: ${this.infoHash}`) @@ -38155,7 +59420,7 @@ class Torrent extends EventEmitter { port: parts[1] } - if (peer.type === 'utpOutgoing') { + if (this.client.utp && peer.type === 'utpOutgoing') { peer.conn = utp.connect(opts.port, opts.host) } else { peer.conn = net.connect(opts) @@ -38192,7 +59457,9 @@ class Torrent extends EventEmitter { const reconnectTimeout = setTimeout(() => { if (this.destroyed) return - const newPeer = this._addPeer(peer.addr, this.client.utp ? 'utp' : 'tcp') + const host = addrToIPPort(peer.addr)[0] + const type = (this.client.utp && this._isIPv4(host)) ? 'utp' : 'tcp' + const newPeer = this._addPeer(peer.addr, type) if (newPeer) newPeer.retries = peer.retries + 1 }, ms) if (reconnectTimeout.unref) reconnectTimeout.unref() @@ -38216,6 +59483,16 @@ class Torrent extends EventEmitter { return port > 0 && port < 65535 && !(host === '127.0.0.1' && port === this.client.torrentPort) } + + /** + * Return `true` if string is a valid IPv4 address. + * @param {string} addr + * @return {boolean} + */ + _isIPv4 (addr) { + const IPv4Pattern = /^((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/ + return IPv4Pattern.test(addr) + } } function getBlockPipelineLength (wire, duration) { @@ -38238,7 +59515,7 @@ function noop () {} module.exports = Torrent }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../package.json":335,"./file":312,"./peer":313,"./rarity-map":314,"./server":54,"./webconn":316,"_process":189,"addr-to-ip-port":3,"bitfield":10,"chunk-store-stream/write":76,"cpus":78,"debug":317,"events":97,"fs":54,"fs-chunk-store":143,"immediate-chunk-store":117,"lt_donthave":122,"multistream":168,"net":54,"os":54,"parse-torrent":186,"path":187,"pump":190,"queue-microtask":195,"random-iterate":196,"run-parallel":220,"run-parallel-limit":219,"simple-get":224,"simple-sha1":244,"speedometer":265,"torrent-discovery":293,"torrent-piece":297,"ut_metadata":303,"ut_pex":54,"utp-native":54}],316:[function(require,module,exports){ +},{"../package.json":513,"./file":490,"./peer":491,"./rarity-map":492,"./server":71,"./utp":71,"./webconn":494,"_process":333,"addr-to-ip-port":3,"bitfield":25,"cache-chunk-store":121,"chunk-store-stream/write":137,"cpus":140,"debug":495,"events":194,"fs":71,"fs-chunk-store":272,"immediate-chunk-store":244,"lt_donthave":250,"memory-chunk-store":272,"multistream":301,"net":71,"os":71,"parse-torrent":324,"path":325,"pump":341,"queue-microtask":346,"random-iterate":347,"run-parallel":374,"run-parallel-limit":373,"simple-get":387,"simple-sha1":407,"speedometer":428,"torrent-discovery":471,"torrent-piece":475,"ut_metadata":481,"ut_pex":71}],494:[function(require,module,exports){ (function (Buffer){(function (){ const BitField = require('bitfield').default const debug = require('debug')('webtorrent:webconn') @@ -38334,9 +59611,7 @@ class WebConn extends Wire { end: rangeEnd }] } else { - const requestedFiles = files.filter(file => { - return file.offset <= rangeEnd && (file.offset + file.length) > rangeStart - }) + const requestedFiles = files.filter(file => file.offset <= rangeEnd && (file.offset + file.length) > rangeStart) if (requestedFiles.length < 1) { return cb(new Error('Could not find file corresponding to web seed range request')) } @@ -38460,47 +59735,47 @@ class WebConn extends Wire { module.exports = WebConn }).call(this)}).call(this,require("buffer").Buffer) -},{"../package.json":335,"bitfield":10,"bittorrent-protocol":11,"buffer":55,"debug":317,"lt_donthave":122,"simple-get":224,"simple-sha1":244}],317:[function(require,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"./common":318,"_process":189,"dup":12}],318:[function(require,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13,"ms":319}],319:[function(require,module,exports){ -arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],320:[function(require,module,exports){ -arguments[4][15][0].apply(exports,arguments) -},{"dup":15}],321:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_readable":323,"./_stream_writable":325,"_process":189,"dup":16,"inherits":118}],322:[function(require,module,exports){ -arguments[4][17][0].apply(exports,arguments) -},{"./_stream_transform":324,"dup":17,"inherits":118}],323:[function(require,module,exports){ -arguments[4][18][0].apply(exports,arguments) -},{"../errors":320,"./_stream_duplex":321,"./internal/streams/async_iterator":326,"./internal/streams/buffer_list":327,"./internal/streams/destroy":328,"./internal/streams/from":330,"./internal/streams/state":332,"./internal/streams/stream":333,"_process":189,"buffer":55,"dup":18,"events":97,"inherits":118,"string_decoder/":288,"util":54}],324:[function(require,module,exports){ -arguments[4][19][0].apply(exports,arguments) -},{"../errors":320,"./_stream_duplex":321,"dup":19,"inherits":118}],325:[function(require,module,exports){ -arguments[4][20][0].apply(exports,arguments) -},{"../errors":320,"./_stream_duplex":321,"./internal/streams/destroy":328,"./internal/streams/state":332,"./internal/streams/stream":333,"_process":189,"buffer":55,"dup":20,"inherits":118,"util-deprecate":307}],326:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"./end-of-stream":329,"_process":189,"dup":21}],327:[function(require,module,exports){ -arguments[4][22][0].apply(exports,arguments) -},{"buffer":55,"dup":22,"util":54}],328:[function(require,module,exports){ -arguments[4][23][0].apply(exports,arguments) -},{"_process":189,"dup":23}],329:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"../../../errors":320,"dup":24}],330:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],331:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"../../../errors":320,"./end-of-stream":329,"dup":26}],332:[function(require,module,exports){ +},{"../package.json":513,"bitfield":25,"bittorrent-protocol":26,"buffer":114,"debug":495,"lt_donthave":250,"simple-get":387,"simple-sha1":407}],495:[function(require,module,exports){ arguments[4][27][0].apply(exports,arguments) -},{"../../../errors":320,"dup":27}],333:[function(require,module,exports){ +},{"./common":496,"_process":333,"dup":27}],496:[function(require,module,exports){ arguments[4][28][0].apply(exports,arguments) -},{"dup":28,"events":97}],334:[function(require,module,exports){ +},{"dup":28,"ms":497}],497:[function(require,module,exports){ arguments[4][29][0].apply(exports,arguments) -},{"./lib/_stream_duplex.js":321,"./lib/_stream_passthrough.js":322,"./lib/_stream_readable.js":323,"./lib/_stream_transform.js":324,"./lib/_stream_writable.js":325,"./lib/internal/streams/end-of-stream.js":329,"./lib/internal/streams/pipeline.js":331,"dup":29}],335:[function(require,module,exports){ +},{"dup":29}],498:[function(require,module,exports){ +arguments[4][30][0].apply(exports,arguments) +},{"dup":30}],499:[function(require,module,exports){ +arguments[4][31][0].apply(exports,arguments) +},{"./_stream_readable":501,"./_stream_writable":503,"_process":333,"dup":31,"inherits":245}],500:[function(require,module,exports){ +arguments[4][32][0].apply(exports,arguments) +},{"./_stream_transform":502,"dup":32,"inherits":245}],501:[function(require,module,exports){ +arguments[4][33][0].apply(exports,arguments) +},{"../errors":498,"./_stream_duplex":499,"./internal/streams/async_iterator":504,"./internal/streams/buffer_list":505,"./internal/streams/destroy":506,"./internal/streams/from":508,"./internal/streams/state":510,"./internal/streams/stream":511,"_process":333,"buffer":114,"dup":33,"events":194,"inherits":245,"string_decoder/":466,"util":71}],502:[function(require,module,exports){ +arguments[4][34][0].apply(exports,arguments) +},{"../errors":498,"./_stream_duplex":499,"dup":34,"inherits":245}],503:[function(require,module,exports){ +arguments[4][35][0].apply(exports,arguments) +},{"../errors":498,"./_stream_duplex":499,"./internal/streams/destroy":506,"./internal/streams/state":510,"./internal/streams/stream":511,"_process":333,"buffer":114,"dup":35,"inherits":245,"util-deprecate":485}],504:[function(require,module,exports){ +arguments[4][36][0].apply(exports,arguments) +},{"./end-of-stream":507,"_process":333,"dup":36}],505:[function(require,module,exports){ +arguments[4][37][0].apply(exports,arguments) +},{"buffer":114,"dup":37,"util":71}],506:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"_process":333,"dup":38}],507:[function(require,module,exports){ +arguments[4][39][0].apply(exports,arguments) +},{"../../../errors":498,"dup":39}],508:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],509:[function(require,module,exports){ +arguments[4][41][0].apply(exports,arguments) +},{"../../../errors":498,"./end-of-stream":507,"dup":41}],510:[function(require,module,exports){ +arguments[4][42][0].apply(exports,arguments) +},{"../../../errors":498,"dup":42}],511:[function(require,module,exports){ +arguments[4][43][0].apply(exports,arguments) +},{"dup":43,"events":194}],512:[function(require,module,exports){ +arguments[4][44][0].apply(exports,arguments) +},{"./lib/_stream_duplex.js":499,"./lib/_stream_passthrough.js":500,"./lib/_stream_readable.js":501,"./lib/_stream_transform.js":502,"./lib/_stream_writable.js":503,"./lib/internal/streams/end-of-stream.js":507,"./lib/internal/streams/pipeline.js":509,"dup":44}],513:[function(require,module,exports){ module.exports={ - "version": "1.0.0" + "version": "1.2.5" } -},{}],336:[function(require,module,exports){ +},{}],514:[function(require,module,exports){ // Returns a wrapper function that returns a wrapped callback // The wrapper function should do some stuff, and return a // presumably different callback function. @@ -38535,7 +59810,7 @@ function wrappy (fn, cb) { } } -},{}],337:[function(require,module,exports){ +},{}],515:[function(require,module,exports){ module.exports = extend var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -38556,7 +59831,7 @@ function extend() { return target } -},{}],338:[function(require,module,exports){ +},{}],516:[function(require,module,exports){ const clipboard = require('clipboard'); const parser = require('parse-torrent'); const Buffer = require('Buffer'); @@ -39097,4 +60372,4 @@ function saveTorrent() { "content_id": parsed.name }); } -},{"Buffer":2,"bytes":60,"clipboard":77,"mime-types":146,"parse-torrent":186,"tippy.js":291,"webtorrent":310}]},{},[338]); +},{"Buffer":2,"bytes":120,"clipboard":139,"mime-types":277,"parse-torrent":324,"tippy.js":469,"webtorrent":488}]},{},[516]); diff --git a/bin/bundle.min.js b/bin/bundle.min.js index dffff55..d6d136f 100644 --- a/bin/bundle.min.js +++ b/bin/bundle.min.js @@ -1,93 +1,95 @@ -!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[s]={exports:{}};t[s][0].call(p.exports,(function(e){return r(t[s][1][e]||e)}),p,p.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s=0?e.ownerDocument.body:s(e)&&d(e)?e:g(m(e))}function v(e,t){var n;void 0===t&&(t=[]);var r=g(e),o=r===(null==(n=e.ownerDocument)?void 0:n.body),s=i(r),a=o?[s].concat(s.visualViewport||[],d(r)?r:[]):r,c=t.concat(a);return o?c:c.concat(v(m(a)))}function b(e){return["table","td","th"].indexOf(c(e))>=0}function x(e){return s(e)&&"fixed"!==u(e).position?e.offsetParent:null}function y(e){for(var t=i(e),n=x(e);n&&b(n)&&"static"===u(n).position;)n=x(n);return n&&("html"===c(n)||"body"===c(n)&&"static"===u(n).position)?t:n||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&s(e)&&"fixed"===u(e).position)return null;for(var n=m(e);s(n)&&["html","body"].indexOf(c(n))<0;){var i=u(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}Object.defineProperty(n,"__esModule",{value:!0});var _="top",w="bottom",k="right",E="left",S="auto",C=[_,w,k,E],T="start",j="end",A="viewport",L="popper",I=C.reduce((function(e,t){return e.concat([t+"-"+T,t+"-"+j])}),[]),R=[].concat(C,[S]).reduce((function(e,t){return e.concat([t,t+"-"+T,t+"-"+j])}),[]),O=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function B(e){var t=new Map,n=new Set,i=[];function r(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var i=t.get(e);i&&r(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||r(e)})),i}function U(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i=0&&s(e)?y(e):e;return o(n)?t.filter((function(e){return o(e)&&F(e,n)&&"body"!==c(e)})):[]}(e):[].concat(t),r=[].concat(i,[n]),a=r[0],l=r.reduce((function(t,n){var i=W(e,n);return t.top=D(i.top,t.top),t.right=q(i.right,t.right),t.bottom=q(i.bottom,t.bottom),t.left=D(i.left,t.left),t}),W(e,a));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function V(e){return e.split("-")[1]}function G(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Y(e){var t,n=e.reference,i=e.element,r=e.placement,o=r?N(r):null,s=r?V(r):null,a=n.x+n.width/2-i.width/2,c=n.y+n.height/2-i.height/2;switch(o){case _:t={x:a,y:n.y-i.height};break;case w:t={x:a,y:n.y+n.height};break;case k:t={x:n.x+n.width,y:c};break;case E:t={x:n.x-i.width,y:c};break;default:t={x:n.x,y:n.y}}var l=o?G(o):null;if(null!=l){var p="y"===l?"height":"width";switch(s){case T:t[l]=t[l]-(n[p]/2-i[p]/2);break;case j:t[l]=t[l]+(n[p]/2-i[p]/2)}}return t}function K(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function X(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function J(e,n){void 0===n&&(n={});var i=n,r=i.placement,s=void 0===r?e.placement:r,a=i.boundary,c=void 0===a?"clippingParents":a,p=i.rootBoundary,u=void 0===p?A:p,d=i.elementContext,f=void 0===d?L:d,h=i.altBoundary,m=void 0!==h&&h,g=i.padding,v=void 0===g?0:g,b=K("number"!=typeof v?v:X(v,C)),x=f===L?"reference":L,y=e.elements.reference,E=e.rects.popper,S=e.elements[m?x:f],T=$(o(S)?S:S.contextElement||l(e.elements.popper),c,u),j=t(y),I=Y({reference:j,element:E,strategy:"absolute",placement:s}),R=z(Object.assign({},E,I)),O=f===L?R:j,B={top:T.top-O.top+b.top,bottom:O.bottom-T.bottom+b.bottom,left:T.left-O.left+b.left,right:O.right-T.right+b.right},U=e.modifiersData.offset;if(f===L&&U){var P=U[s];Object.keys(B).forEach((function(e){var t=[k,w].indexOf(e)>=0?1:-1,n=[_,w].indexOf(e)>=0?"y":"x";B[e]+=P[n]*t}))}return B}var Z="Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.",Q={placement:"bottom",modifiers:[],strategy:"absolute"};function ee(){for(var e=arguments.length,t=new Array(e),n=0;n100){console.error("Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.");break}if(!0!==l.reset){var s=l.orderedModifiers[o],a=s.fn,c=s.options,p=void 0===c?{}:c,u=s.name;"function"==typeof a&&(l=a({state:l,options:p,name:u,instance:m})||l)}else l.reset=!1,o=-1}}else"production"!==e.env.NODE_ENV&&console.error(Z)}},update:(s=function(){return new Promise((function(e){m.forceUpdate(),e(l)}))},function(){return c||(c=new Promise((function(e){Promise.resolve().then((function(){c=void 0,e(s())}))}))),c}),destroy:function(){g(),d=!0}};if(!ee(t,n))return"production"!==e.env.NODE_ENV&&console.error(Z),m;function g(){p.forEach((function(e){return e()})),p=[]}return m.setOptions(i).then((function(e){!d&&i.onFirstUpdate&&i.onFirstUpdate(e)})),m}}var ne={passive:!0};var ie={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,o=r.scroll,s=void 0===o||o,a=r.resize,c=void 0===a||a,l=i(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&p.forEach((function(e){e.addEventListener("scroll",n.update,ne)})),c&&l.addEventListener("resize",n.update,ne),function(){s&&p.forEach((function(e){e.removeEventListener("scroll",n.update,ne)})),c&&l.removeEventListener("resize",n.update,ne)}},data:{}};var re={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=Y({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},oe={top:"auto",right:"auto",bottom:"auto",left:"auto"};function se(e){var t,n=e.popper,r=e.popperRect,o=e.placement,s=e.offsets,a=e.position,c=e.gpuAcceleration,p=e.adaptive,d=e.roundOffsets,f=!0===d?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:H(H(t*i)/i)||0,y:H(H(n*i)/i)||0}}(s):"function"==typeof d?d(s):s,h=f.x,m=void 0===h?0:h,g=f.y,v=void 0===g?0:g,b=s.hasOwnProperty("x"),x=s.hasOwnProperty("y"),S=E,C=_,T=window;if(p){var j=y(n),A="clientHeight",L="clientWidth";j===i(n)&&"static"!==u(j=l(n)).position&&(A="scrollHeight",L="scrollWidth"),j=j,o===_&&(C=w,v-=j[A]-r.height,v*=c?1:-1),o===E&&(S=k,m-=j[L]-r.width,m*=c?1:-1)}var I,R=Object.assign({position:a},p&&oe);return c?Object.assign({},R,((I={})[C]=x?"0":"",I[S]=b?"0":"",I.transform=(T.devicePixelRatio||1)<2?"translate("+m+"px, "+v+"px)":"translate3d("+m+"px, "+v+"px, 0)",I)):Object.assign({},R,((t={})[C]=x?v+"px":"",t[S]=b?m+"px":"",t.transform="",t))}var ae={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var n=t.state,i=t.options,r=i.gpuAcceleration,o=void 0===r||r,s=i.adaptive,a=void 0===s||s,c=i.roundOffsets,l=void 0===c||c;if("production"!==e.env.NODE_ENV){var p=u(n.elements.popper).transitionProperty||"";a&&["transform","top","right","bottom","left"].some((function(e){return p.indexOf(e)>=0}))&&console.warn(["Popper: Detected CSS transitions on at least one of the following",'CSS properties: "transform", "top", "right", "bottom", "left".',"\n\n",'Disable the "computeStyles" modifier\'s `adaptive` option to allow',"for smooth transitions, or remove these properties from the CSS","transition declaration on the popper element if only transitioning","opacity or background-color for example.","\n\n","We recommend using the popper element as a wrapper around an inner","element that can have any CSS property transitioned for animations."].join(" "))}var d={placement:N(n.placement),popper:n.elements.popper,popperRect:n.rects.popper,gpuAcceleration:o};null!=n.modifiersData.popperOffsets&&(n.styles.popper=Object.assign({},n.styles.popper,se(Object.assign({},d,{offsets:n.modifiersData.popperOffsets,position:n.options.strategy,adaptive:a,roundOffsets:l})))),null!=n.modifiersData.arrow&&(n.styles.arrow=Object.assign({},n.styles.arrow,se(Object.assign({},d,{offsets:n.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),n.attributes.popper=Object.assign({},n.attributes.popper,{"data-popper-placement":n.placement})},data:{}};var ce={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},r=t.elements[e];s(r)&&c(r)&&(Object.assign(r.style,n),Object.keys(i).forEach((function(e){var t=i[e];!1===t?r.removeAttribute(e):r.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],r=t.attributes[e]||{},o=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});s(i)&&c(i)&&(Object.assign(i.style,o),Object.keys(r).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};var le={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.offset,o=void 0===r?[0,0]:r,s=R.reduce((function(e,n){return e[n]=function(e,t,n){var i=N(e),r=[E,_].indexOf(i)>=0?-1:1,o="function"==typeof n?n(Object.assign({},t,{placement:e})):n,s=o[0],a=o[1];return s=s||0,a=(a||0)*r,[E,k].indexOf(i)>=0?{x:a,y:s}:{x:s,y:a}}(n,t.rects,o),e}),{}),a=s[t.placement],c=a.x,l=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[i]=s}},pe={left:"right",right:"left",bottom:"top",top:"bottom"};function ue(e){return e.replace(/left|right|bottom|top/g,(function(e){return pe[e]}))}var de={start:"end",end:"start"};function fe(e){return e.replace(/start|end/g,(function(e){return de[e]}))}function he(t,n){void 0===n&&(n={});var i=n,r=i.placement,o=i.boundary,s=i.rootBoundary,a=i.padding,c=i.flipVariations,l=i.allowedAutoPlacements,p=void 0===l?R:l,u=V(r),d=u?c?I:I.filter((function(e){return V(e)===u})):C,f=d.filter((function(e){return p.indexOf(e)>=0}));0===f.length&&(f=d,"production"!==e.env.NODE_ENV&&console.error(["Popper: The `allowedAutoPlacements` option did not allow any","placements. Ensure the `placement` option matches the variation","of the allowed placements.",'For example, "auto" cannot be used to allow "bottom-start".','Use "auto-start" instead.'].join(" ")));var h=f.reduce((function(e,n){return e[n]=J(t,{placement:n,boundary:o,rootBoundary:s,padding:a})[N(n)],e}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}var me={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var r=n.mainAxis,o=void 0===r||r,s=n.altAxis,a=void 0===s||s,c=n.fallbackPlacements,l=n.padding,p=n.boundary,u=n.rootBoundary,d=n.altBoundary,f=n.flipVariations,h=void 0===f||f,m=n.allowedAutoPlacements,g=t.options.placement,v=N(g),b=c||(v===g||!h?[ue(g)]:function(e){if(N(e)===S)return[];var t=ue(e);return[fe(e),t,fe(t)]}(g)),x=[g].concat(b).reduce((function(e,n){return e.concat(N(n)===S?he(t,{placement:n,boundary:p,rootBoundary:u,padding:l,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),y=t.rects.reference,C=t.rects.popper,j=new Map,A=!0,L=x[0],I=0;I=0,P=U?"width":"height",M=J(t,{placement:R,boundary:p,rootBoundary:u,altBoundary:d,padding:l}),D=U?B?k:E:B?w:_;y[P]>C[P]&&(D=ue(D));var q=ue(D),H=[];if(o&&H.push(M[O]<=0),a&&H.push(M[D]<=0,M[q]<=0),H.every((function(e){return e}))){L=R,A=!1;break}j.set(R,H)}if(A)for(var F=function(e){var t=x.find((function(t){var n=j.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return L=t,"break"},z=h?3:1;z>0;z--){if("break"===F(z))break}t.placement!==L&&(t.modifiersData[i]._skip=!0,t.placement=L,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ge(e,t,n){return D(e,q(t,n))}var ve={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.mainAxis,o=void 0===r||r,s=n.altAxis,a=void 0!==s&&s,c=n.boundary,l=n.rootBoundary,p=n.altBoundary,u=n.padding,d=n.tether,f=void 0===d||d,m=n.tetherOffset,g=void 0===m?0:m,v=J(t,{boundary:c,rootBoundary:l,padding:u,altBoundary:p}),b=N(t.placement),x=V(t.placement),S=!x,C=G(b),j="x"===C?"y":"x",A=t.modifiersData.popperOffsets,L=t.rects.reference,I=t.rects.popper,R="function"==typeof g?g(Object.assign({},t.rects,{placement:t.placement})):g,O={x:0,y:0};if(A){if(o||a){var B="y"===C?_:E,U="y"===C?w:k,P="y"===C?"height":"width",M=A[C],H=A[C]+v[B],F=A[C]-v[U],z=f?-I[P]/2:0,W=x===T?L[P]:I[P],$=x===T?-I[P]:-L[P],Y=t.elements.arrow,K=f&&Y?h(Y):{width:0,height:0},X=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},Z=X[B],Q=X[U],ee=ge(0,L[P],K[P]),te=S?L[P]/2-z-ee-Z-R:W-ee-Z-R,ne=S?-L[P]/2+z+ee+Q+R:$+ee+Q+R,ie=t.elements.arrow&&y(t.elements.arrow),re=ie?"y"===C?ie.clientTop||0:ie.clientLeft||0:0,oe=t.modifiersData.offset?t.modifiersData.offset[t.placement][C]:0,se=A[C]+te-oe-re,ae=A[C]+ne-oe;if(o){var ce=ge(f?q(H,se):H,M,f?D(F,ae):F);A[C]=ce,O[C]=ce-M}if(a){var le="x"===C?_:E,pe="x"===C?w:k,ue=A[j],de=ue+v[le],fe=ue-v[pe],he=ge(f?q(de,se):de,ue,f?D(fe,ae):fe);A[j]=he,O[j]=he-ue}}t.modifiersData[i]=O}},requiresIfExists:["offset"]};var be={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,r=e.options,o=n.elements.arrow,s=n.modifiersData.popperOffsets,a=N(n.placement),c=G(a),l=[E,k].indexOf(a)>=0?"height":"width";if(o&&s){var p=function(e,t){return K("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:X(e,C))}(r.padding,n),u=h(o),d="y"===c?_:E,f="y"===c?w:k,m=n.rects.reference[l]+n.rects.reference[c]-s[c]-n.rects.popper[l],g=s[c]-n.rects.reference[c],v=y(o),b=v?"y"===c?v.clientHeight||0:v.clientWidth||0:0,x=m/2-g/2,S=p[d],T=b-u[l]-p[f],j=b/2-u[l]/2+x,A=ge(S,j,T),L=c;n.modifiersData[i]=((t={})[L]=A,t.centerOffset=A-j,t)}},effect:function(t){var n=t.state,i=t.options.element,r=void 0===i?"[data-popper-arrow]":i;null!=r&&("string"!=typeof r||(r=n.elements.popper.querySelector(r)))&&("production"!==e.env.NODE_ENV&&(s(r)||console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).',"To use an SVG arrow, wrap it in an HTMLElement that will be used as","the arrow."].join(" "))),F(n.elements.popper,r)?n.elements.arrow=r:"production"!==e.env.NODE_ENV&&console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper',"element."].join(" ")))},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function xe(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function ye(e){return[_,k,w,E].some((function(t){return e[t]>=0}))}var _e={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,r=t.rects.popper,o=t.modifiersData.preventOverflow,s=J(t,{elementContext:"reference"}),a=J(t,{altBoundary:!0}),c=xe(s,i),l=xe(a,r,o),p=ye(c),u=ye(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}},we=te({defaultModifiers:[ie,re,ae,ce]}),ke=[ie,re,ae,ce,le,me,ve,be,_e],Ee=te({defaultModifiers:ke});n.applyStyles=ce,n.arrow=be,n.computeStyles=ae,n.createPopper=Ee,n.createPopperLite=we,n.defaultModifiers=ke,n.detectOverflow=J,n.eventListeners=ie,n.flip=me,n.hide=_e,n.offset=le,n.popperGenerator=te,n.popperOffsets=re,n.preventOverflow=ve}).call(this)}).call(this,e("_process"))},{_process:189}],2:[function(e,t,n){(function(e){(function(){void 0===e&&(e=void 0),function(){"use strict";void 0===e&&(e=Array),t.exports=e}()}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55}],3:[function(e,t,n){const i=/^\[?([^\]]+)\]?:(\d+)$/;let r={},o=0;t.exports=function(e){if(1e5===o&&t.exports.reset(),!r[e]){const t=i.exec(e);if(!t)throw new Error(`invalid addr: ${e}`);r[e]=[t[1],Number(t[2])],o+=1}return r[e]},t.exports.reset=function(){r={},o=0}},{}],4:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),n=t[0],i=t[1];return 3*(n+i)/4-i},n.toByteArray=function(e){var t,n,i=l(e),s=i[0],a=i[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),p=0,u=a>0?s-4:s;for(n=0;n>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,o=[],s=16383,a=0,c=n-r;ac?c:a+s));1===r?(t=e[n-1],o.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return o.join("")};for(var i=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function p(e,t,n){for(var r,o,s=[],a=t;a>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},{}],5:[function(e,t,n){var i=e("safe-buffer").Buffer;function r(e,t,n){for(var i=0,r=1,o=t;o=48)i=10*i+(s-48);else if(o!==t||43!==s){if(o!==t||45!==s){if(46===s)break;throw new Error("not a number: buffer["+o+"] = "+s)}r=-1}}return i*r}function o(e,t,n,r){return null==e||0===e.length?null:("number"!=typeof t&&null==r&&(r=t,t=void 0),"number"!=typeof n&&null==r&&(r=n,n=void 0),o.position=0,o.encoding=r||null,o.data=i.isBuffer(e)?e.slice(t,n):i.from(e),o.bytes=o.data.length,o.next())}o.bytes=0,o.position=0,o.data=null,o.encoding=null,o.next=function(){switch(o.data[o.position]){case 100:return o.dictionary();case 108:return o.list();case 105:return o.integer();default:return o.buffer()}},o.find=function(e){for(var t=o.position,n=o.data.length,i=o.data;t{const r=t.split("-").map((e=>parseInt(e)));return e.concat(((e,t=e)=>Array.from({length:t-e+1},((t,n)=>n+e)))(...r))}),[])}t.exports=i,t.exports.parse=i,t.exports.compose=function(e){return e.reduce(((e,t,n,i)=>(0!==n&&t===i[n-1]+1||e.push([]),e[e.length-1].push(t),e)),[]).map((e=>e.length>1?`${e[0]}-${e[e.length-1]}`:`${e[0]}`))}},{}],9:[function(e,t,n){t.exports=function(e,t,n,i,r){var o,s;if(void 0===i)i=0;else if((i|=0)<0||i>=e.length)throw new RangeError("invalid lower bound");if(void 0===r)r=e.length-1;else if((r|=0)=e.length)throw new RangeError("invalid upper bound");for(;i<=r;)if((s=+n(e[o=i+(r-i>>>1)],t,o,e))<0)i=o+1;else{if(!(s>0))return o;r=o-1}return~i}},{}],10:[function(e,t,n){"use strict";function i(e){var t=e>>3;return e%8!=0&&t++,t}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){void 0===e&&(e=0);var n=null==t?void 0:t.grow;this.grow=n&&isFinite(n)&&i(n)||n||0,this.buffer="number"==typeof e?new Uint8Array(i(e)):e}return e.prototype.get=function(e){var t=e>>3;return t>e%8)},e.prototype.set=function(e,t){void 0===t&&(t=!0);var n=e>>3;if(t){if(this.buffer.length>e%8}else n>e%8))},e.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=8*this.buffer.length);for(var i=t,r=i>>3,o=128>>i%8,s=this.buffer[r];i>1},e}();n.default=r},{}],11:[function(e,t,n){(function(n){(function(){ +!function e(t,n,i){function r(o,a){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!a&&c)return c(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[o]={exports:{}};t[o][0].call(l.exports,(function(e){return r(t[o][1][e]||e)}),l,l.exports,e,t,n,i)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o=0?e.ownerDocument.body:o(e)&&f(e)?e:b(m(e))}function g(e,t){var n;void 0===t&&(t=[]);var r=b(e),s=r===(null==(n=e.ownerDocument)?void 0:n.body),o=i(r),a=s?[o].concat(o.visualViewport||[],f(r)?r:[]):r,c=t.concat(a);return s?c:c.concat(g(m(a)))}function v(e){return["table","td","th"].indexOf(c(e))>=0}function y(e){return o(e)&&"fixed"!==d(e).position?e.offsetParent:null}function _(e){for(var t=i(e),n=y(e);n&&v(n)&&"static"===d(n).position;)n=y(n);return n&&("html"===c(n)||"body"===c(n)&&"static"===d(n).position)?t:n||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&o(e)&&"fixed"===d(e).position)return null;for(var n=m(e);o(n)&&["html","body"].indexOf(c(n))<0;){var i=d(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}Object.defineProperty(n,"__esModule",{value:!0});var w="top",x="bottom",k="right",E="left",S="auto",M=[w,x,k,E],A="start",I="end",j="viewport",C="popper",T=M.reduce((function(e,t){return e.concat([t+"-"+A,t+"-"+I])}),[]),B=[].concat(M,[S]).reduce((function(e,t){return e.concat([t,t+"-"+A,t+"-"+I])}),[]),R=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function L(e){var t=new Map,n=new Set,i=[];function r(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var i=t.get(e);i&&r(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||r(e)})),i}function O(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i=0&&o(e)?_(e):e;return s(n)?t.filter((function(e){return s(e)&&H(e,n)&&"body"!==c(e)})):[]}(e):[].concat(t),r=[].concat(i,[n]),a=r[0],u=r.reduce((function(t,n){var i=W(e,n);return t.top=D(i.top,t.top),t.right=N(i.right,t.right),t.bottom=N(i.bottom,t.bottom),t.left=D(i.left,t.left),t}),W(e,a));return u.width=u.right-u.left,u.height=u.bottom-u.top,u.x=u.left,u.y=u.top,u}function K(e){return e.split("-")[1]}function $(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function G(e){var t,n=e.reference,i=e.element,r=e.placement,s=r?q(r):null,o=r?K(r):null,a=n.x+n.width/2-i.width/2,c=n.y+n.height/2-i.height/2;switch(s){case w:t={x:a,y:n.y-i.height};break;case x:t={x:a,y:n.y+n.height};break;case k:t={x:n.x+n.width,y:c};break;case E:t={x:n.x-i.width,y:c};break;default:t={x:n.x,y:n.y}}var u=s?$(s):null;if(null!=u){var l="y"===u?"height":"width";switch(o){case A:t[u]=t[u]-(n[l]/2-i[l]/2);break;case I:t[u]=t[u]+(n[l]/2-i[l]/2)}}return t}function X(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function Y(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function Z(e,n){void 0===n&&(n={});var i=n,r=i.placement,o=void 0===r?e.placement:r,a=i.boundary,c=void 0===a?"clippingParents":a,l=i.rootBoundary,d=void 0===l?j:l,f=i.elementContext,p=void 0===f?C:f,h=i.altBoundary,m=void 0!==h&&h,b=i.padding,g=void 0===b?0:b,v=X("number"!=typeof g?g:Y(g,M)),y=p===C?"reference":C,_=e.elements.reference,E=e.rects.popper,S=e.elements[m?y:p],A=V(s(S)?S:S.contextElement||u(e.elements.popper),c,d),I=t(_),T=G({reference:I,element:E,strategy:"absolute",placement:o}),B=F(Object.assign({},E,T)),R=p===C?B:I,L={top:A.top-R.top+v.top,bottom:R.bottom-A.bottom+v.bottom,left:A.left-R.left+v.left,right:R.right-A.right+v.right},O=e.modifiersData.offset;if(p===C&&O){var P=O[o];Object.keys(L).forEach((function(e){var t=[k,x].indexOf(e)>=0?1:-1,n=[w,x].indexOf(e)>=0?"y":"x";L[e]+=P[n]*t}))}return L}var J="Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.",Q={placement:"bottom",modifiers:[],strategy:"absolute"};function ee(){for(var e=arguments.length,t=new Array(e),n=0;n100){console.error("Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.");break}if(!0!==u.reset){var o=u.orderedModifiers[s],a=o.fn,c=o.options,l=void 0===c?{}:c,d=o.name;"function"==typeof a&&(u=a({state:u,options:l,name:d,instance:m})||u)}else u.reset=!1,s=-1}}else"production"!==e.env.NODE_ENV&&console.error(J)}},update:(o=function(){return new Promise((function(e){m.forceUpdate(),e(u)}))},function(){return c||(c=new Promise((function(e){Promise.resolve().then((function(){c=void 0,e(o())}))}))),c}),destroy:function(){b(),f=!0}};if(!ee(t,n))return"production"!==e.env.NODE_ENV&&console.error(J),m;function b(){l.forEach((function(e){return e()})),l=[]}return m.setOptions(i).then((function(e){!f&&i.onFirstUpdate&&i.onFirstUpdate(e)})),m}}var ne={passive:!0};var ie={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,s=r.scroll,o=void 0===s||s,a=r.resize,c=void 0===a||a,u=i(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&l.forEach((function(e){e.addEventListener("scroll",n.update,ne)})),c&&u.addEventListener("resize",n.update,ne),function(){o&&l.forEach((function(e){e.removeEventListener("scroll",n.update,ne)})),c&&u.removeEventListener("resize",n.update,ne)}},data:{}};var re={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=G({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},se={top:"auto",right:"auto",bottom:"auto",left:"auto"};function oe(e){var t,n=e.popper,r=e.popperRect,s=e.placement,o=e.offsets,a=e.position,c=e.gpuAcceleration,l=e.adaptive,f=e.roundOffsets,p=!0===f?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:z(z(t*i)/i)||0,y:z(z(n*i)/i)||0}}(o):"function"==typeof f?f(o):o,h=p.x,m=void 0===h?0:h,b=p.y,g=void 0===b?0:b,v=o.hasOwnProperty("x"),y=o.hasOwnProperty("y"),S=E,M=w,A=window;if(l){var I=_(n),j="clientHeight",C="clientWidth";I===i(n)&&"static"!==d(I=u(n)).position&&(j="scrollHeight",C="scrollWidth"),I=I,s===w&&(M=x,g-=I[j]-r.height,g*=c?1:-1),s===E&&(S=k,m-=I[C]-r.width,m*=c?1:-1)}var T,B=Object.assign({position:a},l&&se);return c?Object.assign({},B,((T={})[M]=y?"0":"",T[S]=v?"0":"",T.transform=(A.devicePixelRatio||1)<2?"translate("+m+"px, "+g+"px)":"translate3d("+m+"px, "+g+"px, 0)",T)):Object.assign({},B,((t={})[M]=y?g+"px":"",t[S]=v?m+"px":"",t.transform="",t))}var ae={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var n=t.state,i=t.options,r=i.gpuAcceleration,s=void 0===r||r,o=i.adaptive,a=void 0===o||o,c=i.roundOffsets,u=void 0===c||c;if("production"!==e.env.NODE_ENV){var l=d(n.elements.popper).transitionProperty||"";a&&["transform","top","right","bottom","left"].some((function(e){return l.indexOf(e)>=0}))&&console.warn(["Popper: Detected CSS transitions on at least one of the following",'CSS properties: "transform", "top", "right", "bottom", "left".',"\n\n",'Disable the "computeStyles" modifier\'s `adaptive` option to allow',"for smooth transitions, or remove these properties from the CSS","transition declaration on the popper element if only transitioning","opacity or background-color for example.","\n\n","We recommend using the popper element as a wrapper around an inner","element that can have any CSS property transitioned for animations."].join(" "))}var f={placement:q(n.placement),popper:n.elements.popper,popperRect:n.rects.popper,gpuAcceleration:s};null!=n.modifiersData.popperOffsets&&(n.styles.popper=Object.assign({},n.styles.popper,oe(Object.assign({},f,{offsets:n.modifiersData.popperOffsets,position:n.options.strategy,adaptive:a,roundOffsets:u})))),null!=n.modifiersData.arrow&&(n.styles.arrow=Object.assign({},n.styles.arrow,oe(Object.assign({},f,{offsets:n.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:u})))),n.attributes.popper=Object.assign({},n.attributes.popper,{"data-popper-placement":n.placement})},data:{}};var ce={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},r=t.elements[e];o(r)&&c(r)&&(Object.assign(r.style,n),Object.keys(i).forEach((function(e){var t=i[e];!1===t?r.removeAttribute(e):r.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],r=t.attributes[e]||{},s=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});o(i)&&c(i)&&(Object.assign(i.style,s),Object.keys(r).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};var ue={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.offset,s=void 0===r?[0,0]:r,o=B.reduce((function(e,n){return e[n]=function(e,t,n){var i=q(e),r=[E,w].indexOf(i)>=0?-1:1,s="function"==typeof n?n(Object.assign({},t,{placement:e})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*r,[E,k].indexOf(i)>=0?{x:a,y:o}:{x:o,y:a}}(n,t.rects,s),e}),{}),a=o[t.placement],c=a.x,u=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=u),t.modifiersData[i]=o}},le={left:"right",right:"left",bottom:"top",top:"bottom"};function de(e){return e.replace(/left|right|bottom|top/g,(function(e){return le[e]}))}var fe={start:"end",end:"start"};function pe(e){return e.replace(/start|end/g,(function(e){return fe[e]}))}function he(t,n){void 0===n&&(n={});var i=n,r=i.placement,s=i.boundary,o=i.rootBoundary,a=i.padding,c=i.flipVariations,u=i.allowedAutoPlacements,l=void 0===u?B:u,d=K(r),f=d?c?T:T.filter((function(e){return K(e)===d})):M,p=f.filter((function(e){return l.indexOf(e)>=0}));0===p.length&&(p=f,"production"!==e.env.NODE_ENV&&console.error(["Popper: The `allowedAutoPlacements` option did not allow any","placements. Ensure the `placement` option matches the variation","of the allowed placements.",'For example, "auto" cannot be used to allow "bottom-start".','Use "auto-start" instead.'].join(" ")));var h=p.reduce((function(e,n){return e[n]=Z(t,{placement:n,boundary:s,rootBoundary:o,padding:a})[q(n)],e}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}var me={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var r=n.mainAxis,s=void 0===r||r,o=n.altAxis,a=void 0===o||o,c=n.fallbackPlacements,u=n.padding,l=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,h=void 0===p||p,m=n.allowedAutoPlacements,b=t.options.placement,g=q(b),v=c||(g===b||!h?[de(b)]:function(e){if(q(e)===S)return[];var t=de(e);return[pe(e),t,pe(t)]}(b)),y=[b].concat(v).reduce((function(e,n){return e.concat(q(n)===S?he(t,{placement:n,boundary:l,rootBoundary:d,padding:u,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),_=t.rects.reference,M=t.rects.popper,I=new Map,j=!0,C=y[0],T=0;T=0,P=O?"width":"height",U=Z(t,{placement:B,boundary:l,rootBoundary:d,altBoundary:f,padding:u}),D=O?L?k:E:L?x:w;_[P]>M[P]&&(D=de(D));var N=de(D),z=[];if(s&&z.push(U[R]<=0),a&&z.push(U[D]<=0,U[N]<=0),z.every((function(e){return e}))){C=B,j=!1;break}I.set(B,z)}if(j)for(var H=function(e){var t=y.find((function(t){var n=I.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return C=t,"break"},F=h?3:1;F>0;F--){if("break"===H(F))break}t.placement!==C&&(t.modifiersData[i]._skip=!0,t.placement=C,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function be(e,t,n){return D(e,N(t,n))}var ge={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.mainAxis,s=void 0===r||r,o=n.altAxis,a=void 0!==o&&o,c=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.padding,f=n.tether,p=void 0===f||f,m=n.tetherOffset,b=void 0===m?0:m,g=Z(t,{boundary:c,rootBoundary:u,padding:d,altBoundary:l}),v=q(t.placement),y=K(t.placement),S=!y,M=$(v),I="x"===M?"y":"x",j=t.modifiersData.popperOffsets,C=t.rects.reference,T=t.rects.popper,B="function"==typeof b?b(Object.assign({},t.rects,{placement:t.placement})):b,R={x:0,y:0};if(j){if(s||a){var L="y"===M?w:E,O="y"===M?x:k,P="y"===M?"height":"width",U=j[M],z=j[M]+g[L],H=j[M]-g[O],F=p?-T[P]/2:0,W=y===A?C[P]:T[P],V=y===A?-T[P]:-C[P],G=t.elements.arrow,X=p&&G?h(G):{width:0,height:0},Y=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},J=Y[L],Q=Y[O],ee=be(0,C[P],X[P]),te=S?C[P]/2-F-ee-J-B:W-ee-J-B,ne=S?-C[P]/2+F+ee+Q+B:V+ee+Q+B,ie=t.elements.arrow&&_(t.elements.arrow),re=ie?"y"===M?ie.clientTop||0:ie.clientLeft||0:0,se=t.modifiersData.offset?t.modifiersData.offset[t.placement][M]:0,oe=j[M]+te-se-re,ae=j[M]+ne-se;if(s){var ce=be(p?N(z,oe):z,U,p?D(H,ae):H);j[M]=ce,R[M]=ce-U}if(a){var ue="x"===M?w:E,le="x"===M?x:k,de=j[I],fe=de+g[ue],pe=de-g[le],he=be(p?N(fe,oe):fe,de,p?D(pe,ae):pe);j[I]=he,R[I]=he-de}}t.modifiersData[i]=R}},requiresIfExists:["offset"]};var ve={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,r=e.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=q(n.placement),c=$(a),u=[E,k].indexOf(a)>=0?"height":"width";if(s&&o){var l=function(e,t){return X("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:Y(e,M))}(r.padding,n),d=h(s),f="y"===c?w:E,p="y"===c?x:k,m=n.rects.reference[u]+n.rects.reference[c]-o[c]-n.rects.popper[u],b=o[c]-n.rects.reference[c],g=_(s),v=g?"y"===c?g.clientHeight||0:g.clientWidth||0:0,y=m/2-b/2,S=l[f],A=v-d[u]-l[p],I=v/2-d[u]/2+y,j=be(S,I,A),C=c;n.modifiersData[i]=((t={})[C]=j,t.centerOffset=j-I,t)}},effect:function(t){var n=t.state,i=t.options.element,r=void 0===i?"[data-popper-arrow]":i;null!=r&&("string"!=typeof r||(r=n.elements.popper.querySelector(r)))&&("production"!==e.env.NODE_ENV&&(o(r)||console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).',"To use an SVG arrow, wrap it in an HTMLElement that will be used as","the arrow."].join(" "))),H(n.elements.popper,r)?n.elements.arrow=r:"production"!==e.env.NODE_ENV&&console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper',"element."].join(" ")))},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function ye(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function _e(e){return[w,k,x,E].some((function(t){return e[t]>=0}))}var we={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,r=t.rects.popper,s=t.modifiersData.preventOverflow,o=Z(t,{elementContext:"reference"}),a=Z(t,{altBoundary:!0}),c=ye(o,i),u=ye(a,r,s),l=_e(c),d=_e(u);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:u,isReferenceHidden:l,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":l,"data-popper-escaped":d})}},xe=te({defaultModifiers:[ie,re,ae,ce]}),ke=[ie,re,ae,ce,ue,me,ge,ve,we],Ee=te({defaultModifiers:ke});n.applyStyles=ce,n.arrow=ve,n.computeStyles=ae,n.createPopper=Ee,n.createPopperLite=xe,n.defaultModifiers=ke,n.detectOverflow=Z,n.eventListeners=ie,n.flip=me,n.hide=we,n.offset=ue,n.popperGenerator=te,n.popperOffsets=re,n.preventOverflow=ge}).call(this)}).call(this,e("_process"))},{_process:333}],2:[function(e,t,n){(function(e){(function(){void 0===e&&(e=void 0),function(){"use strict";void 0===e&&(e=Array),t.exports=e}()}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114}],3:[function(e,t,n){const i=/^\[?([^\]]+)\]?:(\d+)$/;let r={},s=0;t.exports=function(e){if(1e5===s&&t.exports.reset(),!r[e]){const t=i.exec(e);if(!t)throw new Error(`invalid addr: ${e}`);r[e]=[t[1],Number(t[2])],s+=1}return r[e]},t.exports.reset=function(){r={},s=0}},{}],4:[function(e,t,n){"use strict";const i=n;i.bignum=e("bn.js"),i.define=e("./asn1/api").define,i.base=e("./asn1/base"),i.constants=e("./asn1/constants"),i.decoders=e("./asn1/decoders"),i.encoders=e("./asn1/encoders")},{"./asn1/api":5,"./asn1/base":7,"./asn1/constants":11,"./asn1/decoders":13,"./asn1/encoders":16,"bn.js":18}],5:[function(e,t,n){"use strict";const i=e("./encoders"),r=e("./decoders"),s=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}n.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function n(e){this._initNamed(e,t)}return s(n,e),n.prototype._initNamed=function(t,n){e.call(this,t,n)},new n(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,n){return this._getDecoder(t).decode(e,n)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(i[e])),this.encoders[e]},o.prototype.encode=function(e,t,n){return this._getEncoder(t).encode(e,n)}},{"./decoders":13,"./encoders":16,inherits:245}],6:[function(e,t,n){"use strict";const i=e("inherits"),r=e("../base/reporter").Reporter,s=e("safer-buffer").Buffer;function o(e,t){r.call(this,t),s.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function a(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return a.isEncoderBuffer(e)||(e=new a(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=s.byteLength(e);else{if(!s.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}i(o,r),n.DecoderBuffer=o,o.isDecoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&s.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},o.prototype.save=function(){return{offset:this.offset,reporter:r.prototype.save.call(this)}},o.prototype.restore=function(e){const t=new o(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,r.prototype.restore.call(this,e.reporter),t},o.prototype.isEmpty=function(){return this.offset===this.length},o.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},o.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const n=new o(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},o.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},n.EncoderBuffer=a,a.isEncoderBuffer=function(e){if(e instanceof a)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},a.prototype.join=function(e,t){return e||(e=s.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(n){n.join(e,t),t+=n.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):s.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},{"../base/reporter":9,inherits:245,"safer-buffer":377}],7:[function(e,t,n){"use strict";const i=n;i.Reporter=e("./reporter").Reporter,i.DecoderBuffer=e("./buffer").DecoderBuffer,i.EncoderBuffer=e("./buffer").EncoderBuffer,i.Node=e("./node")},{"./buffer":6,"./node":8,"./reporter":9}],8:[function(e,t,n){"use strict";const i=e("../base/reporter").Reporter,r=e("../base/buffer").EncoderBuffer,s=e("../base/buffer").DecoderBuffer,o=e("minimalistic-assert"),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],c=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function u(e,t,n){const i={};this._baseState=i,i.name=n,i.enc=e,i.parent=t||null,i.children=null,i.tag=null,i.args=null,i.reverseArgs=null,i.choice=null,i.optional=!1,i.any=!1,i.obj=!1,i.use=null,i.useDecoder=null,i.key=null,i.default=null,i.explicit=null,i.implicit=null,i.contains=null,i.parent||(i.children=[],this._wrap())}t.exports=u;const l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){const e=this._baseState,t={};l.forEach((function(n){t[n]=e[n]}));const n=new this.constructor(t.parent);return n._baseState=t,n},u.prototype._wrap=function(){const e=this._baseState;c.forEach((function(t){this[t]=function(){const n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}}),this)},u.prototype._init=function(e){const t=this._baseState;o(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),o.equal(t.children.length,1,"Root node can have only one child")},u.prototype._useArgs=function(e){const t=this._baseState,n=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==n.length&&(o(null===t.children),t.children=n,n.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(o(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(n){n==(0|n)&&(n|=0);const i=e[n];t[i]=n})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){u.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),a.forEach((function(e){u.prototype[e]=function(){const t=this._baseState,n=Array.prototype.slice.call(arguments);return o(null===t.tag),t.tag=e,this._useArgs(n),this}})),u.prototype.use=function(e){o(e);const t=this._baseState;return o(null===t.use),t.use=e,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(e){const t=this._baseState;return o(null===t.default),t.default=e,t.optional=!0,this},u.prototype.explicit=function(e){const t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.explicit=e,this},u.prototype.implicit=function(e){const t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.implicit=e,this},u.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},u.prototype.key=function(e){const t=this._baseState;return o(null===t.key),t.key=e,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(e){const t=this._baseState;return o(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},u.prototype.contains=function(e){const t=this._baseState;return o(null===t.use),t.contains=e,this},u.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let i,r=n.default,o=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let i=null;if(null!==n.explicit?i=n.explicit:null!==n.implicit?i=n.implicit:null!==n.tag&&(i=n.tag),null!==i||n.any){if(o=this._peekTag(e,i,n.any),e.isError(o))return o}else{const i=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),o=!0}catch(e){o=!1}e.restore(i)}}if(n.obj&&o&&(i=e.enterObject()),o){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const i=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const i=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(i))return i;n.any?r=e.raw(t):e=i}if(t&&t.track&&null!==n.tag&&t.track(e.path(),i,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(r=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(r))return r;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(n){n._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const i=new s(r);r=this._getUse(n.contains,e._reporterState.obj)._decode(i,t)}}return n.obj&&o&&(r=e.leaveObject(i)),null===n.key||null===r&&!0!==o?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,r),r},u.prototype._decodeGeneric=function(e,t,n){const i=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,i.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):"objid"===e&&i.args?this._decodeObjid(t,i.args[0],i.args[1],n):"objid"===e?this._decodeObjid(t,null,null,n):"gentime"===e||"utctime"===e?this._decodeTime(t,e,n):"null_"===e?this._decodeNull(t,n):"bool"===e?this._decodeBool(t,n):"objDesc"===e?this._decodeStr(t,e,n):"int"===e||"enum"===e?this._decodeInt(t,i.args&&i.args[0],n):null!==i.use?this._getUse(i.use,t._reporterState.obj)._decode(t,n):t.error("unknown tag: "+e)},u.prototype._getUse=function(e,t){const n=this._baseState;return n.useDecoder=this._use(e,t),o(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},u.prototype._decodeChoice=function(e,t){const n=this._baseState;let i=null,r=!1;return Object.keys(n.choice).some((function(s){const o=e.save(),a=n.choice[s];try{const n=a._decode(e,t);if(e.isError(n))return!1;i={type:s,value:n},r=!0}catch(t){return e.restore(o),!1}return!0}),this),r?i:e.error("Choice not matched")},u.prototype._createEncoderBuffer=function(e){return new r(e,this.reporter)},u.prototype._encode=function(e,t,n){const i=this._baseState;if(null!==i.default&&i.default===e)return;const r=this._encodeValue(e,t,n);return void 0===r||this._skipDefault(r,t,n)?void 0:r},u.prototype._encodeValue=function(e,t,n){const r=this._baseState;if(null===r.parent)return r.children[0]._encode(e,t||new i);let s=null;if(this.reporter=t,r.optional&&void 0===e){if(null===r.default)return;e=r.default}let o=null,a=!1;if(r.any)s=this._createEncoderBuffer(e);else if(r.choice)s=this._encodeChoice(e,t);else if(r.contains)o=this._getUse(r.contains,n)._encode(e,t),a=!0;else if(r.children)o=r.children.map((function(n){if("null_"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error("Child should have a key");const i=t.enterKey(n._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const r=n._encode(e[n._baseState.key],t,e);return t.leaveKey(i),r}),this).filter((function(e){return e})),o=this._createEncoderBuffer(o);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return t.error("Too many args for : "+r.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const n=this.clone();n._baseState.implicit=null,o=this._createEncoderBuffer(e.map((function(n){const i=this._baseState;return this._getUse(i.args[0],e)._encode(n,t)}),n))}else null!==r.use?s=this._getUse(r.use,n)._encode(e,t):(o=this._encodePrimitive(r.tag,e),a=!0);if(!r.any&&null===r.choice){const e=null!==r.implicit?r.implicit:r.tag,n=null===r.implicit?"universal":"context";null===e?null===r.use&&t.error("Tag could be omitted only for .use()"):null===r.use&&(s=this._encodeComposite(e,a,n,o))}return null!==r.explicit&&(s=this._encodeComposite(r.explicit,!1,"context",s)),s},u.prototype._encodeChoice=function(e,t){const n=this._baseState,i=n.choice[e.type];return i||o(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,t)},u.prototype._encodePrimitive=function(e,t){const n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},u.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},u.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}},{"../base/buffer":6,"../base/reporter":9,"minimalistic-assert":278}],9:[function(e,t,n){"use strict";const i=e("inherits");function r(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function s(e,t){this.path=e,this.rethrow(t)}n.Reporter=r,r.prototype.isError=function(e){return e instanceof s},r.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},r.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},r.prototype.enterKey=function(e){return this._reporterState.path.push(e)},r.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},r.prototype.leaveKey=function(e,t,n){const i=this._reporterState;this.exitKey(e),null!==i.obj&&(i.obj[t]=n)},r.prototype.path=function(){return this._reporterState.path.join("/")},r.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},r.prototype.leaveObject=function(e){const t=this._reporterState,n=t.obj;return t.obj=e,n},r.prototype.error=function(e){let t;const n=this._reporterState,i=e instanceof s;if(t=i?e:new s(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return i||n.errors.push(t),t},r.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},i(s,Error),s.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,s),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:245}],10:[function(e,t,n){"use strict";function i(e){const t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);const i=e[n];t[i]=n})),t}n.tagClass={0:"universal",1:"application",2:"context",3:"private"},n.tagClassByName=i(n.tagClass),n.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},n.tagByName=i(n.tag)},{}],11:[function(e,t,n){"use strict";const i=n;i._reverse=function(e){const t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);const i=e[n];t[i]=n})),t},i.der=e("./der")},{"./der":10}],12:[function(e,t,n){"use strict";const i=e("inherits"),r=e("bn.js"),s=e("../base/buffer").DecoderBuffer,o=e("../base/node"),a=e("../constants/der");function c(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new u,this.tree._init(e.body)}function u(e){o.call(this,"der",e)}function l(e,t){let n=e.readUInt8(t);if(e.isError(n))return n;const i=a.tagClass[n>>6],r=0==(32&n);if(31==(31&n)){let i=n;for(n=0;128==(128&i);){if(i=e.readUInt8(t),e.isError(i))return i;n<<=7,n|=127&i}}else n&=31;return{cls:i,primitive:r,tag:n,tagStr:a.tag[n]}}function d(e,t,n){let i=e.readUInt8(n);if(e.isError(i))return i;if(!t&&128===i)return null;if(0==(128&i))return i;const r=127&i;if(r>4)return e.error("length octect is too long");i=0;for(let t=0;t=31)return i.error("Multi-octet tag encoding unsupported");t||(r|=32);return r|=o.tagClassByName[n||"universal"]<<6,r}(e,t,n,this.reporter);if(i.length<128){const e=r.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=r.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=r.alloc(2*e.length);for(let n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let i=0;for(let t=0;t=128;n>>=7)i++}const s=r.alloc(i);let o=s.length-1;for(let t=e.length-1;t>=0;t--){let n=e[t];for(s[o--]=127&n;(n>>=7)>0;)s[o--]=128|127&n}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){let n;const i=new Date(e);return"gentime"===t?n=[u(i.getUTCFullYear()),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[u(i.getUTCFullYear()%100),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!r.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=r.from(t)}if(r.isBuffer(e)){let t=e.length;0===e.length&&t++;const n=r.alloc(t);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const i=new Array(n);for(let t=i.length-1;t>=0;t--)i[t]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(r.from(i))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,n){const i=this._baseState;let r;if(null===i.default)return!1;const s=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,n).join()),s.length!==i.defaultBuffer.length)return!1;for(r=0;r=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function c(e,t,n){var i=a(e,n);return n-1>=t&&(i|=a(e,n-1)<<4),i}function u(e,t,n,i){for(var r=0,s=Math.min(e.length,n),o=t;o=49?a-49+10:a>=17?a-17+10:a}return r}s.isBN=function(e){return e instanceof s||null!==e&&"object"==typeof e&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)o=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(r=0,s=0;r>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i=t;i-=2)r=c(e,t,i)<=18?(s-=18,o+=1,this.words[o]|=r>>>26):s+=8;else for(i=(e.length-t)%2==0?t+1:t;i=18?(s-=18,o+=1,this.words[o]|=r>>>26):s+=8;this.strip()},s.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var i=0,r=1;r<=67108863;r*=t)i++;i--,r=r/t|0;for(var s=e.length-n,o=s%i,a=Math.min(s,s-o)+n,c=0,l=n;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(e,t,n){n.negative=t.negative^e.negative;var i=e.length+t.length|0;n.length=i,i=i-1|0;var r=0|e.words[0],s=0|t.words[0],o=r*s,a=67108863&o,c=o/67108864|0;n.words[0]=a;for(var u=1;u>>26,d=67108863&c,f=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=f;p++){var h=u-p|0;l+=(o=(r=0|e.words[h])*(s=0|t.words[p])+d)/67108864|0,d=67108863&o}n.words[u]=0|d,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n.strip()}s.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var r=0,s=0,o=0;o>>24-r&16777215)||o!==this.length-1?l[6-c.length]+c+n:c+n,(r+=2)>=26&&(r-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=d[e],p=f[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var m=h.modn(p).toString(e);n=(h=h.idivn(p)).isZero()?m+n:l[u-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return i(void 0!==o),this.toArrayLike(o,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,n){var r=this.byteLength(),s=n||Math.max(1,r);i(r<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===t,u=new e(s),l=this.clone();if(c){for(a=0;!l.isZero();a++)o=l.andln(255),l.iushrn(8),u[a]=o;for(;a=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-n),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var n=e/26|0,r=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(n=this,i=e):(n=e,i=this);for(var r=0,s=0;s>>26;for(;0!==r&&s>>26;if(this.length=n.length,0!==r)this.words[this.length]=r,this.length++;else if(n!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,i,r=this.cmp(e);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(n=this,i=e):(n=e,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,p=0|o[1],h=8191&p,m=p>>>13,b=0|o[2],g=8191&b,v=b>>>13,y=0|o[3],_=8191&y,w=y>>>13,x=0|o[4],k=8191&x,E=x>>>13,S=0|o[5],M=8191&S,A=S>>>13,I=0|o[6],j=8191&I,C=I>>>13,T=0|o[7],B=8191&T,R=T>>>13,L=0|o[8],O=8191&L,P=L>>>13,U=0|o[9],q=8191&U,D=U>>>13,N=0|a[0],z=8191&N,H=N>>>13,F=0|a[1],W=8191&F,V=F>>>13,K=0|a[2],$=8191&K,G=K>>>13,X=0|a[3],Y=8191&X,Z=X>>>13,J=0|a[4],Q=8191&J,ee=J>>>13,te=0|a[5],ne=8191&te,ie=te>>>13,re=0|a[6],se=8191&re,oe=re>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,le=0|a[8],de=8191&le,fe=le>>>13,pe=0|a[9],he=8191&pe,me=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(i=Math.imul(d,z))|0)+((8191&(r=(r=Math.imul(d,H))+Math.imul(f,z)|0))<<13)|0;u=((s=Math.imul(f,H))+(r>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(h,z),r=(r=Math.imul(h,H))+Math.imul(m,z)|0,s=Math.imul(m,H);var ge=(u+(i=i+Math.imul(d,W)|0)|0)+((8191&(r=(r=r+Math.imul(d,V)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,V)|0)+(r>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,z),r=(r=Math.imul(g,H))+Math.imul(v,z)|0,s=Math.imul(v,H),i=i+Math.imul(h,W)|0,r=(r=r+Math.imul(h,V)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,V)|0;var ve=(u+(i=i+Math.imul(d,$)|0)|0)+((8191&(r=(r=r+Math.imul(d,G)|0)+Math.imul(f,$)|0))<<13)|0;u=((s=s+Math.imul(f,G)|0)+(r>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(_,z),r=(r=Math.imul(_,H))+Math.imul(w,z)|0,s=Math.imul(w,H),i=i+Math.imul(g,W)|0,r=(r=r+Math.imul(g,V)|0)+Math.imul(v,W)|0,s=s+Math.imul(v,V)|0,i=i+Math.imul(h,$)|0,r=(r=r+Math.imul(h,G)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,G)|0;var ye=(u+(i=i+Math.imul(d,Y)|0)|0)+((8191&(r=(r=r+Math.imul(d,Z)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,Z)|0)+(r>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(k,z),r=(r=Math.imul(k,H))+Math.imul(E,z)|0,s=Math.imul(E,H),i=i+Math.imul(_,W)|0,r=(r=r+Math.imul(_,V)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,V)|0,i=i+Math.imul(g,$)|0,r=(r=r+Math.imul(g,G)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,G)|0,i=i+Math.imul(h,Y)|0,r=(r=r+Math.imul(h,Z)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,Z)|0;var _e=(u+(i=i+Math.imul(d,Q)|0)|0)+((8191&(r=(r=r+Math.imul(d,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((s=s+Math.imul(f,ee)|0)+(r>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(M,z),r=(r=Math.imul(M,H))+Math.imul(A,z)|0,s=Math.imul(A,H),i=i+Math.imul(k,W)|0,r=(r=r+Math.imul(k,V)|0)+Math.imul(E,W)|0,s=s+Math.imul(E,V)|0,i=i+Math.imul(_,$)|0,r=(r=r+Math.imul(_,G)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,G)|0,i=i+Math.imul(g,Y)|0,r=(r=r+Math.imul(g,Z)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,Z)|0,i=i+Math.imul(h,Q)|0,r=(r=r+Math.imul(h,ee)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,ee)|0;var we=(u+(i=i+Math.imul(d,ne)|0)|0)+((8191&(r=(r=r+Math.imul(d,ie)|0)+Math.imul(f,ne)|0))<<13)|0;u=((s=s+Math.imul(f,ie)|0)+(r>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(j,z),r=(r=Math.imul(j,H))+Math.imul(C,z)|0,s=Math.imul(C,H),i=i+Math.imul(M,W)|0,r=(r=r+Math.imul(M,V)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,V)|0,i=i+Math.imul(k,$)|0,r=(r=r+Math.imul(k,G)|0)+Math.imul(E,$)|0,s=s+Math.imul(E,G)|0,i=i+Math.imul(_,Y)|0,r=(r=r+Math.imul(_,Z)|0)+Math.imul(w,Y)|0,s=s+Math.imul(w,Z)|0,i=i+Math.imul(g,Q)|0,r=(r=r+Math.imul(g,ee)|0)+Math.imul(v,Q)|0,s=s+Math.imul(v,ee)|0,i=i+Math.imul(h,ne)|0,r=(r=r+Math.imul(h,ie)|0)+Math.imul(m,ne)|0,s=s+Math.imul(m,ie)|0;var xe=(u+(i=i+Math.imul(d,se)|0)|0)+((8191&(r=(r=r+Math.imul(d,oe)|0)+Math.imul(f,se)|0))<<13)|0;u=((s=s+Math.imul(f,oe)|0)+(r>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(B,z),r=(r=Math.imul(B,H))+Math.imul(R,z)|0,s=Math.imul(R,H),i=i+Math.imul(j,W)|0,r=(r=r+Math.imul(j,V)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,V)|0,i=i+Math.imul(M,$)|0,r=(r=r+Math.imul(M,G)|0)+Math.imul(A,$)|0,s=s+Math.imul(A,G)|0,i=i+Math.imul(k,Y)|0,r=(r=r+Math.imul(k,Z)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,Z)|0,i=i+Math.imul(_,Q)|0,r=(r=r+Math.imul(_,ee)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,ee)|0,i=i+Math.imul(g,ne)|0,r=(r=r+Math.imul(g,ie)|0)+Math.imul(v,ne)|0,s=s+Math.imul(v,ie)|0,i=i+Math.imul(h,se)|0,r=(r=r+Math.imul(h,oe)|0)+Math.imul(m,se)|0,s=s+Math.imul(m,oe)|0;var ke=(u+(i=i+Math.imul(d,ce)|0)|0)+((8191&(r=(r=r+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((s=s+Math.imul(f,ue)|0)+(r>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(O,z),r=(r=Math.imul(O,H))+Math.imul(P,z)|0,s=Math.imul(P,H),i=i+Math.imul(B,W)|0,r=(r=r+Math.imul(B,V)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,V)|0,i=i+Math.imul(j,$)|0,r=(r=r+Math.imul(j,G)|0)+Math.imul(C,$)|0,s=s+Math.imul(C,G)|0,i=i+Math.imul(M,Y)|0,r=(r=r+Math.imul(M,Z)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(k,Q)|0,r=(r=r+Math.imul(k,ee)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,ee)|0,i=i+Math.imul(_,ne)|0,r=(r=r+Math.imul(_,ie)|0)+Math.imul(w,ne)|0,s=s+Math.imul(w,ie)|0,i=i+Math.imul(g,se)|0,r=(r=r+Math.imul(g,oe)|0)+Math.imul(v,se)|0,s=s+Math.imul(v,oe)|0,i=i+Math.imul(h,ce)|0,r=(r=r+Math.imul(h,ue)|0)+Math.imul(m,ce)|0,s=s+Math.imul(m,ue)|0;var Ee=(u+(i=i+Math.imul(d,de)|0)|0)+((8191&(r=(r=r+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((s=s+Math.imul(f,fe)|0)+(r>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(q,z),r=(r=Math.imul(q,H))+Math.imul(D,z)|0,s=Math.imul(D,H),i=i+Math.imul(O,W)|0,r=(r=r+Math.imul(O,V)|0)+Math.imul(P,W)|0,s=s+Math.imul(P,V)|0,i=i+Math.imul(B,$)|0,r=(r=r+Math.imul(B,G)|0)+Math.imul(R,$)|0,s=s+Math.imul(R,G)|0,i=i+Math.imul(j,Y)|0,r=(r=r+Math.imul(j,Z)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(M,Q)|0,r=(r=r+Math.imul(M,ee)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,ee)|0,i=i+Math.imul(k,ne)|0,r=(r=r+Math.imul(k,ie)|0)+Math.imul(E,ne)|0,s=s+Math.imul(E,ie)|0,i=i+Math.imul(_,se)|0,r=(r=r+Math.imul(_,oe)|0)+Math.imul(w,se)|0,s=s+Math.imul(w,oe)|0,i=i+Math.imul(g,ce)|0,r=(r=r+Math.imul(g,ue)|0)+Math.imul(v,ce)|0,s=s+Math.imul(v,ue)|0,i=i+Math.imul(h,de)|0,r=(r=r+Math.imul(h,fe)|0)+Math.imul(m,de)|0,s=s+Math.imul(m,fe)|0;var Se=(u+(i=i+Math.imul(d,he)|0)|0)+((8191&(r=(r=r+Math.imul(d,me)|0)+Math.imul(f,he)|0))<<13)|0;u=((s=s+Math.imul(f,me)|0)+(r>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(q,W),r=(r=Math.imul(q,V))+Math.imul(D,W)|0,s=Math.imul(D,V),i=i+Math.imul(O,$)|0,r=(r=r+Math.imul(O,G)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,G)|0,i=i+Math.imul(B,Y)|0,r=(r=r+Math.imul(B,Z)|0)+Math.imul(R,Y)|0,s=s+Math.imul(R,Z)|0,i=i+Math.imul(j,Q)|0,r=(r=r+Math.imul(j,ee)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,ee)|0,i=i+Math.imul(M,ne)|0,r=(r=r+Math.imul(M,ie)|0)+Math.imul(A,ne)|0,s=s+Math.imul(A,ie)|0,i=i+Math.imul(k,se)|0,r=(r=r+Math.imul(k,oe)|0)+Math.imul(E,se)|0,s=s+Math.imul(E,oe)|0,i=i+Math.imul(_,ce)|0,r=(r=r+Math.imul(_,ue)|0)+Math.imul(w,ce)|0,s=s+Math.imul(w,ue)|0,i=i+Math.imul(g,de)|0,r=(r=r+Math.imul(g,fe)|0)+Math.imul(v,de)|0,s=s+Math.imul(v,fe)|0;var Me=(u+(i=i+Math.imul(h,he)|0)|0)+((8191&(r=(r=r+Math.imul(h,me)|0)+Math.imul(m,he)|0))<<13)|0;u=((s=s+Math.imul(m,me)|0)+(r>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(q,$),r=(r=Math.imul(q,G))+Math.imul(D,$)|0,s=Math.imul(D,G),i=i+Math.imul(O,Y)|0,r=(r=r+Math.imul(O,Z)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,Z)|0,i=i+Math.imul(B,Q)|0,r=(r=r+Math.imul(B,ee)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,ee)|0,i=i+Math.imul(j,ne)|0,r=(r=r+Math.imul(j,ie)|0)+Math.imul(C,ne)|0,s=s+Math.imul(C,ie)|0,i=i+Math.imul(M,se)|0,r=(r=r+Math.imul(M,oe)|0)+Math.imul(A,se)|0,s=s+Math.imul(A,oe)|0,i=i+Math.imul(k,ce)|0,r=(r=r+Math.imul(k,ue)|0)+Math.imul(E,ce)|0,s=s+Math.imul(E,ue)|0,i=i+Math.imul(_,de)|0,r=(r=r+Math.imul(_,fe)|0)+Math.imul(w,de)|0,s=s+Math.imul(w,fe)|0;var Ae=(u+(i=i+Math.imul(g,he)|0)|0)+((8191&(r=(r=r+Math.imul(g,me)|0)+Math.imul(v,he)|0))<<13)|0;u=((s=s+Math.imul(v,me)|0)+(r>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(q,Y),r=(r=Math.imul(q,Z))+Math.imul(D,Y)|0,s=Math.imul(D,Z),i=i+Math.imul(O,Q)|0,r=(r=r+Math.imul(O,ee)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,ee)|0,i=i+Math.imul(B,ne)|0,r=(r=r+Math.imul(B,ie)|0)+Math.imul(R,ne)|0,s=s+Math.imul(R,ie)|0,i=i+Math.imul(j,se)|0,r=(r=r+Math.imul(j,oe)|0)+Math.imul(C,se)|0,s=s+Math.imul(C,oe)|0,i=i+Math.imul(M,ce)|0,r=(r=r+Math.imul(M,ue)|0)+Math.imul(A,ce)|0,s=s+Math.imul(A,ue)|0,i=i+Math.imul(k,de)|0,r=(r=r+Math.imul(k,fe)|0)+Math.imul(E,de)|0,s=s+Math.imul(E,fe)|0;var Ie=(u+(i=i+Math.imul(_,he)|0)|0)+((8191&(r=(r=r+Math.imul(_,me)|0)+Math.imul(w,he)|0))<<13)|0;u=((s=s+Math.imul(w,me)|0)+(r>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(q,Q),r=(r=Math.imul(q,ee))+Math.imul(D,Q)|0,s=Math.imul(D,ee),i=i+Math.imul(O,ne)|0,r=(r=r+Math.imul(O,ie)|0)+Math.imul(P,ne)|0,s=s+Math.imul(P,ie)|0,i=i+Math.imul(B,se)|0,r=(r=r+Math.imul(B,oe)|0)+Math.imul(R,se)|0,s=s+Math.imul(R,oe)|0,i=i+Math.imul(j,ce)|0,r=(r=r+Math.imul(j,ue)|0)+Math.imul(C,ce)|0,s=s+Math.imul(C,ue)|0,i=i+Math.imul(M,de)|0,r=(r=r+Math.imul(M,fe)|0)+Math.imul(A,de)|0,s=s+Math.imul(A,fe)|0;var je=(u+(i=i+Math.imul(k,he)|0)|0)+((8191&(r=(r=r+Math.imul(k,me)|0)+Math.imul(E,he)|0))<<13)|0;u=((s=s+Math.imul(E,me)|0)+(r>>>13)|0)+(je>>>26)|0,je&=67108863,i=Math.imul(q,ne),r=(r=Math.imul(q,ie))+Math.imul(D,ne)|0,s=Math.imul(D,ie),i=i+Math.imul(O,se)|0,r=(r=r+Math.imul(O,oe)|0)+Math.imul(P,se)|0,s=s+Math.imul(P,oe)|0,i=i+Math.imul(B,ce)|0,r=(r=r+Math.imul(B,ue)|0)+Math.imul(R,ce)|0,s=s+Math.imul(R,ue)|0,i=i+Math.imul(j,de)|0,r=(r=r+Math.imul(j,fe)|0)+Math.imul(C,de)|0,s=s+Math.imul(C,fe)|0;var Ce=(u+(i=i+Math.imul(M,he)|0)|0)+((8191&(r=(r=r+Math.imul(M,me)|0)+Math.imul(A,he)|0))<<13)|0;u=((s=s+Math.imul(A,me)|0)+(r>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(q,se),r=(r=Math.imul(q,oe))+Math.imul(D,se)|0,s=Math.imul(D,oe),i=i+Math.imul(O,ce)|0,r=(r=r+Math.imul(O,ue)|0)+Math.imul(P,ce)|0,s=s+Math.imul(P,ue)|0,i=i+Math.imul(B,de)|0,r=(r=r+Math.imul(B,fe)|0)+Math.imul(R,de)|0,s=s+Math.imul(R,fe)|0;var Te=(u+(i=i+Math.imul(j,he)|0)|0)+((8191&(r=(r=r+Math.imul(j,me)|0)+Math.imul(C,he)|0))<<13)|0;u=((s=s+Math.imul(C,me)|0)+(r>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(q,ce),r=(r=Math.imul(q,ue))+Math.imul(D,ce)|0,s=Math.imul(D,ue),i=i+Math.imul(O,de)|0,r=(r=r+Math.imul(O,fe)|0)+Math.imul(P,de)|0,s=s+Math.imul(P,fe)|0;var Be=(u+(i=i+Math.imul(B,he)|0)|0)+((8191&(r=(r=r+Math.imul(B,me)|0)+Math.imul(R,he)|0))<<13)|0;u=((s=s+Math.imul(R,me)|0)+(r>>>13)|0)+(Be>>>26)|0,Be&=67108863,i=Math.imul(q,de),r=(r=Math.imul(q,fe))+Math.imul(D,de)|0,s=Math.imul(D,fe);var Re=(u+(i=i+Math.imul(O,he)|0)|0)+((8191&(r=(r=r+Math.imul(O,me)|0)+Math.imul(P,he)|0))<<13)|0;u=((s=s+Math.imul(P,me)|0)+(r>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Le=(u+(i=Math.imul(q,he))|0)+((8191&(r=(r=Math.imul(q,me))+Math.imul(D,he)|0))<<13)|0;return u=((s=Math.imul(D,me))+(r>>>13)|0)+(Le>>>26)|0,Le&=67108863,c[0]=be,c[1]=ge,c[2]=ve,c[3]=ye,c[4]=_e,c[5]=we,c[6]=xe,c[7]=ke,c[8]=Ee,c[9]=Se,c[10]=Me,c[11]=Ae,c[12]=Ie,c[13]=je,c[14]=Ce,c[15]=Te,c[16]=Be,c[17]=Re,c[18]=Le,0!==u&&(c[19]=u,n.length++),n};function m(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(h=p),s.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?h(this,e,t):n<63?p(this,e,t):n<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var i=0,r=0,s=0;s>>26)|0)>>>26,o&=67108863}n.words[s]=a,i=o,o=r}return 0!==i?n.words[s]=i:n.length--,n.strip()}(this,e,t):m(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=s.prototype._countBits(e)-1,i=0;i>=1;return i},b.prototype.permute=function(e,t,n,i,r,s){for(var o=0;o>>=1)r++;return 1<>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,t+=r/67108864|0,t+=s>>>26,this.words[n]=67108863&s}return 0!==t&&(this.words[n]=t,this.length++),this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>r}return t}(e);if(0===t.length)return new s(1);for(var n=this,i=0;i=0);var t,n=e%26,r=(e-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(t=0;t>>26-n}o&&(this.words[t]=o,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=r);u--){var d=0|this.words[u];this.words[u]=l<<26-s|d>>>s,l=d&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(e,t,n){return i(0===this.negative),this.iushrn(e,t,n)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,r=1<=0);var t=e%26,n=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[r+n]=67108863&s}for(;r>26,this.words[r+n]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,r=0;r>26,this.words[r]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(e,t){var n=(this.length,e.length),i=this.clone(),r=e,o=0|r.words[r.length-1];0!==(n=26-this._countBits(o))&&(r=r.ushln(n),i.iushln(n),o=0|r.words[r.length-1]);var a,c=i.length-r.length;if("mod"!==t){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;d--){var f=67108864*(0|i.words[r.length+d])+(0|i.words[r.length+d-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(r,f,d);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(r,1,d),i.isZero()||(i.negative^=1);a&&(a.words[d]=f)}return a&&a.strip(),i.strip(),"div"!==t&&0!==n&&i.iushrn(n),{div:a||null,mod:i}},s.prototype.divmod=function(e,t,n){return i(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(r=a.div.neg()),"div"!==t&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(e)),{div:r,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(r=a.div.neg()),{div:r,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),r=e.andln(1),s=n.cmp(i);return s<0||1===r&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modn=function(e){i(e<=67108863);for(var t=(1<<26)%e,n=0,r=this.length-1;r>=0;r--)n=(t*n+(0|this.words[r]))%e;return n},s.prototype.idivn=function(e){i(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var r=(0|this.words[n])+67108864*t;this.words[n]=r/e|0,t=r%e}return this.strip()},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;0==(t.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(r.isOdd()||o.isOdd())&&(r.iadd(l),o.isub(d)),r.iushrn(1),o.iushrn(1);for(var h=0,m=1;0==(n.words[0]&m)&&h<26;++h,m<<=1);if(h>0)for(n.iushrn(h);h-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(d)),a.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),r.isub(a),o.isub(c)):(n.isub(t),a.isub(r),c.isub(o))}return{a:a,b:c,gcd:n.iushln(u)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,o=new s(1),a=new s(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var d=0,f=1;0==(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(a)):(n.isub(t),a.isub(o))}return(r=0===t.cmpn(1)?o:a).cmpn(0)<0&&r.iadd(e),r},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var i=0;t.isEven()&&n.isEven();i++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var r=t.cmp(n);if(r<0){var s=t;t=n,n=s}else if(0===r||0===n.cmpn(1))break;t.isub(n)}return n.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,n=(e-t)/26,r=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),i(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;n--){var i=0|this.words[n],r=0|e.words[n];if(i!==r){ir&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new k(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function x(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function k(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},r(y,v),y.prototype.split=function(e,t){for(var n=4194303,i=Math.min(e.length,9),r=0;r>>22,s=o}s>>>=22,e.words[r-10]=s,0===s&&e.length>10?e.length-=10:e.length-=9},y.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=r,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new y;else if("p224"===e)t=new _;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new x}return g[e]=t,t},k.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},k.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},k.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var n=this.m.add(new s(1)).iushrn(2);return this.pow(e,n)}for(var r=this.m.subn(1),o=0;!r.isZero()&&0===r.andln(1);)o++,r.iushrn(1);i(!r.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,r),f=this.pow(e,r.addn(1).iushrn(1)),p=this.pow(e,r),h=o;0!==p.cmp(a);){for(var m=p,b=0;0!==m.cmp(a);b++)m=m.redSqr();i(b=0;i--){for(var u=t.words[i],l=c-1;l>=0;l--){var d=u>>l&1;r!==n[0]&&(r=this.sqr(r)),0!==d||0!==o?(o<<=1,o|=d,(4===++a||0===i&&0===l)&&(r=this.mul(r,n[o]),a=0,o=0)):a=0}c=26}return r},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new E(e)},r(E,k),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),s=r;return r.cmp(this.m)>=0?s=r.isub(this.m):r.cmpn(0)<0&&(s=r.iadd(this.m)),s._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var n=e.mul(t),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),o=r;return r.cmp(this.m)>=0?o=r.isub(this.m):r.cmpn(0)<0&&(o=r.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:71}],19:[function(e,t,n){"use strict";n.byteLength=function(e){var t=u(e),n=t[0],i=t[1];return 3*(n+i)/4-i},n.toByteArray=function(e){var t,n,i=u(e),o=i[0],a=i[1],c=new s(function(e,t,n){return 3*(t+n)/4-n}(0,o,a)),l=0,d=a>0?o-4:o;for(n=0;n>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[l++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=16383,a=0,c=n-r;ac?c:a+o));1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},{}],20:[function(e,t,n){var i=e("safe-buffer").Buffer;function r(e,t,n){for(var i=0,r=1,s=t;s=48)i=10*i+(o-48);else if(s!==t||43!==o){if(s!==t||45!==o){if(46===o)break;throw new Error("not a number: buffer["+s+"] = "+o)}r=-1}}return i*r}function s(e,t,n,r){return null==e||0===e.length?null:("number"!=typeof t&&null==r&&(r=t,t=void 0),"number"!=typeof n&&null==r&&(r=n,n=void 0),s.position=0,s.encoding=r||null,s.data=i.isBuffer(e)?e.slice(t,n):i.from(e),s.bytes=s.data.length,s.next())}s.bytes=0,s.position=0,s.data=null,s.encoding=null,s.next=function(){switch(s.data[s.position]){case 100:return s.dictionary();case 108:return s.list();case 105:return s.integer();default:return s.buffer()}},s.find=function(e){for(var t=s.position,n=s.data.length,i=s.data;t{const r=t.split("-").map((e=>parseInt(e)));return e.concat(((e,t=e)=>Array.from({length:t-e+1},((t,n)=>n+e)))(...r))}),[])}t.exports=i,t.exports.parse=i,t.exports.compose=function(e){return e.reduce(((e,t,n,i)=>(0!==n&&t===i[n-1]+1||e.push([]),e[e.length-1].push(t),e)),[]).map((e=>e.length>1?`${e[0]}-${e[e.length-1]}`:`${e[0]}`))}},{}],24:[function(e,t,n){t.exports=function(e,t,n,i,r){var s,o;if(void 0===i)i=0;else if((i|=0)<0||i>=e.length)throw new RangeError("invalid lower bound");if(void 0===r)r=e.length-1;else if((r|=0)=e.length)throw new RangeError("invalid upper bound");for(;i<=r;)if((o=+n(e[s=i+(r-i>>>1)],t,s,e))<0)i=s+1;else{if(!(o>0))return s;r=s-1}return~i}},{}],25:[function(e,t,n){"use strict";function i(e){var t=e>>3;return e%8!=0&&t++,t}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){void 0===e&&(e=0);var n=null==t?void 0:t.grow;this.grow=n&&isFinite(n)&&i(n)||n||0,this.buffer="number"==typeof e?new Uint8Array(i(e)):e}return e.prototype.get=function(e){var t=e>>3;return t>e%8)},e.prototype.set=function(e,t){void 0===t&&(t=!0);var n=e>>3;if(t){if(this.buffer.length>e%8}else n>e%8))},e.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=8*this.buffer.length);for(var i=t,r=i>>3,s=128>>i%8,o=this.buffer[r];i>1},e}();n.default=r},{}],26:[function(e,t,n){(function(n){(function(){ /*! bittorrent-protocol. MIT License. WebTorrent LLC */ -const i=e("unordered-array-remove"),r=e("bencode"),o=e("bitfield").default,s=e("debug")("bittorrent-protocol"),a=e("randombytes"),c=e("speedometer"),l=e("readable-stream"),p=n.from("BitTorrent protocol"),u=n.from([0,0,0,0]),d=n.from([0,0,0,1,0]),f=n.from([0,0,0,1,1]),h=n.from([0,0,0,1,2]),m=n.from([0,0,0,1,3]),g=[0,0,0,0,0,0,0,0],v=[0,0,0,3,9,0,0];class b{constructor(e,t,n,i){this.piece=e,this.offset=t,this.length=n,this.callback=i}}class x extends l.Duplex{constructor(){super(),this._debugId=a(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=null,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new o(0,{grow:4e5}),this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=c(),this.downloadSpeed=c(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this._timeoutExpiresAt=null,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this.once("finish",(()=>this._onFinish())),this._parseHandshake()}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval),!1!==e&&(this._keepAliveInterval=setInterval((()=>{this.keepAlive()}),55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._timeoutMs=e,this._timeoutUnref=!!t,this._resetTimeout(!0)}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){const t=e.prototype.name;if(!t)throw new Error('Extension class requires a "name" property on the prototype');this._debug("use extension.name=%s",t);const n=this._nextExt,i=new e(this);function r(){}"function"!=typeof i.onHandshake&&(i.onHandshake=r),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=r),"function"!=typeof i.onMessage&&(i.onMessage=r),this.extendedMapping[n]=t,this._ext[t]=i,this[t]=i,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(u)}handshake(e,t,i){let r,o;if("string"==typeof e?(e=e.toLowerCase(),r=n.from(e,"hex")):(r=e,e=r.toString("hex")),"string"==typeof t?o=n.from(t,"hex"):(o=t,t=o.toString("hex")),20!==r.length||20!==o.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,i);const s=n.from(g);s[5]|=16,i&&i.dht&&(s[7]|=1),this._push(n.concat([p,s,r,o])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=Object.assign({},this.extendedHandshake);e.m={};for(const t in this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,r.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(d)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(f))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(h))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(m))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(e){this._debug("bitfield"),n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(e,t,n,i){return i||(i=()=>{}),this._finished?i(new Error("wire is closed")):this.peerChoking?i(new Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new b(e,t,n,i)),this._timeout||this._resetTimeout(!0),void this._message(6,[e,t,n],null))}piece(e,t,n){this._debug("piece index=%d offset=%d",e,t),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(e){this._debug("port %d",e);const t=n.from(v);t.writeUInt16BE(e,5),this._push(t)}extended(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error(`Unrecognized extension: ${e}`);{const i=n.from([e]),o=n.isBuffer(t)?t:r.encode(t);this._message(20,[],n.concat([i,o]))}}_read(){}_message(e,t,i){const r=i?i.length:0,o=n.allocUnsafe(5+4*t.length);o.writeUInt32BE(o.length+r-4,0),o[4]=e;for(let e=0;e{if(r===this._pull(this.peerRequests,e,t,n))return i?this._debug("error satisfying request index=%d offset=%d length=%d (%s)",e,t,n,i.message):void this.piece(e,t,o)},r=new b(e,t,n,i);this.peerRequests.push(r),this.emit("request",e,t,n,i)}_onPiece(e,t,n){this._debug("got piece index=%d offset=%d",e,t),this._callback(this._pull(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)}_onCancel(e,t,n){this._debug("got cancel index=%d offset=%d length=%d",e,t,n),this._pull(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)}_onPort(e){this._debug("got port %d",e),this.emit("port",e)}_onExtended(e,t){if(0===e){let e,n;try{e=r.decode(t)}catch(e){this._debug("ignoring invalid extended handshake: %s",e.message||e)}if(!e)return;if(this.peerExtendedHandshake=e,"object"==typeof e.m)for(n in e.m)this.peerExtendedMapping[n]=Number(e.m[n].toString());for(n in this._ext)this.peerExtendedMapping[n]&&this._ext[n].onExtendedHandshake(this.peerExtendedHandshake);this._debug("got extended handshake"),this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this._debug("got extended message ext=%s",e),this.emit("extended",e,t)}_onTimeout(){this._debug("request timed out"),this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")}_write(e,t,i){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){const e=1===this._buffer.length?this._buffer[0]:n.concat(this._buffer,this._bufferSize);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[e.slice(this._parserSize)]:[],this._parser(e.slice(0,this._parserSize))}i(null)}_callback(e,t,n){e&&(this._resetTimeout(!this.peerChoking&&!this._finished),e.callback(t,n))}_resetTimeout(e){if(!e||!this._timeoutMs||!this.requests.length)return clearTimeout(this._timeout),this._timeout=null,void(this._timeoutExpiresAt=null);const t=Date.now()+this._timeoutMs;if(this._timeout){if(t-this._timeoutExpiresAt<.05*this._timeoutMs)return;clearTimeout(this._timeout)}this._timeoutExpiresAt=t,this._timeout=setTimeout((()=>this._onTimeout()),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref()}_parse(e,t){this._parserSize=e,this._parser=t}_onMessageLength(e){const t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(e){switch(this._parse(4,this._onMessageLength),e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",e)}}_parseHandshake(){this._parse(1,(e=>{const t=e.readUInt8(0);this._parse(t+48,(e=>{const n=e.slice(0,t);if("BitTorrent protocol"!==n.toString())return this._debug("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void this.end();e=e.slice(t),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),this._parse(4,this._onMessageLength)}))}))}_onFinish(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,(()=>{}));this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)}_debug(...e){e[0]=`[${this._debugId}] ${e[0]}`,s(...e)}_pull(e,t,n,r){for(let o=0;o{"%%"!==e&&(i++,"%c"===e&&(r=i))})),e.splice(r,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG);return e},n.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"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+)/)},n.storage=function(){try{return localStorage}catch(e){}}(),n.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`."))}})(),n.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"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:r}=t.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":13,_process:189}],13:[function(e,t,n){t.exports=function(t){function n(e){let t,r=null;function o(...e){if(!o.enabled)return;const i=o,r=Number(new Date),s=r-(t||r);i.diff=s,i.prev=t,i.curr=r,t=r,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,r)=>{if("%%"===t)return"%";a++;const o=n.formatters[r];if("function"==typeof o){const n=e[a];t=o.call(i,n),e.splice(a,1),a--}return t})),n.formatArgs.call(i,e);(i.log||n.log).apply(i,e)}return o.namespace=e,o.useColors=n.useColors(),o.color=n.selectColor(e),o.extend=i,o.destroy=n.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===r?n.enabled(e):r,set:e=>{r=e}}),"function"==typeof n.init&&n.init(o),o}function i(e,t){const i=n(this.namespace+(void 0===t?":":t)+e);return i.log=this.log,i}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map((e=>"-"+e))].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),r=i.length;for(t=0;t{n[e]=t[e]})),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*o;case"minutes":case"minute":case"mins":case"min":case"m":return n*r;case"seconds":case"second":case"secs":case"sec":case"s":return n*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return l(e,t,s,"day");if(t>=o)return l(e,t,o,"hour");if(t>=r)return l(e,t,r,"minute");if(t>=i)return l(e,t,i,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=o)return Math.round(e/o)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=i)return Math.round(e/i)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],15:[function(e,t,n){"use strict";var i={};function r(e,t,n){n||(n=Error);var r=function(e){var n,i;function r(n,i,r){return e.call(this,function(e,n,i){return"string"==typeof t?t:t(e,n,i)}(n,i,r))||this}return i=e,(n=r).prototype=Object.create(i.prototype),n.prototype.constructor=n,n.__proto__=i,r}(n);r.prototype.name=n.name,r.prototype.code=e,i[e]=r}function o(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}r("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(e,t,n){var i,r,s,a;if("string"==typeof t&&(r="not ",t.substr(!s||s<0?0:+s,r.length)===r)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(i," ").concat(o(t,"type"));else{var c=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(i," ").concat(o(t,"type"))}return a+=". Received type ".concat(typeof n)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=i},{}],16:[function(e,t,n){(function(n){(function(){"use strict";var i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var r=e("./_stream_readable"),o=e("./_stream_writable");e("inherits")(l,r);for(var s=i(o.prototype),a=0;a0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),i)s.endEmitted?w(e,new _):T(e,s,t,!0);else if(s.ended)w(e,new x);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?T(e,s,t,!1):R(e,s)):T(e,s,t,!1)}else i||(s.reading=!1,R(e,s));return!s.ended&&(s.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=j?e=j:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function L(e){var t=e._readableState;l("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(l("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(I,e))}function I(e){var t=e._readableState;l("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,M(e)}function R(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(O,e,t))}function O(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function U(e){l("readable nexttick read 0"),e.read(0)}function P(e,t){l("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),M(e),t.flowing&&!t.reading&&e.read(0)}function M(e){var t=e._readableState;for(l("flow",t.flowing);t.flowing&&null!==e.read(););}function N(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function D(e){var t=e._readableState;l("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(q,t,e))}function q(e,t){if(l("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function H(e,t){for(var n=0,i=e.length;n=t.highWaterMark:t.length>0)||t.ended))return l("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):L(this),null;if(0===(e=A(e,t))&&t.ended)return 0===t.length&&D(this),null;var i,r=t.needReadable;return l("need readable",r),(0===t.length||t.length-e0?N(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),n!==e&&t.ended&&D(this)),null!==i&&this.emit("data",i),i},S.prototype._read=function(e){w(this,new y("_read()"))},S.prototype.pipe=function(e,t){var i=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,l("pipe count=%d opts=%j",r.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:g;function a(t,n){l("onunpipe"),t===i&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,l("cleanup"),e.removeListener("close",h),e.removeListener("finish",m),e.removeListener("drain",p),e.removeListener("error",f),e.removeListener("unpipe",a),i.removeListener("end",c),i.removeListener("end",g),i.removeListener("data",d),u=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||p())}function c(){l("onend"),e.end()}r.endEmitted?n.nextTick(s):i.once("end",s),e.on("unpipe",a);var p=function(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,M(e))}}(i);e.on("drain",p);var u=!1;function d(t){l("ondata");var n=e.write(t);l("dest.write",n),!1===n&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==H(r.pipes,e))&&!u&&(l("false write response, pause",r.awaitDrain),r.awaitDrain++),i.pause())}function f(t){l("onerror",t),g(),e.removeListener("error",f),0===o(e,"error")&&w(e,t)}function h(){e.removeListener("finish",m),g()}function m(){l("onfinish"),e.removeListener("close",h),g()}function g(){l("unpipe"),i.unpipe(e)}return i.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",h),e.once("finish",m),e.emit("pipe",i),r.flowing||(l("pipe resume"),i.resume()),e},S.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,l("on readable",r.length,r.reading),r.length?L(this):r.reading||n.nextTick(U,this))),i},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(e,t){var i=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(B,this),i},S.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(B,this),t},S.prototype.resume=function(){var e=this._readableState;return e.flowing||(l("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(P,e,t))}(this,e)),e.paused=!1,this},S.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},S.prototype.wrap=function(e){var t=this,n=this._readableState,i=!1;for(var r in e.on("end",(function(){if(l("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(r){(l("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r)||(n.objectMode||r&&r.length)&&(t.push(r)||(i=!0,e.pause()))})),e)void 0===this[r]&&"function"==typeof e[r]&&(this[r]=function(t){return function(){return e[t].apply(e,arguments)}}(r));for(var o=0;o-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(S.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(S.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),S.prototype._write=function(e,t,n){n(new m("_write()"))},S.prototype._writev=null,S.prototype.end=function(e,t,i){var r=this._writableState;return"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,i){t.ending=!0,I(e,t),i&&(t.finished?n.nextTick(i):e.once("finish",i));t.ended=!0,e.writable=!1}(this,r,i),this},Object.defineProperty(S.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),S.prototype.destroy=u.destroy,S.prototype._undestroy=u.undestroy,S.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,_process:189,buffer:55,inherits:118,"util-deprecate":307}],21:[function(e,t,n){(function(n){(function(){"use strict";var i;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),p=Symbol("lastPromise"),u=Symbol("handlePromise"),d=Symbol("stream");function f(e,t){return{value:e,done:t}}function h(e){var t=e[s];if(null!==t){var n=e[d].read();null!==n&&(e[p]=null,e[s]=null,e[a]=null,t(f(n,!1)))}}function m(e){n.nextTick(h,e)}var g=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((r(i={get stream(){return this[d]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(f(void 0,!0));if(this[d].destroyed)return new Promise((function(t,i){n.nextTick((function(){e[c]?i(e[c]):t(f(void 0,!0))}))}));var i,r=this[p];if(r)i=new Promise(function(e,t){return function(n,i){e.then((function(){t[l]?n(f(void 0,!0)):t[u](n,i)}),i)}}(r,this));else{var o=this[d].read();if(null!==o)return Promise.resolve(f(o,!1));i=new Promise(this[u])}return this[p]=i,i}},Symbol.asyncIterator,(function(){return this})),r(i,"return",(function(){var e=this;return new Promise((function(t,n){e[d].destroy(null,(function(e){e?n(e):t(f(void 0,!0))}))}))})),i),g);t.exports=function(e){var t,n=Object.create(v,(r(t={},d,{value:e,writable:!0}),r(t,s,{value:null,writable:!0}),r(t,a,{value:null,writable:!0}),r(t,c,{value:null,writable:!0}),r(t,l,{value:e._readableState.endEmitted,writable:!0}),r(t,u,{value:function(e,t){var i=n[d].read();i?(n[p]=null,n[s]=null,n[a]=null,e(f(i,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[p]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[p]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var i=n[s];null!==i&&(n[p]=null,n[s]=null,n[a]=null,i(f(void 0,!0))),n[l]=!0})),e.on("readable",m.bind(null,n)),n}}).call(this)}).call(this,e("_process"))},{"./end-of-stream":24,_process:189}],22:[function(e,t,n){"use strict";function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){for(var n=0;n0?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 s.alloc(0);for(var t,n,i,r=s.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,n=r,i=a,s.prototype.copy.call(t,n,i),a+=o.data.length,o=o.next;return r}},{key:"consume",value:function(e,t){var n;return er.length?r.length:e;if(o===r.length?i+=r:i+=r.slice(0,e),0==(e-=o)){o===r.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=r.slice(o));break}++n}return this.length-=n,i}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),n=this.head,i=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var r=n.data,o=e>r.length?r.length:e;if(r.copy(t,t.length-e,0,o),0==(e-=o)){o===r.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=r.slice(o));break}++i}return this.length-=i,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){i||(i=e),e&&s.forEach(l),o||(s.forEach(l),r(i))}))}));return t.reduce(p)}},{"../../../errors":15,"./end-of-stream":24}],27:[function(e,t,n){"use strict";var i=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,n,r){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new i(r?n:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},{"../../../errors":15}],28:[function(e,t,n){t.exports=e("events").EventEmitter},{events:97}],29:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(e,t,n){(function(n,i){(function(){const r=e("debug")("bittorrent-tracker:client"),o=e("events"),s=e("once"),a=e("run-parallel"),c=e("simple-peer"),l=e("queue-microtask"),p=e("./lib/common"),u=e("./lib/client/http-tracker"),d=e("./lib/client/udp-tracker"),f=e("./lib/client/websocket-tracker");class h extends o{constructor(e={}){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this._peerIdBuffer=i.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._infoHashBuffer=i.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),r("new client %s",this.infoHash),this.destroyed=!1,this._port=e.port,this._getAnnounceOpts=e.getAnnounceOpts,this._rtcConfig=e.rtcConfig,this._userAgent=e.userAgent,this._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;let t="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;t=t.map((e=>("/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e))),t=Array.from(new Set(t));const o=!1!==this._wrtc&&(!!this._wrtc||c.WEBRTC_SUPPORT),s=e=>{l((()=>{this.emit("warning",e)}))};this._trackers=t.map((e=>{let t;try{t=new URL(e)}catch(t){return s(new Error(`Invalid tracker URL: ${e}`)),null}const n=t.port;if(n<0||n>65535)return s(new Error(`Invalid tracker port: ${e}`)),null;const i=t.protocol;return"http:"!==i&&"https:"!==i||"function"!=typeof u?"udp:"===i&&"function"==typeof d?new d(this,e):"ws:"!==i&&"wss:"!==i||!o||"ws:"===i&&"undefined"!=typeof window&&"https:"===window.location.protocol?(s(new Error(`Unsupported tracker protocol: ${e}`)),null):new f(this,e):new u(this,e)})).filter(Boolean)}start(e){(e=this._defaultAnnounceOpts(e)).event="started",r("send `start` %o",e),this._announce(e),this._trackers.forEach((e=>{e.setInterval()}))}stop(e){(e=this._defaultAnnounceOpts(e)).event="stopped",r("send `stop` %o",e),this._announce(e)}complete(e){e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",r("send `complete` %o",e),this._announce(e)}update(e){(e=this._defaultAnnounceOpts(e)).event&&delete e.event,r("send `update` %o",e),this._announce(e)}_announce(e){this._trackers.forEach((t=>{t.announce(e)}))}scrape(e){r("send `scrape`"),e||(e={}),this._trackers.forEach((t=>{t.scrape(e)}))}setInterval(e){r("setInterval %d",e),this._trackers.forEach((t=>{t.setInterval(e)}))}destroy(e){if(this.destroyed)return;this.destroyed=!0,r("destroy");const t=this._trackers.map((e=>t=>{e.destroy(t)}));a(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=p.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}h.scrape=(e,t)=>{if(t=s(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:i.from("01234567890123456789"),port:6881}),r=new h(n);r.once("error",t),r.once("warning",t);let o=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return r.on("scrape",(e=>{if(o-=1,a[e.infoHash]=e,0===o){r.destroy();const e=Object.keys(a);1===e.length?t(null,a[e[0]]):t(null,a)}})),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map((e=>i.from(e,"hex"))):i.from(e.infoHash,"hex"),r.scrape({infoHash:e.infoHash}),r},t.exports=h}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/client/http-tracker":54,"./lib/client/udp-tracker":54,"./lib/client/websocket-tracker":32,"./lib/common":33,_process:189,buffer:55,debug:34,events:97,once:185,"queue-microtask":195,"run-parallel":220,"simple-peer":225}],31:[function(e,t,n){const i=e("events");t.exports=class extends i{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval((()=>{this.announce(this.client._defaultAnnounceOpts())}),e),this.interval.unref&&this.interval.unref())}}},{events:97}],32:[function(e,t,n){const i=e("debug")("bittorrent-tracker:websocket-tracker"),r=e("simple-peer"),o=e("randombytes"),s=e("simple-websocket"),a=e("../common"),c=e("./tracker"),l={};class p extends c{constructor(e,t,n){super(e,t),i("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",(()=>{this.announce(e)}));const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,5);this._generateOffers(n,(e=>{t.numwant=n,t.offers=e,this._send(t)}))}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",(()=>{this.scrape(e)}));const t={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map((e=>e.toString("binary"))):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary};this._send(t)}destroy(e=u){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const e in this.peers){const t=this.peers[e];clearTimeout(t.trackerTimeout),t.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,l[this.announceUrl]&&(l[this.announceUrl].consumers-=1),l[this.announceUrl].consumers>0)return e();let t,n=l[this.announceUrl];if(delete l[this.announceUrl],n.on("error",u),n.once("close",e),!this.expectingResponse)return i();function i(){t&&(clearTimeout(t),t=null),n.removeListener("data",i),n.destroy(),n=null}t=setTimeout(i,a.DESTROY_TIMEOUT),n.once("data",i)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=e=>{this._onSocketError(e)},this._onSocketDataBound=e=>{this._onSocketData(e)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=l[this.announceUrl],this.socket?(l[this.announceUrl].consumers+=1,this.socket.connected&&this._onSocketConnectBound()):(this.socket=l[this.announceUrl]=new s(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void i("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,a.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;i("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const r=e.interval||e["min interval"];r&&this.setInterval(1e3*r);const o=e["tracker id"];if(o&&(this._trackerId=o),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:a.binaryToHex(e.info_hash)});this.client.emit("update",t)}let s;if(e.offer&&e.peer_id&&(i("creating peer (from remote offer)"),s=this._createPeer(),s.id=a.binaryToHex(e.peer_id),s.once("signal",(t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)})),this.client.emit("peer",s),s.signal(e.offer)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);s=this.peers[t],s?(s.id=a.binaryToHex(e.peer_id),this.client.emit("peer",s),s.signal(e.answer),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete this.peers[t]):i(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach((t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:a.binaryToHex(t)});this.client.emit("scrape",n)})):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(3e5*Math.random())+Math.min(1e4*Math.pow(2,this.retries),36e5);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout((()=>{this.retries++,this._openSocket()}),e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),i("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);i("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,r=[];i("generating %s offers",e);for(let t=0;t{r.push({offer:t,offer_id:a.hexToBinary(e)}),c()})),t.trackerTimeout=setTimeout((()=>{i("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()}),5e4),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function c(){r.length===e&&(i("generated %s offers",e),t(r))}c()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new r(e);return n.once("error",i),n.once("connect",(function e(){n.removeListener("error",i),n.removeListener("connect",e)})),n;function i(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}}}function u(){}p.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,p._socketPool=l,t.exports=p},{"../common":33,"./tracker":31,debug:34,randombytes:197,"simple-peer":225,"simple-websocket":246}],33:[function(e,t,n){(function(t){(function(){n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=function(e){return"string"!=typeof e&&(e=String(e)),t.from(e,"binary").toString("hex")},n.hexToBinary=function(e){return"string"!=typeof e&&(e=String(e)),t.from(e,"hex").toString("binary")};const i=e("./common-node");Object.assign(n,i)}).call(this)}).call(this,e("buffer").Buffer)},{"./common-node":54,buffer:55}],34:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":35,_process:189,dup:12}],35:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:36}],36:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],37:[function(e,t,n){(function(e){(function(){ +const i=e("unordered-array-remove"),r=e("bencode"),s=e("bitfield").default,o=e("crypto"),a=e("debug")("bittorrent-protocol"),c=e("randombytes"),u=e("simple-sha1"),l=e("speedometer"),d=e("readable-stream"),f=e("rc4"),p=n.from("BitTorrent protocol"),h=n.from([0,0,0,0]),m=n.from([0,0,0,1,0]),b=n.from([0,0,0,1,1]),g=n.from([0,0,0,1,2]),v=n.from([0,0,0,1,3]),y=[0,0,0,0,0,0,0,0],_=[0,0,0,3,9,0,0],w=n.from([0,0,0,0,0,0,0,0]),x=n.from([0,0,1,2]),k=n.from([0,0,0,2]);function E(e,t){for(let n=e.length;n--;)e[n]^=t[n];return e}class S{constructor(e,t,n,i){this.piece=e,this.offset=t,this.length=n,this.callback=i}}class M extends d.Duplex{constructor(e=null,t=0,n=!1){super(),this._debugId=c(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=e,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new s(0,{grow:4e5}),this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=l(),this.downloadSpeed=l(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this._timeoutExpiresAt=null,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this._peEnabled=n,n?(this._dh=o.createDiffieHellman("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a36210000000000090563","hex",2),this._myPubKey=this._dh.generateKeys("hex")):this._myPubKey=null,this._peerPubKey=null,this._sharedSecret=null,this._peerCryptoProvide=[],this._cryptoHandshakeDone=!1,this._cryptoSyncPattern=null,this._waitMaxBytes=null,this._encryptionMethod=null,this._encryptGenerator=null,this._decryptGenerator=null,this._setGenerators=!1,this.once("finish",(()=>this._onFinish())),this.on("finish",this._onFinish),this._debug("type:",this.type),"tcpIncoming"===this.type&&this._peEnabled?this._determineHandshakeType():"tcpOutgoing"===this.type&&this._peEnabled&&0===t?this._parsePe2():this._parseHandshake(null)}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval),!1!==e&&(this._keepAliveInterval=setInterval((()=>{this.keepAlive()}),55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._timeoutMs=e,this._timeoutUnref=!!t,this._resetTimeout(!0)}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){const t=e.prototype.name;if(!t)throw new Error('Extension class requires a "name" property on the prototype');this._debug("use extension.name=%s",t);const n=this._nextExt,i=new e(this);function r(){}"function"!=typeof i.onHandshake&&(i.onHandshake=r),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=r),"function"!=typeof i.onMessage&&(i.onMessage=r),this.extendedMapping[n]=t,this._ext[t]=i,this[t]=i,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(h)}sendPe1(){if(this._peEnabled){const e=Math.floor(513*Math.random()),t=c(e);this._push(n.concat([n.from(this._myPubKey,"hex"),t]))}}sendPe2(){const e=Math.floor(513*Math.random()),t=c(e);this._push(n.concat([n.from(this._myPubKey,"hex"),t]))}sendPe3(e){this.setEncrypt(this._sharedSecret,e);const t=n.from(u.sync(n.from(this._utfToHex("req1")+this._sharedSecret,"hex")),"hex"),i=E(n.from(u.sync(n.from(this._utfToHex("req2")+e,"hex")),"hex"),n.from(u.sync(n.from(this._utfToHex("req3")+this._sharedSecret,"hex")),"hex")),r=c(2).readUInt16BE(0)%512,s=c(r);let o=n.alloc(14+r+2);w.copy(o),x.copy(o,8),o.writeInt16BE(r,12),s.copy(o,14),o.writeInt16BE(0,14+r),o=this._encryptHandshake(o),this._push(n.concat([t,i,o]))}sendPe4(e){this.setEncrypt(this._sharedSecret,e);const t=c(2).readUInt16BE(0)%512,i=c(t);let r=n.alloc(14+t);w.copy(r),k.copy(r,8),r.writeInt16BE(t,12),i.copy(r,14),r=this._encryptHandshake(r),this._push(r),this._cryptoHandshakeDone=!0,this._debug("completed crypto handshake")}handshake(e,t,i){let r,s;if("string"==typeof e?(e=e.toLowerCase(),r=n.from(e,"hex")):(r=e,e=r.toString("hex")),"string"==typeof t?s=n.from(t,"hex"):(s=t,t=s.toString("hex")),this._infoHash=r,20!==r.length||20!==s.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,i);const o=n.from(y);o[5]|=16,i&&i.dht&&(o[7]|=1),this._push(n.concat([p,o,r,s])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=Object.assign({},this.extendedHandshake);e.m={};for(const t in this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,r.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(m)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(b))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(g))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(v))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(e){this._debug("bitfield"),n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(e,t,n,i){return i||(i=()=>{}),this._finished?i(new Error("wire is closed")):this.peerChoking?i(new Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new S(e,t,n,i)),this._timeout||this._resetTimeout(!0),void this._message(6,[e,t,n],null))}piece(e,t,n){this._debug("piece index=%d offset=%d",e,t),this._message(7,[e,t],n),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(e){this._debug("port %d",e);const t=n.from(_);t.writeUInt16BE(e,5),this._push(t)}extended(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error(`Unrecognized extension: ${e}`);{const i=n.from([e]),s=n.isBuffer(t)?t:r.encode(t);this._message(20,[],n.concat([i,s]))}}setEncrypt(e,t){let i,r,s,o,a,c;switch(this.type){case"tcpIncoming":i=u.sync(n.from(this._utfToHex("keyB")+e+t,"hex")),r=u.sync(n.from(this._utfToHex("keyA")+e+t,"hex")),s=n.from(i,"hex"),o=[];for(const e of s.values())o.push(e);a=n.from(r,"hex"),c=[];for(const e of a.values())c.push(e);this._encryptGenerator=new f(o),this._decryptGenerator=new f(c);break;case"tcpOutgoing":i=u.sync(n.from(this._utfToHex("keyA")+e+t,"hex")),r=u.sync(n.from(this._utfToHex("keyB")+e+t,"hex")),s=n.from(i,"hex"),o=[];for(const e of s.values())o.push(e);a=n.from(r,"hex"),c=[];for(const e of a.values())c.push(e);this._encryptGenerator=new f(o),this._decryptGenerator=new f(c);break;default:return!1}for(let e=0;e<1024;e++)this._encryptGenerator.randomByte(),this._decryptGenerator.randomByte();return this._setGenerators=!0,!0}_read(){}_message(e,t,i){const r=i?i.length:0,s=n.allocUnsafe(5+4*t.length);s.writeUInt32BE(s.length+r-4,0),s[4]=e;for(let e=0;e{if(r===this._pull(this.peerRequests,e,t,n))return i?this._debug("error satisfying request index=%d offset=%d length=%d (%s)",e,t,n,i.message):void this.piece(e,t,s)},r=new S(e,t,n,i);this.peerRequests.push(r),this.emit("request",e,t,n,i)}_onPiece(e,t,n){this._debug("got piece index=%d offset=%d",e,t),this._callback(this._pull(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)}_onCancel(e,t,n){this._debug("got cancel index=%d offset=%d length=%d",e,t,n),this._pull(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)}_onPort(e){this._debug("got port %d",e),this.emit("port",e)}_onExtended(e,t){if(0===e){let e;try{e=r.decode(t)}catch(e){this._debug("ignoring invalid extended handshake: %s",e.message||e)}if(!e)return;if(this.peerExtendedHandshake=e,"object"==typeof e.m)for(const t in e.m)this.peerExtendedMapping[t]=Number(e.m[t].toString());for(const e in this._ext)this.peerExtendedMapping[e]&&this._ext[e].onExtendedHandshake(this.peerExtendedHandshake);this._debug("got extended handshake"),this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this._debug("got extended message ext=%s",e),this.emit("extended",e,t)}_onTimeout(){this._debug("request timed out"),this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")}_write(e,t,i){if(2===this._encryptionMethod&&this._cryptoHandshakeDone&&(e=this._decrypt(e)),this._bufferSize+=e.length,this._buffer.push(e),this._buffer.length>1&&(this._buffer=[n.concat(this._buffer,this._bufferSize)]),this._cryptoSyncPattern){const t=this._buffer[0].indexOf(this._cryptoSyncPattern);if(-1!==t)this._buffer[0]=this._buffer[0].slice(t+this._cryptoSyncPattern.length),this._bufferSize-=t+this._cryptoSyncPattern.length,this._cryptoSyncPattern=null;else if(this._bufferSize+e.length>this._waitMaxBytes+this._cryptoSyncPattern.length)return this._debug("Error: could not resynchronize"),void this.destroy()}for(;this._bufferSize>=this._parserSize&&!this._cryptoSyncPattern;)if(0===this._parserSize)this._parser(n.from([]));else{const e=this._buffer[0];this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[e.slice(this._parserSize)]:[],this._parser(e.slice(0,this._parserSize))}i(null)}_callback(e,t,n){e&&(this._resetTimeout(!this.peerChoking&&!this._finished),e.callback(t,n))}_resetTimeout(e){if(!e||!this._timeoutMs||!this.requests.length)return clearTimeout(this._timeout),this._timeout=null,void(this._timeoutExpiresAt=null);const t=Date.now()+this._timeoutMs;if(this._timeout){if(t-this._timeoutExpiresAt<.05*this._timeoutMs)return;clearTimeout(this._timeout)}this._timeoutExpiresAt=t,this._timeout=setTimeout((()=>this._onTimeout()),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref()}_parse(e,t){this._parserSize=e,this._parser=t}_parseUntil(e,t){this._cryptoSyncPattern=e,this._waitMaxBytes=t}_onMessageLength(e){const t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(e){switch(this._parse(4,this._onMessageLength),e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",e)}}_determineHandshakeType(){this._parse(1,(e=>{const t=e.readUInt8(0);19===t?this._parse(t+48,this._onHandshakeBuffer):this._parsePe1(e)}))}_parsePe1(e){this._parse(95,(t=>{this._onPe1(n.concat([e,t])),this._parsePe3()}))}_parsePe2(){this._parse(96,(e=>{for(this._onPe2(e);!this._setGenerators;);this._parsePe4()}))}_parsePe3(){const e=n.from(u.sync(n.from(this._utfToHex("req1")+this._sharedSecret,"hex")),"hex");this._parseUntil(e,512),this._parse(20,(e=>{for(this._onPe3(e);!this._setGenerators;);this._parsePe3Encrypted()}))}_parsePe3Encrypted(){this._parse(14,(e=>{const t=this._decryptHandshake(e.slice(0,8)),n=this._decryptHandshake(e.slice(8,12)),i=this._decryptHandshake(e.slice(12,14)).readUInt16BE(0);this._parse(i,(e=>{e=this._decryptHandshake(e),this._parse(2,(i=>{const r=this._decryptHandshake(i).readUInt16BE(0);this._parse(r,(i=>{i=this._decryptHandshake(i),this._onPe3Encrypted(t,n,e,i);const s=r?i.readUInt8(0):null,o=r?i.slice(1,20):null;19===s&&"BitTorrent protocol"===o.toString()?this._onHandshakeBuffer(i.slice(1)):this._parseHandshake()}))}))}))}))}_parsePe4(){const e=this._decryptHandshake(w);this._parseUntil(e,512),this._parse(6,(e=>{const t=this._decryptHandshake(e.slice(0,4)),n=this._decryptHandshake(e.slice(4,6)).readUInt16BE(0);this._parse(n,(e=>{this._decryptHandshake(e),this._onPe4(t),this._parseHandshake(null)}))}))}_parseHandshake(){this._parse(1,(e=>{const t=e.readUInt8(0);if(19!==t)return this._debug("Error: wire not speaking BitTorrent protocol (%s)",t.toString()),void this.end();this._parse(t+48,this._onHandshakeBuffer)}))}_onHandshakeBuffer(e){const t=e.slice(0,19);if("BitTorrent protocol"!==t.toString())return this._debug("Error: wire not speaking BitTorrent protocol (%s)",t.toString()),void this.end();e=e.slice(19),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),this._parse(4,this._onMessageLength)}_onFinish(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,(()=>{}));this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)}_debug(...e){e[0]=`[${this._debugId}] ${e[0]}`,a(...e)}_pull(e,t,n,r){for(let s=0;s{"%%"!==e&&(i++,"%c"===e&&(r=i))})),e.splice(r,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG);return e},n.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"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+)/)},n.storage=function(){try{return localStorage}catch(e){}}(),n.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`."))}})(),n.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"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:r}=t.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":28,_process:333}],28:[function(e,t,n){t.exports=function(t){function n(e){let t,r,s,o=null;function a(...e){if(!a.enabled)return;const i=a,r=Number(new Date),s=r-(t||r);i.diff=s,i.prev=t,i.curr=r,t=r,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,r)=>{if("%%"===t)return"%";o++;const s=n.formatters[r];if("function"==typeof s){const n=e[o];t=s.call(i,n),e.splice(o,1),o--}return t})),n.formatArgs.call(i,e);(i.log||n.log).apply(i,e)}return a.namespace=e,a.useColors=n.useColors(),a.color=n.selectColor(e),a.extend=i,a.destroy=n.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==n.namespaces&&(r=n.namespaces,s=n.enabled(e)),s),set:e=>{o=e}}),"function"==typeof n.init&&n.init(a),a}function i(e,t){const i=n(this.namespace+(void 0===t?":":t)+e);return i.log=this.log,i}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 i=("string"==typeof e?e:"").split(/[\s,]+/),r=i.length;for(t=0;t{n[e]=t[e]})),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*o;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*r;case"seconds":case"second":case"secs":case"sec":case"s":return n*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return u(e,t,o,"day");if(t>=s)return u(e,t,s,"hour");if(t>=r)return u(e,t,r,"minute");if(t>=i)return u(e,t,i,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=s)return Math.round(e/s)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=i)return Math.round(e/i)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],30:[function(e,t,n){"use strict";var i={};function r(e,t,n){n||(n=Error);var r=function(e){var n,i;function r(n,i,r){return e.call(this,function(e,n,i){return"string"==typeof t?t:t(e,n,i)}(n,i,r))||this}return i=e,(n=r).prototype=Object.create(i.prototype),n.prototype.constructor=n,n.__proto__=i,r}(n);r.prototype.name=n.name,r.prototype.code=e,i[e]=r}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}r("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(e,t,n){var i,r,o,a;if("string"==typeof t&&(r="not ",t.substr(!o||o<0?0:+o,r.length)===r)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(i," ").concat(s(t,"type"));else{var c=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(i," ").concat(s(t,"type"))}return a+=". Received type ".concat(typeof n)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=i},{}],31:[function(e,t,n){(function(n){(function(){"use strict";var i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=u;var r=e("./_stream_readable"),s=e("./_stream_writable");e("inherits")(u,r);for(var o=i(s.prototype),a=0;a0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),i)o.endEmitted?x(e,new w):A(e,o,t,!0);else if(o.ended)x(e,new y);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?A(e,o,t,!1):B(e,o)):A(e,o,t,!1)}else i||(o.reading=!1,B(e,o));return!o.ended&&(o.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=I?e=I:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function C(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(T,e))}function T(e){var t=e._readableState;u("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,U(e)}function B(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){u("readable nexttick read 0"),e.read(0)}function P(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),U(e),t.flowing&&!t.reading&&e.read(0)}function U(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function q(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function D(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(N,t,e))}function N(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function z(e,t){for(var n=0,i=e.length;n=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):C(this),null;if(0===(e=j(e,t))&&t.ended)return 0===t.length&&D(this),null;var i,r=t.needReadable;return u("need readable",r),(0===t.length||t.length-e0?q(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),n!==e&&t.ended&&D(this)),null!==i&&this.emit("data",i),i},S.prototype._read=function(e){x(this,new _("_read()"))},S.prototype.pipe=function(e,t){var i=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,u("pipe count=%d opts=%j",r.pipesCount,t);var o=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:b;function a(t,n){u("onunpipe"),t===i&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",h),e.removeListener("finish",m),e.removeListener("drain",l),e.removeListener("error",p),e.removeListener("unpipe",a),i.removeListener("end",c),i.removeListener("end",b),i.removeListener("data",f),d=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function c(){u("onend"),e.end()}r.endEmitted?n.nextTick(o):i.once("end",o),e.on("unpipe",a);var l=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,U(e))}}(i);e.on("drain",l);var d=!1;function f(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==z(r.pipes,e))&&!d&&(u("false write response, pause",r.awaitDrain),r.awaitDrain++),i.pause())}function p(t){u("onerror",t),b(),e.removeListener("error",p),0===s(e,"error")&&x(e,t)}function h(){e.removeListener("finish",m),b()}function m(){u("onfinish"),e.removeListener("close",h),b()}function b(){u("unpipe"),i.unpipe(e)}return i.on("data",f),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",p),e.once("close",h),e.once("finish",m),e.emit("pipe",i),r.flowing||(u("pipe resume"),i.resume()),e},S.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,u("on readable",r.length,r.reading),r.length?C(this):r.reading||n.nextTick(O,this))),i},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(e,t){var i=o.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(L,this),i},S.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(L,this),t},S.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(P,e,t))}(this,e)),e.paused=!1,this},S.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},S.prototype.wrap=function(e){var t=this,n=this._readableState,i=!1;for(var r in e.on("end",(function(){if(u("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(r){(u("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r)||(n.objectMode||r&&r.length)&&(t.push(r)||(i=!0,e.pause()))})),e)void 0===this[r]&&"function"==typeof e[r]&&(this[r]=function(t){return function(){return e[t].apply(e,arguments)}}(r));for(var s=0;s-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(S.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(S.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),S.prototype._write=function(e,t,n){n(new m("_write()"))},S.prototype._writev=null,S.prototype.end=function(e,t,i){var r=this._writableState;return"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,i){t.ending=!0,T(e,t),i&&(t.finished?n.nextTick(i):e.once("finish",i));t.ended=!0,e.writable=!1}(this,r,i),this},Object.defineProperty(S.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),S.prototype.destroy=d.destroy,S.prototype._undestroy=d.undestroy,S.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":30,"./_stream_duplex":31,"./internal/streams/destroy":38,"./internal/streams/state":42,"./internal/streams/stream":43,_process:333,buffer:114,inherits:245,"util-deprecate":485}],36:[function(e,t,n){(function(n){(function(){"use strict";var i;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e("./end-of-stream"),o=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),d=Symbol("handlePromise"),f=Symbol("stream");function p(e,t){return{value:e,done:t}}function h(e){var t=e[o];if(null!==t){var n=e[f].read();null!==n&&(e[l]=null,e[o]=null,e[a]=null,t(p(n,!1)))}}function m(e){n.nextTick(h,e)}var b=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((r(i={get stream(){return this[f]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[u])return Promise.resolve(p(void 0,!0));if(this[f].destroyed)return new Promise((function(t,i){n.nextTick((function(){e[c]?i(e[c]):t(p(void 0,!0))}))}));var i,r=this[l];if(r)i=new Promise(function(e,t){return function(n,i){e.then((function(){t[u]?n(p(void 0,!0)):t[d](n,i)}),i)}}(r,this));else{var s=this[f].read();if(null!==s)return Promise.resolve(p(s,!1));i=new Promise(this[d])}return this[l]=i,i}},Symbol.asyncIterator,(function(){return this})),r(i,"return",(function(){var e=this;return new Promise((function(t,n){e[f].destroy(null,(function(e){e?n(e):t(p(void 0,!0))}))}))})),i),b);t.exports=function(e){var t,n=Object.create(g,(r(t={},f,{value:e,writable:!0}),r(t,o,{value:null,writable:!0}),r(t,a,{value:null,writable:!0}),r(t,c,{value:null,writable:!0}),r(t,u,{value:e._readableState.endEmitted,writable:!0}),r(t,d,{value:function(e,t){var i=n[f].read();i?(n[l]=null,n[o]=null,n[a]=null,e(p(i,!1))):(n[o]=e,n[a]=t)},writable:!0}),t));return n[l]=null,s(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[l]=null,n[o]=null,n[a]=null,t(e)),void(n[c]=e)}var i=n[o];null!==i&&(n[l]=null,n[o]=null,n[a]=null,i(p(void 0,!0))),n[u]=!0})),e.on("readable",m.bind(null,n)),n}}).call(this)}).call(this,e("_process"))},{"./end-of-stream":39,_process:333}],37:[function(e,t,n){"use strict";function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){for(var n=0;n0?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 o.alloc(0);for(var t,n,i,r=o.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=r,i=a,o.prototype.copy.call(t,n,i),a+=s.data.length,s=s.next;return r}},{key:"consume",value:function(e,t){var n;return er.length?r.length:e;if(s===r.length?i+=r:i+=r.slice(0,e),0==(e-=s)){s===r.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=r.slice(s));break}++n}return this.length-=n,i}},{key:"_getBuffer",value:function(e){var t=o.allocUnsafe(e),n=this.head,i=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var r=n.data,s=e>r.length?r.length:e;if(r.copy(t,t.length-e,0,s),0==(e-=s)){s===r.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=r.slice(s));break}++i}return this.length-=i,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){i||(i=e),e&&o.forEach(u),s||(o.forEach(u),r(i))}))}));return t.reduce(l)}},{"../../../errors":30,"./end-of-stream":39}],42:[function(e,t,n){"use strict";var i=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,n,r){var s=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new i(r?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}}},{"../../../errors":30}],43:[function(e,t,n){t.exports=e("events").EventEmitter},{events:194}],44:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":31,"./lib/_stream_passthrough.js":32,"./lib/_stream_readable.js":33,"./lib/_stream_transform.js":34,"./lib/_stream_writable.js":35,"./lib/internal/streams/end-of-stream.js":39,"./lib/internal/streams/pipeline.js":41}],45:[function(e,t,n){(function(n,i){(function(){const r=e("debug")("bittorrent-tracker:client"),s=e("events"),o=e("once"),a=e("run-parallel"),c=e("simple-peer"),u=e("queue-microtask"),l=e("./lib/common"),d=e("./lib/client/http-tracker"),f=e("./lib/client/udp-tracker"),p=e("./lib/client/websocket-tracker");class h extends s{constructor(e={}){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this._peerIdBuffer=i.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._infoHashBuffer=i.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),r("new client %s",this.infoHash),this.destroyed=!1,this._port=e.port,this._getAnnounceOpts=e.getAnnounceOpts,this._rtcConfig=e.rtcConfig,this._userAgent=e.userAgent,this._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;let t="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;t=t.map((e=>("/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e))),t=Array.from(new Set(t));const s=!1!==this._wrtc&&(!!this._wrtc||c.WEBRTC_SUPPORT),o=e=>{u((()=>{this.emit("warning",e)}))};this._trackers=t.map((e=>{let t;try{t=l.parseUrl(e)}catch(t){return o(new Error(`Invalid tracker URL: ${e}`)),null}const n=t.port;if(n<0||n>65535)return o(new Error(`Invalid tracker port: ${e}`)),null;const i=t.protocol;return"http:"!==i&&"https:"!==i||"function"!=typeof d?"udp:"===i&&"function"==typeof f?new f(this,e):"ws:"!==i&&"wss:"!==i||!s||"ws:"===i&&"undefined"!=typeof window&&"https:"===window.location.protocol?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):new p(this,e):new d(this,e)})).filter(Boolean)}start(e){(e=this._defaultAnnounceOpts(e)).event="started",r("send `start` %o",e),this._announce(e),this._trackers.forEach((e=>{e.setInterval()}))}stop(e){(e=this._defaultAnnounceOpts(e)).event="stopped",r("send `stop` %o",e),this._announce(e)}complete(e){e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",r("send `complete` %o",e),this._announce(e)}update(e){(e=this._defaultAnnounceOpts(e)).event&&delete e.event,r("send `update` %o",e),this._announce(e)}_announce(e){this._trackers.forEach((t=>{t.announce(e)}))}scrape(e){r("send `scrape`"),e||(e={}),this._trackers.forEach((t=>{t.scrape(e)}))}setInterval(e){r("setInterval %d",e),this._trackers.forEach((t=>{t.setInterval(e)}))}destroy(e){if(this.destroyed)return;this.destroyed=!0,r("destroy");const t=this._trackers.map((e=>t=>{e.destroy(t)}));a(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=l.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}h.scrape=(e,t)=>{if(t=o(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:i.from("01234567890123456789"),port:6881}),r=new h(n);r.once("error",t),r.once("warning",t);let s=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return r.on("scrape",(e=>{if(s-=1,a[e.infoHash]=e,0===s){r.destroy();const e=Object.keys(a);1===e.length?t(null,a[e[0]]):t(null,a)}})),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map((e=>i.from(e,"hex"))):i.from(e.infoHash,"hex"),r.scrape({infoHash:e.infoHash}),r},t.exports=h}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/client/http-tracker":71,"./lib/client/udp-tracker":71,"./lib/client/websocket-tracker":47,"./lib/common":48,_process:333,buffer:114,debug:49,events:194,once:318,"queue-microtask":346,"run-parallel":374,"simple-peer":388}],46:[function(e,t,n){const i=e("events");t.exports=class extends i{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval((()=>{this.announce(this.client._defaultAnnounceOpts())}),e),this.interval.unref&&this.interval.unref())}}},{events:194}],47:[function(e,t,n){const i=e("debug")("bittorrent-tracker:websocket-tracker"),r=e("simple-peer"),s=e("randombytes"),o=e("simple-websocket"),a=e("../common"),c=e("./tracker"),u={};class l extends c{constructor(e,t){super(e,t),i("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",(()=>{this.announce(e)}));const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,5);this._generateOffers(n,(e=>{t.numwant=n,t.offers=e,this._send(t)}))}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",(()=>{this.scrape(e)}));const t={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map((e=>e.toString("binary"))):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary};this._send(t)}destroy(e=d){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const e in this.peers){const t=this.peers[e];clearTimeout(t.trackerTimeout),t.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,u[this.announceUrl]&&(u[this.announceUrl].consumers-=1),u[this.announceUrl].consumers>0)return e();let t,n=u[this.announceUrl];if(delete u[this.announceUrl],n.on("error",d),n.once("close",e),!this.expectingResponse)return i();function i(){t&&(clearTimeout(t),t=null),n.removeListener("data",i),n.destroy(),n=null}t=setTimeout(i,a.DESTROY_TIMEOUT),n.once("data",i)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=e=>{this._onSocketError(e)},this._onSocketDataBound=e=>{this._onSocketData(e)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=u[this.announceUrl],this.socket?(u[this.announceUrl].consumers+=1,this.socket.connected&&this._onSocketConnectBound()):(this.socket=u[this.announceUrl]=new o(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void i("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,a.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;i("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const r=e.interval||e["min interval"];r&&this.setInterval(1e3*r);const s=e["tracker id"];if(s&&(this._trackerId=s),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:a.binaryToHex(e.info_hash)});this.client.emit("update",t)}let o;if(e.offer&&e.peer_id&&(i("creating peer (from remote offer)"),o=this._createPeer(),o.id=a.binaryToHex(e.peer_id),o.once("signal",(t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)})),this.client.emit("peer",o),o.signal(e.offer)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);o=this.peers[t],o?(o.id=a.binaryToHex(e.peer_id),this.client.emit("peer",o),o.signal(e.answer),clearTimeout(o.trackerTimeout),o.trackerTimeout=null,delete this.peers[t]):i(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach((t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:a.binaryToHex(t)});this.client.emit("scrape",n)})):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(3e5*Math.random())+Math.min(1e4*Math.pow(2,this.retries),36e5);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout((()=>{this.retries++,this._openSocket()}),e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),i("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);i("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,r=[];i("generating %s offers",e);for(let t=0;t{r.push({offer:t,offer_id:a.hexToBinary(e)}),c()})),t.trackerTimeout=setTimeout((()=>{i("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()}),5e4),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function c(){r.length===e&&(i("generated %s offers",e),t(r))}c()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new r(e);return n.once("error",i),n.once("connect",(function e(){n.removeListener("error",i),n.removeListener("connect",e)})),n;function i(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}}}function d(){}l.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,l._socketPool=u,t.exports=l},{"../common":48,"./tracker":46,debug:49,randombytes:348,"simple-peer":388,"simple-websocket":409}],48:[function(e,t,n){(function(t){(function(){n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=e=>("string"!=typeof e&&(e=String(e)),t.from(e,"binary").toString("hex")),n.hexToBinary=e=>("string"!=typeof e&&(e=String(e)),t.from(e,"hex").toString("binary")),n.parseUrl=e=>{const t=new URL(e.replace(/^udp:/,"http:"));return e.match(/^udp:/)&&Object.defineProperties(t,{href:{value:t.href.replace(/^http/,"udp")},protocol:{value:t.protocol.replace(/^http/,"udp")},origin:{value:t.origin.replace(/^http/,"udp")}}),t};const i=e("./common-node");Object.assign(n,i)}).call(this)}).call(this,e("buffer").Buffer)},{"./common-node":71,buffer:114}],49:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":50,_process:333,dup:27}],50:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:51}],51:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],52:[function(e,t,n){(function(e){(function(){ /*! blob-to-buffer. MIT License. Feross Aboukhadijeh */ -t.exports=function(t,n){if("undefined"==typeof Blob||!(t instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof n)throw new Error("second argument must be a function");const i=new FileReader;i.addEventListener("loadend",(function t(r){i.removeEventListener("loadend",t,!1),r.error?n(r.error):n(null,e.from(i.result))}),!1),i.readAsArrayBuffer(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55}],38:[function(e,t,n){(function(n){(function(){const{Transform:i}=e("readable-stream");t.exports=class extends i{constructor(e,t={}){super(t),"object"==typeof e&&(e=(t=e).size),this.size=e||512;const{nopad:n,zeroPadding:i=!0}=t;this._zeroPadding=!n&&!!i,this._buffered=[],this._bufferedBytes=0}_transform(e,t,i){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){this._bufferedBytes-=this.size;const e=[];let t=0;for(;t=this.size;){this._bufferedBytes-=this.size;const e=[];let t=0;for(;t=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void i(!1,"Invalid character in "+e)}function c(e,t,n){var i=a(e,n);return n-1>=t&&(i|=a(e,n-1)<<4),i}function u(e,t,n,r){for(var s=0,o=0,a=Math.min(e.length,n),c=t;c=49?u-49+10:u>=17?u-17+10:u,i(u>=0&&o0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r=0;r-=3)o=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(r=0,s=0;r>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i=t;i-=2)r=c(e,t,i)<=18?(s-=18,o+=1,this.words[o]|=r>>>26):s+=8;else for(i=(e.length-t)%2==0?t+1:t;i=18?(s-=18,o+=1,this.words[o]|=r>>>26):s+=8;this._strip()},s.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var i=0,r=1;r<=67108863;r*=t)i++;i--,r=r/t|0;for(var s=e.length-n,o=s%i,a=Math.min(s,s-o)+n,c=0,l=n;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=d}catch(e){s.prototype.inspect=d}else s.prototype.inspect=d;function d(){return(this.red?""}var f=["","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"],p=[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],h=[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];s.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var r=0,s=0,o=0;o>>24-r&16777215)||o!==this.length-1?f[6-c.length]+c+n:c+n,(r+=2)>=26&&(r-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=p[e],l=h[e];n="";var d=this.clone();for(d.negative=0;!d.isZero();){var m=d.modrn(l).toString(e);n=(d=d.idivn(l)).isZero()?m+n:f[u-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function m(e,t,n){n.negative=t.negative^e.negative;var i=e.length+t.length|0;n.length=i,i=i-1|0;var r=0|e.words[0],s=0|t.words[0],o=r*s,a=67108863&o,c=o/67108864|0;n.words[0]=a;for(var u=1;u>>26,d=67108863&c,f=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=f;p++){var h=u-p|0;l+=(o=(r=0|e.words[h])*(s=0|t.words[p])+d)/67108864|0,d=67108863&o}n.words[u]=0|d,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n._strip()}s.prototype.toArrayLike=function(e,t,n){this._strip();var r=this.byteLength(),s=n||Math.max(1,r);i(r<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0");var o=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,s);return this["_toArrayLike"+("le"===t?"LE":"BE")](o,r),o},s.prototype._toArrayLikeLE=function(e,t){for(var n=0,i=0,r=0,s=0;r>8&255),n>16&255),6===s?(n>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(n=0&&(e[n--]=o>>8&255),n>=0&&(e[n--]=o>>16&255),6===s?(n>=0&&(e[n--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(n>=0)for(e[n--]=i;n>=0;)e[n--]=0},Math.clz32?s.prototype._countBits=function(e){return 32-Math.clz32(e)}:s.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-n),this._strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var n=e/26|0,r=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(n=this,i=e):(n=e,i=this);for(var r=0,s=0;s>>26;for(;0!==r&&s>>26;if(this.length=n.length,0!==r)this.words[this.length]=r,this.length++;else if(n!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,i,r=this.cmp(e);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(n=this,i=e):(n=e,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,p=0|o[1],h=8191&p,m=p>>>13,b=0|o[2],g=8191&b,v=b>>>13,y=0|o[3],_=8191&y,w=y>>>13,x=0|o[4],k=8191&x,E=x>>>13,S=0|o[5],M=8191&S,A=S>>>13,I=0|o[6],j=8191&I,C=I>>>13,T=0|o[7],B=8191&T,R=T>>>13,L=0|o[8],O=8191&L,P=L>>>13,U=0|o[9],q=8191&U,D=U>>>13,N=0|a[0],z=8191&N,H=N>>>13,F=0|a[1],W=8191&F,V=F>>>13,K=0|a[2],$=8191&K,G=K>>>13,X=0|a[3],Y=8191&X,Z=X>>>13,J=0|a[4],Q=8191&J,ee=J>>>13,te=0|a[5],ne=8191&te,ie=te>>>13,re=0|a[6],se=8191&re,oe=re>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,le=0|a[8],de=8191&le,fe=le>>>13,pe=0|a[9],he=8191&pe,me=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(i=Math.imul(d,z))|0)+((8191&(r=(r=Math.imul(d,H))+Math.imul(f,z)|0))<<13)|0;u=((s=Math.imul(f,H))+(r>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(h,z),r=(r=Math.imul(h,H))+Math.imul(m,z)|0,s=Math.imul(m,H);var ge=(u+(i=i+Math.imul(d,W)|0)|0)+((8191&(r=(r=r+Math.imul(d,V)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,V)|0)+(r>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,z),r=(r=Math.imul(g,H))+Math.imul(v,z)|0,s=Math.imul(v,H),i=i+Math.imul(h,W)|0,r=(r=r+Math.imul(h,V)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,V)|0;var ve=(u+(i=i+Math.imul(d,$)|0)|0)+((8191&(r=(r=r+Math.imul(d,G)|0)+Math.imul(f,$)|0))<<13)|0;u=((s=s+Math.imul(f,G)|0)+(r>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(_,z),r=(r=Math.imul(_,H))+Math.imul(w,z)|0,s=Math.imul(w,H),i=i+Math.imul(g,W)|0,r=(r=r+Math.imul(g,V)|0)+Math.imul(v,W)|0,s=s+Math.imul(v,V)|0,i=i+Math.imul(h,$)|0,r=(r=r+Math.imul(h,G)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,G)|0;var ye=(u+(i=i+Math.imul(d,Y)|0)|0)+((8191&(r=(r=r+Math.imul(d,Z)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,Z)|0)+(r>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(k,z),r=(r=Math.imul(k,H))+Math.imul(E,z)|0,s=Math.imul(E,H),i=i+Math.imul(_,W)|0,r=(r=r+Math.imul(_,V)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,V)|0,i=i+Math.imul(g,$)|0,r=(r=r+Math.imul(g,G)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,G)|0,i=i+Math.imul(h,Y)|0,r=(r=r+Math.imul(h,Z)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,Z)|0;var _e=(u+(i=i+Math.imul(d,Q)|0)|0)+((8191&(r=(r=r+Math.imul(d,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((s=s+Math.imul(f,ee)|0)+(r>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(M,z),r=(r=Math.imul(M,H))+Math.imul(A,z)|0,s=Math.imul(A,H),i=i+Math.imul(k,W)|0,r=(r=r+Math.imul(k,V)|0)+Math.imul(E,W)|0,s=s+Math.imul(E,V)|0,i=i+Math.imul(_,$)|0,r=(r=r+Math.imul(_,G)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,G)|0,i=i+Math.imul(g,Y)|0,r=(r=r+Math.imul(g,Z)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,Z)|0,i=i+Math.imul(h,Q)|0,r=(r=r+Math.imul(h,ee)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,ee)|0;var we=(u+(i=i+Math.imul(d,ne)|0)|0)+((8191&(r=(r=r+Math.imul(d,ie)|0)+Math.imul(f,ne)|0))<<13)|0;u=((s=s+Math.imul(f,ie)|0)+(r>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(j,z),r=(r=Math.imul(j,H))+Math.imul(C,z)|0,s=Math.imul(C,H),i=i+Math.imul(M,W)|0,r=(r=r+Math.imul(M,V)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,V)|0,i=i+Math.imul(k,$)|0,r=(r=r+Math.imul(k,G)|0)+Math.imul(E,$)|0,s=s+Math.imul(E,G)|0,i=i+Math.imul(_,Y)|0,r=(r=r+Math.imul(_,Z)|0)+Math.imul(w,Y)|0,s=s+Math.imul(w,Z)|0,i=i+Math.imul(g,Q)|0,r=(r=r+Math.imul(g,ee)|0)+Math.imul(v,Q)|0,s=s+Math.imul(v,ee)|0,i=i+Math.imul(h,ne)|0,r=(r=r+Math.imul(h,ie)|0)+Math.imul(m,ne)|0,s=s+Math.imul(m,ie)|0;var xe=(u+(i=i+Math.imul(d,se)|0)|0)+((8191&(r=(r=r+Math.imul(d,oe)|0)+Math.imul(f,se)|0))<<13)|0;u=((s=s+Math.imul(f,oe)|0)+(r>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(B,z),r=(r=Math.imul(B,H))+Math.imul(R,z)|0,s=Math.imul(R,H),i=i+Math.imul(j,W)|0,r=(r=r+Math.imul(j,V)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,V)|0,i=i+Math.imul(M,$)|0,r=(r=r+Math.imul(M,G)|0)+Math.imul(A,$)|0,s=s+Math.imul(A,G)|0,i=i+Math.imul(k,Y)|0,r=(r=r+Math.imul(k,Z)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,Z)|0,i=i+Math.imul(_,Q)|0,r=(r=r+Math.imul(_,ee)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,ee)|0,i=i+Math.imul(g,ne)|0,r=(r=r+Math.imul(g,ie)|0)+Math.imul(v,ne)|0,s=s+Math.imul(v,ie)|0,i=i+Math.imul(h,se)|0,r=(r=r+Math.imul(h,oe)|0)+Math.imul(m,se)|0,s=s+Math.imul(m,oe)|0;var ke=(u+(i=i+Math.imul(d,ce)|0)|0)+((8191&(r=(r=r+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((s=s+Math.imul(f,ue)|0)+(r>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(O,z),r=(r=Math.imul(O,H))+Math.imul(P,z)|0,s=Math.imul(P,H),i=i+Math.imul(B,W)|0,r=(r=r+Math.imul(B,V)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,V)|0,i=i+Math.imul(j,$)|0,r=(r=r+Math.imul(j,G)|0)+Math.imul(C,$)|0,s=s+Math.imul(C,G)|0,i=i+Math.imul(M,Y)|0,r=(r=r+Math.imul(M,Z)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(k,Q)|0,r=(r=r+Math.imul(k,ee)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,ee)|0,i=i+Math.imul(_,ne)|0,r=(r=r+Math.imul(_,ie)|0)+Math.imul(w,ne)|0,s=s+Math.imul(w,ie)|0,i=i+Math.imul(g,se)|0,r=(r=r+Math.imul(g,oe)|0)+Math.imul(v,se)|0,s=s+Math.imul(v,oe)|0,i=i+Math.imul(h,ce)|0,r=(r=r+Math.imul(h,ue)|0)+Math.imul(m,ce)|0,s=s+Math.imul(m,ue)|0;var Ee=(u+(i=i+Math.imul(d,de)|0)|0)+((8191&(r=(r=r+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((s=s+Math.imul(f,fe)|0)+(r>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(q,z),r=(r=Math.imul(q,H))+Math.imul(D,z)|0,s=Math.imul(D,H),i=i+Math.imul(O,W)|0,r=(r=r+Math.imul(O,V)|0)+Math.imul(P,W)|0,s=s+Math.imul(P,V)|0,i=i+Math.imul(B,$)|0,r=(r=r+Math.imul(B,G)|0)+Math.imul(R,$)|0,s=s+Math.imul(R,G)|0,i=i+Math.imul(j,Y)|0,r=(r=r+Math.imul(j,Z)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(M,Q)|0,r=(r=r+Math.imul(M,ee)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,ee)|0,i=i+Math.imul(k,ne)|0,r=(r=r+Math.imul(k,ie)|0)+Math.imul(E,ne)|0,s=s+Math.imul(E,ie)|0,i=i+Math.imul(_,se)|0,r=(r=r+Math.imul(_,oe)|0)+Math.imul(w,se)|0,s=s+Math.imul(w,oe)|0,i=i+Math.imul(g,ce)|0,r=(r=r+Math.imul(g,ue)|0)+Math.imul(v,ce)|0,s=s+Math.imul(v,ue)|0,i=i+Math.imul(h,de)|0,r=(r=r+Math.imul(h,fe)|0)+Math.imul(m,de)|0,s=s+Math.imul(m,fe)|0;var Se=(u+(i=i+Math.imul(d,he)|0)|0)+((8191&(r=(r=r+Math.imul(d,me)|0)+Math.imul(f,he)|0))<<13)|0;u=((s=s+Math.imul(f,me)|0)+(r>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(q,W),r=(r=Math.imul(q,V))+Math.imul(D,W)|0,s=Math.imul(D,V),i=i+Math.imul(O,$)|0,r=(r=r+Math.imul(O,G)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,G)|0,i=i+Math.imul(B,Y)|0,r=(r=r+Math.imul(B,Z)|0)+Math.imul(R,Y)|0,s=s+Math.imul(R,Z)|0,i=i+Math.imul(j,Q)|0,r=(r=r+Math.imul(j,ee)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,ee)|0,i=i+Math.imul(M,ne)|0,r=(r=r+Math.imul(M,ie)|0)+Math.imul(A,ne)|0,s=s+Math.imul(A,ie)|0,i=i+Math.imul(k,se)|0,r=(r=r+Math.imul(k,oe)|0)+Math.imul(E,se)|0,s=s+Math.imul(E,oe)|0,i=i+Math.imul(_,ce)|0,r=(r=r+Math.imul(_,ue)|0)+Math.imul(w,ce)|0,s=s+Math.imul(w,ue)|0,i=i+Math.imul(g,de)|0,r=(r=r+Math.imul(g,fe)|0)+Math.imul(v,de)|0,s=s+Math.imul(v,fe)|0;var Me=(u+(i=i+Math.imul(h,he)|0)|0)+((8191&(r=(r=r+Math.imul(h,me)|0)+Math.imul(m,he)|0))<<13)|0;u=((s=s+Math.imul(m,me)|0)+(r>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(q,$),r=(r=Math.imul(q,G))+Math.imul(D,$)|0,s=Math.imul(D,G),i=i+Math.imul(O,Y)|0,r=(r=r+Math.imul(O,Z)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,Z)|0,i=i+Math.imul(B,Q)|0,r=(r=r+Math.imul(B,ee)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,ee)|0,i=i+Math.imul(j,ne)|0,r=(r=r+Math.imul(j,ie)|0)+Math.imul(C,ne)|0,s=s+Math.imul(C,ie)|0,i=i+Math.imul(M,se)|0,r=(r=r+Math.imul(M,oe)|0)+Math.imul(A,se)|0,s=s+Math.imul(A,oe)|0,i=i+Math.imul(k,ce)|0,r=(r=r+Math.imul(k,ue)|0)+Math.imul(E,ce)|0,s=s+Math.imul(E,ue)|0,i=i+Math.imul(_,de)|0,r=(r=r+Math.imul(_,fe)|0)+Math.imul(w,de)|0,s=s+Math.imul(w,fe)|0;var Ae=(u+(i=i+Math.imul(g,he)|0)|0)+((8191&(r=(r=r+Math.imul(g,me)|0)+Math.imul(v,he)|0))<<13)|0;u=((s=s+Math.imul(v,me)|0)+(r>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(q,Y),r=(r=Math.imul(q,Z))+Math.imul(D,Y)|0,s=Math.imul(D,Z),i=i+Math.imul(O,Q)|0,r=(r=r+Math.imul(O,ee)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,ee)|0,i=i+Math.imul(B,ne)|0,r=(r=r+Math.imul(B,ie)|0)+Math.imul(R,ne)|0,s=s+Math.imul(R,ie)|0,i=i+Math.imul(j,se)|0,r=(r=r+Math.imul(j,oe)|0)+Math.imul(C,se)|0,s=s+Math.imul(C,oe)|0,i=i+Math.imul(M,ce)|0,r=(r=r+Math.imul(M,ue)|0)+Math.imul(A,ce)|0,s=s+Math.imul(A,ue)|0,i=i+Math.imul(k,de)|0,r=(r=r+Math.imul(k,fe)|0)+Math.imul(E,de)|0,s=s+Math.imul(E,fe)|0;var Ie=(u+(i=i+Math.imul(_,he)|0)|0)+((8191&(r=(r=r+Math.imul(_,me)|0)+Math.imul(w,he)|0))<<13)|0;u=((s=s+Math.imul(w,me)|0)+(r>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(q,Q),r=(r=Math.imul(q,ee))+Math.imul(D,Q)|0,s=Math.imul(D,ee),i=i+Math.imul(O,ne)|0,r=(r=r+Math.imul(O,ie)|0)+Math.imul(P,ne)|0,s=s+Math.imul(P,ie)|0,i=i+Math.imul(B,se)|0,r=(r=r+Math.imul(B,oe)|0)+Math.imul(R,se)|0,s=s+Math.imul(R,oe)|0,i=i+Math.imul(j,ce)|0,r=(r=r+Math.imul(j,ue)|0)+Math.imul(C,ce)|0,s=s+Math.imul(C,ue)|0,i=i+Math.imul(M,de)|0,r=(r=r+Math.imul(M,fe)|0)+Math.imul(A,de)|0,s=s+Math.imul(A,fe)|0;var je=(u+(i=i+Math.imul(k,he)|0)|0)+((8191&(r=(r=r+Math.imul(k,me)|0)+Math.imul(E,he)|0))<<13)|0;u=((s=s+Math.imul(E,me)|0)+(r>>>13)|0)+(je>>>26)|0,je&=67108863,i=Math.imul(q,ne),r=(r=Math.imul(q,ie))+Math.imul(D,ne)|0,s=Math.imul(D,ie),i=i+Math.imul(O,se)|0,r=(r=r+Math.imul(O,oe)|0)+Math.imul(P,se)|0,s=s+Math.imul(P,oe)|0,i=i+Math.imul(B,ce)|0,r=(r=r+Math.imul(B,ue)|0)+Math.imul(R,ce)|0,s=s+Math.imul(R,ue)|0,i=i+Math.imul(j,de)|0,r=(r=r+Math.imul(j,fe)|0)+Math.imul(C,de)|0,s=s+Math.imul(C,fe)|0;var Ce=(u+(i=i+Math.imul(M,he)|0)|0)+((8191&(r=(r=r+Math.imul(M,me)|0)+Math.imul(A,he)|0))<<13)|0;u=((s=s+Math.imul(A,me)|0)+(r>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(q,se),r=(r=Math.imul(q,oe))+Math.imul(D,se)|0,s=Math.imul(D,oe),i=i+Math.imul(O,ce)|0,r=(r=r+Math.imul(O,ue)|0)+Math.imul(P,ce)|0,s=s+Math.imul(P,ue)|0,i=i+Math.imul(B,de)|0,r=(r=r+Math.imul(B,fe)|0)+Math.imul(R,de)|0,s=s+Math.imul(R,fe)|0;var Te=(u+(i=i+Math.imul(j,he)|0)|0)+((8191&(r=(r=r+Math.imul(j,me)|0)+Math.imul(C,he)|0))<<13)|0;u=((s=s+Math.imul(C,me)|0)+(r>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(q,ce),r=(r=Math.imul(q,ue))+Math.imul(D,ce)|0,s=Math.imul(D,ue),i=i+Math.imul(O,de)|0,r=(r=r+Math.imul(O,fe)|0)+Math.imul(P,de)|0,s=s+Math.imul(P,fe)|0;var Be=(u+(i=i+Math.imul(B,he)|0)|0)+((8191&(r=(r=r+Math.imul(B,me)|0)+Math.imul(R,he)|0))<<13)|0;u=((s=s+Math.imul(R,me)|0)+(r>>>13)|0)+(Be>>>26)|0,Be&=67108863,i=Math.imul(q,de),r=(r=Math.imul(q,fe))+Math.imul(D,de)|0,s=Math.imul(D,fe);var Re=(u+(i=i+Math.imul(O,he)|0)|0)+((8191&(r=(r=r+Math.imul(O,me)|0)+Math.imul(P,he)|0))<<13)|0;u=((s=s+Math.imul(P,me)|0)+(r>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Le=(u+(i=Math.imul(q,he))|0)+((8191&(r=(r=Math.imul(q,me))+Math.imul(D,he)|0))<<13)|0;return u=((s=Math.imul(D,me))+(r>>>13)|0)+(Le>>>26)|0,Le&=67108863,c[0]=be,c[1]=ge,c[2]=ve,c[3]=ye,c[4]=_e,c[5]=we,c[6]=xe,c[7]=ke,c[8]=Ee,c[9]=Se,c[10]=Me,c[11]=Ae,c[12]=Ie,c[13]=je,c[14]=Ce,c[15]=Te,c[16]=Be,c[17]=Re,c[18]=Le,0!==u&&(c[19]=u,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var i=0,r=0,s=0;s>>26)|0)>>>26,o&=67108863}n.words[s]=a,i=o,o=r}return 0!==i?n.words[s]=i:n.length--,n._strip()}function v(e,t,n){return g(e,t,n)}function y(e,t){this.x=e,this.y=t}Math.imul||(b=m),s.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?b(this,e,t):n<63?m(this,e,t):n<1024?g(this,e,t):v(this,e,t)},y.prototype.makeRBT=function(e){for(var t=new Array(e),n=s.prototype._countBits(e)-1,i=0;i>=1;return i},y.prototype.permute=function(e,t,n,i,r,s){for(var o=0;o>>=1)r++;return 1<>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,n+=s/67108864|0,n+=o>>>26,this.words[r]=67108863&o}return 0!==n&&(this.words[r]=n,this.length++),t?this.ineg():this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>r&1}return t}(e);if(0===t.length)return new s(1);for(var n=this,i=0;i=0);var t,n=e%26,r=(e-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(t=0;t>>26-n}o&&(this.words[t]=o,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0),r=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=r);u--){var d=0|this.words[u];this.words[u]=l<<26-s|d>>>s,l=d&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(e,t,n){return i(0===this.negative),this.iushrn(e,t,n)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,r=1<=0);var t=e%26,n=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[r+n]=67108863&s}for(;r>26,this.words[r+n]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,r=0;r>26,this.words[r]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(e,t){var n=(this.length,e.length),i=this.clone(),r=e,o=0|r.words[r.length-1];0!==(n=26-this._countBits(o))&&(r=r.ushln(n),i.iushln(n),o=0|r.words[r.length-1]);var a,c=i.length-r.length;if("mod"!==t){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;d--){var f=67108864*(0|i.words[r.length+d])+(0|i.words[r.length+d-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(r,f,d);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(r,1,d),i.isZero()||(i.negative^=1);a&&(a.words[d]=f)}return a&&a._strip(),i._strip(),"div"!==t&&0!==n&&i.iushrn(n),{div:a||null,mod:i}},s.prototype.divmod=function(e,t,n){return i(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(r=a.div.neg()),"div"!==t&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(e)),{div:r,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(r=a.div.neg()),{div:r,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modrn(e.words[0]))}:this._wordDiv(e,t);var r,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),r=e.andln(1),s=n.cmp(i);return s<0||1===r&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modrn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var n=(1<<26)%e,r=0,s=this.length-1;s>=0;s--)r=(n*r+(0|this.words[s]))%e;return t?-r:r},s.prototype.modn=function(e){return this.modrn(e)},s.prototype.idivn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var n=0,r=this.length-1;r>=0;r--){var s=(0|this.words[r])+67108864*n;this.words[r]=s/e|0,n=s%e}return this._strip(),t?this.ineg():this},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;0==(t.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(r.isOdd()||o.isOdd())&&(r.iadd(l),o.isub(d)),r.iushrn(1),o.iushrn(1);for(var h=0,m=1;0==(n.words[0]&m)&&h<26;++h,m<<=1);if(h>0)for(n.iushrn(h);h-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(d)),a.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),r.isub(a),o.isub(c)):(n.isub(t),a.isub(r),c.isub(o))}return{a:a,b:c,gcd:n.iushln(u)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,o=new s(1),a=new s(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var d=0,f=1;0==(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(a)):(n.isub(t),a.isub(o))}return(r=0===t.cmpn(1)?o:a).cmpn(0)<0&&r.iadd(e),r},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var i=0;t.isEven()&&n.isEven();i++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var r=t.cmp(n);if(r<0){var s=t;t=n,n=s}else if(0===r||0===n.cmpn(1))break;t.isub(n)}return n.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,n=(e-t)/26,r=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)t=1;else{n&&(e=-e),i(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:re.length)return 1;if(this.length=0;n--){var i=0|this.words[n],r=0|e.words[n];if(i!==r){ir&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new M(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var _={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function x(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){M.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},r(x,w),x.prototype.split=function(e,t){for(var n=4194303,i=Math.min(e.length,9),r=0;r>>22,s=o}s>>>=22,e.words[r-10]=s,0===s&&e.length>10?e.length-=10:e.length-=9},x.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=r,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(_[e])return _[e];var t;if("k256"===e)t=new x;else if("p224"===e)t=new k;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return _[e]=t,t},M.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},M.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},M.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},M.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},M.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},M.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},M.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},M.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},M.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},M.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},M.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},M.prototype.isqr=function(e){return this.imul(e,e.clone())},M.prototype.sqr=function(e){return this.mul(e,e)},M.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var n=this.m.add(new s(1)).iushrn(2);return this.pow(e,n)}for(var r=this.m.subn(1),o=0;!r.isZero()&&0===r.andln(1);)o++,r.iushrn(1);i(!r.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,r),f=this.pow(e,r.addn(1).iushrn(1)),p=this.pow(e,r),h=o;0!==p.cmp(a);){for(var m=p,b=0;0!==m.cmp(a);b++)m=m.redSqr();i(b=0;i--){for(var u=t.words[i],l=c-1;l>=0;l--){var d=u>>l&1;r!==n[0]&&(r=this.sqr(r)),0!==d||0!==o?(o<<=1,o|=d,(4===++a||0===i&&0===l)&&(r=this.mul(r,n[o]),a=0,o=0)):a=0}c=26}return r},M.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},M.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new A(e)},r(A,M),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),s=r;return r.cmp(this.m)>=0?s=r.isub(this.m):r.cmpn(0)<0&&(s=r.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var n=e.mul(t),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),o=r;return r.cmp(this.m)>=0?o=r.isub(this.m):r.cmpn(0)<0&&(o=r.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:71}],70:[function(e,t,n){var i;function r(e){this.rand=e}if(t.exports=function(e){return i||(i=new r(null)),i.generate(e)},t.exports.Rand=r,r.prototype.generate=function(e){return this._rand(e)},r.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n>>24]^l[h>>>16&255]^d[m>>>8&255]^f[255&b]^t[g++],o=u[h>>>24]^l[m>>>16&255]^d[b>>>8&255]^f[255&p]^t[g++],a=u[m>>>24]^l[b>>>16&255]^d[p>>>8&255]^f[255&h]^t[g++],c=u[b>>>24]^l[p>>>16&255]^d[h>>>8&255]^f[255&m]^t[g++],p=s,h=o,m=a,b=c;return s=(i[p>>>24]<<24|i[h>>>16&255]<<16|i[m>>>8&255]<<8|i[255&b])^t[g++],o=(i[h>>>24]<<24|i[m>>>16&255]<<16|i[b>>>8&255]<<8|i[255&p])^t[g++],a=(i[m>>>24]<<24|i[b>>>16&255]<<16|i[p>>>8&255]<<8|i[255&h])^t[g++],c=(i[b>>>24]<<24|i[p>>>16&255]<<16|i[h>>>8&255]<<8|i[255&m])^t[g++],[s>>>=0,o>>>=0,a>>>=0,c>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],c=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var n=[],i=[],r=[[],[],[],[]],s=[[],[],[],[]],o=0,a=0,c=0;c<256;++c){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,n[o]=u,i[u]=o;var l=e[o],d=e[l],f=e[d],p=257*e[u]^16843008*u;r[0][o]=p<<24|p>>>8,r[1][o]=p<<16|p>>>16,r[2][o]=p<<8|p>>>24,r[3][o]=p,p=16843009*f^65537*d^257*l^16843008*o,s[0][u]=p<<24|p>>>8,s[1][u]=p<<16|p>>>16,s[2][u]=p<<8|p>>>24,s[3][u]=p,0===o?o=a=1:(o=l^e[e[e[f^l]]],a^=e[e[a]])}return{SBOX:n,INV_SBOX:i,SUB_MIX:r,INV_SUB_MIX:s}}();function u(e){this._key=r(e),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var e=this._key,t=e.length,n=t+6,i=4*(n+1),r=[],s=0;s>>24,o=c.SBOX[o>>>24]<<24|c.SBOX[o>>>16&255]<<16|c.SBOX[o>>>8&255]<<8|c.SBOX[255&o],o^=a[s/t|0]<<24):t>6&&s%t==4&&(o=c.SBOX[o>>>24]<<24|c.SBOX[o>>>16&255]<<16|c.SBOX[o>>>8&255]<<8|c.SBOX[255&o]),r[s]=r[s-t]^o}for(var u=[],l=0;l>>24]]^c.INV_SUB_MIX[1][c.SBOX[f>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[f>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&f]]}this._nRounds=n,this._keySchedule=r,this._invKeySchedule=u},u.prototype.encryptBlockRaw=function(e){return o(e=r(e),this._keySchedule,c.SUB_MIX,c.SBOX,this._nRounds)},u.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),n=i.allocUnsafe(16);return n.writeUInt32BE(t[0],0),n.writeUInt32BE(t[1],4),n.writeUInt32BE(t[2],8),n.writeUInt32BE(t[3],12),n},u.prototype.decryptBlock=function(e){var t=(e=r(e))[1];e[1]=e[3],e[3]=t;var n=o(e,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX,this._nRounds),s=i.allocUnsafe(16);return s.writeUInt32BE(n[0],0),s.writeUInt32BE(n[3],4),s.writeUInt32BE(n[2],8),s.writeUInt32BE(n[1],12),s},u.prototype.scrub=function(){s(this._keySchedule),s(this._invKeySchedule),s(this._key)},t.exports.AES=u},{"safe-buffer":376}],73:[function(e,t,n){var i=e("./aes"),r=e("safe-buffer").Buffer,s=e("cipher-base"),o=e("inherits"),a=e("./ghash"),c=e("buffer-xor"),u=e("./incr32");function l(e,t,n,o){s.call(this);var c=r.alloc(4,0);this._cipher=new i.AES(t);var l=this._cipher.encryptBlock(c);this._ghash=new a(l),n=function(e,t,n){if(12===t.length)return e._finID=r.concat([t,r.from([0,0,0,1])]),r.concat([t,r.from([0,0,0,2])]);var i=new a(n),s=t.length,o=s%16;i.update(t),o&&(o=16-o,i.update(r.alloc(o,0))),i.update(r.alloc(8,0));var c=8*s,l=r.alloc(8);l.writeUIntBE(c,0,8),i.update(l),e._finID=i.state;var d=r.from(e._finID);return u(d),d}(this,n,l),this._prev=r.from(n),this._cache=r.allocUnsafe(0),this._secCache=r.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}o(l,s),l.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=r.alloc(t,0),this._ghash.update(t))}this._called=!0;var n=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(n),this._len+=e.length,n},l.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=c(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var n=0;e.length!==t.length&&n++;for(var i=Math.min(e.length,t.length),r=0;r16)throw new Error("unable to decrypt data");var n=-1;for(;++n16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},d.prototype.flush=function(){if(this.cache.length)return this.cache},n.createDecipher=function(e,t){var n=s[e.toLowerCase()];if(!n)throw new TypeError("invalid suite type");var i=u(t,!1,n.key,n.iv);return f(e,i.key,i.iv)},n.createDecipheriv=f},{"./aes":72,"./authCipher":73,"./modes":85,"./streamCipher":88,"cipher-base":138,evp_bytestokey:195,inherits:245,"safe-buffer":376}],76:[function(e,t,n){var i=e("./modes"),r=e("./authCipher"),s=e("safe-buffer").Buffer,o=e("./streamCipher"),a=e("cipher-base"),c=e("./aes"),u=e("evp_bytestokey");function l(e,t,n){a.call(this),this._cache=new f,this._cipher=new c.AES(t),this._prev=s.from(n),this._mode=e,this._autopadding=!0}e("inherits")(l,a),l.prototype._update=function(e){var t,n;this._cache.add(e);for(var i=[];t=this._cache.get();)n=this._mode.encrypt(this,t),i.push(n);return s.concat(i)};var d=s.alloc(16,16);function f(){this.cache=s.allocUnsafe(0)}function p(e,t,n){var a=i[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=s.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof n&&(n=s.from(n)),"GCM"!==a.mode&&n.length!==a.iv)throw new TypeError("invalid iv length "+n.length);return"stream"===a.type?new o(a.module,t,n):"auth"===a.type?new r(a.module,t,n):new l(a.module,t,n)}l.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(d))throw this._cipher.scrub(),new Error("data not multiple of block length")},l.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},f.prototype.add=function(e){this.cache=s.concat([this.cache,e])},f.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},f.prototype.flush=function(){for(var e=16-this.cache.length,t=s.allocUnsafe(e),n=-1;++n>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)i[t]=i[t]>>>1|(1&i[t-1])<<31;i[0]=i[0]>>>1,n&&(i[0]=i[0]^225<<24)}this.state=s(r)},o.prototype.update=function(e){var t;for(this.cache=i.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(i.concat([this.cache,r],16)),this.ghash(s([0,e,0,t])),this.state},t.exports=o},{"safe-buffer":376}],78:[function(e,t,n){t.exports=function(e){for(var t,n=e.length;n--;){if(255!==(t=e.readUInt8(n))){t++,e.writeUInt8(t,n);break}e.writeUInt8(0,n)}}},{}],79:[function(e,t,n){var i=e("buffer-xor");n.encrypt=function(e,t){var n=i(t,e._prev);return e._prev=e._cipher.encryptBlock(n),e._prev},n.decrypt=function(e,t){var n=e._prev;e._prev=t;var r=e._cipher.decryptBlock(t);return i(r,n)}},{"buffer-xor":118}],80:[function(e,t,n){var i=e("safe-buffer").Buffer,r=e("buffer-xor");function s(e,t,n){var s=t.length,o=r(t,e._cache);return e._cache=e._cache.slice(s),e._prev=i.concat([e._prev,n?t:o]),o}n.encrypt=function(e,t,n){for(var r,o=i.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=i.allocUnsafe(0)),!(e._cache.length<=t.length)){o=i.concat([o,s(e,t,n)]);break}r=e._cache.length,o=i.concat([o,s(e,t.slice(0,r),n)]),t=t.slice(r)}return o}},{"buffer-xor":118,"safe-buffer":376}],81:[function(e,t,n){var i=e("safe-buffer").Buffer;function r(e,t,n){for(var i,r,o=-1,a=0;++o<8;)i=t&1<<7-o?128:0,a+=(128&(r=e._cipher.encryptBlock(e._prev)[0]^i))>>o%8,e._prev=s(e._prev,n?i:r);return a}function s(e,t){var n=e.length,r=-1,s=i.allocUnsafe(e.length);for(e=i.concat([e,i.from([t])]);++r>7;return s}n.encrypt=function(e,t,n){for(var s=t.length,o=i.allocUnsafe(s),a=-1;++a=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function o(e,t){var r=function(e){var t=s(e);return{blinder:t.toRed(i.mont(e.modulus)).redPow(new i(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),o=t.modulus.byteLength(),a=new i(e).mul(r.blinder).umod(t.modulus),c=a.toRed(i.mont(t.prime1)),u=a.toRed(i.mont(t.prime2)),l=t.coefficient,d=t.prime1,f=t.prime2,p=c.redPow(t.exponent1).fromRed(),h=u.redPow(t.exponent2).fromRed(),m=p.isub(h).imul(l).umod(d).imul(f);return h.iadd(m).imul(r.unblinder).umod(t.modulus).toArrayLike(n,"be",o)}o.getr=s,t.exports=o}).call(this)}).call(this,e("buffer").Buffer)},{"bn.js":69,buffer:114,randombytes:348}],93:[function(e,t,n){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":94}],94:[function(e,t,n){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],95:[function(e,t,n){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],96:[function(e,t,n){var i=e("safe-buffer").Buffer,r=e("create-hash"),s=e("readable-stream"),o=e("inherits"),a=e("./sign"),c=e("./verify"),u=e("./algorithms.json");function l(e){s.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function d(e){s.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){return new l(e)}function p(e){return new d(e)}Object.keys(u).forEach((function(e){u[e].id=i.from(u[e].id,"hex"),u[e.toLowerCase()]=u[e]})),o(l,s.Writable),l.prototype._write=function(e,t,n){this._hash.update(e),n()},l.prototype.update=function(e,t){return"string"==typeof e&&(e=i.from(e,t)),this._hash.update(e),this},l.prototype.sign=function(e,t){this.end();var n=this._hash.digest(),i=a(n,e,this._hashType,this._signType,this._tag);return t?i.toString(t):i},o(d,s.Writable),d.prototype._write=function(e,t,n){this._hash.update(e),n()},d.prototype.update=function(e,t){return"string"==typeof e&&(e=i.from(e,t)),this._hash.update(e),this},d.prototype.verify=function(e,t,n){"string"==typeof t&&(t=i.from(t,n)),this.end();var r=this._hash.digest();return c(t,r,e,this._signType,this._tag)},t.exports={Sign:f,Verify:p,createSign:f,createVerify:p}},{"./algorithms.json":94,"./sign":97,"./verify":98,"create-hash":143,inherits:245,"readable-stream":113,"safe-buffer":376}],97:[function(e,t,n){var i=e("safe-buffer").Buffer,r=e("create-hmac"),s=e("browserify-rsa"),o=e("elliptic").ec,a=e("bn.js"),c=e("parse-asn1"),u=e("./curves.json");function l(e,t,n,s){if((e=i.from(e.toArray())).length0&&n.ishrn(i),n}function f(e,t,n){var s,o;do{for(s=i.alloc(0);8*s.length=t)throw new Error("invalid sig")}t.exports=function(e,t,n,u,l){var d=o(n);if("ec"===d.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(e,t,n){var i=a[n.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+n.data.algorithm.curve.join("."));var r=new s(i),o=n.data.subjectPrivateKey.data;return r.verify(t,e,o)}(e,t,d)}if("dsa"===d.type){if("dsa"!==u)throw new Error("wrong public key type");return function(e,t,n){var i=n.data.p,s=n.data.q,a=n.data.g,u=n.data.pub_key,l=o.signature.decode(e,"der"),d=l.s,f=l.r;c(d,s),c(f,s);var p=r.mont(i),h=d.invm(s);return 0===a.toRed(p).redPow(new r(t).mul(h).mod(s)).fromRed().mul(u.toRed(p).redPow(f.mul(h).mod(s)).fromRed()).mod(i).mod(s).cmp(f)}(e,t,d)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");t=i.concat([l,t]);for(var f=d.modulus.byteLength(),p=[1],h=0;t.length+p.length+2 * @license MIT */ -"use strict";var t=e("base64-js"),i=e("ieee754");n.Buffer=s,n.SlowBuffer=function(e){+e!=e&&(e=0);return s.alloc(+e)},n.INSPECT_MAX_BYTES=50;var r=2147483647;function o(e){if(e>r)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return a(e,t,n)}function a(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|d(e,t),i=o(n),r=i.write(e,t);r!==n&&(i=i.slice(0,r));return i}(e,t);if(ArrayBuffer.isView(e))return p(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(q(e,ArrayBuffer)||e&&q(e.buffer,ArrayBuffer))return function(e,t,n){if(t<0||e.byteLength=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return M(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(r)return i?-1:M(e).length;t=(""+t).toLowerCase(),r=!0}}function f(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return C(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return k(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function h(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function m(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=s.from(t,i)),s.isBuffer(t))return 0===t.length?-1:g(e,t,n,i,r);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,i,r){var o,s=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r){var p=-1;for(o=n;oa&&(n=a-c),o=n;o>=0;o--){for(var u=!0,d=0;dr&&(i=r):i=r;var o=t.length;i>o/2&&(i=o/2);for(var s=0;s>8,r=n%256,o.push(r),o.push(i);return o}(t,e.length-n),e,n,i)}function k(e,n,i){return 0===n&&i===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,i))}function E(e,t,n){n=Math.min(e.length,n);for(var i=[],r=t;r239?4:l>223?3:l>191?2:1;if(r+u<=n)switch(u){case 1:l<128&&(p=l);break;case 2:128==(192&(o=e[r+1]))&&(c=(31&l)<<6|63&o)>127&&(p=c);break;case 3:o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(p=c);break;case 4:o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(p=c)}null===p?(p=65533,u=1):p>65535&&(p-=65536,i.push(p>>>10&1023|55296),p=56320|1023&p),i.push(p),r+=u}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var n="",i=0;for(;it&&(e+=" ... "),""},s.prototype.compare=function(e,t,n,i,r){if(q(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.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===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),t<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&t>=n)return 0;if(i>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(r>>>=0)-(i>>>=0),a=(n>>>=0)-(t>>>=0),c=Math.min(o,a),l=this.slice(i,r),p=e.slice(t,n),u=0;u>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}var r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return x(this,e,t,n);case"latin1":case"binary":return y(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function C(e,t,n){var i="";n=Math.min(e.length,n);for(var r=t;ri)&&(n=i);for(var r="",o=t;on)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,n,i,r,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function R(e,t,n,i,r,o){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function O(e,t,n,r,o){return t=+t,n>>>=0,o||R(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function B(e,t,n,r,o){return t=+t,n>>>=0,o||R(e,0,n,8),i.write(e,t,n,r,52,8),n+8}s.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||L(e,t,this.length);for(var i=this[e],r=1,o=0;++o>>=0,t>>>=0,n||L(e,t,this.length);for(var i=this[e+--t],r=1;t>0&&(r*=256);)i+=this[e+--t]*r;return i},s.prototype.readUInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);for(var i=this[e],r=1,o=0;++o=(r*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);for(var i=t,r=1,o=this[e+--i];i>0&&(r*=256);)o+=this[e+--i]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||L(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||L(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||L(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||L(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||L(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||L(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,n,i){(e=+e,t>>>=0,n>>>=0,i)||I(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,o=0;for(this[t]=255&e;++o>>=0,n>>>=0,i)||I(this,e,t,n,Math.pow(2,8*n)-1,0);var r=n-1,o=1;for(this[t+r]=255&e;--r>=0&&(o*=256);)this[t+r]=e/o&255;return t+n},s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||I(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},s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||I(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},s.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t>>>=0,!i){var r=Math.pow(2,8*n-1);I(this,e,t,n,r-1,-r)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+n},s.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t>>>=0,!i){var r=Math.pow(2,8*n-1);I(this,e,t,n,r-1,-r)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||I(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},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||I(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},s.prototype.writeFloatLE=function(e,t,n){return O(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return O(this,e,t,!1,n)},s.prototype.writeDoubleLE=function(e,t,n){return B(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return B(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,i){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,i),t);return r},s.prototype.fill=function(e,t,n,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var r=e.charCodeAt(0);("utf8"===i&&r<128||"latin1"===i)&&(e=r)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&o.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function N(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":4,buffer:55,ieee754:116}],56:[function(e,t,n){(function(e){(function(){t.exports=function(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55}],57:[function(e,t,n){(function(n){(function(){var i=e("buffer-fill"),r=e("buffer-alloc-unsafe");t.exports=function(e,t,o){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(n.alloc)return n.alloc(e,t,o);var s=r(e);return 0===e?s:void 0===t?i(s,0):("string"!=typeof o&&(o=void 0),i(s,t,o))}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55,"buffer-alloc-unsafe":56,"buffer-fill":58}],58:[function(e,t,n){(function(e){(function(){var n=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(e){return!1}}();function i(e,t,n,i){if(n<0||i>e.length)throw new RangeError("Out of range index");return n>>>=0,(i=void 0===i?e.length:i>>>0)>n&&e.fill(t,n,i),e}t.exports=function(t,r,o,s,a){if(n)return t.fill(r,o,s,a);if("number"==typeof r)return i(t,r,o,s);if("string"==typeof r){if("string"==typeof o?(a=o,o=0,s=t.length):"string"==typeof s&&(a=s,s=t.length),void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("latin1"===a&&(a="binary"),"string"==typeof a&&!e.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(""===r)return i(t,0,o,s);if(function(e){return 1===e.length&&e.charCodeAt(0)<256}(r))return i(t,r.charCodeAt(0),o,s);r=new e(r,a)}return e.isBuffer(r)?function(e,t,n,i){if(n<0||i>e.length)throw new RangeError("Out of range index");if(i<=n)return e;n>>>=0,i=void 0===i?e.length:i>>>0;for(var r=n,o=t.length;r<=i-o;)t.copy(e,r),r+=o;return r!==i&&t.copy(e,r,0,i-r),e}(t,r,o,s):i(t,0,o,s)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55}],59:[function(e,t,n){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],60:[function(e,t,n){ +"use strict";var t=e("base64-js"),i=e("ieee754");n.Buffer=o,n.SlowBuffer=function(e){+e!=e&&(e=0);return o.alloc(+e)},n.INSPECT_MAX_BYTES=50;var r=2147483647;function s(e){if(e>r)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=o.prototype,t}function o(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return a(e,t,n)}function a(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|f(e,t),i=s(n),r=i.write(e,t);r!==n&&(i=i.slice(0,r));return i}(e,t);if(ArrayBuffer.isView(e))return l(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(N(e,ArrayBuffer)||e&&N(e.buffer,ArrayBuffer))return function(e,t,n){if(t<0||e.byteLength=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|e}function f(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||N(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(e).length;default:if(r)return i?-1:U(e).length;t=(""+t).toLowerCase(),r=!0}}function p(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return M(this,t,n);case"latin1":case"binary":return A(this,t,n);case"base64":return k(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function h(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function m(e,t,n,i,r){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),z(n=+n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=o.from(t,i)),o.isBuffer(t))return 0===t.length?-1:b(e,t,n,i,r);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,i,r);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,i,r){var s,o=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){var l=-1;for(s=n;sa&&(n=a-c),s=n;s>=0;s--){for(var d=!0,f=0;fr&&(i=r):i=r;var s=t.length;i>s/2&&(i=s/2);for(var o=0;o>8,r=n%256,s.push(r),s.push(i);return s}(t,e.length-n),e,n,i)}function k(e,n,i){return 0===n&&i===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,i))}function E(e,t,n){n=Math.min(e.length,n);for(var i=[],r=t;r239?4:u>223?3:u>191?2:1;if(r+d<=n)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(s=e[r+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=e[r+1],o=e[r+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=e[r+1],o=e[r+2],a=e[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),r+=d}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var n="",i=0;for(;it&&(e+=" ... "),""},o.prototype.compare=function(e,t,n,i,r){if(N(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.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===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),t<0||n>e.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&t>=n)return 0;if(i>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(r>>>=0)-(i>>>=0),a=(n>>>=0)-(t>>>=0),c=Math.min(s,a),u=this.slice(i,r),l=e.slice(t,n),d=0;d>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}var r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return g(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":return y(this,e,t,n);case"latin1":case"binary":return _(this,e,t,n);case"base64":return w(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function M(e,t,n){var i="";n=Math.min(e.length,n);for(var r=t;ri)&&(n=i);for(var r="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function T(e,t,n,i,r,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function B(e,t,n,i,r,s){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function R(e,t,n,r,s){return t=+t,n>>>=0,s||B(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function L(e,t,n,r,s){return t=+t,n>>>=0,s||B(e,0,n,8),i.write(e,t,n,r,52,8),n+8}o.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||C(e,t,this.length);for(var i=this[e],r=1,s=0;++s>>=0,t>>>=0,n||C(e,t,this.length);for(var i=this[e+--t],r=1;t>0&&(r*=256);)i+=this[e+--t]*r;return i},o.prototype.readUInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||C(e,t,this.length);for(var i=this[e],r=1,s=0;++s=(r*=128)&&(i-=Math.pow(2,8*t)),i},o.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||C(e,t,this.length);for(var i=t,r=1,s=this[e+--i];i>0&&(r*=256);)s+=this[e+--i]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||C(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){e>>>=0,t||C(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||C(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||C(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||C(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||C(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,i){(e=+e,t>>>=0,n>>>=0,i)||T(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,s=0;for(this[t]=255&e;++s>>=0,n>>>=0,i)||T(this,e,t,n,Math.pow(2,8*n)-1,0);var r=n-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||T(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||T(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||T(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||T(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},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||T(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},o.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t>>>=0,!i){var r=Math.pow(2,8*n-1);T(this,e,t,n,r-1,-r)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+n},o.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t>>>=0,!i){var r=Math.pow(2,8*n-1);T(this,e,t,n,r-1,-r)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||T(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||T(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||T(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||T(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},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||T(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},o.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return L(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return L(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,i){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t=0;--s)e[s+t]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,i),t);return r},o.prototype.fill=function(e,t,n,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!o.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var r=e.charCodeAt(0);("utf8"===i&&r<128||"latin1"===i)&&(e=r)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function q(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function N(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function z(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":19,buffer:114,ieee754:243}],115:[function(e,t,n){(function(e){(function(){t.exports=function(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114}],116:[function(e,t,n){(function(n){(function(){var i=e("buffer-fill"),r=e("buffer-alloc-unsafe");t.exports=function(e,t,s){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(n.alloc)return n.alloc(e,t,s);var o=r(e);return 0===e?o:void 0===t?i(o,0):("string"!=typeof s&&(s=void 0),i(o,t,s))}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114,"buffer-alloc-unsafe":115,"buffer-fill":117}],117:[function(e,t,n){(function(e){(function(){var n=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(e){return!1}}();function i(e,t,n,i){if(n<0||i>e.length)throw new RangeError("Out of range index");return n>>>=0,(i=void 0===i?e.length:i>>>0)>n&&e.fill(t,n,i),e}t.exports=function(t,r,s,o,a){if(n)return t.fill(r,s,o,a);if("number"==typeof r)return i(t,r,s,o);if("string"==typeof r){if("string"==typeof s?(a=s,s=0,o=t.length):"string"==typeof o&&(a=o,o=t.length),void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("latin1"===a&&(a="binary"),"string"==typeof a&&!e.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(""===r)return i(t,0,s,o);if(function(e){return 1===e.length&&e.charCodeAt(0)<256}(r))return i(t,r.charCodeAt(0),s,o);r=new e(r,a)}return e.isBuffer(r)?function(e,t,n,i){if(n<0||i>e.length)throw new RangeError("Out of range index");if(i<=n)return e;n>>>=0,i=void 0===i?e.length:i>>>0;for(var r=n,s=t.length;r<=i-s;)t.copy(e,r),r+=s;return r!==i&&t.copy(e,r,0,i-r),e}(t,r,s,o):i(t,0,s,o)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114}],118:[function(e,t,n){(function(e){(function(){t.exports=function(t,n){for(var i=Math.min(t.length,n.length),r=new e(i),s=0;s=o.pb?"PB":n>=o.tb?"TB":n>=o.gb?"GB":n>=o.mb?"MB":n>=o.kb?"KB":"B");var u=(e/o[p.toLowerCase()]).toFixed(c);return l||(u=u.replace(r,"$1")),s&&(u=u.replace(i,s)),u+a+p}function c(e){if("number"==typeof e&&!isNaN(e))return e;if("string"!=typeof e)return null;var t,n=s.exec(e),i="b";return n?(t=parseFloat(n[1]),i=n[4].toLowerCase()):(t=parseInt(e,10),i="b"),Math.floor(o[i]*t)}},{}],61:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],62:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":64,"./_stream_writable":66,_process:189,dup:16,inherits:118}],63:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":65,dup:17,inherits:118}],64:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":61,"./_stream_duplex":62,"./internal/streams/async_iterator":67,"./internal/streams/buffer_list":68,"./internal/streams/destroy":69,"./internal/streams/from":71,"./internal/streams/state":73,"./internal/streams/stream":74,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],65:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":61,"./_stream_duplex":62,dup:19,inherits:118}],66:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":61,"./_stream_duplex":62,"./internal/streams/destroy":69,"./internal/streams/state":73,"./internal/streams/stream":74,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],67:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":70,_process:189,dup:21}],68:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],69:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],70:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":61,dup:24}],71:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],72:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":61,"./end-of-stream":70,dup:26}],73:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":61,dup:27}],74:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],75:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":62,"./lib/_stream_passthrough.js":63,"./lib/_stream_readable.js":64,"./lib/_stream_transform.js":65,"./lib/_stream_writable.js":66,"./lib/internal/streams/end-of-stream.js":70,"./lib/internal/streams/pipeline.js":72,dup:29}],76:[function(e,t,n){const i=e("block-stream2"),r=e("readable-stream");class o extends r.Writable{constructor(e,t,n={}){if(super(n),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(!(t=Number(t)))throw new Error("Second argument must be a chunk length");const r=void 0!==n.zeroPadding&&n.zeroPadding;this._blockstream=new i(t,{...n,zeroPadding:r}),this._outstandingPuts=0,this._storeMaxOutstandingPuts=n.storeMaxOutstandingPuts||16;let o=0;this._blockstream.on("data",(t=>{this.destroyed||(this._outstandingPuts+=1,this._outstandingPuts>=this._storeMaxOutstandingPuts&&this._blockstream.pause(),e.put(o,t,(e=>{if(e)return this.destroy(e);this._outstandingPuts-=1,this._outstandingPuts{this.destroy(e)}))}_write(e,t,n){this._blockstream.write(e,t,n)}_final(e){this._blockstream.end(),this._blockstream.once("end",(()=>{0===this._outstandingPuts?e(null):this._finalCb=e}))}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}}t.exports=o},{"block-stream2":38,"readable-stream":75}],77:[function(e,t,n){ +"use strict";t.exports=function(e,t){if("string"==typeof e)return c(e);if("number"==typeof e)return a(e,t);return null},t.exports.format=a,t.exports.parse=c;var i=/\B(?=(\d{3})+(?!\d))/g,r=/(?:\.0*|(\.[^0]+)0+)$/,s={b:1,kb:1024,mb:1<<20,gb:1<<30,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},o=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function a(e,t){if(!Number.isFinite(e))return null;var n=Math.abs(e),o=t&&t.thousandsSeparator||"",a=t&&t.unitSeparator||"",c=t&&void 0!==t.decimalPlaces?t.decimalPlaces:2,u=Boolean(t&&t.fixedDecimals),l=t&&t.unit||"";l&&s[l.toLowerCase()]||(l=n>=s.pb?"PB":n>=s.tb?"TB":n>=s.gb?"GB":n>=s.mb?"MB":n>=s.kb?"KB":"B");var d=(e/s[l.toLowerCase()]).toFixed(c);return u||(d=d.replace(r,"$1")),o&&(d=d.replace(i,o)),d+a+l}function c(e){if("number"==typeof e&&!isNaN(e))return e;if("string"!=typeof e)return null;var t,n=o.exec(e),i="b";return n?(t=parseFloat(n[1]),i=n[4].toLowerCase()):(t=parseInt(e,10),i="b"),Math.floor(s[i]*t)}},{}],121:[function(e,t,n){ +/*! cache-chunk-store. MIT License. Feross Aboukhadijeh */ +const i=e("lru"),r=e("queue-microtask");t.exports=class{constructor(e,t){if(this.store=e,this.chunkLength=e.chunkLength,this.inProgressGets=new Map,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.cache=new i(t)}put(e,t,n=(()=>{})){if(!this.cache)return r((()=>n(new Error("CacheStore closed"))));this.cache.remove(e),this.store.put(e,t,n)}get(e,t,n=(()=>{})){if("function"==typeof t)return this.get(e,null,t);if(!this.cache)return r((()=>n(new Error("CacheStore closed"))));t||(t={});let i=this.cache.get(e);if(i){const e=t.offset||0,s=t.length||i.length-e;return 0===e&&s===i.length||(i=i.slice(e,s+e)),r((()=>n(null,i)))}let s=this.inProgressGets.get(e);const o=!!s;s||(s=[],this.inProgressGets.set(e,s)),s.push({opts:t,cb:n}),o||this.store.get(e,((t,n)=>{t||null==this.cache||this.cache.set(e,n);const i=this.inProgressGets.get(e);this.inProgressGets.delete(e);for(const{opts:e,cb:r}of i)if(t)r(t);else{const t=e.offset||0,i=e.length||n.length-t;let s=n;0===t&&i===n.length||(s=n.slice(t,i+t)),r(null,s)}}))}close(e=(()=>{})){if(!this.cache)return r((()=>e(new Error("CacheStore closed"))));this.cache=null,this.store.close(e)}destroy(e=(()=>{})){if(!this.cache)return r((()=>e(new Error("CacheStore closed"))));this.cache=null,this.store.destroy(e)}}},{lru:249,"queue-microtask":346}],122:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],123:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":125,"./_stream_writable":127,_process:333,dup:31,inherits:245}],124:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":126,dup:32,inherits:245}],125:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":122,"./_stream_duplex":123,"./internal/streams/async_iterator":128,"./internal/streams/buffer_list":129,"./internal/streams/destroy":130,"./internal/streams/from":132,"./internal/streams/state":134,"./internal/streams/stream":135,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],126:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":122,"./_stream_duplex":123,dup:34,inherits:245}],127:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":122,"./_stream_duplex":123,"./internal/streams/destroy":130,"./internal/streams/state":134,"./internal/streams/stream":135,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],128:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":131,_process:333,dup:36}],129:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],130:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],131:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":122,dup:39}],132:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],133:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":122,"./end-of-stream":131,dup:41}],134:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":122,dup:42}],135:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],136:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":123,"./lib/_stream_passthrough.js":124,"./lib/_stream_readable.js":125,"./lib/_stream_transform.js":126,"./lib/_stream_writable.js":127,"./lib/internal/streams/end-of-stream.js":131,"./lib/internal/streams/pipeline.js":133,dup:44}],137:[function(e,t,n){const i=e("block-stream2"),r=e("readable-stream");class s extends r.Writable{constructor(e,t,n={}){if(super(n),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(!(t=Number(t)))throw new Error("Second argument must be a chunk length");const r=void 0!==n.zeroPadding&&n.zeroPadding;this._blockstream=new i(t,{...n,zeroPadding:r}),this._outstandingPuts=0,this._storeMaxOutstandingPuts=n.storeMaxOutstandingPuts||16;let s=0;this._blockstream.on("data",(t=>{this.destroyed||(this._outstandingPuts+=1,this._outstandingPuts>=this._storeMaxOutstandingPuts&&this._blockstream.pause(),e.put(s,t,(e=>{if(e)return this.destroy(e);this._outstandingPuts-=1,this._outstandingPuts{this.destroy(e)}))}_write(e,t,n){this._blockstream.write(e,t,n)}_final(e){this._blockstream.end(),this._blockstream.once("end",(()=>{0===this._outstandingPuts?e(null):this._finalCb=e}))}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}}t.exports=s},{"block-stream2":53,"readable-stream":136}],138:[function(e,t,n){var i=e("safe-buffer").Buffer,r=e("stream").Transform,s=e("string_decoder").StringDecoder;function o(e){r.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(o,r),o.prototype.update=function(e,t,n){"string"==typeof e&&(e=i.from(e,t));var r=this._update(e);return this.hashMode?this:(n&&(r=this._toString(r,n)),r)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(e,t,n){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){i=e}finally{n(i)}},o.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},o.prototype._finalOrDigest=function(e){var t=this.__final()||i.alloc(0);return e&&(t=this._toString(t,e,!0)),t},o.prototype._toString=function(e,t,n){if(this._decoder||(this._decoder=new s(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return n&&(i+=this._decoder.end()),i},t.exports=o},{inherits:245,"safe-buffer":376,stream:429,string_decoder:466}],139:[function(e,t,n){ /*! * clipboard.js v2.0.8 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */ -var i,r;i=this,r=function(){return function(){var e={134:function(e,t,n){"use strict";n.d(t,{default:function(){return x}});var i=n(279),r=n.n(i),o=n(370),s=n.n(o),a=n(817),c=n.n(a);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var e="rtl"===document.documentElement.getAttribute("dir");this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var t=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(t,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var e=this,t=this.createFakeElement();this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(t),this.selectedText=c()(t),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=c()(this.target),this.copyText()}},{key:"copyText",value:function(){var e;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(void 0!==e){if(!e||"object"!==l(e)||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function(){return this._target}}])&&p(t.prototype,n),i&&p(t,i),e}();function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof e?[e]:e,n=!!document.queryCommandSupported;return t.forEach((function(e){n=n&&!!document.queryCommandSupported(e)})),n}}],(n=[{key:"resolveOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===d(e.container)?e.container:document.body}},{key:"listenClick",value:function(e){var t=this;this.listener=s()(e,"click",(function(e){return t.onClick(e)}))}},{key:"onClick",value:function(e){var t=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new u({action:this.action(t),target:this.target(t),text:this.text(t),container:this.container,trigger:t,emitter:this})}},{key:"defaultAction",value:function(e){return b("action",e)}},{key:"defaultTarget",value:function(e){var t=b("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return b("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}])&&f(t.prototype,n),i&&f(t,i),o}(r())},828:function(e){if("undefined"!=typeof Element&&!Element.prototype.matches){var t=Element.prototype;t.matches=t.matchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector}e.exports=function(e,t){for(;e&&9!==e.nodeType;){if("function"==typeof e.matches&&e.matches(t))return e;e=e.parentNode}}},438:function(e,t,n){var i=n(828);function r(e,t,n,i,r){var s=o.apply(this,arguments);return e.addEventListener(n,s,r),{destroy:function(){e.removeEventListener(n,s,r)}}}function o(e,t,n,r){return function(n){n.delegateTarget=i(n.target,t),n.delegateTarget&&r.call(e,n)}}e.exports=function(e,t,n,i,o){return"function"==typeof e.addEventListener?r.apply(null,arguments):"function"==typeof n?r.bind(null,document).apply(null,arguments):("string"==typeof e&&(e=document.querySelectorAll(e)),Array.prototype.map.call(e,(function(e){return r(e,t,n,i,o)})))}},879:function(e,t){t.node=function(e){return void 0!==e&&e instanceof HTMLElement&&1===e.nodeType},t.nodeList=function(e){var n=Object.prototype.toString.call(e);return void 0!==e&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in e&&(0===e.length||t.node(e[0]))},t.string=function(e){return"string"==typeof e||e instanceof String},t.fn=function(e){return"[object Function]"===Object.prototype.toString.call(e)}},370:function(e,t,n){var i=n(879),r=n(438);e.exports=function(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required arguments");if(!i.string(t))throw new TypeError("Second argument must be a String");if(!i.fn(n))throw new TypeError("Third argument must be a Function");if(i.node(e))return function(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}(e,t,n);if(i.nodeList(e))return function(e,t,n){return Array.prototype.forEach.call(e,(function(e){e.addEventListener(t,n)})),{destroy:function(){Array.prototype.forEach.call(e,(function(e){e.removeEventListener(t,n)}))}}}(e,t,n);if(i.string(e))return function(e,t,n){return r(document.body,e,t,n)}(e,t,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},817:function(e){e.exports=function(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var i=window.getSelection(),r=document.createRange();r.selectNodeContents(e),i.removeAllRanges(),i.addRange(r),t=i.toString()}return t}},279:function(e){function t(){}t.prototype={on:function(e,t,n){var i=this.e||(this.e={});return(i[e]||(i[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var i=this;function r(){i.off(e,r),t.apply(n,arguments)}return r._=t,this.on(e,r,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),i=0,r=n.length;i0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var e="rtl"===document.documentElement.getAttribute("dir");this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var t=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(t,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var e=this,t=this.createFakeElement();this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(t),this.selectedText=c()(t),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=c()(this.target),this.copyText()}},{key:"copyText",value:function(){var e;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(void 0!==e){if(!e||"object"!==u(e)||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function(){return this._target}}])&&l(t.prototype,n),i&&l(t,i),e}();function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof e?[e]:e,n=!!document.queryCommandSupported;return t.forEach((function(e){n=n&&!!document.queryCommandSupported(e)})),n}}],(n=[{key:"resolveOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===f(e.container)?e.container:document.body}},{key:"listenClick",value:function(e){var t=this;this.listener=o()(e,"click",(function(e){return t.onClick(e)}))}},{key:"onClick",value:function(e){var t=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new d({action:this.action(t),target:this.target(t),text:this.text(t),container:this.container,trigger:t,emitter:this})}},{key:"defaultAction",value:function(e){return v("action",e)}},{key:"defaultTarget",value:function(e){var t=v("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return v("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}])&&p(t.prototype,n),i&&p(t,i),s}(r())},828:function(e){if("undefined"!=typeof Element&&!Element.prototype.matches){var t=Element.prototype;t.matches=t.matchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector}e.exports=function(e,t){for(;e&&9!==e.nodeType;){if("function"==typeof e.matches&&e.matches(t))return e;e=e.parentNode}}},438:function(e,t,n){var i=n(828);function r(e,t,n,i,r){var o=s.apply(this,arguments);return e.addEventListener(n,o,r),{destroy:function(){e.removeEventListener(n,o,r)}}}function s(e,t,n,r){return function(n){n.delegateTarget=i(n.target,t),n.delegateTarget&&r.call(e,n)}}e.exports=function(e,t,n,i,s){return"function"==typeof e.addEventListener?r.apply(null,arguments):"function"==typeof n?r.bind(null,document).apply(null,arguments):("string"==typeof e&&(e=document.querySelectorAll(e)),Array.prototype.map.call(e,(function(e){return r(e,t,n,i,s)})))}},879:function(e,t){t.node=function(e){return void 0!==e&&e instanceof HTMLElement&&1===e.nodeType},t.nodeList=function(e){var n=Object.prototype.toString.call(e);return void 0!==e&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in e&&(0===e.length||t.node(e[0]))},t.string=function(e){return"string"==typeof e||e instanceof String},t.fn=function(e){return"[object Function]"===Object.prototype.toString.call(e)}},370:function(e,t,n){var i=n(879),r=n(438);e.exports=function(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required arguments");if(!i.string(t))throw new TypeError("Second argument must be a String");if(!i.fn(n))throw new TypeError("Third argument must be a Function");if(i.node(e))return function(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}(e,t,n);if(i.nodeList(e))return function(e,t,n){return Array.prototype.forEach.call(e,(function(e){e.addEventListener(t,n)})),{destroy:function(){Array.prototype.forEach.call(e,(function(e){e.removeEventListener(t,n)}))}}}(e,t,n);if(i.string(e))return function(e,t,n){return r(document.body,e,t,n)}(e,t,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},817:function(e){e.exports=function(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var i=window.getSelection(),r=document.createRange();r.selectNodeContents(e),i.removeAllRanges(),i.addRange(r),t=i.toString()}return t}},279:function(e){function t(){}t.prototype={on:function(e,t,n){var i=this.e||(this.e={});return(i[e]||(i[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var i=this;function r(){i.off(e,r),t.apply(n,arguments)}return r._=t,this.on(e,r,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),i=0,r=n.length;in)?t=("rmd160"===e?new c:u(e)).update(t).digest():t.lengtha?t=e(t):t.length */ -const r=e("bencode"),o=e("block-stream2"),s=e("piece-length"),a=e("path"),c=e("filestream/read"),l=e("is-file"),p=e("junk"),u=e("multistream"),d=e("once"),f=e("run-parallel"),h=e("queue-microtask"),m=e("simple-sha1"),g=e("readable-stream"),v=e("./get-files");function b(e){return e.reduce(((e,t)=>Array.isArray(t)?e.concat(b(t)):e.concat(t)),[])}function x(e,t,n){var r;if(r=e,"undefined"!=typeof FileList&&r instanceof FileList&&(e=Array.from(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");e.forEach((e=>{if(null==e)throw new Error(`invalid input type: ${e}`)})),1!==(e=e.map((e=>w(e)&&"string"==typeof e.path&&"function"==typeof v?e.path:e))).length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);let o=null;e.forEach(((t,n)=>{if("string"==typeof t)return;let i=t.fullPath||t.name;i||(i=`Unknown File ${n+1}`,t.unknownName=!0),t.path=i.split("/"),t.path[0]||t.path.shift(),t.path.length<2?o=null:0===n&&e.length>1?o=t.path[0]:t.path[0]!==o&&(o=null)}));(void 0===t.filterJunkFiles||t.filterJunkFiles)&&(e=e.filter((e=>"string"==typeof e||!y(e.path)))),o&&e.forEach((e=>{const t=(i.isBuffer(e)||k(e))&&!e.path;"string"==typeof e||t||e.path.shift()})),!t.name&&o&&(t.name=o),t.name||e.some((e=>"string"==typeof e?(t.name=a.basename(e),!0):!e.unknownName&&(t.name=e.path[e.path.length-1],!0))),t.name||(t.name=`Unnamed Torrent ${Date.now()}`);const s=e.reduce(((e,t)=>e+Number("string"==typeof t)),0);let p=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof v)throw new Error("filesystem paths do not work in the browser");l(e[0],((e,t)=>{if(e)return n(e);p=t,u()}))}else h(u);function u(){f(e.map((e=>t=>{const n={};if(w(e))n.getStream=function(e){return()=>new c(e)}(e),n.length=e.size;else if(i.isBuffer(e))n.getStream=(r=e,()=>{const e=new g.PassThrough;return e.end(r),e}),n.length=e.length;else{if(!k(e)){if("string"==typeof e){if("function"!=typeof v)throw new Error("filesystem paths do not work in the browser");return void v(e,s>1||p,t)}throw new Error("invalid input type")}n.getStream=function(e,t){return()=>{const n=new g.Transform;return n._transform=function(e,n,i){t.length+=e.length,this.push(e),i()},e.pipe(n),n}}(e,n),n.length=0}var r;n.path=e.path,t(null,n)})),((e,t)=>{if(e)return n(e);t=b(t),n(null,t,p)}))}}function y(e){const t=e[e.length-1];return"."===t[0]&&p.is(t)}function _(e,t){return e+t.length}function w(e){return"undefined"!=typeof Blob&&e instanceof Blob}function k(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}t.exports=function(e,a,c){"function"==typeof a&&([a,c]=[c,a]),x(e,a=a?Object.assign({},a):{},((e,l,p)=>{if(e)return c(e);a.singleFileTorrent=p,function(e,a,c){let l=a.announceList;l||("string"==typeof a.announce?l=[[a.announce]]:Array.isArray(a.announce)&&(l=a.announce.map((e=>[e]))));l||(l=[]);n.WEBTORRENT_ANNOUNCE&&("string"==typeof n.WEBTORRENT_ANNOUNCE?l.push([[n.WEBTORRENT_ANNOUNCE]]):Array.isArray(n.WEBTORRENT_ANNOUNCE)&&(l=l.concat(n.WEBTORRENT_ANNOUNCE.map((e=>[e])))));void 0===a.announce&&void 0===a.announceList&&(l=l.concat(t.exports.announceList));"string"==typeof a.urlList&&(a.urlList=[a.urlList]);const p={info:{name:a.name},"creation date":Math.ceil((Number(a.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==l.length&&(p.announce=l[0][0],p["announce-list"]=l);void 0!==a.comment&&(p.comment=a.comment);void 0!==a.createdBy&&(p["created by"]=a.createdBy);void 0!==a.private&&(p.info.private=Number(a.private));void 0!==a.info&&Object.assign(p.info,a.info);void 0!==a.sslCert&&(p.info["ssl-cert"]=a.sslCert);void 0!==a.urlList&&(p["url-list"]=a.urlList);const f=e.reduce(_,0),h=a.pieceLength||s(f);p.info["piece length"]=h,function(e,t,n,r,s){s=d(s);const a=[];let c=0,l=0;const p=e.map((e=>e.getStream));let f=0,h=0,g=!1;const v=new u(p),b=new o(t,{zeroPadding:!1});function x(e){c+=e.length;const t=h;m(e,(i=>{a[t]=i,f-=1,f<5&&b.resume(),l+=e.length,r.onProgress&&r.onProgress(l,n),k()})),f+=1,f>=5&&b.pause(),h+=1}function y(){g=!0,k()}function _(e){w(),s(e)}function w(){v.removeListener("error",_),b.removeListener("data",x),b.removeListener("end",y),b.removeListener("error",_)}function k(){g&&0===f&&(w(),s(null,i.from(a.join(""),"hex"),c))}v.on("error",_),v.pipe(b).on("data",x).on("end",y).on("error",_)}(e,h,f,a,((t,n,i)=>{if(t)return c(t);p.info.pieces=n,e.forEach((e=>{delete e.getStream})),a.singleFileTorrent?p.info.length=i:p.info.files=e,c(null,r.encode(p))}))}(l,a,c)}))},t.exports.parseInput=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),x(e,t=t?Object.assign({},t):{},n)},t.exports.announceList=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"]],t.exports.isJunkPath=y}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./get-files":54,bencode:7,"block-stream2":38,buffer:55,"filestream/read":113,"is-file":54,junk:121,multistream:168,once:185,path:187,"piece-length":188,"queue-microtask":195,"readable-stream":94,"run-parallel":220,"simple-sha1":244}],80:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],81:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":83,"./_stream_writable":85,_process:189,dup:16,inherits:118}],82:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":84,dup:17,inherits:118}],83:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":80,"./_stream_duplex":81,"./internal/streams/async_iterator":86,"./internal/streams/buffer_list":87,"./internal/streams/destroy":88,"./internal/streams/from":90,"./internal/streams/state":92,"./internal/streams/stream":93,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],84:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":80,"./_stream_duplex":81,dup:19,inherits:118}],85:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":80,"./_stream_duplex":81,"./internal/streams/destroy":88,"./internal/streams/state":92,"./internal/streams/stream":93,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],86:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":89,_process:189,dup:21}],87:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],88:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],89:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":80,dup:24}],90:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],91:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":80,"./end-of-stream":89,dup:26}],92:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":80,dup:27}],93:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],94:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":81,"./lib/_stream_passthrough.js":82,"./lib/_stream_readable.js":83,"./lib/_stream_transform.js":84,"./lib/_stream_writable.js":85,"./lib/internal/streams/end-of-stream.js":89,"./lib/internal/streams/pipeline.js":91,dup:29}],95:[function(e,t,n){(function(n){(function(){var i=e("once"),r=function(){},o=function(e,t,s){if("function"==typeof t)return o(e,null,t);t||(t={}),s=i(s||r);var a=e._writableState,c=e._readableState,l=t.readable||!1!==t.readable&&e.readable,p=t.writable||!1!==t.writable&&e.writable,u=!1,d=function(){e.writable||f()},f=function(){p=!1,l||s.call(e)},h=function(){l=!1,p||s.call(e)},m=function(t){s.call(e,t?new Error("exited with error code: "+t):null)},g=function(t){s.call(e,t)},v=function(){n.nextTick(b)},b=function(){if(!u)return(!l||c&&c.ended&&!c.destroyed)&&(!p||a&&a.ended&&!a.destroyed)?void 0:s.call(e,new Error("premature close"))},x=function(){e.req.on("finish",f)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?p&&!a&&(e.on("end",d),e.on("close",d)):(e.on("complete",f),e.on("abort",v),e.req?x():e.on("request",x)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",h),e.on("finish",f),!1!==t.error&&e.on("error",g),e.on("close",v),function(){u=!0,e.removeListener("complete",f),e.removeListener("abort",v),e.removeListener("request",x),e.req&&e.req.removeListener("finish",f),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",f),e.removeListener("exit",m),e.removeListener("end",h),e.removeListener("error",g),e.removeListener("close",v)}};t.exports=o}).call(this)}).call(this,e("_process"))},{_process:189,once:185}],96:[function(e,t,n){"use strict";function i(e,t){for(const n in t)Object.defineProperty(e,n,{value:t[n],enumerable:!0,configurable:!0});return e}t.exports=function(e,t,n){if(!e||"string"==typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"==typeof t&&(n=t,t=""),t&&(n.code=t);try{return i(e,n)}catch(t){n.message=e.message,n.stack=e.stack;const r=function(){};r.prototype=Object.create(Object.getPrototypeOf(e));return i(new r,n)}}},{}],97:[function(e,t,n){"use strict";var i,r="object"==typeof Reflect?Reflect:null,o=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};i=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 s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(e,t){return new Promise((function(n,i){function r(n){e.removeListener(t,o),i(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}v(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&v(e,"error",t,n)}(e,r,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function p(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function u(e,t,n,i){var r,o,s,a;if(l(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]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(r=p(e))>0&&s.length>r&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){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 f(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=d.bind(i);return r.listener=n,i.wrapFn=r,r}function h(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=r[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var l=c.length,p=g(c,l);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},{}],98:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],99:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":101,"./_stream_writable":103,_process:189,dup:16,inherits:118}],100:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":102,dup:17,inherits:118}],101:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":98,"./_stream_duplex":99,"./internal/streams/async_iterator":104,"./internal/streams/buffer_list":105,"./internal/streams/destroy":106,"./internal/streams/from":108,"./internal/streams/state":110,"./internal/streams/stream":111,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],102:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":98,"./_stream_duplex":99,dup:19,inherits:118}],103:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":98,"./_stream_duplex":99,"./internal/streams/destroy":106,"./internal/streams/state":110,"./internal/streams/stream":111,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],104:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":107,_process:189,dup:21}],105:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],106:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],107:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":98,dup:24}],108:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],109:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":98,"./end-of-stream":107,dup:26}],110:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":98,dup:27}],111:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],112:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":99,"./lib/_stream_passthrough.js":100,"./lib/_stream_readable.js":101,"./lib/_stream_transform.js":102,"./lib/_stream_writable.js":103,"./lib/internal/streams/end-of-stream.js":107,"./lib/internal/streams/pipeline.js":109,dup:29}],113:[function(e,t,n){const{Readable:i}=e("readable-stream"),r=e("typedarray-to-buffer");t.exports=class extends i{constructor(e,t={}){super(t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800);const n=new FileReader;n.onload=()=>{this.push(r(n.result))},n.onerror=()=>{this.emit("error",n.error)},this.reader=n,this._generateHeaderBlocks(e,t,((e,t)=>{if(e)return this.emit("error",e);Array.isArray(t)&&t.forEach((e=>this.push(e))),this._ready=!0,this.emit("_ready")}))}_generateHeaderBlocks(e,t,n){n(null,[])}_read(){if(!this._ready)return void this.once("_ready",this._read.bind(this));const e=this._offset;let t=this._offset+this._chunkSize;if(t>this._size&&(t=this._size),e===this._size)return this.destroy(),void this.push(null);this.reader.readAsArrayBuffer(this._file.slice(e,t)),this._offset=t}destroy(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}}},{"readable-stream":112,"typedarray-to-buffer":298}],114:[function(e,t,n){t.exports=function(){if("undefined"==typeof globalThis)return null;var e={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],115:[function(e,t,n){var i=e("http"),r=e("url"),o=t.exports;for(var s in i)i.hasOwnProperty(s)&&(o[s]=i[s]);function a(e){if("string"==typeof e&&(e=r.parse(e)),e.protocol||(e.protocol="https:"),"https:"!==e.protocol)throw new Error('Protocol "'+e.protocol+'" not supported. Expected "https:"');return e}o.request=function(e,t){return e=a(e),i.request.call(this,e,t)},o.get=function(e,t){return e=a(e),i.get.call(this,e,t)}},{http:266,url:301}],116:[function(e,t,n){ +const r=e("bencode"),s=e("block-stream2"),o=e("piece-length"),a=e("path"),c=e("filestream/read"),u=e("is-file"),l=e("junk"),d=e("multistream"),f=e("once"),p=e("run-parallel"),h=e("queue-microtask"),m=e("simple-sha1"),b=e("readable-stream"),g=e("./get-files");function v(e){return e.reduce(((e,t)=>Array.isArray(t)?e.concat(v(t)):e.concat(t)),[])}function y(e,t,n){var r;if(r=e,"undefined"!=typeof FileList&&r instanceof FileList&&(e=Array.from(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");e.forEach((e=>{if(null==e)throw new Error(`invalid input type: ${e}`)})),1!==(e=e.map((e=>x(e)&&"string"==typeof e.path&&"function"==typeof g?e.path:e))).length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);let s=null;e.forEach(((t,n)=>{if("string"==typeof t)return;let i=t.fullPath||t.name;i||(i=`Unknown File ${n+1}`,t.unknownName=!0),t.path=i.split("/"),t.path[0]||t.path.shift(),t.path.length<2?s=null:0===n&&e.length>1?s=t.path[0]:t.path[0]!==s&&(s=null)}));(void 0===t.filterJunkFiles||t.filterJunkFiles)&&(e=e.filter((e=>"string"==typeof e||!_(e.path)))),s&&e.forEach((e=>{const t=(i.isBuffer(e)||k(e))&&!e.path;"string"==typeof e||t||e.path.shift()})),!t.name&&s&&(t.name=s),t.name||e.some((e=>"string"==typeof e?(t.name=a.basename(e),!0):!e.unknownName&&(t.name=e.path[e.path.length-1],!0))),t.name||(t.name=`Unnamed Torrent ${Date.now()}`);const o=e.reduce(((e,t)=>e+Number("string"==typeof t)),0);let l=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof g)throw new Error("filesystem paths do not work in the browser");u(e[0],((e,t)=>{if(e)return n(e);l=t,d()}))}else h(d);function d(){p(e.map((e=>t=>{const n={};if(x(e))n.getStream=function(e){return()=>new c(e)}(e),n.length=e.size;else if(i.isBuffer(e))n.getStream=(r=e,()=>{const e=new b.PassThrough;return e.end(r),e}),n.length=e.length;else{if(!k(e)){if("string"==typeof e){if("function"!=typeof g)throw new Error("filesystem paths do not work in the browser");return void g(e,o>1||l,t)}throw new Error("invalid input type")}n.getStream=function(e,t){return()=>{const n=new b.Transform;return n._transform=function(e,n,i){t.length+=e.length,this.push(e),i()},e.pipe(n),n}}(e,n),n.length=0}var r;n.path=e.path,t(null,n)})),((e,t)=>{if(e)return n(e);t=v(t),n(null,t,l)}))}}function _(e){const t=e[e.length-1];return"."===t[0]&&l.is(t)}function w(e,t){return e+t.length}function x(e){return"undefined"!=typeof Blob&&e instanceof Blob}function k(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}t.exports=function(e,a,c){"function"==typeof a&&([a,c]=[c,a]),y(e,a=a?Object.assign({},a):{},((e,u,l)=>{if(e)return c(e);a.singleFileTorrent=l,function(e,a,c){let u=a.announceList;u||("string"==typeof a.announce?u=[[a.announce]]:Array.isArray(a.announce)&&(u=a.announce.map((e=>[e]))));u||(u=[]);n.WEBTORRENT_ANNOUNCE&&("string"==typeof n.WEBTORRENT_ANNOUNCE?u.push([[n.WEBTORRENT_ANNOUNCE]]):Array.isArray(n.WEBTORRENT_ANNOUNCE)&&(u=u.concat(n.WEBTORRENT_ANNOUNCE.map((e=>[e])))));void 0===a.announce&&void 0===a.announceList&&(u=u.concat(t.exports.announceList));"string"==typeof a.urlList&&(a.urlList=[a.urlList]);const l={info:{name:a.name},"creation date":Math.ceil((Number(a.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==u.length&&(l.announce=u[0][0],l["announce-list"]=u);void 0!==a.comment&&(l.comment=a.comment);void 0!==a.createdBy&&(l["created by"]=a.createdBy);void 0!==a.private&&(l.info.private=Number(a.private));void 0!==a.info&&Object.assign(l.info,a.info);void 0!==a.sslCert&&(l.info["ssl-cert"]=a.sslCert);void 0!==a.urlList&&(l["url-list"]=a.urlList);const p=e.reduce(w,0),h=a.pieceLength||o(p);l.info["piece length"]=h,function(e,t,n,r,o){o=f(o);const a=[];let c=0,u=0;const l=e.map((e=>e.getStream));let p=0,h=0,b=!1;const g=new d(l),v=new s(t,{zeroPadding:!1});function y(e){c+=e.length;const t=h;m(e,(i=>{a[t]=i,p-=1,p<5&&v.resume(),u+=e.length,r.onProgress&&r.onProgress(u,n),k()})),p+=1,p>=5&&v.pause(),h+=1}function _(){b=!0,k()}function w(e){x(),o(e)}function x(){g.removeListener("error",w),v.removeListener("data",y),v.removeListener("end",_),v.removeListener("error",w)}function k(){b&&0===p&&(x(),o(null,i.from(a.join(""),"hex"),c))}g.on("error",w),g.pipe(v).on("data",y).on("end",_).on("error",w)}(e,h,p,a,((t,n,i)=>{if(t)return c(t);l.info.pieces=n,e.forEach((e=>{delete e.getStream})),a.singleFileTorrent?l.info.length=i:l.info.files=e,c(null,r.encode(l))}))}(u,a,c)}))},t.exports.parseInput=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),y(e,t=t?Object.assign({},t):{},n)},t.exports.announceList=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"]],t.exports.isJunkPath=_}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./get-files":71,bencode:22,"block-stream2":53,buffer:114,"filestream/read":211,"is-file":71,junk:248,multistream:301,once:318,path:325,"piece-length":332,"queue-microtask":346,"readable-stream":162,"run-parallel":374,"simple-sha1":407}],148:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],149:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":151,"./_stream_writable":153,_process:333,dup:31,inherits:245}],150:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":152,dup:32,inherits:245}],151:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":148,"./_stream_duplex":149,"./internal/streams/async_iterator":154,"./internal/streams/buffer_list":155,"./internal/streams/destroy":156,"./internal/streams/from":158,"./internal/streams/state":160,"./internal/streams/stream":161,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],152:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":148,"./_stream_duplex":149,dup:34,inherits:245}],153:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":148,"./_stream_duplex":149,"./internal/streams/destroy":156,"./internal/streams/state":160,"./internal/streams/stream":161,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],154:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":157,_process:333,dup:36}],155:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],156:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],157:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":148,dup:39}],158:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],159:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":148,"./end-of-stream":157,dup:41}],160:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":148,dup:42}],161:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],162:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":149,"./lib/_stream_passthrough.js":150,"./lib/_stream_readable.js":151,"./lib/_stream_transform.js":152,"./lib/_stream_writable.js":153,"./lib/internal/streams/end-of-stream.js":157,"./lib/internal/streams/pipeline.js":159,dup:44}],163:[function(e,t,n){"use strict";n.randomBytes=n.rng=n.pseudoRandomBytes=n.prng=e("randombytes"),n.createHash=n.Hash=e("create-hash"),n.createHmac=n.Hmac=e("create-hmac");var i=e("browserify-sign/algos"),r=Object.keys(i),s=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(r);n.getHashes=function(){return s};var o=e("pbkdf2");n.pbkdf2=o.pbkdf2,n.pbkdf2Sync=o.pbkdf2Sync;var a=e("browserify-cipher");n.Cipher=a.Cipher,n.createCipher=a.createCipher,n.Cipheriv=a.Cipheriv,n.createCipheriv=a.createCipheriv,n.Decipher=a.Decipher,n.createDecipher=a.createDecipher,n.Decipheriv=a.Decipheriv,n.createDecipheriv=a.createDecipheriv,n.getCiphers=a.getCiphers,n.listCiphers=a.listCiphers;var c=e("diffie-hellman");n.DiffieHellmanGroup=c.DiffieHellmanGroup,n.createDiffieHellmanGroup=c.createDiffieHellmanGroup,n.getDiffieHellman=c.getDiffieHellman,n.createDiffieHellman=c.createDiffieHellman,n.DiffieHellman=c.DiffieHellman;var u=e("browserify-sign");n.createSign=u.createSign,n.Sign=u.Sign,n.createVerify=u.createVerify,n.Verify=u.Verify,n.createECDH=e("create-ecdh");var l=e("public-encrypt");n.publicEncrypt=l.publicEncrypt,n.privateEncrypt=l.privateEncrypt,n.publicDecrypt=l.publicDecrypt,n.privateDecrypt=l.privateDecrypt;var d=e("randomfill");n.randomFill=d.randomFill,n.randomFillSync=d.randomFillSync,n.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},n.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":89,"browserify-sign":96,"browserify-sign/algos":93,"create-ecdh":141,"create-hash":143,"create-hmac":145,"diffie-hellman":170,pbkdf2:326,"public-encrypt":334,randombytes:348,randomfill:349}],164:[function(e,t,n){"use strict";n.utils=e("./des/utils"),n.Cipher=e("./des/cipher"),n.DES=e("./des/des"),n.CBC=e("./des/cbc"),n.EDE=e("./des/ede")},{"./des/cbc":165,"./des/cipher":166,"./des/des":167,"./des/ede":168,"./des/utils":169}],165:[function(e,t,n){"use strict";var i=e("minimalistic-assert"),r=e("inherits"),s={};function o(e){i.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t0;i--)t+=this._buffer(e,t),n+=this._flushBuffer(r,n);return t+=this._buffer(e,t),r},r.prototype.final=function(e){var t,n;return e&&(t=this.update(e)),n="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(n):n},r.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];n=s.r28shl(n,a),r=s.r28shl(r,a),s.pc2(n,r,e.keys,o)}},c.prototype._update=function(e,t,n,i){var r=this._desState,o=s.readUInt32BE(e,t),a=s.readUInt32BE(e,t+4);s.ip(o,a,r.tmp,0),o=r.tmp[0],a=r.tmp[1],"encrypt"===this.type?this._encrypt(r,o,a,r.tmp,0):this._decrypt(r,o,a,r.tmp,0),o=r.tmp[0],a=r.tmp[1],s.writeUInt32BE(n,o,i),s.writeUInt32BE(n,a,i+4)},c.prototype._pad=function(e,t){for(var n=e.length-t,i=t;i>>0,o=f}s.rip(a,o,i,r)},c.prototype._decrypt=function(e,t,n,i,r){for(var o=n,a=t,c=e.keys.length-2;c>=0;c-=2){var u=e.keys[c],l=e.keys[c+1];s.expand(o,e.tmp,0),u^=e.tmp[0],l^=e.tmp[1];var d=s.substitute(u,l),f=o;o=(a^s.permute(d))>>>0,a=f}s.rip(o,a,i,r)}},{"./cipher":166,"./utils":169,inherits:245,"minimalistic-assert":278}],168:[function(e,t,n){"use strict";var i=e("minimalistic-assert"),r=e("inherits"),s=e("./cipher"),o=e("./des");function a(e,t){i.equal(t.length,24,"Invalid key length");var n=t.slice(0,8),r=t.slice(8,16),s=t.slice(16,24);this.ciphers="encrypt"===e?[o.create({type:"encrypt",key:n}),o.create({type:"decrypt",key:r}),o.create({type:"encrypt",key:s})]:[o.create({type:"decrypt",key:s}),o.create({type:"encrypt",key:r}),o.create({type:"decrypt",key:n})]}function c(e){s.call(this,e);var t=new a(this.type,this.options.key);this._edeState=t}r(c,s),t.exports=c,c.create=function(e){return new c(e)},c.prototype._update=function(e,t,n,i){var r=this._edeState;r.ciphers[0]._update(e,t,n,i),r.ciphers[1]._update(n,i,n,i),r.ciphers[2]._update(n,i,n,i)},c.prototype._pad=o.prototype._pad,c.prototype._unpad=o.prototype._unpad},{"./cipher":166,"./des":167,inherits:245,"minimalistic-assert":278}],169:[function(e,t,n){"use strict";n.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},n.writeUInt32BE=function(e,t,n){e[0+n]=t>>>24,e[1+n]=t>>>16&255,e[2+n]=t>>>8&255,e[3+n]=255&t},n.ip=function(e,t,n,i){for(var r=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)r<<=1,r|=t>>>a+o&1;for(a=0;a<=24;a+=8)r<<=1,r|=e>>>a+o&1}for(o=6;o>=0;o-=2){for(a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1;for(a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1}n[i+0]=r>>>0,n[i+1]=s>>>0},n.rip=function(e,t,n,i){for(var r=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)r<<=1,r|=t>>>a+o&1,r<<=1,r|=e>>>a+o&1;for(o=4;o<8;o++)for(a=24;a>=0;a-=8)s<<=1,s|=t>>>a+o&1,s<<=1,s|=e>>>a+o&1;n[i+0]=r>>>0,n[i+1]=s>>>0},n.pc1=function(e,t,n,i){for(var r=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)r<<=1,r|=t>>a+o&1;for(a=0;a<=24;a+=8)r<<=1,r|=e>>a+o&1}for(a=0;a<=24;a+=8)r<<=1,r|=t>>a+o&1;for(o=1;o<=3;o++){for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1}for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;n[i+0]=r>>>0,n[i+1]=s>>>0},n.r28shl=function(e,t){return e<>>28-t};var i=[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];n.pc2=function(e,t,n,r){for(var s=0,o=0,a=i.length>>>1,c=0;c>>i[c]&1;for(c=a;c>>i[c]&1;n[r+0]=s>>>0,n[r+1]=o>>>0},n.expand=function(e,t,n){var i=0,r=0;i=(1&e)<<5|e>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=e>>>s&63;for(s=11;s>=3;s-=4)r|=e>>>s&63,r<<=6;r|=(31&e)<<1|e>>>31,t[n+0]=i>>>0,t[n+1]=r>>>0};var r=[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];n.substitute=function(e,t){for(var n=0,i=0;i<4;i++){n<<=4,n|=r[64*i+(e>>>18-6*i&63)]}for(i=0;i<4;i++){n<<=4,n|=r[256+64*i+(t>>>18-6*i&63)]}return n>>>0};var s=[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];n.permute=function(e){for(var t=0,n=0;n>>s[n]&1;return t>>>0},n.padSplit=function(e,t,n){for(var i=e.toString(2);i.lengthe;)n.ishrn(1);if(n.isEven()&&n.iadd(a),n.testn(1)||n.iadd(c),t.cmp(c)){if(!t.cmp(u))for(;n.mod(l).cmp(d);)n.iadd(p)}else for(;n.mod(s).cmp(f);)n.iadd(p);if(b(h=n.shrn(1))&&b(n)&&g(h)&&g(n)&&o.test(h)&&o.test(n))return n}}},{"bn.js":174,"miller-rabin":273,randombytes:348}],173:[function(e,t,n){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],174:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{buffer:71,dup:18}],175:[function(e,t,n){"use strict";var i=n;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec"),i.eddsa=e("./elliptic/eddsa")},{"../package.json":191,"./elliptic/curve":178,"./elliptic/curves":181,"./elliptic/ec":182,"./elliptic/eddsa":185,"./elliptic/utils":189,brorand:70}],176:[function(e,t,n){"use strict";var i=e("bn.js"),r=e("../utils"),s=r.getNAF,o=r.getJSF,a=r.assert;function c(e,t){this.type=e,this.p=new i(t.p,16),this.red=t.prime?i.red(t.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=t.n&&new i(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.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 u(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var n=e._getDoubles(),i=s(t,1,this._bitLength),r=(1<=o;l--)c=(c<<1)+i[l];u.push(c)}for(var d=this.jpoint(null,null,null),f=this.jpoint(null,null,null),p=r;p>0;p--){for(o=0;o=0;u--){for(var l=0;u>=0&&0===o[u];u--)l++;if(u>=0&&l++,c=c.dblp(l),u<0)break;var d=o[u];a(0!==d),c="affine"===e.type?d>0?c.mixedAdd(r[d-1>>1]):c.mixedAdd(r[-d-1>>1].neg()):d>0?c.add(r[d-1>>1]):c.add(r[-d-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,n,i,r){var a,c,u,l=this._wnafT1,d=this._wnafT2,f=this._wnafT3,p=0;for(a=0;a=1;a-=2){var m=a-1,b=a;if(1===l[m]&&1===l[b]){var g=[t[m],null,null,t[b]];0===t[m].y.cmp(t[b].y)?(g[1]=t[m].add(t[b]),g[2]=t[m].toJ().mixedAdd(t[b].neg())):0===t[m].y.cmp(t[b].y.redNeg())?(g[1]=t[m].toJ().mixedAdd(t[b]),g[2]=t[m].add(t[b].neg())):(g[1]=t[m].toJ().mixedAdd(t[b]),g[2]=t[m].toJ().mixedAdd(t[b].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],y=o(n[m],n[b]);for(p=Math.max(y[0].length,p),f[m]=new Array(p),f[b]=new Array(p),c=0;c=0;a--){for(var E=0;a>=0;){var S=!0;for(c=0;c=0&&E++,x=x.dblp(E),a<0)break;for(c=0;c0?u=d[c][M-1>>1]:M<0&&(u=d[c][-M-1>>1].neg()),x="affine"===u.type?x.mixedAdd(u):x.add(u))}}for(a=0;a=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,r=0;r":""},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(e),r=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),s=i.redAdd(t),o=s.redSub(n),a=i.redSub(t),c=r.redMul(o),u=s.redMul(a),l=r.redMul(a),d=o.redMul(s);return this.curve.point(c,u,d,l)},u.prototype._projDbl=function(){var e,t,n,i,r,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(i=this.curve._mulA(a)).redAdd(c);this.zOne?(e=o.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(i.redSub(c)),n=u.redSqr().redSub(u).redSub(u)):(r=this.z.redSqr(),s=u.redSub(r).redISub(r),e=o.redSub(a).redISub(c).redMul(s),t=u.redMul(i.redSub(c)),n=u.redMul(s))}else i=a.redAdd(c),r=this.curve._mulC(this.z).redSqr(),s=i.redSub(r).redSub(r),e=this.curve._mulC(o.redISub(i)).redMul(s),t=this.curve._mulC(i).redMul(a.redISub(c)),n=i.redMul(s);return this.curve.point(e,t,n)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),r=this.z.redMul(e.z.redAdd(e.z)),s=n.redSub(t),o=r.redSub(i),a=r.redAdd(i),c=n.redAdd(t),u=s.redMul(o),l=a.redMul(c),d=s.redMul(c),f=o.redMul(a);return this.curve.point(u,l,f,d)},u.prototype._projAdd=function(e){var t,n,i=this.z.redMul(e.z),r=i.redSqr(),s=this.x.redMul(e.x),o=this.y.redMul(e.y),a=this.curve.d.redMul(s).redMul(o),c=r.redSub(a),u=r.redAdd(a),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(s).redISub(o),d=i.redMul(c).redMul(l);return this.curve.twisted?(t=i.redMul(u).redMul(o.redSub(this.curve._mulA(s))),n=c.redMul(u)):(t=i.redMul(u).redMul(o.redSub(s)),n=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,n)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},u.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},{"../utils":189,"./base":176,"bn.js":190,inherits:245}],178:[function(e,t,n){"use strict";var i=n;i.base=e("./base"),i.short=e("./short"),i.mont=e("./mont"),i.edwards=e("./edwards")},{"./base":176,"./edwards":177,"./mont":179,"./short":180}],179:[function(e,t,n){"use strict";var i=e("bn.js"),r=e("inherits"),s=e("./base"),o=e("../utils");function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){s.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}r(a,s),t.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),i=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},r(c,s.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(o.toArray(e,t),1)},a.prototype.point=function(e,t){return new c(this,e,t)},a.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),i=e.redMul(t),r=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(i,r)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),i=this.x.redSub(this.z),r=e.x.redAdd(e.z),s=e.x.redSub(e.z).redMul(n),o=r.redMul(i),a=t.z.redMul(s.redAdd(o).redSqr()),c=t.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(e){for(var t=e.clone(),n=this,i=this.curve.point(null,null),r=[];0!==t.cmpn(0);t.iushrn(1))r.push(t.andln(1));for(var s=r.length-1;s>=0;s--)0===r[s]?(n=n.diffAdd(i,this),i=i.dbl()):(i=n.diffAdd(i,this),n=n.dbl());return i},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":189,"./base":176,"bn.js":190,inherits:245}],180:[function(e,t,n){"use strict";var i=e("../utils"),r=e("bn.js"),s=e("inherits"),o=e("./base"),a=i.assert;function c(e){o.call(this,"short",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.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(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,n,i){o.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new r(t,16),this.y=new r(n,16),i&&(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 l(e,t,n,i){o.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new r(0)):(this.x=new r(t,16),this.y=new r(n,16),this.z=new r(i,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}s(c,o),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new r(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=(t=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(e.lambda)n=new r(e.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))?n=s[0]:(n=s[1],a(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:n,basis:e.basis?e.basis.map((function(e){return{a:new r(e.a,16),b:new r(e.b,16)}})):this._getEndoBasis(n)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:r.mont(e),n=new r(2).toRed(t).redInvm(),i=n.redNeg(),s=new r(3).toRed(t).redNeg().redSqrt().redMul(n);return[i.redAdd(s).fromRed(),i.redSub(s).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,n,i,s,o,a,c,u,l,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,p=this.n.clone(),h=new r(1),m=new r(0),b=new r(0),g=new r(1),v=0;0!==f.cmpn(0);){var y=p.div(f);u=p.sub(y.mul(f)),l=b.sub(y.mul(h));var _=g.sub(y.mul(m));if(!i&&u.cmp(d)<0)t=c.neg(),n=h,i=u.neg(),s=l;else if(i&&2==++v)break;c=u,p=f,f=u,b=h,h=l,g=m,m=_}o=u.neg(),a=l;var w=i.sqr().add(s.sqr());return o.sqr().add(a.sqr()).cmp(w)>=0&&(o=t,a=n),i.negative&&(i=i.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:s},{a:o,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],i=t[1],r=i.b.mul(e).divRound(this.n),s=n.b.neg().mul(e).divRound(this.n),o=r.mul(n.a),a=s.mul(i.a),c=r.mul(n.b),u=s.mul(i.b);return{k1:e.sub(o).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new r(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(0!==i.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,i=this.a.redMul(t),r=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===n.redSqr().redISub(r).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,n){for(var i=this._endoWnafT1,r=this._endoWnafT2,s=0;s":""},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),r=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(i),s=r.redSqr().redISub(this.x.redAdd(this.x)),o=r.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new r(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){var i=[this,t],r=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,r):this.curve._wnafMulAdd(1,i,r,2)},u.prototype.jmulAdd=function(e,t,n){var i=[this,t],r=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,r,!0):this.curve._wnafMulAdd(1,i,r,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(l,o.BasePoint),c.prototype.jpoint=function(e,t,n){return new l(this,e,t,n)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(n,i)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(t),r=e.x.redMul(n),s=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(n.redMul(this.z)),a=i.redSub(r),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),d=i.redMul(u),f=c.redSqr().redIAdd(l).redISub(d).redISub(d),p=c.redMul(d.redISub(f)).redISub(s.redMul(l)),h=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(f,p,h)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,i=e.x.redMul(t),r=this.y,s=e.y.redMul(t).redMul(this.z),o=n.redSub(i),a=r.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),u=c.redMul(o),l=n.redMul(c),d=a.redSqr().redIAdd(u).redISub(l).redISub(l),f=a.redMul(l.redISub(d)).redISub(r.redMul(u)),p=this.z.redMul(o);return this.curve.jpoint(d,f,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t=0)return!1;if(n.redIAdd(r),0===this.x.cmp(n))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":189,"./base":176,"bn.js":190,inherits:245}],181:[function(e,t,n){"use strict";var i,r=n,s=e("hash.js"),o=e("./curve"),a=e("./utils").assert;function c(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var n=new c(t);return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=c,u("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:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("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:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("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:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("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:s.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"]}),u("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:s.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"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),u("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:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=e("./precomputed/secp256k1")}catch(e){i=void 0}u("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:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},{"./curve":178,"./precomputed/secp256k1":188,"./utils":189,"hash.js":229}],182:[function(e,t,n){"use strict";var i=e("bn.js"),r=e("hmac-drbg"),s=e("../utils"),o=e("../curves"),a=e("brorand"),c=s.assert,u=e("./key"),l=e("./signature");function d(e){if(!(this instanceof d))return new d(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(o,e),"Unknown curve "+e),e=o[e]),e instanceof o.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=d,d.prototype.keyPair=function(e){return new u(this,e)},d.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},d.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},d.prototype.genKeyPair=function(e){e||(e={});for(var t=new r({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||a(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),s=this.n.sub(new i(2));;){var o=new i(t.generate(n));if(!(o.cmp(s)>0))return o.iaddn(1),this.keyFromPrivate(o)}},d.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,n,s){"object"==typeof n&&(s=n,n=null),s||(s={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new i(e,16));for(var o=this.n.byteLength(),a=t.getPrivate().toArray("be",o),c=e.toArray("be",o),u=new r({hash:this.hash,entropy:a,nonce:c,pers:s.pers,persEnc:s.persEnc||"utf8"}),d=this.n.sub(new i(1)),f=0;;f++){var p=s.k?s.k(f):new i(u.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(d)>=0)){var h=this.g.mul(p);if(!h.isInfinity()){var m=h.getX(),b=m.umod(this.n);if(0!==b.cmpn(0)){var g=p.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var v=(h.getY().isOdd()?1:0)|(0!==m.cmp(b)?2:0);return s.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),v^=1),new l({r:b,s:g,recoveryParam:v})}}}}}},d.prototype.verify=function(e,t,n,r){e=this._truncateToN(new i(e,16)),n=this.keyFromPublic(n,r);var s=(t=new l(t,"hex")).r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,c=o.invm(this.n),u=c.mul(e).umod(this.n),d=c.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,n.getPublic(),d)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(u,n.getPublic(),d)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},d.prototype.recoverPubKey=function(e,t,n,r){c((3&n)===n,"The recovery param is more than two bits"),t=new l(t,r);var s=this.n,o=new i(e),a=t.r,u=t.s,d=1&n,f=n>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");a=f?this.curve.pointFromX(a.add(this.curve.n),d):this.curve.pointFromX(a,d);var p=t.r.invm(s),h=s.sub(o).mul(p).umod(s),m=u.mul(p).umod(s);return this.g.mulAdd(h,a,m)},d.prototype.getKeyRecoveryParam=function(e,t,n,i){if(null!==(t=new l(t,i)).recoveryParam)return t.recoveryParam;for(var r=0;r<4;r++){var s;try{s=this.recoverPubKey(e,t,r)}catch(e){continue}if(s.eq(n))return r}throw new Error("Unable to find valid recovery factor")}},{"../curves":181,"../utils":189,"./key":183,"./signature":184,"bn.js":190,brorand:70,"hmac-drbg":241}],183:[function(e,t,n){"use strict";var i=e("bn.js"),r=e("../utils").assert;function s(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=s,s.fromPublic=function(e,t,n){return t instanceof s?t:new s(e,{pub:t,pubEnc:n})},s.fromPrivate=function(e,t,n){return t instanceof s?t:new s(e,{priv:t,privEnc:n})},s.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.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"}},s.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},s.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},s.prototype._importPrivate=function(e,t){this.priv=new i(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},s.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?r(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||r(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},s.prototype.derive=function(e){return e.validate()||r(e.validate(),"public point not validated"),e.mul(this.priv).getX()},s.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},s.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},s.prototype.inspect=function(){return""}},{"../utils":189,"bn.js":190}],184:[function(e,t,n){"use strict";var i=e("bn.js"),r=e("../utils"),s=r.assert;function o(e,t){if(e instanceof o)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new i(e.r,16),this.s=new i(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function c(e,t){var n=e[t.place++];if(!(128&n))return n;var i=15&n;if(0===i||i>4)return!1;for(var r=0,s=0,o=t.place;s>>=0;return!(r<=127)&&(t.place=o,r)}function u(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}t.exports=o,o.prototype._importDER=function(e,t){e=r.toArray(e,t);var n=new a;if(48!==e[n.place++])return!1;var s=c(e,n);if(!1===s)return!1;if(s+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var o=c(e,n);if(!1===o)return!1;var u=e.slice(n.place,o+n.place);if(n.place+=o,2!==e[n.place++])return!1;var l=c(e,n);if(!1===l)return!1;if(e.length!==l+n.place)return!1;var d=e.slice(n.place,l+n.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new i(u),this.s=new i(d),this.recoveryParam=null,!0},o.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=u(t),n=u(n);!(n[0]||128&n[1]);)n=n.slice(1);var i=[2];l(i,t.length),(i=i.concat(t)).push(2),l(i,n.length);var s=i.concat(n),o=[48];return l(o,s.length),o=o.concat(s),r.encode(o,e)}},{"../utils":189,"bn.js":190}],185:[function(e,t,n){"use strict";var i=e("hash.js"),r=e("../curves"),s=e("../utils"),o=s.assert,a=s.parseBytes,c=e("./key"),u=e("./signature");function l(e){if(o("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=r[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=i.sha512}t.exports=l,l.prototype.sign=function(e,t){e=a(e);var n=this.keyFromSecret(t),i=this.hashInt(n.messagePrefix(),e),r=this.g.mul(i),s=this.encodePoint(r),o=this.hashInt(s,n.pubBytes(),e).mul(n.priv()),c=i.add(o).umod(this.curve.n);return this.makeSignature({R:r,S:c,Rencoded:s})},l.prototype.verify=function(e,t,n){e=a(e),t=this.makeSignature(t);var i=this.keyFromPublic(n),r=this.hashInt(t.Rencoded(),i.pubBytes(),e),s=this.g.mul(t.S());return t.R().add(i.pub().mul(r)).eq(s)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t(r>>1)-1?(r>>1)-c:c,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},i.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var i,r=0,s=0;e.cmpn(-r)>0||t.cmpn(-s)>0;){var o,a,c=e.andln(3)+r&3,u=t.andln(3)+s&3;3===c&&(c=-1),3===u&&(u=-1),o=0==(1&c)?0:3!==(i=e.andln(7)+r&7)&&5!==i||2!==u?c:-c,n[0].push(o),a=0==(1&u)?0:3!==(i=t.andln(7)+s&7)&&5!==i||2!==c?u:-u,n[1].push(a),2*r===o+1&&(r=1-r),2*s===a+1&&(s=1-s),e.iushrn(1),t.iushrn(1)}return n},i.cachedProperty=function(e,t,n){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=n.call(this)}},i.parseBytes=function(e){return"string"==typeof e?i.toArray(e,"hex"):e},i.intFromLE=function(e){return new r(e,"hex","le")}},{"bn.js":190,"minimalistic-assert":278,"minimalistic-crypto-utils":279}],190:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{buffer:71,dup:18}],191:[function(e,t,n){t.exports={name:"elliptic",version:"6.5.4",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}},{}],192:[function(e,t,n){(function(n){(function(){var i=e("once"),r=function(){},s=function(e,t,o){if("function"==typeof t)return s(e,null,t);t||(t={}),o=i(o||r);var a=e._writableState,c=e._readableState,u=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,d=!1,f=function(){e.writable||p()},p=function(){l=!1,u||o.call(e)},h=function(){u=!1,l||o.call(e)},m=function(t){o.call(e,t?new Error("exited with error code: "+t):null)},b=function(t){o.call(e,t)},g=function(){n.nextTick(v)},v=function(){if(!d)return(!u||c&&c.ended&&!c.destroyed)&&(!l||a&&a.ended&&!a.destroyed)?void 0:o.call(e,new Error("premature close"))},y=function(){e.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!a&&(e.on("end",f),e.on("close",f)):(e.on("complete",p),e.on("abort",g),e.req?y():e.on("request",y)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",h),e.on("finish",p),!1!==t.error&&e.on("error",b),e.on("close",g),function(){d=!0,e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",p),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",p),e.removeListener("exit",m),e.removeListener("end",h),e.removeListener("error",b),e.removeListener("close",g)}};t.exports=s}).call(this)}).call(this,e("_process"))},{_process:333,once:318}],193:[function(e,t,n){"use strict";function i(e,t){for(const n in t)Object.defineProperty(e,n,{value:t[n],enumerable:!0,configurable:!0});return e}t.exports=function(e,t,n){if(!e||"string"==typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"==typeof t&&(n=t,t=""),t&&(n.code=t);try{return i(e,n)}catch(t){n.message=e.message,n.stack=e.stack;const r=function(){};r.prototype=Object.create(Object.getPrototypeOf(e));return i(new r,n)}}},{}],194:[function(e,t,n){"use strict";var i,r="object"==typeof Reflect?Reflect:null,s=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};i=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 o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(e,t){return new Promise((function(n,i){function r(n){e.removeListener(t,s),i(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}g(e,t,s,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&g(e,"error",t,n)}(e,r,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function d(e,t,n,i){var r,s,o,a;if(u(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=l(e))>0&&o.length>r&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function f(){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 p(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=f.bind(i);return r.listener=n,i.wrapFn=r,r}function h(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=r[e];if(void 0===c)return!1;if("function"==typeof c)s(c,this,t);else{var u=c.length,l=b(c,u);for(n=0;n=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},{}],195:[function(e,t,n){var i=e("safe-buffer").Buffer,r=e("md5.js");t.exports=function(e,t,n,s){if(i.isBuffer(e)||(e=i.from(e,"binary")),t&&(i.isBuffer(t)||(t=i.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=n/8,a=i.alloc(o),c=i.alloc(s||0),u=i.alloc(0);o>0||s>0;){var l=new r;l.update(u),l.update(e),t&&l.update(t),u=l.digest();var d=0;if(o>0){var f=a.length-o;d=Math.min(o,u.length),u.copy(a,f,0,d),o-=d}if(d0){var p=c.length-s,h=Math.min(s,u.length-d);u.copy(c,p,d,d+h),s-=h}}return u.fill(0),{key:a,iv:c}}},{"md5.js":255,"safe-buffer":376}],196:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],197:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":199,"./_stream_writable":201,_process:333,dup:31,inherits:245}],198:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":200,dup:32,inherits:245}],199:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,"./internal/streams/async_iterator":202,"./internal/streams/buffer_list":203,"./internal/streams/destroy":204,"./internal/streams/from":206,"./internal/streams/state":208,"./internal/streams/stream":209,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],200:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,dup:34,inherits:245}],201:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,"./internal/streams/destroy":204,"./internal/streams/state":208,"./internal/streams/stream":209,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],202:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":205,_process:333,dup:36}],203:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],204:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],205:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":196,dup:39}],206:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],207:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":196,"./end-of-stream":205,dup:41}],208:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":196,dup:42}],209:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],210:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":197,"./lib/_stream_passthrough.js":198,"./lib/_stream_readable.js":199,"./lib/_stream_transform.js":200,"./lib/_stream_writable.js":201,"./lib/internal/streams/end-of-stream.js":205,"./lib/internal/streams/pipeline.js":207,dup:44}],211:[function(e,t,n){const{Readable:i}=e("readable-stream"),r=e("typedarray-to-buffer");t.exports=class extends i{constructor(e,t={}){super(t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800);const n=new FileReader;n.onload=()=>{this.push(r(n.result))},n.onerror=()=>{this.emit("error",n.error)},this.reader=n,this._generateHeaderBlocks(e,t,((e,t)=>{if(e)return this.emit("error",e);Array.isArray(t)&&t.forEach((e=>this.push(e))),this._ready=!0,this.emit("_ready")}))}_generateHeaderBlocks(e,t,n){n(null,[])}_read(){if(!this._ready)return void this.once("_ready",this._read.bind(this));const e=this._offset;let t=this._offset+this._chunkSize;if(t>this._size&&(t=this._size),e===this._size)return this.destroy(),void this.push(null);this.reader.readAsArrayBuffer(this._file.slice(e,t)),this._offset=t}destroy(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}}},{"readable-stream":210,"typedarray-to-buffer":476}],212:[function(e,t,n){t.exports=function(){if("undefined"==typeof globalThis)return null;var e={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],213:[function(e,t,n){"use strict";var i=e("safe-buffer").Buffer,r=e("readable-stream").Transform;function s(e){r.call(this),this._block=i.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(s,r),s.prototype._transform=function(e,t,n){var i=null;try{this.update(e,t)}catch(e){i=e}n(i)},s.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},s.prototype.update=function(e,t){if(function(e,t){if(!i.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");i.isBuffer(e)||(e=i.from(e,t));for(var n=this._block,r=0;this._blockOffset+e.length-r>=this._blockSize;){for(var s=this._blockOffset;s0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},s.prototype._update=function(){throw new Error("_update is not implemented")},s.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},s.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=s},{inherits:245,"readable-stream":228,"safe-buffer":376}],214:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],215:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":217,"./_stream_writable":219,_process:333,dup:31,inherits:245}],216:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":218,dup:32,inherits:245}],217:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":214,"./_stream_duplex":215,"./internal/streams/async_iterator":220,"./internal/streams/buffer_list":221,"./internal/streams/destroy":222,"./internal/streams/from":224,"./internal/streams/state":226,"./internal/streams/stream":227,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],218:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":214,"./_stream_duplex":215,dup:34,inherits:245}],219:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":214,"./_stream_duplex":215,"./internal/streams/destroy":222,"./internal/streams/state":226,"./internal/streams/stream":227,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],220:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":223,_process:333,dup:36}],221:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],222:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],223:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":214,dup:39}],224:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],225:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":214,"./end-of-stream":223,dup:41}],226:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":214,dup:42}],227:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],228:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":215,"./lib/_stream_passthrough.js":216,"./lib/_stream_readable.js":217,"./lib/_stream_transform.js":218,"./lib/_stream_writable.js":219,"./lib/internal/streams/end-of-stream.js":223,"./lib/internal/streams/pipeline.js":225,dup:44}],229:[function(e,t,n){var i=n;i.utils=e("./hash/utils"),i.common=e("./hash/common"),i.sha=e("./hash/sha"),i.ripemd=e("./hash/ripemd"),i.hmac=e("./hash/hmac"),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},{"./hash/common":230,"./hash/hmac":231,"./hash/ripemd":232,"./hash/sha":233,"./hash/utils":240}],230:[function(e,t,n){"use strict";var i=e("./utils"),r=e("minimalistic-assert");function s(){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}n.BlockHash=s,s.prototype.update=function(e,t){if(e=i.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=i.join32(e,0,e.length-n,this.endian);for(var r=0;r>>24&255,i[r++]=e>>>16&255,i[r++]=e>>>8&255,i[r++]=255&e}else for(i[r++]=255&e,i[r++]=e>>>8&255,i[r++]=e>>>16&255,i[r++]=e>>>24&255,i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=0,s=8;sthis.blockSize&&(e=(new this.Hash).update(e).digest()),r(e.length<=this.blockSize);for(var t=e.length;t>>3},n.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},{"../utils":240}],240:[function(e,t,n){"use strict";var i=e("minimalistic-assert"),r=e("inherits");function s(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}n.inherits=r,n.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),r=0;r>6|192,n[i++]=63&o|128):s(e,r)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),n[i++]=o>>18|240,n[i++]=o>>12&63|128,n[i++]=o>>6&63|128,n[i++]=63&o|128):(n[i++]=o>>12|224,n[i++]=o>>6&63|128,n[i++]=63&o|128)}else for(r=0;r>>0}return o},n.split32=function(e,t){for(var n=new Array(4*e.length),i=0,r=0;i>>24,n[r+1]=s>>>16&255,n[r+2]=s>>>8&255,n[r+3]=255&s):(n[r+3]=s>>>24,n[r+2]=s>>>16&255,n[r+1]=s>>>8&255,n[r]=255&s)}return n},n.rotr32=function(e,t){return e>>>t|e<<32-t},n.rotl32=function(e,t){return e<>>32-t},n.sum32=function(e,t){return e+t>>>0},n.sum32_3=function(e,t,n){return e+t+n>>>0},n.sum32_4=function(e,t,n,i){return e+t+n+i>>>0},n.sum32_5=function(e,t,n,i,r){return e+t+n+i+r>>>0},n.sum64=function(e,t,n,i){var r=e[t],s=i+e[t+1]>>>0,o=(s>>0,e[t+1]=s},n.sum64_hi=function(e,t,n,i){return(t+i>>>0>>0},n.sum64_lo=function(e,t,n,i){return t+i>>>0},n.sum64_4_hi=function(e,t,n,i,r,s,o,a){var c=0,u=t;return c+=(u=u+i>>>0)>>0)>>0)>>0},n.sum64_4_lo=function(e,t,n,i,r,s,o,a){return t+i+s+a>>>0},n.sum64_5_hi=function(e,t,n,i,r,s,o,a,c,u){var l=0,d=t;return l+=(d=d+i>>>0)>>0)>>0)>>0)>>0},n.sum64_5_lo=function(e,t,n,i,r,s,o,a,c,u){return t+i+s+a+u>>>0},n.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},n.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},n.shr64_hi=function(e,t,n){return e>>>n},n.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0}},{inherits:245,"minimalistic-assert":278}],241:[function(e,t,n){"use strict";var i=e("hash.js"),r=e("minimalistic-crypto-utils"),s=e("minimalistic-assert");function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=r.toArray(e.entropy,e.entropyEnc||"hex"),n=r.toArray(e.nonce,e.nonceEnc||"hex"),i=r.toArray(e.pers,e.persEnc||"hex");s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,i)}t.exports=o,o.prototype._init=function(e,t,n){var i=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var r=0;r=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},o.prototype.generate=function(e,t,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=n,n=t,t=null),n&&(n=r.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length */ -n.read=function(e,t,n,i,r){var o,s,a=8*r-i-1,c=(1<>1,p=-7,u=n?r-1:0,d=n?-1:1,f=e[t+u];for(u+=d,o=f&(1<<-p)-1,f>>=-p,p+=a;p>0;o=256*o+e[t+u],u+=d,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=i;p>0;s=256*s+e[t+u],u+=d,p-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,i),o-=l}return(f?-1:1)*s*Math.pow(2,o-i)},n.write=function(e,t,n,i,r,o){var s,a,c,l=8*o-r-1,p=(1<>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,h=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=p):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?d/c:d*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=p?(a=0,s=p):s+u>=1?(a=(t*c-1)*Math.pow(2,r),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;e[n+f]=255&a,f+=h,a/=256,r-=8);for(s=s<0;e[n+f]=255&s,f+=h,s/=256,l-=8);e[n+f-h]|=128*m}},{}],117:[function(e,t,n){ +n.read=function(e,t,n,i,r){var s,o,a=8*r-i-1,c=(1<>1,l=-7,d=n?r-1:0,f=n?-1:1,p=e[t+d];for(d+=f,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=256*s+e[t+d],d+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=i;l>0;o=256*o+e[t+d],d+=f,l-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,i),s-=u}return(p?-1:1)*o*Math.pow(2,s-i)},n.write=function(e,t,n,i,r,s){var o,a,c,u=8*s-r-1,l=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:s-1,h=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[n+p]=255&a,p+=h,a/=256,r-=8);for(o=o<0;e[n+p]=255&o,p+=h,o/=256,u-=8);e[n+p-h]|=128*m}},{}],244:[function(e,t,n){ /*! immediate-chunk-store. MIT License. Feross Aboukhadijeh */ -const i=e("queue-microtask");t.exports=class{constructor(e){if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}put(e,t,n=(()=>{})){this.mem[e]=t,this.store.put(e,t,(t=>{this.mem[e]=null,n(t)}))}get(e,t,n=(()=>{})){if("function"==typeof t)return this.get(e,null,t);let r=this.mem[e];if(!r)return this.store.get(e,t,n);t||(t={});const o=t.offset||0,s=t.length||r.length-o;0===o&&s===r.length||(r=r.slice(o,s+o)),i((()=>n(null,r)))}close(e=(()=>{})){this.store.close(e)}destroy(e=(()=>{})){this.store.destroy(e)}}},{"queue-microtask":195}],118:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],119:[function(e,t,n){t.exports=function(e){for(var t=0,n=e.length;t127)return!1;return!0}},{}],120:[function(e,t,n){t.exports=o,o.strict=s,o.loose=a;var i=Object.prototype.toString,r={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function o(e){return s(e)||a(e)}function s(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function a(e){return r[i.call(e)]}},{}],121:[function(e,t,n){"use strict";n.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},n.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),n.is=e=>n.regex.test(e),n.not=e=>!n.is(e),n.default=t.exports},{}],122:[function(e,t,n){(function(n){(function(){ +const i=e("queue-microtask");t.exports=class{constructor(e){if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}put(e,t,n=(()=>{})){this.mem[e]=t,this.store.put(e,t,(t=>{this.mem[e]=null,n(t)}))}get(e,t,n=(()=>{})){if("function"==typeof t)return this.get(e,null,t);let r=this.mem[e];if(!r)return this.store.get(e,t,n);t||(t={});const s=t.offset||0,o=t.length||r.length-s;0===s&&o===r.length||(r=r.slice(s,o+s)),i((()=>n(null,r)))}close(e=(()=>{})){this.store.close(e)}destroy(e=(()=>{})){this.store.destroy(e)}}},{"queue-microtask":346}],245:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],246:[function(e,t,n){t.exports=function(e){for(var t=0,n=e.length;t127)return!1;return!0}},{}],247:[function(e,t,n){t.exports=s,s.strict=o,s.loose=a;var i=Object.prototype.toString,r={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function s(e){return o(e)||a(e)}function o(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function a(e){return r[i.call(e)]}},{}],248:[function(e,t,n){"use strict";n.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},n.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),n.is=e=>n.regex.test(e),n.not=e=>!n.is(e),n.default=t.exports},{}],249:[function(e,t,n){var i=e("events"),r=e("inherits");function s(e){if(!(this instanceof s))return new s(e);"number"==typeof e&&(e={max:e}),e||(e={}),i.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=e.max||1e3,this.maxAge=e.maxAge||0}t.exports=s,r(s,i.EventEmitter),Object.defineProperty(s.prototype,"keys",{get:function(){return Object.keys(this.cache)}}),s.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},s.prototype.remove=function(e){if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){var t=this.cache[e];return delete this.cache[e],this._unlink(e,t.prev,t.next),t.value}},s.prototype._unlink=function(e,t,n){this.length--,0===this.length?this.head=this.tail=null:this.head===e?(this.head=t,this.cache[this.head].next=null):this.tail===e?(this.tail=n,this.cache[this.tail].prev=null):(this.cache[t].next=n,this.cache[n].prev=t)},s.prototype.peek=function(e){if(this.cache.hasOwnProperty(e)){var t=this.cache[e];if(this._checkAge(e,t))return t.value}},s.prototype.set=function(e,t){var n;if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){if((n=this.cache[e]).value=t,this.maxAge&&(n.modified=Date.now()),e===this.head)return t;this._unlink(e,n.prev,n.next)}else n={value:t,modified:0,next:null,prev:null},this.maxAge&&(n.modified=Date.now()),this.cache[e]=n,this.length===this.max&&this.evict();return this.length++,n.next=null,n.prev=this.head,this.head&&(this.cache[this.head].next=e),this.head=e,this.tail||(this.tail=e),t},s.prototype._checkAge=function(e,t){return!(this.maxAge&&Date.now()-t.modified>this.maxAge)||(this.remove(e),this.emit("evict",{key:e,value:t.value}),!1)},s.prototype.get=function(e){if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){var t=this.cache[e];if(this._checkAge(e,t))return this.head!==e&&(e===this.tail?(this.tail=t.next,this.cache[this.tail].prev=null):this.cache[t.prev].next=t.next,this.cache[t.next].prev=t.prev,this.cache[this.head].next=e,t.prev=this.head,t.next=null,this.head=e),t.value}},s.prototype.evict=function(){if(this.tail){var e=this.tail,t=this.remove(this.tail);this.emit("evict",{key:e,value:t})}}},{events:194,inherits:245}],250:[function(e,t,n){(function(n){(function(){ /*! lt_donthave. MIT License. WebTorrent LLC */ -const i=e("unordered-array-remove"),{EventEmitter:r}=e("events"),o=e("debug")("lt_donthave");t.exports=()=>{class e extends r{constructor(e){super(),this._peerSupports=!1,this._wire=e}onExtendedHandshake(){this._peerSupports=!0}onMessage(e){let t;try{t=e.readUInt32BE()}catch(e){return}this._wire.peerPieces.get(t)&&(o("got donthave %d",t),this._wire.peerPieces.set(t,!1),this.emit("donthave",t),this._failRequests(t))}donthave(e){if(!this._peerSupports)return;o("donthave %d",e);const t=n.alloc(4);t.writeUInt32BE(e),this._wire.extended("lt_donthave",t)}_failRequests(e){const t=this._wire.requests;for(let n=0;n{class e extends r{constructor(e){super(),this._peerSupports=!1,this._wire=e}onExtendedHandshake(){this._peerSupports=!0}onMessage(e){let t;try{t=e.readUInt32BE()}catch(e){return}this._wire.peerPieces.get(t)&&(s("got donthave %d",t),this._wire.peerPieces.set(t,!1),this.emit("donthave",t),this._failRequests(t))}donthave(e){if(!this._peerSupports)return;s("donthave %d",e);const t=n.alloc(4);t.writeUInt32BE(e),this._wire.extended("lt_donthave",t)}_failRequests(e){const t=this._wire.requests;for(let n=0;n */ -t.exports=o,t.exports.decode=o,t.exports.encode=function(e){e=Object.assign({},e);let t=new Set;e.xt&&"string"==typeof e.xt&&t.add(e.xt);e.xt&&Array.isArray(e.xt)&&(t=new Set(e.xt));e.infoHashBuffer&&t.add(`urn:btih:${e.infoHashBuffer.toString("hex")}`);e.infoHash&&t.add(`urn:btih:${e.infoHash}`);e.infoHashV2Buffer&&t.add(e.xt=`urn:btmh:1220${e.infoHashV2Buffer.toString("hex")}`);e.infoHashV2&&t.add(`urn:btmh:1220${e.infoHashV2}`);const n=Array.from(t);1===n.length&&(e.xt=n[0]);n.length>1&&(e.xt=n);e.publicKeyBuffer&&(e.xs=`urn:btpk:${e.publicKeyBuffer.toString("hex")}`);e.publicKey&&(e.xs=`urn:btpk:${e.publicKey}`);e.name&&(e.dn=e.name);e.keywords&&(e.kt=e.keywords);e.announce&&(e.tr=e.announce);e.urlList&&(e.ws=e.urlList,delete e.as);e.peerAddresses&&(e["x.pe"]=e.peerAddresses);let i="magnet:?";return Object.keys(e).filter((e=>2===e.length||"x.pe"===e)).forEach(((t,n)=>{const o=Array.isArray(e[t])?e[t]:[e[t]];o.forEach(((e,r)=>{(n>0||r>0)&&("kt"!==t&&"so"!==t||0===r)&&(i+="&"),"dn"===t&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==t&&"as"!==t&&"ws"!==t||(e=encodeURIComponent(e)),"xs"!==t||e.startsWith("urn:btpk:")||(e=encodeURIComponent(e)),"kt"===t&&(e=encodeURIComponent(e)),"so"!==t&&(i+="kt"===t&&r>0?`+${e}`:`${t}=${e}`)})),"so"===t&&(i+=`${t}=${r.compose(o)}`)})),i};const i=e("thirty-two"),r=e("bep53-range");function o(e){const t={},o=e.split("magnet:?")[1];let s;if((o&&o.length>=0?o.split("&"):[]).forEach((e=>{const n=e.split("=");if(2!==n.length)return;const i=n[0];let o=n[1];"dn"===i&&(o=decodeURIComponent(o).replace(/\+/g," ")),"tr"!==i&&"xs"!==i&&"as"!==i&&"ws"!==i||(o=decodeURIComponent(o)),"kt"===i&&(o=decodeURIComponent(o).split("+")),"ix"===i&&(o=Number(o)),"so"===i&&(o=r.parse(decodeURIComponent(o).split(","))),t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(o)):t[i]=o})),t.xt){(Array.isArray(t.xt)?t.xt:[t.xt]).forEach((e=>{if(s=e.match(/^urn:btih:(.{40})/))t.infoHash=s[1].toLowerCase();else if(s=e.match(/^urn:btih:(.{32})/)){const e=i.decode(s[1]);t.infoHash=n.from(e,"binary").toString("hex")}else(s=e.match(/^urn:btmh:1220(.{64})/))&&(t.infoHashV2=s[1].toLowerCase())}))}if(t.xs){(Array.isArray(t.xs)?t.xs:[t.xs]).forEach((e=>{(s=e.match(/^urn:btpk:(.{64})/))&&(t.publicKey=s[1].toLowerCase())}))}return t.infoHash&&(t.infoHashBuffer=n.from(t.infoHash,"hex")),t.infoHashV2&&(t.infoHashV2Buffer=n.from(t.infoHashV2,"hex")),t.publicKey&&(t.publicKeyBuffer=n.from(t.publicKey,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),t.announce=[],("string"==typeof t.tr||Array.isArray(t.tr))&&(t.announce=t.announce.concat(t.tr)),t.urlList=[],("string"==typeof t.as||Array.isArray(t.as))&&(t.urlList=t.urlList.concat(t.as)),("string"==typeof t.ws||Array.isArray(t.ws))&&(t.urlList=t.urlList.concat(t.ws)),t.peerAddresses=[],("string"==typeof t["x.pe"]||Array.isArray(t["x.pe"]))&&(t.peerAddresses=t.peerAddresses.concat(t["x.pe"])),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList)),t.peerAddresses=Array.from(new Set(t.peerAddresses)),t}}).call(this)}).call(this,e("buffer").Buffer)},{"bep53-range":8,buffer:55,"thirty-two":289}],127:[function(e,t,n){ +t.exports=s,t.exports.decode=s,t.exports.encode=function(e){e=Object.assign({},e);let t=new Set;e.xt&&"string"==typeof e.xt&&t.add(e.xt);e.xt&&Array.isArray(e.xt)&&(t=new Set(e.xt));e.infoHashBuffer&&t.add(`urn:btih:${e.infoHashBuffer.toString("hex")}`);e.infoHash&&t.add(`urn:btih:${e.infoHash}`);e.infoHashV2Buffer&&t.add(e.xt=`urn:btmh:1220${e.infoHashV2Buffer.toString("hex")}`);e.infoHashV2&&t.add(`urn:btmh:1220${e.infoHashV2}`);const n=Array.from(t);1===n.length&&(e.xt=n[0]);n.length>1&&(e.xt=n);e.publicKeyBuffer&&(e.xs=`urn:btpk:${e.publicKeyBuffer.toString("hex")}`);e.publicKey&&(e.xs=`urn:btpk:${e.publicKey}`);e.name&&(e.dn=e.name);e.keywords&&(e.kt=e.keywords);e.announce&&(e.tr=e.announce);e.urlList&&(e.ws=e.urlList,delete e.as);e.peerAddresses&&(e["x.pe"]=e.peerAddresses);let i="magnet:?";return Object.keys(e).filter((e=>2===e.length||"x.pe"===e)).forEach(((t,n)=>{const s=Array.isArray(e[t])?e[t]:[e[t]];s.forEach(((e,r)=>{(n>0||r>0)&&("kt"!==t&&"so"!==t||0===r)&&(i+="&"),"dn"===t&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==t&&"as"!==t&&"ws"!==t||(e=encodeURIComponent(e)),"xs"!==t||e.startsWith("urn:btpk:")||(e=encodeURIComponent(e)),"kt"===t&&(e=encodeURIComponent(e)),"so"!==t&&(i+="kt"===t&&r>0?`+${e}`:`${t}=${e}`)})),"so"===t&&(i+=`${t}=${r.compose(s)}`)})),i};const i=e("thirty-two"),r=e("bep53-range");function s(e){const t={},s=e.split("magnet:?")[1];let o;if((s&&s.length>=0?s.split("&"):[]).forEach((e=>{const n=e.split("=");if(2!==n.length)return;const i=n[0];let s=n[1];"dn"===i&&(s=decodeURIComponent(s).replace(/\+/g," ")),"tr"!==i&&"xs"!==i&&"as"!==i&&"ws"!==i||(s=decodeURIComponent(s)),"kt"===i&&(s=decodeURIComponent(s).split("+")),"ix"===i&&(s=Number(s)),"so"===i&&(s=r.parse(decodeURIComponent(s).split(","))),t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(s)):t[i]=s})),t.xt){(Array.isArray(t.xt)?t.xt:[t.xt]).forEach((e=>{if(o=e.match(/^urn:btih:(.{40})/))t.infoHash=o[1].toLowerCase();else if(o=e.match(/^urn:btih:(.{32})/)){const e=i.decode(o[1]);t.infoHash=n.from(e,"binary").toString("hex")}else(o=e.match(/^urn:btmh:1220(.{64})/))&&(t.infoHashV2=o[1].toLowerCase())}))}if(t.xs){(Array.isArray(t.xs)?t.xs:[t.xs]).forEach((e=>{(o=e.match(/^urn:btpk:(.{64})/))&&(t.publicKey=o[1].toLowerCase())}))}return t.infoHash&&(t.infoHashBuffer=n.from(t.infoHash,"hex")),t.infoHashV2&&(t.infoHashV2Buffer=n.from(t.infoHashV2,"hex")),t.publicKey&&(t.publicKeyBuffer=n.from(t.publicKey,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),t.announce=[],("string"==typeof t.tr||Array.isArray(t.tr))&&(t.announce=t.announce.concat(t.tr)),t.urlList=[],("string"==typeof t.as||Array.isArray(t.as))&&(t.urlList=t.urlList.concat(t.as)),("string"==typeof t.ws||Array.isArray(t.ws))&&(t.urlList=t.urlList.concat(t.ws)),t.peerAddresses=[],("string"==typeof t["x.pe"]||Array.isArray(t["x.pe"]))&&(t.peerAddresses=t.peerAddresses.concat(t["x.pe"])),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList)),t.peerAddresses=Array.from(new Set(t.peerAddresses)),t}}).call(this)}).call(this,e("buffer").Buffer)},{"bep53-range":23,buffer:114,"thirty-two":467}],255:[function(e,t,n){"use strict";var i=e("inherits"),r=e("hash-base"),s=e("safe-buffer").Buffer,o=new Array(16);function a(){r.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(e,t){return e<>>32-t}function u(e,t,n,i,r,s,o){return c(e+(t&n|~t&i)+r+s|0,o)+t|0}function l(e,t,n,i,r,s,o){return c(e+(t&i|n&~i)+r+s|0,o)+t|0}function d(e,t,n,i,r,s,o){return c(e+(t^n^i)+r+s|0,o)+t|0}function f(e,t,n,i,r,s,o){return c(e+(n^(t|~i))+r+s|0,o)+t|0}i(a,r),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,i=this._b,r=this._c,s=this._d;n=u(n,i,r,s,e[0],3614090360,7),s=u(s,n,i,r,e[1],3905402710,12),r=u(r,s,n,i,e[2],606105819,17),i=u(i,r,s,n,e[3],3250441966,22),n=u(n,i,r,s,e[4],4118548399,7),s=u(s,n,i,r,e[5],1200080426,12),r=u(r,s,n,i,e[6],2821735955,17),i=u(i,r,s,n,e[7],4249261313,22),n=u(n,i,r,s,e[8],1770035416,7),s=u(s,n,i,r,e[9],2336552879,12),r=u(r,s,n,i,e[10],4294925233,17),i=u(i,r,s,n,e[11],2304563134,22),n=u(n,i,r,s,e[12],1804603682,7),s=u(s,n,i,r,e[13],4254626195,12),r=u(r,s,n,i,e[14],2792965006,17),n=l(n,i=u(i,r,s,n,e[15],1236535329,22),r,s,e[1],4129170786,5),s=l(s,n,i,r,e[6],3225465664,9),r=l(r,s,n,i,e[11],643717713,14),i=l(i,r,s,n,e[0],3921069994,20),n=l(n,i,r,s,e[5],3593408605,5),s=l(s,n,i,r,e[10],38016083,9),r=l(r,s,n,i,e[15],3634488961,14),i=l(i,r,s,n,e[4],3889429448,20),n=l(n,i,r,s,e[9],568446438,5),s=l(s,n,i,r,e[14],3275163606,9),r=l(r,s,n,i,e[3],4107603335,14),i=l(i,r,s,n,e[8],1163531501,20),n=l(n,i,r,s,e[13],2850285829,5),s=l(s,n,i,r,e[2],4243563512,9),r=l(r,s,n,i,e[7],1735328473,14),n=d(n,i=l(i,r,s,n,e[12],2368359562,20),r,s,e[5],4294588738,4),s=d(s,n,i,r,e[8],2272392833,11),r=d(r,s,n,i,e[11],1839030562,16),i=d(i,r,s,n,e[14],4259657740,23),n=d(n,i,r,s,e[1],2763975236,4),s=d(s,n,i,r,e[4],1272893353,11),r=d(r,s,n,i,e[7],4139469664,16),i=d(i,r,s,n,e[10],3200236656,23),n=d(n,i,r,s,e[13],681279174,4),s=d(s,n,i,r,e[0],3936430074,11),r=d(r,s,n,i,e[3],3572445317,16),i=d(i,r,s,n,e[6],76029189,23),n=d(n,i,r,s,e[9],3654602809,4),s=d(s,n,i,r,e[12],3873151461,11),r=d(r,s,n,i,e[15],530742520,16),n=f(n,i=d(i,r,s,n,e[2],3299628645,23),r,s,e[0],4096336452,6),s=f(s,n,i,r,e[7],1126891415,10),r=f(r,s,n,i,e[14],2878612391,15),i=f(i,r,s,n,e[5],4237533241,21),n=f(n,i,r,s,e[12],1700485571,6),s=f(s,n,i,r,e[3],2399980690,10),r=f(r,s,n,i,e[10],4293915773,15),i=f(i,r,s,n,e[1],2240044497,21),n=f(n,i,r,s,e[8],1873313359,6),s=f(s,n,i,r,e[15],4264355552,10),r=f(r,s,n,i,e[6],2734768916,15),i=f(i,r,s,n,e[13],1309151649,21),n=f(n,i,r,s,e[4],4149444226,6),s=f(s,n,i,r,e[11],3174756917,10),r=f(r,s,n,i,e[2],718787259,15),i=f(i,r,s,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+i|0,this._c=this._c+r|0,this._d=this._d+s|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=s.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a},{"hash-base":213,inherits:245,"safe-buffer":376}],256:[function(e,t,n){ /*! mediasource. MIT License. Feross Aboukhadijeh */ -t.exports=a;var i=e("inherits"),r=e("readable-stream"),o=e("to-arraybuffer"),s="undefined"!=typeof window&&window.MediaSource;function a(e,t){var n=this;if(!(n instanceof a))return new a(e,t);if(!s)throw new Error("web browser lacks MediaSource support");t||(t={}),n._debug=t.debug,n._bufferDuration=t.bufferDuration||60,n._elem=e,n._mediaSource=new s,n._streams=[],n.detailedError=null,n._errorHandler=function(){n._elem.removeEventListener("error",n._errorHandler),n._streams.slice().forEach((function(e){e.destroy(n._elem.error)}))},n._elem.addEventListener("error",n._errorHandler),n._elem.src=window.URL.createObjectURL(n._mediaSource)}function c(e,t){var n=this;if(r.Writable.call(n),n._wrapper=e,n._elem=e._elem,n._mediaSource=e._mediaSource,n._allStreams=e._streams,n._allStreams.push(n),n._bufferDuration=e._bufferDuration,n._sourceBuffer=null,n._debugBuffers=[],n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},n._errorHandler=function(e){n.destroyed||n.emit("error",e)},"string"==typeof t)n._type=t,"open"===n._mediaSource.readyState?n._createSourceBuffer():n._mediaSource.addEventListener("sourceopen",n._openHandler);else if(null===t._sourceBuffer)t.destroy(),n._type=t._type,n._mediaSource.addEventListener("sourceopen",n._openHandler);else{if(!t._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._debugBuffers=t._debugBuffers,n._sourceBuffer.addEventListener("updateend",n._flowHandler),n._sourceBuffer.addEventListener("error",n._errorHandler)}n._elem.addEventListener("timeupdate",n._flowHandler),n.on("error",(function(e){n._wrapper.error(e)})),n.on("finish",(function(){if(!n.destroyed&&(n._finished=!0,n._allStreams.every((function(e){return e._finished})))){n._wrapper._dumpDebugData();try{n._mediaSource.endOfStream()}catch(e){}}}))}a.prototype.createWriteStream=function(e){return new c(this,e)},a.prototype.error=function(e){var t=this;t.detailedError||(t.detailedError=e),t._dumpDebugData();try{t._mediaSource.endOfStream("decode")}catch(e){}try{window.URL.revokeObjectURL(t._elem.src)}catch(e){}},a.prototype._dumpDebugData=function(){var e=this;e._debug&&(e._debug=!1,e._streams.forEach((function(e,t){var n,i,r;n=e._debugBuffers,i="mediasource-stream-"+t,(r=document.createElement("a")).href=window.URL.createObjectURL(new window.Blob(n)),r.download=i,r.click()})))},i(c,r.Writable),c.prototype._onSourceOpen=function(){var e=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},c.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,t._allStreams.splice(t._allStreams.indexOf(t),1),t._mediaSource.removeEventListener("sourceopen",t._openHandler),t._elem.removeEventListener("timeupdate",t._flowHandler),t._sourceBuffer&&(t._sourceBuffer.removeEventListener("updateend",t._flowHandler),t._sourceBuffer.removeEventListener("error",t._errorHandler),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},c.prototype._createSourceBuffer=function(){var e=this;if(!e.destroyed)if(s.isTypeSupported(e._type)){if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._sourceBuffer.addEventListener("error",e._errorHandler),e._cb){var t=e._cb;e._cb=null,t()}}else e.destroy(new Error("The provided type is not supported"))},c.prototype._write=function(e,t,n){var i=this;if(!i.destroyed)if(i._sourceBuffer){if(i._sourceBuffer.updating)return n(new Error("Cannot append buffer while source buffer updating"));var r=o(e);i._wrapper._debug&&i._debugBuffers.push(r);try{i._sourceBuffer.appendBuffer(r)}catch(e){return void i.destroy(e)}i._cb=n}else i._cb=function(r){if(r)return n(r);i._write(e,t,n)}},c.prototype._flow=function(){var e=this;if(!e.destroyed&&e._sourceBuffer&&!e._sourceBuffer.updating&&!("open"===e._mediaSource.readyState&&e._getBufferDuration()>e._bufferDuration)&&e._cb){var t=e._cb;e._cb=null,t()}};c.prototype._getBufferDuration=function(){for(var e=this._sourceBuffer.buffered,t=this._elem.currentTime,n=-1,i=0;it)break;(n>=0||t<=o)&&(n=o)}var s=n-t;return s<0&&(s=0),s}},{inherits:118,"readable-stream":142,"to-arraybuffer":292}],128:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],129:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":131,"./_stream_writable":133,_process:189,dup:16,inherits:118}],130:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":132,dup:17,inherits:118}],131:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":128,"./_stream_duplex":129,"./internal/streams/async_iterator":134,"./internal/streams/buffer_list":135,"./internal/streams/destroy":136,"./internal/streams/from":138,"./internal/streams/state":140,"./internal/streams/stream":141,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],132:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":128,"./_stream_duplex":129,dup:19,inherits:118}],133:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":128,"./_stream_duplex":129,"./internal/streams/destroy":136,"./internal/streams/state":140,"./internal/streams/stream":141,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],134:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":137,_process:189,dup:21}],135:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],136:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],137:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":128,dup:24}],138:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],139:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":128,"./end-of-stream":137,dup:26}],140:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":128,dup:27}],141:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],142:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":129,"./lib/_stream_passthrough.js":130,"./lib/_stream_readable.js":131,"./lib/_stream_transform.js":132,"./lib/_stream_writable.js":133,"./lib/internal/streams/end-of-stream.js":137,"./lib/internal/streams/pipeline.js":139,dup:29}],143:[function(e,t,n){t.exports=r;const i=e("queue-microtask");function r(e,t){if(!(this instanceof r))return new r(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}r.prototype.put=function(e,t,n=(()=>{})){if(this.closed)return i((()=>n(new Error("Storage is closed"))));const r=e===this.lastChunkIndex;return r&&t.length!==this.lastChunkLength?i((()=>n(new Error("Last chunk length must be "+this.lastChunkLength)))):r||t.length===this.chunkLength?(this.chunks[e]=t,void i((()=>n(null)))):i((()=>n(new Error("Chunk length must be "+this.chunkLength))))},r.prototype.get=function(e,t,n=(()=>{})){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return i((()=>n(new Error("Storage is closed"))));let r=this.chunks[e];if(!r){const e=new Error("Chunk not found");return e.notFound=!0,i((()=>n(e)))}t||(t={});const o=t.offset||0,s=t.length||r.length-o;0===o&&s===r.length||(r=r.slice(o,s+o)),i((()=>n(null,r)))},r.prototype.close=r.prototype.destroy=function(e=(()=>{})){if(this.closed)return i((()=>e(new Error("Storage is closed"))));this.closed=!0,this.chunks=null,i((()=>e(null)))}},{"queue-microtask":195}],144:[function(e,t,n){t.exports={"application/1d-interleaved-parityfec":{source:"iana"},"application/3gpdash-qoe-report+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/3gpp-ims+xml":{source:"iana",compressible:!0},"application/a2l":{source:"iana"},"application/activemessage":{source:"iana"},"application/activity+json":{source:"iana",compressible:!0},"application/alto-costmap+json":{source:"iana",compressible:!0},"application/alto-costmapfilter+json":{source:"iana",compressible:!0},"application/alto-directory+json":{source:"iana",compressible:!0},"application/alto-endpointcost+json":{source:"iana",compressible:!0},"application/alto-endpointcostparams+json":{source:"iana",compressible:!0},"application/alto-endpointprop+json":{source:"iana",compressible:!0},"application/alto-endpointpropparams+json":{source:"iana",compressible:!0},"application/alto-error+json":{source:"iana",compressible:!0},"application/alto-networkmap+json":{source:"iana",compressible:!0},"application/alto-networkmapfilter+json":{source:"iana",compressible:!0},"application/alto-updatestreamcontrol+json":{source:"iana",compressible:!0},"application/alto-updatestreamparams+json":{source:"iana",compressible:!0},"application/aml":{source:"iana"},"application/andrew-inset":{source:"iana",extensions:["ez"]},"application/applefile":{source:"iana"},"application/applixware":{source:"apache",extensions:["aw"]},"application/atf":{source:"iana"},"application/atfx":{source:"iana"},"application/atom+xml":{source:"iana",compressible:!0,extensions:["atom"]},"application/atomcat+xml":{source:"iana",compressible:!0,extensions:["atomcat"]},"application/atomdeleted+xml":{source:"iana",compressible:!0,extensions:["atomdeleted"]},"application/atomicmail":{source:"iana"},"application/atomsvc+xml":{source:"iana",compressible:!0,extensions:["atomsvc"]},"application/atsc-dwd+xml":{source:"iana",compressible:!0,extensions:["dwd"]},"application/atsc-dynamic-event-message":{source:"iana"},"application/atsc-held+xml":{source:"iana",compressible:!0,extensions:["held"]},"application/atsc-rdt+json":{source:"iana",compressible:!0},"application/atsc-rsat+xml":{source:"iana",compressible:!0,extensions:["rsat"]},"application/atxml":{source:"iana"},"application/auth-policy+xml":{source:"iana",compressible:!0},"application/bacnet-xdd+zip":{source:"iana",compressible:!1},"application/batch-smtp":{source:"iana"},"application/bdoc":{compressible:!1,extensions:["bdoc"]},"application/beep+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/calendar+json":{source:"iana",compressible:!0},"application/calendar+xml":{source:"iana",compressible:!0,extensions:["xcs"]},"application/call-completion":{source:"iana"},"application/cals-1840":{source:"iana"},"application/captive+json":{source:"iana",compressible:!0},"application/cbor":{source:"iana"},"application/cbor-seq":{source:"iana"},"application/cccex":{source:"iana"},"application/ccmp+xml":{source:"iana",compressible:!0},"application/ccxml+xml":{source:"iana",compressible:!0,extensions:["ccxml"]},"application/cdfx+xml":{source:"iana",compressible:!0,extensions:["cdfx"]},"application/cdmi-capability":{source:"iana",extensions:["cdmia"]},"application/cdmi-container":{source:"iana",extensions:["cdmic"]},"application/cdmi-domain":{source:"iana",extensions:["cdmid"]},"application/cdmi-object":{source:"iana",extensions:["cdmio"]},"application/cdmi-queue":{source:"iana",extensions:["cdmiq"]},"application/cdni":{source:"iana"},"application/cea":{source:"iana"},"application/cea-2018+xml":{source:"iana",compressible:!0},"application/cellml+xml":{source:"iana",compressible:!0},"application/cfw":{source:"iana"},"application/clr":{source:"iana"},"application/clue+xml":{source:"iana",compressible:!0},"application/clue_info+xml":{source:"iana",compressible:!0},"application/cms":{source:"iana"},"application/cnrp+xml":{source:"iana",compressible:!0},"application/coap-group+json":{source:"iana",compressible:!0},"application/coap-payload":{source:"iana"},"application/commonground":{source:"iana"},"application/conference-info+xml":{source:"iana",compressible:!0},"application/cose":{source:"iana"},"application/cose-key":{source:"iana"},"application/cose-key-set":{source:"iana"},"application/cpl+xml":{source:"iana",compressible:!0},"application/csrattrs":{source:"iana"},"application/csta+xml":{source:"iana",compressible:!0},"application/cstadata+xml":{source:"iana",compressible:!0},"application/csvm+json":{source:"iana",compressible:!0},"application/cu-seeme":{source:"apache",extensions:["cu"]},"application/cwt":{source:"iana"},"application/cybercash":{source:"iana"},"application/dart":{compressible:!0},"application/dash+xml":{source:"iana",compressible:!0,extensions:["mpd"]},"application/dashdelta":{source:"iana"},"application/davmount+xml":{source:"iana",compressible:!0,extensions:["davmount"]},"application/dca-rft":{source:"iana"},"application/dcd":{source:"iana"},"application/dec-dx":{source:"iana"},"application/dialog-info+xml":{source:"iana",compressible:!0},"application/dicom":{source:"iana"},"application/dicom+json":{source:"iana",compressible:!0},"application/dicom+xml":{source:"iana",compressible:!0},"application/dii":{source:"iana"},"application/dit":{source:"iana"},"application/dns":{source:"iana"},"application/dns+json":{source:"iana",compressible:!0},"application/dns-message":{source:"iana"},"application/docbook+xml":{source:"apache",compressible:!0,extensions:["dbk"]},"application/dots+cbor":{source:"iana"},"application/dskpp+xml":{source:"iana",compressible:!0},"application/dssc+der":{source:"iana",extensions:["dssc"]},"application/dssc+xml":{source:"iana",compressible:!0,extensions:["xdssc"]},"application/dvcs":{source:"iana"},"application/ecmascript":{source:"iana",compressible:!0,extensions:["es","ecma"]},"application/edi-consent":{source:"iana"},"application/edi-x12":{source:"iana",compressible:!1},"application/edifact":{source:"iana",compressible:!1},"application/efi":{source:"iana"},"application/elm+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/elm+xml":{source:"iana",compressible:!0},"application/emergencycalldata.cap+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/emergencycalldata.comment+xml":{source:"iana",compressible:!0},"application/emergencycalldata.control+xml":{source:"iana",compressible:!0},"application/emergencycalldata.deviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.ecall.msd":{source:"iana"},"application/emergencycalldata.providerinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.serviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.subscriberinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.veds+xml":{source:"iana",compressible:!0},"application/emma+xml":{source:"iana",compressible:!0,extensions:["emma"]},"application/emotionml+xml":{source:"iana",compressible:!0,extensions:["emotionml"]},"application/encaprtp":{source:"iana"},"application/epp+xml":{source:"iana",compressible:!0},"application/epub+zip":{source:"iana",compressible:!1,extensions:["epub"]},"application/eshop":{source:"iana"},"application/exi":{source:"iana",extensions:["exi"]},"application/expect-ct-report+json":{source:"iana",compressible:!0},"application/fastinfoset":{source:"iana"},"application/fastsoap":{source:"iana"},"application/fdt+xml":{source:"iana",compressible:!0,extensions:["fdt"]},"application/fhir+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/fhir+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/fido.trusted-apps+json":{compressible:!0},"application/fits":{source:"iana"},"application/flexfec":{source:"iana"},"application/font-sfnt":{source:"iana"},"application/font-tdpfr":{source:"iana",extensions:["pfr"]},"application/font-woff":{source:"iana",compressible:!1},"application/framework-attributes+xml":{source:"iana",compressible:!0},"application/geo+json":{source:"iana",compressible:!0,extensions:["geojson"]},"application/geo+json-seq":{source:"iana"},"application/geopackage+sqlite3":{source:"iana"},"application/geoxacml+xml":{source:"iana",compressible:!0},"application/gltf-buffer":{source:"iana"},"application/gml+xml":{source:"iana",compressible:!0,extensions:["gml"]},"application/gpx+xml":{source:"apache",compressible:!0,extensions:["gpx"]},"application/gxf":{source:"apache",extensions:["gxf"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/h224":{source:"iana"},"application/held+xml":{source:"iana",compressible:!0},"application/hjson":{extensions:["hjson"]},"application/http":{source:"iana"},"application/hyperstudio":{source:"iana",extensions:["stk"]},"application/ibe-key-request+xml":{source:"iana",compressible:!0},"application/ibe-pkg-reply+xml":{source:"iana",compressible:!0},"application/ibe-pp-data":{source:"iana"},"application/iges":{source:"iana"},"application/im-iscomposing+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/index":{source:"iana"},"application/index.cmd":{source:"iana"},"application/index.obj":{source:"iana"},"application/index.response":{source:"iana"},"application/index.vnd":{source:"iana"},"application/inkml+xml":{source:"iana",compressible:!0,extensions:["ink","inkml"]},"application/iotp":{source:"iana"},"application/ipfix":{source:"iana",extensions:["ipfix"]},"application/ipp":{source:"iana"},"application/isup":{source:"iana"},"application/its+xml":{source:"iana",compressible:!0,extensions:["its"]},"application/java-archive":{source:"apache",compressible:!1,extensions:["jar","war","ear"]},"application/java-serialized-object":{source:"apache",compressible:!1,extensions:["ser"]},"application/java-vm":{source:"apache",compressible:!1,extensions:["class"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/jf2feed+json":{source:"iana",compressible:!0},"application/jose":{source:"iana"},"application/jose+json":{source:"iana",compressible:!0},"application/jrd+json":{source:"iana",compressible:!0},"application/jscalendar+json":{source:"iana",compressible:!0},"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/json-patch+json":{source:"iana",compressible:!0},"application/json-seq":{source:"iana"},"application/json5":{extensions:["json5"]},"application/jsonml+json":{source:"apache",compressible:!0,extensions:["jsonml"]},"application/jwk+json":{source:"iana",compressible:!0},"application/jwk-set+json":{source:"iana",compressible:!0},"application/jwt":{source:"iana"},"application/kpml-request+xml":{source:"iana",compressible:!0},"application/kpml-response+xml":{source:"iana",compressible:!0},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/lgr+xml":{source:"iana",compressible:!0,extensions:["lgr"]},"application/link-format":{source:"iana"},"application/load-control+xml":{source:"iana",compressible:!0},"application/lost+xml":{source:"iana",compressible:!0,extensions:["lostxml"]},"application/lostsync+xml":{source:"iana",compressible:!0},"application/lpf+zip":{source:"iana",compressible:!1},"application/lxf":{source:"iana"},"application/mac-binhex40":{source:"iana",extensions:["hqx"]},"application/mac-compactpro":{source:"apache",extensions:["cpt"]},"application/macwriteii":{source:"iana"},"application/mads+xml":{source:"iana",compressible:!0,extensions:["mads"]},"application/manifest+json":{charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/marc":{source:"iana",extensions:["mrc"]},"application/marcxml+xml":{source:"iana",compressible:!0,extensions:["mrcx"]},"application/mathematica":{source:"iana",extensions:["ma","nb","mb"]},"application/mathml+xml":{source:"iana",compressible:!0,extensions:["mathml"]},"application/mathml-content+xml":{source:"iana",compressible:!0},"application/mathml-presentation+xml":{source:"iana",compressible:!0},"application/mbms-associated-procedure-description+xml":{source:"iana",compressible:!0},"application/mbms-deregister+xml":{source:"iana",compressible:!0},"application/mbms-envelope+xml":{source:"iana",compressible:!0},"application/mbms-msk+xml":{source:"iana",compressible:!0},"application/mbms-msk-response+xml":{source:"iana",compressible:!0},"application/mbms-protection-description+xml":{source:"iana",compressible:!0},"application/mbms-reception-report+xml":{source:"iana",compressible:!0},"application/mbms-register+xml":{source:"iana",compressible:!0},"application/mbms-register-response+xml":{source:"iana",compressible:!0},"application/mbms-schedule+xml":{source:"iana",compressible:!0},"application/mbms-user-service-description+xml":{source:"iana",compressible:!0},"application/mbox":{source:"iana",extensions:["mbox"]},"application/media-policy-dataset+xml":{source:"iana",compressible:!0},"application/media_control+xml":{source:"iana",compressible:!0},"application/mediaservercontrol+xml":{source:"iana",compressible:!0,extensions:["mscml"]},"application/merge-patch+json":{source:"iana",compressible:!0},"application/metalink+xml":{source:"apache",compressible:!0,extensions:["metalink"]},"application/metalink4+xml":{source:"iana",compressible:!0,extensions:["meta4"]},"application/mets+xml":{source:"iana",compressible:!0,extensions:["mets"]},"application/mf4":{source:"iana"},"application/mikey":{source:"iana"},"application/mipc":{source:"iana"},"application/mmt-aei+xml":{source:"iana",compressible:!0,extensions:["maei"]},"application/mmt-usd+xml":{source:"iana",compressible:!0,extensions:["musd"]},"application/mods+xml":{source:"iana",compressible:!0,extensions:["mods"]},"application/moss-keys":{source:"iana"},"application/moss-signature":{source:"iana"},"application/mosskey-data":{source:"iana"},"application/mosskey-request":{source:"iana"},"application/mp21":{source:"iana",extensions:["m21","mp21"]},"application/mp4":{source:"iana",extensions:["mp4s","m4p"]},"application/mpeg4-generic":{source:"iana"},"application/mpeg4-iod":{source:"iana"},"application/mpeg4-iod-xmt":{source:"iana"},"application/mrb-consumer+xml":{source:"iana",compressible:!0},"application/mrb-publish+xml":{source:"iana",compressible:!0},"application/msc-ivr+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msc-mixer+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msword":{source:"iana",compressible:!1,extensions:["doc","dot"]},"application/mud+json":{source:"iana",compressible:!0},"application/multipart-core":{source:"iana"},"application/mxf":{source:"iana",extensions:["mxf"]},"application/n-quads":{source:"iana",extensions:["nq"]},"application/n-triples":{source:"iana",extensions:["nt"]},"application/nasdata":{source:"iana"},"application/news-checkgroups":{source:"iana",charset:"US-ASCII"},"application/news-groupinfo":{source:"iana",charset:"US-ASCII"},"application/news-transmission":{source:"iana"},"application/nlsml+xml":{source:"iana",compressible:!0},"application/node":{source:"iana",extensions:["cjs"]},"application/nss":{source:"iana"},"application/ocsp-request":{source:"iana"},"application/ocsp-response":{source:"iana"},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{source:"iana",extensions:["oda"]},"application/odm+xml":{source:"iana",compressible:!0},"application/odx":{source:"iana"},"application/oebps-package+xml":{source:"iana",compressible:!0,extensions:["opf"]},"application/ogg":{source:"iana",compressible:!1,extensions:["ogx"]},"application/omdoc+xml":{source:"apache",compressible:!0,extensions:["omdoc"]},"application/onenote":{source:"apache",extensions:["onetoc","onetoc2","onetmp","onepkg"]},"application/opc-nodeset+xml":{source:"iana",compressible:!0},"application/oscore":{source:"iana"},"application/oxps":{source:"iana",extensions:["oxps"]},"application/p2p-overlay+xml":{source:"iana",compressible:!0,extensions:["relo"]},"application/parityfec":{source:"iana"},"application/passport":{source:"iana"},"application/patch-ops-error+xml":{source:"iana",compressible:!0,extensions:["xer"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/pdx":{source:"iana"},"application/pem-certificate-chain":{source:"iana"},"application/pgp-encrypted":{source:"iana",compressible:!1,extensions:["pgp"]},"application/pgp-keys":{source:"iana"},"application/pgp-signature":{source:"iana",extensions:["asc","sig"]},"application/pics-rules":{source:"apache",extensions:["prf"]},"application/pidf+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pidf-diff+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pkcs10":{source:"iana",extensions:["p10"]},"application/pkcs12":{source:"iana"},"application/pkcs7-mime":{source:"iana",extensions:["p7m","p7c"]},"application/pkcs7-signature":{source:"iana",extensions:["p7s"]},"application/pkcs8":{source:"iana",extensions:["p8"]},"application/pkcs8-encrypted":{source:"iana"},"application/pkix-attr-cert":{source:"iana",extensions:["ac"]},"application/pkix-cert":{source:"iana",extensions:["cer"]},"application/pkix-crl":{source:"iana",extensions:["crl"]},"application/pkix-pkipath":{source:"iana",extensions:["pkipath"]},"application/pkixcmp":{source:"iana",extensions:["pki"]},"application/pls+xml":{source:"iana",compressible:!0,extensions:["pls"]},"application/poc-settings+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/postscript":{source:"iana",compressible:!0,extensions:["ai","eps","ps"]},"application/ppsp-tracker+json":{source:"iana",compressible:!0},"application/problem+json":{source:"iana",compressible:!0},"application/problem+xml":{source:"iana",compressible:!0},"application/provenance+xml":{source:"iana",compressible:!0,extensions:["provx"]},"application/prs.alvestrand.titrax-sheet":{source:"iana"},"application/prs.cww":{source:"iana",extensions:["cww"]},"application/prs.cyn":{source:"iana",charset:"7-BIT"},"application/prs.hpub+zip":{source:"iana",compressible:!1},"application/prs.nprend":{source:"iana"},"application/prs.plucker":{source:"iana"},"application/prs.rdf-xml-crypt":{source:"iana"},"application/prs.xsf+xml":{source:"iana",compressible:!0},"application/pskc+xml":{source:"iana",compressible:!0,extensions:["pskcxml"]},"application/pvd+json":{source:"iana",compressible:!0},"application/qsig":{source:"iana"},"application/raml+yaml":{compressible:!0,extensions:["raml"]},"application/raptorfec":{source:"iana"},"application/rdap+json":{source:"iana",compressible:!0},"application/rdf+xml":{source:"iana",compressible:!0,extensions:["rdf","owl"]},"application/reginfo+xml":{source:"iana",compressible:!0,extensions:["rif"]},"application/relax-ng-compact-syntax":{source:"iana",extensions:["rnc"]},"application/remote-printing":{source:"iana"},"application/reputon+json":{source:"iana",compressible:!0},"application/resource-lists+xml":{source:"iana",compressible:!0,extensions:["rl"]},"application/resource-lists-diff+xml":{source:"iana",compressible:!0,extensions:["rld"]},"application/rfc+xml":{source:"iana",compressible:!0},"application/riscos":{source:"iana"},"application/rlmi+xml":{source:"iana",compressible:!0},"application/rls-services+xml":{source:"iana",compressible:!0,extensions:["rs"]},"application/route-apd+xml":{source:"iana",compressible:!0,extensions:["rapd"]},"application/route-s-tsid+xml":{source:"iana",compressible:!0,extensions:["sls"]},"application/route-usd+xml":{source:"iana",compressible:!0,extensions:["rusd"]},"application/rpki-ghostbusters":{source:"iana",extensions:["gbr"]},"application/rpki-manifest":{source:"iana",extensions:["mft"]},"application/rpki-publication":{source:"iana"},"application/rpki-roa":{source:"iana",extensions:["roa"]},"application/rpki-updown":{source:"iana"},"application/rsd+xml":{source:"apache",compressible:!0,extensions:["rsd"]},"application/rss+xml":{source:"apache",compressible:!0,extensions:["rss"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/rtploopback":{source:"iana"},"application/rtx":{source:"iana"},"application/samlassertion+xml":{source:"iana",compressible:!0},"application/samlmetadata+xml":{source:"iana",compressible:!0},"application/sarif+json":{source:"iana",compressible:!0},"application/sbe":{source:"iana"},"application/sbml+xml":{source:"iana",compressible:!0,extensions:["sbml"]},"application/scaip+xml":{source:"iana",compressible:!0},"application/scim+json":{source:"iana",compressible:!0},"application/scvp-cv-request":{source:"iana",extensions:["scq"]},"application/scvp-cv-response":{source:"iana",extensions:["scs"]},"application/scvp-vp-request":{source:"iana",extensions:["spq"]},"application/scvp-vp-response":{source:"iana",extensions:["spp"]},"application/sdp":{source:"iana",extensions:["sdp"]},"application/secevent+jwt":{source:"iana"},"application/senml+cbor":{source:"iana"},"application/senml+json":{source:"iana",compressible:!0},"application/senml+xml":{source:"iana",compressible:!0,extensions:["senmlx"]},"application/senml-etch+cbor":{source:"iana"},"application/senml-etch+json":{source:"iana",compressible:!0},"application/senml-exi":{source:"iana"},"application/sensml+cbor":{source:"iana"},"application/sensml+json":{source:"iana",compressible:!0},"application/sensml+xml":{source:"iana",compressible:!0,extensions:["sensmlx"]},"application/sensml-exi":{source:"iana"},"application/sep+xml":{source:"iana",compressible:!0},"application/sep-exi":{source:"iana"},"application/session-info":{source:"iana"},"application/set-payment":{source:"iana"},"application/set-payment-initiation":{source:"iana",extensions:["setpay"]},"application/set-registration":{source:"iana"},"application/set-registration-initiation":{source:"iana",extensions:["setreg"]},"application/sgml":{source:"iana"},"application/sgml-open-catalog":{source:"iana"},"application/shf+xml":{source:"iana",compressible:!0,extensions:["shf"]},"application/sieve":{source:"iana",extensions:["siv","sieve"]},"application/simple-filter+xml":{source:"iana",compressible:!0},"application/simple-message-summary":{source:"iana"},"application/simplesymbolcontainer":{source:"iana"},"application/sipc":{source:"iana"},"application/slate":{source:"iana"},"application/smil":{source:"iana"},"application/smil+xml":{source:"iana",compressible:!0,extensions:["smi","smil"]},"application/smpte336m":{source:"iana"},"application/soap+fastinfoset":{source:"iana"},"application/soap+xml":{source:"iana",compressible:!0},"application/sparql-query":{source:"iana",extensions:["rq"]},"application/sparql-results+xml":{source:"iana",compressible:!0,extensions:["srx"]},"application/spirits-event+xml":{source:"iana",compressible:!0},"application/sql":{source:"iana"},"application/srgs":{source:"iana",extensions:["gram"]},"application/srgs+xml":{source:"iana",compressible:!0,extensions:["grxml"]},"application/sru+xml":{source:"iana",compressible:!0,extensions:["sru"]},"application/ssdl+xml":{source:"apache",compressible:!0,extensions:["ssdl"]},"application/ssml+xml":{source:"iana",compressible:!0,extensions:["ssml"]},"application/stix+json":{source:"iana",compressible:!0},"application/swid+xml":{source:"iana",compressible:!0,extensions:["swidtag"]},"application/tamp-apex-update":{source:"iana"},"application/tamp-apex-update-confirm":{source:"iana"},"application/tamp-community-update":{source:"iana"},"application/tamp-community-update-confirm":{source:"iana"},"application/tamp-error":{source:"iana"},"application/tamp-sequence-adjust":{source:"iana"},"application/tamp-sequence-adjust-confirm":{source:"iana"},"application/tamp-status-query":{source:"iana"},"application/tamp-status-response":{source:"iana"},"application/tamp-update":{source:"iana"},"application/tamp-update-confirm":{source:"iana"},"application/tar":{compressible:!0},"application/taxii+json":{source:"iana",compressible:!0},"application/td+json":{source:"iana",compressible:!0},"application/tei+xml":{source:"iana",compressible:!0,extensions:["tei","teicorpus"]},"application/tetra_isi":{source:"iana"},"application/thraud+xml":{source:"iana",compressible:!0,extensions:["tfi"]},"application/timestamp-query":{source:"iana"},"application/timestamp-reply":{source:"iana"},"application/timestamped-data":{source:"iana",extensions:["tsd"]},"application/tlsrpt+gzip":{source:"iana"},"application/tlsrpt+json":{source:"iana",compressible:!0},"application/tnauthlist":{source:"iana"},"application/toml":{compressible:!0,extensions:["toml"]},"application/trickle-ice-sdpfrag":{source:"iana"},"application/trig":{source:"iana"},"application/ttml+xml":{source:"iana",compressible:!0,extensions:["ttml"]},"application/tve-trigger":{source:"iana"},"application/tzif":{source:"iana"},"application/tzif-leap":{source:"iana"},"application/ubjson":{compressible:!1,extensions:["ubj"]},"application/ulpfec":{source:"iana"},"application/urc-grpsheet+xml":{source:"iana",compressible:!0},"application/urc-ressheet+xml":{source:"iana",compressible:!0,extensions:["rsheet"]},"application/urc-targetdesc+xml":{source:"iana",compressible:!0,extensions:["td"]},"application/urc-uisocketdesc+xml":{source:"iana",compressible:!0},"application/vcard+json":{source:"iana",compressible:!0},"application/vcard+xml":{source:"iana",compressible:!0},"application/vemmi":{source:"iana"},"application/vividence.scriptfile":{source:"apache"},"application/vnd.1000minds.decision-model+xml":{source:"iana",compressible:!0,extensions:["1km"]},"application/vnd.3gpp-prose+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-prose-pc3ch+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-v2x-local-service-information":{source:"iana"},"application/vnd.3gpp.access-transfer-events+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.bsf+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gmop+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.interworking-data":{source:"iana"},"application/vnd.3gpp.mc-signalling-ear":{source:"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-payload":{source:"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-signalling":{source:"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-floor-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-signed+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-init-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-transmission-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mid-call+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.pic-bw-large":{source:"iana",extensions:["plb"]},"application/vnd.3gpp.pic-bw-small":{source:"iana",extensions:["psb"]},"application/vnd.3gpp.pic-bw-var":{source:"iana",extensions:["pvb"]},"application/vnd.3gpp.sms":{source:"iana"},"application/vnd.3gpp.sms+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-ext+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.state-and-event-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ussd+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.bcmcsinfo+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.sms":{source:"iana"},"application/vnd.3gpp2.tcap":{source:"iana",extensions:["tcap"]},"application/vnd.3lightssoftware.imagescal":{source:"iana"},"application/vnd.3m.post-it-notes":{source:"iana",extensions:["pwn"]},"application/vnd.accpac.simply.aso":{source:"iana",extensions:["aso"]},"application/vnd.accpac.simply.imp":{source:"iana",extensions:["imp"]},"application/vnd.acucobol":{source:"iana",extensions:["acu"]},"application/vnd.acucorp":{source:"iana",extensions:["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{source:"apache",compressible:!1,extensions:["air"]},"application/vnd.adobe.flash.movie":{source:"iana"},"application/vnd.adobe.formscentral.fcdt":{source:"iana",extensions:["fcdt"]},"application/vnd.adobe.fxp":{source:"iana",extensions:["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{source:"iana"},"application/vnd.adobe.xdp+xml":{source:"iana",compressible:!0,extensions:["xdp"]},"application/vnd.adobe.xfdf":{source:"iana",extensions:["xfdf"]},"application/vnd.aether.imp":{source:"iana"},"application/vnd.afpc.afplinedata":{source:"iana"},"application/vnd.afpc.afplinedata-pagedef":{source:"iana"},"application/vnd.afpc.cmoca-cmresource":{source:"iana"},"application/vnd.afpc.foca-charset":{source:"iana"},"application/vnd.afpc.foca-codedfont":{source:"iana"},"application/vnd.afpc.foca-codepage":{source:"iana"},"application/vnd.afpc.modca":{source:"iana"},"application/vnd.afpc.modca-cmtable":{source:"iana"},"application/vnd.afpc.modca-formdef":{source:"iana"},"application/vnd.afpc.modca-mediummap":{source:"iana"},"application/vnd.afpc.modca-objectcontainer":{source:"iana"},"application/vnd.afpc.modca-overlay":{source:"iana"},"application/vnd.afpc.modca-pagesegment":{source:"iana"},"application/vnd.ah-barcode":{source:"iana"},"application/vnd.ahead.space":{source:"iana",extensions:["ahead"]},"application/vnd.airzip.filesecure.azf":{source:"iana",extensions:["azf"]},"application/vnd.airzip.filesecure.azs":{source:"iana",extensions:["azs"]},"application/vnd.amadeus+json":{source:"iana",compressible:!0},"application/vnd.amazon.ebook":{source:"apache",extensions:["azw"]},"application/vnd.amazon.mobi8-ebook":{source:"iana"},"application/vnd.americandynamics.acc":{source:"iana",extensions:["acc"]},"application/vnd.amiga.ami":{source:"iana",extensions:["ami"]},"application/vnd.amundsen.maze+xml":{source:"iana",compressible:!0},"application/vnd.android.ota":{source:"iana"},"application/vnd.android.package-archive":{source:"apache",compressible:!1,extensions:["apk"]},"application/vnd.anki":{source:"iana"},"application/vnd.anser-web-certificate-issue-initiation":{source:"iana",extensions:["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{source:"apache",extensions:["fti"]},"application/vnd.antix.game-component":{source:"iana",extensions:["atx"]},"application/vnd.apache.thrift.binary":{source:"iana"},"application/vnd.apache.thrift.compact":{source:"iana"},"application/vnd.apache.thrift.json":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/vnd.aplextor.warrp+json":{source:"iana",compressible:!0},"application/vnd.apothekende.reservation+json":{source:"iana",compressible:!0},"application/vnd.apple.installer+xml":{source:"iana",compressible:!0,extensions:["mpkg"]},"application/vnd.apple.keynote":{source:"iana",extensions:["key"]},"application/vnd.apple.mpegurl":{source:"iana",extensions:["m3u8"]},"application/vnd.apple.numbers":{source:"iana",extensions:["numbers"]},"application/vnd.apple.pages":{source:"iana",extensions:["pages"]},"application/vnd.apple.pkpass":{compressible:!1,extensions:["pkpass"]},"application/vnd.arastra.swi":{source:"iana"},"application/vnd.aristanetworks.swi":{source:"iana",extensions:["swi"]},"application/vnd.artisan+json":{source:"iana",compressible:!0},"application/vnd.artsquare":{source:"iana"},"application/vnd.astraea-software.iota":{source:"iana",extensions:["iota"]},"application/vnd.audiograph":{source:"iana",extensions:["aep"]},"application/vnd.autopackage":{source:"iana"},"application/vnd.avalon+json":{source:"iana",compressible:!0},"application/vnd.avistar+xml":{source:"iana",compressible:!0},"application/vnd.balsamiq.bmml+xml":{source:"iana",compressible:!0,extensions:["bmml"]},"application/vnd.balsamiq.bmpr":{source:"iana"},"application/vnd.banana-accounting":{source:"iana"},"application/vnd.bbf.usp.error":{source:"iana"},"application/vnd.bbf.usp.msg":{source:"iana"},"application/vnd.bbf.usp.msg+json":{source:"iana",compressible:!0},"application/vnd.bekitzur-stech+json":{source:"iana",compressible:!0},"application/vnd.bint.med-content":{source:"iana"},"application/vnd.biopax.rdf+xml":{source:"iana",compressible:!0},"application/vnd.blink-idb-value-wrapper":{source:"iana"},"application/vnd.blueice.multipass":{source:"iana",extensions:["mpm"]},"application/vnd.bluetooth.ep.oob":{source:"iana"},"application/vnd.bluetooth.le.oob":{source:"iana"},"application/vnd.bmi":{source:"iana",extensions:["bmi"]},"application/vnd.bpf":{source:"iana"},"application/vnd.bpf3":{source:"iana"},"application/vnd.businessobjects":{source:"iana",extensions:["rep"]},"application/vnd.byu.uapi+json":{source:"iana",compressible:!0},"application/vnd.cab-jscript":{source:"iana"},"application/vnd.canon-cpdl":{source:"iana"},"application/vnd.canon-lips":{source:"iana"},"application/vnd.capasystems-pg+json":{source:"iana",compressible:!0},"application/vnd.cendio.thinlinc.clientconf":{source:"iana"},"application/vnd.century-systems.tcp_stream":{source:"iana"},"application/vnd.chemdraw+xml":{source:"iana",compressible:!0,extensions:["cdxml"]},"application/vnd.chess-pgn":{source:"iana"},"application/vnd.chipnuts.karaoke-mmd":{source:"iana",extensions:["mmd"]},"application/vnd.ciedi":{source:"iana"},"application/vnd.cinderella":{source:"iana",extensions:["cdy"]},"application/vnd.cirpack.isdn-ext":{source:"iana"},"application/vnd.citationstyles.style+xml":{source:"iana",compressible:!0,extensions:["csl"]},"application/vnd.claymore":{source:"iana",extensions:["cla"]},"application/vnd.cloanto.rp9":{source:"iana",extensions:["rp9"]},"application/vnd.clonk.c4group":{source:"iana",extensions:["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{source:"iana",extensions:["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{source:"iana",extensions:["c11amz"]},"application/vnd.coffeescript":{source:"iana"},"application/vnd.collabio.xodocuments.document":{source:"iana"},"application/vnd.collabio.xodocuments.document-template":{source:"iana"},"application/vnd.collabio.xodocuments.presentation":{source:"iana"},"application/vnd.collabio.xodocuments.presentation-template":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{source:"iana"},"application/vnd.collection+json":{source:"iana",compressible:!0},"application/vnd.collection.doc+json":{source:"iana",compressible:!0},"application/vnd.collection.next+json":{source:"iana",compressible:!0},"application/vnd.comicbook+zip":{source:"iana",compressible:!1},"application/vnd.comicbook-rar":{source:"iana"},"application/vnd.commerce-battelle":{source:"iana"},"application/vnd.commonspace":{source:"iana",extensions:["csp"]},"application/vnd.contact.cmsg":{source:"iana",extensions:["cdbcmsg"]},"application/vnd.coreos.ignition+json":{source:"iana",compressible:!0},"application/vnd.cosmocaller":{source:"iana",extensions:["cmc"]},"application/vnd.crick.clicker":{source:"iana",extensions:["clkx"]},"application/vnd.crick.clicker.keyboard":{source:"iana",extensions:["clkk"]},"application/vnd.crick.clicker.palette":{source:"iana",extensions:["clkp"]},"application/vnd.crick.clicker.template":{source:"iana",extensions:["clkt"]},"application/vnd.crick.clicker.wordbank":{source:"iana",extensions:["clkw"]},"application/vnd.criticaltools.wbs+xml":{source:"iana",compressible:!0,extensions:["wbs"]},"application/vnd.cryptii.pipe+json":{source:"iana",compressible:!0},"application/vnd.crypto-shade-file":{source:"iana"},"application/vnd.cryptomator.encrypted":{source:"iana"},"application/vnd.ctc-posml":{source:"iana",extensions:["pml"]},"application/vnd.ctct.ws+xml":{source:"iana",compressible:!0},"application/vnd.cups-pdf":{source:"iana"},"application/vnd.cups-postscript":{source:"iana"},"application/vnd.cups-ppd":{source:"iana",extensions:["ppd"]},"application/vnd.cups-raster":{source:"iana"},"application/vnd.cups-raw":{source:"iana"},"application/vnd.curl":{source:"iana"},"application/vnd.curl.car":{source:"apache",extensions:["car"]},"application/vnd.curl.pcurl":{source:"apache",extensions:["pcurl"]},"application/vnd.cyan.dean.root+xml":{source:"iana",compressible:!0},"application/vnd.cybank":{source:"iana"},"application/vnd.cyclonedx+json":{source:"iana",compressible:!0},"application/vnd.cyclonedx+xml":{source:"iana",compressible:!0},"application/vnd.d2l.coursepackage1p0+zip":{source:"iana",compressible:!1},"application/vnd.d3m-dataset":{source:"iana"},"application/vnd.d3m-problem":{source:"iana"},"application/vnd.dart":{source:"iana",compressible:!0,extensions:["dart"]},"application/vnd.data-vision.rdz":{source:"iana",extensions:["rdz"]},"application/vnd.datapackage+json":{source:"iana",compressible:!0},"application/vnd.dataresource+json":{source:"iana",compressible:!0},"application/vnd.dbf":{source:"iana",extensions:["dbf"]},"application/vnd.debian.binary-package":{source:"iana"},"application/vnd.dece.data":{source:"iana",extensions:["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{source:"iana",compressible:!0,extensions:["uvt","uvvt"]},"application/vnd.dece.unspecified":{source:"iana",extensions:["uvx","uvvx"]},"application/vnd.dece.zip":{source:"iana",extensions:["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{source:"iana",extensions:["fe_launch"]},"application/vnd.desmume.movie":{source:"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{source:"iana"},"application/vnd.dm.delegation+xml":{source:"iana",compressible:!0},"application/vnd.dna":{source:"iana",extensions:["dna"]},"application/vnd.document+json":{source:"iana",compressible:!0},"application/vnd.dolby.mlp":{source:"apache",extensions:["mlp"]},"application/vnd.dolby.mobile.1":{source:"iana"},"application/vnd.dolby.mobile.2":{source:"iana"},"application/vnd.doremir.scorecloud-binary-document":{source:"iana"},"application/vnd.dpgraph":{source:"iana",extensions:["dpg"]},"application/vnd.dreamfactory":{source:"iana",extensions:["dfac"]},"application/vnd.drive+json":{source:"iana",compressible:!0},"application/vnd.ds-keypoint":{source:"apache",extensions:["kpxx"]},"application/vnd.dtg.local":{source:"iana"},"application/vnd.dtg.local.flash":{source:"iana"},"application/vnd.dtg.local.html":{source:"iana"},"application/vnd.dvb.ait":{source:"iana",extensions:["ait"]},"application/vnd.dvb.dvbisl+xml":{source:"iana",compressible:!0},"application/vnd.dvb.dvbj":{source:"iana"},"application/vnd.dvb.esgcontainer":{source:"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess2":{source:"iana"},"application/vnd.dvb.ipdcesgpdd":{source:"iana"},"application/vnd.dvb.ipdcroaming":{source:"iana"},"application/vnd.dvb.iptv.alfec-base":{source:"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{source:"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-container+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-generic+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-msglist+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-request+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-response+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-init+xml":{source:"iana",compressible:!0},"application/vnd.dvb.pfr":{source:"iana"},"application/vnd.dvb.service":{source:"iana",extensions:["svc"]},"application/vnd.dxr":{source:"iana"},"application/vnd.dynageo":{source:"iana",extensions:["geo"]},"application/vnd.dzr":{source:"iana"},"application/vnd.easykaraoke.cdgdownload":{source:"iana"},"application/vnd.ecdis-update":{source:"iana"},"application/vnd.ecip.rlp":{source:"iana"},"application/vnd.ecowin.chart":{source:"iana",extensions:["mag"]},"application/vnd.ecowin.filerequest":{source:"iana"},"application/vnd.ecowin.fileupdate":{source:"iana"},"application/vnd.ecowin.series":{source:"iana"},"application/vnd.ecowin.seriesrequest":{source:"iana"},"application/vnd.ecowin.seriesupdate":{source:"iana"},"application/vnd.efi.img":{source:"iana"},"application/vnd.efi.iso":{source:"iana"},"application/vnd.emclient.accessrequest+xml":{source:"iana",compressible:!0},"application/vnd.enliven":{source:"iana",extensions:["nml"]},"application/vnd.enphase.envoy":{source:"iana"},"application/vnd.eprints.data+xml":{source:"iana",compressible:!0},"application/vnd.epson.esf":{source:"iana",extensions:["esf"]},"application/vnd.epson.msf":{source:"iana",extensions:["msf"]},"application/vnd.epson.quickanime":{source:"iana",extensions:["qam"]},"application/vnd.epson.salt":{source:"iana",extensions:["slt"]},"application/vnd.epson.ssf":{source:"iana",extensions:["ssf"]},"application/vnd.ericsson.quickcall":{source:"iana"},"application/vnd.espass-espass+zip":{source:"iana",compressible:!1},"application/vnd.eszigno3+xml":{source:"iana",compressible:!0,extensions:["es3","et3"]},"application/vnd.etsi.aoc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.asic-e+zip":{source:"iana",compressible:!1},"application/vnd.etsi.asic-s+zip":{source:"iana",compressible:!1},"application/vnd.etsi.cug+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvcommand+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-bc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-cod+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-npvr+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvservice+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsync+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvueprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mcid+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mheg5":{source:"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{source:"iana",compressible:!0},"application/vnd.etsi.pstn+xml":{source:"iana",compressible:!0},"application/vnd.etsi.sci+xml":{source:"iana",compressible:!0},"application/vnd.etsi.simservs+xml":{source:"iana",compressible:!0},"application/vnd.etsi.timestamp-token":{source:"iana"},"application/vnd.etsi.tsl+xml":{source:"iana",compressible:!0},"application/vnd.etsi.tsl.der":{source:"iana"},"application/vnd.eudora.data":{source:"iana"},"application/vnd.evolv.ecig.profile":{source:"iana"},"application/vnd.evolv.ecig.settings":{source:"iana"},"application/vnd.evolv.ecig.theme":{source:"iana"},"application/vnd.exstream-empower+zip":{source:"iana",compressible:!1},"application/vnd.exstream-package":{source:"iana"},"application/vnd.ezpix-album":{source:"iana",extensions:["ez2"]},"application/vnd.ezpix-package":{source:"iana",extensions:["ez3"]},"application/vnd.f-secure.mobile":{source:"iana"},"application/vnd.fastcopy-disk-image":{source:"iana"},"application/vnd.fdf":{source:"iana",extensions:["fdf"]},"application/vnd.fdsn.mseed":{source:"iana",extensions:["mseed"]},"application/vnd.fdsn.seed":{source:"iana",extensions:["seed","dataless"]},"application/vnd.ffsns":{source:"iana"},"application/vnd.ficlab.flb+zip":{source:"iana",compressible:!1},"application/vnd.filmit.zfc":{source:"iana"},"application/vnd.fints":{source:"iana"},"application/vnd.firemonkeys.cloudcell":{source:"iana"},"application/vnd.flographit":{source:"iana",extensions:["gph"]},"application/vnd.fluxtime.clip":{source:"iana",extensions:["ftc"]},"application/vnd.font-fontforge-sfd":{source:"iana"},"application/vnd.framemaker":{source:"iana",extensions:["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{source:"iana",extensions:["fnc"]},"application/vnd.frogans.ltf":{source:"iana",extensions:["ltf"]},"application/vnd.fsc.weblaunch":{source:"iana",extensions:["fsc"]},"application/vnd.fujitsu.oasys":{source:"iana",extensions:["oas"]},"application/vnd.fujitsu.oasys2":{source:"iana",extensions:["oa2"]},"application/vnd.fujitsu.oasys3":{source:"iana",extensions:["oa3"]},"application/vnd.fujitsu.oasysgp":{source:"iana",extensions:["fg5"]},"application/vnd.fujitsu.oasysprs":{source:"iana",extensions:["bh2"]},"application/vnd.fujixerox.art-ex":{source:"iana"},"application/vnd.fujixerox.art4":{source:"iana"},"application/vnd.fujixerox.ddd":{source:"iana",extensions:["ddd"]},"application/vnd.fujixerox.docuworks":{source:"iana",extensions:["xdw"]},"application/vnd.fujixerox.docuworks.binder":{source:"iana",extensions:["xbd"]},"application/vnd.fujixerox.docuworks.container":{source:"iana"},"application/vnd.fujixerox.hbpl":{source:"iana"},"application/vnd.fut-misnet":{source:"iana"},"application/vnd.futoin+cbor":{source:"iana"},"application/vnd.futoin+json":{source:"iana",compressible:!0},"application/vnd.fuzzysheet":{source:"iana",extensions:["fzs"]},"application/vnd.genomatix.tuxedo":{source:"iana",extensions:["txd"]},"application/vnd.gentics.grd+json":{source:"iana",compressible:!0},"application/vnd.geo+json":{source:"iana",compressible:!0},"application/vnd.geocube+xml":{source:"iana",compressible:!0},"application/vnd.geogebra.file":{source:"iana",extensions:["ggb"]},"application/vnd.geogebra.slides":{source:"iana"},"application/vnd.geogebra.tool":{source:"iana",extensions:["ggt"]},"application/vnd.geometry-explorer":{source:"iana",extensions:["gex","gre"]},"application/vnd.geonext":{source:"iana",extensions:["gxt"]},"application/vnd.geoplan":{source:"iana",extensions:["g2w"]},"application/vnd.geospace":{source:"iana",extensions:["g3w"]},"application/vnd.gerber":{source:"iana"},"application/vnd.globalplatform.card-content-mgt":{source:"iana"},"application/vnd.globalplatform.card-content-mgt-response":{source:"iana"},"application/vnd.gmx":{source:"iana",extensions:["gmx"]},"application/vnd.google-apps.document":{compressible:!1,extensions:["gdoc"]},"application/vnd.google-apps.presentation":{compressible:!1,extensions:["gslides"]},"application/vnd.google-apps.spreadsheet":{compressible:!1,extensions:["gsheet"]},"application/vnd.google-earth.kml+xml":{source:"iana",compressible:!0,extensions:["kml"]},"application/vnd.google-earth.kmz":{source:"iana",compressible:!1,extensions:["kmz"]},"application/vnd.gov.sk.e-form+xml":{source:"iana",compressible:!0},"application/vnd.gov.sk.e-form+zip":{source:"iana",compressible:!1},"application/vnd.gov.sk.xmldatacontainer+xml":{source:"iana",compressible:!0},"application/vnd.grafeq":{source:"iana",extensions:["gqf","gqs"]},"application/vnd.gridmp":{source:"iana"},"application/vnd.groove-account":{source:"iana",extensions:["gac"]},"application/vnd.groove-help":{source:"iana",extensions:["ghf"]},"application/vnd.groove-identity-message":{source:"iana",extensions:["gim"]},"application/vnd.groove-injector":{source:"iana",extensions:["grv"]},"application/vnd.groove-tool-message":{source:"iana",extensions:["gtm"]},"application/vnd.groove-tool-template":{source:"iana",extensions:["tpl"]},"application/vnd.groove-vcard":{source:"iana",extensions:["vcg"]},"application/vnd.hal+json":{source:"iana",compressible:!0},"application/vnd.hal+xml":{source:"iana",compressible:!0,extensions:["hal"]},"application/vnd.handheld-entertainment+xml":{source:"iana",compressible:!0,extensions:["zmm"]},"application/vnd.hbci":{source:"iana",extensions:["hbci"]},"application/vnd.hc+json":{source:"iana",compressible:!0},"application/vnd.hcl-bireports":{source:"iana"},"application/vnd.hdt":{source:"iana"},"application/vnd.heroku+json":{source:"iana",compressible:!0},"application/vnd.hhe.lesson-player":{source:"iana",extensions:["les"]},"application/vnd.hp-hpgl":{source:"iana",extensions:["hpgl"]},"application/vnd.hp-hpid":{source:"iana",extensions:["hpid"]},"application/vnd.hp-hps":{source:"iana",extensions:["hps"]},"application/vnd.hp-jlyt":{source:"iana",extensions:["jlt"]},"application/vnd.hp-pcl":{source:"iana",extensions:["pcl"]},"application/vnd.hp-pclxl":{source:"iana",extensions:["pclxl"]},"application/vnd.httphone":{source:"iana"},"application/vnd.hydrostatix.sof-data":{source:"iana",extensions:["sfd-hdstx"]},"application/vnd.hyper+json":{source:"iana",compressible:!0},"application/vnd.hyper-item+json":{source:"iana",compressible:!0},"application/vnd.hyperdrive+json":{source:"iana",compressible:!0},"application/vnd.hzn-3d-crossword":{source:"iana"},"application/vnd.ibm.afplinedata":{source:"iana"},"application/vnd.ibm.electronic-media":{source:"iana"},"application/vnd.ibm.minipay":{source:"iana",extensions:["mpy"]},"application/vnd.ibm.modcap":{source:"iana",extensions:["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{source:"iana",extensions:["irm"]},"application/vnd.ibm.secure-container":{source:"iana",extensions:["sc"]},"application/vnd.iccprofile":{source:"iana",extensions:["icc","icm"]},"application/vnd.ieee.1905":{source:"iana"},"application/vnd.igloader":{source:"iana",extensions:["igl"]},"application/vnd.imagemeter.folder+zip":{source:"iana",compressible:!1},"application/vnd.imagemeter.image+zip":{source:"iana",compressible:!1},"application/vnd.immervision-ivp":{source:"iana",extensions:["ivp"]},"application/vnd.immervision-ivu":{source:"iana",extensions:["ivu"]},"application/vnd.ims.imsccv1p1":{source:"iana"},"application/vnd.ims.imsccv1p2":{source:"iana"},"application/vnd.ims.imsccv1p3":{source:"iana"},"application/vnd.ims.lis.v2.result+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy.id+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings.simple+json":{source:"iana",compressible:!0},"application/vnd.informedcontrol.rms+xml":{source:"iana",compressible:!0},"application/vnd.informix-visionary":{source:"iana"},"application/vnd.infotech.project":{source:"iana"},"application/vnd.infotech.project+xml":{source:"iana",compressible:!0},"application/vnd.innopath.wamp.notification":{source:"iana"},"application/vnd.insors.igm":{source:"iana",extensions:["igm"]},"application/vnd.intercon.formnet":{source:"iana",extensions:["xpw","xpx"]},"application/vnd.intergeo":{source:"iana",extensions:["i2g"]},"application/vnd.intertrust.digibox":{source:"iana"},"application/vnd.intertrust.nncp":{source:"iana"},"application/vnd.intu.qbo":{source:"iana",extensions:["qbo"]},"application/vnd.intu.qfx":{source:"iana",extensions:["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.conceptitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.knowledgeitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsmessage+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.packageitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.planningitem+xml":{source:"iana",compressible:!0},"application/vnd.ipunplugged.rcprofile":{source:"iana",extensions:["rcprofile"]},"application/vnd.irepository.package+xml":{source:"iana",compressible:!0,extensions:["irp"]},"application/vnd.is-xpr":{source:"iana",extensions:["xpr"]},"application/vnd.isac.fcs":{source:"iana",extensions:["fcs"]},"application/vnd.iso11783-10+zip":{source:"iana",compressible:!1},"application/vnd.jam":{source:"iana",extensions:["jam"]},"application/vnd.japannet-directory-service":{source:"iana"},"application/vnd.japannet-jpnstore-wakeup":{source:"iana"},"application/vnd.japannet-payment-wakeup":{source:"iana"},"application/vnd.japannet-registration":{source:"iana"},"application/vnd.japannet-registration-wakeup":{source:"iana"},"application/vnd.japannet-setstore-wakeup":{source:"iana"},"application/vnd.japannet-verification":{source:"iana"},"application/vnd.japannet-verification-wakeup":{source:"iana"},"application/vnd.jcp.javame.midlet-rms":{source:"iana",extensions:["rms"]},"application/vnd.jisp":{source:"iana",extensions:["jisp"]},"application/vnd.joost.joda-archive":{source:"iana",extensions:["joda"]},"application/vnd.jsk.isdn-ngn":{source:"iana"},"application/vnd.kahootz":{source:"iana",extensions:["ktz","ktr"]},"application/vnd.kde.karbon":{source:"iana",extensions:["karbon"]},"application/vnd.kde.kchart":{source:"iana",extensions:["chrt"]},"application/vnd.kde.kformula":{source:"iana",extensions:["kfo"]},"application/vnd.kde.kivio":{source:"iana",extensions:["flw"]},"application/vnd.kde.kontour":{source:"iana",extensions:["kon"]},"application/vnd.kde.kpresenter":{source:"iana",extensions:["kpr","kpt"]},"application/vnd.kde.kspread":{source:"iana",extensions:["ksp"]},"application/vnd.kde.kword":{source:"iana",extensions:["kwd","kwt"]},"application/vnd.kenameaapp":{source:"iana",extensions:["htke"]},"application/vnd.kidspiration":{source:"iana",extensions:["kia"]},"application/vnd.kinar":{source:"iana",extensions:["kne","knp"]},"application/vnd.koan":{source:"iana",extensions:["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{source:"iana",extensions:["sse"]},"application/vnd.las":{source:"iana"},"application/vnd.las.las+json":{source:"iana",compressible:!0},"application/vnd.las.las+xml":{source:"iana",compressible:!0,extensions:["lasxml"]},"application/vnd.laszip":{source:"iana"},"application/vnd.leap+json":{source:"iana",compressible:!0},"application/vnd.liberty-request+xml":{source:"iana",compressible:!0},"application/vnd.llamagraphics.life-balance.desktop":{source:"iana",extensions:["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{source:"iana",compressible:!0,extensions:["lbe"]},"application/vnd.logipipe.circuit+zip":{source:"iana",compressible:!1},"application/vnd.loom":{source:"iana"},"application/vnd.lotus-1-2-3":{source:"iana",extensions:["123"]},"application/vnd.lotus-approach":{source:"iana",extensions:["apr"]},"application/vnd.lotus-freelance":{source:"iana",extensions:["pre"]},"application/vnd.lotus-notes":{source:"iana",extensions:["nsf"]},"application/vnd.lotus-organizer":{source:"iana",extensions:["org"]},"application/vnd.lotus-screencam":{source:"iana",extensions:["scm"]},"application/vnd.lotus-wordpro":{source:"iana",extensions:["lwp"]},"application/vnd.macports.portpkg":{source:"iana",extensions:["portpkg"]},"application/vnd.mapbox-vector-tile":{source:"iana"},"application/vnd.marlin.drm.actiontoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.conftoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.license+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.mdcf":{source:"iana"},"application/vnd.mason+json":{source:"iana",compressible:!0},"application/vnd.maxmind.maxmind-db":{source:"iana"},"application/vnd.mcd":{source:"iana",extensions:["mcd"]},"application/vnd.medcalcdata":{source:"iana",extensions:["mc1"]},"application/vnd.mediastation.cdkey":{source:"iana",extensions:["cdkey"]},"application/vnd.meridian-slingshot":{source:"iana"},"application/vnd.mfer":{source:"iana",extensions:["mwf"]},"application/vnd.mfmp":{source:"iana",extensions:["mfm"]},"application/vnd.micro+json":{source:"iana",compressible:!0},"application/vnd.micrografx.flo":{source:"iana",extensions:["flo"]},"application/vnd.micrografx.igx":{source:"iana",extensions:["igx"]},"application/vnd.microsoft.portable-executable":{source:"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{source:"iana"},"application/vnd.miele+json":{source:"iana",compressible:!0},"application/vnd.mif":{source:"iana",extensions:["mif"]},"application/vnd.minisoft-hp3000-save":{source:"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{source:"iana"},"application/vnd.mobius.daf":{source:"iana",extensions:["daf"]},"application/vnd.mobius.dis":{source:"iana",extensions:["dis"]},"application/vnd.mobius.mbk":{source:"iana",extensions:["mbk"]},"application/vnd.mobius.mqy":{source:"iana",extensions:["mqy"]},"application/vnd.mobius.msl":{source:"iana",extensions:["msl"]},"application/vnd.mobius.plc":{source:"iana",extensions:["plc"]},"application/vnd.mobius.txf":{source:"iana",extensions:["txf"]},"application/vnd.mophun.application":{source:"iana",extensions:["mpn"]},"application/vnd.mophun.certificate":{source:"iana",extensions:["mpc"]},"application/vnd.motorola.flexsuite":{source:"iana"},"application/vnd.motorola.flexsuite.adsi":{source:"iana"},"application/vnd.motorola.flexsuite.fis":{source:"iana"},"application/vnd.motorola.flexsuite.gotap":{source:"iana"},"application/vnd.motorola.flexsuite.kmr":{source:"iana"},"application/vnd.motorola.flexsuite.ttc":{source:"iana"},"application/vnd.motorola.flexsuite.wem":{source:"iana"},"application/vnd.motorola.iprm":{source:"iana"},"application/vnd.mozilla.xul+xml":{source:"iana",compressible:!0,extensions:["xul"]},"application/vnd.ms-3mfdocument":{source:"iana"},"application/vnd.ms-artgalry":{source:"iana",extensions:["cil"]},"application/vnd.ms-asf":{source:"iana"},"application/vnd.ms-cab-compressed":{source:"iana",extensions:["cab"]},"application/vnd.ms-color.iccprofile":{source:"apache"},"application/vnd.ms-excel":{source:"iana",compressible:!1,extensions:["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{source:"iana",extensions:["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{source:"iana",extensions:["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{source:"iana",extensions:["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{source:"iana",extensions:["xltm"]},"application/vnd.ms-fontobject":{source:"iana",compressible:!0,extensions:["eot"]},"application/vnd.ms-htmlhelp":{source:"iana",extensions:["chm"]},"application/vnd.ms-ims":{source:"iana",extensions:["ims"]},"application/vnd.ms-lrm":{source:"iana",extensions:["lrm"]},"application/vnd.ms-office.activex+xml":{source:"iana",compressible:!0},"application/vnd.ms-officetheme":{source:"iana",extensions:["thmx"]},"application/vnd.ms-opentype":{source:"apache",compressible:!0},"application/vnd.ms-outlook":{compressible:!1,extensions:["msg"]},"application/vnd.ms-package.obfuscated-opentype":{source:"apache"},"application/vnd.ms-pki.seccat":{source:"apache",extensions:["cat"]},"application/vnd.ms-pki.stl":{source:"apache",extensions:["stl"]},"application/vnd.ms-playready.initiator+xml":{source:"iana",compressible:!0},"application/vnd.ms-powerpoint":{source:"iana",compressible:!1,extensions:["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{source:"iana",extensions:["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{source:"iana",extensions:["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{source:"iana",extensions:["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{source:"iana",extensions:["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{source:"iana",extensions:["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{source:"iana",compressible:!0},"application/vnd.ms-printing.printticket+xml":{source:"apache",compressible:!0},"application/vnd.ms-printschematicket+xml":{source:"iana",compressible:!0},"application/vnd.ms-project":{source:"iana",extensions:["mpp","mpt"]},"application/vnd.ms-tnef":{source:"iana"},"application/vnd.ms-windows.devicepairing":{source:"iana"},"application/vnd.ms-windows.nwprinting.oob":{source:"iana"},"application/vnd.ms-windows.printerpairing":{source:"iana"},"application/vnd.ms-windows.wsd.oob":{source:"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.lic-resp":{source:"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.meter-resp":{source:"iana"},"application/vnd.ms-word.document.macroenabled.12":{source:"iana",extensions:["docm"]},"application/vnd.ms-word.template.macroenabled.12":{source:"iana",extensions:["dotm"]},"application/vnd.ms-works":{source:"iana",extensions:["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{source:"iana",extensions:["wpl"]},"application/vnd.ms-xpsdocument":{source:"iana",compressible:!1,extensions:["xps"]},"application/vnd.msa-disk-image":{source:"iana"},"application/vnd.mseq":{source:"iana",extensions:["mseq"]},"application/vnd.msign":{source:"iana"},"application/vnd.multiad.creator":{source:"iana"},"application/vnd.multiad.creator.cif":{source:"iana"},"application/vnd.music-niff":{source:"iana"},"application/vnd.musician":{source:"iana",extensions:["mus"]},"application/vnd.muvee.style":{source:"iana",extensions:["msty"]},"application/vnd.mynfc":{source:"iana",extensions:["taglet"]},"application/vnd.ncd.control":{source:"iana"},"application/vnd.ncd.reference":{source:"iana"},"application/vnd.nearst.inv+json":{source:"iana",compressible:!0},"application/vnd.nebumind.line":{source:"iana"},"application/vnd.nervana":{source:"iana"},"application/vnd.netfpx":{source:"iana"},"application/vnd.neurolanguage.nlu":{source:"iana",extensions:["nlu"]},"application/vnd.nimn":{source:"iana"},"application/vnd.nintendo.nitro.rom":{source:"iana"},"application/vnd.nintendo.snes.rom":{source:"iana"},"application/vnd.nitf":{source:"iana",extensions:["ntf","nitf"]},"application/vnd.noblenet-directory":{source:"iana",extensions:["nnd"]},"application/vnd.noblenet-sealer":{source:"iana",extensions:["nns"]},"application/vnd.noblenet-web":{source:"iana",extensions:["nnw"]},"application/vnd.nokia.catalogs":{source:"iana"},"application/vnd.nokia.conml+wbxml":{source:"iana"},"application/vnd.nokia.conml+xml":{source:"iana",compressible:!0},"application/vnd.nokia.iptv.config+xml":{source:"iana",compressible:!0},"application/vnd.nokia.isds-radio-presets":{source:"iana"},"application/vnd.nokia.landmark+wbxml":{source:"iana"},"application/vnd.nokia.landmark+xml":{source:"iana",compressible:!0},"application/vnd.nokia.landmarkcollection+xml":{source:"iana",compressible:!0},"application/vnd.nokia.n-gage.ac+xml":{source:"iana",compressible:!0,extensions:["ac"]},"application/vnd.nokia.n-gage.data":{source:"iana",extensions:["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{source:"iana",extensions:["n-gage"]},"application/vnd.nokia.ncd":{source:"iana"},"application/vnd.nokia.pcd+wbxml":{source:"iana"},"application/vnd.nokia.pcd+xml":{source:"iana",compressible:!0},"application/vnd.nokia.radio-preset":{source:"iana",extensions:["rpst"]},"application/vnd.nokia.radio-presets":{source:"iana",extensions:["rpss"]},"application/vnd.novadigm.edm":{source:"iana",extensions:["edm"]},"application/vnd.novadigm.edx":{source:"iana",extensions:["edx"]},"application/vnd.novadigm.ext":{source:"iana",extensions:["ext"]},"application/vnd.ntt-local.content-share":{source:"iana"},"application/vnd.ntt-local.file-transfer":{source:"iana"},"application/vnd.ntt-local.ogw_remote-access":{source:"iana"},"application/vnd.ntt-local.sip-ta_remote":{source:"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{source:"iana"},"application/vnd.oasis.opendocument.chart":{source:"iana",extensions:["odc"]},"application/vnd.oasis.opendocument.chart-template":{source:"iana",extensions:["otc"]},"application/vnd.oasis.opendocument.database":{source:"iana",extensions:["odb"]},"application/vnd.oasis.opendocument.formula":{source:"iana",extensions:["odf"]},"application/vnd.oasis.opendocument.formula-template":{source:"iana",extensions:["odft"]},"application/vnd.oasis.opendocument.graphics":{source:"iana",compressible:!1,extensions:["odg"]},"application/vnd.oasis.opendocument.graphics-template":{source:"iana",extensions:["otg"]},"application/vnd.oasis.opendocument.image":{source:"iana",extensions:["odi"]},"application/vnd.oasis.opendocument.image-template":{source:"iana",extensions:["oti"]},"application/vnd.oasis.opendocument.presentation":{source:"iana",compressible:!1,extensions:["odp"]},"application/vnd.oasis.opendocument.presentation-template":{source:"iana",extensions:["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{source:"iana",compressible:!1,extensions:["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{source:"iana",extensions:["ots"]},"application/vnd.oasis.opendocument.text":{source:"iana",compressible:!1,extensions:["odt"]},"application/vnd.oasis.opendocument.text-master":{source:"iana",extensions:["odm"]},"application/vnd.oasis.opendocument.text-template":{source:"iana",extensions:["ott"]},"application/vnd.oasis.opendocument.text-web":{source:"iana",extensions:["oth"]},"application/vnd.obn":{source:"iana"},"application/vnd.ocf+cbor":{source:"iana"},"application/vnd.oci.image.manifest.v1+json":{source:"iana",compressible:!0},"application/vnd.oftn.l10n+json":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessdownload+xml":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessstreaming+xml":{source:"iana",compressible:!0},"application/vnd.oipf.cspg-hexbinary":{source:"iana"},"application/vnd.oipf.dae.svg+xml":{source:"iana",compressible:!0},"application/vnd.oipf.dae.xhtml+xml":{source:"iana",compressible:!0},"application/vnd.oipf.mippvcontrolmessage+xml":{source:"iana",compressible:!0},"application/vnd.oipf.pae.gem":{source:"iana"},"application/vnd.oipf.spdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.oipf.spdlist+xml":{source:"iana",compressible:!0},"application/vnd.oipf.ueprofile+xml":{source:"iana",compressible:!0},"application/vnd.oipf.userprofile+xml":{source:"iana",compressible:!0},"application/vnd.olpc-sugar":{source:"iana",extensions:["xo"]},"application/vnd.oma-scws-config":{source:"iana"},"application/vnd.oma-scws-http-request":{source:"iana"},"application/vnd.oma-scws-http-response":{source:"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.drm-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.imd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.ltkm":{source:"iana"},"application/vnd.oma.bcast.notification+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.provisioningtrigger":{source:"iana"},"application/vnd.oma.bcast.sgboot":{source:"iana"},"application/vnd.oma.bcast.sgdd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sgdu":{source:"iana"},"application/vnd.oma.bcast.simple-symbol-container":{source:"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sprov+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.stkm":{source:"iana"},"application/vnd.oma.cab-address-book+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-feature-handler+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-pcc+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-subs-invite+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-user-prefs+xml":{source:"iana",compressible:!0},"application/vnd.oma.dcd":{source:"iana"},"application/vnd.oma.dcdc":{source:"iana"},"application/vnd.oma.dd2+xml":{source:"iana",compressible:!0,extensions:["dd2"]},"application/vnd.oma.drm.risd+xml":{source:"iana",compressible:!0},"application/vnd.oma.group-usage-list+xml":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+cbor":{source:"iana"},"application/vnd.oma.lwm2m+json":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+tlv":{source:"iana"},"application/vnd.oma.pal+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.detailed-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.final-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.groups+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.invocation-descriptor+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.optimized-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.push":{source:"iana"},"application/vnd.oma.scidm.messages+xml":{source:"iana",compressible:!0},"application/vnd.oma.xcap-directory+xml":{source:"iana",compressible:!0},"application/vnd.omads-email+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-file+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-folder+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omaloc-supl-init":{source:"iana"},"application/vnd.onepager":{source:"iana"},"application/vnd.onepagertamp":{source:"iana"},"application/vnd.onepagertamx":{source:"iana"},"application/vnd.onepagertat":{source:"iana"},"application/vnd.onepagertatp":{source:"iana"},"application/vnd.onepagertatx":{source:"iana"},"application/vnd.openblox.game+xml":{source:"iana",compressible:!0,extensions:["obgx"]},"application/vnd.openblox.game-binary":{source:"iana"},"application/vnd.openeye.oeb":{source:"iana"},"application/vnd.openofficeorg.extension":{source:"apache",extensions:["oxt"]},"application/vnd.openstreetmap.data+xml":{source:"iana",compressible:!0,extensions:["osm"]},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawing+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",compressible:!1,extensions:["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slide":{source:"iana",extensions:["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{source:"iana",extensions:["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.template":{source:"iana",extensions:["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",compressible:!1,extensions:["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{source:"iana",extensions:["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.theme+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.vmldrawing":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",compressible:!1,extensions:["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{source:"iana",extensions:["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.core-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.relationships+xml":{source:"iana",compressible:!0},"application/vnd.oracle.resource+json":{source:"iana",compressible:!0},"application/vnd.orange.indata":{source:"iana"},"application/vnd.osa.netdeploy":{source:"iana"},"application/vnd.osgeo.mapguide.package":{source:"iana",extensions:["mgp"]},"application/vnd.osgi.bundle":{source:"iana"},"application/vnd.osgi.dp":{source:"iana",extensions:["dp"]},"application/vnd.osgi.subsystem":{source:"iana",extensions:["esa"]},"application/vnd.otps.ct-kip+xml":{source:"iana",compressible:!0},"application/vnd.oxli.countgraph":{source:"iana"},"application/vnd.pagerduty+json":{source:"iana",compressible:!0},"application/vnd.palm":{source:"iana",extensions:["pdb","pqa","oprc"]},"application/vnd.panoply":{source:"iana"},"application/vnd.paos.xml":{source:"iana"},"application/vnd.patentdive":{source:"iana"},"application/vnd.patientecommsdoc":{source:"iana"},"application/vnd.pawaafile":{source:"iana",extensions:["paw"]},"application/vnd.pcos":{source:"iana"},"application/vnd.pg.format":{source:"iana",extensions:["str"]},"application/vnd.pg.osasli":{source:"iana",extensions:["ei6"]},"application/vnd.piaccess.application-licence":{source:"iana"},"application/vnd.picsel":{source:"iana",extensions:["efif"]},"application/vnd.pmi.widget":{source:"iana",extensions:["wg"]},"application/vnd.poc.group-advertisement+xml":{source:"iana",compressible:!0},"application/vnd.pocketlearn":{source:"iana",extensions:["plf"]},"application/vnd.powerbuilder6":{source:"iana",extensions:["pbd"]},"application/vnd.powerbuilder6-s":{source:"iana"},"application/vnd.powerbuilder7":{source:"iana"},"application/vnd.powerbuilder7-s":{source:"iana"},"application/vnd.powerbuilder75":{source:"iana"},"application/vnd.powerbuilder75-s":{source:"iana"},"application/vnd.preminet":{source:"iana"},"application/vnd.previewsystems.box":{source:"iana",extensions:["box"]},"application/vnd.proteus.magazine":{source:"iana",extensions:["mgz"]},"application/vnd.psfs":{source:"iana"},"application/vnd.publishare-delta-tree":{source:"iana",extensions:["qps"]},"application/vnd.pvi.ptid1":{source:"iana",extensions:["ptid"]},"application/vnd.pwg-multiplexed":{source:"iana"},"application/vnd.pwg-xhtml-print+xml":{source:"iana",compressible:!0},"application/vnd.qualcomm.brew-app-res":{source:"iana"},"application/vnd.quarantainenet":{source:"iana"},"application/vnd.quark.quarkxpress":{source:"iana",extensions:["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{source:"iana"},"application/vnd.radisys.moml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conn+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-stream+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-base+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-detect+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-group+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-speech+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-transform+xml":{source:"iana",compressible:!0},"application/vnd.rainstor.data":{source:"iana"},"application/vnd.rapid":{source:"iana"},"application/vnd.rar":{source:"iana",extensions:["rar"]},"application/vnd.realvnc.bed":{source:"iana",extensions:["bed"]},"application/vnd.recordare.musicxml":{source:"iana",extensions:["mxl"]},"application/vnd.recordare.musicxml+xml":{source:"iana",compressible:!0,extensions:["musicxml"]},"application/vnd.renlearn.rlprint":{source:"iana"},"application/vnd.restful+json":{source:"iana",compressible:!0},"application/vnd.rig.cryptonote":{source:"iana",extensions:["cryptonote"]},"application/vnd.rim.cod":{source:"apache",extensions:["cod"]},"application/vnd.rn-realmedia":{source:"apache",extensions:["rm"]},"application/vnd.rn-realmedia-vbr":{source:"apache",extensions:["rmvb"]},"application/vnd.route66.link66+xml":{source:"iana",compressible:!0,extensions:["link66"]},"application/vnd.rs-274x":{source:"iana"},"application/vnd.ruckus.download":{source:"iana"},"application/vnd.s3sms":{source:"iana"},"application/vnd.sailingtracker.track":{source:"iana",extensions:["st"]},"application/vnd.sar":{source:"iana"},"application/vnd.sbm.cid":{source:"iana"},"application/vnd.sbm.mid2":{source:"iana"},"application/vnd.scribus":{source:"iana"},"application/vnd.sealed.3df":{source:"iana"},"application/vnd.sealed.csf":{source:"iana"},"application/vnd.sealed.doc":{source:"iana"},"application/vnd.sealed.eml":{source:"iana"},"application/vnd.sealed.mht":{source:"iana"},"application/vnd.sealed.net":{source:"iana"},"application/vnd.sealed.ppt":{source:"iana"},"application/vnd.sealed.tiff":{source:"iana"},"application/vnd.sealed.xls":{source:"iana"},"application/vnd.sealedmedia.softseal.html":{source:"iana"},"application/vnd.sealedmedia.softseal.pdf":{source:"iana"},"application/vnd.seemail":{source:"iana",extensions:["see"]},"application/vnd.seis+json":{source:"iana",compressible:!0},"application/vnd.sema":{source:"iana",extensions:["sema"]},"application/vnd.semd":{source:"iana",extensions:["semd"]},"application/vnd.semf":{source:"iana",extensions:["semf"]},"application/vnd.shade-save-file":{source:"iana"},"application/vnd.shana.informed.formdata":{source:"iana",extensions:["ifm"]},"application/vnd.shana.informed.formtemplate":{source:"iana",extensions:["itp"]},"application/vnd.shana.informed.interchange":{source:"iana",extensions:["iif"]},"application/vnd.shana.informed.package":{source:"iana",extensions:["ipk"]},"application/vnd.shootproof+json":{source:"iana",compressible:!0},"application/vnd.shopkick+json":{source:"iana",compressible:!0},"application/vnd.shp":{source:"iana"},"application/vnd.shx":{source:"iana"},"application/vnd.sigrok.session":{source:"iana"},"application/vnd.simtech-mindmapper":{source:"iana",extensions:["twd","twds"]},"application/vnd.siren+json":{source:"iana",compressible:!0},"application/vnd.smaf":{source:"iana",extensions:["mmf"]},"application/vnd.smart.notebook":{source:"iana"},"application/vnd.smart.teacher":{source:"iana",extensions:["teacher"]},"application/vnd.snesdev-page-table":{source:"iana"},"application/vnd.software602.filler.form+xml":{source:"iana",compressible:!0,extensions:["fo"]},"application/vnd.software602.filler.form-xml-zip":{source:"iana"},"application/vnd.solent.sdkm+xml":{source:"iana",compressible:!0,extensions:["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{source:"iana",extensions:["dxp"]},"application/vnd.spotfire.sfs":{source:"iana",extensions:["sfs"]},"application/vnd.sqlite3":{source:"iana"},"application/vnd.sss-cod":{source:"iana"},"application/vnd.sss-dtf":{source:"iana"},"application/vnd.sss-ntf":{source:"iana"},"application/vnd.stardivision.calc":{source:"apache",extensions:["sdc"]},"application/vnd.stardivision.draw":{source:"apache",extensions:["sda"]},"application/vnd.stardivision.impress":{source:"apache",extensions:["sdd"]},"application/vnd.stardivision.math":{source:"apache",extensions:["smf"]},"application/vnd.stardivision.writer":{source:"apache",extensions:["sdw","vor"]},"application/vnd.stardivision.writer-global":{source:"apache",extensions:["sgl"]},"application/vnd.stepmania.package":{source:"iana",extensions:["smzip"]},"application/vnd.stepmania.stepchart":{source:"iana",extensions:["sm"]},"application/vnd.street-stream":{source:"iana"},"application/vnd.sun.wadl+xml":{source:"iana",compressible:!0,extensions:["wadl"]},"application/vnd.sun.xml.calc":{source:"apache",extensions:["sxc"]},"application/vnd.sun.xml.calc.template":{source:"apache",extensions:["stc"]},"application/vnd.sun.xml.draw":{source:"apache",extensions:["sxd"]},"application/vnd.sun.xml.draw.template":{source:"apache",extensions:["std"]},"application/vnd.sun.xml.impress":{source:"apache",extensions:["sxi"]},"application/vnd.sun.xml.impress.template":{source:"apache",extensions:["sti"]},"application/vnd.sun.xml.math":{source:"apache",extensions:["sxm"]},"application/vnd.sun.xml.writer":{source:"apache",extensions:["sxw"]},"application/vnd.sun.xml.writer.global":{source:"apache",extensions:["sxg"]},"application/vnd.sun.xml.writer.template":{source:"apache",extensions:["stw"]},"application/vnd.sus-calendar":{source:"iana",extensions:["sus","susp"]},"application/vnd.svd":{source:"iana",extensions:["svd"]},"application/vnd.swiftview-ics":{source:"iana"},"application/vnd.sycle+xml":{source:"iana",compressible:!0},"application/vnd.symbian.install":{source:"apache",extensions:["sis","sisx"]},"application/vnd.syncml+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xsm"]},"application/vnd.syncml.dm+wbxml":{source:"iana",charset:"UTF-8",extensions:["bdm"]},"application/vnd.syncml.dm+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xdm"]},"application/vnd.syncml.dm.notification":{source:"iana"},"application/vnd.syncml.dmddf+wbxml":{source:"iana"},"application/vnd.syncml.dmddf+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{source:"iana"},"application/vnd.syncml.dmtnds+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.syncml.ds.notification":{source:"iana"},"application/vnd.tableschema+json":{source:"iana",compressible:!0},"application/vnd.tao.intent-module-archive":{source:"iana",extensions:["tao"]},"application/vnd.tcpdump.pcap":{source:"iana",extensions:["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{source:"iana",compressible:!0},"application/vnd.tmd.mediaflex.api+xml":{source:"iana",compressible:!0},"application/vnd.tml":{source:"iana"},"application/vnd.tmobile-livetv":{source:"iana",extensions:["tmo"]},"application/vnd.tri.onesource":{source:"iana"},"application/vnd.trid.tpt":{source:"iana",extensions:["tpt"]},"application/vnd.triscape.mxs":{source:"iana",extensions:["mxs"]},"application/vnd.trueapp":{source:"iana",extensions:["tra"]},"application/vnd.truedoc":{source:"iana"},"application/vnd.ubisoft.webplayer":{source:"iana"},"application/vnd.ufdl":{source:"iana",extensions:["ufd","ufdl"]},"application/vnd.uiq.theme":{source:"iana",extensions:["utz"]},"application/vnd.umajin":{source:"iana",extensions:["umj"]},"application/vnd.unity":{source:"iana",extensions:["unityweb"]},"application/vnd.uoml+xml":{source:"iana",compressible:!0,extensions:["uoml"]},"application/vnd.uplanet.alert":{source:"iana"},"application/vnd.uplanet.alert-wbxml":{source:"iana"},"application/vnd.uplanet.bearer-choice":{source:"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{source:"iana"},"application/vnd.uplanet.cacheop":{source:"iana"},"application/vnd.uplanet.cacheop-wbxml":{source:"iana"},"application/vnd.uplanet.channel":{source:"iana"},"application/vnd.uplanet.channel-wbxml":{source:"iana"},"application/vnd.uplanet.list":{source:"iana"},"application/vnd.uplanet.list-wbxml":{source:"iana"},"application/vnd.uplanet.listcmd":{source:"iana"},"application/vnd.uplanet.listcmd-wbxml":{source:"iana"},"application/vnd.uplanet.signal":{source:"iana"},"application/vnd.uri-map":{source:"iana"},"application/vnd.valve.source.material":{source:"iana"},"application/vnd.vcx":{source:"iana",extensions:["vcx"]},"application/vnd.vd-study":{source:"iana"},"application/vnd.vectorworks":{source:"iana"},"application/vnd.vel+json":{source:"iana",compressible:!0},"application/vnd.verimatrix.vcas":{source:"iana"},"application/vnd.veryant.thin":{source:"iana"},"application/vnd.ves.encrypted":{source:"iana"},"application/vnd.vidsoft.vidconference":{source:"iana"},"application/vnd.visio":{source:"iana",extensions:["vsd","vst","vss","vsw"]},"application/vnd.visionary":{source:"iana",extensions:["vis"]},"application/vnd.vividence.scriptfile":{source:"iana"},"application/vnd.vsf":{source:"iana",extensions:["vsf"]},"application/vnd.wap.sic":{source:"iana"},"application/vnd.wap.slc":{source:"iana"},"application/vnd.wap.wbxml":{source:"iana",charset:"UTF-8",extensions:["wbxml"]},"application/vnd.wap.wmlc":{source:"iana",extensions:["wmlc"]},"application/vnd.wap.wmlscriptc":{source:"iana",extensions:["wmlsc"]},"application/vnd.webturbo":{source:"iana",extensions:["wtb"]},"application/vnd.wfa.dpp":{source:"iana"},"application/vnd.wfa.p2p":{source:"iana"},"application/vnd.wfa.wsc":{source:"iana"},"application/vnd.windows.devicepairing":{source:"iana"},"application/vnd.wmc":{source:"iana"},"application/vnd.wmf.bootstrap":{source:"iana"},"application/vnd.wolfram.mathematica":{source:"iana"},"application/vnd.wolfram.mathematica.package":{source:"iana"},"application/vnd.wolfram.player":{source:"iana",extensions:["nbp"]},"application/vnd.wordperfect":{source:"iana",extensions:["wpd"]},"application/vnd.wqd":{source:"iana",extensions:["wqd"]},"application/vnd.wrq-hp3000-labelled":{source:"iana"},"application/vnd.wt.stf":{source:"iana",extensions:["stf"]},"application/vnd.wv.csp+wbxml":{source:"iana"},"application/vnd.wv.csp+xml":{source:"iana",compressible:!0},"application/vnd.wv.ssp+xml":{source:"iana",compressible:!0},"application/vnd.xacml+json":{source:"iana",compressible:!0},"application/vnd.xara":{source:"iana",extensions:["xar"]},"application/vnd.xfdl":{source:"iana",extensions:["xfdl"]},"application/vnd.xfdl.webform":{source:"iana"},"application/vnd.xmi+xml":{source:"iana",compressible:!0},"application/vnd.xmpie.cpkg":{source:"iana"},"application/vnd.xmpie.dpkg":{source:"iana"},"application/vnd.xmpie.plan":{source:"iana"},"application/vnd.xmpie.ppkg":{source:"iana"},"application/vnd.xmpie.xlim":{source:"iana"},"application/vnd.yamaha.hv-dic":{source:"iana",extensions:["hvd"]},"application/vnd.yamaha.hv-script":{source:"iana",extensions:["hvs"]},"application/vnd.yamaha.hv-voice":{source:"iana",extensions:["hvp"]},"application/vnd.yamaha.openscoreformat":{source:"iana",extensions:["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{source:"iana",compressible:!0,extensions:["osfpvg"]},"application/vnd.yamaha.remote-setup":{source:"iana"},"application/vnd.yamaha.smaf-audio":{source:"iana",extensions:["saf"]},"application/vnd.yamaha.smaf-phrase":{source:"iana",extensions:["spf"]},"application/vnd.yamaha.through-ngn":{source:"iana"},"application/vnd.yamaha.tunnel-udpencap":{source:"iana"},"application/vnd.yaoweme":{source:"iana"},"application/vnd.yellowriver-custom-menu":{source:"iana",extensions:["cmp"]},"application/vnd.youtube.yt":{source:"iana"},"application/vnd.zul":{source:"iana",extensions:["zir","zirz"]},"application/vnd.zzazz.deck+xml":{source:"iana",compressible:!0,extensions:["zaz"]},"application/voicexml+xml":{source:"iana",compressible:!0,extensions:["vxml"]},"application/voucher-cms+json":{source:"iana",compressible:!0},"application/vq-rtcpxr":{source:"iana"},"application/wasm":{compressible:!0,extensions:["wasm"]},"application/watcherinfo+xml":{source:"iana",compressible:!0},"application/webpush-options+json":{source:"iana",compressible:!0},"application/whoispp-query":{source:"iana"},"application/whoispp-response":{source:"iana"},"application/widget":{source:"iana",extensions:["wgt"]},"application/winhlp":{source:"apache",extensions:["hlp"]},"application/wita":{source:"iana"},"application/wordperfect5.1":{source:"iana"},"application/wsdl+xml":{source:"iana",compressible:!0,extensions:["wsdl"]},"application/wspolicy+xml":{source:"iana",compressible:!0,extensions:["wspolicy"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/x-abiword":{source:"apache",extensions:["abw"]},"application/x-ace-compressed":{source:"apache",extensions:["ace"]},"application/x-amf":{source:"apache"},"application/x-apple-diskimage":{source:"apache",extensions:["dmg"]},"application/x-arj":{compressible:!1,extensions:["arj"]},"application/x-authorware-bin":{source:"apache",extensions:["aab","x32","u32","vox"]},"application/x-authorware-map":{source:"apache",extensions:["aam"]},"application/x-authorware-seg":{source:"apache",extensions:["aas"]},"application/x-bcpio":{source:"apache",extensions:["bcpio"]},"application/x-bdoc":{compressible:!1,extensions:["bdoc"]},"application/x-bittorrent":{source:"apache",extensions:["torrent"]},"application/x-blorb":{source:"apache",extensions:["blb","blorb"]},"application/x-bzip":{source:"apache",compressible:!1,extensions:["bz"]},"application/x-bzip2":{source:"apache",compressible:!1,extensions:["bz2","boz"]},"application/x-cbr":{source:"apache",extensions:["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{source:"apache",extensions:["vcd"]},"application/x-cfs-compressed":{source:"apache",extensions:["cfs"]},"application/x-chat":{source:"apache",extensions:["chat"]},"application/x-chess-pgn":{source:"apache",extensions:["pgn"]},"application/x-chrome-extension":{extensions:["crx"]},"application/x-cocoa":{source:"nginx",extensions:["cco"]},"application/x-compress":{source:"apache"},"application/x-conference":{source:"apache",extensions:["nsc"]},"application/x-cpio":{source:"apache",extensions:["cpio"]},"application/x-csh":{source:"apache",extensions:["csh"]},"application/x-deb":{compressible:!1},"application/x-debian-package":{source:"apache",extensions:["deb","udeb"]},"application/x-dgc-compressed":{source:"apache",extensions:["dgc"]},"application/x-director":{source:"apache",extensions:["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{source:"apache",extensions:["wad"]},"application/x-dtbncx+xml":{source:"apache",compressible:!0,extensions:["ncx"]},"application/x-dtbook+xml":{source:"apache",compressible:!0,extensions:["dtb"]},"application/x-dtbresource+xml":{source:"apache",compressible:!0,extensions:["res"]},"application/x-dvi":{source:"apache",compressible:!1,extensions:["dvi"]},"application/x-envoy":{source:"apache",extensions:["evy"]},"application/x-eva":{source:"apache",extensions:["eva"]},"application/x-font-bdf":{source:"apache",extensions:["bdf"]},"application/x-font-dos":{source:"apache"},"application/x-font-framemaker":{source:"apache"},"application/x-font-ghostscript":{source:"apache",extensions:["gsf"]},"application/x-font-libgrx":{source:"apache"},"application/x-font-linux-psf":{source:"apache",extensions:["psf"]},"application/x-font-pcf":{source:"apache",extensions:["pcf"]},"application/x-font-snf":{source:"apache",extensions:["snf"]},"application/x-font-speedo":{source:"apache"},"application/x-font-sunos-news":{source:"apache"},"application/x-font-type1":{source:"apache",extensions:["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{source:"apache"},"application/x-freearc":{source:"apache",extensions:["arc"]},"application/x-futuresplash":{source:"apache",extensions:["spl"]},"application/x-gca-compressed":{source:"apache",extensions:["gca"]},"application/x-glulx":{source:"apache",extensions:["ulx"]},"application/x-gnumeric":{source:"apache",extensions:["gnumeric"]},"application/x-gramps-xml":{source:"apache",extensions:["gramps"]},"application/x-gtar":{source:"apache",extensions:["gtar"]},"application/x-gzip":{source:"apache"},"application/x-hdf":{source:"apache",extensions:["hdf"]},"application/x-httpd-php":{compressible:!0,extensions:["php"]},"application/x-install-instructions":{source:"apache",extensions:["install"]},"application/x-iso9660-image":{source:"apache",extensions:["iso"]},"application/x-java-archive-diff":{source:"nginx",extensions:["jardiff"]},"application/x-java-jnlp-file":{source:"apache",compressible:!1,extensions:["jnlp"]},"application/x-javascript":{compressible:!0},"application/x-keepass2":{extensions:["kdbx"]},"application/x-latex":{source:"apache",compressible:!1,extensions:["latex"]},"application/x-lua-bytecode":{extensions:["luac"]},"application/x-lzh-compressed":{source:"apache",extensions:["lzh","lha"]},"application/x-makeself":{source:"nginx",extensions:["run"]},"application/x-mie":{source:"apache",extensions:["mie"]},"application/x-mobipocket-ebook":{source:"apache",extensions:["prc","mobi"]},"application/x-mpegurl":{compressible:!1},"application/x-ms-application":{source:"apache",extensions:["application"]},"application/x-ms-shortcut":{source:"apache",extensions:["lnk"]},"application/x-ms-wmd":{source:"apache",extensions:["wmd"]},"application/x-ms-wmz":{source:"apache",extensions:["wmz"]},"application/x-ms-xbap":{source:"apache",extensions:["xbap"]},"application/x-msaccess":{source:"apache",extensions:["mdb"]},"application/x-msbinder":{source:"apache",extensions:["obd"]},"application/x-mscardfile":{source:"apache",extensions:["crd"]},"application/x-msclip":{source:"apache",extensions:["clp"]},"application/x-msdos-program":{extensions:["exe"]},"application/x-msdownload":{source:"apache",extensions:["exe","dll","com","bat","msi"]},"application/x-msmediaview":{source:"apache",extensions:["mvb","m13","m14"]},"application/x-msmetafile":{source:"apache",extensions:["wmf","wmz","emf","emz"]},"application/x-msmoney":{source:"apache",extensions:["mny"]},"application/x-mspublisher":{source:"apache",extensions:["pub"]},"application/x-msschedule":{source:"apache",extensions:["scd"]},"application/x-msterminal":{source:"apache",extensions:["trm"]},"application/x-mswrite":{source:"apache",extensions:["wri"]},"application/x-netcdf":{source:"apache",extensions:["nc","cdf"]},"application/x-ns-proxy-autoconfig":{compressible:!0,extensions:["pac"]},"application/x-nzb":{source:"apache",extensions:["nzb"]},"application/x-perl":{source:"nginx",extensions:["pl","pm"]},"application/x-pilot":{source:"nginx",extensions:["prc","pdb"]},"application/x-pkcs12":{source:"apache",compressible:!1,extensions:["p12","pfx"]},"application/x-pkcs7-certificates":{source:"apache",extensions:["p7b","spc"]},"application/x-pkcs7-certreqresp":{source:"apache",extensions:["p7r"]},"application/x-pki-message":{source:"iana"},"application/x-rar-compressed":{source:"apache",compressible:!1,extensions:["rar"]},"application/x-redhat-package-manager":{source:"nginx",extensions:["rpm"]},"application/x-research-info-systems":{source:"apache",extensions:["ris"]},"application/x-sea":{source:"nginx",extensions:["sea"]},"application/x-sh":{source:"apache",compressible:!0,extensions:["sh"]},"application/x-shar":{source:"apache",extensions:["shar"]},"application/x-shockwave-flash":{source:"apache",compressible:!1,extensions:["swf"]},"application/x-silverlight-app":{source:"apache",extensions:["xap"]},"application/x-sql":{source:"apache",extensions:["sql"]},"application/x-stuffit":{source:"apache",compressible:!1,extensions:["sit"]},"application/x-stuffitx":{source:"apache",extensions:["sitx"]},"application/x-subrip":{source:"apache",extensions:["srt"]},"application/x-sv4cpio":{source:"apache",extensions:["sv4cpio"]},"application/x-sv4crc":{source:"apache",extensions:["sv4crc"]},"application/x-t3vm-image":{source:"apache",extensions:["t3"]},"application/x-tads":{source:"apache",extensions:["gam"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-tcl":{source:"apache",extensions:["tcl","tk"]},"application/x-tex":{source:"apache",extensions:["tex"]},"application/x-tex-tfm":{source:"apache",extensions:["tfm"]},"application/x-texinfo":{source:"apache",extensions:["texinfo","texi"]},"application/x-tgif":{source:"apache",extensions:["obj"]},"application/x-ustar":{source:"apache",extensions:["ustar"]},"application/x-virtualbox-hdd":{compressible:!0,extensions:["hdd"]},"application/x-virtualbox-ova":{compressible:!0,extensions:["ova"]},"application/x-virtualbox-ovf":{compressible:!0,extensions:["ovf"]},"application/x-virtualbox-vbox":{compressible:!0,extensions:["vbox"]},"application/x-virtualbox-vbox-extpack":{compressible:!1,extensions:["vbox-extpack"]},"application/x-virtualbox-vdi":{compressible:!0,extensions:["vdi"]},"application/x-virtualbox-vhd":{compressible:!0,extensions:["vhd"]},"application/x-virtualbox-vmdk":{compressible:!0,extensions:["vmdk"]},"application/x-wais-source":{source:"apache",extensions:["src"]},"application/x-web-app-manifest+json":{compressible:!0,extensions:["webapp"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"application/x-x509-ca-cert":{source:"iana",extensions:["der","crt","pem"]},"application/x-x509-ca-ra-cert":{source:"iana"},"application/x-x509-next-ca-cert":{source:"iana"},"application/x-xfig":{source:"apache",extensions:["fig"]},"application/x-xliff+xml":{source:"apache",compressible:!0,extensions:["xlf"]},"application/x-xpinstall":{source:"apache",compressible:!1,extensions:["xpi"]},"application/x-xz":{source:"apache",extensions:["xz"]},"application/x-zmachine":{source:"apache",extensions:["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{source:"iana"},"application/xacml+xml":{source:"iana",compressible:!0},"application/xaml+xml":{source:"apache",compressible:!0,extensions:["xaml"]},"application/xcap-att+xml":{source:"iana",compressible:!0,extensions:["xav"]},"application/xcap-caps+xml":{source:"iana",compressible:!0,extensions:["xca"]},"application/xcap-diff+xml":{source:"iana",compressible:!0,extensions:["xdf"]},"application/xcap-el+xml":{source:"iana",compressible:!0,extensions:["xel"]},"application/xcap-error+xml":{source:"iana",compressible:!0},"application/xcap-ns+xml":{source:"iana",compressible:!0,extensions:["xns"]},"application/xcon-conference-info+xml":{source:"iana",compressible:!0},"application/xcon-conference-info-diff+xml":{source:"iana",compressible:!0},"application/xenc+xml":{source:"iana",compressible:!0,extensions:["xenc"]},"application/xhtml+xml":{source:"iana",compressible:!0,extensions:["xhtml","xht"]},"application/xhtml-voice+xml":{source:"apache",compressible:!0},"application/xliff+xml":{source:"iana",compressible:!0,extensions:["xlf"]},"application/xml":{source:"iana",compressible:!0,extensions:["xml","xsl","xsd","rng"]},"application/xml-dtd":{source:"iana",compressible:!0,extensions:["dtd"]},"application/xml-external-parsed-entity":{source:"iana"},"application/xml-patch+xml":{source:"iana",compressible:!0},"application/xmpp+xml":{source:"iana",compressible:!0},"application/xop+xml":{source:"iana",compressible:!0,extensions:["xop"]},"application/xproc+xml":{source:"apache",compressible:!0,extensions:["xpl"]},"application/xslt+xml":{source:"iana",compressible:!0,extensions:["xsl","xslt"]},"application/xspf+xml":{source:"apache",compressible:!0,extensions:["xspf"]},"application/xv+xml":{source:"iana",compressible:!0,extensions:["mxml","xhvml","xvml","xvm"]},"application/yang":{source:"iana",extensions:["yang"]},"application/yang-data+json":{source:"iana",compressible:!0},"application/yang-data+xml":{source:"iana",compressible:!0},"application/yang-patch+json":{source:"iana",compressible:!0},"application/yang-patch+xml":{source:"iana",compressible:!0},"application/yin+xml":{source:"iana",compressible:!0,extensions:["yin"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/zlib":{source:"iana"},"application/zstd":{source:"iana"},"audio/1d-interleaved-parityfec":{source:"iana"},"audio/32kadpcm":{source:"iana"},"audio/3gpp":{source:"iana",compressible:!1,extensions:["3gpp"]},"audio/3gpp2":{source:"iana"},"audio/aac":{source:"iana"},"audio/ac3":{source:"iana"},"audio/adpcm":{source:"apache",extensions:["adp"]},"audio/amr":{source:"iana",extensions:["amr"]},"audio/amr-wb":{source:"iana"},"audio/amr-wb+":{source:"iana"},"audio/aptx":{source:"iana"},"audio/asc":{source:"iana"},"audio/atrac-advanced-lossless":{source:"iana"},"audio/atrac-x":{source:"iana"},"audio/atrac3":{source:"iana"},"audio/basic":{source:"iana",compressible:!1,extensions:["au","snd"]},"audio/bv16":{source:"iana"},"audio/bv32":{source:"iana"},"audio/clearmode":{source:"iana"},"audio/cn":{source:"iana"},"audio/dat12":{source:"iana"},"audio/dls":{source:"iana"},"audio/dsr-es201108":{source:"iana"},"audio/dsr-es202050":{source:"iana"},"audio/dsr-es202211":{source:"iana"},"audio/dsr-es202212":{source:"iana"},"audio/dv":{source:"iana"},"audio/dvi4":{source:"iana"},"audio/eac3":{source:"iana"},"audio/encaprtp":{source:"iana"},"audio/evrc":{source:"iana"},"audio/evrc-qcp":{source:"iana"},"audio/evrc0":{source:"iana"},"audio/evrc1":{source:"iana"},"audio/evrcb":{source:"iana"},"audio/evrcb0":{source:"iana"},"audio/evrcb1":{source:"iana"},"audio/evrcnw":{source:"iana"},"audio/evrcnw0":{source:"iana"},"audio/evrcnw1":{source:"iana"},"audio/evrcwb":{source:"iana"},"audio/evrcwb0":{source:"iana"},"audio/evrcwb1":{source:"iana"},"audio/evs":{source:"iana"},"audio/flexfec":{source:"iana"},"audio/fwdred":{source:"iana"},"audio/g711-0":{source:"iana"},"audio/g719":{source:"iana"},"audio/g722":{source:"iana"},"audio/g7221":{source:"iana"},"audio/g723":{source:"iana"},"audio/g726-16":{source:"iana"},"audio/g726-24":{source:"iana"},"audio/g726-32":{source:"iana"},"audio/g726-40":{source:"iana"},"audio/g728":{source:"iana"},"audio/g729":{source:"iana"},"audio/g7291":{source:"iana"},"audio/g729d":{source:"iana"},"audio/g729e":{source:"iana"},"audio/gsm":{source:"iana"},"audio/gsm-efr":{source:"iana"},"audio/gsm-hr-08":{source:"iana"},"audio/ilbc":{source:"iana"},"audio/ip-mr_v2.5":{source:"iana"},"audio/isac":{source:"apache"},"audio/l16":{source:"iana"},"audio/l20":{source:"iana"},"audio/l24":{source:"iana",compressible:!1},"audio/l8":{source:"iana"},"audio/lpc":{source:"iana"},"audio/melp":{source:"iana"},"audio/melp1200":{source:"iana"},"audio/melp2400":{source:"iana"},"audio/melp600":{source:"iana"},"audio/mhas":{source:"iana"},"audio/midi":{source:"apache",extensions:["mid","midi","kar","rmi"]},"audio/mobile-xmf":{source:"iana",extensions:["mxmf"]},"audio/mp3":{compressible:!1,extensions:["mp3"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a","mp4a"]},"audio/mp4a-latm":{source:"iana"},"audio/mpa":{source:"iana"},"audio/mpa-robust":{source:"iana"},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{source:"iana"},"audio/musepack":{source:"apache"},"audio/ogg":{source:"iana",compressible:!1,extensions:["oga","ogg","spx","opus"]},"audio/opus":{source:"iana"},"audio/parityfec":{source:"iana"},"audio/pcma":{source:"iana"},"audio/pcma-wb":{source:"iana"},"audio/pcmu":{source:"iana"},"audio/pcmu-wb":{source:"iana"},"audio/prs.sid":{source:"iana"},"audio/qcelp":{source:"iana"},"audio/raptorfec":{source:"iana"},"audio/red":{source:"iana"},"audio/rtp-enc-aescm128":{source:"iana"},"audio/rtp-midi":{source:"iana"},"audio/rtploopback":{source:"iana"},"audio/rtx":{source:"iana"},"audio/s3m":{source:"apache",extensions:["s3m"]},"audio/scip":{source:"iana"},"audio/silk":{source:"apache",extensions:["sil"]},"audio/smv":{source:"iana"},"audio/smv-qcp":{source:"iana"},"audio/smv0":{source:"iana"},"audio/sofa":{source:"iana"},"audio/sp-midi":{source:"iana"},"audio/speex":{source:"iana"},"audio/t140c":{source:"iana"},"audio/t38":{source:"iana"},"audio/telephone-event":{source:"iana"},"audio/tetra_acelp":{source:"iana"},"audio/tetra_acelp_bb":{source:"iana"},"audio/tone":{source:"iana"},"audio/tsvcis":{source:"iana"},"audio/uemclip":{source:"iana"},"audio/ulpfec":{source:"iana"},"audio/usac":{source:"iana"},"audio/vdvi":{source:"iana"},"audio/vmr-wb":{source:"iana"},"audio/vnd.3gpp.iufp":{source:"iana"},"audio/vnd.4sb":{source:"iana"},"audio/vnd.audiokoz":{source:"iana"},"audio/vnd.celp":{source:"iana"},"audio/vnd.cisco.nse":{source:"iana"},"audio/vnd.cmles.radio-events":{source:"iana"},"audio/vnd.cns.anp1":{source:"iana"},"audio/vnd.cns.inf1":{source:"iana"},"audio/vnd.dece.audio":{source:"iana",extensions:["uva","uvva"]},"audio/vnd.digital-winds":{source:"iana",extensions:["eol"]},"audio/vnd.dlna.adts":{source:"iana"},"audio/vnd.dolby.heaac.1":{source:"iana"},"audio/vnd.dolby.heaac.2":{source:"iana"},"audio/vnd.dolby.mlp":{source:"iana"},"audio/vnd.dolby.mps":{source:"iana"},"audio/vnd.dolby.pl2":{source:"iana"},"audio/vnd.dolby.pl2x":{source:"iana"},"audio/vnd.dolby.pl2z":{source:"iana"},"audio/vnd.dolby.pulse.1":{source:"iana"},"audio/vnd.dra":{source:"iana",extensions:["dra"]},"audio/vnd.dts":{source:"iana",extensions:["dts"]},"audio/vnd.dts.hd":{source:"iana",extensions:["dtshd"]},"audio/vnd.dts.uhd":{source:"iana"},"audio/vnd.dvb.file":{source:"iana"},"audio/vnd.everad.plj":{source:"iana"},"audio/vnd.hns.audio":{source:"iana"},"audio/vnd.lucent.voice":{source:"iana",extensions:["lvp"]},"audio/vnd.ms-playready.media.pya":{source:"iana",extensions:["pya"]},"audio/vnd.nokia.mobile-xmf":{source:"iana"},"audio/vnd.nortel.vbk":{source:"iana"},"audio/vnd.nuera.ecelp4800":{source:"iana",extensions:["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{source:"iana",extensions:["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{source:"iana",extensions:["ecelp9600"]},"audio/vnd.octel.sbc":{source:"iana"},"audio/vnd.presonus.multitrack":{source:"iana"},"audio/vnd.qcelp":{source:"iana"},"audio/vnd.rhetorex.32kadpcm":{source:"iana"},"audio/vnd.rip":{source:"iana",extensions:["rip"]},"audio/vnd.rn-realaudio":{compressible:!1},"audio/vnd.sealedmedia.softseal.mpeg":{source:"iana"},"audio/vnd.vmx.cvsd":{source:"iana"},"audio/vnd.wave":{compressible:!1},"audio/vorbis":{source:"iana",compressible:!1},"audio/vorbis-config":{source:"iana"},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/wave":{compressible:!1,extensions:["wav"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/x-aac":{source:"apache",compressible:!1,extensions:["aac"]},"audio/x-aiff":{source:"apache",extensions:["aif","aiff","aifc"]},"audio/x-caf":{source:"apache",compressible:!1,extensions:["caf"]},"audio/x-flac":{source:"apache",extensions:["flac"]},"audio/x-m4a":{source:"nginx",extensions:["m4a"]},"audio/x-matroska":{source:"apache",extensions:["mka"]},"audio/x-mpegurl":{source:"apache",extensions:["m3u"]},"audio/x-ms-wax":{source:"apache",extensions:["wax"]},"audio/x-ms-wma":{source:"apache",extensions:["wma"]},"audio/x-pn-realaudio":{source:"apache",extensions:["ram","ra"]},"audio/x-pn-realaudio-plugin":{source:"apache",extensions:["rmp"]},"audio/x-realaudio":{source:"nginx",extensions:["ra"]},"audio/x-tta":{source:"apache"},"audio/x-wav":{source:"apache",extensions:["wav"]},"audio/xm":{source:"apache",extensions:["xm"]},"chemical/x-cdx":{source:"apache",extensions:["cdx"]},"chemical/x-cif":{source:"apache",extensions:["cif"]},"chemical/x-cmdf":{source:"apache",extensions:["cmdf"]},"chemical/x-cml":{source:"apache",extensions:["cml"]},"chemical/x-csml":{source:"apache",extensions:["csml"]},"chemical/x-pdb":{source:"apache"},"chemical/x-xyz":{source:"apache",extensions:["xyz"]},"font/collection":{source:"iana",extensions:["ttc"]},"font/otf":{source:"iana",compressible:!0,extensions:["otf"]},"font/sfnt":{source:"iana"},"font/ttf":{source:"iana",compressible:!0,extensions:["ttf"]},"font/woff":{source:"iana",extensions:["woff"]},"font/woff2":{source:"iana",extensions:["woff2"]},"image/aces":{source:"iana",extensions:["exr"]},"image/apng":{compressible:!1,extensions:["apng"]},"image/avci":{source:"iana"},"image/avcs":{source:"iana"},"image/avif":{source:"iana",compressible:!1,extensions:["avif"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/cgm":{source:"iana",extensions:["cgm"]},"image/dicom-rle":{source:"iana",extensions:["drle"]},"image/emf":{source:"iana",extensions:["emf"]},"image/fits":{source:"iana",extensions:["fits"]},"image/g3fax":{source:"iana",extensions:["g3"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/heic":{source:"iana",extensions:["heic"]},"image/heic-sequence":{source:"iana",extensions:["heics"]},"image/heif":{source:"iana",extensions:["heif"]},"image/heif-sequence":{source:"iana",extensions:["heifs"]},"image/hej2k":{source:"iana",extensions:["hej2"]},"image/hsj2":{source:"iana",extensions:["hsj2"]},"image/ief":{source:"iana",extensions:["ief"]},"image/jls":{source:"iana",extensions:["jls"]},"image/jp2":{source:"iana",compressible:!1,extensions:["jp2","jpg2"]},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/jph":{source:"iana",extensions:["jph"]},"image/jphc":{source:"iana",extensions:["jhc"]},"image/jpm":{source:"iana",compressible:!1,extensions:["jpm"]},"image/jpx":{source:"iana",compressible:!1,extensions:["jpx","jpf"]},"image/jxr":{source:"iana",extensions:["jxr"]},"image/jxra":{source:"iana",extensions:["jxra"]},"image/jxrs":{source:"iana",extensions:["jxrs"]},"image/jxs":{source:"iana",extensions:["jxs"]},"image/jxsc":{source:"iana",extensions:["jxsc"]},"image/jxsi":{source:"iana",extensions:["jxsi"]},"image/jxss":{source:"iana",extensions:["jxss"]},"image/ktx":{source:"iana",extensions:["ktx"]},"image/ktx2":{source:"iana",extensions:["ktx2"]},"image/naplps":{source:"iana"},"image/pjpeg":{compressible:!1},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/prs.btif":{source:"iana",extensions:["btif"]},"image/prs.pti":{source:"iana",extensions:["pti"]},"image/pwg-raster":{source:"iana"},"image/sgi":{source:"apache",extensions:["sgi"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/t38":{source:"iana",extensions:["t38"]},"image/tiff":{source:"iana",compressible:!1,extensions:["tif","tiff"]},"image/tiff-fx":{source:"iana",extensions:["tfx"]},"image/vnd.adobe.photoshop":{source:"iana",compressible:!0,extensions:["psd"]},"image/vnd.airzip.accelerator.azv":{source:"iana",extensions:["azv"]},"image/vnd.cns.inf2":{source:"iana"},"image/vnd.dece.graphic":{source:"iana",extensions:["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{source:"iana",extensions:["djvu","djv"]},"image/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"image/vnd.dwg":{source:"iana",extensions:["dwg"]},"image/vnd.dxf":{source:"iana",extensions:["dxf"]},"image/vnd.fastbidsheet":{source:"iana",extensions:["fbs"]},"image/vnd.fpx":{source:"iana",extensions:["fpx"]},"image/vnd.fst":{source:"iana",extensions:["fst"]},"image/vnd.fujixerox.edmics-mmr":{source:"iana",extensions:["mmr"]},"image/vnd.fujixerox.edmics-rlc":{source:"iana",extensions:["rlc"]},"image/vnd.globalgraphics.pgb":{source:"iana"},"image/vnd.microsoft.icon":{source:"iana",extensions:["ico"]},"image/vnd.mix":{source:"iana"},"image/vnd.mozilla.apng":{source:"iana"},"image/vnd.ms-dds":{extensions:["dds"]},"image/vnd.ms-modi":{source:"iana",extensions:["mdi"]},"image/vnd.ms-photo":{source:"apache",extensions:["wdp"]},"image/vnd.net-fpx":{source:"iana",extensions:["npx"]},"image/vnd.pco.b16":{source:"iana",extensions:["b16"]},"image/vnd.radiance":{source:"iana"},"image/vnd.sealed.png":{source:"iana"},"image/vnd.sealedmedia.softseal.gif":{source:"iana"},"image/vnd.sealedmedia.softseal.jpg":{source:"iana"},"image/vnd.svf":{source:"iana"},"image/vnd.tencent.tap":{source:"iana",extensions:["tap"]},"image/vnd.valve.source.texture":{source:"iana",extensions:["vtf"]},"image/vnd.wap.wbmp":{source:"iana",extensions:["wbmp"]},"image/vnd.xiff":{source:"iana",extensions:["xif"]},"image/vnd.zbrush.pcx":{source:"iana",extensions:["pcx"]},"image/webp":{source:"apache",extensions:["webp"]},"image/wmf":{source:"iana",extensions:["wmf"]},"image/x-3ds":{source:"apache",extensions:["3ds"]},"image/x-cmu-raster":{source:"apache",extensions:["ras"]},"image/x-cmx":{source:"apache",extensions:["cmx"]},"image/x-freehand":{source:"apache",extensions:["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/x-jng":{source:"nginx",extensions:["jng"]},"image/x-mrsid-image":{source:"apache",extensions:["sid"]},"image/x-ms-bmp":{source:"nginx",compressible:!0,extensions:["bmp"]},"image/x-pcx":{source:"apache",extensions:["pcx"]},"image/x-pict":{source:"apache",extensions:["pic","pct"]},"image/x-portable-anymap":{source:"apache",extensions:["pnm"]},"image/x-portable-bitmap":{source:"apache",extensions:["pbm"]},"image/x-portable-graymap":{source:"apache",extensions:["pgm"]},"image/x-portable-pixmap":{source:"apache",extensions:["ppm"]},"image/x-rgb":{source:"apache",extensions:["rgb"]},"image/x-tga":{source:"apache",extensions:["tga"]},"image/x-xbitmap":{source:"apache",extensions:["xbm"]},"image/x-xcf":{compressible:!1},"image/x-xpixmap":{source:"apache",extensions:["xpm"]},"image/x-xwindowdump":{source:"apache",extensions:["xwd"]},"message/cpim":{source:"iana"},"message/delivery-status":{source:"iana"},"message/disposition-notification":{source:"iana",extensions:["disposition-notification"]},"message/external-body":{source:"iana"},"message/feedback-report":{source:"iana"},"message/global":{source:"iana",extensions:["u8msg"]},"message/global-delivery-status":{source:"iana",extensions:["u8dsn"]},"message/global-disposition-notification":{source:"iana",extensions:["u8mdn"]},"message/global-headers":{source:"iana",extensions:["u8hdr"]},"message/http":{source:"iana",compressible:!1},"message/imdn+xml":{source:"iana",compressible:!0},"message/news":{source:"iana"},"message/partial":{source:"iana",compressible:!1},"message/rfc822":{source:"iana",compressible:!0,extensions:["eml","mime"]},"message/s-http":{source:"iana"},"message/sip":{source:"iana"},"message/sipfrag":{source:"iana"},"message/tracking-status":{source:"iana"},"message/vnd.si.simp":{source:"iana"},"message/vnd.wfa.wsc":{source:"iana",extensions:["wsc"]},"model/3mf":{source:"iana",extensions:["3mf"]},"model/e57":{source:"iana"},"model/gltf+json":{source:"iana",compressible:!0,extensions:["gltf"]},"model/gltf-binary":{source:"iana",compressible:!0,extensions:["glb"]},"model/iges":{source:"iana",compressible:!1,extensions:["igs","iges"]},"model/mesh":{source:"iana",compressible:!1,extensions:["msh","mesh","silo"]},"model/mtl":{source:"iana",extensions:["mtl"]},"model/obj":{source:"iana",extensions:["obj"]},"model/stl":{source:"iana",extensions:["stl"]},"model/vnd.collada+xml":{source:"iana",compressible:!0,extensions:["dae"]},"model/vnd.dwf":{source:"iana",extensions:["dwf"]},"model/vnd.flatland.3dml":{source:"iana"},"model/vnd.gdl":{source:"iana",extensions:["gdl"]},"model/vnd.gs-gdl":{source:"apache"},"model/vnd.gs.gdl":{source:"iana"},"model/vnd.gtw":{source:"iana",extensions:["gtw"]},"model/vnd.moml+xml":{source:"iana",compressible:!0},"model/vnd.mts":{source:"iana",extensions:["mts"]},"model/vnd.opengex":{source:"iana",extensions:["ogex"]},"model/vnd.parasolid.transmit.binary":{source:"iana",extensions:["x_b"]},"model/vnd.parasolid.transmit.text":{source:"iana",extensions:["x_t"]},"model/vnd.rosette.annotated-data-model":{source:"iana"},"model/vnd.sap.vds":{source:"iana",extensions:["vds"]},"model/vnd.usdz+zip":{source:"iana",compressible:!1,extensions:["usdz"]},"model/vnd.valve.source.compiled-map":{source:"iana",extensions:["bsp"]},"model/vnd.vtu":{source:"iana",extensions:["vtu"]},"model/vrml":{source:"iana",compressible:!1,extensions:["wrl","vrml"]},"model/x3d+binary":{source:"apache",compressible:!1,extensions:["x3db","x3dbz"]},"model/x3d+fastinfoset":{source:"iana",extensions:["x3db"]},"model/x3d+vrml":{source:"apache",compressible:!1,extensions:["x3dv","x3dvz"]},"model/x3d+xml":{source:"iana",compressible:!0,extensions:["x3d","x3dz"]},"model/x3d-vrml":{source:"iana",extensions:["x3dv"]},"multipart/alternative":{source:"iana",compressible:!1},"multipart/appledouble":{source:"iana"},"multipart/byteranges":{source:"iana"},"multipart/digest":{source:"iana"},"multipart/encrypted":{source:"iana",compressible:!1},"multipart/form-data":{source:"iana",compressible:!1},"multipart/header-set":{source:"iana"},"multipart/mixed":{source:"iana"},"multipart/multilingual":{source:"iana"},"multipart/parallel":{source:"iana"},"multipart/related":{source:"iana",compressible:!1},"multipart/report":{source:"iana"},"multipart/signed":{source:"iana",compressible:!1},"multipart/vnd.bint.med-plus":{source:"iana"},"multipart/voice-message":{source:"iana"},"multipart/x-mixed-replace":{source:"iana"},"text/1d-interleaved-parityfec":{source:"iana"},"text/cache-manifest":{source:"iana",compressible:!0,extensions:["appcache","manifest"]},"text/calendar":{source:"iana",extensions:["ics","ifb"]},"text/calender":{compressible:!0},"text/cmd":{compressible:!0},"text/coffeescript":{extensions:["coffee","litcoffee"]},"text/cql":{source:"iana"},"text/cql-expression":{source:"iana"},"text/cql-identifier":{source:"iana"},"text/css":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["css"]},"text/csv":{source:"iana",compressible:!0,extensions:["csv"]},"text/csv-schema":{source:"iana"},"text/directory":{source:"iana"},"text/dns":{source:"iana"},"text/ecmascript":{source:"iana"},"text/encaprtp":{source:"iana"},"text/enriched":{source:"iana"},"text/fhirpath":{source:"iana"},"text/flexfec":{source:"iana"},"text/fwdred":{source:"iana"},"text/gff3":{source:"iana"},"text/grammar-ref-list":{source:"iana"},"text/html":{source:"iana",compressible:!0,extensions:["html","htm","shtml"]},"text/jade":{extensions:["jade"]},"text/javascript":{source:"iana",compressible:!0},"text/jcr-cnd":{source:"iana"},"text/jsx":{compressible:!0,extensions:["jsx"]},"text/less":{compressible:!0,extensions:["less"]},"text/markdown":{source:"iana",compressible:!0,extensions:["markdown","md"]},"text/mathml":{source:"nginx",extensions:["mml"]},"text/mdx":{compressible:!0,extensions:["mdx"]},"text/mizar":{source:"iana"},"text/n3":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["n3"]},"text/parameters":{source:"iana",charset:"UTF-8"},"text/parityfec":{source:"iana"},"text/plain":{source:"iana",compressible:!0,extensions:["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{source:"iana",charset:"UTF-8"},"text/prs.fallenstein.rst":{source:"iana"},"text/prs.lines.tag":{source:"iana",extensions:["dsc"]},"text/prs.prop.logic":{source:"iana"},"text/raptorfec":{source:"iana"},"text/red":{source:"iana"},"text/rfc822-headers":{source:"iana"},"text/richtext":{source:"iana",compressible:!0,extensions:["rtx"]},"text/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"text/rtp-enc-aescm128":{source:"iana"},"text/rtploopback":{source:"iana"},"text/rtx":{source:"iana"},"text/sgml":{source:"iana",extensions:["sgml","sgm"]},"text/shaclc":{source:"iana"},"text/shex":{extensions:["shex"]},"text/slim":{extensions:["slim","slm"]},"text/spdx":{source:"iana",extensions:["spdx"]},"text/strings":{source:"iana"},"text/stylus":{extensions:["stylus","styl"]},"text/t140":{source:"iana"},"text/tab-separated-values":{source:"iana",compressible:!0,extensions:["tsv"]},"text/troff":{source:"iana",extensions:["t","tr","roff","man","me","ms"]},"text/turtle":{source:"iana",charset:"UTF-8",extensions:["ttl"]},"text/ulpfec":{source:"iana"},"text/uri-list":{source:"iana",compressible:!0,extensions:["uri","uris","urls"]},"text/vcard":{source:"iana",compressible:!0,extensions:["vcard"]},"text/vnd.a":{source:"iana"},"text/vnd.abc":{source:"iana"},"text/vnd.ascii-art":{source:"iana"},"text/vnd.curl":{source:"iana",extensions:["curl"]},"text/vnd.curl.dcurl":{source:"apache",extensions:["dcurl"]},"text/vnd.curl.mcurl":{source:"apache",extensions:["mcurl"]},"text/vnd.curl.scurl":{source:"apache",extensions:["scurl"]},"text/vnd.debian.copyright":{source:"iana",charset:"UTF-8"},"text/vnd.dmclientscript":{source:"iana"},"text/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"text/vnd.esmertec.theme-descriptor":{source:"iana",charset:"UTF-8"},"text/vnd.ficlab.flt":{source:"iana"},"text/vnd.fly":{source:"iana",extensions:["fly"]},"text/vnd.fmi.flexstor":{source:"iana",extensions:["flx"]},"text/vnd.gml":{source:"iana"},"text/vnd.graphviz":{source:"iana",extensions:["gv"]},"text/vnd.hans":{source:"iana"},"text/vnd.hgl":{source:"iana"},"text/vnd.in3d.3dml":{source:"iana",extensions:["3dml"]},"text/vnd.in3d.spot":{source:"iana",extensions:["spot"]},"text/vnd.iptc.newsml":{source:"iana"},"text/vnd.iptc.nitf":{source:"iana"},"text/vnd.latex-z":{source:"iana"},"text/vnd.motorola.reflex":{source:"iana"},"text/vnd.ms-mediapackage":{source:"iana"},"text/vnd.net2phone.commcenter.command":{source:"iana"},"text/vnd.radisys.msml-basic-layout":{source:"iana"},"text/vnd.senx.warpscript":{source:"iana"},"text/vnd.si.uricatalogue":{source:"iana"},"text/vnd.sosi":{source:"iana"},"text/vnd.sun.j2me.app-descriptor":{source:"iana",charset:"UTF-8",extensions:["jad"]},"text/vnd.trolltech.linguist":{source:"iana",charset:"UTF-8"},"text/vnd.wap.si":{source:"iana"},"text/vnd.wap.sl":{source:"iana"},"text/vnd.wap.wml":{source:"iana",extensions:["wml"]},"text/vnd.wap.wmlscript":{source:"iana",extensions:["wmls"]},"text/vtt":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["vtt"]},"text/x-asm":{source:"apache",extensions:["s","asm"]},"text/x-c":{source:"apache",extensions:["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{source:"nginx",extensions:["htc"]},"text/x-fortran":{source:"apache",extensions:["f","for","f77","f90"]},"text/x-gwt-rpc":{compressible:!0},"text/x-handlebars-template":{extensions:["hbs"]},"text/x-java-source":{source:"apache",extensions:["java"]},"text/x-jquery-tmpl":{compressible:!0},"text/x-lua":{extensions:["lua"]},"text/x-markdown":{compressible:!0,extensions:["mkd"]},"text/x-nfo":{source:"apache",extensions:["nfo"]},"text/x-opml":{source:"apache",extensions:["opml"]},"text/x-org":{compressible:!0,extensions:["org"]},"text/x-pascal":{source:"apache",extensions:["p","pas"]},"text/x-processing":{compressible:!0,extensions:["pde"]},"text/x-sass":{extensions:["sass"]},"text/x-scss":{extensions:["scss"]},"text/x-setext":{source:"apache",extensions:["etx"]},"text/x-sfv":{source:"apache",extensions:["sfv"]},"text/x-suse-ymp":{compressible:!0,extensions:["ymp"]},"text/x-uuencode":{source:"apache",extensions:["uu"]},"text/x-vcalendar":{source:"apache",extensions:["vcs"]},"text/x-vcard":{source:"apache",extensions:["vcf"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/xml-external-parsed-entity":{source:"iana"},"text/yaml":{extensions:["yaml","yml"]},"video/1d-interleaved-parityfec":{source:"iana"},"video/3gpp":{source:"iana",extensions:["3gp","3gpp"]},"video/3gpp-tt":{source:"iana"},"video/3gpp2":{source:"iana",extensions:["3g2"]},"video/av1":{source:"iana"},"video/bmpeg":{source:"iana"},"video/bt656":{source:"iana"},"video/celb":{source:"iana"},"video/dv":{source:"iana"},"video/encaprtp":{source:"iana"},"video/ffv1":{source:"iana"},"video/flexfec":{source:"iana"},"video/h261":{source:"iana",extensions:["h261"]},"video/h263":{source:"iana",extensions:["h263"]},"video/h263-1998":{source:"iana"},"video/h263-2000":{source:"iana"},"video/h264":{source:"iana",extensions:["h264"]},"video/h264-rcdo":{source:"iana"},"video/h264-svc":{source:"iana"},"video/h265":{source:"iana"},"video/iso.segment":{source:"iana",extensions:["m4s"]},"video/jpeg":{source:"iana",extensions:["jpgv"]},"video/jpeg2000":{source:"iana"},"video/jpm":{source:"apache",extensions:["jpm","jpgm"]},"video/mj2":{source:"iana",extensions:["mj2","mjp2"]},"video/mp1s":{source:"iana"},"video/mp2p":{source:"iana"},"video/mp2t":{source:"iana",extensions:["ts"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","mp4v","mpg4"]},"video/mp4v-es":{source:"iana"},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{source:"iana"},"video/mpv":{source:"iana"},"video/nv":{source:"iana"},"video/ogg":{source:"iana",compressible:!1,extensions:["ogv"]},"video/parityfec":{source:"iana"},"video/pointer":{source:"iana"},"video/quicktime":{source:"iana",compressible:!1,extensions:["qt","mov"]},"video/raptorfec":{source:"iana"},"video/raw":{source:"iana"},"video/rtp-enc-aescm128":{source:"iana"},"video/rtploopback":{source:"iana"},"video/rtx":{source:"iana"},"video/scip":{source:"iana"},"video/smpte291":{source:"iana"},"video/smpte292m":{source:"iana"},"video/ulpfec":{source:"iana"},"video/vc1":{source:"iana"},"video/vc2":{source:"iana"},"video/vnd.cctv":{source:"iana"},"video/vnd.dece.hd":{source:"iana",extensions:["uvh","uvvh"]},"video/vnd.dece.mobile":{source:"iana",extensions:["uvm","uvvm"]},"video/vnd.dece.mp4":{source:"iana"},"video/vnd.dece.pd":{source:"iana",extensions:["uvp","uvvp"]},"video/vnd.dece.sd":{source:"iana",extensions:["uvs","uvvs"]},"video/vnd.dece.video":{source:"iana",extensions:["uvv","uvvv"]},"video/vnd.directv.mpeg":{source:"iana"},"video/vnd.directv.mpeg-tts":{source:"iana"},"video/vnd.dlna.mpeg-tts":{source:"iana"},"video/vnd.dvb.file":{source:"iana",extensions:["dvb"]},"video/vnd.fvt":{source:"iana",extensions:["fvt"]},"video/vnd.hns.video":{source:"iana"},"video/vnd.iptvforum.1dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.1dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.2dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.2dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.ttsavc":{source:"iana"},"video/vnd.iptvforum.ttsmpeg2":{source:"iana"},"video/vnd.motorola.video":{source:"iana"},"video/vnd.motorola.videop":{source:"iana"},"video/vnd.mpegurl":{source:"iana",extensions:["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{source:"iana",extensions:["pyv"]},"video/vnd.nokia.interleaved-multimedia":{source:"iana"},"video/vnd.nokia.mp4vr":{source:"iana"},"video/vnd.nokia.videovoip":{source:"iana"},"video/vnd.objectvideo":{source:"iana"},"video/vnd.radgamettools.bink":{source:"iana"},"video/vnd.radgamettools.smacker":{source:"iana"},"video/vnd.sealed.mpeg1":{source:"iana"},"video/vnd.sealed.mpeg4":{source:"iana"},"video/vnd.sealed.swf":{source:"iana"},"video/vnd.sealedmedia.softseal.mov":{source:"iana"},"video/vnd.uvvu.mp4":{source:"iana",extensions:["uvu","uvvu"]},"video/vnd.vivo":{source:"iana",extensions:["viv"]},"video/vnd.youtube.yt":{source:"iana"},"video/vp8":{source:"iana"},"video/webm":{source:"apache",compressible:!1,extensions:["webm"]},"video/x-f4v":{source:"apache",extensions:["f4v"]},"video/x-fli":{source:"apache",extensions:["fli"]},"video/x-flv":{source:"apache",compressible:!1,extensions:["flv"]},"video/x-m4v":{source:"apache",extensions:["m4v"]},"video/x-matroska":{source:"apache",compressible:!1,extensions:["mkv","mk3d","mks"]},"video/x-mng":{source:"apache",extensions:["mng"]},"video/x-ms-asf":{source:"apache",extensions:["asf","asx"]},"video/x-ms-vob":{source:"apache",extensions:["vob"]},"video/x-ms-wm":{source:"apache",extensions:["wm"]},"video/x-ms-wmv":{source:"apache",compressible:!1,extensions:["wmv"]},"video/x-ms-wmx":{source:"apache",extensions:["wmx"]},"video/x-ms-wvx":{source:"apache",extensions:["wvx"]},"video/x-msvideo":{source:"apache",extensions:["avi"]},"video/x-sgi-movie":{source:"apache",extensions:["movie"]},"video/x-smv":{source:"apache",extensions:["smv"]},"x-conference/x-cooltalk":{source:"apache",extensions:["ice"]},"x-shader/x-fragment":{compressible:!0},"x-shader/x-vertex":{compressible:!0}}},{}],145:[function(e,t,n){ +t.exports=a;var i=e("inherits"),r=e("readable-stream"),s=e("to-arraybuffer"),o="undefined"!=typeof window&&window.MediaSource;function a(e,t){var n=this;if(!(n instanceof a))return new a(e,t);if(!o)throw new Error("web browser lacks MediaSource support");t||(t={}),n._debug=t.debug,n._bufferDuration=t.bufferDuration||60,n._elem=e,n._mediaSource=new o,n._streams=[],n.detailedError=null,n._errorHandler=function(){n._elem.removeEventListener("error",n._errorHandler),n._streams.slice().forEach((function(e){e.destroy(n._elem.error)}))},n._elem.addEventListener("error",n._errorHandler),n._elem.src=window.URL.createObjectURL(n._mediaSource)}function c(e,t){var n=this;if(r.Writable.call(n),n._wrapper=e,n._elem=e._elem,n._mediaSource=e._mediaSource,n._allStreams=e._streams,n._allStreams.push(n),n._bufferDuration=e._bufferDuration,n._sourceBuffer=null,n._debugBuffers=[],n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},n._errorHandler=function(e){n.destroyed||n.emit("error",e)},"string"==typeof t)n._type=t,"open"===n._mediaSource.readyState?n._createSourceBuffer():n._mediaSource.addEventListener("sourceopen",n._openHandler);else if(null===t._sourceBuffer)t.destroy(),n._type=t._type,n._mediaSource.addEventListener("sourceopen",n._openHandler);else{if(!t._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._debugBuffers=t._debugBuffers,n._sourceBuffer.addEventListener("updateend",n._flowHandler),n._sourceBuffer.addEventListener("error",n._errorHandler)}n._elem.addEventListener("timeupdate",n._flowHandler),n.on("error",(function(e){n._wrapper.error(e)})),n.on("finish",(function(){if(!n.destroyed&&(n._finished=!0,n._allStreams.every((function(e){return e._finished})))){n._wrapper._dumpDebugData();try{n._mediaSource.endOfStream()}catch(e){}}}))}a.prototype.createWriteStream=function(e){return new c(this,e)},a.prototype.error=function(e){var t=this;t.detailedError||(t.detailedError=e),t._dumpDebugData();try{t._mediaSource.endOfStream("decode")}catch(e){}try{window.URL.revokeObjectURL(t._elem.src)}catch(e){}},a.prototype._dumpDebugData=function(){var e=this;e._debug&&(e._debug=!1,e._streams.forEach((function(e,t){var n,i,r;n=e._debugBuffers,i="mediasource-stream-"+t,(r=document.createElement("a")).href=window.URL.createObjectURL(new window.Blob(n)),r.download=i,r.click()})))},i(c,r.Writable),c.prototype._onSourceOpen=function(){var e=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},c.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,t._allStreams.splice(t._allStreams.indexOf(t),1),t._mediaSource.removeEventListener("sourceopen",t._openHandler),t._elem.removeEventListener("timeupdate",t._flowHandler),t._sourceBuffer&&(t._sourceBuffer.removeEventListener("updateend",t._flowHandler),t._sourceBuffer.removeEventListener("error",t._errorHandler),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},c.prototype._createSourceBuffer=function(){var e=this;if(!e.destroyed)if(o.isTypeSupported(e._type)){if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._sourceBuffer.addEventListener("error",e._errorHandler),e._cb){var t=e._cb;e._cb=null,t()}}else e.destroy(new Error("The provided type is not supported"))},c.prototype._write=function(e,t,n){var i=this;if(!i.destroyed)if(i._sourceBuffer){if(i._sourceBuffer.updating)return n(new Error("Cannot append buffer while source buffer updating"));var r=s(e);i._wrapper._debug&&i._debugBuffers.push(r);try{i._sourceBuffer.appendBuffer(r)}catch(e){return void i.destroy(e)}i._cb=n}else i._cb=function(r){if(r)return n(r);i._write(e,t,n)}},c.prototype._flow=function(){var e=this;if(!e.destroyed&&e._sourceBuffer&&!e._sourceBuffer.updating&&!("open"===e._mediaSource.readyState&&e._getBufferDuration()>e._bufferDuration)&&e._cb){var t=e._cb;e._cb=null,t()}};c.prototype._getBufferDuration=function(){for(var e=this._sourceBuffer.buffered,t=this._elem.currentTime,n=-1,i=0;it)break;(n>=0||t<=s)&&(n=s)}var o=n-t;return o<0&&(o=0),o}},{inherits:245,"readable-stream":271,"to-arraybuffer":470}],257:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],258:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":260,"./_stream_writable":262,_process:333,dup:31,inherits:245}],259:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":261,dup:32,inherits:245}],260:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":257,"./_stream_duplex":258,"./internal/streams/async_iterator":263,"./internal/streams/buffer_list":264,"./internal/streams/destroy":265,"./internal/streams/from":267,"./internal/streams/state":269,"./internal/streams/stream":270,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],261:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":257,"./_stream_duplex":258,dup:34,inherits:245}],262:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":257,"./_stream_duplex":258,"./internal/streams/destroy":265,"./internal/streams/state":269,"./internal/streams/stream":270,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],263:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":266,_process:333,dup:36}],264:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],265:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],266:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":257,dup:39}],267:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],268:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":257,"./end-of-stream":266,dup:41}],269:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":257,dup:42}],270:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],271:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":258,"./lib/_stream_passthrough.js":259,"./lib/_stream_readable.js":260,"./lib/_stream_transform.js":261,"./lib/_stream_writable.js":262,"./lib/internal/streams/end-of-stream.js":266,"./lib/internal/streams/pipeline.js":268,dup:44}],272:[function(e,t,n){t.exports=r;const i=e("queue-microtask");function r(e,t){if(!(this instanceof r))return new r(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}r.prototype.put=function(e,t,n=(()=>{})){if(this.closed)return i((()=>n(new Error("Storage is closed"))));const r=e===this.lastChunkIndex;return r&&t.length!==this.lastChunkLength?i((()=>n(new Error("Last chunk length must be "+this.lastChunkLength)))):r||t.length===this.chunkLength?(this.chunks[e]=t,void i((()=>n(null)))):i((()=>n(new Error("Chunk length must be "+this.chunkLength))))},r.prototype.get=function(e,t,n=(()=>{})){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return i((()=>n(new Error("Storage is closed"))));let r=this.chunks[e];if(!r){const e=new Error("Chunk not found");return e.notFound=!0,i((()=>n(e)))}t||(t={});const s=t.offset||0,o=t.length||r.length-s;0===s&&o===r.length||(r=r.slice(s,o+s)),i((()=>n(null,r)))},r.prototype.close=r.prototype.destroy=function(e=(()=>{})){if(this.closed)return i((()=>e(new Error("Storage is closed"))));this.closed=!0,this.chunks=null,i((()=>e(null)))}},{"queue-microtask":346}],273:[function(e,t,n){var i=e("bn.js"),r=e("brorand");function s(e){this.rand=e||new r.Rand}t.exports=s,s.create=function(e){return new s(e)},s.prototype._randbelow=function(e){var t=e.bitLength(),n=Math.ceil(t/8);do{var r=new i(this.rand.generate(n))}while(r.cmp(e)>=0);return r},s.prototype._randrange=function(e,t){var n=t.sub(e);return e.add(this._randbelow(n))},s.prototype.test=function(e,t,n){var r=e.bitLength(),s=i.mont(e),o=new i(1).toRed(s);t||(t=Math.max(1,r/48|0));for(var a=e.subn(1),c=0;!a.testn(c);c++);for(var u=e.shrn(c),l=a.toRed(s);t>0;t--){var d=this._randrange(new i(2),a);n&&n(d);var f=d.toRed(s).redPow(u);if(0!==f.cmp(o)&&0!==f.cmp(l)){for(var p=1;p0;t--){var l=this._randrange(new i(2),o),d=e.gcd(l);if(0!==d.cmpn(1))return d;var f=l.toRed(r).redPow(c);if(0!==f.cmp(s)&&0!==f.cmp(u)){for(var p=1;pp||l===p&&"application/"===r[c].substr(0,12)))continue}r[c]=e}}}))},{"mime-db":145,path:187}],147:[function(e,t,n){(function(t){(function(){var i=e("./index"),r=e("./descriptor"),o=e("uint64be"),s=20828448e5;n.fullBoxes={};function a(e,t,n){for(var i=t;i=8;){var c=i.decode(e,a,r);s.children.push(c),s[c.type]=c,a+=c.length}return s},n.VisualSampleEntry.encodingLength=function(e){var t=78;return(e.children||[]).forEach((function(e){t+=i.encodingLength(e)})),t},n.avcC={},n.avcC.encode=function(e,i,r){i=i?i.slice(r):t.alloc(e.buffer.length),e.buffer.copy(i),n.avcC.encode.bytes=e.buffer.length},n.avcC.decode=function(e,n,i){return{mimeCodec:(e=e.slice(n,i)).toString("hex",1,4),buffer:t.from(e)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(e,r,o){a(r=r?r.slice(o):t.alloc(n.AudioSampleEntry.encodingLength(e)),0,6),r.writeUInt16BE(e.dataReferenceIndex||0,6),a(r,8,16),r.writeUInt16BE(e.channelCount||2,16),r.writeUInt16BE(e.sampleSize||16,18),a(r,20,24),r.writeUInt32BE(e.sampleRate||0,24);var s=28;(e.children||[]).forEach((function(e){i.encode(e,r,s),s+=i.encode.bytes})),n.AudioSampleEntry.encode.bytes=s},n.AudioSampleEntry.decode=function(e,t,n){for(var r=n-t,o={dataReferenceIndex:(e=e.slice(t,n)).readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},s=28;r-s>=8;){var a=i.decode(e,s,r);o.children.push(a),o[a.type]=a,s+=a.length}return o},n.AudioSampleEntry.encodingLength=function(e){var t=28;return(e.children||[]).forEach((function(e){t+=i.encodingLength(e)})),t},n.esds={},n.esds.encode=function(e,i,r){i=i?i.slice(r):t.alloc(e.buffer.length),e.buffer.copy(i,0),n.esds.encode.bytes=e.buffer.length},n.esds.decode=function(e,n,i){e=e.slice(n,i);var o=r.Descriptor.decode(e,0,e.length),s=("ESDescriptor"===o.tagName?o:{}).DecoderConfigDescriptor||{},a=s.oti||0,c=s.DecoderSpecificInfo,l=c?(248&c.buffer.readUInt8(0))>>3:0,p=null;return a&&(p=a.toString(16),l&&(p+="."+l)),{mimeCodec:p,buffer:t.from(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,i,r){var o=e.entries||[];(i=i?i.slice(r):t.alloc(n.stsz.encodingLength(e))).writeUInt32BE(0,0),i.writeUInt32BE(o.length,4);for(var s=0;so&&(l=1),t.writeUInt32BE(l,n),t.write(e.type,n+4,4,"ascii");var p=n+8;if(1===l&&(i.encode(e.length,t,p),p+=8),r.fullBoxes[c]&&(t.writeUInt32BE(e.flags||0,p),t.writeUInt8(e.version||0,p),p+=4),a[c])a[c].forEach((function(n){if(5===n.length){var i=e[n]||[];n=n.substr(0,4),i.forEach((function(e){s._encode(e,t,p),p+=s.encode.bytes}))}else e[n]&&(s._encode(e[n],t,p),p+=s.encode.bytes)})),e.otherBoxes&&e.otherBoxes.forEach((function(e){s._encode(e,t,p),p+=s.encode.bytes}));else if(r[c]){var u=r[c].encode;u(e,t,p),p+=u.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+c+"') or `buffer` must be set");e.buffer.copy(t,p),p+=e.buffer.length}return s.encode.bytes=p-n,t},s.readHeaders=function(e,t,n){if(t=t||0,(n=n||e.length)-t<8)return 8;var o,s,a=e.readUInt32BE(t),c=e.toString("ascii",t+4,t+8),l=t+8;if(1===a){if(n-t<16)return 16;a=i.decode(e,l),l+=8}return r.fullBoxes[c]&&(o=e.readUInt8(l),s=16777215&e.readUInt32BE(l),l+=4),{length:a,headersLen:l-t,contentLen:a-(l-t),type:c,version:o,flags:s}},s.decode=function(e,t,n){t=t||0,n=n||e.length;var i=s.readHeaders(e,t,n);if(!i||i.length>n-t)throw new Error("Data too short");return s.decodeWithoutHeaders(i,e,t+i.headersLen,t+i.length)},s.decodeWithoutHeaders=function(e,n,i,o){i=i||0,o=o||n.length;var c=e.type,l={};if(a[c]){l.otherBoxes=[];for(var p=a[c],u=i;o-u>=8;){var d=s.decode(n,u,o);if(u+=d.length,p.indexOf(d.type)>=0)l[d.type]=d;else if(p.indexOf(d.type+"s")>=0){var f=d.type+"s";(l[f]=l[f]||[]).push(d)}else l.otherBoxes.push(d)}}else if(r[c]){l=(0,r[c].decode)(n,i,o)}else l.buffer=t.from(n.slice(i,o));return l.length=e.length,l.contentLen=e.contentLen,l.type=e.type,l.version=e.version,l.flags=e.flags,l},s.encodingLength=function(e){var t=e.type,n=8;if(r.fullBoxes[t]&&(n+=4),a[t])a[t].forEach((function(t){if(5===t.length){var i=e[t]||[];t=t.substr(0,4),i.forEach((function(e){e.type=t,n+=s.encodingLength(e)}))}else if(e[t]){var r=e[t];r.type=t,n+=s.encodingLength(r)}})),e.otherBoxes&&e.otherBoxes.forEach((function(e){n+=s.encodingLength(e)}));else if(r[t])n+=r[t].encodingLength(e);else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");n+=e.buffer.length}return n>o&&(n+=8),e.length=n,n}}).call(this)}).call(this,e("buffer").Buffer)},{"./boxes":147,buffer:55,uint64be:299}],150:[function(e,t,n){(function(n){(function(){var i=e("readable-stream"),r=e("next-event"),o=e("mp4-box-encoding"),s=n.alloc(0);class a extends i.Writable{constructor(e){super(e),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}_write(e,t,n){if(!this.destroyed){for(var i=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=e,void(this._writeCb=n);var r=e.length{this._pending--,this._kick()})),this._cb=t,this._str}_readBox(){const e=(t,i)=>{this._buffer(t,(t=>{i=i?n.concat([i,t]):t;var r=o.readHeaders(i);"number"==typeof r?e(r-i.length,i):(this._pending++,this._headers=r,this.emit("box",r))}))};e(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;return this._headers=null,this._stream(e.contentLen,(()=>{this._pending--,this._kick()}))}decode(e){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=this._headers;this._headers=null,this._buffer(t.contentLen,(n=>{var i=o.decodeWithoutHeaders(t,n);e(i),this._pending--,this._kick()}))}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;this._headers=null,this._missing=e.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var e=this._writeCb,t=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(t,null,e)}}}class c extends i.PassThrough{constructor(e){super(),this._parent=e,this.destroyed=!1}destroy(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}t.exports=a}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55,"mp4-box-encoding":149,"next-event":184,"readable-stream":167}],151:[function(e,t,n){(function(n){(function(){var i=e("readable-stream"),r=e("mp4-box-encoding"),o=e("queue-microtask");function s(){}class a extends i.Readable{constructor(e){super(e),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(e,t){this.mediaData(e,t)}mediaData(e,t){var n=new c(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n}box(e,t){if(t||(t=s),this.destroyed)return t(new Error("Encoder is destroyed"));var i;if(e.encodeBufferLen&&(i=n.alloc(e.encodeBufferLen)),e.stream)e.buffer=null,i=r.encode(e,i),this.push(i),this._stream=e.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",t),this._forward();else{if(i=r.encode(e,i),this.push(i))return o(t);this._drain=t}}destroy(e){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var t=this._drain;this._drain=null,t(e)}e&&this.emit("error",e),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var e=this._stream.read();if(!e)return void(this._want=!!this._stream);if(!this.push(e))return}}_read(){if(!this._reading&&!this.destroyed){if(this._reading=!0,this._stream&&this._forward(),this._drain){var e=this._drain;this._drain=null,e()}this._reading=!1,this._finalized&&this.push(null)}}}class c extends i.PassThrough{constructor(e){super(),this._parent=e,this.destroyed=!1}destroy(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}t.exports=a}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55,"mp4-box-encoding":149,"queue-microtask":195,"readable-stream":167}],152:[function(e,t,n){const i=e("./decode"),r=e("./encode");n.decode=e=>new i(e),n.encode=e=>new r(e)},{"./decode":150,"./encode":151}],153:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],154:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":156,"./_stream_writable":158,_process:189,dup:16,inherits:118}],155:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":157,dup:17,inherits:118}],156:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":153,"./_stream_duplex":154,"./internal/streams/async_iterator":159,"./internal/streams/buffer_list":160,"./internal/streams/destroy":161,"./internal/streams/from":163,"./internal/streams/state":165,"./internal/streams/stream":166,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],157:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":153,"./_stream_duplex":154,dup:19,inherits:118}],158:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":153,"./_stream_duplex":154,"./internal/streams/destroy":161,"./internal/streams/state":165,"./internal/streams/stream":166,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],159:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":162,_process:189,dup:21}],160:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],161:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],162:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":153,dup:24}],163:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],164:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":153,"./end-of-stream":162,dup:26}],165:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":153,dup:27}],166:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],167:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":154,"./lib/_stream_passthrough.js":155,"./lib/_stream_readable.js":156,"./lib/_stream_transform.js":157,"./lib/_stream_writable.js":158,"./lib/internal/streams/end-of-stream.js":162,"./lib/internal/streams/pipeline.js":164,dup:29}],168:[function(e,t,n){ +"use strict";var i,r,s,o=e("mime-db"),a=e("path").extname,c=/^\s*([^;\s]*)(?:;|\s|$)/,u=/^text\//i;function l(e){if(!e||"string"!=typeof e)return!1;var t=c.exec(e),n=t&&o[t[1].toLowerCase()];return n&&n.charset?n.charset:!(!t||!u.test(t[1]))&&"UTF-8"}n.charset=l,n.charsets={lookup:l},n.contentType=function(e){if(!e||"string"!=typeof e)return!1;var t=-1===e.indexOf("/")?n.lookup(e):e;if(!t)return!1;if(-1===t.indexOf("charset")){var i=n.charset(t);i&&(t+="; charset="+i.toLowerCase())}return t},n.extension=function(e){if(!e||"string"!=typeof e)return!1;var t=c.exec(e),i=t&&n.extensions[t[1].toLowerCase()];if(!i||!i.length)return!1;return i[0]},n.extensions=Object.create(null),n.lookup=function(e){if(!e||"string"!=typeof e)return!1;var t=a("x."+e).toLowerCase().substr(1);if(!t)return!1;return n.types[t]||!1},n.types=Object.create(null),i=n.extensions,r=n.types,s=["nginx","apache",void 0,"iana"],Object.keys(o).forEach((function(e){var t=o[e],n=t.extensions;if(n&&n.length){i[e]=n;for(var a=0;al||u===l&&"application/"===r[c].substr(0,12)))continue}r[c]=e}}}))},{"mime-db":276,path:325}],278:[function(e,t,n){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}t.exports=i,i.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)}},{}],279:[function(e,t,n){"use strict";var i=n;function r(e){return 1===e.length?"0"+e:e}function s(e){for(var t="",n=0;n>8,o=255&r;s?n.push(s,o):n.push(o)}return n},i.zero2=r,i.toHex=s,i.encode=function(e,t){return"hex"===t?s(e):e}},{}],280:[function(e,t,n){(function(t){(function(){var i=e("./index"),r=e("./descriptor"),s=e("uint64be"),o=20828448e5;n.fullBoxes={};function a(e,t,n){for(var i=t;i=8;){var c=i.decode(e,a,r);o.children.push(c),o[c.type]=c,a+=c.length}return o},n.VisualSampleEntry.encodingLength=function(e){var t=78;return(e.children||[]).forEach((function(e){t+=i.encodingLength(e)})),t},n.avcC={},n.avcC.encode=function(e,i,r){i=i?i.slice(r):t.alloc(e.buffer.length),e.buffer.copy(i),n.avcC.encode.bytes=e.buffer.length},n.avcC.decode=function(e,n,i){return{mimeCodec:(e=e.slice(n,i)).toString("hex",1,4),buffer:t.from(e)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(e,r,s){a(r=r?r.slice(s):t.alloc(n.AudioSampleEntry.encodingLength(e)),0,6),r.writeUInt16BE(e.dataReferenceIndex||0,6),a(r,8,16),r.writeUInt16BE(e.channelCount||2,16),r.writeUInt16BE(e.sampleSize||16,18),a(r,20,24),r.writeUInt32BE(e.sampleRate||0,24);var o=28;(e.children||[]).forEach((function(e){i.encode(e,r,o),o+=i.encode.bytes})),n.AudioSampleEntry.encode.bytes=o},n.AudioSampleEntry.decode=function(e,t,n){for(var r=n-t,s={dataReferenceIndex:(e=e.slice(t,n)).readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},o=28;r-o>=8;){var a=i.decode(e,o,r);s.children.push(a),s[a.type]=a,o+=a.length}return s},n.AudioSampleEntry.encodingLength=function(e){var t=28;return(e.children||[]).forEach((function(e){t+=i.encodingLength(e)})),t},n.esds={},n.esds.encode=function(e,i,r){i=i?i.slice(r):t.alloc(e.buffer.length),e.buffer.copy(i,0),n.esds.encode.bytes=e.buffer.length},n.esds.decode=function(e,n,i){e=e.slice(n,i);var s=r.Descriptor.decode(e,0,e.length),o=("ESDescriptor"===s.tagName?s:{}).DecoderConfigDescriptor||{},a=o.oti||0,c=o.DecoderSpecificInfo,u=c?(248&c.buffer.readUInt8(0))>>3:0,l=null;return a&&(l=a.toString(16),u&&(l+="."+u)),{mimeCodec:l,buffer:t.from(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,i,r){var s=e.entries||[];(i=i?i.slice(r):t.alloc(n.stsz.encodingLength(e))).writeUInt32BE(0,0),i.writeUInt32BE(s.length,4);for(var o=0;os&&(u=1),t.writeUInt32BE(u,n),t.write(e.type,n+4,4,"ascii");var l=n+8;if(1===u&&(i.encode(e.length,t,l),l+=8),r.fullBoxes[c]&&(t.writeUInt32BE(e.flags||0,l),t.writeUInt8(e.version||0,l),l+=4),a[c])a[c].forEach((function(n){if(5===n.length){var i=e[n]||[];n=n.substr(0,4),i.forEach((function(e){o._encode(e,t,l),l+=o.encode.bytes}))}else e[n]&&(o._encode(e[n],t,l),l+=o.encode.bytes)})),e.otherBoxes&&e.otherBoxes.forEach((function(e){o._encode(e,t,l),l+=o.encode.bytes}));else if(r[c]){var d=r[c].encode;d(e,t,l),l+=d.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+c+"') or `buffer` must be set");e.buffer.copy(t,l),l+=e.buffer.length}return o.encode.bytes=l-n,t},o.readHeaders=function(e,t,n){if(t=t||0,(n=n||e.length)-t<8)return 8;var s,o,a=e.readUInt32BE(t),c=e.toString("ascii",t+4,t+8),u=t+8;if(1===a){if(n-t<16)return 16;a=i.decode(e,u),u+=8}return r.fullBoxes[c]&&(s=e.readUInt8(u),o=16777215&e.readUInt32BE(u),u+=4),{length:a,headersLen:u-t,contentLen:a-(u-t),type:c,version:s,flags:o}},o.decode=function(e,t,n){t=t||0,n=n||e.length;var i=o.readHeaders(e,t,n);if(!i||i.length>n-t)throw new Error("Data too short");return o.decodeWithoutHeaders(i,e,t+i.headersLen,t+i.length)},o.decodeWithoutHeaders=function(e,n,i,s){i=i||0,s=s||n.length;var c=e.type,u={};if(a[c]){u.otherBoxes=[];for(var l=a[c],d=i;s-d>=8;){var f=o.decode(n,d,s);if(d+=f.length,l.indexOf(f.type)>=0)u[f.type]=f;else if(l.indexOf(f.type+"s")>=0){var p=f.type+"s";(u[p]=u[p]||[]).push(f)}else u.otherBoxes.push(f)}}else if(r[c]){u=(0,r[c].decode)(n,i,s)}else u.buffer=t.from(n.slice(i,s));return u.length=e.length,u.contentLen=e.contentLen,u.type=e.type,u.version=e.version,u.flags=e.flags,u},o.encodingLength=function(e){var t=e.type,n=8;if(r.fullBoxes[t]&&(n+=4),a[t])a[t].forEach((function(t){if(5===t.length){var i=e[t]||[];t=t.substr(0,4),i.forEach((function(e){e.type=t,n+=o.encodingLength(e)}))}else if(e[t]){var r=e[t];r.type=t,n+=o.encodingLength(r)}})),e.otherBoxes&&e.otherBoxes.forEach((function(e){n+=o.encodingLength(e)}));else if(r[t])n+=r[t].encodingLength(e);else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");n+=e.buffer.length}return n>s&&(n+=8),e.length=n,n}}).call(this)}).call(this,e("buffer").Buffer)},{"./boxes":280,buffer:114,uint64be:477}],283:[function(e,t,n){(function(n){(function(){var i=e("readable-stream"),r=e("next-event"),s=e("mp4-box-encoding"),o=n.alloc(0);class a extends i.Writable{constructor(e){super(e),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}_write(e,t,n){if(!this.destroyed){for(var i=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=e,void(this._writeCb=n);var r=e.length{this._pending--,this._kick()})),this._cb=t,this._str}_readBox(){const e=(t,i)=>{this._buffer(t,(t=>{i=i?n.concat([i,t]):t;var r=s.readHeaders(i);"number"==typeof r?e(r-i.length,i):(this._pending++,this._headers=r,this.emit("box",r))}))};e(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;return this._headers=null,this._stream(e.contentLen,(()=>{this._pending--,this._kick()}))}decode(e){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=this._headers;this._headers=null,this._buffer(t.contentLen,(n=>{var i=s.decodeWithoutHeaders(t,n);e(i),this._pending--,this._kick()}))}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;this._headers=null,this._missing=e.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var e=this._writeCb,t=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(t,null,e)}}}class c extends i.PassThrough{constructor(e){super(),this._parent=e,this.destroyed=!1}destroy(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}t.exports=a}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114,"mp4-box-encoding":282,"next-event":317,"readable-stream":300}],284:[function(e,t,n){(function(n){(function(){var i=e("readable-stream"),r=e("mp4-box-encoding"),s=e("queue-microtask");function o(){}class a extends i.Readable{constructor(e){super(e),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(e,t){this.mediaData(e,t)}mediaData(e,t){var n=new c(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n}box(e,t){if(t||(t=o),this.destroyed)return t(new Error("Encoder is destroyed"));var i;if(e.encodeBufferLen&&(i=n.alloc(e.encodeBufferLen)),e.stream)e.buffer=null,i=r.encode(e,i),this.push(i),this._stream=e.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",t),this._forward();else{if(i=r.encode(e,i),this.push(i))return s(t);this._drain=t}}destroy(e){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var t=this._drain;this._drain=null,t(e)}e&&this.emit("error",e),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var e=this._stream.read();if(!e)return void(this._want=!!this._stream);if(!this.push(e))return}}_read(){if(!this._reading&&!this.destroyed){if(this._reading=!0,this._stream&&this._forward(),this._drain){var e=this._drain;this._drain=null,e()}this._reading=!1,this._finalized&&this.push(null)}}}class c extends i.PassThrough{constructor(e){super(),this._parent=e,this.destroyed=!1}destroy(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}t.exports=a}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114,"mp4-box-encoding":282,"queue-microtask":346,"readable-stream":300}],285:[function(e,t,n){const i=e("./decode"),r=e("./encode");n.decode=e=>new i(e),n.encode=e=>new r(e)},{"./decode":283,"./encode":284}],286:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],287:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":289,"./_stream_writable":291,_process:333,dup:31,inherits:245}],288:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":290,dup:32,inherits:245}],289:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":286,"./_stream_duplex":287,"./internal/streams/async_iterator":292,"./internal/streams/buffer_list":293,"./internal/streams/destroy":294,"./internal/streams/from":296,"./internal/streams/state":298,"./internal/streams/stream":299,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],290:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":286,"./_stream_duplex":287,dup:34,inherits:245}],291:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":286,"./_stream_duplex":287,"./internal/streams/destroy":294,"./internal/streams/state":298,"./internal/streams/stream":299,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],292:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":295,_process:333,dup:36}],293:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],294:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],295:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":286,dup:39}],296:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],297:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":286,"./end-of-stream":295,dup:41}],298:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":286,dup:42}],299:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],300:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":287,"./lib/_stream_passthrough.js":288,"./lib/_stream_readable.js":289,"./lib/_stream_transform.js":290,"./lib/_stream_writable.js":291,"./lib/internal/streams/end-of-stream.js":295,"./lib/internal/streams/pipeline.js":297,dup:44}],301:[function(e,t,n){ /*! multistream. MIT License. Feross Aboukhadijeh */ -const i=e("readable-stream"),r=e("once");function o(e){return a(e,{objectMode:!0,highWaterMark:16})}function s(e){return a(e)}function a(e,t){if(!e||"function"==typeof e||e._readableState)return e;const n=new i.Readable(t).wrap(e);return e.destroy&&(n.destroy=e.destroy.bind(e)),n}class c extends i.Readable{constructor(e,t){super({...t,autoDestroy:!0}),this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=t&&t.objectMode?o:s,"function"==typeof e?this._queue=e:(this._queue=e.map(this._toStreams2),this._queue.forEach((e=>{"function"!=typeof e&&this._attachErrorListener(e)}))),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(this._forwarding||!this._drained||!this._current)return;let e;for(this._forwarding=!0;this._drained&&null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}_destroy(e,t){let n=[];if(this._current&&n.push(this._current),"function"!=typeof this._queue&&(n=n.concat(this._queue)),0===n.length)t(e);else{let i=n.length,o=e;n.forEach((n=>{!function(e,t,n){if(!e.destroy||e.destroyed)n(t);else{const i=r((e=>n(e||t)));e.on("error",i).on("close",(()=>i())).destroy(t,i)}}(n,e,(e=>{o=o||e,0==--i&&t(o)}))}))}}_next(){if(this._current=null,"function"==typeof this._queue)this._queue(((e,t)=>{if(e)return this.destroy(e);t=this._toStreams2(t),this._attachErrorListener(t),this._gotNextStream(t)}));else{let e=this._queue.shift();"function"==typeof e&&(e=this._toStreams2(e()),this._attachErrorListener(e)),this._gotNextStream(e)}}_gotNextStream(e){if(!e)return void this.push(null);this._current=e,this._forward();const t=()=>{this._forward()},n=()=>{if(!e._readableState.ended&&!e.destroyed){const e=new Error("ERR_STREAM_PREMATURE_CLOSE");e.code="ERR_STREAM_PREMATURE_CLOSE",this.destroy(e)}},i=()=>{this._current=null,e.removeListener("readable",t),e.removeListener("end",i),e.removeListener("close",n),e.destroy(),this._next()};e.on("readable",t),e.once("end",i),e.once("close",n)}_attachErrorListener(e){if(!e)return;const t=n=>{e.removeListener("error",t),this.destroy(n)};e.once("error",t)}}c.obj=e=>new c(e,{objectMode:!0,highWaterMark:16}),t.exports=c},{once:185,"readable-stream":183}],169:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],170:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":172,"./_stream_writable":174,_process:189,dup:16,inherits:118}],171:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":173,dup:17,inherits:118}],172:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":169,"./_stream_duplex":170,"./internal/streams/async_iterator":175,"./internal/streams/buffer_list":176,"./internal/streams/destroy":177,"./internal/streams/from":179,"./internal/streams/state":181,"./internal/streams/stream":182,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],173:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":169,"./_stream_duplex":170,dup:19,inherits:118}],174:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":169,"./_stream_duplex":170,"./internal/streams/destroy":177,"./internal/streams/state":181,"./internal/streams/stream":182,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],175:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":178,_process:189,dup:21}],176:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],177:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],178:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":169,dup:24}],179:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],180:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":169,"./end-of-stream":178,dup:26}],181:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":169,dup:27}],182:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],183:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":170,"./lib/_stream_passthrough.js":171,"./lib/_stream_readable.js":172,"./lib/_stream_transform.js":173,"./lib/_stream_writable.js":174,"./lib/internal/streams/end-of-stream.js":178,"./lib/internal/streams/pipeline.js":180,dup:29}],184:[function(e,t,n){t.exports=function(e,t){var n=null;return e.on(t,(function(e){if(n){var t=n;n=null,t(e)}})),function(e){n=e}}},{}],185:[function(e,t,n){var i=e("wrappy");function r(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=i(r),t.exports.strict=i(o),r.proto=r((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},{wrappy:336}],186:[function(e,t,n){(function(n){(function(){ +const i=e("readable-stream"),r=e("once");function s(e){return a(e,{objectMode:!0,highWaterMark:16})}function o(e){return a(e)}function a(e,t){if(!e||"function"==typeof e||e._readableState)return e;const n=new i.Readable(t).wrap(e);return e.destroy&&(n.destroy=e.destroy.bind(e)),n}class c extends i.Readable{constructor(e,t){super({...t,autoDestroy:!0}),this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=t&&t.objectMode?s:o,"function"==typeof e?this._queue=e:(this._queue=e.map(this._toStreams2),this._queue.forEach((e=>{"function"!=typeof e&&this._attachErrorListener(e)}))),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(this._forwarding||!this._drained||!this._current)return;let e;for(this._forwarding=!0;this._drained&&null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}_destroy(e,t){let n=[];if(this._current&&n.push(this._current),"function"!=typeof this._queue&&(n=n.concat(this._queue)),0===n.length)t(e);else{let i=n.length,s=e;n.forEach((n=>{!function(e,t,n){if(!e.destroy||e.destroyed)n(t);else{const i=r((e=>n(e||t)));e.on("error",i).on("close",(()=>i())).destroy(t,i)}}(n,e,(e=>{s=s||e,0==--i&&t(s)}))}))}}_next(){if(this._current=null,"function"==typeof this._queue)this._queue(((e,t)=>{if(e)return this.destroy(e);t=this._toStreams2(t),this._attachErrorListener(t),this._gotNextStream(t)}));else{let e=this._queue.shift();"function"==typeof e&&(e=this._toStreams2(e()),this._attachErrorListener(e)),this._gotNextStream(e)}}_gotNextStream(e){if(!e)return void this.push(null);this._current=e,this._forward();const t=()=>{this._forward()},n=()=>{if(!e._readableState.ended&&!e.destroyed){const e=new Error("ERR_STREAM_PREMATURE_CLOSE");e.code="ERR_STREAM_PREMATURE_CLOSE",this.destroy(e)}},i=()=>{this._current=null,e.removeListener("readable",t),e.removeListener("end",i),e.removeListener("close",n),e.destroy(),this._next()};e.on("readable",t),e.once("end",i),e.once("close",n)}_attachErrorListener(e){if(!e)return;const t=n=>{e.removeListener("error",t),this.destroy(n)};e.once("error",t)}}c.obj=e=>new c(e,{objectMode:!0,highWaterMark:16}),t.exports=c},{once:318,"readable-stream":316}],302:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],303:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":305,"./_stream_writable":307,_process:333,dup:31,inherits:245}],304:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":306,dup:32,inherits:245}],305:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":302,"./_stream_duplex":303,"./internal/streams/async_iterator":308,"./internal/streams/buffer_list":309,"./internal/streams/destroy":310,"./internal/streams/from":312,"./internal/streams/state":314,"./internal/streams/stream":315,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],306:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":302,"./_stream_duplex":303,dup:34,inherits:245}],307:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":302,"./_stream_duplex":303,"./internal/streams/destroy":310,"./internal/streams/state":314,"./internal/streams/stream":315,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],308:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":311,_process:333,dup:36}],309:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],310:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],311:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":302,dup:39}],312:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],313:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":302,"./end-of-stream":311,dup:41}],314:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":302,dup:42}],315:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],316:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":303,"./lib/_stream_passthrough.js":304,"./lib/_stream_readable.js":305,"./lib/_stream_transform.js":306,"./lib/_stream_writable.js":307,"./lib/internal/streams/end-of-stream.js":311,"./lib/internal/streams/pipeline.js":313,dup:44}],317:[function(e,t,n){t.exports=function(e,t){var n=null;return e.on(t,(function(e){if(n){var t=n;n=null,t(e)}})),function(e){n=e}}},{}],318:[function(e,t,n){var i=e("wrappy");function r(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function s(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=i(r),t.exports.strict=i(s),r.proto=r((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return s(this)},configurable:!0})}))},{wrappy:514}],319:[function(e,t,n){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],320:[function(e,t,n){"use strict";var i=e("asn1.js");n.certificate=e("./certificate");var r=i.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));n.RSAPrivateKey=r;var s=i.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));n.RSAPublicKey=s;var o=i.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}));n.PublicKey=o;var a=i.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),c=i.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(a),this.key("subjectPrivateKey").octstr())}));n.PrivateKey=c;var u=i.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));n.EncryptedPrivateKey=u;var l=i.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));n.DSAPrivateKey=l,n.DSAparam=i.define("DSAparam",(function(){this.int()}));var d=i.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(f),this.key("publicKey").optional().explicit(1).bitstr())}));n.ECPrivateKey=d;var f=i.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})}));n.signature=i.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},{"./certificate":321,"asn1.js":4}],321:[function(e,t,n){"use strict";var i=e("asn1.js"),r=i.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),s=i.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),o=i.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),a=i.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())})),c=i.define("RelativeDistinguishedName",(function(){this.setof(s)})),u=i.define("RDNSequence",(function(){this.seqof(c)})),l=i.define("Name",(function(){this.choice({rdnSequence:this.use(u)})})),d=i.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(r),this.key("notAfter").use(r))})),f=i.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),p=i.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(o),this.key("issuer").use(l),this.key("validity").use(d),this.key("subject").use(l),this.key("subjectPublicKeyInfo").use(a),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(f).optional())})),h=i.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(p),this.key("signatureAlgorithm").use(o),this.key("signatureValue").bitstr())}));t.exports=h},{"asn1.js":4}],322:[function(e,t,n){var i=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,r=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,s=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,o=e("evp_bytestokey"),a=e("browserify-aes"),c=e("safe-buffer").Buffer;t.exports=function(e,t){var n,u=e.toString(),l=u.match(i);if(l){var d="aes"+l[1],f=c.from(l[2],"hex"),p=c.from(l[3].replace(/[\r\n]/g,""),"base64"),h=o(t,f.slice(0,8),parseInt(l[1],10)).key,m=[],b=a.createDecipheriv(d,h,f);m.push(b.update(p)),m.push(b.final()),n=c.concat(m)}else{var g=u.match(s);n=c.from(g[2].replace(/[\r\n]/g,""),"base64")}return{tag:u.match(r)[1],data:n}}},{"browserify-aes":74,evp_bytestokey:195,"safe-buffer":376}],323:[function(e,t,n){var i=e("./asn1"),r=e("./aesid.json"),s=e("./fixProc"),o=e("browserify-aes"),a=e("pbkdf2"),c=e("safe-buffer").Buffer;function u(e){var t;"object"!=typeof e||c.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=c.from(e));var n,u,l=s(e,t),d=l.tag,f=l.data;switch(d){case"CERTIFICATE":u=i.certificate.decode(f,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(u||(u=i.PublicKey.decode(f,"der")),n=u.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return i.RSAPublicKey.decode(u.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return u.subjectPrivateKey=u.subjectPublicKey,{type:"ec",data:u};case"1.2.840.10040.4.1":return u.algorithm.params.pub_key=i.DSAparam.decode(u.subjectPublicKey.data,"der"),{type:"dsa",data:u.algorithm.params};default:throw new Error("unknown key id "+n)}case"ENCRYPTED PRIVATE KEY":f=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),s=r[e.algorithm.decrypt.cipher.algo.join(".")],u=e.algorithm.decrypt.cipher.iv,l=e.subjectPrivateKey,d=parseInt(s.split("-")[1],10)/8,f=a.pbkdf2Sync(t,n,i,d,"sha1"),p=o.createDecipheriv(s,f,u),h=[];return h.push(p.update(l)),h.push(p.final()),c.concat(h)}(f=i.EncryptedPrivateKey.decode(f,"der"),t);case"PRIVATE KEY":switch(n=(u=i.PrivateKey.decode(f,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return i.RSAPrivateKey.decode(u.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:u.algorithm.curve,privateKey:i.ECPrivateKey.decode(u.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return u.algorithm.params.priv_key=i.DSAparam.decode(u.subjectPrivateKey,"der"),{type:"dsa",params:u.algorithm.params};default:throw new Error("unknown key id "+n)}case"RSA PUBLIC KEY":return i.RSAPublicKey.decode(f,"der");case"RSA PRIVATE KEY":return i.RSAPrivateKey.decode(f,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:i.DSAPrivateKey.decode(f,"der")};case"EC PRIVATE KEY":return{curve:(f=i.ECPrivateKey.decode(f,"der")).parameters.value,privateKey:f.privateKey};default:throw new Error("unknown key type "+d)}}t.exports=u,u.signature=i.signature},{"./aesid.json":319,"./asn1":320,"./fixProc":322,"browserify-aes":74,pbkdf2:326,"safe-buffer":376}],324:[function(e,t,n){(function(n){(function(){ /*! parse-torrent. MIT License. WebTorrent LLC */ -const i=e("bencode"),r=e("blob-to-buffer"),o=e("fs"),s=e("simple-get"),a=e("magnet-uri"),c=e("path"),l=e("simple-sha1"),p=e("queue-microtask");function u(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e)){const t=a(e);if(!t.infoHash)throw new Error("Invalid torrent identifier");return t}if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return a(`magnet:?xt=urn:btih:${e}`);if(n.isBuffer(e)&&20===e.length)return a(`magnet:?xt=urn:btih:${e.toString("hex")}`);if(n.isBuffer(e))return function(e){n.isBuffer(e)&&(e=i.decode(e));f(e.info,"info"),f(e.info["name.utf-8"]||e.info.name,"info.name"),f(e.info["piece length"],"info['piece length']"),f(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach((e=>{f("number"==typeof e.length,"info.files[0].length"),f(e["path.utf-8"]||e.path,"info.files[0].path")})):f("number"==typeof e.info.length,"info.length");const t={info:e.info,infoBuffer:i.encode(e.info),name:(e.info["name.utf-8"]||e.info.name).toString(),announce:[]};t.infoHash=l.sync(t.infoBuffer),t.infoHashBuffer=n.from(t.infoHash,"hex"),void 0!==e.info.private&&(t.private=!!e.info.private);e["creation date"]&&(t.created=new Date(1e3*e["creation date"]));e["created by"]&&(t.createdBy=e["created by"].toString());n.isBuffer(e.comment)&&(t.comment=e.comment.toString());Array.isArray(e["announce-list"])&&e["announce-list"].length>0?e["announce-list"].forEach((e=>{e.forEach((e=>{t.announce.push(e.toString())}))})):e.announce&&t.announce.push(e.announce.toString());n.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]);t.urlList=(e["url-list"]||[]).map((e=>e.toString())),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList));const r=e.info.files||[e.info];t.files=r.map(((e,n)=>{const i=[].concat(t.name,e["path.utf-8"]||e.path||[]).map((e=>e.toString()));return{path:c.join.apply(null,[c.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:r.slice(0,n).reduce(d,0)}})),t.length=r.reduce(d,0);const o=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(o.offset+o.length)%t.pieceLength||t.pieceLength,t.pieces=function(e){const t=[];for(let n=0;n{i(null,a)})):(c=t,"undefined"!=typeof Blob&&c instanceof Blob?r(t,((e,t)=>{if(e)return i(new Error(`Error converting Blob: ${e.message}`));l(t)})):"function"==typeof s&&/^https?:/.test(t)?(n=Object.assign({url:t,timeout:3e4,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},n),s.concat(n,((e,t,n)=>{if(e)return i(new Error(`Error downloading torrent: ${e.message}`));l(n)}))):"function"==typeof o.readFile&&"string"==typeof t?o.readFile(t,((e,t)=>{if(e)return i(new Error("Invalid torrent identifier"));l(t)})):p((()=>{i(new Error("Invalid torrent identifier"))})));var c;function l(e){try{a=u(e)}catch(e){return i(e)}a&&a.infoHash?i(null,a):i(new Error("Invalid torrent identifier"))}},t.exports.toMagnetURI=a.encode,t.exports.toTorrentFile=function(e){const t={info:e.info};t["announce-list"]=(e.announce||[]).map((e=>(t.announce||(t.announce=e),[e=n.from(e,"utf8")]))),t["url-list"]=e.urlList||[],void 0!==e.private&&(t.private=Number(e.private));e.created&&(t["creation date"]=e.created.getTime()/1e3|0);e.createdBy&&(t["created by"]=e.createdBy);e.comment&&(t.comment=e.comment);return i.encode(t)},n.alloc(0)}).call(this)}).call(this,e("buffer").Buffer)},{bencode:7,"blob-to-buffer":37,buffer:55,fs:54,"magnet-uri":126,path:187,"queue-microtask":195,"simple-get":224,"simple-sha1":244}],187:[function(e,t,n){(function(e){(function(){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function i(e,t){for(var n,i="",r=0,o=-1,s=0,a=0;a<=e.length;++a){if(a2){var c=i.lastIndexOf("/");if(c!==i.length-1){-1===c?(i="",r=0):r=(i=i.slice(0,c)).length-1-i.lastIndexOf("/"),o=a,s=0;continue}}else if(2===i.length||1===i.length){i="",r=0,o=a,s=0;continue}t&&(i.length>0?i+="/..":i="..",r=2)}else i.length>0?i+="/"+e.slice(o+1,a):i=e.slice(o+1,a),r=a-o-1;o=a,s=0}else 46===n&&-1!==s?++s:s=-1}return i}var r={resolve:function(){for(var t,r="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){var a;s>=0?a=arguments[s]:(void 0===t&&(t=e.cwd()),a=t),n(a),0!==a.length&&(r=a+"/"+r,o=47===a.charCodeAt(0))}return r=i(r,!o),o?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(n(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=i(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return n(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t0&&(void 0===e?e=i:e+="/"+i)}return void 0===e?".":r.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t)return"";if((e=r.resolve(e))===(t=r.resolve(t)))return"";for(var i=1;il){if(47===t.charCodeAt(a+u))return t.slice(a+u+1);if(0===u)return t.slice(a+u)}else s>l&&(47===e.charCodeAt(i+u)?p=u:0===u&&(p=0));break}var d=e.charCodeAt(i+u);if(d!==t.charCodeAt(a+u))break;47===d&&(p=u)}var f="";for(u=i+p+1;u<=o;++u)u!==o&&47!==e.charCodeAt(u)||(0===f.length?f+="..":f+="/..");return f.length>0?f+t.slice(a+p):(a+=p,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(n(e),0===e.length)return".";for(var t=e.charCodeAt(0),i=47===t,r=-1,o=!0,s=e.length-1;s>=1;--s)if(47===(t=e.charCodeAt(s))){if(!o){r=s;break}}else o=!1;return-1===r?i?"/":".":i&&1===r?"//":e.slice(0,r)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');n(e);var i,r=0,o=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,c=-1;for(i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(47===l){if(!s){r=i+1;break}}else-1===c&&(s=!1,c=i+1),a>=0&&(l===t.charCodeAt(a)?-1==--a&&(o=i):(a=-1,o=c))}return r===o?o=c:-1===o&&(o=e.length),e.slice(r,o)}for(i=e.length-1;i>=0;--i)if(47===e.charCodeAt(i)){if(!s){r=i+1;break}}else-1===o&&(s=!1,o=i+1);return-1===o?"":e.slice(r,o)},extname:function(e){n(e);for(var t=-1,i=0,r=-1,o=!0,s=0,a=e.length-1;a>=0;--a){var c=e.charCodeAt(a);if(47!==c)-1===r&&(o=!1,r=a+1),46===c?-1===t?t=a:1!==s&&(s=1):-1!==t&&(s=-1);else if(!o){i=a+1;break}}return-1===t||-1===r||0===s||1===s&&t===r-1&&t===i+1?"":e.slice(t,r)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+i:n+e+i:i}("/",e)},parse:function(e){n(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var i,r=e.charCodeAt(0),o=47===r;o?(t.root="/",i=1):i=0;for(var s=-1,a=0,c=-1,l=!0,p=e.length-1,u=0;p>=i;--p)if(47!==(r=e.charCodeAt(p)))-1===c&&(l=!1,c=p+1),46===r?-1===s?s=p:1!==u&&(u=1):-1!==s&&(u=-1);else if(!l){a=p+1;break}return-1===s||-1===c||0===u||1===u&&s===c-1&&s===a+1?-1!==c&&(t.base=t.name=0===a&&o?e.slice(1,c):e.slice(a,c)):(0===a&&o?(t.name=e.slice(1,s),t.base=e.slice(1,c)):(t.name=e.slice(a,s),t.base=e.slice(a,c)),t.ext=e.slice(s,c)),a>0?t.dir=e.slice(0,a-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,t.exports=r}).call(this)}).call(this,e("_process"))},{_process:189}],188:[function(e,t,n){t.exports=function(e){return Math.max(16384,1<1)for(var n=1;n0,(function(t){e||(e=t),t&&i.forEach(p),s||(i.forEach(p),n(e))}))}));return t.reduce(u)}}).call(this)}).call(this,e("_process"))},{_process:189,"end-of-stream":95,fs:54,once:185}],191:[function(e,t,n){(function(e){(function(){!function(i){var r="object"==typeof n&&n&&!n.nodeType&&n,o="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(i=s);var a,c,l=2147483647,p=36,u=/^xn--/,d=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},m=Math.floor,g=String.fromCharCode;function v(e){throw new RangeError(h[e])}function b(e,t){for(var n=e.length,i=[];n--;)i[n]=t(e[n]);return i}function x(e,t){var n=e.split("@"),i="";return n.length>1&&(i=n[0]+"@",e=n[1]),i+b((e=e.replace(f,".")).split("."),t).join(".")}function y(e){for(var t,n,i=[],r=0,o=e.length;r=55296&&t<=56319&&r65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=g(e)})).join("")}function w(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function k(e,t,n){var i=0;for(e=n?m(e/700):e>>1,e+=m(e/t);e>455;i+=p)e=m(e/35);return m(i+36*e/(e+38))}function E(e){var t,n,i,r,o,s,a,c,u,d,f,h=[],g=e.length,b=0,x=128,y=72;for((n=e.lastIndexOf("-"))<0&&(n=0),i=0;i=128&&v("not-basic"),h.push(e.charCodeAt(i));for(r=n>0?n+1:0;r=g&&v("invalid-input"),((c=(f=e.charCodeAt(r++))-48<10?f-22:f-65<26?f-65:f-97<26?f-97:p)>=p||c>m((l-b)/s))&&v("overflow"),b+=c*s,!(c<(u=a<=y?1:a>=y+26?26:a-y));a+=p)s>m(l/(d=p-u))&&v("overflow"),s*=d;y=k(b-o,t=h.length+1,0==o),m(b/t)>l-x&&v("overflow"),x+=m(b/t),b%=t,h.splice(b++,0,x)}return _(h)}function S(e){var t,n,i,r,o,s,a,c,u,d,f,h,b,x,_,E=[];for(h=(e=y(e)).length,t=128,n=0,o=72,s=0;s=t&&fm((l-n)/(b=i+1))&&v("overflow"),n+=(a-t)*b,t=a,s=0;sl&&v("overflow"),f==t){for(c=n,u=p;!(c<(d=u<=o?1:u>=o+26?26:u-o));u+=p)_=c-d,x=p-d,E.push(g(w(d+_%x,0))),c=m(_/x);E.push(g(w(c,0))),o=k(n,b,i==r),n=0,++i}++n,++t}return E.join("")}if(a={version:"1.4.1",ucs2:{decode:y,encode:_},decode:E,encode:S,toASCII:function(e){return x(e,(function(e){return d.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return x(e,(function(e){return u.test(e)?E(e.slice(4).toLowerCase()):e}))}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",(function(){return a}));else if(r&&o)if(t.exports==r)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(r[c]=a[c]);else i.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],192:[function(e,t,n){"use strict";function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,o){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var p=0;p=0?(u=m.substr(0,g),d=m.substr(g+1)):(u=m,d=""),f=decodeURIComponent(u),h=decodeURIComponent(d),i(s,f)?r(s[f])?s[f].push(h):s[f]=[s[f],h]:s[f]=h}return s};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],193:[function(e,t,n){"use strict";var i=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),(function(s){var a=encodeURIComponent(i(s))+n;return r(e[s])?o(e[s],(function(e){return a+encodeURIComponent(i(e))})).join(t):a+encodeURIComponent(i(e[s]))})).join(t):a?encodeURIComponent(i(a))+n+encodeURIComponent(i(e)):""};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],i=0;i{p("number"==typeof e.length,"info.files[0].length"),p(e["path.utf-8"]||e.path,"info.files[0].path")})):p("number"==typeof e.info.length,"info.length");const t={info:e.info,infoBuffer:i.encode(e.info),name:(e.info["name.utf-8"]||e.info.name).toString(),announce:[]};t.infoHash=u.sync(t.infoBuffer),t.infoHashBuffer=n.from(t.infoHash,"hex"),void 0!==e.info.private&&(t.private=!!e.info.private);e["creation date"]&&(t.created=new Date(1e3*e["creation date"]));e["created by"]&&(t.createdBy=e["created by"].toString());n.isBuffer(e.comment)&&(t.comment=e.comment.toString());Array.isArray(e["announce-list"])&&e["announce-list"].length>0?e["announce-list"].forEach((e=>{e.forEach((e=>{t.announce.push(e.toString())}))})):e.announce&&t.announce.push(e.announce.toString());n.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]);t.urlList=(e["url-list"]||[]).map((e=>e.toString())),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList));const r=e.info.files||[e.info];t.files=r.map(((e,n)=>{const i=[].concat(t.name,e["path.utf-8"]||e.path||[]).map((e=>e.toString()));return{path:c.join.apply(null,[c.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:r.slice(0,n).reduce(f,0)}})),t.length=r.reduce(f,0);const s=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(s.offset+s.length)%t.pieceLength||t.pieceLength,t.pieces=function(e){const t=[];for(let n=0;n{i(null,a)})):(c=t,"undefined"!=typeof Blob&&c instanceof Blob?r(t,((e,t)=>{if(e)return i(new Error(`Error converting Blob: ${e.message}`));u(t)})):"function"==typeof o&&/^https?:/.test(t)?(n=Object.assign({url:t,timeout:3e4,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},n),o.concat(n,((e,t,n)=>{if(e)return i(new Error(`Error downloading torrent: ${e.message}`));u(n)}))):"function"==typeof s.readFile&&"string"==typeof t?s.readFile(t,((e,t)=>{if(e)return i(new Error("Invalid torrent identifier"));u(t)})):l((()=>{i(new Error("Invalid torrent identifier"))})));var c;function u(e){try{a=d(e)}catch(e){return i(e)}a&&a.infoHash?i(null,a):i(new Error("Invalid torrent identifier"))}},t.exports.toMagnetURI=a.encode,t.exports.toTorrentFile=function(e){const t={info:e.info};t["announce-list"]=(e.announce||[]).map((e=>(t.announce||(t.announce=e),[e=n.from(e,"utf8")]))),t["url-list"]=e.urlList||[],void 0!==e.private&&(t.private=Number(e.private));e.created&&(t["creation date"]=e.created.getTime()/1e3|0);e.createdBy&&(t["created by"]=e.createdBy);e.comment&&(t.comment=e.comment);return i.encode(t)},n.alloc(0)}).call(this)}).call(this,e("buffer").Buffer)},{bencode:22,"blob-to-buffer":52,buffer:114,fs:71,"magnet-uri":254,path:325,"queue-microtask":346,"simple-get":387,"simple-sha1":407}],325:[function(e,t,n){(function(e){(function(){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function i(e,t){for(var n,i="",r=0,s=-1,o=0,a=0;a<=e.length;++a){if(a2){var c=i.lastIndexOf("/");if(c!==i.length-1){-1===c?(i="",r=0):r=(i=i.slice(0,c)).length-1-i.lastIndexOf("/"),s=a,o=0;continue}}else if(2===i.length||1===i.length){i="",r=0,s=a,o=0;continue}t&&(i.length>0?i+="/..":i="..",r=2)}else i.length>0?i+="/"+e.slice(s+1,a):i=e.slice(s+1,a),r=a-s-1;s=a,o=0}else 46===n&&-1!==o?++o:o=-1}return i}var r={resolve:function(){for(var t,r="",s=!1,o=arguments.length-1;o>=-1&&!s;o--){var a;o>=0?a=arguments[o]:(void 0===t&&(t=e.cwd()),a=t),n(a),0!==a.length&&(r=a+"/"+r,s=47===a.charCodeAt(0))}return r=i(r,!s),s?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(n(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=i(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return n(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t0&&(void 0===e?e=i:e+="/"+i)}return void 0===e?".":r.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t)return"";if((e=r.resolve(e))===(t=r.resolve(t)))return"";for(var i=1;iu){if(47===t.charCodeAt(a+d))return t.slice(a+d+1);if(0===d)return t.slice(a+d)}else o>u&&(47===e.charCodeAt(i+d)?l=d:0===d&&(l=0));break}var f=e.charCodeAt(i+d);if(f!==t.charCodeAt(a+d))break;47===f&&(l=d)}var p="";for(d=i+l+1;d<=s;++d)d!==s&&47!==e.charCodeAt(d)||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(a+l):(a+=l,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(n(e),0===e.length)return".";for(var t=e.charCodeAt(0),i=47===t,r=-1,s=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!s){r=o;break}}else s=!1;return-1===r?i?"/":".":i&&1===r?"//":e.slice(0,r)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');n(e);var i,r=0,s=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,c=-1;for(i=e.length-1;i>=0;--i){var u=e.charCodeAt(i);if(47===u){if(!o){r=i+1;break}}else-1===c&&(o=!1,c=i+1),a>=0&&(u===t.charCodeAt(a)?-1==--a&&(s=i):(a=-1,s=c))}return r===s?s=c:-1===s&&(s=e.length),e.slice(r,s)}for(i=e.length-1;i>=0;--i)if(47===e.charCodeAt(i)){if(!o){r=i+1;break}}else-1===s&&(o=!1,s=i+1);return-1===s?"":e.slice(r,s)},extname:function(e){n(e);for(var t=-1,i=0,r=-1,s=!0,o=0,a=e.length-1;a>=0;--a){var c=e.charCodeAt(a);if(47!==c)-1===r&&(s=!1,r=a+1),46===c?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!s){i=a+1;break}}return-1===t||-1===r||0===o||1===o&&t===r-1&&t===i+1?"":e.slice(t,r)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+i:n+e+i:i}("/",e)},parse:function(e){n(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var i,r=e.charCodeAt(0),s=47===r;s?(t.root="/",i=1):i=0;for(var o=-1,a=0,c=-1,u=!0,l=e.length-1,d=0;l>=i;--l)if(47!==(r=e.charCodeAt(l)))-1===c&&(u=!1,c=l+1),46===r?-1===o?o=l:1!==d&&(d=1):-1!==o&&(d=-1);else if(!u){a=l+1;break}return-1===o||-1===c||0===d||1===d&&o===c-1&&o===a+1?-1!==c&&(t.base=t.name=0===a&&s?e.slice(1,c):e.slice(a,c)):(0===a&&s?(t.name=e.slice(1,o),t.base=e.slice(1,c)):(t.name=e.slice(a,o),t.base=e.slice(a,c)),t.ext=e.slice(o,c)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,t.exports=r}).call(this)}).call(this,e("_process"))},{_process:333}],326:[function(e,t,n){n.pbkdf2=e("./lib/async"),n.pbkdf2Sync=e("./lib/sync")},{"./lib/async":327,"./lib/sync":330}],327:[function(e,t,n){(function(n){(function(){var i,r,s=e("safe-buffer").Buffer,o=e("./precondition"),a=e("./default-encoding"),c=e("./sync"),u=e("./to-buffer"),l=n.crypto&&n.crypto.subtle,d={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},f=[];function p(){return r||(r=n.process&&n.process.nextTick?n.process.nextTick:n.queueMicrotask?n.queueMicrotask:n.setImmediate?n.setImmediate:n.setTimeout)}function h(e,t,n,i,r){return l.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return l.deriveBits({name:"PBKDF2",salt:t,iterations:n,hash:{name:r}},e,i<<3)})).then((function(e){return s.from(e)}))}t.exports=function(e,t,r,m,b,g){"function"==typeof b&&(g=b,b=void 0);var v=d[(b=b||"sha1").toLowerCase()];if(v&&"function"==typeof n.Promise){if(o(r,m),e=u(e,a,"Password"),t=u(t,a,"Salt"),"function"!=typeof g)throw new Error("No callback provided to pbkdf2");!function(e,t){e.then((function(e){p()((function(){t(null,e)}))}),(function(e){p()((function(){t(e)}))}))}(function(e){if(n.process&&!n.process.browser)return Promise.resolve(!1);if(!l||!l.importKey||!l.deriveBits)return Promise.resolve(!1);if(void 0!==f[e])return f[e];var t=h(i=i||s.alloc(8),i,10,128,e).then((function(){return!0})).catch((function(){return!1}));return f[e]=t,t}(v).then((function(n){return n?h(e,t,r,m,v):c(e,t,r,m,b)})),g)}else p()((function(){var n;try{n=c(e,t,r,m,b)}catch(e){return g(e)}g(null,n)}))}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":328,"./precondition":329,"./sync":330,"./to-buffer":331,"safe-buffer":376}],328:[function(e,t,n){(function(e,n){(function(){var i;if(n.process&&n.process.browser)i="utf-8";else if(n.process&&n.process.version){i=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else i="utf-8";t.exports=i}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:333}],329:[function(e,t,n){var i=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>i||t!=t)throw new TypeError("Bad key length")}},{}],330:[function(e,t,n){var i=e("create-hash/md5"),r=e("ripemd160"),s=e("sha.js"),o=e("safe-buffer").Buffer,a=e("./precondition"),c=e("./default-encoding"),u=e("./to-buffer"),l=o.alloc(128),d={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function f(e,t,n){var a=function(e){function t(t){return s(e).update(t).digest()}function n(e){return(new r).update(e).digest()}return"rmd160"===e||"ripemd160"===e?n:"md5"===e?i:t}(e),c="sha512"===e||"sha384"===e?128:64;t.length>c?t=a(t):t.length1)for(var n=1;nh||new o(t).cmp(p.modulus)>=0)throw new Error("decryption error");f=n?u(new o(t),p):a(t,p);var m=l.alloc(h-f.length);if(f=l.concat([m,f],h),4===d)return function(e,t){var n=e.modulus.byteLength(),i=c("sha1").update(l.alloc(0)).digest(),o=i.length;if(0!==t[0])throw new Error("decryption error");var a=t.slice(1,o+1),u=t.slice(o+1),d=s(a,r(u,o)),f=s(u,r(d,n-o-1));if(function(e,t){e=l.from(e),t=l.from(t);var n=0,i=e.length;e.length!==t.length&&(n++,i=Math.min(e.length,t.length));var r=-1;for(;++r=t.length){s++;break}var o=t.slice(2,r-1);("0002"!==i.toString("hex")&&!n||"0001"!==i.toString("hex")&&n)&&s++;o.length<8&&s++;if(s)throw new Error("decryption error");return t.slice(r)}(0,f,n);if(3===d)return f;throw new Error("unknown padding")}},{"./mgf":335,"./withPublic":339,"./xor":340,"bn.js":336,"browserify-rsa":92,"create-hash":143,"parse-asn1":323,"safe-buffer":376}],338:[function(e,t,n){var i=e("parse-asn1"),r=e("randombytes"),s=e("create-hash"),o=e("./mgf"),a=e("./xor"),c=e("bn.js"),u=e("./withPublic"),l=e("browserify-rsa"),d=e("safe-buffer").Buffer;t.exports=function(e,t,n){var f;f=e.padding?e.padding:n?1:4;var p,h=i(e);if(4===f)p=function(e,t){var n=e.modulus.byteLength(),i=t.length,u=s("sha1").update(d.alloc(0)).digest(),l=u.length,f=2*l;if(i>n-f-2)throw new Error("message too long");var p=d.alloc(n-i-f-2),h=n-l-1,m=r(l),b=a(d.concat([u,p,d.alloc(1,1),t],h),o(m,h)),g=a(m,o(b,l));return new c(d.concat([d.alloc(1),g,b],n))}(h,t);else if(1===f)p=function(e,t,n){var i,s=t.length,o=e.modulus.byteLength();if(s>o-11)throw new Error("message too long");i=n?d.alloc(o-s-3,255):function(e){var t,n=d.allocUnsafe(e),i=0,s=r(2*e),o=0;for(;i=0)throw new Error("data too long for modulus")}return n?l(p,h):u(p,h)}},{"./mgf":335,"./withPublic":339,"./xor":340,"bn.js":336,"browserify-rsa":92,"create-hash":143,"parse-asn1":323,randombytes:348,"safe-buffer":376}],339:[function(e,t,n){var i=e("bn.js"),r=e("safe-buffer").Buffer;t.exports=function(e,t){return r.from(e.toRed(i.mont(t.modulus)).redPow(new i(t.publicExponent)).fromRed().toArray())}},{"bn.js":336,"safe-buffer":376}],340:[function(e,t,n){t.exports=function(e,t){for(var n=e.length,i=-1;++i0,(function(t){e||(e=t),t&&i.forEach(l),o||(i.forEach(l),n(e))}))}));return t.reduce(d)}}).call(this)}).call(this,e("_process"))},{_process:333,"end-of-stream":192,fs:71,once:318}],342:[function(e,t,n){(function(e){(function(){!function(i){var r="object"==typeof n&&n&&!n.nodeType&&n,s="object"==typeof t&&t&&!t.nodeType&&t,o="object"==typeof e&&e;o.global!==o&&o.window!==o&&o.self!==o||(i=o);var a,c,u=2147483647,l=36,d=/^xn--/,f=/[^\x20-\x7E]/,p=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},m=Math.floor,b=String.fromCharCode;function g(e){throw new RangeError(h[e])}function v(e,t){for(var n=e.length,i=[];n--;)i[n]=t(e[n]);return i}function y(e,t){var n=e.split("@"),i="";return n.length>1&&(i=n[0]+"@",e=n[1]),i+v((e=e.replace(p,".")).split("."),t).join(".")}function _(e){for(var t,n,i=[],r=0,s=e.length;r=55296&&t<=56319&&r65535&&(t+=b((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=b(e)})).join("")}function x(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function k(e,t,n){var i=0;for(e=n?m(e/700):e>>1,e+=m(e/t);e>455;i+=l)e=m(e/35);return m(i+36*e/(e+38))}function E(e){var t,n,i,r,s,o,a,c,d,f,p,h=[],b=e.length,v=0,y=128,_=72;for((n=e.lastIndexOf("-"))<0&&(n=0),i=0;i=128&&g("not-basic"),h.push(e.charCodeAt(i));for(r=n>0?n+1:0;r=b&&g("invalid-input"),((c=(p=e.charCodeAt(r++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:l)>=l||c>m((u-v)/o))&&g("overflow"),v+=c*o,!(c<(d=a<=_?1:a>=_+26?26:a-_));a+=l)o>m(u/(f=l-d))&&g("overflow"),o*=f;_=k(v-s,t=h.length+1,0==s),m(v/t)>u-y&&g("overflow"),y+=m(v/t),v%=t,h.splice(v++,0,y)}return w(h)}function S(e){var t,n,i,r,s,o,a,c,d,f,p,h,v,y,w,E=[];for(h=(e=_(e)).length,t=128,n=0,s=72,o=0;o=t&&pm((u-n)/(v=i+1))&&g("overflow"),n+=(a-t)*v,t=a,o=0;ou&&g("overflow"),p==t){for(c=n,d=l;!(c<(f=d<=s?1:d>=s+26?26:d-s));d+=l)w=c-f,y=l-f,E.push(b(x(f+w%y,0))),c=m(w/y);E.push(b(x(c,0))),s=k(n,v,i==r),n=0,++i}++n,++t}return E.join("")}if(a={version:"1.4.1",ucs2:{decode:_,encode:w},decode:E,encode:S,toASCII:function(e){return y(e,(function(e){return f.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return y(e,(function(e){return d.test(e)?E(e.slice(4).toLowerCase()):e}))}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",(function(){return a}));else if(r&&s)if(t.exports==r)s.exports=a;else for(c in a)a.hasOwnProperty(c)&&(r[c]=a[c]);else i.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],343:[function(e,t,n){"use strict";function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,s){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;var a=/\+/g;e=e.split(t);var c=1e3;s&&"number"==typeof s.maxKeys&&(c=s.maxKeys);var u=e.length;c>0&&u>c&&(u=c);for(var l=0;l=0?(d=m.substr(0,b),f=m.substr(b+1)):(d=m,f=""),p=decodeURIComponent(d),h=decodeURIComponent(f),i(o,p)?r(o[p])?o[p].push(h):o[p]=[o[p],h]:o[p]=h}return o};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],344:[function(e,t,n){"use strict";var i=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?s(o(e),(function(o){var a=encodeURIComponent(i(o))+n;return r(e[o])?s(e[o],(function(e){return a+encodeURIComponent(i(e))})).join(t):a+encodeURIComponent(i(e[o]))})).join(t):a?encodeURIComponent(i(a))+n+encodeURIComponent(i(e)):""};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function s(e,t){if(e.map)return e.map(t);for(var n=[],i=0;i */ -let n;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:e):e=>(n||(n=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0)))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],196:[function(e,t,n){t.exports=function(e){var t=0;return function(){if(t===e.length)return null;var n=e.length-t,i=Math.random()*n|0,r=e[t+i],o=e[t];return e[t]=r,e[t+i]=o,t++,r}}},{}],197:[function(e,t,n){(function(n,i){(function(){"use strict";var r=65536,o=4294967295;var s=e("safe-buffer").Buffer,a=i.crypto||i.msCrypto;a&&a.getRandomValues?t.exports=function(e,t){if(e>o)throw new RangeError("requested too many random bytes");var i=s.allocUnsafe(e);if(e>0)if(e>r)for(var c=0;c=e.length)return this._position+=e.length,n(null);let s;if(o>e.length){this._position+=e.length,s=0===t?e:e.slice(t),i=r.stream.write(s)&&i;break}this._position+=o,s=0===t&&o===e.length?e:e.slice(t,o),i=r.stream.write(s)&&i,r.last&&r.stream.end(),e=e.slice(o),this._queue.shift()}i?n(null):r.stream.once("drain",n.bind(null,null))}slice(e){if(this.destroyed)return null;Array.isArray(e)||(e=[e]);const t=new r;return e.forEach(((n,i)=>{this._queue.push({start:n.start,end:n.end,stream:t,last:i===e.length-1})})),this._buffer&&this._write(this._buffer,null,this._cb),t}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}}},{"readable-stream":213}],199:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],200:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":202,"./_stream_writable":204,_process:189,dup:16,inherits:118}],201:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":203,dup:17,inherits:118}],202:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":199,"./_stream_duplex":200,"./internal/streams/async_iterator":205,"./internal/streams/buffer_list":206,"./internal/streams/destroy":207,"./internal/streams/from":209,"./internal/streams/state":211,"./internal/streams/stream":212,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],203:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":199,"./_stream_duplex":200,dup:19,inherits:118}],204:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":199,"./_stream_duplex":200,"./internal/streams/destroy":207,"./internal/streams/state":211,"./internal/streams/stream":212,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],205:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":208,_process:189,dup:21}],206:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],207:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],208:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":199,dup:24}],209:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],210:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":199,"./end-of-stream":208,dup:26}],211:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":199,dup:27}],212:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],213:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":200,"./lib/_stream_passthrough.js":201,"./lib/_stream_readable.js":202,"./lib/_stream_transform.js":203,"./lib/_stream_writable.js":204,"./lib/internal/streams/end-of-stream.js":208,"./lib/internal/streams/pipeline.js":210,dup:29}],214:[function(e,t,n){ +let n;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:e):e=>(n||(n=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0)))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],347:[function(e,t,n){t.exports=function(e){var t=0;return function(){if(t===e.length)return null;var n=e.length-t,i=Math.random()*n|0,r=e[t+i],s=e[t];return e[t]=r,e[t+i]=s,t++,r}}},{}],348:[function(e,t,n){(function(n,i){(function(){"use strict";var r=65536,s=4294967295;var o=e("safe-buffer").Buffer,a=i.crypto||i.msCrypto;a&&a.getRandomValues?t.exports=function(e,t){if(e>s)throw new RangeError("requested too many random bytes");var i=o.allocUnsafe(e);if(e>0)if(e>r)for(var c=0;cl||e<0)throw new TypeError("offset must be a uint32");if(e>c||e>t)throw new RangeError("offset out of range")}function f(e,t,n){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>l||e<0)throw new TypeError("size must be a uint32");if(e+t>n||e>c)throw new RangeError("buffer too small")}function p(e,n,i,r){if(t.browser){var s=e.buffer,a=new Uint8Array(s,n,i);return u.getRandomValues(a),r?void t.nextTick((function(){r(null,e)})):e}if(!r)return o(i).copy(e,n),e;o(i,(function(t,i){if(t)return r(t);i.copy(e,n),r(null,e)}))}u&&u.getRandomValues||!t.browser?(n.randomFill=function(e,t,n,r){if(!(a.isBuffer(e)||e instanceof i.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)r=t,t=0,n=e.length;else if("function"==typeof n)r=n,n=e.length-t;else if("function"!=typeof r)throw new TypeError('"cb" argument must be a function');return d(t,e.length),f(n,t,e.length),p(e,t,n,r)},n.randomFillSync=function(e,t,n){void 0===t&&(t=0);if(!(a.isBuffer(e)||e instanceof i.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');d(t,e.length),void 0===n&&(n=e.length-t);return f(n,t,e.length),p(e,t,n)}):(n.randomFill=r,n.randomFillSync=r)}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:333,randombytes:348,"safe-buffer":376}],350:[function(e,t,n){const{Writable:i,PassThrough:r}=e("readable-stream");t.exports=class extends i{constructor(e,t={}){super(t),this.destroyed=!1,this._queue=[],this._position=e||0,this._cb=null,this._buffer=null,this._out=null}_write(e,t,n){let i=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=e,void(this._cb=n);this._buffer=null;var r=this._queue[0];const t=Math.max(r.start-this._position,0),s=r.end-this._position;if(t>=e.length)return this._position+=e.length,n(null);let o;if(s>e.length){this._position+=e.length,o=0===t?e:e.slice(t),i=r.stream.write(o)&&i;break}this._position+=s,o=0===t&&s===e.length?e:e.slice(t,s),i=r.stream.write(o)&&i,r.last&&r.stream.end(),e=e.slice(s),this._queue.shift()}i?n(null):r.stream.once("drain",n.bind(null,null))}slice(e){if(this.destroyed)return null;Array.isArray(e)||(e=[e]);const t=new r;return e.forEach(((n,i)=>{this._queue.push({start:n.start,end:n.end,stream:t,last:i===e.length-1})})),this._buffer&&this._write(this._buffer,null,this._cb),t}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}}},{"readable-stream":365}],351:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],352:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":354,"./_stream_writable":356,_process:333,dup:31,inherits:245}],353:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":355,dup:32,inherits:245}],354:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":351,"./_stream_duplex":352,"./internal/streams/async_iterator":357,"./internal/streams/buffer_list":358,"./internal/streams/destroy":359,"./internal/streams/from":361,"./internal/streams/state":363,"./internal/streams/stream":364,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],355:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":351,"./_stream_duplex":352,dup:34,inherits:245}],356:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":351,"./_stream_duplex":352,"./internal/streams/destroy":359,"./internal/streams/state":363,"./internal/streams/stream":364,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],357:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":360,_process:333,dup:36}],358:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],359:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],360:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":351,dup:39}],361:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],362:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":351,"./end-of-stream":360,dup:41}],363:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":351,dup:42}],364:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],365:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":352,"./lib/_stream_passthrough.js":353,"./lib/_stream_readable.js":354,"./lib/_stream_transform.js":355,"./lib/_stream_writable.js":356,"./lib/internal/streams/end-of-stream.js":360,"./lib/internal/streams/pipeline.js":362,dup:44}],366:[function(e,t,n){"use strict";function i(e){return parseInt(e,10)===e}function r(e){function t(t){if(void 0===t){t=new Array(e);for(var n=0;n */ -n.render=function(e,t,n,i){"function"==typeof n&&(i=n,n={});n||(n={});i||(i=()=>{});x(e),y(n),"string"==typeof t&&(t=document.querySelector(t));v(e,(i=>{if(t.nodeName!==i.toUpperCase()){const n=s.extname(e.name).toLowerCase();throw new Error(`Cannot render "${n}" inside a "${t.nodeName.toLowerCase()}" element, expected "${i}"`)}return"video"!==i&&"audio"!==i||_(t,n),t}),n,i)},n.append=function(e,t,n,i){"function"==typeof n&&(i=n,n={});n||(n={});i||(i=()=>{});x(e),y(n),"string"==typeof t&&(t=document.querySelector(t));if(t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");function r(e){const n=document.createElement(e);return t.appendChild(n),n}v(e,(function(e){return"video"===e||"audio"===e?function(e){const i=r(e);return _(i,n),t.appendChild(i),i}(e):r(e)}),n,(function(e,t){e&&t&&t.remove(),i(e,t)}))},n.mime=e("./lib/mime.json");const i=e("debug")("render-media"),r=e("is-ascii"),o=e("mediasource"),s=e("path"),a=e("stream-to-blob-url"),c=e("videostream"),l=[".m4a",".m4b",".m4p",".m4v",".mp4"],p=[".m4v",".mkv",".mp4",".webm"],u=[].concat(p,[".m4a",".m4b",".m4p",".mp3"]),d=[".mov",".ogv"],f=[".aac",".oga",".ogg",".wav",".flac"],h=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],m=[".css",".html",".js",".md",".pdf",".srt",".txt"],g="undefined"!=typeof window&&window.MediaSource;function v(e,t,n,a){const v=s.extname(e.name).toLowerCase();let x,y=0;function _(){return!("number"==typeof e.length&&e.length>n.maxBlobLength)||(i("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),C(new Error(`File length too large for Blob URL approach: ${e.length} (max: ${n.maxBlobLength})`)),!1)}function w(n){_()&&(x=t(n),b(e,((e,t)=>{if(e)return C(e);x.addEventListener("error",C),x.addEventListener("loadstart",k),x.addEventListener("loadedmetadata",E),x.src=t})))}function k(){if(x.removeEventListener("loadstart",k),n.autoplay){const e=x.play();void 0!==e&&e.catch(C)}}function E(){x.removeEventListener("loadedmetadata",E),a(null,x)}function S(){b(e,((e,n)=>{if(e)return C(e);".pdf"!==v?(x=t("iframe"),x.sandbox="allow-forms allow-scripts",x.src=n):(x=t("object"),x.setAttribute("typemustmatch",!0),x.setAttribute("type","application/pdf"),x.setAttribute("data",n)),a(null,x)}))}function C(t){t.message=`Error rendering file "${e.name}": ${t.message}`,i(t.message),a(t)}u.includes(v)?function(){const n=p.includes(v)?"video":"audio";g?l.includes(v)?r():a():u();function r(){i(`Use \`videostream\` package for ${e.name}`),h(),x.addEventListener("error",d),x.addEventListener("loadstart",k),x.addEventListener("loadedmetadata",E),new c(e,x)}function a(){i(`Use MediaSource API for ${e.name}`),h(),x.addEventListener("error",f),x.addEventListener("loadstart",k),x.addEventListener("loadedmetadata",E);const t=new o(x).createWriteStream((n=e.name,{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4b":'audio/mp4; codecs="mp4a.40.5"',".m4p":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[s.extname(n).toLowerCase()]));var n;e.createReadStream().pipe(t),y&&(x.currentTime=y)}function u(){i(`Use Blob URL for ${e.name}`),h(),x.addEventListener("error",C),x.addEventListener("loadstart",k),x.addEventListener("loadedmetadata",E),b(e,((e,t)=>{if(e)return C(e);x.src=t,y&&(x.currentTime=y)}))}function d(e){i("videostream error: fallback to MediaSource API: %o",e.message||e),x.removeEventListener("error",d),x.removeEventListener("loadedmetadata",E),a()}function f(e){i("MediaSource API error: fallback to Blob URL: %o",e.message||e),_()&&(x.removeEventListener("error",f),x.removeEventListener("loadedmetadata",E),u())}function h(){x||(x=t(n),x.addEventListener("progress",(()=>{y=x.currentTime})))}}():d.includes(v)?w("video"):f.includes(v)?w("audio"):h.includes(v)?(x=t("img"),b(e,((t,n)=>{if(t)return C(t);x.src=n,x.alt=e.name,a(null,x)}))):m.includes(v)?S():function(){i('Unknown file extension "%s" - will attempt to render into iframe',v);let t="";function n(){r(t)?(i('File extension "%s" appears ascii, so will render.',v),S()):(i('File extension "%s" appears non-ascii, will not render.',v),a(new Error(`Unsupported file type "${v}": Cannot append to DOM`)))}e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",(e=>{t+=e})).on("end",n).on("error",a)}()}function b(e,t){const i=s.extname(e.name).toLowerCase();a(e.createReadStream(),n.mime[i]).then((e=>t(null,e)),(e=>t(e)))}function x(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function y(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=2e8)}function _(e,t){e.autoplay=!!t.autoplay,e.muted=!!t.muted,e.controls=!!t.controls}},{"./lib/mime.json":215,debug:216,"is-ascii":119,mediasource:127,path:187,"stream-to-blob-url":285,videostream:309}],215:[function(e,t,n){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],216:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":217,_process:189,dup:12}],217:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:218}],218:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],219:[function(e,t,n){ +n.render=function(e,t,n,i){"function"==typeof n&&(i=n,n={});n||(n={});i||(i=()=>{});y(e),_(n),"string"==typeof t&&(t=document.querySelector(t));g(e,(i=>{if(t.nodeName!==i.toUpperCase()){const n=o.extname(e.name).toLowerCase();throw new Error(`Cannot render "${n}" inside a "${t.nodeName.toLowerCase()}" element, expected "${i}"`)}return"video"!==i&&"audio"!==i||w(t,n),t}),n,i)},n.append=function(e,t,n,i){"function"==typeof n&&(i=n,n={});n||(n={});i||(i=()=>{});y(e),_(n),"string"==typeof t&&(t=document.querySelector(t));if(t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");function r(e){const n=document.createElement(e);return t.appendChild(n),n}g(e,(function(e){return"video"===e||"audio"===e?function(e){const i=r(e);return w(i,n),t.appendChild(i),i}(e):r(e)}),n,(function(e,t){e&&t&&t.remove(),i(e,t)}))},n.mime=e("./lib/mime.json");const i=e("debug")("render-media"),r=e("is-ascii"),s=e("mediasource"),o=e("path"),a=e("stream-to-blob-url"),c=e("videostream"),u=[".m4a",".m4b",".m4p",".m4v",".mp4"],l=[".m4v",".mkv",".mp4",".webm"],d=[].concat(l,[".m4a",".m4b",".m4p",".mp3"]),f=[".mov",".ogv"],p=[".aac",".oga",".ogg",".wav",".flac"],h=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],m=[".css",".html",".js",".md",".pdf",".srt",".txt"],b="undefined"!=typeof window&&window.MediaSource;function g(e,t,n,a){const g=o.extname(e.name).toLowerCase();let y,_=0;function w(){return!("number"==typeof e.length&&e.length>n.maxBlobLength)||(i("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),M(new Error(`File length too large for Blob URL approach: ${e.length} (max: ${n.maxBlobLength})`)),!1)}function x(n){w()&&(y=t(n),v(e,((e,t)=>{if(e)return M(e);y.addEventListener("error",M),y.addEventListener("loadstart",k),y.addEventListener("loadedmetadata",E),y.src=t})))}function k(){if(y.removeEventListener("loadstart",k),n.autoplay){const e=y.play();void 0!==e&&e.catch(M)}}function E(){y.removeEventListener("loadedmetadata",E),a(null,y)}function S(){v(e,((e,n)=>{if(e)return M(e);".pdf"!==g?(y=t("iframe"),y.sandbox="allow-forms allow-scripts",y.src=n):(y=t("object"),y.setAttribute("typemustmatch",!0),y.setAttribute("type","application/pdf"),y.setAttribute("data",n)),a(null,y)}))}function M(t){t.message=`Error rendering file "${e.name}": ${t.message}`,i(t.message),a(t)}d.includes(g)?function(){const n=l.includes(g)?"video":"audio";b?u.includes(g)?r():a():d();function r(){i(`Use \`videostream\` package for ${e.name}`),h(),y.addEventListener("error",f),y.addEventListener("loadstart",k),y.addEventListener("loadedmetadata",E),new c(e,y)}function a(){i(`Use MediaSource API for ${e.name}`),h(),y.addEventListener("error",p),y.addEventListener("loadstart",k),y.addEventListener("loadedmetadata",E);const t=new s(y).createWriteStream((n=e.name,{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4b":'audio/mp4; codecs="mp4a.40.5"',".m4p":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[o.extname(n).toLowerCase()]));var n;e.createReadStream().pipe(t),_&&(y.currentTime=_)}function d(){i(`Use Blob URL for ${e.name}`),h(),y.addEventListener("error",M),y.addEventListener("loadstart",k),y.addEventListener("loadedmetadata",E),v(e,((e,t)=>{if(e)return M(e);y.src=t,_&&(y.currentTime=_)}))}function f(e){i("videostream error: fallback to MediaSource API: %o",e.message||e),y.removeEventListener("error",f),y.removeEventListener("loadedmetadata",E),a()}function p(e){i("MediaSource API error: fallback to Blob URL: %o",e.message||e),w()&&(y.removeEventListener("error",p),y.removeEventListener("loadedmetadata",E),d())}function h(){y||(y=t(n),y.addEventListener("progress",(()=>{_=y.currentTime})))}}():f.includes(g)?x("video"):p.includes(g)?x("audio"):h.includes(g)?(y=t("img"),v(e,((t,n)=>{if(t)return M(t);y.src=n,y.alt=e.name,a(null,y)}))):m.includes(g)?S():function(){i('Unknown file extension "%s" - will attempt to render into iframe',g);let t="";function n(){r(t)?(i('File extension "%s" appears ascii, so will render.',g),S()):(i('File extension "%s" appears non-ascii, will not render.',g),a(new Error(`Unsupported file type "${g}": Cannot append to DOM`)))}e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",(e=>{t+=e})).on("end",n).on("error",a)}()}function v(e,t){const i=o.extname(e.name).toLowerCase();a(e.createReadStream(),n.mime[i]).then((e=>t(null,e)),(e=>t(e)))}function y(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function _(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=2e8)}function w(e,t){e.autoplay=!!t.autoplay,e.muted=!!t.muted,e.controls=!!t.controls}},{"./lib/mime.json":368,debug:369,"is-ascii":246,mediasource:256,path:325,"stream-to-blob-url":463,videostream:487}],368:[function(e,t,n){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],369:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":370,_process:333,dup:27}],370:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:371}],371:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],372:[function(e,t,n){"use strict";var i=e("buffer").Buffer,r=e("inherits"),s=e("hash-base"),o=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],l=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],d=[0,1518500249,1859775393,2400959708,2840853838],f=[1352829926,1548603684,1836072691,2053994217,0];function p(){s.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function h(e,t){return e<>>32-t}function m(e,t,n,i,r,s,o,a){return h(e+(t^n^i)+s+o|0,a)+r|0}function b(e,t,n,i,r,s,o,a){return h(e+(t&n|~t&i)+s+o|0,a)+r|0}function g(e,t,n,i,r,s,o,a){return h(e+((t|~n)^i)+s+o|0,a)+r|0}function v(e,t,n,i,r,s,o,a){return h(e+(t&i|n&~i)+s+o|0,a)+r|0}function y(e,t,n,i,r,s,o,a){return h(e+(t^(n|~i))+s+o|0,a)+r|0}r(p,s),p.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var n=0|this._a,i=0|this._b,r=0|this._c,s=0|this._d,p=0|this._e,_=0|this._a,w=0|this._b,x=0|this._c,k=0|this._d,E=0|this._e,S=0;S<80;S+=1){var M,A;S<16?(M=m(n,i,r,s,p,e[a[S]],d[0],u[S]),A=y(_,w,x,k,E,e[c[S]],f[0],l[S])):S<32?(M=b(n,i,r,s,p,e[a[S]],d[1],u[S]),A=v(_,w,x,k,E,e[c[S]],f[1],l[S])):S<48?(M=g(n,i,r,s,p,e[a[S]],d[2],u[S]),A=g(_,w,x,k,E,e[c[S]],f[2],l[S])):S<64?(M=v(n,i,r,s,p,e[a[S]],d[3],u[S]),A=b(_,w,x,k,E,e[c[S]],f[3],l[S])):(M=y(n,i,r,s,p,e[a[S]],d[4],u[S]),A=m(_,w,x,k,E,e[c[S]],f[4],l[S])),n=p,p=s,s=h(r,10),r=i,i=M,_=E,E=k,k=h(x,10),x=w,w=A}var I=this._b+r+k|0;this._b=this._c+s+E|0,this._c=this._d+p+_|0,this._d=this._e+n+w|0,this._e=this._a+i+x|0,this._a=I},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=i.alloc?i.alloc(20):new i(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=p},{buffer:114,"hash-base":213,inherits:245}],373:[function(e,t,n){ /*! run-parallel-limit. MIT License. Feross Aboukhadijeh */ -t.exports=function(e,t,n){if("number"!=typeof t)throw new Error("second argument must be a Number");let r,o,s,a,c,l,p=!0;Array.isArray(e)?(r=[],s=o=e.length):(a=Object.keys(e),r={},s=o=a.length);function u(e){function t(){n&&n(e,r),n=null}p?i(t):t()}function d(t,n,i){if(r[t]=i,n&&(c=!0),0==--s||n)u(n);else if(!c&&l */ -t.exports=function(e,t){let n,r,o,s=!0;Array.isArray(e)?(n=[],r=e.length):(o=Object.keys(e),n={},r=o.length);function a(e){function r(){t&&t(e,n),t=null}s?i(r):r()}function c(e,t,i){n[e]=i,(0==--r||t)&&a(t)}r?o?o.forEach((function(t){e[t]((function(e,n){c(t,e,n)}))})):e.forEach((function(e,t){e((function(e,n){c(t,e,n)}))})):a(null);s=!1};const i=e("queue-microtask")},{"queue-microtask":195}],221:[function(e,t,n){var i,r;i="undefined"!=typeof self?self:this,r=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){var i=n(5),r=n(1),o=r.toHex,s=r.ceilHeapSize,a=n(6),c=function(e){for(e+=9;e%64>0;e+=1);return e},l=function(e,t){var n=new Int32Array(e,t+320,5),i=new Int32Array(5),r=new DataView(i.buffer);return r.setInt32(0,n[0],!1),r.setInt32(4,n[1],!1),r.setInt32(8,n[2],!1),r.setInt32(12,n[3],!1),r.setInt32(16,n[4],!1),i},p=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(t=t||65536)%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=c(t),this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new i({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},e.prototype._padChunk=function(e,t){var n=c(e),i=new Int32Array(this._heap,0,n>>2);return function(e,t){var n=new Uint8Array(e.buffer),i=t%4,r=t-i;switch(i){case 0:n[r+3]=0;case 1:n[r+2]=0;case 2:n[r+1]=0;case 3:n[r+0]=0}for(var o=1+(t>>2);o>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=n/(1<<29)|0,e[15+(2+(t>>2)&-16)]=n<<3}(i,e,t),n},e.prototype._write=function(e,t,n,i){a(e,this._h8,this._h32,t,n,i||0)},e.prototype._coreCall=function(e,t,n,i,r){var o=n;this._write(e,t,n),r&&(o=this._padChunk(n,i)),this._core.hash(o,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,i=this._maxChunkLen;for(n=0;t>n+i;n+=i)this._coreCall(e,n,i,t,!1);return this._coreCall(e,n,t-n,t,!0),l(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return o(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,n=e.byteLength||e.length||e.size||0,i=this._offset%this._maxChunkLen,r=void 0;for(this._offset+=n;t0}),!1)}e.exports=function(e,t){t=t||{};var r={main:n.m},o=t.all?{main:Object.keys(r)}:function(e,t){for(var n={main:[t]},i={main:[]},r={main:{}};c(n);)for(var o=Object.keys(n),s=0;s>2]|0;a=i[t+324>>2]|0;l=i[t+328>>2]|0;u=i[t+332>>2]|0;f=i[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=o;c=a;p=l;d=u;h=f;for(r=0;(r|0)<64;r=r+4|0){g=i[n+r>>2]|0;m=((o<<5|o>>>27)+(a&l|~a&u)|0)+((g+f|0)+1518500249|0)|0;f=u;u=l;l=a<<30|a>>>2;a=o;o=m;i[e+r>>2]=g}for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a&l|~a&u)|0)+((g+f|0)+1518500249|0)|0;f=u;u=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a^l^u)|0)+((g+f|0)+1859775393|0)|0;f=u;u=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a&l|a&u|l&u)|0)+((g+f|0)-1894007588|0)|0;f=u;u=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a^l^u)|0)+((g+f|0)-899497514|0)|0;f=u;u=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}o=o+s|0;a=a+c|0;l=l+p|0;u=u+d|0;f=f+h|0}i[t+320>>2]=o;i[t+324>>2]=a;i[t+328>>2]=l;i[t+332>>2]=u;i[t+336>>2]=f}return{hash:r}}},function(e,t){var n=this,i=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(i=new self.FileReaderSync);var r=function(e,t,n,i,r,o){var s=void 0,a=o%4,c=(r+a)%4,l=r-c;switch(a){case 0:t[o]=e[i+3];case 1:t[o+1-(a<<1)|0]=e[i+2];case 2:t[o+2-(a<<1)|0]=e[i+1];case 3:t[o+3-(a<<1)|0]=e[i]}if(!(r>2|0]=e[i+s]<<24|e[i+s+1]<<16|e[i+s+2]<<8|e[i+s+3];switch(c){case 3:t[o+l+1|0]=e[i+l+2];case 2:t[o+l+2|0]=e[i+l+1];case 1:t[o+l+3|0]=e[i+l]}}};e.exports=function(e,t,o,s,a,c){if("string"==typeof e)return function(e,t,n,i,r,o){var s=void 0,a=o%4,c=(r+a)%4,l=r-c;switch(a){case 0:t[o]=e.charCodeAt(i+3);case 1:t[o+1-(a<<1)|0]=e.charCodeAt(i+2);case 2:t[o+2-(a<<1)|0]=e.charCodeAt(i+1);case 3:t[o+3-(a<<1)|0]=e.charCodeAt(i)}if(!(r>2]=e.charCodeAt(i+s)<<24|e.charCodeAt(i+s+1)<<16|e.charCodeAt(i+s+2)<<8|e.charCodeAt(i+s+3);switch(c){case 3:t[o+l+1|0]=e.charCodeAt(i+l+2);case 2:t[o+l+2|0]=e.charCodeAt(i+l+1);case 1:t[o+l+3|0]=e.charCodeAt(i+l)}}}(e,t,o,s,a,c);if(e instanceof Array)return r(e,t,o,s,a,c);if(n&&n.Buffer&&n.Buffer.isBuffer(e))return r(e,t,o,s,a,c);if(e instanceof ArrayBuffer)return r(new Uint8Array(e),t,o,s,a,c);if(e.buffer instanceof ArrayBuffer)return r(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,o,s,a,c);if(e instanceof Blob)return function(e,t,n,r,o,s){var a=void 0,c=s%4,l=(o+c)%4,p=o-l,u=new Uint8Array(i.readAsArrayBuffer(e.slice(r,r+o)));switch(c){case 0:t[s]=u[3];case 1:t[s+1-(c<<1)|0]=u[2];case 2:t[s+2-(c<<1)|0]=u[1];case 3:t[s+3-(c<<1)|0]=u[0]}if(!(o>2|0]=u[a]<<24|u[a+1]<<16|u[a+2]<<8|u[a+3];switch(l){case 3:t[s+p+1|0]=u[p+2];case 2:t[s+p+2|0]=u[p+1];case 1:t[s+p+3|0]=u[p]}}}(e,t,o,s,a,c);throw new Error("Unsupported data type.")}},function(e,t,n){var i=n(0),r=n(1).toHex,o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._rusha=new i,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function(e){var t=this._rusha.rawEnd().buffer;if(!e)return t;if("hex"===e)return r(t);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new o}}])},"object"==typeof n&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof n?n.Rusha=r():i.Rusha=r()},{}],222:[function(e,t,n){ +t.exports=function(e,t){let n,r,s,o=!0;Array.isArray(e)?(n=[],r=e.length):(s=Object.keys(e),n={},r=s.length);function a(e){function r(){t&&t(e,n),t=null}o?i(r):r()}function c(e,t,i){n[e]=i,(0==--r||t)&&a(t)}r?s?s.forEach((function(t){e[t]((function(e,n){c(t,e,n)}))})):e.forEach((function(e,t){e((function(e,n){c(t,e,n)}))})):a(null);o=!1};const i=e("queue-microtask")},{"queue-microtask":346}],375:[function(e,t,n){var i,r;i="undefined"!=typeof self?self:this,r=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){var i=n(5),r=n(1),s=r.toHex,o=r.ceilHeapSize,a=n(6),c=function(e){for(e+=9;e%64>0;e+=1);return e},u=function(e,t){var n=new Int32Array(e,t+320,5),i=new Int32Array(5),r=new DataView(i.buffer);return r.setInt32(0,n[0],!1),r.setInt32(4,n[1],!1),r.setInt32(8,n[2],!1),r.setInt32(12,n[3],!1),r.setInt32(16,n[4],!1),i},l=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(t=t||65536)%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=c(t),this._heap=new ArrayBuffer(o(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new i({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},e.prototype._padChunk=function(e,t){var n=c(e),i=new Int32Array(this._heap,0,n>>2);return function(e,t){var n=new Uint8Array(e.buffer),i=t%4,r=t-i;switch(i){case 0:n[r+3]=0;case 1:n[r+2]=0;case 2:n[r+1]=0;case 3:n[r+0]=0}for(var s=1+(t>>2);s>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=n/(1<<29)|0,e[15+(2+(t>>2)&-16)]=n<<3}(i,e,t),n},e.prototype._write=function(e,t,n,i){a(e,this._h8,this._h32,t,n,i||0)},e.prototype._coreCall=function(e,t,n,i,r){var s=n;this._write(e,t,n),r&&(s=this._padChunk(n,i)),this._core.hash(s,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,i=this._maxChunkLen;for(n=0;t>n+i;n+=i)this._coreCall(e,n,i,t,!1);return this._coreCall(e,n,t-n,t,!0),u(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return s(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,n=e.byteLength||e.length||e.size||0,i=this._offset%this._maxChunkLen,r=void 0;for(this._offset+=n;t0}),!1)}e.exports=function(e,t){t=t||{};var r={main:n.m},s=t.all?{main:Object.keys(r)}:function(e,t){for(var n={main:[t]},i={main:[]},r={main:{}};c(n);)for(var s=Object.keys(n),o=0;o>2]|0;a=i[t+324>>2]|0;u=i[t+328>>2]|0;d=i[t+332>>2]|0;p=i[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){o=s;c=a;l=u;f=d;h=p;for(r=0;(r|0)<64;r=r+4|0){b=i[n+r>>2]|0;m=((s<<5|s>>>27)+(a&u|~a&d)|0)+((b+p|0)+1518500249|0)|0;p=d;d=u;u=a<<30|a>>>2;a=s;s=m;i[e+r>>2]=b}for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0){b=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((s<<5|s>>>27)+(a&u|~a&d)|0)+((b+p|0)+1518500249|0)|0;p=d;d=u;u=a<<30|a>>>2;a=s;s=m;i[r>>2]=b}for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0){b=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((s<<5|s>>>27)+(a^u^d)|0)+((b+p|0)+1859775393|0)|0;p=d;d=u;u=a<<30|a>>>2;a=s;s=m;i[r>>2]=b}for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0){b=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((s<<5|s>>>27)+(a&u|a&d|u&d)|0)+((b+p|0)-1894007588|0)|0;p=d;d=u;u=a<<30|a>>>2;a=s;s=m;i[r>>2]=b}for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0){b=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((s<<5|s>>>27)+(a^u^d)|0)+((b+p|0)-899497514|0)|0;p=d;d=u;u=a<<30|a>>>2;a=s;s=m;i[r>>2]=b}s=s+o|0;a=a+c|0;u=u+l|0;d=d+f|0;p=p+h|0}i[t+320>>2]=s;i[t+324>>2]=a;i[t+328>>2]=u;i[t+332>>2]=d;i[t+336>>2]=p}return{hash:r}}},function(e,t){var n=this,i=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(i=new self.FileReaderSync);var r=function(e,t,n,i,r,s){var o=void 0,a=s%4,c=(r+a)%4,u=r-c;switch(a){case 0:t[s]=e[i+3];case 1:t[s+1-(a<<1)|0]=e[i+2];case 2:t[s+2-(a<<1)|0]=e[i+1];case 3:t[s+3-(a<<1)|0]=e[i]}if(!(r>2|0]=e[i+o]<<24|e[i+o+1]<<16|e[i+o+2]<<8|e[i+o+3];switch(c){case 3:t[s+u+1|0]=e[i+u+2];case 2:t[s+u+2|0]=e[i+u+1];case 1:t[s+u+3|0]=e[i+u]}}};e.exports=function(e,t,s,o,a,c){if("string"==typeof e)return function(e,t,n,i,r,s){var o=void 0,a=s%4,c=(r+a)%4,u=r-c;switch(a){case 0:t[s]=e.charCodeAt(i+3);case 1:t[s+1-(a<<1)|0]=e.charCodeAt(i+2);case 2:t[s+2-(a<<1)|0]=e.charCodeAt(i+1);case 3:t[s+3-(a<<1)|0]=e.charCodeAt(i)}if(!(r>2]=e.charCodeAt(i+o)<<24|e.charCodeAt(i+o+1)<<16|e.charCodeAt(i+o+2)<<8|e.charCodeAt(i+o+3);switch(c){case 3:t[s+u+1|0]=e.charCodeAt(i+u+2);case 2:t[s+u+2|0]=e.charCodeAt(i+u+1);case 1:t[s+u+3|0]=e.charCodeAt(i+u)}}}(e,t,s,o,a,c);if(e instanceof Array)return r(e,t,s,o,a,c);if(n&&n.Buffer&&n.Buffer.isBuffer(e))return r(e,t,s,o,a,c);if(e instanceof ArrayBuffer)return r(new Uint8Array(e),t,s,o,a,c);if(e.buffer instanceof ArrayBuffer)return r(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,s,o,a,c);if(e instanceof Blob)return function(e,t,n,r,s,o){var a=void 0,c=o%4,u=(s+c)%4,l=s-u,d=new Uint8Array(i.readAsArrayBuffer(e.slice(r,r+s)));switch(c){case 0:t[o]=d[3];case 1:t[o+1-(c<<1)|0]=d[2];case 2:t[o+2-(c<<1)|0]=d[1];case 3:t[o+3-(c<<1)|0]=d[0]}if(!(s>2|0]=d[a]<<24|d[a+1]<<16|d[a+2]<<8|d[a+3];switch(u){case 3:t[o+l+1|0]=d[l+2];case 2:t[o+l+2|0]=d[l+1];case 1:t[o+l+3|0]=d[l]}}}(e,t,s,o,a,c);throw new Error("Unsupported data type.")}},function(e,t,n){var i=function(){function e(e,t){for(var n=0;n */ -var i=e("buffer"),r=i.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=i:(o(i,n),n.Buffer=s),s.prototype=Object.create(r.prototype),o(r,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=r(e);return void 0!==t?"string"==typeof n?i.fill(t,n):i.fill(t):i.fill(0),i},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:55}],223:[function(e,t,n){(function(e){(function(){ +var i=e("buffer"),r=i.Buffer;function s(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=i:(s(i,n),n.Buffer=o),o.prototype=Object.create(r.prototype),s(r,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=r(e);return void 0!==t?"string"==typeof n?i.fill(t,n):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:114}],377:[function(e,t,n){(function(n){(function(){"use strict";var i,r=e("buffer"),s=r.Buffer,o={};for(i in r)r.hasOwnProperty(i)&&"SlowBuffer"!==i&&"Buffer"!==i&&(o[i]=r[i]);var a=o.Buffer={};for(i in s)s.hasOwnProperty(i)&&"allocUnsafe"!==i&&"allocUnsafeSlow"!==i&&(a[i]=s[i]);if(o.Buffer.prototype=s.prototype,a.from&&a.from!==Uint8Array.from||(a.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return s(e,t,n)}),a.alloc||(a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var i=s(e);return t&&0!==t.length?"string"==typeof n?i.fill(t,n):i.fill(t):i.fill(0),i}),!o.kStringMaxLength)try{o.kStringMaxLength=n.binding("buffer").kStringMaxLength}catch(e){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),t.exports=o}).call(this)}).call(this,e("_process"))},{_process:333,buffer:114}],378:[function(e,t,n){var i=e("safe-buffer").Buffer;function r(e,t){this._block=i.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}r.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=i.from(e,t));for(var n=this._block,r=this._blockSize,s=e.length,o=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=8*this._len;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var i=(4294967295&n)>>>0,r=(n-i)/4294967296;this._block.writeUInt32BE(r,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s},r.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=r},{"safe-buffer":376}],379:[function(e,t,n){(n=t.exports=function(e){e=e.toLowerCase();var t=n[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),n.sha1=e("./sha1"),n.sha224=e("./sha224"),n.sha256=e("./sha256"),n.sha384=e("./sha384"),n.sha512=e("./sha512")},{"./sha":380,"./sha1":381,"./sha224":382,"./sha256":383,"./sha384":384,"./sha512":385}],380:[function(e,t,n){var i=e("inherits"),r=e("./hash"),s=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,r.call(this,64,56)}function u(e){return e<<30|e>>>2}function l(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}i(c,r),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(e){for(var t,n=this._w,i=0|this._a,r=0|this._b,s=0|this._c,a=0|this._d,c=0|this._e,d=0;d<16;++d)n[d]=e.readInt32BE(4*d);for(;d<80;++d)n[d]=n[d-3]^n[d-8]^n[d-14]^n[d-16];for(var f=0;f<80;++f){var p=~~(f/20),h=0|((t=i)<<5|t>>>27)+l(p,r,s,a)+c+n[f]+o[p];c=a,a=s,s=u(r),r=i,i=h}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=c},{"./hash":378,inherits:245,"safe-buffer":376}],381:[function(e,t,n){var i=e("inherits"),r=e("./hash"),s=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,r.call(this,64,56)}function u(e){return e<<5|e>>>27}function l(e){return e<<30|e>>>2}function d(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}i(c,r),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(e){for(var t,n=this._w,i=0|this._a,r=0|this._b,s=0|this._c,a=0|this._d,c=0|this._e,f=0;f<16;++f)n[f]=e.readInt32BE(4*f);for(;f<80;++f)n[f]=(t=n[f-3]^n[f-8]^n[f-14]^n[f-16])<<1|t>>>31;for(var p=0;p<80;++p){var h=~~(p/20),m=u(i)+d(h,r,s,a)+c+n[p]+o[h]|0;c=a,a=s,s=l(r),r=i,i=m}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=c},{"./hash":378,inherits:245,"safe-buffer":376}],382:[function(e,t,n){var i=e("inherits"),r=e("./sha256"),s=e("./hash"),o=e("safe-buffer").Buffer,a=new Array(64);function c(){this.init(),this._w=a,s.call(this,64,56)}i(c,r),c.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},c.prototype._hash=function(){var e=o.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=c},{"./hash":378,"./sha256":383,inherits:245,"safe-buffer":376}],383:[function(e,t,n){var i=e("inherits"),r=e("./hash"),s=e("safe-buffer").Buffer,o=[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],a=new Array(64);function c(){this.init(),this._w=a,r.call(this,64,56)}function u(e,t,n){return n^e&(t^n)}function l(e,t,n){return e&t|n&(e|t)}function d(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function f(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function p(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}i(c,r),c.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},c.prototype._update=function(e){for(var t,n=this._w,i=0|this._a,r=0|this._b,s=0|this._c,a=0|this._d,c=0|this._e,h=0|this._f,m=0|this._g,b=0|this._h,g=0;g<16;++g)n[g]=e.readInt32BE(4*g);for(;g<64;++g)n[g]=0|(((t=n[g-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+n[g-7]+p(n[g-15])+n[g-16];for(var v=0;v<64;++v){var y=b+f(c)+u(c,h,m)+o[v]+n[v]|0,_=d(i)+l(i,r,s)|0;b=m,m=h,h=c,c=a+y|0,a=s,s=r,r=i,i=y+_|0}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=h+this._f|0,this._g=m+this._g|0,this._h=b+this._h|0},c.prototype._hash=function(){var e=s.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=c},{"./hash":378,inherits:245,"safe-buffer":376}],384:[function(e,t,n){var i=e("inherits"),r=e("./sha512"),s=e("./hash"),o=e("safe-buffer").Buffer,a=new Array(160);function c(){this.init(),this._w=a,s.call(this,128,112)}i(c,r),c.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},c.prototype._hash=function(){var e=o.allocUnsafe(48);function t(t,n,i){e.writeInt32BE(t,i),e.writeInt32BE(n,i+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),e},t.exports=c},{"./hash":378,"./sha512":385,inherits:245,"safe-buffer":376}],385:[function(e,t,n){var i=e("inherits"),r=e("./hash"),s=e("safe-buffer").Buffer,o=[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],a=new Array(160);function c(){this.init(),this._w=a,r.call(this,128,112)}function u(e,t,n){return n^e&(t^n)}function l(e,t,n){return e&t|n&(e|t)}function d(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function f(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function g(e,t){return e>>>0>>0?1:0}i(c,r),c.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},c.prototype._update=function(e){for(var t=this._w,n=0|this._ah,i=0|this._bh,r=0|this._ch,s=0|this._dh,a=0|this._eh,c=0|this._fh,v=0|this._gh,y=0|this._hh,_=0|this._al,w=0|this._bl,x=0|this._cl,k=0|this._dl,E=0|this._el,S=0|this._fl,M=0|this._gl,A=0|this._hl,I=0;I<32;I+=2)t[I]=e.readInt32BE(4*I),t[I+1]=e.readInt32BE(4*I+4);for(;I<160;I+=2){var j=t[I-30],C=t[I-30+1],T=p(j,C),B=h(C,j),R=m(j=t[I-4],C=t[I-4+1]),L=b(C,j),O=t[I-14],P=t[I-14+1],U=t[I-32],q=t[I-32+1],D=B+P|0,N=T+O+g(D,B)|0;N=(N=N+R+g(D=D+L|0,L)|0)+U+g(D=D+q|0,q)|0,t[I]=N,t[I+1]=D}for(var z=0;z<160;z+=2){N=t[z],D=t[z+1];var H=l(n,i,r),F=l(_,w,x),W=d(n,_),V=d(_,n),K=f(a,E),$=f(E,a),G=o[z],X=o[z+1],Y=u(a,c,v),Z=u(E,S,M),J=A+$|0,Q=y+K+g(J,A)|0;Q=(Q=(Q=Q+Y+g(J=J+Z|0,Z)|0)+G+g(J=J+X|0,X)|0)+N+g(J=J+D|0,D)|0;var ee=V+F|0,te=W+H+g(ee,V)|0;y=v,A=M,v=c,M=S,c=a,S=E,a=s+Q+g(E=k+J|0,k)|0,s=r,k=x,r=i,x=w,i=n,w=_,n=Q+te+g(_=J+ee|0,J)|0}this._al=this._al+_|0,this._bl=this._bl+w|0,this._cl=this._cl+x|0,this._dl=this._dl+k|0,this._el=this._el+E|0,this._fl=this._fl+S|0,this._gl=this._gl+M|0,this._hl=this._hl+A|0,this._ah=this._ah+n+g(this._al,_)|0,this._bh=this._bh+i+g(this._bl,w)|0,this._ch=this._ch+r+g(this._cl,x)|0,this._dh=this._dh+s+g(this._dl,k)|0,this._eh=this._eh+a+g(this._el,E)|0,this._fh=this._fh+c+g(this._fl,S)|0,this._gh=this._gh+v+g(this._gl,M)|0,this._hh=this._hh+y+g(this._hl,A)|0},c.prototype._hash=function(){var e=s.allocUnsafe(64);function t(t,n,i){e.writeInt32BE(t,i),e.writeInt32BE(n,i+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),e},t.exports=c},{"./hash":378,inherits:245,"safe-buffer":376}],386:[function(e,t,n){(function(e){(function(){ /*! simple-concat. MIT License. Feross Aboukhadijeh */ -t.exports=function(t,n){var i=[];t.on("data",(function(e){i.push(e)})),t.once("end",(function(){n&&n(null,e.concat(i)),n=null})),t.once("error",(function(e){n&&n(e),n=null}))}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55}],224:[function(e,t,n){(function(n){(function(){ +t.exports=function(t,n){var i=[];t.on("data",(function(e){i.push(e)})),t.once("end",(function(){n&&n(null,e.concat(i)),n=null})),t.once("error",(function(e){n&&n(e),n=null}))}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114}],387:[function(e,t,n){(function(n){(function(){ /*! simple-get. MIT License. Feross Aboukhadijeh */ -t.exports=u;const i=e("simple-concat"),r=e("decompress-response"),o=e("http"),s=e("https"),a=e("once"),c=e("querystring"),l=e("url"),p=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;function u(e,t){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),t=a(t),e.url){const{hostname:t,port:n,protocol:i,auth:r,path:o}=l.parse(e.url);delete e.url,t||n||i||r?Object.assign(e,{hostname:t,port:n,protocol:i,auth:r,path:o}):e.path=o}const i={"accept-encoding":"gzip, deflate"};let d;e.headers&&Object.keys(e.headers).forEach((t=>i[t.toLowerCase()]=e.headers[t])),e.headers=i,e.body?d=e.json&&!p(e.body)?JSON.stringify(e.body):e.body:e.form&&(d="string"==typeof e.form?e.form:c.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),d&&(e.method||(e.method="POST"),p(d)||(e.headers["content-length"]=n.byteLength(d)),e.json&&!e.form&&(e.headers["content-type"]="application/json")),delete e.body,delete e.form,e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const f=("https:"===e.protocol?s:o).request(e,(n=>{if(!1!==e.followRedirects&&n.statusCode>=300&&n.statusCode<400&&n.headers.location)return e.url=n.headers.location,delete e.headers.host,n.resume(),"POST"===e.method&&[301,302].includes(n.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?t(new Error("too many redirects")):u(e,t);const i="function"==typeof r&&"HEAD"!==e.method;t(null,i?r(n):n)}));return f.on("timeout",(()=>{f.abort(),t(new Error("Request timed out"))})),f.on("error",t),p(d)?d.on("error",t).pipe(f):f.end(d),f}u.concat=(e,t)=>u(e,((n,r)=>{if(n)return t(n);i(r,((n,i)=>{if(n)return t(n);if(e.json)try{i=JSON.parse(i.toString())}catch(n){return t(n,r,i)}t(null,r,i)}))})),["get","post","put","patch","head","delete"].forEach((e=>{u[e]=(t,n)=>("string"==typeof t&&(t={url:t}),u(Object.assign({method:e.toUpperCase()},t),n))}))}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55,"decompress-response":54,http:266,https:115,once:185,querystring:194,"simple-concat":223,url:301}],225:[function(e,t,n){ +t.exports=d;const i=e("simple-concat"),r=e("decompress-response"),s=e("http"),o=e("https"),a=e("once"),c=e("querystring"),u=e("url"),l=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;function d(e,t){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),t=a(t),e.url){const{hostname:t,port:n,protocol:i,auth:r,path:s}=u.parse(e.url);delete e.url,t||n||i||r?Object.assign(e,{hostname:t,port:n,protocol:i,auth:r,path:s}):e.path=s}const i={"accept-encoding":"gzip, deflate"};let f;e.headers&&Object.keys(e.headers).forEach((t=>i[t.toLowerCase()]=e.headers[t])),e.headers=i,e.body?f=e.json&&!l(e.body)?JSON.stringify(e.body):e.body:e.form&&(f="string"==typeof e.form?e.form:c.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),f&&(e.method||(e.method="POST"),l(f)||(e.headers["content-length"]=n.byteLength(f)),e.json&&!e.form&&(e.headers["content-type"]="application/json")),delete e.body,delete e.form,e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const p=("https:"===e.protocol?o:s).request(e,(n=>{if(!1!==e.followRedirects&&n.statusCode>=300&&n.statusCode<400&&n.headers.location)return e.url=n.headers.location,delete e.headers.host,n.resume(),"POST"===e.method&&[301,302].includes(n.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?t(new Error("too many redirects")):d(e,t);const i="function"==typeof r&&"HEAD"!==e.method;t(null,i?r(n):n)}));return p.on("timeout",(()=>{p.abort(),t(new Error("Request timed out"))})),p.on("error",t),l(f)?f.on("error",t).pipe(p):p.end(f),p}d.concat=(e,t)=>d(e,((n,r)=>{if(n)return t(n);i(r,((n,i)=>{if(n)return t(n);if(e.json)try{i=JSON.parse(i.toString())}catch(n){return t(n,r,i)}t(null,r,i)}))})),["get","post","put","patch","head","delete"].forEach((e=>{d[e]=(t,n)=>("string"==typeof t&&(t={url:t}),d(Object.assign({method:e.toUpperCase()},t),n))}))}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114,"decompress-response":71,http:444,https:242,once:318,querystring:345,"simple-concat":386,url:479}],388:[function(e,t,n){ /*! simple-peer. MIT License. Feross Aboukhadijeh */ -const i=e("debug")("simple-peer"),r=e("get-browser-rtc"),o=e("randombytes"),s=e("readable-stream"),a=e("queue-microtask"),c=e("err-code"),{Buffer:l}=e("buffer"),p=65536;function u(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}class d extends s.Duplex{constructor(e){if(super(e=Object.assign({allowHalfOpen:!1},e)),this._id=o(4).toString("hex").slice(0,7),this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||o(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||d.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},d.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(e=>e),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=void 0===e.trickle||e.trickle,this.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:r(),!this._wrtc)throw"undefined"==typeof window?c(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT"):c(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(e){return void this.destroy(c(e,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=e=>{this._onIceCandidate(e)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch((e=>{this.destroy(c(e,"ERR_PC_PEER_IDENTITY"))})),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=e=>{this._setupData(e)},this.streams&&this.streams.forEach((e=>{this.addStream(e)})),this._pc.ontrack=e=>{this._onTrack(e)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then((()=>{this.destroyed||(this._pendingCandidates.forEach((e=>{this._addIceCandidate(e)})),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())})).catch((e=>{this.destroy(c(e,"ERR_SET_REMOTE_DESCRIPTION"))})),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch((e=>{var n;!t.address||t.address.endsWith(".local")?(n="Ignoring unsupported ICE candidate.",console.warn(n)):this.destroy(c(e,"ERR_ADD_ICE_CANDIDATE"))}))}send(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(e){this.destroy(c(e,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach((t=>{this.addTrack(t,e)}))}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const n=this._senderMap.get(e)||new Map;let i=n.get(t);if(i)throw i.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED");i=this._pc.addTrack(e,t),n.set(t,i),this._senderMap.set(e,n),this._needsNegotiation()}replaceTrack(e,t,n){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const i=this._senderMap.get(e),r=i?i.get(n):null;if(!r)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),null!=r.replaceTrack?r.replaceTrack(t):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const n=this._senderMap.get(e),i=n?n.get(t):null;if(!i)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(i):this.destroy(c(e,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach((t=>{this.removeTrack(t,e)}))}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,a((()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1})))}negotiate(){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout((()=>{this._createOffer()}),0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this._destroy(e,(()=>{}))}_destroy(e,t){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),a((()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close"),t()})))}_setupData(e){if(!e.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=p),this.channelName=this._channel.label,this._channel.onmessage=e=>{this._onChannelMessage(e)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=e=>{const t=e.error instanceof Error?e.error:new Error(`Datachannel error: ${e.message} ${e.filename}:${e.lineno}:${e.colno}`);this.destroy(c(t,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval((()=>{this._channel&&"closing"===this._channel.readyState?(t&&this._onChannelClose(),t=!0):t=!1}),5e3)}_read(){}_write(e,t,n){if(this.destroyed)return n(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(e)}catch(e){return this.destroy(c(e,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>p?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_onFinish(){if(this.destroyed)return;const e=()=>{setTimeout((()=>this.destroy()),1e3)};this._connected?e():this.once("connect",e)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout((()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))}),this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then((e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=u(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp})};this._pc.setLocalDescription(e).then((()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))})).catch((e=>{this.destroy(c(e,"ERR_SET_LOCAL_DESCRIPTION"))}))})).catch((e=>{this.destroy(c(e,"ERR_CREATE_OFFER"))}))}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach((e=>{e.mid||!e.sender.track||e.requested||(e.requested=!0,this.addTransceiver(e.sender.track.kind))}))}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then((e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=u(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp}),this.initiator||this._requestMissingTransceivers()};this._pc.setLocalDescription(e).then((()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))})).catch((e=>{this.destroy(c(e,"ERR_SET_LOCAL_DESCRIPTION"))}))})).catch((e=>{this.destroy(c(e,"ERR_CREATE_ANSWER"))}))}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=e=>("[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach((t=>{Object.assign(e,t)})),e);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then((n=>{const i=[];n.forEach((e=>{i.push(t(e))})),e(null,i)}),(t=>e(t))):this._pc.getStats.length>0?this._pc.getStats((n=>{if(this.destroyed)return;const i=[];n.result().forEach((e=>{const n={};e.names().forEach((t=>{n[t]=e.stat(t)})),n.id=e.id,n.type=e.type,n.timestamp=e.timestamp,i.push(t(n))})),e(null,i)}),(t=>e(t))):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats(((t,n)=>{if(this.destroyed)return;t&&(n=[]);const i={},r={},o={};let s=!1;n.forEach((e=>{"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(r[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(o[e.id]=e)}));const a=e=>{s=!0;let t=r[e.localCandidateId];t&&(t.ip||t.address)?(this.localAddress=t.ip||t.address,this.localPort=Number(t.port)):t&&t.ipAddress?(this.localAddress=t.ipAddress,this.localPort=Number(t.portNumber)):"string"==typeof e.googLocalAddress&&(t=e.googLocalAddress.split(":"),this.localAddress=t[0],this.localPort=Number(t[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let n=i[e.remoteCandidateId];n&&(n.ip||n.address)?(this.remoteAddress=n.ip||n.address,this.remotePort=Number(n.port)):n&&n.ipAddress?(this.remoteAddress=n.ipAddress,this.remotePort=Number(n.portNumber)):"string"==typeof e.googRemoteAddress&&(n=e.googRemoteAddress.split(":"),this.remoteAddress=n[0],this.remotePort=Number(n[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(n.forEach((e=>{"transport"===e.type&&e.selectedCandidatePairId&&a(o[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&a(e)})),s||Object.keys(o).length&&!Object.keys(r).length){if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(t){return this.destroy(c(t,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const e=this._cb;this._cb=null,e(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval((()=>this._onInterval()),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}else setTimeout(e,100)}))};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>p||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach((e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0})),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=l.from(t)),this.push(t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach((t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),this._remoteStreams.some((e=>e.id===t.id))||(this._remoteStreams.push(t),a((()=>{this._debug("on stream"),this.emit("stream",t)})))}))}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}d.WEBRTC_SUPPORT=!!r(),d.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},d.channelConfig={},t.exports=d},{buffer:55,debug:226,"err-code":96,"get-browser-rtc":114,"queue-microtask":195,randombytes:197,"readable-stream":243}],226:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":227,_process:189,dup:12}],227:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:228}],228:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],229:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],230:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":232,"./_stream_writable":234,_process:189,dup:16,inherits:118}],231:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":233,dup:17,inherits:118}],232:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":229,"./_stream_duplex":230,"./internal/streams/async_iterator":235,"./internal/streams/buffer_list":236,"./internal/streams/destroy":237,"./internal/streams/from":239,"./internal/streams/state":241,"./internal/streams/stream":242,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],233:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":229,"./_stream_duplex":230,dup:19,inherits:118}],234:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":229,"./_stream_duplex":230,"./internal/streams/destroy":237,"./internal/streams/state":241,"./internal/streams/stream":242,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],235:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":238,_process:189,dup:21}],236:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],237:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],238:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":229,dup:24}],239:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],240:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":229,"./end-of-stream":238,dup:26}],241:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":229,dup:27}],242:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],243:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":230,"./lib/_stream_passthrough.js":231,"./lib/_stream_readable.js":232,"./lib/_stream_transform.js":233,"./lib/_stream_writable.js":234,"./lib/internal/streams/end-of-stream.js":238,"./lib/internal/streams/pipeline.js":240,dup:29}],244:[function(e,t,n){const i=e("rusha"),r=e("./rusha-worker-sha1"),o=new i,s="undefined"!=typeof window?window:self,a=s.crypto||s.msCrypto||{};let c=a.subtle||a.webkitSubtle;function l(e){return o.digest(e)}try{c.digest({name:"sha-1"},new Uint8Array).catch((function(){c=!1}))}catch(e){c=!1}t.exports=function(e,t){c?("string"==typeof e&&(e=function(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i>>4).toString(16)),n.push((15&t).toString(16))}return n.join("")}(new Uint8Array(e)))}),(function(){t(l(e))}))):"undefined"!=typeof window?r(e,(function(n,i){t(n?l(e):i)})):queueMicrotask((()=>t(l(e))))},t.exports.sync=l},{"./rusha-worker-sha1":245,rusha:221}],245:[function(e,t,n){const i=e("rusha");let r,o,s;t.exports=function(e,t){r||(r=i.createWorker(),o=1,s={},r.onmessage=function(e){const t=e.data.id,n=s[t];delete s[t],null!=e.data.error?n(new Error("Rusha worker error: "+e.data.error)):n(null,e.data.hash)}),s[o]=t,r.postMessage({id:o,data:e}),o+=1}},{rusha:221}],246:[function(e,t,n){(function(n){(function(){ +const i=e("debug")("simple-peer"),r=e("get-browser-rtc"),s=e("randombytes"),o=e("readable-stream"),a=e("queue-microtask"),c=e("err-code"),{Buffer:u}=e("buffer"),l=65536;function d(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}class f extends o.Duplex{constructor(e){if(super(e=Object.assign({allowHalfOpen:!1},e)),this._id=s(4).toString("hex").slice(0,7),this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||s(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||f.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},f.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(e=>e),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=void 0===e.trickle||e.trickle,this.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:r(),!this._wrtc)throw"undefined"==typeof window?c(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT"):c(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(e){return void this.destroy(c(e,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=e=>{this._onIceCandidate(e)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch((e=>{this.destroy(c(e,"ERR_PC_PEER_IDENTITY"))})),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=e=>{this._setupData(e)},this.streams&&this.streams.forEach((e=>{this.addStream(e)})),this._pc.ontrack=e=>{this._onTrack(e)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then((()=>{this.destroyed||(this._pendingCandidates.forEach((e=>{this._addIceCandidate(e)})),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())})).catch((e=>{this.destroy(c(e,"ERR_SET_REMOTE_DESCRIPTION"))})),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch((e=>{var n;!t.address||t.address.endsWith(".local")?(n="Ignoring unsupported ICE candidate.",console.warn(n)):this.destroy(c(e,"ERR_ADD_ICE_CANDIDATE"))}))}send(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(e){this.destroy(c(e,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach((t=>{this.addTrack(t,e)}))}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const n=this._senderMap.get(e)||new Map;let i=n.get(t);if(i)throw i.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED");i=this._pc.addTrack(e,t),n.set(t,i),this._senderMap.set(e,n),this._needsNegotiation()}replaceTrack(e,t,n){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const i=this._senderMap.get(e),r=i?i.get(n):null;if(!r)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),null!=r.replaceTrack?r.replaceTrack(t):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const n=this._senderMap.get(e),i=n?n.get(t):null;if(!i)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(i):this.destroy(c(e,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach((t=>{this.removeTrack(t,e)}))}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,a((()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1})))}negotiate(){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout((()=>{this._createOffer()}),0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this._destroy(e,(()=>{}))}_destroy(e,t){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),a((()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close"),t()})))}_setupData(e){if(!e.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=l),this.channelName=this._channel.label,this._channel.onmessage=e=>{this._onChannelMessage(e)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=e=>{const t=e.error instanceof Error?e.error:new Error(`Datachannel error: ${e.message} ${e.filename}:${e.lineno}:${e.colno}`);this.destroy(c(t,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval((()=>{this._channel&&"closing"===this._channel.readyState?(t&&this._onChannelClose(),t=!0):t=!1}),5e3)}_read(){}_write(e,t,n){if(this.destroyed)return n(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(e)}catch(e){return this.destroy(c(e,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>l?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_onFinish(){if(this.destroyed)return;const e=()=>{setTimeout((()=>this.destroy()),1e3)};this._connected?e():this.once("connect",e)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout((()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))}),this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then((e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=d(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp})};this._pc.setLocalDescription(e).then((()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))})).catch((e=>{this.destroy(c(e,"ERR_SET_LOCAL_DESCRIPTION"))}))})).catch((e=>{this.destroy(c(e,"ERR_CREATE_OFFER"))}))}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach((e=>{e.mid||!e.sender.track||e.requested||(e.requested=!0,this.addTransceiver(e.sender.track.kind))}))}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then((e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=d(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp}),this.initiator||this._requestMissingTransceivers()};this._pc.setLocalDescription(e).then((()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))})).catch((e=>{this.destroy(c(e,"ERR_SET_LOCAL_DESCRIPTION"))}))})).catch((e=>{this.destroy(c(e,"ERR_CREATE_ANSWER"))}))}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=e=>("[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach((t=>{Object.assign(e,t)})),e);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then((n=>{const i=[];n.forEach((e=>{i.push(t(e))})),e(null,i)}),(t=>e(t))):this._pc.getStats.length>0?this._pc.getStats((n=>{if(this.destroyed)return;const i=[];n.result().forEach((e=>{const n={};e.names().forEach((t=>{n[t]=e.stat(t)})),n.id=e.id,n.type=e.type,n.timestamp=e.timestamp,i.push(t(n))})),e(null,i)}),(t=>e(t))):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats(((t,n)=>{if(this.destroyed)return;t&&(n=[]);const i={},r={},s={};let o=!1;n.forEach((e=>{"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(r[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(s[e.id]=e)}));const a=e=>{o=!0;let t=r[e.localCandidateId];t&&(t.ip||t.address)?(this.localAddress=t.ip||t.address,this.localPort=Number(t.port)):t&&t.ipAddress?(this.localAddress=t.ipAddress,this.localPort=Number(t.portNumber)):"string"==typeof e.googLocalAddress&&(t=e.googLocalAddress.split(":"),this.localAddress=t[0],this.localPort=Number(t[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let n=i[e.remoteCandidateId];n&&(n.ip||n.address)?(this.remoteAddress=n.ip||n.address,this.remotePort=Number(n.port)):n&&n.ipAddress?(this.remoteAddress=n.ipAddress,this.remotePort=Number(n.portNumber)):"string"==typeof e.googRemoteAddress&&(n=e.googRemoteAddress.split(":"),this.remoteAddress=n[0],this.remotePort=Number(n[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(n.forEach((e=>{"transport"===e.type&&e.selectedCandidatePairId&&a(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&a(e)})),o||Object.keys(s).length&&!Object.keys(r).length){if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(t){return this.destroy(c(t,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const e=this._cb;this._cb=null,e(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval((()=>this._onInterval()),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}else setTimeout(e,100)}))};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>l||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach((e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0})),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=u.from(t)),this.push(t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach((t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),this._remoteStreams.some((e=>e.id===t.id))||(this._remoteStreams.push(t),a((()=>{this._debug("on stream"),this.emit("stream",t)})))}))}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}f.WEBRTC_SUPPORT=!!r(),f.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},f.channelConfig={},t.exports=f},{buffer:114,debug:389,"err-code":193,"get-browser-rtc":212,"queue-microtask":346,randombytes:348,"readable-stream":406}],389:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":390,_process:333,dup:27}],390:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:391}],391:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],392:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],393:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":395,"./_stream_writable":397,_process:333,dup:31,inherits:245}],394:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":396,dup:32,inherits:245}],395:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":392,"./_stream_duplex":393,"./internal/streams/async_iterator":398,"./internal/streams/buffer_list":399,"./internal/streams/destroy":400,"./internal/streams/from":402,"./internal/streams/state":404,"./internal/streams/stream":405,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],396:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":392,"./_stream_duplex":393,dup:34,inherits:245}],397:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":392,"./_stream_duplex":393,"./internal/streams/destroy":400,"./internal/streams/state":404,"./internal/streams/stream":405,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],398:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":401,_process:333,dup:36}],399:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],400:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],401:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":392,dup:39}],402:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],403:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":392,"./end-of-stream":401,dup:41}],404:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":392,dup:42}],405:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],406:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":393,"./lib/_stream_passthrough.js":394,"./lib/_stream_readable.js":395,"./lib/_stream_transform.js":396,"./lib/_stream_writable.js":397,"./lib/internal/streams/end-of-stream.js":401,"./lib/internal/streams/pipeline.js":403,dup:44}],407:[function(e,t,n){const i=e("rusha"),r=e("./rusha-worker-sha1"),s=new i,o="undefined"!=typeof window?window:self,a=o.crypto||o.msCrypto||{};let c=a.subtle||a.webkitSubtle;function u(e){return s.digest(e)}try{c.digest({name:"sha-1"},new Uint8Array).catch((function(){c=!1}))}catch(e){c=!1}t.exports=function(e,t){c?("string"==typeof e&&(e=function(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i>>4).toString(16)),n.push((15&t).toString(16))}return n.join("")}(new Uint8Array(e)))}),(function(){t(u(e))}))):"undefined"!=typeof window?r(e,(function(n,i){t(n?u(e):i)})):queueMicrotask((()=>t(u(e))))},t.exports.sync=u},{"./rusha-worker-sha1":408,rusha:375}],408:[function(e,t,n){const i=e("rusha");let r,s,o;t.exports=function(e,t){r||(r=i.createWorker(),s=1,o={},r.onmessage=function(e){const t=e.data.id,n=o[t];delete o[t],null!=e.data.error?n(new Error("Rusha worker error: "+e.data.error)):n(null,e.data.hash)}),o[s]=t,r.postMessage({id:s,data:e}),s+=1}},{rusha:375}],409:[function(e,t,n){(function(n){(function(){ /*! simple-websocket. MIT License. Feross Aboukhadijeh */ -const i=e("debug")("simple-websocket"),r=e("randombytes"),o=e("readable-stream"),s=e("queue-microtask"),a=e("ws"),c="function"!=typeof a?WebSocket:a;class l extends o.Duplex{constructor(e={}){if("string"==typeof e&&(e={url:e}),super(e=Object.assign({allowHalfOpen:!1},e)),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=r(4).toString("hex").slice(0,7),this._debug("new websocket: %o",e),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,e.socket)this.url=e.socket.url,this._ws=e.socket,this.connected=e.socket.readyState===c.OPEN;else{this.url=e.url;try{this._ws="function"==typeof a?new c(e.url,null,{...e,encoding:void 0}):new c(e.url)}catch(e){return void s((()=>this.destroy(e)))}}this._ws.binaryType="arraybuffer",e.socket&&this.connected?s((()=>this._handleOpen())):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=e=>this._handleMessage(e),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=e=>this._handleError(e),this._handleFinishBound=()=>this._handleFinish(),this.once("finish",this._handleFinishBound)}send(e){this._ws.send(e)}destroy(e){this._destroy(e,(()=>{}))}_destroy(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._handleFinishBound&&this.removeListener("finish",this._handleFinishBound),this._handleFinishBound=null,this._ws){const t=this._ws,n=()=>{t.onclose=null};if(t.readyState===c.CLOSED)n();else try{t.onclose=n,t.close()}catch(e){n()}t.onopen=null,t.onmessage=null,t.onerror=()=>{}}this._ws=null,e&&this.emit("error",e),this.emit("close"),t()}}_read(){}_write(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof a&&this._ws.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_handleOpen(){if(!this.connected&&!this.destroyed){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(e)}this._chunk=null,this._debug('sent chunk from "write before connect"');const e=this._cb;this._cb=null,e(null)}"function"!=typeof a&&(this._interval=setInterval((()=>this._onInterval()),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_handleMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=n.from(t)),this.push(t)}_handleClose(){this.destroyed||(this._debug("on close"),this.destroy())}_handleError(e){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(this.destroyed)return;const e=()=>{setTimeout((()=>this.destroy()),1e3)};this.connected?e():this.once("connect",e)}_onInterval(){if(!this._cb||!this._ws||this._ws.bufferedAmount>65536)return;this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}l.WEBSOCKET_SUPPORT=!!c,t.exports=l}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55,debug:247,"queue-microtask":195,randombytes:197,"readable-stream":264,ws:54}],247:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":248,_process:189,dup:12}],248:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:249}],249:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],250:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],251:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":253,"./_stream_writable":255,_process:189,dup:16,inherits:118}],252:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":254,dup:17,inherits:118}],253:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":250,"./_stream_duplex":251,"./internal/streams/async_iterator":256,"./internal/streams/buffer_list":257,"./internal/streams/destroy":258,"./internal/streams/from":260,"./internal/streams/state":262,"./internal/streams/stream":263,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],254:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":250,"./_stream_duplex":251,dup:19,inherits:118}],255:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":250,"./_stream_duplex":251,"./internal/streams/destroy":258,"./internal/streams/state":262,"./internal/streams/stream":263,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],256:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":259,_process:189,dup:21}],257:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],258:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],259:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":250,dup:24}],260:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],261:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":250,"./end-of-stream":259,dup:26}],262:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":250,dup:27}],263:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],264:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":251,"./lib/_stream_passthrough.js":252,"./lib/_stream_readable.js":253,"./lib/_stream_transform.js":254,"./lib/_stream_writable.js":255,"./lib/internal/streams/end-of-stream.js":259,"./lib/internal/streams/pipeline.js":261,dup:29}],265:[function(e,t,n){var i,r=1,o=65535,s=function(){r=r+1&o};t.exports=function(e){i||(i=setInterval(s,250)).unref&&i.unref();var t=4*(e||5),n=[0],a=1,c=r-1&o;return function(e){var i=r-c&o;for(i>t&&(i=t),c=r;i--;)a===t&&(a=0),n[a]=n[0===a?t-1:a-1],a++;e&&(n[a-1]+=e);var s=n[a-1],l=n.lengtht._pos){var s=o.substr(t._pos);if("x-user-defined"===t._charset){for(var a=r.alloc(s.length),l=0;lt._pos&&(t.push(r.from(new Uint8Array(p.result.slice(t._pos)))),t._pos=p.result.byteLength)},p.onload=function(){e(!0),t.push(null)},p.readAsArrayBuffer(o)}t._xhr.readyState===c.DONE&&"ms-stream"!==t._mode&&(e(!0),t.push(null))}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":267,_process:189,buffer:55,inherits:118,"readable-stream":284}],270:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],271:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":273,"./_stream_writable":275,_process:189,dup:16,inherits:118}],272:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":274,dup:17,inherits:118}],273:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":270,"./_stream_duplex":271,"./internal/streams/async_iterator":276,"./internal/streams/buffer_list":277,"./internal/streams/destroy":278,"./internal/streams/from":280,"./internal/streams/state":282,"./internal/streams/stream":283,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],274:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":270,"./_stream_duplex":271,dup:19,inherits:118}],275:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":270,"./_stream_duplex":271,"./internal/streams/destroy":278,"./internal/streams/state":282,"./internal/streams/stream":283,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],276:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":279,_process:189,dup:21}],277:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],278:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],279:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":270,dup:24}],280:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],281:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":270,"./end-of-stream":279,dup:26}],282:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":270,dup:27}],283:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],284:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":271,"./lib/_stream_passthrough.js":272,"./lib/_stream_readable.js":273,"./lib/_stream_transform.js":274,"./lib/_stream_writable.js":275,"./lib/internal/streams/end-of-stream.js":279,"./lib/internal/streams/pipeline.js":281,dup:29}],285:[function(e,t,n){ +const i=e("debug")("simple-websocket"),r=e("randombytes"),s=e("readable-stream"),o=e("queue-microtask"),a=e("ws"),c="function"!=typeof a?WebSocket:a;class u extends s.Duplex{constructor(e={}){if("string"==typeof e&&(e={url:e}),super(e=Object.assign({allowHalfOpen:!1},e)),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=r(4).toString("hex").slice(0,7),this._debug("new websocket: %o",e),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,e.socket)this.url=e.socket.url,this._ws=e.socket,this.connected=e.socket.readyState===c.OPEN;else{this.url=e.url;try{this._ws="function"==typeof a?new c(e.url,null,{...e,encoding:void 0}):new c(e.url)}catch(e){return void o((()=>this.destroy(e)))}}this._ws.binaryType="arraybuffer",e.socket&&this.connected?o((()=>this._handleOpen())):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=e=>this._handleMessage(e),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=e=>this._handleError(e),this._handleFinishBound=()=>this._handleFinish(),this.once("finish",this._handleFinishBound)}send(e){this._ws.send(e)}destroy(e){this._destroy(e,(()=>{}))}_destroy(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._handleFinishBound&&this.removeListener("finish",this._handleFinishBound),this._handleFinishBound=null,this._ws){const t=this._ws,n=()=>{t.onclose=null};if(t.readyState===c.CLOSED)n();else try{t.onclose=n,t.close()}catch(e){n()}t.onopen=null,t.onmessage=null,t.onerror=()=>{}}this._ws=null,e&&this.emit("error",e),this.emit("close"),t()}}_read(){}_write(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof a&&this._ws.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_handleOpen(){if(!this.connected&&!this.destroyed){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(e)}this._chunk=null,this._debug('sent chunk from "write before connect"');const e=this._cb;this._cb=null,e(null)}"function"!=typeof a&&(this._interval=setInterval((()=>this._onInterval()),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_handleMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=n.from(t)),this.push(t)}_handleClose(){this.destroyed||(this._debug("on close"),this.destroy())}_handleError(e){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(this.destroyed)return;const e=()=>{setTimeout((()=>this.destroy()),1e3)};this.connected?e():this.once("connect",e)}_onInterval(){if(!this._cb||!this._ws||this._ws.bufferedAmount>65536)return;this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}u.WEBSOCKET_SUPPORT=!!c,t.exports=u}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114,debug:410,"queue-microtask":346,randombytes:348,"readable-stream":427,ws:71}],410:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":411,_process:333,dup:27}],411:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:412}],412:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],413:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],414:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":416,"./_stream_writable":418,_process:333,dup:31,inherits:245}],415:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":417,dup:32,inherits:245}],416:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":413,"./_stream_duplex":414,"./internal/streams/async_iterator":419,"./internal/streams/buffer_list":420,"./internal/streams/destroy":421,"./internal/streams/from":423,"./internal/streams/state":425,"./internal/streams/stream":426,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],417:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":413,"./_stream_duplex":414,dup:34,inherits:245}],418:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":413,"./_stream_duplex":414,"./internal/streams/destroy":421,"./internal/streams/state":425,"./internal/streams/stream":426,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],419:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":422,_process:333,dup:36}],420:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],421:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],422:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":413,dup:39}],423:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],424:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":413,"./end-of-stream":422,dup:41}],425:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":413,dup:42}],426:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],427:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":414,"./lib/_stream_passthrough.js":415,"./lib/_stream_readable.js":416,"./lib/_stream_transform.js":417,"./lib/_stream_writable.js":418,"./lib/internal/streams/end-of-stream.js":422,"./lib/internal/streams/pipeline.js":424,dup:44}],428:[function(e,t,n){var i,r=1,s=65535,o=function(){r=r+1&s};t.exports=function(e){i||(i=setInterval(o,250)).unref&&i.unref();var t=4*(e||5),n=[0],a=1,c=r-1&s;return function(e){var i=r-c&s;for(i>t&&(i=t),c=r;i--;)a===t&&(a=0),n[a]=n[0===a?t-1:a-1],a++;e&&(n[a-1]+=e);var o=n[a-1],u=n.lengtht._pos){var o=s.substr(t._pos);if("x-user-defined"===t._charset){for(var a=r.alloc(o.length),u=0;ut._pos&&(t.push(r.from(new Uint8Array(l.result.slice(t._pos)))),t._pos=l.result.byteLength)},l.onload=function(){e(!0),t.push(null)},l.readAsArrayBuffer(s)}t._xhr.readyState===c.DONE&&"ms-stream"!==t._mode&&(e(!0),t.push(null))}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":445,_process:333,buffer:114,inherits:245,"readable-stream":462}],448:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],449:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":451,"./_stream_writable":453,_process:333,dup:31,inherits:245}],450:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":452,dup:32,inherits:245}],451:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":448,"./_stream_duplex":449,"./internal/streams/async_iterator":454,"./internal/streams/buffer_list":455,"./internal/streams/destroy":456,"./internal/streams/from":458,"./internal/streams/state":460,"./internal/streams/stream":461,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],452:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":448,"./_stream_duplex":449,dup:34,inherits:245}],453:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":448,"./_stream_duplex":449,"./internal/streams/destroy":456,"./internal/streams/state":460,"./internal/streams/stream":461,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],454:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":457,_process:333,dup:36}],455:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],456:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],457:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":448,dup:39}],458:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],459:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":448,"./end-of-stream":457,dup:41}],460:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":448,dup:42}],461:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],462:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":449,"./lib/_stream_passthrough.js":450,"./lib/_stream_readable.js":451,"./lib/_stream_transform.js":452,"./lib/_stream_writable.js":453,"./lib/internal/streams/end-of-stream.js":457,"./lib/internal/streams/pipeline.js":459,dup:44}],463:[function(e,t,n){ /*! stream-to-blob-url. MIT License. Feross Aboukhadijeh */ -t.exports=async function(e,t){const n=await i(e,t);return URL.createObjectURL(n)};const i=e("stream-to-blob")},{"stream-to-blob":286}],286:[function(e,t,n){ +t.exports=async function(e,t){const n=await i(e,t);return URL.createObjectURL(n)};const i=e("stream-to-blob")},{"stream-to-blob":464}],464:[function(e,t,n){ /*! stream-to-blob. MIT License. Feross Aboukhadijeh */ -t.exports=function(e,t){if(null!=t&&"string"!=typeof t)throw new Error("Invalid mimetype, expected string.");return new Promise(((n,i)=>{const r=[];e.on("data",(e=>r.push(e))).once("end",(()=>{const e=null!=t?new Blob(r,{type:t}):new Blob(r);n(e)})).once("error",i)}))}},{}],287:[function(e,t,n){(function(n){(function(){ +t.exports=function(e,t){if(null!=t&&"string"!=typeof t)throw new Error("Invalid mimetype, expected string.");return new Promise(((n,i)=>{const r=[];e.on("data",(e=>r.push(e))).once("end",(()=>{const e=null!=t?new Blob(r,{type:t}):new Blob(r);n(e)})).once("error",i)}))}},{}],465:[function(e,t,n){(function(n){(function(){ /*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh */ -var i=e("once");t.exports=function(e,t,r){r=i(r);var o=n.alloc(t),s=0;e.on("data",(function(e){e.copy(o,s),s+=e.length})).on("end",(function(){r(null,o)})).on("error",r)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55,once:185}],288:[function(e,t,n){"use strict";var i=e("safe-buffer").Buffer,r=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===r||!r(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=p,this.end=u,t=3;break;default:return this.write=d,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function p(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}n.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return r>0&&(e.lastNeed=r-1),r;if(--i=0)return r>0&&(e.lastNeed=r-2),r;if(--i=0)return r>0&&(2===r?r=0:e.lastNeed=r-3),r;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":222}],289:[function(e,t,n){var i=e("./thirty-two");n.encode=i.encode,n.decode=i.decode},{"./thirty-two":290}],290:[function(e,t,n){(function(e){(function(){"use strict";var t=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var n,i,r=0,o=0,s=0,a=0,c=new e(8*(n=t,i=Math.floor(n.length/5),n.length%5==0?i:i+1));r3?(a=(a=l&255>>s)<<(s=(s+5)%8)|(r+1>8-s,r++):(a=l>>8-(s+5)&31,0===(s=(s+5)%8)&&r++),c[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(a),o++}for(r=o;r>>(r=(r+5)%8),a[s]=i,s++,i=255&o<<8-r)}return a.slice(0,s)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:55}],291:[function(e,t,n){(function(t){(function(){ +var i=e("once");t.exports=function(e,t,r){r=i(r);var s=n.alloc(t),o=0;e.on("data",(function(e){e.copy(s,o),o+=e.length})).on("end",(function(){r(null,s)})).on("error",r)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114,once:318}],466:[function(e,t,n){"use strict";var i=e("safe-buffer").Buffer,r=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===r||!r(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=d,t=3;break;default:return this.write=f,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function l(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}n.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return r>0&&(e.lastNeed=r-1),r;if(--i=0)return r>0&&(e.lastNeed=r-2),r;if(--i=0)return r>0&&(2===r?r=0:e.lastNeed=r-3),r;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":376}],467:[function(e,t,n){var i=e("./thirty-two");n.encode=i.encode,n.decode=i.decode},{"./thirty-two":468}],468:[function(e,t,n){(function(e){(function(){"use strict";var t=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var n,i,r=0,s=0,o=0,a=0,c=new e(8*(n=t,i=Math.floor(n.length/5),n.length%5==0?i:i+1));r3?(a=(a=u&255>>o)<<(o=(o+5)%8)|(r+1>8-o,r++):(a=u>>8-(o+5)&31,0===(o=(o+5)%8)&&r++),c[s]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(a),s++}for(r=s;r>>(r=(r+5)%8),a[o]=i,o++,i=255&s<<8-r)}return a.slice(0,o)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:114}],469:[function(e,t,n){(function(t){(function(){ /**! * tippy.js v6.3.1 * (c) 2017-2021 atomiks * MIT License */ -"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=e("@popperjs/core"),r="tippy-content",o="tippy-backdrop",s="tippy-arrow",a="tippy-svg-arrow",c={passive:!0,capture:!0};function l(e,t,n){if(Array.isArray(e)){var i=e[t];return null==i?Array.isArray(n)?n[t]:n:i}return e}function p(e,t){var n={}.toString.call(e);return 0===n.indexOf("[object")&&n.indexOf(t+"]")>-1}function u(e,t){return"function"==typeof e?e.apply(void 0,t):e}function d(e,t){return 0===t?e:function(i){clearTimeout(n),n=setTimeout((function(){e(i)}),t)};var n}function f(e,t){var n=Object.assign({},e);return t.forEach((function(e){delete n[e]})),n}function h(e){return[].concat(e)}function m(e,t){-1===e.indexOf(t)&&e.push(t)}function g(e){return e.split("-")[0]}function v(e){return[].slice.call(e)}function b(){return document.createElement("div")}function x(e){return["Element","Fragment"].some((function(t){return p(e,t)}))}function y(e){return p(e,"MouseEvent")}function _(e){return!(!e||!e._tippy||e._tippy.reference!==e)}function w(e){return x(e)?[e]:function(e){return p(e,"NodeList")}(e)?v(e):Array.isArray(e)?e:v(document.querySelectorAll(e))}function k(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function E(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function S(e){var t,n=h(e)[0];return(null==n||null==(t=n.ownerDocument)?void 0:t.body)?n.ownerDocument:document}function C(e,t,n){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[i](t,n)}))}var T={isTouch:!1},j=0;function A(){T.isTouch||(T.isTouch=!0,window.performance&&document.addEventListener("mousemove",L))}function L(){var e=performance.now();e-j<20&&(T.isTouch=!1,document.removeEventListener("mousemove",L)),j=e}function I(){var e=document.activeElement;if(_(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}var R,O="undefined"!=typeof window&&"undefined"!=typeof document?navigator.userAgent:"",B=/MSIE |Trident\//.test(O);function U(e){return[e+"() was called on a"+("destroy"===e?"n already-":" ")+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function P(e){return e.replace(/[ \t]{2,}/g," ").replace(/^[ \t]*/gm,"").trim()}function M(e){return P("\n %ctippy.js\n\n %c"+P(e)+"\n\n %c👷‍ This is a development-only message. It will be removed in production.\n ")}function N(e){return[M(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}function D(e,t){var n;e&&!R.has(t)&&(R.add(t),(n=console).warn.apply(n,N(t)))}function q(e,t){var n;e&&!R.has(t)&&(R.add(t),(n=console).error.apply(n,N(t)))}"production"!==t.env.NODE_ENV&&(R=new Set);var H={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},F=Object.assign({appendTo:function(){return document.body},aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},H,{},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),z=Object.keys(F);function W(e){var t=(e.plugins||[]).reduce((function(t,n){var i=n.name,r=n.defaultValue;return i&&(t[i]=void 0!==e[i]?e[i]:r),t}),{});return Object.assign({},e,{},t)}function $(e,t){var n=Object.assign({},t,{content:u(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(W(Object.assign({},F,{plugins:t}))):z).reduce((function(t,n){var i=(e.getAttribute("data-tippy-"+n)||"").trim();if(!i)return t;if("content"===n)t[n]=i;else try{t[n]=JSON.parse(i)}catch(e){t[n]=i}return t}),{})}(e,t.plugins));return n.aria=Object.assign({},F.aria,{},n.aria),n.aria={expanded:"auto"===n.aria.expanded?t.interactive:n.aria.expanded,content:"auto"===n.aria.content?t.interactive?null:"describedby":n.aria.content},n}function V(e,t){void 0===e&&(e={}),void 0===t&&(t=[]),Object.keys(e).forEach((function(e){var n,i,r=f(F,Object.keys(H)),o=(n=r,i=e,!{}.hasOwnProperty.call(n,i));o&&(o=0===t.filter((function(t){return t.name===e})).length),D(o,["`"+e+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.","\n\n","All props: https://atomiks.github.io/tippyjs/v6/all-props/\n","Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))}))}function G(e,t){e.innerHTML=t}function Y(e){var t=b();return!0===e?t.className=s:(t.className=a,x(e)?t.appendChild(e):G(t,e)),t}function K(e,t){x(t.content)?(G(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?G(e,t.content):e.textContent=t.content)}function X(e){var t=e.firstElementChild,n=v(t.children);return{box:t,content:n.find((function(e){return e.classList.contains(r)})),arrow:n.find((function(e){return e.classList.contains(s)||e.classList.contains(a)})),backdrop:n.find((function(e){return e.classList.contains(o)}))}}function J(e){var t=b(),n=b();n.className="tippy-box",n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var i=b();function o(n,i){var r=X(t),o=r.box,s=r.content,a=r.arrow;i.theme?o.setAttribute("data-theme",i.theme):o.removeAttribute("data-theme"),"string"==typeof i.animation?o.setAttribute("data-animation",i.animation):o.removeAttribute("data-animation"),i.inertia?o.setAttribute("data-inertia",""):o.removeAttribute("data-inertia"),o.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?o.setAttribute("role",i.role):o.removeAttribute("role"),n.content===i.content&&n.allowHTML===i.allowHTML||K(s,e.props),i.arrow?a?n.arrow!==i.arrow&&(o.removeChild(a),o.appendChild(Y(i.arrow))):o.appendChild(Y(i.arrow)):a&&o.removeChild(a)}return i.className=r,i.setAttribute("data-state","hidden"),K(i,e.props),t.appendChild(n),n.appendChild(i),o(e.props,e.props),{popper:t,onUpdate:o}}J.$$tippy=!0;var Z=1,Q=[],ee=[];function te(e,n){var r,o,s,a,p,f,x,_,w,j=$(e,Object.assign({},F,{},W((r=n,Object.keys(r).reduce((function(e,t){return void 0!==r[t]&&(e[t]=r[t]),e}),{}))))),A=!1,L=!1,I=!1,R=!1,O=[],P=d(we,j.interactiveDebounce),M=Z++,N=(w=j.plugins).filter((function(e,t){return w.indexOf(e)===t})),H={id:M,reference:e,popper:b(),popperInstance:null,props:j,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:N,clearDelayTimeouts:function(){clearTimeout(o),clearTimeout(s),cancelAnimationFrame(a)},setProps:function(n){"production"!==t.env.NODE_ENV&&D(H.state.isDestroyed,U("setProps"));if(H.state.isDestroyed)return;ce("onBeforeUpdate",[H,n]),ye();var i=H.props,r=$(e,Object.assign({},H.props,{},n,{ignoreAttributes:!0}));H.props=r,xe(),i.interactiveDebounce!==r.interactiveDebounce&&(ue(),P=d(we,r.interactiveDebounce));i.triggerTarget&&!r.triggerTarget?h(i.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):r.triggerTarget&&e.removeAttribute("aria-expanded");pe(),ae(),G&&G(i,r);H.popperInstance&&(Ce(),je().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));ce("onAfterUpdate",[H,n])},setContent:function(e){H.setProps({content:e})},show:function(){"production"!==t.env.NODE_ENV&&D(H.state.isDestroyed,U("show"));var e=H.state.isVisible,n=H.state.isDestroyed,i=!H.state.isEnabled,r=T.isTouch&&!H.props.touch,o=l(H.props.duration,0,F.duration);if(e||n||i||r)return;if(ie().hasAttribute("disabled"))return;if(ce("onShow",[H],!1),!1===H.props.onShow(H))return;H.state.isVisible=!0,ne()&&(V.style.visibility="visible");ae(),me(),H.state.isMounted||(V.style.transition="none");if(ne()){var s=oe(),a=s.box,c=s.content;k([a,c],0)}x=function(){var e;if(H.state.isVisible&&!R){if(R=!0,V.offsetHeight,V.style.transition=H.props.moveTransition,ne()&&H.props.animation){var t=oe(),n=t.box,i=t.content;k([n,i],o),E([n,i],"visible")}le(),pe(),m(ee,H),null==(e=H.popperInstance)||e.forceUpdate(),H.state.isMounted=!0,ce("onMount",[H]),H.props.animation&&ne()&&function(e,t){ve(e,t)}(o,(function(){H.state.isShown=!0,ce("onShown",[H])}))}},function(){var e,n=H.props.appendTo,i=ie();e=H.props.interactive&&n===F.appendTo||"parent"===n?i.parentNode:u(n,[i]);e.contains(V)||e.appendChild(V);Ce(),"production"!==t.env.NODE_ENV&&D(H.props.interactive&&n===F.appendTo&&i.nextElementSibling!==V,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.","\n\n","Using a wrapper
or tag around the reference element","solves this by creating a new parentNode context.","\n\n","Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.","\n\n","See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}()},hide:function(){"production"!==t.env.NODE_ENV&&D(H.state.isDestroyed,U("hide"));var e=!H.state.isVisible,n=H.state.isDestroyed,i=!H.state.isEnabled,r=l(H.props.duration,1,F.duration);if(e||n||i)return;if(ce("onHide",[H],!1),!1===H.props.onHide(H))return;H.state.isVisible=!1,H.state.isShown=!1,R=!1,A=!1,ne()&&(V.style.visibility="hidden");if(ue(),ge(),ae(),ne()){var o=oe(),s=o.box,a=o.content;H.props.animation&&(k([s,a],r),E([s,a],"hidden"))}le(),pe(),H.props.animation?ne()&&function(e,t){ve(e,(function(){!H.state.isVisible&&V.parentNode&&V.parentNode.contains(V)&&t()}))}(r,H.unmount):H.unmount()},hideWithInteractivity:function(e){"production"!==t.env.NODE_ENV&&D(H.state.isDestroyed,U("hideWithInteractivity"));re().addEventListener("mousemove",P),m(Q,P),P(e)},enable:function(){H.state.isEnabled=!0},disable:function(){H.hide(),H.state.isEnabled=!1},unmount:function(){"production"!==t.env.NODE_ENV&&D(H.state.isDestroyed,U("unmount"));H.state.isVisible&&H.hide();if(!H.state.isMounted)return;Te(),je().forEach((function(e){e._tippy.unmount()})),V.parentNode&&V.parentNode.removeChild(V);ee=ee.filter((function(e){return e!==H})),H.state.isMounted=!1,ce("onHidden",[H])},destroy:function(){"production"!==t.env.NODE_ENV&&D(H.state.isDestroyed,U("destroy"));if(H.state.isDestroyed)return;H.clearDelayTimeouts(),H.unmount(),ye(),delete e._tippy,H.state.isDestroyed=!0,ce("onDestroy",[H])}};if(!j.render)return"production"!==t.env.NODE_ENV&&q(!0,"render() function has not been supplied."),H;var z=j.render(H),V=z.popper,G=z.onUpdate;V.setAttribute("data-tippy-root",""),V.id="tippy-"+H.id,H.popper=V,e._tippy=H,V._tippy=H;var Y=N.map((function(e){return e.fn(H)})),K=e.hasAttribute("aria-expanded");return xe(),pe(),ae(),ce("onCreate",[H]),j.showOnCreate&&Ae(),V.addEventListener("mouseenter",(function(){H.props.interactive&&H.state.isVisible&&H.clearDelayTimeouts()})),V.addEventListener("mouseleave",(function(e){H.props.interactive&&H.props.trigger.indexOf("mouseenter")>=0&&(re().addEventListener("mousemove",P),P(e))})),H;function J(){var e=H.props.touch;return Array.isArray(e)?e:[e,0]}function te(){return"hold"===J()[0]}function ne(){var e;return!!(null==(e=H.props.render)?void 0:e.$$tippy)}function ie(){return _||e}function re(){var e=ie().parentNode;return e?S(e):document}function oe(){return X(V)}function se(e){return H.state.isMounted&&!H.state.isVisible||T.isTouch||p&&"focus"===p.type?0:l(H.props.delay,e?0:1,F.delay)}function ae(){V.style.pointerEvents=H.props.interactive&&H.state.isVisible?"":"none",V.style.zIndex=""+H.props.zIndex}function ce(e,t,n){var i;(void 0===n&&(n=!0),Y.forEach((function(n){n[e]&&n[e].apply(void 0,t)})),n)&&(i=H.props)[e].apply(i,t)}function le(){var t=H.props.aria;if(t.content){var n="aria-"+t.content,i=V.id;h(H.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(n);if(H.state.isVisible)e.setAttribute(n,t?t+" "+i:i);else{var r=t&&t.replace(i,"").trim();r?e.setAttribute(n,r):e.removeAttribute(n)}}))}}function pe(){!K&&H.props.aria.expanded&&h(H.props.triggerTarget||e).forEach((function(e){H.props.interactive?e.setAttribute("aria-expanded",H.state.isVisible&&e===ie()?"true":"false"):e.removeAttribute("aria-expanded")}))}function ue(){re().removeEventListener("mousemove",P),Q=Q.filter((function(e){return e!==P}))}function de(e){if(!(T.isTouch&&(I||"mousedown"===e.type)||H.props.interactive&&V.contains(e.target))){if(ie().contains(e.target)){if(T.isTouch)return;if(H.state.isVisible&&H.props.trigger.indexOf("click")>=0)return}else ce("onClickOutside",[H,e]);!0===H.props.hideOnClick&&(H.clearDelayTimeouts(),H.hide(),L=!0,setTimeout((function(){L=!1})),H.state.isMounted||ge())}}function fe(){I=!0}function he(){I=!1}function me(){var e=re();e.addEventListener("mousedown",de,!0),e.addEventListener("touchend",de,c),e.addEventListener("touchstart",he,c),e.addEventListener("touchmove",fe,c)}function ge(){var e=re();e.removeEventListener("mousedown",de,!0),e.removeEventListener("touchend",de,c),e.removeEventListener("touchstart",he,c),e.removeEventListener("touchmove",fe,c)}function ve(e,t){var n=oe().box;function i(e){e.target===n&&(C(n,"remove",i),t())}if(0===e)return t();C(n,"remove",f),C(n,"add",i),f=i}function be(t,n,i){void 0===i&&(i=!1),h(H.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,n,i),O.push({node:e,eventType:t,handler:n,options:i})}))}function xe(){var e;te()&&(be("touchstart",_e,{passive:!0}),be("touchend",ke,{passive:!0})),(e=H.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch(be(e,_e),e){case"mouseenter":be("mouseleave",ke);break;case"focus":be(B?"focusout":"blur",Ee);break;case"focusin":be("focusout",Ee)}}))}function ye(){O.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),O=[]}function _e(e){var t,n=!1;if(H.state.isEnabled&&!Se(e)&&!L){var i="focus"===(null==(t=p)?void 0:t.type);p=e,_=e.currentTarget,pe(),!H.state.isVisible&&y(e)&&Q.forEach((function(t){return t(e)})),"click"===e.type&&(H.props.trigger.indexOf("mouseenter")<0||A)&&!1!==H.props.hideOnClick&&H.state.isVisible?n=!0:Ae(e),"click"===e.type&&(A=!n),n&&!i&&Le(e)}}function we(e){var t=e.target,n=ie().contains(t)||V.contains(t);"mousemove"===e.type&&n||function(e,t){var n=t.clientX,i=t.clientY;return e.every((function(e){var t=e.popperRect,r=e.popperState,o=e.props.interactiveBorder,s=g(r.placement),a=r.modifiersData.offset;if(!a)return!0;var c="bottom"===s?a.top.y:0,l="top"===s?a.bottom.y:0,p="right"===s?a.left.x:0,u="left"===s?a.right.x:0,d=t.top-i+c>o,f=i-t.bottom-l>o,h=t.left-n+p>o,m=n-t.right-u>o;return d||f||h||m}))}(je().concat(V).map((function(e){var t,n=null==(t=e._tippy.popperInstance)?void 0:t.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:j}:null})).filter(Boolean),e)&&(ue(),Le(e))}function ke(e){Se(e)||H.props.trigger.indexOf("click")>=0&&A||(H.props.interactive?H.hideWithInteractivity(e):Le(e))}function Ee(e){H.props.trigger.indexOf("focusin")<0&&e.target!==ie()||H.props.interactive&&e.relatedTarget&&V.contains(e.relatedTarget)||Le(e)}function Se(e){return!!T.isTouch&&te()!==e.type.indexOf("touch")>=0}function Ce(){Te();var t=H.props,n=t.popperOptions,r=t.placement,o=t.offset,s=t.getReferenceClientRect,a=t.moveTransition,c=ne()?X(V).arrow:null,l=s?{getBoundingClientRect:s,contextElement:s.contextElement||ie()}:e,p=[{name:"offset",options:{offset:o}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!a}},{name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(ne()){var n=oe().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?n.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)})),t.attributes.popper={}}}}];ne()&&c&&p.push({name:"arrow",options:{element:c,padding:3}}),p.push.apply(p,(null==n?void 0:n.modifiers)||[]),H.popperInstance=i.createPopper(l,V,Object.assign({},n,{placement:r,onFirstUpdate:x,modifiers:p}))}function Te(){H.popperInstance&&(H.popperInstance.destroy(),H.popperInstance=null)}function je(){return v(V.querySelectorAll("[data-tippy-root]"))}function Ae(e){H.clearDelayTimeouts(),e&&ce("onTrigger",[H,e]),me();var t=se(!0),n=J(),i=n[0],r=n[1];T.isTouch&&"hold"===i&&r&&(t=r),t?o=setTimeout((function(){H.show()}),t):H.show()}function Le(e){if(H.clearDelayTimeouts(),ce("onUntrigger",[H,e]),H.state.isVisible){if(!(H.props.trigger.indexOf("mouseenter")>=0&&H.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&A)){var t=se(!1);t?s=setTimeout((function(){H.state.isVisible&&H.hide()}),t):a=requestAnimationFrame((function(){H.hide()}))}}else ge()}}function ne(e,n){void 0===n&&(n={});var i=F.plugins.concat(n.plugins||[]);"production"!==t.env.NODE_ENV&&(!function(e){var t=!e,n="[object Object]"===Object.prototype.toString.call(e)&&!e.addEventListener;q(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),q(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}(e),V(n,i)),document.addEventListener("touchstart",A,c),window.addEventListener("blur",I);var r=Object.assign({},n,{plugins:i}),o=w(e);if("production"!==t.env.NODE_ENV){var s=x(r.content),a=o.length>1;D(s&&a,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.","\n\n","Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.","\n\n","1) content: element.innerHTML\n","2) content: () => element.cloneNode(true)"].join(" "))}var l=o.reduce((function(e,t){var n=t&&te(t,r);return n&&e.push(n),e}),[]);return x(e)?l[0]:l}ne.defaultProps=F,ne.setDefaultProps=function(e){"production"!==t.env.NODE_ENV&&V(e,[]),Object.keys(e).forEach((function(t){F[t]=e[t]}))},ne.currentInput=T;var ie=Object.assign({},i.applyStyles,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}}),re={mouseover:"mouseenter",focusin:"focus",click:"click"};var oe={name:"animateFill",defaultValue:!1,fn:function(e){var n;if(!(null==(n=e.props.render)?void 0:n.$$tippy))return"production"!==t.env.NODE_ENV&&q(e.props.animateFill,"The `animateFill` plugin requires the default render function."),{};var i=X(e.popper),r=i.box,s=i.content,a=e.props.animateFill?function(){var e=b();return e.className=o,E([e],"hidden"),e}():null;return{onCreate:function(){a&&(r.insertBefore(a,r.firstElementChild),r.setAttribute("data-animatefill",""),r.style.overflow="hidden",e.setProps({arrow:!1,animation:"shift-away"}))},onMount:function(){if(a){var e=r.style.transitionDuration,t=Number(e.replace("ms",""));s.style.transitionDelay=Math.round(t/10)+"ms",a.style.transitionDuration=e,E([a],"visible")}},onShow:function(){a&&(a.style.transitionDuration="0ms")},onHide:function(){a&&E([a],"hidden")}}}};var se={clientX:0,clientY:0},ae=[];function ce(e){var t=e.clientX,n=e.clientY;se={clientX:t,clientY:n}}var le={name:"followCursor",defaultValue:!1,fn:function(e){var t=e.reference,n=S(e.props.triggerTarget||t),i=!1,r=!1,o=!0,s=e.props;function a(){return"initial"===e.props.followCursor&&e.state.isVisible}function c(){n.addEventListener("mousemove",u)}function l(){n.removeEventListener("mousemove",u)}function p(){i=!0,e.setProps({getReferenceClientRect:null}),i=!1}function u(n){var i=!n.target||t.contains(n.target),r=e.props.followCursor,o=n.clientX,s=n.clientY,a=t.getBoundingClientRect(),c=o-a.left,l=s-a.top;!i&&e.props.interactive||e.setProps({getReferenceClientRect:function(){var e=t.getBoundingClientRect(),n=o,i=s;"initial"===r&&(n=e.left+c,i=e.top+l);var a="horizontal"===r?e.top:i,p="vertical"===r?e.right:n,u="horizontal"===r?e.bottom:i,d="vertical"===r?e.left:n;return{width:p-d,height:u-a,top:a,right:p,bottom:u,left:d}}})}function d(){e.props.followCursor&&(ae.push({instance:e,doc:n}),function(e){e.addEventListener("mousemove",ce)}(n))}function f(){0===(ae=ae.filter((function(t){return t.instance!==e}))).filter((function(e){return e.doc===n})).length&&function(e){e.removeEventListener("mousemove",ce)}(n)}return{onCreate:d,onDestroy:f,onBeforeUpdate:function(){s=e.props},onAfterUpdate:function(t,n){var o=n.followCursor;i||void 0!==o&&s.followCursor!==o&&(f(),o?(d(),!e.state.isMounted||r||a()||c()):(l(),p()))},onMount:function(){e.props.followCursor&&!r&&(o&&(u(se),o=!1),a()||c())},onTrigger:function(e,t){y(t)&&(se={clientX:t.clientX,clientY:t.clientY}),r="focus"===t.type},onHidden:function(){e.props.followCursor&&(p(),l(),o=!0)}}}};var pe={name:"inlinePositioning",defaultValue:!1,fn:function(e){var t,n=e.reference;var i=-1,r=!1,o={name:"tippyInlinePositioning",enabled:!0,phase:"afterWrite",fn:function(r){var o=r.state;e.props.inlinePositioning&&(t!==o.placement&&e.setProps({getReferenceClientRect:function(){return function(e){return function(e,t,n,i){if(n.length<2||null===e)return t;if(2===n.length&&i>=0&&n[0].left>n[1].right)return n[i]||t;switch(e){case"top":case"bottom":var r=n[0],o=n[n.length-1],s="top"===e,a=r.top,c=o.bottom,l=s?r.left:o.left,p=s?r.right:o.right;return{top:a,bottom:c,left:l,right:p,width:p-l,height:c-a};case"left":case"right":var u=Math.min.apply(Math,n.map((function(e){return e.left}))),d=Math.max.apply(Math,n.map((function(e){return e.right}))),f=n.filter((function(t){return"left"===e?t.left===u:t.right===d})),h=f[0].top,m=f[f.length-1].bottom;return{top:h,bottom:m,left:u,right:d,width:d-u,height:m-h};default:return t}}(g(e),n.getBoundingClientRect(),v(n.getClientRects()),i)}(o.placement)}}),t=o.placement)}};function s(){var t;r||(t=function(e,t){var n;return{popperOptions:Object.assign({},e.popperOptions,{modifiers:[].concat(((null==(n=e.popperOptions)?void 0:n.modifiers)||[]).filter((function(e){return e.name!==t.name})),[t])})}}(e.props,o),r=!0,e.setProps(t),r=!1)}return{onCreate:s,onAfterUpdate:s,onTrigger:function(t,n){if(y(n)){var r=v(e.reference.getClientRects()),o=r.find((function(e){return e.left-2<=n.clientX&&e.right+2>=n.clientX&&e.top-2<=n.clientY&&e.bottom+2>=n.clientY}));i=r.indexOf(o)}},onUntrigger:function(){i=-1}}}};var ue={name:"sticky",defaultValue:!1,fn:function(e){var t=e.reference,n=e.popper;function i(t){return!0===e.props.sticky||e.props.sticky===t}var r=null,o=null;function s(){var a=i("reference")?(e.popperInstance?e.popperInstance.state.elements.reference:t).getBoundingClientRect():null,c=i("popper")?n.getBoundingClientRect():null;(a&&de(r,a)||c&&de(o,c))&&e.popperInstance&&e.popperInstance.update(),r=a,o=c,e.state.isMounted&&requestAnimationFrame(s)}return{onMount:function(){e.props.sticky&&s()}}}};function de(e,t){return!e||!t||(e.top!==t.top||e.right!==t.right||e.bottom!==t.bottom||e.left!==t.left)}ne.setDefaultProps({render:J}),n.animateFill=oe,n.createSingleton=function(e,n){var i;void 0===n&&(n={}),"production"!==t.env.NODE_ENV&&q(!Array.isArray(e),["The first argument passed to createSingleton() must be an array of","tippy instances. The passed value was",String(e)].join(" "));var r,o=e,s=[],a=n.overrides,c=[],l=!1;function p(){s=o.map((function(e){return e.reference}))}function u(e){o.forEach((function(t){e?t.enable():t.disable()}))}function d(e){return o.map((function(t){var n=t.setProps;return t.setProps=function(i){n(i),t.reference===r&&e.setProps(i)},function(){t.setProps=n}}))}function h(e,t){var n=s.indexOf(t);if(t!==r){r=t;var i=(a||[]).concat("content").reduce((function(e,t){return e[t]=o[n].props[t],e}),{});e.setProps(Object.assign({},i,{getReferenceClientRect:"function"==typeof i.getReferenceClientRect?i.getReferenceClientRect:function(){return t.getBoundingClientRect()}}))}}u(!1),p();var m={fn:function(){return{onDestroy:function(){u(!0)},onHidden:function(){r=null},onClickOutside:function(e){e.props.showOnCreate&&!l&&(l=!0,r=null)},onShow:function(e){e.props.showOnCreate&&!l&&(l=!0,h(e,s[0]))},onTrigger:function(e,t){h(e,t.currentTarget)}}}},g=ne(b(),Object.assign({},f(n,["overrides"]),{plugins:[m].concat(n.plugins||[]),triggerTarget:s,popperOptions:Object.assign({},n.popperOptions,{modifiers:[].concat((null==(i=n.popperOptions)?void 0:i.modifiers)||[],[ie])})})),v=g.show;g.show=function(e){if(v(),!r&&null==e)return h(g,s[0]);if(!r||null!=e){if("number"==typeof e)return s[e]&&h(g,s[e]);if(o.includes(e)){var t=e.reference;return h(g,t)}return s.includes(e)?h(g,e):void 0}},g.showNext=function(){var e=s[0];if(!r)return g.show(0);var t=s.indexOf(r);g.show(s[t+1]||e)},g.showPrevious=function(){var e=s[s.length-1];if(!r)return g.show(e);var t=s.indexOf(r),n=s[t-1]||e;g.show(n)};var x=g.setProps;return g.setProps=function(e){a=e.overrides||a,x(e)},g.setInstances=function(e){u(!0),c.forEach((function(e){return e()})),o=e,u(!1),p(),d(g),g.setProps({triggerTarget:s})},c=d(g),g},n.default=ne,n.delegate=function(e,n){"production"!==t.env.NODE_ENV&&q(!(n&&n.target),["You must specity a `target` prop indicating a CSS selector string matching","the target elements that should receive a tippy."].join(" "));var i=[],r=[],o=!1,s=n.target,a=f(n,["target"]),l=Object.assign({},a,{trigger:"manual",touch:!1}),p=Object.assign({},a,{showOnCreate:!0}),u=ne(e,l);function d(e){if(e.target&&!o){var t=e.target.closest(s);if(t){var i=t.getAttribute("data-tippy-trigger")||n.trigger||F.trigger;if(!t._tippy&&!("touchstart"===e.type&&"boolean"==typeof p.touch||"touchstart"!==e.type&&i.indexOf(re[e.type])<0)){var a=ne(t,p);a&&(r=r.concat(a))}}}}function m(e,t,n,r){void 0===r&&(r=!1),e.addEventListener(t,n,r),i.push({node:e,eventType:t,handler:n,options:r})}return h(u).forEach((function(e){var t=e.destroy,n=e.enable,s=e.disable;e.destroy=function(e){void 0===e&&(e=!0),e&&r.forEach((function(e){e.destroy()})),r=[],i.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),i=[],t()},e.enable=function(){n(),r.forEach((function(e){return e.enable()})),o=!1},e.disable=function(){s(),r.forEach((function(e){return e.disable()})),o=!0},function(e){var t=e.reference;m(t,"touchstart",d,c),m(t,"mouseover",d),m(t,"focusin",d),m(t,"click",d)}(e)})),u},n.followCursor=le,n.hideAll=function(e){var t=void 0===e?{}:e,n=t.exclude,i=t.duration;ee.forEach((function(e){var t=!1;if(n&&(t=_(n)?e.reference===n:e.popper===n.popper),!t){var r=e.props.duration;e.setProps({duration:i}),e.hide(),e.state.isDestroyed||e.setProps({duration:r})}}))},n.inlinePositioning=pe,n.roundArrow='',n.sticky=ue}).call(this)}).call(this,e("_process"))},{"@popperjs/core":1,_process:189}],292:[function(e,t,n){var i=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(i.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,r=0;r-1}function d(e,t){return"function"==typeof e?e.apply(void 0,t):e}function f(e,t){return 0===t?e:function(i){clearTimeout(n),n=setTimeout((function(){e(i)}),t)};var n}function p(e,t){var n=Object.assign({},e);return t.forEach((function(e){delete n[e]})),n}function h(e){return[].concat(e)}function m(e,t){-1===e.indexOf(t)&&e.push(t)}function b(e){return e.split("-")[0]}function g(e){return[].slice.call(e)}function v(){return document.createElement("div")}function y(e){return["Element","Fragment"].some((function(t){return l(e,t)}))}function _(e){return l(e,"MouseEvent")}function w(e){return!(!e||!e._tippy||e._tippy.reference!==e)}function x(e){return y(e)?[e]:function(e){return l(e,"NodeList")}(e)?g(e):Array.isArray(e)?e:g(document.querySelectorAll(e))}function k(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function E(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function S(e){var t,n=h(e)[0];return(null==n||null==(t=n.ownerDocument)?void 0:t.body)?n.ownerDocument:document}function M(e,t,n){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[i](t,n)}))}var A={isTouch:!1},I=0;function j(){A.isTouch||(A.isTouch=!0,window.performance&&document.addEventListener("mousemove",C))}function C(){var e=performance.now();e-I<20&&(A.isTouch=!1,document.removeEventListener("mousemove",C)),I=e}function T(){var e=document.activeElement;if(w(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}var B,R="undefined"!=typeof window&&"undefined"!=typeof document?navigator.userAgent:"",L=/MSIE |Trident\//.test(R);function O(e){return[e+"() was called on a"+("destroy"===e?"n already-":" ")+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function P(e){return e.replace(/[ \t]{2,}/g," ").replace(/^[ \t]*/gm,"").trim()}function U(e){return P("\n %ctippy.js\n\n %c"+P(e)+"\n\n %c👷‍ This is a development-only message. It will be removed in production.\n ")}function q(e){return[U(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}function D(e,t){var n;e&&!B.has(t)&&(B.add(t),(n=console).warn.apply(n,q(t)))}function N(e,t){var n;e&&!B.has(t)&&(B.add(t),(n=console).error.apply(n,q(t)))}"production"!==t.env.NODE_ENV&&(B=new Set);var z={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},H=Object.assign({appendTo:function(){return document.body},aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},z,{},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),F=Object.keys(H);function W(e){var t=(e.plugins||[]).reduce((function(t,n){var i=n.name,r=n.defaultValue;return i&&(t[i]=void 0!==e[i]?e[i]:r),t}),{});return Object.assign({},e,{},t)}function V(e,t){var n=Object.assign({},t,{content:d(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(W(Object.assign({},H,{plugins:t}))):F).reduce((function(t,n){var i=(e.getAttribute("data-tippy-"+n)||"").trim();if(!i)return t;if("content"===n)t[n]=i;else try{t[n]=JSON.parse(i)}catch(e){t[n]=i}return t}),{})}(e,t.plugins));return n.aria=Object.assign({},H.aria,{},n.aria),n.aria={expanded:"auto"===n.aria.expanded?t.interactive:n.aria.expanded,content:"auto"===n.aria.content?t.interactive?null:"describedby":n.aria.content},n}function K(e,t){void 0===e&&(e={}),void 0===t&&(t=[]),Object.keys(e).forEach((function(e){var n,i,r=p(H,Object.keys(z)),s=(n=r,i=e,!{}.hasOwnProperty.call(n,i));s&&(s=0===t.filter((function(t){return t.name===e})).length),D(s,["`"+e+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.","\n\n","All props: https://atomiks.github.io/tippyjs/v6/all-props/\n","Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))}))}function $(e,t){e.innerHTML=t}function G(e){var t=v();return!0===e?t.className=o:(t.className=a,y(e)?t.appendChild(e):$(t,e)),t}function X(e,t){y(t.content)?($(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?$(e,t.content):e.textContent=t.content)}function Y(e){var t=e.firstElementChild,n=g(t.children);return{box:t,content:n.find((function(e){return e.classList.contains(r)})),arrow:n.find((function(e){return e.classList.contains(o)||e.classList.contains(a)})),backdrop:n.find((function(e){return e.classList.contains(s)}))}}function Z(e){var t=v(),n=v();n.className="tippy-box",n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var i=v();function s(n,i){var r=Y(t),s=r.box,o=r.content,a=r.arrow;i.theme?s.setAttribute("data-theme",i.theme):s.removeAttribute("data-theme"),"string"==typeof i.animation?s.setAttribute("data-animation",i.animation):s.removeAttribute("data-animation"),i.inertia?s.setAttribute("data-inertia",""):s.removeAttribute("data-inertia"),s.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?s.setAttribute("role",i.role):s.removeAttribute("role"),n.content===i.content&&n.allowHTML===i.allowHTML||X(o,e.props),i.arrow?a?n.arrow!==i.arrow&&(s.removeChild(a),s.appendChild(G(i.arrow))):s.appendChild(G(i.arrow)):a&&s.removeChild(a)}return i.className=r,i.setAttribute("data-state","hidden"),X(i,e.props),t.appendChild(n),n.appendChild(i),s(e.props,e.props),{popper:t,onUpdate:s}}Z.$$tippy=!0;var J=1,Q=[],ee=[];function te(e,n){var r,s,o,a,l,p,y,w,x,I=V(e,Object.assign({},H,{},W((r=n,Object.keys(r).reduce((function(e,t){return void 0!==r[t]&&(e[t]=r[t]),e}),{}))))),j=!1,C=!1,T=!1,B=!1,R=[],P=f(xe,I.interactiveDebounce),U=J++,q=(x=I.plugins).filter((function(e,t){return x.indexOf(e)===t})),z={id:U,reference:e,popper:v(),popperInstance:null,props:I,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:q,clearDelayTimeouts:function(){clearTimeout(s),clearTimeout(o),cancelAnimationFrame(a)},setProps:function(n){"production"!==t.env.NODE_ENV&&D(z.state.isDestroyed,O("setProps"));if(z.state.isDestroyed)return;ce("onBeforeUpdate",[z,n]),_e();var i=z.props,r=V(e,Object.assign({},z.props,{},n,{ignoreAttributes:!0}));z.props=r,ye(),i.interactiveDebounce!==r.interactiveDebounce&&(de(),P=f(xe,r.interactiveDebounce));i.triggerTarget&&!r.triggerTarget?h(i.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):r.triggerTarget&&e.removeAttribute("aria-expanded");le(),ae(),$&&$(i,r);z.popperInstance&&(Me(),Ie().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));ce("onAfterUpdate",[z,n])},setContent:function(e){z.setProps({content:e})},show:function(){"production"!==t.env.NODE_ENV&&D(z.state.isDestroyed,O("show"));var e=z.state.isVisible,n=z.state.isDestroyed,i=!z.state.isEnabled,r=A.isTouch&&!z.props.touch,s=u(z.props.duration,0,H.duration);if(e||n||i||r)return;if(ie().hasAttribute("disabled"))return;if(ce("onShow",[z],!1),!1===z.props.onShow(z))return;z.state.isVisible=!0,ne()&&(K.style.visibility="visible");ae(),me(),z.state.isMounted||(K.style.transition="none");if(ne()){var o=se(),a=o.box,c=o.content;k([a,c],0)}y=function(){var e;if(z.state.isVisible&&!B){if(B=!0,K.offsetHeight,K.style.transition=z.props.moveTransition,ne()&&z.props.animation){var t=se(),n=t.box,i=t.content;k([n,i],s),E([n,i],"visible")}ue(),le(),m(ee,z),null==(e=z.popperInstance)||e.forceUpdate(),z.state.isMounted=!0,ce("onMount",[z]),z.props.animation&&ne()&&function(e,t){ge(e,t)}(s,(function(){z.state.isShown=!0,ce("onShown",[z])}))}},function(){var e,n=z.props.appendTo,i=ie();e=z.props.interactive&&n===H.appendTo||"parent"===n?i.parentNode:d(n,[i]);e.contains(K)||e.appendChild(K);Me(),"production"!==t.env.NODE_ENV&&D(z.props.interactive&&n===H.appendTo&&i.nextElementSibling!==K,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.","\n\n","Using a wrapper
or tag around the reference element","solves this by creating a new parentNode context.","\n\n","Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.","\n\n","See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}()},hide:function(){"production"!==t.env.NODE_ENV&&D(z.state.isDestroyed,O("hide"));var e=!z.state.isVisible,n=z.state.isDestroyed,i=!z.state.isEnabled,r=u(z.props.duration,1,H.duration);if(e||n||i)return;if(ce("onHide",[z],!1),!1===z.props.onHide(z))return;z.state.isVisible=!1,z.state.isShown=!1,B=!1,j=!1,ne()&&(K.style.visibility="hidden");if(de(),be(),ae(),ne()){var s=se(),o=s.box,a=s.content;z.props.animation&&(k([o,a],r),E([o,a],"hidden"))}ue(),le(),z.props.animation?ne()&&function(e,t){ge(e,(function(){!z.state.isVisible&&K.parentNode&&K.parentNode.contains(K)&&t()}))}(r,z.unmount):z.unmount()},hideWithInteractivity:function(e){"production"!==t.env.NODE_ENV&&D(z.state.isDestroyed,O("hideWithInteractivity"));re().addEventListener("mousemove",P),m(Q,P),P(e)},enable:function(){z.state.isEnabled=!0},disable:function(){z.hide(),z.state.isEnabled=!1},unmount:function(){"production"!==t.env.NODE_ENV&&D(z.state.isDestroyed,O("unmount"));z.state.isVisible&&z.hide();if(!z.state.isMounted)return;Ae(),Ie().forEach((function(e){e._tippy.unmount()})),K.parentNode&&K.parentNode.removeChild(K);ee=ee.filter((function(e){return e!==z})),z.state.isMounted=!1,ce("onHidden",[z])},destroy:function(){"production"!==t.env.NODE_ENV&&D(z.state.isDestroyed,O("destroy"));if(z.state.isDestroyed)return;z.clearDelayTimeouts(),z.unmount(),_e(),delete e._tippy,z.state.isDestroyed=!0,ce("onDestroy",[z])}};if(!I.render)return"production"!==t.env.NODE_ENV&&N(!0,"render() function has not been supplied."),z;var F=I.render(z),K=F.popper,$=F.onUpdate;K.setAttribute("data-tippy-root",""),K.id="tippy-"+z.id,z.popper=K,e._tippy=z,K._tippy=z;var G=q.map((function(e){return e.fn(z)})),X=e.hasAttribute("aria-expanded");return ye(),le(),ae(),ce("onCreate",[z]),I.showOnCreate&&je(),K.addEventListener("mouseenter",(function(){z.props.interactive&&z.state.isVisible&&z.clearDelayTimeouts()})),K.addEventListener("mouseleave",(function(e){z.props.interactive&&z.props.trigger.indexOf("mouseenter")>=0&&(re().addEventListener("mousemove",P),P(e))})),z;function Z(){var e=z.props.touch;return Array.isArray(e)?e:[e,0]}function te(){return"hold"===Z()[0]}function ne(){var e;return!!(null==(e=z.props.render)?void 0:e.$$tippy)}function ie(){return w||e}function re(){var e=ie().parentNode;return e?S(e):document}function se(){return Y(K)}function oe(e){return z.state.isMounted&&!z.state.isVisible||A.isTouch||l&&"focus"===l.type?0:u(z.props.delay,e?0:1,H.delay)}function ae(){K.style.pointerEvents=z.props.interactive&&z.state.isVisible?"":"none",K.style.zIndex=""+z.props.zIndex}function ce(e,t,n){var i;(void 0===n&&(n=!0),G.forEach((function(n){n[e]&&n[e].apply(void 0,t)})),n)&&(i=z.props)[e].apply(i,t)}function ue(){var t=z.props.aria;if(t.content){var n="aria-"+t.content,i=K.id;h(z.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(n);if(z.state.isVisible)e.setAttribute(n,t?t+" "+i:i);else{var r=t&&t.replace(i,"").trim();r?e.setAttribute(n,r):e.removeAttribute(n)}}))}}function le(){!X&&z.props.aria.expanded&&h(z.props.triggerTarget||e).forEach((function(e){z.props.interactive?e.setAttribute("aria-expanded",z.state.isVisible&&e===ie()?"true":"false"):e.removeAttribute("aria-expanded")}))}function de(){re().removeEventListener("mousemove",P),Q=Q.filter((function(e){return e!==P}))}function fe(e){if(!(A.isTouch&&(T||"mousedown"===e.type)||z.props.interactive&&K.contains(e.target))){if(ie().contains(e.target)){if(A.isTouch)return;if(z.state.isVisible&&z.props.trigger.indexOf("click")>=0)return}else ce("onClickOutside",[z,e]);!0===z.props.hideOnClick&&(z.clearDelayTimeouts(),z.hide(),C=!0,setTimeout((function(){C=!1})),z.state.isMounted||be())}}function pe(){T=!0}function he(){T=!1}function me(){var e=re();e.addEventListener("mousedown",fe,!0),e.addEventListener("touchend",fe,c),e.addEventListener("touchstart",he,c),e.addEventListener("touchmove",pe,c)}function be(){var e=re();e.removeEventListener("mousedown",fe,!0),e.removeEventListener("touchend",fe,c),e.removeEventListener("touchstart",he,c),e.removeEventListener("touchmove",pe,c)}function ge(e,t){var n=se().box;function i(e){e.target===n&&(M(n,"remove",i),t())}if(0===e)return t();M(n,"remove",p),M(n,"add",i),p=i}function ve(t,n,i){void 0===i&&(i=!1),h(z.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,n,i),R.push({node:e,eventType:t,handler:n,options:i})}))}function ye(){var e;te()&&(ve("touchstart",we,{passive:!0}),ve("touchend",ke,{passive:!0})),(e=z.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch(ve(e,we),e){case"mouseenter":ve("mouseleave",ke);break;case"focus":ve(L?"focusout":"blur",Ee);break;case"focusin":ve("focusout",Ee)}}))}function _e(){R.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),R=[]}function we(e){var t,n=!1;if(z.state.isEnabled&&!Se(e)&&!C){var i="focus"===(null==(t=l)?void 0:t.type);l=e,w=e.currentTarget,le(),!z.state.isVisible&&_(e)&&Q.forEach((function(t){return t(e)})),"click"===e.type&&(z.props.trigger.indexOf("mouseenter")<0||j)&&!1!==z.props.hideOnClick&&z.state.isVisible?n=!0:je(e),"click"===e.type&&(j=!n),n&&!i&&Ce(e)}}function xe(e){var t=e.target,n=ie().contains(t)||K.contains(t);"mousemove"===e.type&&n||function(e,t){var n=t.clientX,i=t.clientY;return e.every((function(e){var t=e.popperRect,r=e.popperState,s=e.props.interactiveBorder,o=b(r.placement),a=r.modifiersData.offset;if(!a)return!0;var c="bottom"===o?a.top.y:0,u="top"===o?a.bottom.y:0,l="right"===o?a.left.x:0,d="left"===o?a.right.x:0,f=t.top-i+c>s,p=i-t.bottom-u>s,h=t.left-n+l>s,m=n-t.right-d>s;return f||p||h||m}))}(Ie().concat(K).map((function(e){var t,n=null==(t=e._tippy.popperInstance)?void 0:t.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:I}:null})).filter(Boolean),e)&&(de(),Ce(e))}function ke(e){Se(e)||z.props.trigger.indexOf("click")>=0&&j||(z.props.interactive?z.hideWithInteractivity(e):Ce(e))}function Ee(e){z.props.trigger.indexOf("focusin")<0&&e.target!==ie()||z.props.interactive&&e.relatedTarget&&K.contains(e.relatedTarget)||Ce(e)}function Se(e){return!!A.isTouch&&te()!==e.type.indexOf("touch")>=0}function Me(){Ae();var t=z.props,n=t.popperOptions,r=t.placement,s=t.offset,o=t.getReferenceClientRect,a=t.moveTransition,c=ne()?Y(K).arrow:null,u=o?{getBoundingClientRect:o,contextElement:o.contextElement||ie()}:e,l=[{name:"offset",options:{offset:s}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!a}},{name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(ne()){var n=se().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?n.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)})),t.attributes.popper={}}}}];ne()&&c&&l.push({name:"arrow",options:{element:c,padding:3}}),l.push.apply(l,(null==n?void 0:n.modifiers)||[]),z.popperInstance=i.createPopper(u,K,Object.assign({},n,{placement:r,onFirstUpdate:y,modifiers:l}))}function Ae(){z.popperInstance&&(z.popperInstance.destroy(),z.popperInstance=null)}function Ie(){return g(K.querySelectorAll("[data-tippy-root]"))}function je(e){z.clearDelayTimeouts(),e&&ce("onTrigger",[z,e]),me();var t=oe(!0),n=Z(),i=n[0],r=n[1];A.isTouch&&"hold"===i&&r&&(t=r),t?s=setTimeout((function(){z.show()}),t):z.show()}function Ce(e){if(z.clearDelayTimeouts(),ce("onUntrigger",[z,e]),z.state.isVisible){if(!(z.props.trigger.indexOf("mouseenter")>=0&&z.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&j)){var t=oe(!1);t?o=setTimeout((function(){z.state.isVisible&&z.hide()}),t):a=requestAnimationFrame((function(){z.hide()}))}}else be()}}function ne(e,n){void 0===n&&(n={});var i=H.plugins.concat(n.plugins||[]);"production"!==t.env.NODE_ENV&&(!function(e){var t=!e,n="[object Object]"===Object.prototype.toString.call(e)&&!e.addEventListener;N(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),N(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}(e),K(n,i)),document.addEventListener("touchstart",j,c),window.addEventListener("blur",T);var r=Object.assign({},n,{plugins:i}),s=x(e);if("production"!==t.env.NODE_ENV){var o=y(r.content),a=s.length>1;D(o&&a,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.","\n\n","Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.","\n\n","1) content: element.innerHTML\n","2) content: () => element.cloneNode(true)"].join(" "))}var u=s.reduce((function(e,t){var n=t&&te(t,r);return n&&e.push(n),e}),[]);return y(e)?u[0]:u}ne.defaultProps=H,ne.setDefaultProps=function(e){"production"!==t.env.NODE_ENV&&K(e,[]),Object.keys(e).forEach((function(t){H[t]=e[t]}))},ne.currentInput=A;var ie=Object.assign({},i.applyStyles,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}}),re={mouseover:"mouseenter",focusin:"focus",click:"click"};var se={name:"animateFill",defaultValue:!1,fn:function(e){var n;if(!(null==(n=e.props.render)?void 0:n.$$tippy))return"production"!==t.env.NODE_ENV&&N(e.props.animateFill,"The `animateFill` plugin requires the default render function."),{};var i=Y(e.popper),r=i.box,o=i.content,a=e.props.animateFill?function(){var e=v();return e.className=s,E([e],"hidden"),e}():null;return{onCreate:function(){a&&(r.insertBefore(a,r.firstElementChild),r.setAttribute("data-animatefill",""),r.style.overflow="hidden",e.setProps({arrow:!1,animation:"shift-away"}))},onMount:function(){if(a){var e=r.style.transitionDuration,t=Number(e.replace("ms",""));o.style.transitionDelay=Math.round(t/10)+"ms",a.style.transitionDuration=e,E([a],"visible")}},onShow:function(){a&&(a.style.transitionDuration="0ms")},onHide:function(){a&&E([a],"hidden")}}}};var oe={clientX:0,clientY:0},ae=[];function ce(e){var t=e.clientX,n=e.clientY;oe={clientX:t,clientY:n}}var ue={name:"followCursor",defaultValue:!1,fn:function(e){var t=e.reference,n=S(e.props.triggerTarget||t),i=!1,r=!1,s=!0,o=e.props;function a(){return"initial"===e.props.followCursor&&e.state.isVisible}function c(){n.addEventListener("mousemove",d)}function u(){n.removeEventListener("mousemove",d)}function l(){i=!0,e.setProps({getReferenceClientRect:null}),i=!1}function d(n){var i=!n.target||t.contains(n.target),r=e.props.followCursor,s=n.clientX,o=n.clientY,a=t.getBoundingClientRect(),c=s-a.left,u=o-a.top;!i&&e.props.interactive||e.setProps({getReferenceClientRect:function(){var e=t.getBoundingClientRect(),n=s,i=o;"initial"===r&&(n=e.left+c,i=e.top+u);var a="horizontal"===r?e.top:i,l="vertical"===r?e.right:n,d="horizontal"===r?e.bottom:i,f="vertical"===r?e.left:n;return{width:l-f,height:d-a,top:a,right:l,bottom:d,left:f}}})}function f(){e.props.followCursor&&(ae.push({instance:e,doc:n}),function(e){e.addEventListener("mousemove",ce)}(n))}function p(){0===(ae=ae.filter((function(t){return t.instance!==e}))).filter((function(e){return e.doc===n})).length&&function(e){e.removeEventListener("mousemove",ce)}(n)}return{onCreate:f,onDestroy:p,onBeforeUpdate:function(){o=e.props},onAfterUpdate:function(t,n){var s=n.followCursor;i||void 0!==s&&o.followCursor!==s&&(p(),s?(f(),!e.state.isMounted||r||a()||c()):(u(),l()))},onMount:function(){e.props.followCursor&&!r&&(s&&(d(oe),s=!1),a()||c())},onTrigger:function(e,t){_(t)&&(oe={clientX:t.clientX,clientY:t.clientY}),r="focus"===t.type},onHidden:function(){e.props.followCursor&&(l(),u(),s=!0)}}}};var le={name:"inlinePositioning",defaultValue:!1,fn:function(e){var t,n=e.reference;var i=-1,r=!1,s={name:"tippyInlinePositioning",enabled:!0,phase:"afterWrite",fn:function(r){var s=r.state;e.props.inlinePositioning&&(t!==s.placement&&e.setProps({getReferenceClientRect:function(){return function(e){return function(e,t,n,i){if(n.length<2||null===e)return t;if(2===n.length&&i>=0&&n[0].left>n[1].right)return n[i]||t;switch(e){case"top":case"bottom":var r=n[0],s=n[n.length-1],o="top"===e,a=r.top,c=s.bottom,u=o?r.left:s.left,l=o?r.right:s.right;return{top:a,bottom:c,left:u,right:l,width:l-u,height:c-a};case"left":case"right":var d=Math.min.apply(Math,n.map((function(e){return e.left}))),f=Math.max.apply(Math,n.map((function(e){return e.right}))),p=n.filter((function(t){return"left"===e?t.left===d:t.right===f})),h=p[0].top,m=p[p.length-1].bottom;return{top:h,bottom:m,left:d,right:f,width:f-d,height:m-h};default:return t}}(b(e),n.getBoundingClientRect(),g(n.getClientRects()),i)}(s.placement)}}),t=s.placement)}};function o(){var t;r||(t=function(e,t){var n;return{popperOptions:Object.assign({},e.popperOptions,{modifiers:[].concat(((null==(n=e.popperOptions)?void 0:n.modifiers)||[]).filter((function(e){return e.name!==t.name})),[t])})}}(e.props,s),r=!0,e.setProps(t),r=!1)}return{onCreate:o,onAfterUpdate:o,onTrigger:function(t,n){if(_(n)){var r=g(e.reference.getClientRects()),s=r.find((function(e){return e.left-2<=n.clientX&&e.right+2>=n.clientX&&e.top-2<=n.clientY&&e.bottom+2>=n.clientY}));i=r.indexOf(s)}},onUntrigger:function(){i=-1}}}};var de={name:"sticky",defaultValue:!1,fn:function(e){var t=e.reference,n=e.popper;function i(t){return!0===e.props.sticky||e.props.sticky===t}var r=null,s=null;function o(){var a=i("reference")?(e.popperInstance?e.popperInstance.state.elements.reference:t).getBoundingClientRect():null,c=i("popper")?n.getBoundingClientRect():null;(a&&fe(r,a)||c&&fe(s,c))&&e.popperInstance&&e.popperInstance.update(),r=a,s=c,e.state.isMounted&&requestAnimationFrame(o)}return{onMount:function(){e.props.sticky&&o()}}}};function fe(e,t){return!e||!t||(e.top!==t.top||e.right!==t.right||e.bottom!==t.bottom||e.left!==t.left)}ne.setDefaultProps({render:Z}),n.animateFill=se,n.createSingleton=function(e,n){var i;void 0===n&&(n={}),"production"!==t.env.NODE_ENV&&N(!Array.isArray(e),["The first argument passed to createSingleton() must be an array of","tippy instances. The passed value was",String(e)].join(" "));var r,s=e,o=[],a=n.overrides,c=[],u=!1;function l(){o=s.map((function(e){return e.reference}))}function d(e){s.forEach((function(t){e?t.enable():t.disable()}))}function f(e){return s.map((function(t){var n=t.setProps;return t.setProps=function(i){n(i),t.reference===r&&e.setProps(i)},function(){t.setProps=n}}))}function h(e,t){var n=o.indexOf(t);if(t!==r){r=t;var i=(a||[]).concat("content").reduce((function(e,t){return e[t]=s[n].props[t],e}),{});e.setProps(Object.assign({},i,{getReferenceClientRect:"function"==typeof i.getReferenceClientRect?i.getReferenceClientRect:function(){return t.getBoundingClientRect()}}))}}d(!1),l();var m={fn:function(){return{onDestroy:function(){d(!0)},onHidden:function(){r=null},onClickOutside:function(e){e.props.showOnCreate&&!u&&(u=!0,r=null)},onShow:function(e){e.props.showOnCreate&&!u&&(u=!0,h(e,o[0]))},onTrigger:function(e,t){h(e,t.currentTarget)}}}},b=ne(v(),Object.assign({},p(n,["overrides"]),{plugins:[m].concat(n.plugins||[]),triggerTarget:o,popperOptions:Object.assign({},n.popperOptions,{modifiers:[].concat((null==(i=n.popperOptions)?void 0:i.modifiers)||[],[ie])})})),g=b.show;b.show=function(e){if(g(),!r&&null==e)return h(b,o[0]);if(!r||null!=e){if("number"==typeof e)return o[e]&&h(b,o[e]);if(s.includes(e)){var t=e.reference;return h(b,t)}return o.includes(e)?h(b,e):void 0}},b.showNext=function(){var e=o[0];if(!r)return b.show(0);var t=o.indexOf(r);b.show(o[t+1]||e)},b.showPrevious=function(){var e=o[o.length-1];if(!r)return b.show(e);var t=o.indexOf(r),n=o[t-1]||e;b.show(n)};var y=b.setProps;return b.setProps=function(e){a=e.overrides||a,y(e)},b.setInstances=function(e){d(!0),c.forEach((function(e){return e()})),s=e,d(!1),l(),f(b),b.setProps({triggerTarget:o})},c=f(b),b},n.default=ne,n.delegate=function(e,n){"production"!==t.env.NODE_ENV&&N(!(n&&n.target),["You must specity a `target` prop indicating a CSS selector string matching","the target elements that should receive a tippy."].join(" "));var i=[],r=[],s=!1,o=n.target,a=p(n,["target"]),u=Object.assign({},a,{trigger:"manual",touch:!1}),l=Object.assign({},a,{showOnCreate:!0}),d=ne(e,u);function f(e){if(e.target&&!s){var t=e.target.closest(o);if(t){var i=t.getAttribute("data-tippy-trigger")||n.trigger||H.trigger;if(!t._tippy&&!("touchstart"===e.type&&"boolean"==typeof l.touch||"touchstart"!==e.type&&i.indexOf(re[e.type])<0)){var a=ne(t,l);a&&(r=r.concat(a))}}}}function m(e,t,n,r){void 0===r&&(r=!1),e.addEventListener(t,n,r),i.push({node:e,eventType:t,handler:n,options:r})}return h(d).forEach((function(e){var t=e.destroy,n=e.enable,o=e.disable;e.destroy=function(e){void 0===e&&(e=!0),e&&r.forEach((function(e){e.destroy()})),r=[],i.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),i=[],t()},e.enable=function(){n(),r.forEach((function(e){return e.enable()})),s=!1},e.disable=function(){o(),r.forEach((function(e){return e.disable()})),s=!0},function(e){var t=e.reference;m(t,"touchstart",f,c),m(t,"mouseover",f),m(t,"focusin",f),m(t,"click",f)}(e)})),d},n.followCursor=ue,n.hideAll=function(e){var t=void 0===e?{}:e,n=t.exclude,i=t.duration;ee.forEach((function(e){var t=!1;if(n&&(t=w(n)?e.reference===n:e.popper===n.popper),!t){var r=e.props.duration;e.setProps({duration:i}),e.hide(),e.state.isDestroyed||e.setProps({duration:r})}}))},n.inlinePositioning=le,n.roundArrow='',n.sticky=de}).call(this)}).call(this,e("_process"))},{"@popperjs/core":1,_process:333}],470:[function(e,t,n){var i=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(i.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,r=0;r */ -const i=e("debug")("torrent-discovery"),r=e("bittorrent-dht/client"),o=e("events").EventEmitter,s=e("run-parallel"),a=e("bittorrent-tracker/client"),c=e("bittorrent-lsd");t.exports=class extends o{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=e=>{this.emit("warning",e)},this._onError=e=>{this.emit("error",e)},this._onDHTPeer=(e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")},this._onTrackerPeer=e=>{this.emit("peer",e,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=(e,t)=>{this.emit("peer",e,"lsd")};const t=(e,t)=>{const n=new r(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===e.dht||"function"!=typeof r?this.dht=null:e.dht&&"function"==typeof e.dht.addNode?this.dht=e.dht:e.dht&&"object"==typeof e.dht?this.dht=t(e.dhtPort,e.dht):this.dht=t(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),!1===e.lsd||"function"!=typeof c?this.lsd=null:this.lsd=this._createLSD()}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy((()=>{this.tracker=this._createTracker()}))))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push((e=>{this.tracker.destroy(e)}))),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push((e=>{this.dht.destroy(e)}))),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),t.push((e=>{this.lsd.destroy(e)}))),s(t,e),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new a(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(i("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,(e=>{this._dhtAnnouncing=!1,i("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout((()=>{this._dhtAnnounce()}),this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())})))}_createLSD(){const e=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),t=new c(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onLSDPeer),t.start(),t}}}).call(this)}).call(this,e("_process"))},{_process:189,"bittorrent-dht/client":54,"bittorrent-lsd":54,"bittorrent-tracker/client":30,debug:294,events:97,"run-parallel":220}],294:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":295,_process:189,dup:12}],295:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:296}],296:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],297:[function(e,t,n){(function(e){(function(){ +const i=e("debug")("torrent-discovery"),r=e("bittorrent-dht/client"),s=e("events").EventEmitter,o=e("run-parallel"),a=e("bittorrent-tracker/client"),c=e("bittorrent-lsd");t.exports=class extends s{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=e=>{this.emit("warning",e)},this._onError=e=>{this.emit("error",e)},this._onDHTPeer=(e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")},this._onTrackerPeer=e=>{this.emit("peer",e,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=(e,t)=>{this.emit("peer",e,"lsd")};const t=(e,t)=>{const n=new r(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===e.dht||"function"!=typeof r?this.dht=null:e.dht&&"function"==typeof e.dht.addNode?this.dht=e.dht:e.dht&&"object"==typeof e.dht?this.dht=t(e.dhtPort,e.dht):this.dht=t(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),!1===e.lsd||"function"!=typeof c?this.lsd=null:this.lsd=this._createLSD()}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy((()=>{this.tracker=this._createTracker()}))))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push((e=>{this.tracker.destroy(e)}))),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push((e=>{this.dht.destroy(e)}))),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),t.push((e=>{this.lsd.destroy(e)}))),o(t,e),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new a(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(i("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,(e=>{this._dhtAnnouncing=!1,i("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout((()=>{this._dhtAnnounce()}),this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())})))}_createLSD(){const e=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),t=new c(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onLSDPeer),t.start(),t}}}).call(this)}).call(this,e("_process"))},{_process:333,"bittorrent-dht/client":71,"bittorrent-lsd":71,"bittorrent-tracker/client":45,debug:472,events:194,"run-parallel":374}],472:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":473,_process:333,dup:27}],473:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:474}],474:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],475:[function(e,t,n){(function(e){(function(){ /*! torrent-piece. MIT License. WebTorrent LLC */ -const n=16384;class i{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/n),this._remainder=e%n||n,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:n}chunkLengthRemaining(e){return this.length-e*n}chunkOffset(e){return e*n}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations=e.length||t<0)return;var n=e.pop();if(t",'"',"`"," ","\r","\n","\t"]),p=["'"].concat(l),u=["%","/","?",";","#"].concat(p),d=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,h=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function x(e,t,n){if(e&&r.isObject(e)&&e instanceof o)return e;var i=new o;return i.parse(e,t,n),i}o.prototype.parse=function(e,t,n){if(!r.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?O+="x":O+=R[B];if(!O.match(f)){var P=L.slice(0,T),M=L.slice(T+1),N=R.match(h);N&&(P.push(N[1]),M.unshift(N[2])),M.length&&(x="/"+M.join(".")+x),this.hostname=P.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),A||(this.hostname=i.toASCII(this.hostname));var D=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+D,this.href+=this.host,A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==x[0]&&(x="/"+x))}if(!m[w])for(T=0,I=p.length;T0)&&n.host.split("@"))&&(n.auth=A.shift(),n.host=n.hostname=A.shift());return n.search=e.search,n.query=e.query,r.isNull(n.pathname)&&r.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var S=k.slice(-1)[0],C=(n.host||e.host||k.length>1)&&("."===S||".."===S)||""===S,T=0,j=k.length;j>=0;j--)"."===(S=k[j])?k.splice(j,1):".."===S?(k.splice(j,1),T++):T&&(k.splice(j,1),T--);if(!_&&!w)for(;T--;T)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),C&&"/"!==k.join("/").substr(-1)&&k.push("");var A,L=""===k[0]||k[0]&&"/"===k[0].charAt(0);E&&(n.hostname=n.host=L?"":k.length?k.shift():"",(A=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=A.shift(),n.host=n.hostname=A.shift()));return(_=_||n.host&&k.length)&&!L&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),r.isNull(n.pathname)&&r.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":302,punycode:191,querystring:194}],302:[function(e,t,n){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],303:[function(e,t,n){(function(n){(function(){ +const n=16384;class i{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/n),this._remainder=e%n||n,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:n}chunkLengthRemaining(e){return this.length-e*n}chunkOffset(e){return e*n}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations=e.length||t<0)return;var n=e.pop();if(t",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(u),d=["%","/","?",";","#"].concat(l),f=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,h=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function y(e,t,n){if(e&&r.isObject(e)&&e instanceof s)return e;var i=new s;return i.parse(e,t,n),i}s.prototype.parse=function(e,t,n){if(!r.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var s=e.indexOf("?"),a=-1!==s&&s127?R+="x":R+=B[L];if(!R.match(p)){var P=C.slice(0,A),U=C.slice(A+1),q=B.match(h);q&&(P.push(q[1]),U.unshift(q[2])),U.length&&(y="/"+U.join(".")+y),this.hostname=P.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),j||(this.hostname=i.toASCII(this.hostname));var D=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+D,this.href+=this.host,j&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!m[x])for(A=0,T=l.length;A0)&&n.host.split("@"))&&(n.auth=j.shift(),n.host=n.hostname=j.shift());return n.search=e.search,n.query=e.query,r.isNull(n.pathname)&&r.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var S=k.slice(-1)[0],M=(n.host||e.host||k.length>1)&&("."===S||".."===S)||""===S,A=0,I=k.length;I>=0;I--)"."===(S=k[I])?k.splice(I,1):".."===S?(k.splice(I,1),A++):A&&(k.splice(I,1),A--);if(!w&&!x)for(;A--;A)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),M&&"/"!==k.join("/").substr(-1)&&k.push("");var j,C=""===k[0]||k[0]&&"/"===k[0].charAt(0);E&&(n.hostname=n.host=C?"":k.length?k.shift():"",(j=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=j.shift(),n.host=n.hostname=j.shift()));return(w=w||n.host&&k.length)&&!C&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),r.isNull(n.pathname)&&r.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},s.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":480,punycode:342,querystring:345}],480:[function(e,t,n){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],481:[function(e,t,n){(function(n){(function(){ /*! ut_metadata. MIT License. WebTorrent LLC */ -const{EventEmitter:i}=e("events"),r=e("bencode"),o=e("bitfield").default,s=e("debug")("ut_metadata"),a=e("simple-sha1"),c=16384;t.exports=e=>{class t extends i{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new o(0,{grow:1e3}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7this._metadataSize&&(n=this._metadataSize);const i=this.metadata.slice(t,n);this._data(e,i,this._metadataSize)}_onData(e,t,n){t.length>c||!this._fetching||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){if(this._fetching){this.metadata=n.alloc(this._metadataSize);for(let e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this)}).call(this,e("buffer").Buffer)},{bencode:7,bitfield:10,buffer:55,debug:304,events:97,"simple-sha1":244}],304:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":305,_process:189,dup:12}],305:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:306}],306:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],307:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],308:[function(e,t,n){(function(n){(function(){const i=e("binary-search"),r=e("events"),o=e("mp4-stream"),s=e("mp4-box-encoding"),a=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}const l=1;t.exports=class extends r{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=o.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const i=r=>{"moov"===r.type?(this._decoder.removeListener("box",i),this._decoder.decode((e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message=`Cannot parse mp4 file: ${e.message}`,this.emit("error",e)}}))):r.length<4096?(t+=r.length,this._decoder.ignore()):(this._decoder.removeListener("box",i),t+=r.length,n.destroy(),this._decoder.destroy(),this._findMoov(e+t))};this._decoder.on("box",i)}_processMoov(e){const t=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let n=0;n=o.stsz.entries.length)break;if(f++,m+=e,f>=i.samplesPerChunk){f=0,m=0,h++;const e=o.stsc.entries[g+1];e&&h+1>=e.firstChunk&&g++}v+=t,b.inc(),x&&x.inc(),r&&y++}r.mdia.mdhd.duration=0,r.tkhd.duration=0;const _=i.sampleDescriptionId,w={type:"moov",mvhd:e.mvhd,traks:[{tkhd:r.tkhd,mdia:{mdhd:r.mdia.mdhd,hdlr:r.mdia.hdlr,elng:r.mdia.elng,minf:{vmhd:r.mdia.minf.vmhd,smhd:r.mdia.minf.smhd,dinf:r.mdia.minf.dinf,stbl:{stsd:o.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:r.tkhd.trackId,defaultSampleDescriptionIndex:_,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:r.tkhd.trackId,timeScale:r.mdia.mdhd.timeScale,samples:u,currSample:null,currTime:null,moov:w,mime:p})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const r=s.encode(this._ftyp),o=this._tracks.map((e=>{const t=s.encode(e.moov);return{mime:e.mime,init:n.concat([r,t])}}));this.emit("ready",o)}seek(e){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let t=-1;if(this._tracks.map(((n,i)=>{n.outStream&&n.outStream.destroy(),n.inStream&&(n.inStream.destroy(),n.inStream=null);const r=n.outStream=o.encode(),s=this._generateFragment(i,e);if(!s)return r.finalize();(-1===t||s.ranges[0].start{r.destroyed||r.box(e.moof,(t=>{if(t)return this.emit("error",t);if(r.destroyed)return;n.inStream.slice(e.ranges).pipe(r.mediaData(e.length,(e=>{if(e)return this.emit("error",e);if(r.destroyed)return;const t=this._generateFragment(i);if(!t)return r.finalize();a(t)})))}))};a(s)})),t>=0){const e=this._fileStream=this._file.createReadStream({start:t});this._tracks.forEach((n=>{n.inStream=new a(t,{highWaterMark:1e7}),e.pipe(n.inStream)}))}return this._tracks.map((e=>e.outStream))}_findSampleBefore(e,t){const n=this._tracks[e],r=Math.floor(n.timeScale*t);let o=i(n.samples,r,((e,t)=>e.dts+e.presentationOffset-t));for(-1===o?o=0:o<0&&(o=-o-2);!n.samples[o].sync;)o--;return o}_generateFragment(e,t){const n=this._tracks[e];let i;if(i=void 0!==t?this._findSampleBefore(e,t):n.currSample,i>=n.samples.length)return null;const r=n.samples[i].dts;let o=0;const s=[];for(var a=i;a=n.timeScale*l)break;o+=e.size;const t=s.length-1;t<0||s[t].end!==e.offset?s.push({start:e.offset,end:e.offset+e.size}):s[t].end+=e.size}return n.currSample=a,{moof:this._generateMoof(e,i,a),ranges:s,length:o}}_generateMoof(e,t,n){const i=this._tracks[e],r=[];let o=0;for(let e=t;e{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},t.autoplay&&(t.preload="auto"),t.addEventListener("waiting",this._onWaiting),t.addEventListener("error",this._onError)}s.prototype={_createMuxer(){this._muxer=new o(this._file),this._muxer.on("ready",(e=>{this._tracks=e.map((e=>{const t=this._elemWrapper.createWriteStream(e.mime);t.on("error",(e=>{this._elemWrapper.error(e)}));const n={muxed:null,mediaSource:t,initFlushed:!1,onInitFlushed:null};return t.write(e.init,(e=>{n.initFlushed=!0,n.onInitFlushed&&n.onInitFlushed(e)})),n})),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()})),this._muxer.on("error",(e=>{this._elemWrapper.error(e)}))},_pump(){const e=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach(((t,n)=>{const i=()=>{t.muxed&&(t.muxed.destroy(),t.mediaSource=this._elemWrapper.createWriteStream(t.mediaSource),t.mediaSource.on("error",(e=>{this._elemWrapper.error(e)}))),t.muxed=e[n],r(t.muxed,t.mediaSource)};t.initFlushed?i():t.onInitFlushed=e=>{e?this._elemWrapper.error(e):i()}}))},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach((e=>{e.muxed&&e.muxed.destroy()})),this._elem.src="")}},t.exports=s},{"./mp4-remuxer":308,mediasource:127,pump:190}],310:[function(e,t,n){(function(n,i){(function(){ +const{EventEmitter:i}=e("events"),r=e("bencode"),s=e("bitfield").default,o=e("debug")("ut_metadata"),a=e("simple-sha1"),c=16384;t.exports=e=>{class t extends i{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new s(0,{grow:1e3}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7this._metadataSize&&(n=this._metadataSize);const i=this.metadata.slice(t,n);this._data(e,i,this._metadataSize)}_onData(e,t,n){t.length>c||!this._fetching||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){if(this._fetching){this.metadata=n.alloc(this._metadataSize);for(let e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this)}).call(this,e("buffer").Buffer)},{bencode:22,bitfield:25,buffer:114,debug:482,events:194,"simple-sha1":407}],482:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":483,_process:333,dup:27}],483:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:484}],484:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],485:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],486:[function(e,t,n){(function(n){(function(){const i=e("binary-search"),r=e("events"),s=e("mp4-stream"),o=e("mp4-box-encoding"),a=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}const u=1;t.exports=class extends r{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=s.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const i=r=>{"moov"===r.type?(this._decoder.removeListener("box",i),this._decoder.decode((e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message=`Cannot parse mp4 file: ${e.message}`,this.emit("error",e)}}))):r.length<4096?(t+=r.length,this._decoder.ignore()):(this._decoder.removeListener("box",i),t+=r.length,n.destroy(),this._decoder.destroy(),this._findMoov(e+t))};this._decoder.on("box",i)}_processMoov(e){const t=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let n=0;n=s.stsz.entries.length)break;if(p++,m+=e,p>=i.samplesPerChunk){p=0,m=0,h++;const e=s.stsc.entries[b+1];e&&h+1>=e.firstChunk&&b++}g+=t,v.inc(),y&&y.inc(),r&&_++}r.mdia.mdhd.duration=0,r.tkhd.duration=0;const w=i.sampleDescriptionId,x={type:"moov",mvhd:e.mvhd,traks:[{tkhd:r.tkhd,mdia:{mdhd:r.mdia.mdhd,hdlr:r.mdia.hdlr,elng:r.mdia.elng,minf:{vmhd:r.mdia.minf.vmhd,smhd:r.mdia.minf.smhd,dinf:r.mdia.minf.dinf,stbl:{stsd:s.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:r.tkhd.trackId,defaultSampleDescriptionIndex:w,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:r.tkhd.trackId,timeScale:r.mdia.mdhd.timeScale,samples:d,currSample:null,currTime:null,moov:x,mime:l})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const r=o.encode(this._ftyp),s=this._tracks.map((e=>{const t=o.encode(e.moov);return{mime:e.mime,init:n.concat([r,t])}}));this.emit("ready",s)}seek(e){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let t=-1;if(this._tracks.map(((n,i)=>{n.outStream&&n.outStream.destroy(),n.inStream&&(n.inStream.destroy(),n.inStream=null);const r=n.outStream=s.encode(),o=this._generateFragment(i,e);if(!o)return r.finalize();(-1===t||o.ranges[0].start{r.destroyed||r.box(e.moof,(t=>{if(t)return this.emit("error",t);if(r.destroyed)return;n.inStream.slice(e.ranges).pipe(r.mediaData(e.length,(e=>{if(e)return this.emit("error",e);if(r.destroyed)return;const t=this._generateFragment(i);if(!t)return r.finalize();a(t)})))}))};a(o)})),t>=0){const e=this._fileStream=this._file.createReadStream({start:t});this._tracks.forEach((n=>{n.inStream=new a(t,{highWaterMark:1e7}),e.pipe(n.inStream)}))}return this._tracks.map((e=>e.outStream))}_findSampleBefore(e,t){const n=this._tracks[e],r=Math.floor(n.timeScale*t);let s=i(n.samples,r,((e,t)=>e.dts+e.presentationOffset-t));for(-1===s?s=0:s<0&&(s=-s-2);!n.samples[s].sync;)s--;return s}_generateFragment(e,t){const n=this._tracks[e];let i;if(i=void 0!==t?this._findSampleBefore(e,t):n.currSample,i>=n.samples.length)return null;const r=n.samples[i].dts;let s=0;const o=[];for(var a=i;a=n.timeScale*u)break;s+=e.size;const t=o.length-1;t<0||o[t].end!==e.offset?o.push({start:e.offset,end:e.offset+e.size}):o[t].end+=e.size}return n.currSample=a,{moof:this._generateMoof(e,i,a),ranges:o,length:s}}_generateMoof(e,t,n){const i=this._tracks[e],r=[];let s=0;for(let e=t;e{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},t.autoplay&&(t.preload="auto"),t.addEventListener("waiting",this._onWaiting),t.addEventListener("error",this._onError)}o.prototype={_createMuxer(){this._muxer=new s(this._file),this._muxer.on("ready",(e=>{this._tracks=e.map((e=>{const t=this._elemWrapper.createWriteStream(e.mime);t.on("error",(e=>{this._elemWrapper.error(e)}));const n={muxed:null,mediaSource:t,initFlushed:!1,onInitFlushed:null};return t.write(e.init,(e=>{n.initFlushed=!0,n.onInitFlushed&&n.onInitFlushed(e)})),n})),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()})),this._muxer.on("error",(e=>{this._elemWrapper.error(e)}))},_pump(){const e=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach(((t,n)=>{const i=()=>{t.muxed&&(t.muxed.destroy(),t.mediaSource=this._elemWrapper.createWriteStream(t.mediaSource),t.mediaSource.on("error",(e=>{this._elemWrapper.error(e)}))),t.muxed=e[n],r(t.muxed,t.mediaSource)};t.initFlushed?i():t.onInitFlushed=e=>{e?this._elemWrapper.error(e):i()}}))},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach((e=>{e.muxed&&e.muxed.destroy()})),this._elem.src="")}},t.exports=o},{"./mp4-remuxer":486,mediasource:256,pump:341}],488:[function(e,t,n){(function(n,i){(function(){ /*! webtorrent. MIT License. WebTorrent LLC */ -const{EventEmitter:r}=e("events"),o=e("simple-concat"),s=e("create-torrent"),a=e("debug")("webtorrent"),c=e("bittorrent-dht/client"),l=e("load-ip-set"),p=e("run-parallel"),u=e("parse-torrent"),d=e("path"),f=e("simple-peer"),h=e("randombytes"),m=e("speedometer"),g=e("queue-microtask"),v=e("./lib/conn-pool"),b=e("./lib/torrent"),x=e("./package.json").version,y=x.replace(/\d*./g,(e=>("0"+e%100).slice(-2))).slice(0,4),_=`-WW${y}-`;class w extends r{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:i.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=i.from(_+h(9).toString("base64")).toString("hex"),this.peerIdBuffer=i.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:i.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=h(20).toString("hex"),this.nodeIdBuffer=i.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.lsd=!1!==e.lsd,this.torrents=[],this.maxConns=Number(e.maxConns)||55,this.utp=!0===e.utp,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),n.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=n.WRTC)),"function"==typeof v?this._connPool=new v(this):g((()=>{this._onListening()})),this._downloadSpeed=m(),this._uploadSpeed=m(),!1!==e.dht&&"function"==typeof c?(this.dht=new c(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",(e=>{this._destroy(e)})),this.dht.once("listening",(()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)})),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof l&&null!=e.blocklist?l(e.blocklist,{headers:{"user-agent":`WebTorrent/${x} (https://webtorrent.io)`}},((e,n)=>{if(e)return this.error(`Failed to load blocklist: ${e.message}`);this.blocked=n,t()})):g(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter((e=>1!==e.progress));return e.reduce(((e,t)=>e+t.downloaded),0)/(e.reduce(((e,t)=>e+(t.length||0)),0)||1)}get ratio(){return this.torrents.reduce(((e,t)=>e+t.uploaded),0)/(this.torrents.reduce(((e,t)=>e+t.received),0)||1)}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=u(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n=(()=>{})){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const i=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===o.infoHash&&e!==o)return void o._destroy(new Error(`Cannot add duplicate torrent ${o.infoHash}`))},r=()=>{this.destroyed||(n(o),this.emit("torrent",o))};this._debug("add"),t=t?Object.assign({},t):{};const o=new b(e,this,t);return this.torrents.push(o),o.once("_infoHash",i),o.once("ready",r),o.once("close",(function e(){o.removeListener("_infoHash",i),o.removeListener("ready",r),o.removeListener("close",e)})),o}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const i="string"==typeof e;i&&(t.path=d.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${y}`);const r=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},a=this.add(null,t,(e=>{const n=[n=>{if(i||t.preloadedStore)return n();e.load(c,n)}];this.dht&&n.push((t=>{e.once("dhtAnnounce",t)})),p(n,(t=>{if(!this.destroyed)return t?e._destroy(t):void r(e)}))}));let c;var l;return l=e,"undefined"!=typeof FileList&&l instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),p(e.map((e=>n=>{!t.preloadedStore&&function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?o(e,((t,i)=>{if(t)return n(t);i.name=e.name,n(null,i)})):n(null,e)})),((e,n)=>{if(!this.destroyed)return e?a._destroy(e):void s.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return a._destroy(e);c=i.map((e=>e.getStream)),s(n,t,((e,t)=>{if(this.destroyed)return;if(e)return a._destroy(e);const n=this.get(t);n?a._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):a._onTorrentId(t)}))}}))})),a}remove(e,t,n){if("function"==typeof t)return this.remove(e,null,t);this._debug("remove");if(!this.get(e))throw new Error(`No torrent with id ${e}`);this._remove(e,t,n)}_remove(e,t,n){if("function"==typeof t)return this._remove(e,null,t);const i=this.get(e);i&&(this.torrents.splice(this.torrents.indexOf(i),1),i.destroy(t,n))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map((e=>t=>{e.destroy(t)}));this._connPool&&n.push((e=>{this._connPool.destroy(e)})),this.dht&&n.push((e=>{this.dht.destroy(e)})),p(n,t),e&&this.emit("error",e),this.torrents=[],this._connPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._connPool){const e=this._connPool.tcpServer.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,a(...e)}}w.WEBRTC_SUPPORT=f.WEBRTC_SUPPORT,w.VERSION=x,t.exports=w}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./lib/conn-pool":54,"./lib/torrent":315,"./package.json":335,"bittorrent-dht/client":54,buffer:55,"create-torrent":79,debug:317,events:97,"load-ip-set":54,"parse-torrent":186,path:187,"queue-microtask":195,randombytes:197,"run-parallel":220,"simple-concat":223,"simple-peer":225,speedometer:265}],311:[function(e,t,n){const i=e("debug")("webtorrent:file-stream"),r=e("readable-stream");class o extends r.Readable{constructor(e,t){super(t),this.destroyed=!1,this._torrent=e._torrent;const n=t&&t.start||0,i=t&&t.end&&t.end{if(this._notifying=!1,!this.destroyed){if(i("read %s (length %s) (err %s)",e,n&&n.length,t&&t.message),t)return this._destroy(t);this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing{const o=r===e.length-1?i:n;return t.get(r)?o:o-e[r].missing};let a=0;for(let t=r;t<=o;t+=1){const c=s(t);if(a+=c,t===r){const e=this.offset%n;a-=Math.min(e,c)}if(t===o){const t=(o===e.length-1?i:n)-(this.offset+this.length)%n;a-=Math.min(t,c)}}return a}get progress(){return this.length?this.downloaded/this.length:0}select(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)}deselect(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)}createReadStream(e){if(0===this.length){const e=new r;return d((()=>{e.end()})),e}const t=new u(this,e);return this._torrent.select(t._startPiece,t._endPiece,!0,(()=>{t._notify()})),o(t,(()=>{this._destroyed||this._torrent.destroyed||this._torrent.deselect(t._startPiece,t._endPiece,!0)})),t}getBuffer(e){p(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");c(this.createReadStream(),this._getMimeType()).then((t=>e(null,t)),(t=>e(t)))}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");l(this.createReadStream(),this._getMimeType()).then((t=>e(null,t)),(t=>e(t)))}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");a.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");a.render(this,e,t,n)}_getMimeType(){return a.mime[s.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}},{"./file-stream":311,"end-of-stream":95,events:97,path:187,"queue-microtask":195,"readable-stream":334,"render-media":214,"stream-to-blob":286,"stream-to-blob-url":285,"stream-with-known-length-to-buffer":287}],313:[function(e,t,n){const i=e("unordered-array-remove"),r=e("debug")("webtorrent:peer"),o=e("bittorrent-protocol");n.createWebRTCPeer=(e,t)=>{const n=new c(e.id,"webrtc");if(n.conn=e,n.swarm=t,n.conn.connected)n.onConnect();else{const e=()=>{n.conn.removeListener("connect",t),n.conn.removeListener("error",i)},t=()=>{e(),n.onConnect()},i=t=>{e(),n.destroy(t)};n.conn.once("connect",t),n.conn.once("error",i),n.startConnectTimeout()}return n},n.createTCPIncomingPeer=e=>s(e,"tcpIncoming"),n.createUTPIncomingPeer=e=>s(e,"utpIncoming"),n.createTCPOutgoingPeer=(e,t)=>a(e,t,"tcpOutgoing"),n.createUTPOutgoingPeer=(e,t)=>a(e,t,"utpOutgoing");const s=(e,t)=>{const n=`${e.remoteAddress}:${e.remotePort}`,i=new c(n,t);return i.conn=e,i.addr=n,i.onConnect(),i},a=(e,t,n)=>{const i=new c(e,n);return i.addr=e,i.swarm=t,i};n.createWebSeedPeer=(e,t,n)=>{const i=new c(t,"webSeed");return i.swarm=n,i.conn=e,i.onConnect(),i};class c{constructor(e,t){this.id=e,this.type=t,r("new %s Peer %s",t,e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}onConnect(){if(this.destroyed)return;this.connected=!0,r("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",(()=>{this.destroy()})),e.once("close",(()=>{this.destroy()})),e.once("finish",(()=>{this.destroy()})),e.once("error",(e=>{this.destroy(e)}));const t=this.wire=new o;t.type=this.type,t.once("end",(()=>{this.destroy()})),t.once("close",(()=>{this.destroy()})),t.once("finish",(()=>{this.destroy()})),t.once("error",(e=>{this.destroy(e)})),t.once("handshake",((e,t)=>{this.onHandshake(e,t)})),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));r("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout);const e={webrtc:25e3,tcpOutgoing:5e3,utpOutgoing:5e3};this.connectTimeout=setTimeout((()=>{this.destroy(new Error("connect timeout"))}),e[this.type]),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout((()=>{this.destroy(new Error("handshake timeout"))}),25e3),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,r("destroy %s %s (error: %s)",this.type,this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,o=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&o&&i(t.wires,t.wires.indexOf(o)),n&&(n.on("error",(()=>{})),n.destroy()),o&&o.destroy(),t&&t.removePeer(this.id)}}},{"bittorrent-protocol":11,debug:317,"unordered-array-remove":300}],314:[function(e,t,n){t.exports=class{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=new Array(this._numPieces),this._onWire=e=>{this.recalculate(),this._initWire(e)},this._onWireHave=e=>{this._pieces[e]+=1},this._onWireBitfield=()=>{this.recalculate()},this._torrent.wires.forEach((e=>{this._initWire(e)})),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let i=0;i{this._cleanupWireEvents(e)})),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=()=>{this._cleanupWireEvents(e);for(let t=0;t{this.destroyed||this._onParsedTorrent(t)}))):_.remote(e,((e,t)=>{if(!this.destroyed)return e?this._destroy(e):void this._onParsedTorrent(t)}))}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));this.path||(this.path=w.join(F,this.infoHash)),this._rechokeIntervalId=setInterval((()=>{this._rechoke()}),1e4),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),this.destroyed||(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",(()=>{this._onListening()}))))}}_processParsedTorrent(e){this._debugId=e.infoHash.toString("hex").substring(0,7),void 0!==this.private&&(e.private=this.private),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&i.WEBTORRENT_ANNOUNCE&&!e.private&&(e.announce=e.announce.concat(i.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),e.announce=Array.from(new Set(e.announce)),e.urlList=Array.from(new Set(e.urlList)),Object.assign(this,e),this.magnetURI=_.toMagnetURI(e),this.torrentFile=_.toTorrentFile(e)}_onListening(){this.destroyed||(this.info?this._onMetadata(this):(this.xs&&this._getMetadataFromServer(),this._startDiscovery()))}_startDiscovery(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{if(this.destroyed)return;const e={uploaded:this.uploaded,downloaded:this.downloaded,left:Math.max(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.peerAddresses&&this.peerAddresses.forEach((e=>this.addPeer(e))),this.discovery=new l({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:H,lsd:this.client.lsd}),this.discovery.on("error",(e=>{this._destroy(e)})),this.discovery.on("peer",((e,t)=>{this._debug("peer %s discovered via %s",e,t),"string"==typeof e&&this.done||this.addPeer(e)})),this.discovery.on("trackerAnnounce",(()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")})),this.discovery.on("dhtAnnounce",(()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")})),this.discovery.on("warning",(e=>{this.emit("warning",e)}))}_getMetadataFromServer(){const e=this,t=(Array.isArray(this.xs)?this.xs:[this.xs]).map((t=>n=>{!function(t,n){if(0!==t.indexOf("http://")&&0!==t.indexOf("https://"))return e.emit("warning",new Error(`skipping non-http xs param: ${t}`)),n(null);const i={url:t,method:"GET",headers:{"user-agent":H}};let r;try{r=f.concat(i,o)}catch(i){return e.emit("warning",new Error(`skipping invalid url xs param: ${t}`)),n(null)}function o(i,r,o){if(e.destroyed)return n(null);if(e.metadata)return n(null);if(i)return e.emit("warning",new Error(`http error from xs param: ${t}`)),n(null);if(200!==r.statusCode)return e.emit("warning",new Error(`non-200 status code ${r.statusCode} from xs param: ${t}`)),n(null);let s;try{s=_(o)}catch(i){}return s?s.infoHash!==e.infoHash?(e.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${t}`)),n(null)):(e._onMetadata(s),void n(null)):(e.emit("warning",new Error(`got invalid torrent file from xs param: ${t}`)),n(null))}e._xsRequests.push(r)}(t,n)}));x(t)}_onMetadata(e){if(this.metadata||this.destroyed)return;let t;if(this._debug("got metadata"),this._xsRequests.forEach((e=>{e.abort()})),this._xsRequests=[],e&&e.infoHash)t=e;else try{t=_(e)}catch(e){return this._destroy(e)}if(this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach((e=>{this.addWebSeed(e)})),this._rarityMap=new B(this),this.store=new h(this._preloadedStore||new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map((e=>({path:w.join(this.path,e.path),length:e.length,offset:e.offset}))),length:this.length,name:this.infoHash})),this.files=this.files.map((e=>new R(this,e))),this.so?this.files.forEach(((e,t)=>{this.so.includes(t)?this.files[t].select():this.files[t].deselect()})):0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1),this._hashes=this.pieces,this.pieces=this.pieces.map(((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new k(n)})),this._reservations=this.pieces.map((()=>[])),this.bitfield=new o(this.pieces.length),this.wires.forEach((e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)})),this.emit("metadata"),!this.destroyed)if(this.skipVerify)this._markAllVerified(),this._onStore();else{const e=e=>{if(e)return this._destroy(e);this._debug("done verifying"),this._onStore()};this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===d?this.getFileModtimes(((t,n)=>{if(t)return this._destroy(t);this.files.map(((e,t)=>n[t]===this._fileModtimes[t])).every((e=>e))?(this._markAllVerified(),this._onStore()):this._verifyPieces(e)})):this._verifyPieces(e)}}getFileModtimes(e){const t=[];y(this.files.map(((e,n)=>i=>{u.stat(w.join(this.path,e.path),((e,r)=>{if(e&&"ENOENT"!==e.code)return i(e);t[n]=r&&r.mtime.getTime(),i(null)}))})),D,(n=>{this._debug("done getting file modtimes"),e(n,t)}))}_verifyPieces(e){y(this.pieces.map(((e,t)=>e=>{if(this.destroyed)return e(new Error("torrent is destroyed"));const n={};t===this.pieces.length-1&&(n.length=this.lastPieceLength),this.store.get(t,n,((n,i)=>this.destroyed?e(new Error("torrent is destroyed")):n?S((()=>e(null))):void T(i,(n=>{if(this.destroyed)return e(new Error("torrent is destroyed"));n===this._hashes[t]?(this._debug("piece verified %s",t),this._markVerified(t)):this._debug("piece invalid %s",t),e(null)}))))})),D,e)}rescanFiles(e){if(this.destroyed)throw new Error("torrent is destroyed");e||(e=W),this._verifyPieces((t=>{if(t)return this._destroy(t),e(t);this._checkDone(),e(null)}))}_markAllVerified(){for(let e=0;e{e.abort()})),this._rarityMap&&this._rarityMap.destroy();for(const e in this._peers)this.removePeer(e);this.files.forEach((e=>{e instanceof R&&e._destroy()}));const i=this._servers.map((e=>t=>{e.destroy(t)}));if(this.discovery&&i.push((e=>{this.discovery.destroy(e)})),this.store){let e=this._destroyStoreOnDestroy;t&&void 0!==t.destroyStore&&(e=t.destroyStore),i.push((t=>{e?this.store.destroy(t):this.store.close(t)}))}x(i,n),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}addPeer(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let t;if("string"==typeof e){let n;try{n=r(e)}catch(t){return this._debug("ignoring peer: invalid %s",e),this.emit("invalidPeer",e),!1}t=n[0]}else"string"==typeof e.remoteAddress&&(t=e.remoteAddress);if(t&&this.client.blocked.contains(t))return this._debug("ignoring peer: blocked %s",e),"string"!=typeof e&&e.destroy(),this.emit("blockedPeer",e),!1}const t=!!this._addPeer(e,this.client.utp?"utp":"tcp");return t?this.emit("peer",e):this.emit("invalidPeer",e),t}_addPeer(e,t){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;const n=e&&e.id||e;if(this._peers[n])return this._debug("ignoring peer: duplicate (%s)",n),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;let i;return this._debug("add peer %s",n),i="string"==typeof e?"utp"===t?O.createUTPOutgoingPeer(e,this):O.createTCPOutgoingPeer(e,this):O.createWebRTCPeer(e,this),this._peers[i.id]=i,this._peersLength+=1,"string"==typeof e&&(this._queue.push(i),this._drain()),i}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");let t,n;if("string"==typeof e){if(t=e,!/^https?:\/\/.+/.test(t))return this.emit("warning",new Error(`ignoring invalid web seed: ${t}`)),void this.emit("invalidPeer",t);if(this._peers[t])return this.emit("warning",new Error(`ignoring duplicate web seed: ${t}`)),void this.emit("invalidPeer",t);n=new P(t,this)}else{if(!e||"string"!=typeof e.connId)return void this.emit("warning",new Error("addWebSeed must be passed a string or connection object with id property"));if(n=e,t=n.connId,this._peers[t])return this.emit("warning",new Error(`ignoring duplicate web seed: ${t}`)),void this.emit("invalidPeer",t)}this._debug("add web seed %s",t);const i=O.createWebSeedPeer(n,t,this);this._peers[i.id]=i,this._peersLength+=1,this.emit("peer",t)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,void(this._peersLength+=1))}removePeer(e){const t=e&&e.id||e;(e=this._peers[t])&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,i){if(this.destroyed)throw new Error("torrent is destroyed");if(e<0||tt.priority-e.priority)),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=Number(n)||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let i=0;i{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.destroyed||this.client.emit("download",e))})),e.on("upload",(e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.destroyed||this.client.emit("upload",e))})),this.wires.push(e),t){const n=r(t);e.remoteAddress=n[0],e.remotePort=n[1]}this.client.dht&&this.client.dht.listening&&e.on("port",(n=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!e.remoteAddress)return this._debug("ignoring PORT from peer with no address");if(0===n||n>65536)return this._debug("ignoring invalid PORT from peer");this._debug("port: %s (from %s)",n,t),this.client.dht.addNode({host:e.remoteAddress,port:n})}})),e.on("timeout",(()=>{this._debug("wire timeout (%s)",t),e.destroy()})),"webSeed"!==e.type&&e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(A(this.metadata)),e.ut_metadata.on("warning",(e=>{this._debug("ut_metadata warning: %s",e.message)})),this.metadata||(e.ut_metadata.on("metadata",(e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)})),e.ut_metadata.fetch()),"function"!=typeof I||this.private||(e.use(I()),e.ut_pex.on("peer",(e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,t),this.addPeer(e))})),e.ut_pex.on("dropped",(e=>{const n=this._peers[e];n&&!n.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,t),this.removePeer(e))})),e.once("close",(()=>{e.ut_pex.reset()}))),e.use(m()),this.emit("wire",e,t),this.metadata&&S((()=>{this._onWireWithMetadata(e)}))}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,M),t.unref&&t.unref()))};let i;const r=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(i=0;i{r(),this._update(),this._updateWireInterest(e)})),e.on("have",(()=>{r(),this._update(),this._updateWireInterest(e)})),e.lt_donthave.on("donthave",(()=>{r(),this._update(),this._updateWireInterest(e)})),e.once("interested",(()=>{e.unchoke()})),e.once("close",(()=>{clearTimeout(t)})),e.on("choke",(()=>{clearTimeout(t),t=setTimeout(n,M),t.unref&&t.unref()})),e.on("unchoke",(()=>{clearTimeout(t),this._update()})),e.on("request",((t,n,i,r)=>{if(i>131072)return e.destroy();this.pieces[t]||this.store.get(t,{offset:n,length:i},r)})),e.bitfield(this.bitfield),this._updateWireInterest(e),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,M),t.unref&&t.unref()),e.isSeeder=!1,r()}_updateSelections(){this.ready&&!this.destroyed&&(S((()=>{this._gcSelections()})),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;ethis._updateWireInterest(e))),e!==this._amInterested&&(this._amInterested?this.emit("interested"):this.emit("uninterested"))}_updateWireInterest(e){let t=!1;for(let n=0;n=i.from+i.offset;--o)if(e.peerPieces.get(o)&&t._request(e,o,!1))return}}();const n=z(e,.5);if(e.requests.length>=n)return;const i=z(e,1);function r(t,n,i,r){return o=>o>=t&&o<=n&&!(o in i)&&e.peerPieces.get(o)&&(!r||r(o))}function o(e){let n=e;for(let i=e;i=i)return!0;const s=function(){const n=e.downloadSpeed()||1;if(n>N)return()=>!0;const i=Math.max(1,e.requests.length)*k.BLOCK_LENGTH/n;let r=10,o=0;return e=>{if(!r||t.bitfield.get(e))return!0;let s=t.pieces[e].missing;for(;o0))return r--,!1}return!0}}();for(let a=0;a({wire:e,random:Math.random()}))).sort(((e,t)=>{const n=e.wire,i=t.wire;return n.downloadSpeed()!==i.downloadSpeed()?n.downloadSpeed()-i.downloadSpeed():n.uploadSpeed()!==i.uploadSpeed()?n.uploadSpeed()-i.uploadSpeed():n.amChoking!==i.amChoking?n.amChoking?-1:1:e.random-t.random})).map((e=>e.wire));this._rechokeOptimisticTime<=0?this._rechokeOptimisticWire=null:this._rechokeOptimisticTime-=1;let t=0;for(;e.length>0&&t0){const t=e.filter((e=>e.peerInterested));if(t.length>0){const e=t[(n=t.length,Math.random()*n|0)];e.unchoke(),this._rechokeOptimisticWire=e,this._rechokeOptimisticTime=2}}var n;e.filter((e=>e!==this._rechokeOptimisticWire)).forEach((e=>e.choke()))}_hotswap(e,t){const n=e.downloadSpeed();if(n=N||(2*a>n||a>s||(r=t,s=a))}if(!r)return!1;for(o=0;o=(o?Math.min(function(e,t,n){return 1+Math.ceil(t*e.downloadSpeed()/n)}(e,1,i.pieceLength),i.maxWebConns):z(e,1)))return!1;const s=i.pieces[t];let a=o?s.reserveRemaining():s.reserve();if(-1===a&&n&&i._hotswap(e,t)&&(a=o?s.reserveRemaining():s.reserve()),-1===a)return!1;let c=i._reservations[t];c||(c=i._reservations[t]=[]);let l=c.indexOf(null);-1===l&&(l=c.length),c[l]=e;const p=s.chunkOffset(a),u=o?s.chunkLengthRemaining(a):s.chunkLength(a);function d(){S((()=>{i._update()}))}return e.request(t,p,u,(function n(r,f){if(i.destroyed)return;if(!i.ready)return i.once("ready",(()=>{n(r,f)}));if(c[l]===e&&(c[l]=null),s!==i.pieces[t])return d();if(r)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,p,u,`${e.remoteAddress}:${e.remotePort}`,r.message),o?s.cancelRemaining(a):s.cancel(a),void d();if(i._debug("got piece %s (offset: %s length: %s) from %s",t,p,u,`${e.remoteAddress}:${e.remotePort}`),!s.set(a,f,e))return d();const h=s.flush();T(h,(e=>{if(!i.destroyed){if(e===i._hashes[t]){if(!i.pieces[t])return;i._debug("piece verified %s",t),i.pieces[t]=null,i._reservations[t]=null,i.bitfield.set(t,!0),i.store.put(t,h,(e=>{e&&i._destroy(e)})),i.wires.forEach((e=>{e.have(t)})),i._checkDone()&&!i.destroyed&&i.discovery.complete()}else i.pieces[t]=new k(s.length),i.emit("warning",new Error(`Piece ${t} failed verification`));d()}}))})),!0}_checkDone(){if(this.destroyed)return;this.files.forEach((e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}}));let e=!0;for(let t=0;t{this.load(e,t)}));Array.isArray(e)||(e=[e]),t||(t=W);const n=new g(e),i=new s(this.store,this.pieceLength);E(n,i,(e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)}))}createServer(e){if("function"!=typeof U)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new U(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client?this.client._debugId:"No Client"}] [${this._debugId}] ${e[0]}`,c(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof v.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("%s connect attempt to %s",e.type,e.addr);const t=r(e.addr),n={host:t[0],port:t[1]};"utpOutgoing"===e.type?e.conn=L.connect(n.port,n.host):e.conn=v.connect(n);const i=e.conn;i.once("connect",(()=>{e.onConnect()})),i.once("error",(t=>{e.destroy(t)})),e.startConnectTimeout(),i.on("close",(()=>{if(this.destroyed)return;if(e.retries>=q.length){if(this.client.utp){const t=this._addPeer(e.addr,"tcp");t&&(t.retries=0)}else this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,q.length);return}const t=q[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout((()=>{if(this.destroyed)return;const t=this._addPeer(e.addr,this.client.utp?"utp":"tcp");t&&(t.retries=e.retries+1)}),t);n.unref&&n.unref()}))}_validAddr(e){let t;try{t=r(e)}catch(e){return!1}const n=t[0],i=t[1];return i>0&&i<65535&&!("127.0.0.1"===n&&i===this.client.torrentPort)}}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../package.json":335,"./file":312,"./peer":313,"./rarity-map":314,"./server":54,"./webconn":316,_process:189,"addr-to-ip-port":3,bitfield:10,"chunk-store-stream/write":76,cpus:78,debug:317,events:97,fs:54,"fs-chunk-store":143,"immediate-chunk-store":117,lt_donthave:122,multistream:168,net:54,os:54,"parse-torrent":186,path:187,pump:190,"queue-microtask":195,"random-iterate":196,"run-parallel":220,"run-parallel-limit":219,"simple-get":224,"simple-sha1":244,speedometer:265,"torrent-discovery":293,"torrent-piece":297,ut_metadata:303,ut_pex:54,"utp-native":54}],316:[function(e,t,n){(function(n){(function(){const i=e("bitfield").default,r=e("debug")("webtorrent:webconn"),o=e("simple-get"),s=e("lt_donthave"),a=e("simple-sha1"),c=e("bittorrent-protocol"),l=e("../package.json").version;t.exports=class extends c{constructor(e,t){super(),this.url=e,this.connId=e,this.webPeerId=a.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.use(s()),this.once("handshake",((e,t)=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const n=this._torrent.pieces.length,r=new i(n);for(let e=0;e<=n;e++)r.set(e,!0);this.bitfield(r)})),this.once("interested",(()=>{r("interested"),this.unchoke()})),this.on("uninterested",(()=>{r("uninterested")})),this.on("choke",(()=>{r("choke")})),this.on("unchoke",(()=>{r("unchoke")})),this.on("bitfield",(()=>{r("bitfield")})),this.lt_donthave.on("donthave",(()=>{r("donthave")})),this.on("request",((e,t,n,i)=>{r("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,((t,n)=>{if(t){this.lt_donthave.donthave(e);const t=setTimeout((()=>{this.destroyed||this.have(e)}),1e4);t.unref&&t.unref()}i(t,n)}))}))}httpRequest(e,t,i,s){const a=e*this._torrent.pieceLength+t,c=a+i-1,p=this._torrent.files;let u;if(p.length<=1)u=[{url:this.url,start:a,end:c}];else{const e=p.filter((e=>e.offset<=c&&e.offset+e.length>a));if(e.length<1)return s(new Error("Could not find file corresponding to web seed range request"));u=e.map((e=>{const t=e.offset+e.length-1;return{url:this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path,fileOffsetInRange:Math.max(e.offset-a,0),start:Math.max(a-e.offset,0),end:Math.min(t,c-e.offset)}}))}let d,f=0,h=!1;u.length>1&&(d=n.alloc(i)),u.forEach((n=>{const a=n.url,c=n.start,p=n.end;r("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,i,c,p);const m={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${l} (https://webtorrent.io)`,range:`bytes=${c}-${p}`},timeout:6e4};function g(e,t){if(e.statusCode<200||e.statusCode>=300){if(h)return;return h=!0,s(new Error(`Unexpected HTTP status code ${e.statusCode}`))}r("Got data of length %d",t.length),1===u.length?s(null,t):(t.copy(d,n.fileOffsetInRange),++f===u.length&&s(null,d))}o.concat(m,((e,t,n)=>{if(!h)return e?"undefined"==typeof window||a.startsWith(`${window.location.origin}/`)?(h=!0,s(e)):o.head(a,((t,n)=>{if(!h){if(t)return h=!0,s(t);if(n.statusCode<200||n.statusCode>=300)return h=!0,s(new Error(`Unexpected HTTP status code ${n.statusCode}`));if(n.url===a)return h=!0,s(e);m.url=n.url,o.concat(m,((e,t,n)=>{if(!h)return e?(h=!0,s(e)):void g(t,n)}))}})):void g(t,n)}))}))}destroy(){super.destroy(),this._torrent=null}}}).call(this)}).call(this,e("buffer").Buffer)},{"../package.json":335,bitfield:10,"bittorrent-protocol":11,buffer:55,debug:317,lt_donthave:122,"simple-get":224,"simple-sha1":244}],317:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":318,_process:189,dup:12}],318:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:319}],319:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],320:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],321:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":323,"./_stream_writable":325,_process:189,dup:16,inherits:118}],322:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":324,dup:17,inherits:118}],323:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":320,"./_stream_duplex":321,"./internal/streams/async_iterator":326,"./internal/streams/buffer_list":327,"./internal/streams/destroy":328,"./internal/streams/from":330,"./internal/streams/state":332,"./internal/streams/stream":333,_process:189,buffer:55,dup:18,events:97,inherits:118,"string_decoder/":288,util:54}],324:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":320,"./_stream_duplex":321,dup:19,inherits:118}],325:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":320,"./_stream_duplex":321,"./internal/streams/destroy":328,"./internal/streams/state":332,"./internal/streams/stream":333,_process:189,buffer:55,dup:20,inherits:118,"util-deprecate":307}],326:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":329,_process:189,dup:21}],327:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:55,dup:22,util:54}],328:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:189,dup:23}],329:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":320,dup:24}],330:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],331:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":320,"./end-of-stream":329,dup:26}],332:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":320,dup:27}],333:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],334:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":321,"./lib/_stream_passthrough.js":322,"./lib/_stream_readable.js":323,"./lib/_stream_transform.js":324,"./lib/_stream_writable.js":325,"./lib/internal/streams/end-of-stream.js":329,"./lib/internal/streams/pipeline.js":331,dup:29}],335:[function(e,t,n){t.exports={version:"1.0.0"}},{}],336:[function(e,t,n){t.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){i[e]=t[e]})),i;function i(){for(var e=new Array(arguments.length),n=0;n1080?(N.setProps({placement:"right"}),D.setProps({placement:"right"}),q.setProps({placement:"right"})):(N.setProps({placement:"top"}),D.setProps({placement:"top"}),q.setProps({placement:"top"}))}function W(e){X();try{console.info("Attempting parse"),u=r(e),V(),u.xs&&(console.info("Magnet includes xs, attempting remote parse"),$(u.xs))}catch(t){console.warn(t),"magnet"==p?(console.info("Attempting remote parse"),$(e)):(F.error("Problem parsing input. Is this a .torrent file?"),console.error("Problem parsing input"))}}function $(e){r.remote(e,(function(e,t){if(e)return F.error("Problem remotely fetching that file or parsing result"),console.warn(e),void X();p="remote-torrent-file",v.innerHTML='',b.setContent("Currently loaded information sourced from remotely fetched Torrent file"),u=t,V()}))}function V(){if(console.log(u),E.value=u.infoHash,x.value=u.name?u.name:"",u.created?(_.value=u.created.toISOString().slice(0,19),_.type="datetime-local"):_.type="text",w.value=u.createdBy?"by "+u.createdBy:"",k.value=u.comment?u.comment:"",j.innerHTML="",u.announce&&u.announce.length)for(let e=0;e',i.addEventListener("click",Q),t.appendChild(i),j.appendChild(t)}if(A.innerHTML="",u.urlList&&u.urlList.length)for(let e=0;e',i.addEventListener("click",Q),t.appendChild(i),A.appendChild(t)}if(R.innerHTML="",u.files&&u.files.length){if(O.style.display="none",u.files.length<100)for(let e of u.files){let t=Y(a.lookup(e.name));R.appendChild(G(t,e.name,e.length))}else{for(let e=0;e<100;e++){let t=Y(a.lookup(u.files[e].name));R.appendChild(G(t,u.files[e].name,u.files[e].length))}R.appendChild(G("","...and another "+(u.files.length-100)+" more files",""))}R.appendChild(G("folder-tree","",u.length)),q.setContent("Download Torrent file"),M.addEventListener("click",ie),M.disabled=!1}else H.torrents.length>0?(O.style.display="none",R.innerHTML=''):(O.style.display="block",R.innerHTML=''),q.setContent("Files metadata is required to generate a Torrent file. Try fetching files list from WebTorrent."),M.removeEventListener("click",ie),M.disabled=!0;B.setAttribute("data-clipboard-text",window.location.origin+"#"+r.toMagnetURI(u)),U.setAttribute("data-clipboard-text",r.toMagnetURI(u)),d.style.display="none",g.style.display="flex",window.location.hash=r.toMagnetURI(u),u.name?document.title="Torrent Parts | "+u.name:document.title="Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link",b.enable(),gtag("event","view_item",{items:[{item_id:u.infoHash,item_name:u.name,item_category:p}]})}function G(e,t,n){let i=document.createElement("tr"),r=document.createElement("td");e&&(r.innerHTML=''),i.appendChild(r);let o=document.createElement("td");o.innerHTML=t,i.appendChild(o);let a=document.createElement("td");return a.innerHTML=s.format(n,{decimalPlaces:1,unitSeparator:" "}),i.appendChild(a),i}function Y(e){if(!e)return"file";switch(!0){case e.includes("msword"):case e.includes("wordprocessingml"):case e.includes("opendocument.text"):case e.includes("abiword"):return"file-word";case e.includes("ms-excel"):case e.includes("spreadsheet"):return"file-powerpoint";case e.includes("powerpoint"):case e.includes("presentation"):return"file-powerpoint";case e.includes("7z-"):case e.includes("iso9660"):case e.includes("zip"):case e.includes("octet-stream"):return"file-archive";case e.includes("csv"):return"file-csv";case e.includes("pdf"):return"file-pdf";case e.includes("font"):return"file-contract";case e.includes("text"):case e.includes("subrip"):case e.includes("vtt"):return"file-alt";case e.includes("audio"):return"file-audio";case e.includes("image"):return"file-image";case e.includes("video"):return"file-video";default:return"file"}}function K(e){this.dataset.group?u[this.dataset.group][this.dataset.index]=this.value?this.value:"":u[this.id]=this.value?this.value:"",window.location.hash=r.toMagnetURI(u),te()}function X(){document.getElementById("magnet").value="",document.getElementById("torrent").value="",d.style.display="flex",g.style.display="none",x.value="",_.value="",w.value="",k.value="",E.value="",j.innerHTML="",A.innerHTML="",H.torrents.forEach((e=>e.destroy())),O.style.display="block",R.innerHTML="",window.location.hash="",B.setAttribute("data-clipboard-text",""),U.setAttribute("data-clipboard-text",""),document.title="Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link",b.disable(),gtag("event","reset")}async function J(){S.className="disabled",S.innerHTML="Adding...";try{let e=await fetch("https://newtrackon.com/api/100"),t=await e.text();u.announce=u.announce.concat(t.split("\n\n")),u.announce.push("http://bt1.archive.org:6969/announce"),u.announce.push("http://bt2.archive.org:6969/announce"),u.announce=u.announce.filter(((e,t)=>e&&u.announce.indexOf(e)===t)),F.success("Added known working trackers from newTrackon"),te()}catch(e){F.error("Problem fetching trackers from newTrackon"),console.warn(e)}S.className="",S.innerHTML="Add Known Working Trackers",V(),gtag("event","add_trackers")}function Z(){u[this.dataset.type].unshift(""),V()}function Q(){u[this.parentElement.className].splice(this.parentElement.dataset.index,1),V()}function ee(e){u[e]=[],te(),V()}function te(){u.created=new Date,u.createdBy="Torrent Parts ",u.created?(_.value=u.created.toISOString().slice(0,19),_.type="datetime-local"):_.type="text",w.value=u.createdBy?"by "+u.createdBy:""}function ne(){console.info("Attempting fetching files from Webtorrent..."),O.style.display="none",u.announce.push("wss://tracker.webtorrent.io"),u.announce.push("wss://tracker.openwebtorrent.com"),u.announce.push("wss://tracker.btorrent.xyz"),u.announce.push("wss://tracker.fastcast.nz"),u.announce=u.announce.filter(((e,t)=>e&&u.announce.indexOf(e)===t)),H.add(r.toMagnetURI(u),(e=>{u.info=Object.assign({},e.info),u.files=e.files,u.infoBuffer=e.infoBuffer,u.length=e.length,u.lastPieceLength=e.lastPieceLength,te(),V(),F.success("Fetched file details from Webtorrent peers"),e.destroy()})),V(),gtag("event","attempt_webtorrent_fetch")}function ie(){let e=r.toTorrentFile(u);if(null!==e&&navigator.msSaveBlob)return navigator.msSaveBlob(new Blob([e],{type:"application/x-bittorrent"}),u.name+".torrent");let t=document.createElement("a");t.style.display="none";let n=window.URL.createObjectURL(new Blob([e],{type:"application/x-bittorrent"}));t.setAttribute("href",n),t.setAttribute("download",u.name+".torrent"),document.body.appendChild(t),t.click(),window.URL.revokeObjectURL(n),t.remove(),gtag("event","share",{method:"Torrent Download",content_id:u.name})}window.addEventListener("resize",z),z(),document.addEventListener("DOMContentLoaded",(function(){document.getElementById("magnet").addEventListener("keyup",(function(e){e.preventDefault(),"Enter"===e.key&&(p="magnet",v.innerHTML='',b.setContent("Currently loaded information sourced from Magnet URL"),W(magnet.value))})),document.getElementById("torrent").addEventListener("change",(function(e){e.preventDefault(),e.target.files[0].arrayBuffer().then((function(e){p="torrent-file",v.innerHTML='',b.setContent("Currently loaded information sourced from Torrent file"),W(o.from(e))}))})),document.addEventListener("dragover",(function(e){e.preventDefault()})),document.addEventListener("drop",(function(e){e.preventDefault(),e.dataTransfer.items[0].getAsFile().arrayBuffer().then((function(e){p="torrent-file",v.innerHTML='',b.setContent("Currently loaded information sourced from Torrent file"),W(o.from(e))}))})),f.addEventListener("click",(function(e){e.preventDefault(),F.success("Parsing Ubuntu 20.04 Magnet URL"),W("magnet:?xt=urn:btih:9fc20b9e98ea98b4a35e6223041a5ef94ea27809&dn=ubuntu-20.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce")})),h.addEventListener("click",(async function(e){e.preventDefault(),F.success("Fetching and Parsing “The WIRED CD” Torrent File..."),$("https://webtorrent.io/torrents/wired-cd.torrent")})),m.addEventListener("click",(async function(e){e.preventDefault(),F.success("Parsing Jack Johnson Archive.org Torrent File");let t=await fetch("/ext/jj2008-06-14.mk4_archive.torrent"),n=await t.arrayBuffer();W(o.from(n))}));let e=new i("#copyURL");e.on("success",(function(e){F.success("Copied site URL to clipboard!"),console.info(e),gtag("event","share",{method:"Copy URL",content_id:e.text})})),e.on("failure",(function(e){F.error("Problem copying to clipboard"),console.warn(e)}));let t=new i("#copyMagnet");t.on("success",(function(e){F.success("Copied Magnet URL to clipboard!"),gtag("event","share",{method:"Copy Magnet",content_id:e.text})})),t.on("failure",(function(e){F.error("Problem copying to clipboard"),console.warn(e)})),x.addEventListener("input",K),x.addEventListener("change",K),x.addEventListener("reset",K),x.addEventListener("paste",K),y.addEventListener("click",X),k.addEventListener("input",K),k.addEventListener("change",K),k.addEventListener("reset",K),k.addEventListener("paste",K),S.addEventListener("click",J),C.addEventListener("click",Z),T.addEventListener("click",(()=>ee("announce"))),L.addEventListener("click",Z),I.addEventListener("click",(()=>ee("urlList"))),O.addEventListener("click",ne),l("[data-tippy-content]",{theme:"torrent-parts",animation:"shift-away-subtle"}),b.disable(),window.location.hash&&(p="shared-url",v.innerHTML='',b.setContent("Currently loaded information sourced from shared torrent.parts link"),W(window.location.hash.split("#")[1]))}))},{Buffer:2,bytes:60,clipboard:77,"mime-types":146,"parse-torrent":186,"tippy.js":291,webtorrent:310}]},{},[338]); \ No newline at end of file +const{EventEmitter:r}=e("events"),s=e("simple-concat"),o=e("create-torrent"),a=e("debug")("webtorrent"),c=e("bittorrent-dht/client"),u=e("load-ip-set"),l=e("run-parallel"),d=e("parse-torrent"),f=e("path"),p=e("simple-peer"),h=e("randombytes"),m=e("speedometer"),b=e("queue-microtask"),g=e("./lib/conn-pool"),v=e("./lib/torrent"),y=e("./package.json").version,_=y.replace(/\d*./g,(e=>("0"+e%100).slice(-2))).slice(0,4),w=`-WW${_}-`;class x extends r{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:i.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=i.from(w+h(9).toString("base64")).toString("hex"),this.peerIdBuffer=i.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:i.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=h(20).toString("hex"),this.nodeIdBuffer=i.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.lsd=!1!==e.lsd,this.torrents=[],this.maxConns=Number(e.maxConns)||55,this.utp=x.UTP_SUPPORT&&!1!==e.utp,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),n.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=n.WRTC)),"function"==typeof g?this._connPool=new g(this):b((()=>{this._onListening()})),this._downloadSpeed=m(),this._uploadSpeed=m(),!1!==e.dht&&"function"==typeof c?(this.dht=new c(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",(e=>{this._destroy(e)})),this.dht.once("listening",(()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)})),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof u&&null!=e.blocklist?u(e.blocklist,{headers:{"user-agent":`WebTorrent/${y} (https://webtorrent.io)`}},((e,n)=>{if(e)return this.error(`Failed to load blocklist: ${e.message}`);this.blocked=n,t()})):b(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter((e=>1!==e.progress));return e.reduce(((e,t)=>e+t.downloaded),0)/(e.reduce(((e,t)=>e+(t.length||0)),0)||1)}get ratio(){return this.torrents.reduce(((e,t)=>e+t.uploaded),0)/(this.torrents.reduce(((e,t)=>e+t.received),0)||1)}get(e){if(e instanceof v){if(this.torrents.includes(e))return e}else{let t;try{t=d(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}add(e,t={},n=(()=>{})){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const i=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===s.infoHash&&e!==s)return void s._destroy(new Error(`Cannot add duplicate torrent ${s.infoHash}`))},r=()=>{this.destroyed||(n(s),this.emit("torrent",s))};this._debug("add"),t=t?Object.assign({},t):{};const s=new v(e,this,t);return this.torrents.push(s),s.once("_infoHash",i),s.once("ready",r),s.once("close",(function e(){s.removeListener("_infoHash",i),s.removeListener("ready",r),s.removeListener("close",e)})),s}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const i="string"==typeof e;i&&(t.path=f.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${_}`);const r=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},a=this.add(null,t,(e=>{const n=[n=>{if(i||t.preloadedStore)return n();e.load(c,n)}];this.dht&&n.push((t=>{e.once("dhtAnnounce",t)})),l(n,(t=>{if(!this.destroyed)return t?e._destroy(t):void r(e)}))}));let c;var u;return u=e,"undefined"!=typeof FileList&&u instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),l(e.map((e=>n=>{!t.preloadedStore&&function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?s(e,((t,i)=>{if(t)return n(t);i.name=e.name,n(null,i)})):n(null,e)})),((e,n)=>{if(!this.destroyed)return e?a._destroy(e):void o.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return a._destroy(e);c=i.map((e=>e.getStream)),o(n,t,((e,t)=>{if(this.destroyed)return;if(e)return a._destroy(e);const n=this.get(t);n?a._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):a._onTorrentId(t)}))}}))})),a}remove(e,t,n){if("function"==typeof t)return this.remove(e,null,t);this._debug("remove");if(!this.get(e))throw new Error(`No torrent with id ${e}`);this._remove(e,t,n)}_remove(e,t,n){if("function"==typeof t)return this._remove(e,null,t);const i=this.get(e);i&&(this.torrents.splice(this.torrents.indexOf(i),1),i.destroy(t,n))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map((e=>t=>{e.destroy(t)}));this._connPool&&n.push((e=>{this._connPool.destroy(e)})),this.dht&&n.push((e=>{this.dht.destroy(e)})),l(n,t),e&&this.emit("error",e),this.torrents=[],this._connPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._connPool){const e=this._connPool.tcpServer.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,a(...e)}}x.WEBRTC_SUPPORT=p.WEBRTC_SUPPORT,x.UTP_SUPPORT=g.UTP_SUPPORT,x.VERSION=y,t.exports=x}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./lib/conn-pool":71,"./lib/torrent":493,"./package.json":513,"bittorrent-dht/client":71,buffer:114,"create-torrent":147,debug:495,events:194,"load-ip-set":71,"parse-torrent":324,path:325,"queue-microtask":346,randombytes:348,"run-parallel":374,"simple-concat":386,"simple-peer":388,speedometer:428}],489:[function(e,t,n){const i=e("debug")("webtorrent:file-stream"),r=e("readable-stream"),s=e("end-of-stream");class o extends r.Readable{constructor(e,t){super(t),this._torrent=e._torrent;const n=t&&t.start||0,i=t&&t.end&&t.end{this._notify()})),s(this,(e=>{this.destroy(e)}))}_read(){this._reading||(this._reading=!0,this._notify())}_notify(){if(!this._reading||0===this._missing)return;if(!this._torrent.bitfield.get(this._piece))return this._torrent.critical(this._piece,this._piece+this._criticalLength);if(this._notifying)return;if(this._notifying=!0,this._torrent.destroyed)return this.destroy(new Error("Torrent removed"));const e=this._piece,t={};e===this._torrent.pieces.length-1&&(t.length=this._torrent.lastPieceLength),this._torrent.store.get(e,t,((t,n)=>{if(this._notifying=!1,!this.destroyed){if(i("read %s (length %s) (err %s)",e,n&&n.length,t&&t.message),t)return this.destroy(t);this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing{const s=r===e.length-1?i:n;return t.get(r)?s:s-e[r].missing};let a=0;for(let t=r;t<=s;t+=1){const c=o(t);if(a+=c,t===r){const e=this.offset%n;a-=Math.min(e,c)}if(t===s){const t=(s===e.length-1?i:n)-(this.offset+this.length)%n;a-=Math.min(t,c)}}return a}get progress(){return this.length?this.downloaded/this.length:0}select(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)}deselect(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)}createReadStream(e){if(0===this.length){const e=new r;return d((()=>{e.end()})),e}const t=new l(this,e);return this._fileStreams.add(t),t.once("close",(()=>{this._fileStreams.delete(t)})),t}getBuffer(e){u(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");a(this.createReadStream(),this._getMimeType()).then((t=>e(null,t)),(t=>e(t)))}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");c(this.createReadStream(),this._getMimeType()).then((t=>e(null,t)),(t=>e(t)))}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");o.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");o.render(this,e,t,n)}_getMimeType(){return o.mime[s.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null;for(const e of this._fileStreams)e.destroy();this._fileStreams.clear()}}},{"./file-stream":489,events:194,path:325,"queue-microtask":346,"readable-stream":512,"render-media":367,"stream-to-blob":464,"stream-to-blob-url":463,"stream-with-known-length-to-buffer":465}],491:[function(e,t,n){const i=e("unordered-array-remove"),r=e("debug")("webtorrent:peer"),s=e("bittorrent-protocol");n.createWebRTCPeer=(e,t)=>{const n=new c(e.id,"webrtc");if(n.conn=e,n.swarm=t,n.conn.connected)n.onConnect();else{const e=()=>{n.conn.removeListener("connect",t),n.conn.removeListener("error",i)},t=()=>{e(),n.onConnect()},i=t=>{e(),n.destroy(t)};n.conn.once("connect",t),n.conn.once("error",i),n.startConnectTimeout()}return n},n.createTCPIncomingPeer=e=>o(e,"tcpIncoming"),n.createUTPIncomingPeer=e=>o(e,"utpIncoming"),n.createTCPOutgoingPeer=(e,t)=>a(e,t,"tcpOutgoing"),n.createUTPOutgoingPeer=(e,t)=>a(e,t,"utpOutgoing");const o=(e,t)=>{const n=`${e.remoteAddress}:${e.remotePort}`,i=new c(n,t);return i.conn=e,i.addr=n,i.onConnect(),i},a=(e,t,n)=>{const i=new c(e,n);return i.addr=e,i.swarm=t,i};n.createWebSeedPeer=(e,t,n)=>{const i=new c(t,"webSeed");return i.swarm=n,i.conn=e,i.onConnect(),i};class c{constructor(e,t){this.id=e,this.type=t,r("new %s Peer %s",t,e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}onConnect(){if(this.destroyed)return;this.connected=!0,r("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",(()=>{this.destroy()})),e.once("close",(()=>{this.destroy()})),e.once("finish",(()=>{this.destroy()})),e.once("error",(e=>{this.destroy(e)}));const t=this.wire=new s;t.type=this.type,t.once("end",(()=>{this.destroy()})),t.once("close",(()=>{this.destroy()})),t.once("finish",(()=>{this.destroy()})),t.once("error",(e=>{this.destroy(e)})),t.once("handshake",((e,t)=>{this.onHandshake(e,t)})),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));r("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout);const e={webrtc:25e3,tcpOutgoing:5e3,utpOutgoing:5e3};this.connectTimeout=setTimeout((()=>{this.destroy(new Error("connect timeout"))}),e[this.type]),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout((()=>{this.destroy(new Error("handshake timeout"))}),25e3),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,r("destroy %s %s (error: %s)",this.type,this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,s=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&s&&i(t.wires,t.wires.indexOf(s)),n&&(n.on("error",(()=>{})),n.destroy()),s&&s.destroy(),t&&t.removePeer(this.id)}}},{"bittorrent-protocol":26,debug:495,"unordered-array-remove":478}],492:[function(e,t,n){t.exports=class{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=new Array(this._numPieces),this._onWire=e=>{this.recalculate(),this._initWire(e)},this._onWireHave=e=>{this._pieces[e]+=1},this._onWireBitfield=()=>{this.recalculate()},this._torrent.wires.forEach((e=>{this._initWire(e)})),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let i=0;i{this._cleanupWireEvents(e)})),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=()=>{this._cleanupWireEvents(e);for(let t=0;t{this.destroyed||this._onParsedTorrent(t)}))):k.remote(e,((e,t)=>{if(!this.destroyed)return e?this._destroy(e):void this._onParsedTorrent(t)}))}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));this.path||(this.path=E.join(W,this.infoHash)),this._rechokeIntervalId=setInterval((()=>{this._rechoke()}),1e4),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),this.destroyed||(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",(()=>{this._onListening()}))))}}_processParsedTorrent(e){this._debugId=e.infoHash.toString("hex").substring(0,7),void 0!==this.private&&(e.private=this.private),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&i.WEBTORRENT_ANNOUNCE&&!e.private&&(e.announce=e.announce.concat(i.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),e.announce=Array.from(new Set(e.announce)),e.urlList=Array.from(new Set(e.urlList)),Object.assign(this,e),this.magnetURI=k.toMagnetURI(e),this.torrentFile=k.toTorrentFile(e)}_onListening(){this.destroyed||(this.info?this._onMetadata(this):(this.xs&&this._getMetadataFromServer(),this._startDiscovery()))}_startDiscovery(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{if(this.destroyed)return;const e={uploaded:this.uploaded,downloaded:this.downloaded,left:Math.max(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.peerAddresses&&this.peerAddresses.forEach((e=>this.addPeer(e))),this.discovery=new l({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:F,lsd:this.client.lsd}),this.discovery.on("error",(e=>{this._destroy(e)})),this.discovery.on("peer",((e,t)=>{this._debug("peer %s discovered via %s",e,t),"string"==typeof e&&this.done||this.addPeer(e)})),this.discovery.on("trackerAnnounce",(()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")})),this.discovery.on("dhtAnnounce",(()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")})),this.discovery.on("warning",(e=>{this.emit("warning",e)}))}_getMetadataFromServer(){const e=this,t=(Array.isArray(this.xs)?this.xs:[this.xs]).map((t=>n=>{!function(t,n){if(0!==t.indexOf("http://")&&0!==t.indexOf("https://"))return e.emit("warning",new Error(`skipping non-http xs param: ${t}`)),n(null);const i={url:t,method:"GET",headers:{"user-agent":F}};let r;try{r=h.concat(i,s)}catch(i){return e.emit("warning",new Error(`skipping invalid url xs param: ${t}`)),n(null)}function s(i,r,s){if(e.destroyed)return n(null);if(e.metadata)return n(null);if(i)return e.emit("warning",new Error(`http error from xs param: ${t}`)),n(null);if(200!==r.statusCode)return e.emit("warning",new Error(`non-200 status code ${r.statusCode} from xs param: ${t}`)),n(null);let o;try{o=k(s)}catch(i){}return o?o.infoHash!==e.infoHash?(e.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${t}`)),n(null)):(e._onMetadata(o),void n(null)):(e.emit("warning",new Error(`got invalid torrent file from xs param: ${t}`)),n(null))}e._xsRequests.push(r)}(t,n)}));w(t)}_onMetadata(e){if(this.metadata||this.destroyed)return;let t;if(this._debug("got metadata"),this._xsRequests.forEach((e=>{e.abort()})),this._xsRequests=[],e&&e.infoHash)t=e;else try{t=k(e)}catch(e){return this._destroy(e)}this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach((e=>{this.addWebSeed(e)})),this._rarityMap=new O(this);let n=this._preloadedStore;if(n||(n=new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map((e=>({path:E.join(this.path,e.path),length:e.length,offset:e.offset}))),length:this.length,name:this.infoHash})),this._storeCacheSlots>0&&!(n instanceof g)&&(n=new o(n,{max:this._storeCacheSlots})),this.store=new m(n),this.files=this.files.map((e=>new R(this,e))),this.so?this.files.forEach(((e,t)=>{this.so.includes(t)?this.files[t].select():this.files[t].deselect()})):0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1),this._hashes=this.pieces,this.pieces=this.pieces.map(((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new S(n)})),this._reservations=this.pieces.map((()=>[])),this.bitfield=new s(this.pieces.length),this.wires.forEach((e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)})),this.emit("metadata"),!this.destroyed)if(this.skipVerify)this._markAllVerified(),this._onStore();else{const e=e=>{if(e)return this._destroy(e);this._debug("done verifying"),this._onStore()};this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===p?this.getFileModtimes(((t,n)=>{if(t)return this._destroy(t);this.files.map(((e,t)=>n[t]===this._fileModtimes[t])).every((e=>e))?(this._markAllVerified(),this._onStore()):this._verifyPieces(e)})):this._verifyPieces(e)}}getFileModtimes(e){const t=[];x(this.files.map(((e,n)=>i=>{f.stat(E.join(this.path,e.path),((e,r)=>{if(e&&"ENOENT"!==e.code)return i(e);t[n]=r&&r.mtime.getTime(),i(null)}))})),z,(n=>{this._debug("done getting file modtimes"),e(n,t)}))}_verifyPieces(e){x(this.pieces.map(((e,t)=>e=>{if(this.destroyed)return e(new Error("torrent is destroyed"));const n={};t===this.pieces.length-1&&(n.length=this.lastPieceLength),this.store.get(t,n,((n,i)=>this.destroyed?e(new Error("torrent is destroyed")):n?A((()=>e(null))):void j(i,(n=>{if(this.destroyed)return e(new Error("torrent is destroyed"));n===this._hashes[t]?(this._debug("piece verified %s",t),this._markVerified(t)):this._debug("piece invalid %s",t),e(null)}))))})),z,e)}rescanFiles(e){if(this.destroyed)throw new Error("torrent is destroyed");e||(e=K),this._verifyPieces((t=>{if(t)return this._destroy(t),e(t);this._checkDone(),e(null)}))}_markAllVerified(){for(let e=0;e{e.abort()})),this._rarityMap&&this._rarityMap.destroy();for(const e in this._peers)this.removePeer(e);this.files.forEach((e=>{e instanceof R&&e._destroy()}));const i=this._servers.map((e=>t=>{e.destroy(t)}));if(this.discovery&&i.push((e=>{this.discovery.destroy(e)})),this.store){let e=this._destroyStoreOnDestroy;t&&void 0!==t.destroyStore&&(e=t.destroyStore),i.push((t=>{e?this.store.destroy(t):this.store.close(t)}))}w(i,n),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}addPeer(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");let t;if(this.client.blocked){if("string"==typeof e){let n;try{n=r(e)}catch(t){return this._debug("ignoring peer: invalid %s",e),this.emit("invalidPeer",e),!1}t=n[0]}else"string"==typeof e.remoteAddress&&(t=e.remoteAddress);if(t&&this.client.blocked.contains(t))return this._debug("ignoring peer: blocked %s",e),"string"!=typeof e&&e.destroy(),this.emit("blockedPeer",e),!1}const n=this.client.utp&&this._isIPv4(t)?"utp":"tcp",i=!!this._addPeer(e,n);return i?this.emit("peer",e):this.emit("invalidPeer",e),i}_addPeer(e,t){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;const n=e&&e.id||e;if(this._peers[n])return this._debug("ignoring peer: duplicate (%s)",n),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;let i;return this._debug("add peer %s",n),i="string"==typeof e?"utp"===t?L.createUTPOutgoingPeer(e,this):L.createTCPOutgoingPeer(e,this):L.createWebRTCPeer(e,this),this._peers[i.id]=i,this._peersLength+=1,"string"==typeof e&&(this._queue.push(i),this._drain()),i}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");let t,n;if("string"==typeof e){if(t=e,!/^https?:\/\/.+/.test(t))return this.emit("warning",new Error(`ignoring invalid web seed: ${t}`)),void this.emit("invalidPeer",t);if(this._peers[t])return this.emit("warning",new Error(`ignoring duplicate web seed: ${t}`)),void this.emit("invalidPeer",t);n=new q(t,this)}else{if(!e||"string"!=typeof e.connId)return void this.emit("warning",new Error("addWebSeed must be passed a string or connection object with id property"));if(n=e,t=n.connId,this._peers[t])return this.emit("warning",new Error(`ignoring duplicate web seed: ${t}`)),void this.emit("invalidPeer",t)}this._debug("add web seed %s",t);const i=L.createWebSeedPeer(n,t,this);this._peers[i.id]=i,this._peersLength+=1,this.emit("peer",t)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,void(this._peersLength+=1))}removePeer(e){const t=e&&e.id||e;(e=this._peers[t])&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,i){if(this.destroyed)throw new Error("torrent is destroyed");if(e<0||tt.priority-e.priority)),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=Number(n)||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let i=0;i{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.destroyed||this.client.emit("download",e))})),e.on("upload",(e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.destroyed||this.client.emit("upload",e))})),this.wires.push(e),t){const n=r(t);e.remoteAddress=n[0],e.remotePort=n[1]}this.client.dht&&this.client.dht.listening&&e.on("port",(n=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!e.remoteAddress)return this._debug("ignoring PORT from peer with no address");if(0===n||n>65536)return this._debug("ignoring invalid PORT from peer");this._debug("port: %s (from %s)",n,t),this.client.dht.addNode({host:e.remoteAddress,port:n})}})),e.on("timeout",(()=>{this._debug("wire timeout (%s)",t),e.destroy()})),"webSeed"!==e.type&&e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(T(this.metadata)),e.ut_metadata.on("warning",(e=>{this._debug("ut_metadata warning: %s",e.message)})),this.metadata||(e.ut_metadata.on("metadata",(e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)})),e.ut_metadata.fetch()),"function"!=typeof B||this.private||(e.use(B()),e.ut_pex.on("peer",(e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,t),this.addPeer(e))})),e.ut_pex.on("dropped",(e=>{const n=this._peers[e];n&&!n.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,t),this.removePeer(e))})),e.once("close",(()=>{e.ut_pex.reset()}))),e.use(b()),this.emit("wire",e,t),this.metadata&&A((()=>{this._onWireWithMetadata(e)}))}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,D),t.unref&&t.unref()))};let i;const r=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(i=0;i{r(),this._update(),this._updateWireInterest(e)})),e.on("have",(()=>{r(),this._update(),this._updateWireInterest(e)})),e.lt_donthave.on("donthave",(()=>{r(),this._update(),this._updateWireInterest(e)})),e.once("interested",(()=>{e.unchoke()})),e.once("close",(()=>{clearTimeout(t)})),e.on("choke",(()=>{clearTimeout(t),t=setTimeout(n,D),t.unref&&t.unref()})),e.on("unchoke",(()=>{clearTimeout(t),this._update()})),e.on("request",((t,n,i,r)=>{if(i>131072)return e.destroy();this.pieces[t]||this.store.get(t,{offset:n,length:i},r)})),e.bitfield(this.bitfield),this._updateWireInterest(e),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,D),t.unref&&t.unref()),e.isSeeder=!1,r()}_updateSelections(){this.ready&&!this.destroyed&&(A((()=>{this._gcSelections()})),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;ethis._updateWireInterest(e))),e!==this._amInterested&&(this._amInterested?this.emit("interested"):this.emit("uninterested"))}_updateWireInterest(e){let t=!1;for(let n=0;n{t._updateWire(e)}),{timeout:250}):t._updateWire(e)}_updateWire(e){const t=this;if(e.peerChoking)return;if(!e.downloaded)return function(){if(e.requests.length)return;let n=t._selections.length;for(;n--;){const i=t._selections[n];let s;if("rarest"===t.strategy){const n=i.from+i.offset,o=i.to,a=o-n+1,c={};let u=0;const l=r(n,o,c);for(;u=i.from+i.offset;--s)if(e.peerPieces.get(s)&&t._request(e,s,!1))return}}();const n=V(e,.5);if(e.requests.length>=n)return;const i=V(e,1);function r(t,n,i,r){return s=>s>=t&&s<=n&&!(s in i)&&e.peerPieces.get(s)&&(!r||r(s))}function s(e){let n=e;for(let i=e;i=i)return!0;const o=function(){const n=e.downloadSpeed()||1;if(n>N)return()=>!0;const i=Math.max(1,e.requests.length)*S.BLOCK_LENGTH/n;let r=10,s=0;return e=>{if(!r||t.bitfield.get(e))return!0;let o=t.pieces[e].missing;for(;s0))return r--,!1}return!0}}();for(let a=0;a({wire:e,random:Math.random()}))).sort(((e,t)=>{const n=e.wire,i=t.wire;return n.downloadSpeed()!==i.downloadSpeed()?n.downloadSpeed()-i.downloadSpeed():n.uploadSpeed()!==i.uploadSpeed()?n.uploadSpeed()-i.uploadSpeed():n.amChoking!==i.amChoking?n.amChoking?-1:1:e.random-t.random})).map((e=>e.wire));this._rechokeOptimisticTime<=0?this._rechokeOptimisticWire=null:this._rechokeOptimisticTime-=1;let t=0;for(;e.length>0&&t0){const t=e.filter((e=>e.peerInterested));if(t.length>0){const e=t[(n=t.length,Math.random()*n|0)];e.unchoke(),this._rechokeOptimisticWire=e,this._rechokeOptimisticTime=2}}var n;e.filter((e=>e!==this._rechokeOptimisticWire)).forEach((e=>e.choke()))}_hotswap(e,t){const n=e.downloadSpeed();if(n=N||(2*a>n||a>o||(r=t,o=a))}if(!r)return!1;for(s=0;s=(s?Math.min(function(e,t,n){return 1+Math.ceil(t*e.downloadSpeed()/n)}(e,1,i.pieceLength),i.maxWebConns):V(e,1)))return!1;const o=i.pieces[t];let a=s?o.reserveRemaining():o.reserve();if(-1===a&&n&&i._hotswap(e,t)&&(a=s?o.reserveRemaining():o.reserve()),-1===a)return!1;let c=i._reservations[t];c||(c=i._reservations[t]=[]);let u=c.indexOf(null);-1===u&&(u=c.length),c[u]=e;const l=o.chunkOffset(a),d=s?o.chunkLengthRemaining(a):o.chunkLength(a);function f(){A((()=>{i._update()}))}return e.request(t,l,d,(function n(r,p){if(i.destroyed)return;if(!i.ready)return i.once("ready",(()=>{n(r,p)}));if(c[u]===e&&(c[u]=null),o!==i.pieces[t])return f();if(r)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,l,d,`${e.remoteAddress}:${e.remotePort}`,r.message),s?o.cancelRemaining(a):o.cancel(a),void f();if(i._debug("got piece %s (offset: %s length: %s) from %s",t,l,d,`${e.remoteAddress}:${e.remotePort}`),!o.set(a,p,e))return f();const h=o.flush();j(h,(e=>{i.destroyed||(e===i._hashes[t]?(i._debug("piece verified %s",t),i.store.put(t,h,(e=>{e?i._destroy(e):(i.pieces[t]=null,i._markVerified(t),i.wires.forEach((e=>{e.have(t)})),i._checkDone()&&!i.destroyed&&i.discovery.complete(),f())}))):(i.pieces[t]=new S(o.length),i.emit("warning",new Error(`Piece ${t} failed verification`)),f()))}))})),!0}_checkDone(){if(this.destroyed)return;this.files.forEach((e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}}));let e=!0;for(const t of this._selections){for(let n=t.from;n<=t.to;n++)if(!this.bitfield.get(n)){e=!1;break}if(!e)break}return!this.done&&e&&(this.done=!0,this._debug(`torrent done: ${this.infoHash}`),this.emit("done")),this._gcSelections(),e}load(e,t){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.ready)return this.once("ready",(()=>{this.load(e,t)}));Array.isArray(e)||(e=[e]),t||(t=K);const n=new v(e),i=new a(this.store,this.pieceLength);M(n,i,(e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)}))}createServer(e){if("function"!=typeof P)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new P(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client?this.client._debugId:"No Client"}] [${this._debugId}] ${e[0]}`,u(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof y.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("%s connect attempt to %s",e.type,e.addr);const t=r(e.addr),n={host:t[0],port:t[1]};this.client.utp&&"utpOutgoing"===e.type?e.conn=U.connect(n.port,n.host):e.conn=y.connect(n);const i=e.conn;i.once("connect",(()=>{e.onConnect()})),i.once("error",(t=>{e.destroy(t)})),e.startConnectTimeout(),i.on("close",(()=>{if(this.destroyed)return;if(e.retries>=H.length){if(this.client.utp){const t=this._addPeer(e.addr,"tcp");t&&(t.retries=0)}else this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,H.length);return}const t=H[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout((()=>{if(this.destroyed)return;const t=r(e.addr)[0],n=this.client.utp&&this._isIPv4(t)?"utp":"tcp",i=this._addPeer(e.addr,n);i&&(i.retries=e.retries+1)}),t);n.unref&&n.unref()}))}_validAddr(e){let t;try{t=r(e)}catch(e){return!1}const n=t[0],i=t[1];return i>0&&i<65535&&!("127.0.0.1"===n&&i===this.client.torrentPort)}_isIPv4(e){return/^((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/.test(e)}}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../package.json":513,"./file":490,"./peer":491,"./rarity-map":492,"./server":71,"./utp":71,"./webconn":494,_process:333,"addr-to-ip-port":3,bitfield:25,"cache-chunk-store":121,"chunk-store-stream/write":137,cpus:140,debug:495,events:194,fs:71,"fs-chunk-store":272,"immediate-chunk-store":244,lt_donthave:250,"memory-chunk-store":272,multistream:301,net:71,os:71,"parse-torrent":324,path:325,pump:341,"queue-microtask":346,"random-iterate":347,"run-parallel":374,"run-parallel-limit":373,"simple-get":387,"simple-sha1":407,speedometer:428,"torrent-discovery":471,"torrent-piece":475,ut_metadata:481,ut_pex:71}],494:[function(e,t,n){(function(n){(function(){const i=e("bitfield").default,r=e("debug")("webtorrent:webconn"),s=e("simple-get"),o=e("lt_donthave"),a=e("simple-sha1"),c=e("bittorrent-protocol"),u=e("../package.json").version;t.exports=class extends c{constructor(e,t){super(),this.url=e,this.connId=e,this.webPeerId=a.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.use(o()),this.once("handshake",((e,t)=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const n=this._torrent.pieces.length,r=new i(n);for(let e=0;e<=n;e++)r.set(e,!0);this.bitfield(r)})),this.once("interested",(()=>{r("interested"),this.unchoke()})),this.on("uninterested",(()=>{r("uninterested")})),this.on("choke",(()=>{r("choke")})),this.on("unchoke",(()=>{r("unchoke")})),this.on("bitfield",(()=>{r("bitfield")})),this.lt_donthave.on("donthave",(()=>{r("donthave")})),this.on("request",((e,t,n,i)=>{r("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,((t,n)=>{if(t){this.lt_donthave.donthave(e);const t=setTimeout((()=>{this.destroyed||this.have(e)}),1e4);t.unref&&t.unref()}i(t,n)}))}))}httpRequest(e,t,i,o){const a=e*this._torrent.pieceLength+t,c=a+i-1,l=this._torrent.files;let d;if(l.length<=1)d=[{url:this.url,start:a,end:c}];else{const e=l.filter((e=>e.offset<=c&&e.offset+e.length>a));if(e.length<1)return o(new Error("Could not find file corresponding to web seed range request"));d=e.map((e=>{const t=e.offset+e.length-1;return{url:this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path,fileOffsetInRange:Math.max(e.offset-a,0),start:Math.max(a-e.offset,0),end:Math.min(t,c-e.offset)}}))}let f,p=0,h=!1;d.length>1&&(f=n.alloc(i)),d.forEach((n=>{const a=n.url,c=n.start,l=n.end;r("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,i,c,l);const m={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${u} (https://webtorrent.io)`,range:`bytes=${c}-${l}`},timeout:6e4};function b(e,t){if(e.statusCode<200||e.statusCode>=300){if(h)return;return h=!0,o(new Error(`Unexpected HTTP status code ${e.statusCode}`))}r("Got data of length %d",t.length),1===d.length?o(null,t):(t.copy(f,n.fileOffsetInRange),++p===d.length&&o(null,f))}s.concat(m,((e,t,n)=>{if(!h)return e?"undefined"==typeof window||a.startsWith(`${window.location.origin}/`)?(h=!0,o(e)):s.head(a,((t,n)=>{if(!h){if(t)return h=!0,o(t);if(n.statusCode<200||n.statusCode>=300)return h=!0,o(new Error(`Unexpected HTTP status code ${n.statusCode}`));if(n.url===a)return h=!0,o(e);m.url=n.url,s.concat(m,((e,t,n)=>{if(!h)return e?(h=!0,o(e)):void b(t,n)}))}})):void b(t,n)}))}))}destroy(){super.destroy(),this._torrent=null}}}).call(this)}).call(this,e("buffer").Buffer)},{"../package.json":513,bitfield:25,"bittorrent-protocol":26,buffer:114,debug:495,lt_donthave:250,"simple-get":387,"simple-sha1":407}],495:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"./common":496,_process:333,dup:27}],496:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,ms:497}],497:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29}],498:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{dup:30}],499:[function(e,t,n){arguments[4][31][0].apply(n,arguments)},{"./_stream_readable":501,"./_stream_writable":503,_process:333,dup:31,inherits:245}],500:[function(e,t,n){arguments[4][32][0].apply(n,arguments)},{"./_stream_transform":502,dup:32,inherits:245}],501:[function(e,t,n){arguments[4][33][0].apply(n,arguments)},{"../errors":498,"./_stream_duplex":499,"./internal/streams/async_iterator":504,"./internal/streams/buffer_list":505,"./internal/streams/destroy":506,"./internal/streams/from":508,"./internal/streams/state":510,"./internal/streams/stream":511,_process:333,buffer:114,dup:33,events:194,inherits:245,"string_decoder/":466,util:71}],502:[function(e,t,n){arguments[4][34][0].apply(n,arguments)},{"../errors":498,"./_stream_duplex":499,dup:34,inherits:245}],503:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"../errors":498,"./_stream_duplex":499,"./internal/streams/destroy":506,"./internal/streams/state":510,"./internal/streams/stream":511,_process:333,buffer:114,dup:35,inherits:245,"util-deprecate":485}],504:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{"./end-of-stream":507,_process:333,dup:36}],505:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:114,dup:37,util:71}],506:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{_process:333,dup:38}],507:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{"../../../errors":498,dup:39}],508:[function(e,t,n){arguments[4][40][0].apply(n,arguments)},{dup:40}],509:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{"../../../errors":498,"./end-of-stream":507,dup:41}],510:[function(e,t,n){arguments[4][42][0].apply(n,arguments)},{"../../../errors":498,dup:42}],511:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43,events:194}],512:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{"./lib/_stream_duplex.js":499,"./lib/_stream_passthrough.js":500,"./lib/_stream_readable.js":501,"./lib/_stream_transform.js":502,"./lib/_stream_writable.js":503,"./lib/internal/streams/end-of-stream.js":507,"./lib/internal/streams/pipeline.js":509,dup:44}],513:[function(e,t,n){t.exports={version:"1.2.5"}},{}],514:[function(e,t,n){t.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){i[e]=t[e]})),i;function i(){for(var e=new Array(arguments.length),n=0;n1080?(q.setProps({placement:"right"}),D.setProps({placement:"right"}),N.setProps({placement:"right"})):(q.setProps({placement:"top"}),D.setProps({placement:"top"}),N.setProps({placement:"top"}))}function W(e){Y();try{console.info("Attempting parse"),d=r(e),K(),d.xs&&(console.info("Magnet includes xs, attempting remote parse"),V(d.xs))}catch(t){console.warn(t),"magnet"==l?(console.info("Attempting remote parse"),V(e)):(H.error("Problem parsing input. Is this a .torrent file?"),console.error("Problem parsing input"))}}function V(e){r.remote(e,(function(e,t){if(e)return H.error("Problem remotely fetching that file or parsing result"),console.warn(e),void Y();l="remote-torrent-file",g.innerHTML='',v.setContent("Currently loaded information sourced from remotely fetched Torrent file"),d=t,K()}))}function K(){if(console.log(d),E.value=d.infoHash,y.value=d.name?d.name:"",d.created?(w.value=d.created.toISOString().slice(0,19),w.type="datetime-local"):w.type="text",x.value=d.createdBy?"by "+d.createdBy:"",k.value=d.comment?d.comment:"",I.innerHTML="",d.announce&&d.announce.length)for(let e=0;e',i.addEventListener("click",Q),t.appendChild(i),I.appendChild(t)}if(j.innerHTML="",d.urlList&&d.urlList.length)for(let e=0;e',i.addEventListener("click",Q),t.appendChild(i),j.appendChild(t)}if(B.innerHTML="",d.files&&d.files.length){if(R.style.display="none",d.files.length<100)for(let e of d.files){let t=G(a.lookup(e.name));B.appendChild($(t,e.name,e.length))}else{for(let e=0;e<100;e++){let t=G(a.lookup(d.files[e].name));B.appendChild($(t,d.files[e].name,d.files[e].length))}B.appendChild($("","...and another "+(d.files.length-100)+" more files",""))}B.appendChild($("folder-tree","",d.length)),N.setContent("Download Torrent file"),U.addEventListener("click",ie),U.disabled=!1}else z.torrents.length>0?(R.style.display="none",B.innerHTML=''):(R.style.display="block",B.innerHTML=''),N.setContent("Files metadata is required to generate a Torrent file. Try fetching files list from WebTorrent."),U.removeEventListener("click",ie),U.disabled=!0;L.setAttribute("data-clipboard-text",window.location.origin+"#"+r.toMagnetURI(d)),O.setAttribute("data-clipboard-text",r.toMagnetURI(d)),f.style.display="none",b.style.display="flex",window.location.hash=r.toMagnetURI(d),d.name?document.title="Torrent Parts | "+d.name:document.title="Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link",v.enable(),gtag("event","view_item",{items:[{item_id:d.infoHash,item_name:d.name,item_category:l}]})}function $(e,t,n){let i=document.createElement("tr"),r=document.createElement("td");e&&(r.innerHTML=''),i.appendChild(r);let s=document.createElement("td");s.innerHTML=t,i.appendChild(s);let a=document.createElement("td");return a.innerHTML=o.format(n,{decimalPlaces:1,unitSeparator:" "}),i.appendChild(a),i}function G(e){if(!e)return"file";switch(!0){case e.includes("msword"):case e.includes("wordprocessingml"):case e.includes("opendocument.text"):case e.includes("abiword"):return"file-word";case e.includes("ms-excel"):case e.includes("spreadsheet"):return"file-powerpoint";case e.includes("powerpoint"):case e.includes("presentation"):return"file-powerpoint";case e.includes("7z-"):case e.includes("iso9660"):case e.includes("zip"):case e.includes("octet-stream"):return"file-archive";case e.includes("csv"):return"file-csv";case e.includes("pdf"):return"file-pdf";case e.includes("font"):return"file-contract";case e.includes("text"):case e.includes("subrip"):case e.includes("vtt"):return"file-alt";case e.includes("audio"):return"file-audio";case e.includes("image"):return"file-image";case e.includes("video"):return"file-video";default:return"file"}}function X(e){this.dataset.group?d[this.dataset.group][this.dataset.index]=this.value?this.value:"":d[this.id]=this.value?this.value:"",window.location.hash=r.toMagnetURI(d),te()}function Y(){document.getElementById("magnet").value="",document.getElementById("torrent").value="",f.style.display="flex",b.style.display="none",y.value="",w.value="",x.value="",k.value="",E.value="",I.innerHTML="",j.innerHTML="",z.torrents.forEach((e=>e.destroy())),R.style.display="block",B.innerHTML="",window.location.hash="",L.setAttribute("data-clipboard-text",""),O.setAttribute("data-clipboard-text",""),document.title="Torrent Parts | Inspect and edit what's in your Torrent file or Magnet link",v.disable(),gtag("event","reset")}async function Z(){S.className="disabled",S.innerHTML="Adding...";try{let e=await fetch("https://newtrackon.com/api/100"),t=await e.text();d.announce=d.announce.concat(t.split("\n\n")),d.announce.push("http://bt1.archive.org:6969/announce"),d.announce.push("http://bt2.archive.org:6969/announce"),d.announce=d.announce.filter(((e,t)=>e&&d.announce.indexOf(e)===t)),H.success("Added known working trackers from newTrackon"),te()}catch(e){H.error("Problem fetching trackers from newTrackon"),console.warn(e)}S.className="",S.innerHTML="Add Known Working Trackers",K(),gtag("event","add_trackers")}function J(){d[this.dataset.type].unshift(""),K()}function Q(){d[this.parentElement.className].splice(this.parentElement.dataset.index,1),K()}function ee(e){d[e]=[],te(),K()}function te(){d.created=new Date,d.createdBy="Torrent Parts ",d.created?(w.value=d.created.toISOString().slice(0,19),w.type="datetime-local"):w.type="text",x.value=d.createdBy?"by "+d.createdBy:""}function ne(){console.info("Attempting fetching files from Webtorrent..."),R.style.display="none",d.announce.push("wss://tracker.webtorrent.io"),d.announce.push("wss://tracker.openwebtorrent.com"),d.announce.push("wss://tracker.btorrent.xyz"),d.announce.push("wss://tracker.fastcast.nz"),d.announce=d.announce.filter(((e,t)=>e&&d.announce.indexOf(e)===t)),z.add(r.toMagnetURI(d),(e=>{d.info=Object.assign({},e.info),d.files=e.files,d.infoBuffer=e.infoBuffer,d.length=e.length,d.lastPieceLength=e.lastPieceLength,te(),K(),H.success("Fetched file details from Webtorrent peers"),e.destroy()})),K(),gtag("event","attempt_webtorrent_fetch")}function ie(){let e=r.toTorrentFile(d);if(null!==e&&navigator.msSaveBlob)return navigator.msSaveBlob(new Blob([e],{type:"application/x-bittorrent"}),d.name+".torrent");let t=document.createElement("a");t.style.display="none";let n=window.URL.createObjectURL(new Blob([e],{type:"application/x-bittorrent"}));t.setAttribute("href",n),t.setAttribute("download",d.name+".torrent"),document.body.appendChild(t),t.click(),window.URL.revokeObjectURL(n),t.remove(),gtag("event","share",{method:"Torrent Download",content_id:d.name})}window.addEventListener("resize",F),F(),document.addEventListener("DOMContentLoaded",(function(){document.getElementById("magnet").addEventListener("keyup",(function(e){e.preventDefault(),"Enter"===e.key&&(l="magnet",g.innerHTML='',v.setContent("Currently loaded information sourced from Magnet URL"),W(magnet.value))})),document.getElementById("torrent").addEventListener("change",(function(e){e.preventDefault(),e.target.files[0].arrayBuffer().then((function(e){l="torrent-file",g.innerHTML='',v.setContent("Currently loaded information sourced from Torrent file"),W(s.from(e))}))})),document.addEventListener("dragover",(function(e){e.preventDefault()})),document.addEventListener("drop",(function(e){e.preventDefault(),e.dataTransfer.items[0].getAsFile().arrayBuffer().then((function(e){l="torrent-file",g.innerHTML='',v.setContent("Currently loaded information sourced from Torrent file"),W(s.from(e))}))})),p.addEventListener("click",(function(e){e.preventDefault(),H.success("Parsing Ubuntu 20.04 Magnet URL"),W("magnet:?xt=urn:btih:9fc20b9e98ea98b4a35e6223041a5ef94ea27809&dn=ubuntu-20.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce")})),h.addEventListener("click",(async function(e){e.preventDefault(),H.success("Fetching and Parsing “The WIRED CD” Torrent File..."),V("https://webtorrent.io/torrents/wired-cd.torrent")})),m.addEventListener("click",(async function(e){e.preventDefault(),H.success("Parsing Jack Johnson Archive.org Torrent File");let t=await fetch("/ext/jj2008-06-14.mk4_archive.torrent"),n=await t.arrayBuffer();W(s.from(n))}));let e=new i("#copyURL");e.on("success",(function(e){H.success("Copied site URL to clipboard!"),console.info(e),gtag("event","share",{method:"Copy URL",content_id:e.text})})),e.on("failure",(function(e){H.error("Problem copying to clipboard"),console.warn(e)}));let t=new i("#copyMagnet");t.on("success",(function(e){H.success("Copied Magnet URL to clipboard!"),gtag("event","share",{method:"Copy Magnet",content_id:e.text})})),t.on("failure",(function(e){H.error("Problem copying to clipboard"),console.warn(e)})),y.addEventListener("input",X),y.addEventListener("change",X),y.addEventListener("reset",X),y.addEventListener("paste",X),_.addEventListener("click",Y),k.addEventListener("input",X),k.addEventListener("change",X),k.addEventListener("reset",X),k.addEventListener("paste",X),S.addEventListener("click",Z),M.addEventListener("click",J),A.addEventListener("click",(()=>ee("announce"))),C.addEventListener("click",J),T.addEventListener("click",(()=>ee("urlList"))),R.addEventListener("click",ne),u("[data-tippy-content]",{theme:"torrent-parts",animation:"shift-away-subtle"}),v.disable(),window.location.hash&&(l="shared-url",g.innerHTML='',v.setContent("Currently loaded information sourced from shared torrent.parts link"),W(window.location.hash.split("#")[1]))}))},{Buffer:2,bytes:120,clipboard:139,"mime-types":277,"parse-torrent":324,"tippy.js":469,webtorrent:488}]},{},[516]); \ No newline at end of file diff --git a/ext/notyf.min.js b/ext/notyf.min.js index d4ad3c6..1a9228e 100644 --- a/ext/notyf.min.js +++ b/ext/notyf.min.js @@ -1,2 +1,2 @@ -/*! Notyf 3.9.0 | MIT License | github.com/caroso1222/notyf */ -var Notyf=function(){"use strict";var n,t,o=function(){return(o=Object.assign||function(t){for(var i,e=1,n=arguments.length;e