diff --git a/bin/bundle.js b/bin/bundle.js index e3ea633..bf9d00d 100644 --- a/bin/bundle.js +++ b/bin/bundle.js @@ -1,7 +1,7 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i { if (this.destroyed) return this._outstandingPuts += 1 + if (this._outstandingPuts >= this._storeMaxOutstandingPuts) { + this._blockstream.pause() + } store.put(index, chunk, (err) => { if (err) return this.destroy(err) this._outstandingPuts -= 1 + if (this._outstandingPuts < this._storeMaxOutstandingPuts) { + this._blockstream.resume() + } if (this._outstandingPuts === 0 && typeof this._finalCb === 'function') { this._finalCb(null) this._finalCb = null @@ -10474,9 +10473,9 @@ module.exports = ChunkStoreWriteStream },{"block-stream2":39,"readable-stream":77}],79:[function(require,module,exports){ /*! - * clipboard.js v2.0.6 + * clipboard.js v2.0.8 * https://clipboardjs.com/ - * + * * Licensed MIT © Zeno Rocha */ (function webpackUniversalModuleDefinition(root, factory) { @@ -10489,220 +10488,660 @@ module.exports = ChunkStoreWriteStream else root["ClipboardJS"] = factory(); })(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 6); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { +return /******/ (function() { // webpackBootstrap +/******/ var __webpack_modules__ = ({ -function select(element) { - var selectedText; +/***/ 134: +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - if (element.nodeName === 'SELECT') { - element.focus(); +"use strict"; - selectedText = element.value; +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ clipboard; } +}); + +// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js +var tiny_emitter = __webpack_require__(279); +var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter); +// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js +var listen = __webpack_require__(370); +var listen_default = /*#__PURE__*/__webpack_require__.n(listen); +// EXTERNAL MODULE: ./node_modules/select/src/select.js +var src_select = __webpack_require__(817); +var select_default = /*#__PURE__*/__webpack_require__.n(src_select); +;// CONCATENATED MODULE: ./src/clipboard-action.js +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + + +/** + * Inner class which performs selection from either `text` or `target` + * properties and then executes copy or cut operations. + */ + +var ClipboardAction = /*#__PURE__*/function () { + /** + * @param {Object} options + */ + function ClipboardAction(options) { + _classCallCheck(this, ClipboardAction); + + this.resolveOptions(options); + this.initSelection(); + } + /** + * Defines base properties passed from constructor. + * @param {Object} options + */ + + + _createClass(ClipboardAction, [{ + key: "resolveOptions", + value: function resolveOptions() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + this.action = options.action; + this.container = options.container; + this.emitter = options.emitter; + this.target = options.target; + this.text = options.text; + this.trigger = options.trigger; + this.selectedText = ''; } - else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { - var isReadOnly = element.hasAttribute('readonly'); + /** + * Decides which selection strategy is going to be applied based + * on the existence of `text` and `target` properties. + */ - if (!isReadOnly) { - element.setAttribute('readonly', ''); - } - - element.select(); - element.setSelectionRange(0, element.value.length); - - if (!isReadOnly) { - element.removeAttribute('readonly'); - } - - selectedText = element.value; - } - else { - if (element.hasAttribute('contenteditable')) { - element.focus(); - } - - var selection = window.getSelection(); - var range = document.createRange(); - - range.selectNodeContents(element); - selection.removeAllRanges(); - selection.addRange(range); - - selectedText = selection.toString(); - } - - return selectedText; -} - -module.exports = select; - - -/***/ }), -/* 1 */ -/***/ (function(module, exports) { - -function E () { - // Keep this empty so it's easier to inherit from - // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) -} - -E.prototype = { - on: function (name, callback, ctx) { - var e = this.e || (this.e = {}); - - (e[name] || (e[name] = [])).push({ - fn: callback, - ctx: ctx - }); - - return this; - }, - - once: function (name, callback, ctx) { - var self = this; - function listener () { - self.off(name, listener); - callback.apply(ctx, arguments); - }; - - listener._ = callback - return this.on(name, listener, ctx); - }, - - emit: function (name) { - var data = [].slice.call(arguments, 1); - var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; - var len = evtArr.length; - - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); - } - - return this; - }, - - off: function (name, callback) { - var e = this.e || (this.e = {}); - var evts = e[name]; - var liveEvents = []; - - if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); + }, { + key: "initSelection", + value: function initSelection() { + if (this.text) { + this.selectFake(); + } else if (this.target) { + this.selectTarget(); } } + /** + * Creates a fake textarea element, sets its value from `text` property, + */ - // Remove event from queue to prevent memory leak - // Suggested by https://github.com/lazd - // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 + }, { + key: "createFakeElement", + value: function createFakeElement() { + var isRTL = document.documentElement.getAttribute('dir') === 'rtl'; + this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS - (liveEvents.length) - ? e[name] = liveEvents - : delete e[name]; + this.fakeElem.style.fontSize = '12pt'; // Reset box model - return this; + this.fakeElem.style.border = '0'; + this.fakeElem.style.padding = '0'; + this.fakeElem.style.margin = '0'; // Move element out of screen horizontally + + this.fakeElem.style.position = 'absolute'; + this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically + + var yPosition = window.pageYOffset || document.documentElement.scrollTop; + this.fakeElem.style.top = "".concat(yPosition, "px"); + this.fakeElem.setAttribute('readonly', ''); + this.fakeElem.value = this.text; + return this.fakeElem; + } + /** + * Get's the value of fakeElem, + * and makes a selection on it. + */ + + }, { + key: "selectFake", + value: function selectFake() { + var _this = this; + + var fakeElem = this.createFakeElement(); + + this.fakeHandlerCallback = function () { + return _this.removeFake(); + }; + + this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; + this.container.appendChild(fakeElem); + this.selectedText = select_default()(fakeElem); + this.copyText(); + this.removeFake(); + } + /** + * Only removes the fake element after another click event, that way + * a user can hit `Ctrl+C` to copy because selection still exists. + */ + + }, { + key: "removeFake", + value: function removeFake() { + if (this.fakeHandler) { + this.container.removeEventListener('click', this.fakeHandlerCallback); + this.fakeHandler = null; + this.fakeHandlerCallback = null; + } + + if (this.fakeElem) { + this.container.removeChild(this.fakeElem); + this.fakeElem = null; + } + } + /** + * Selects the content from element passed on `target` property. + */ + + }, { + key: "selectTarget", + value: function selectTarget() { + this.selectedText = select_default()(this.target); + this.copyText(); + } + /** + * Executes the copy operation based on the current selection. + */ + + }, { + key: "copyText", + value: function copyText() { + var succeeded; + + try { + succeeded = document.execCommand(this.action); + } catch (err) { + succeeded = false; + } + + this.handleResult(succeeded); + } + /** + * Fires an event based on the copy operation result. + * @param {Boolean} succeeded + */ + + }, { + key: "handleResult", + value: function handleResult(succeeded) { + this.emitter.emit(succeeded ? 'success' : 'error', { + action: this.action, + text: this.selectedText, + trigger: this.trigger, + clearSelection: this.clearSelection.bind(this) + }); + } + /** + * Moves focus away from `target` and back to the trigger, removes current selection. + */ + + }, { + key: "clearSelection", + value: function clearSelection() { + if (this.trigger) { + this.trigger.focus(); + } + + document.activeElement.blur(); + window.getSelection().removeAllRanges(); + } + /** + * Sets the `action` to be performed which can be either 'copy' or 'cut'. + * @param {String} action + */ + + }, { + key: "destroy", + + /** + * Destroy lifecycle. + */ + value: function destroy() { + this.removeFake(); + } + }, { + key: "action", + set: function set() { + var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; + this._action = action; + + if (this._action !== 'copy' && this._action !== 'cut') { + throw new Error('Invalid "action" value, use either "copy" or "cut"'); + } + } + /** + * Gets the `action` property. + * @return {String} + */ + , + get: function get() { + return this._action; + } + /** + * Sets the `target` property using an element + * that will be have its content copied. + * @param {Element} target + */ + + }, { + key: "target", + set: function set(target) { + if (target !== undefined) { + if (target && _typeof(target) === 'object' && target.nodeType === 1) { + if (this.action === 'copy' && target.hasAttribute('disabled')) { + throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); + } + + if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { + throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); + } + + this._target = target; + } else { + throw new Error('Invalid "target" value, use a valid Element'); + } + } + } + /** + * Gets the `target` property. + * @return {String|HTMLElement} + */ + , + get: function get() { + return this._target; + } + }]); + + return ClipboardAction; +}(); + +/* harmony default export */ var clipboard_action = (ClipboardAction); +;// CONCATENATED MODULE: ./src/clipboard.js +function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); } + +function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function clipboard_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); } } + +function clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) clipboard_defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + + + + +/** + * Helper function to retrieve attribute value. + * @param {String} suffix + * @param {Element} element + */ + +function getAttributeValue(suffix, element) { + var attribute = "data-clipboard-".concat(suffix); + + if (!element.hasAttribute(attribute)) { + return; } -}; -module.exports = E; -module.exports.TinyEmitter = E; + return element.getAttribute(attribute); +} +/** + * Base class which takes one or more elements, adds event listeners to them, + * and instantiates a new `ClipboardAction` on each click. + */ + + +var Clipboard = /*#__PURE__*/function (_Emitter) { + _inherits(Clipboard, _Emitter); + + var _super = _createSuper(Clipboard); + + /** + * @param {String|HTMLElement|HTMLCollection|NodeList} trigger + * @param {Object} options + */ + function Clipboard(trigger, options) { + var _this; + + clipboard_classCallCheck(this, Clipboard); + + _this = _super.call(this); + + _this.resolveOptions(options); + + _this.listenClick(trigger); + + return _this; + } + /** + * Defines if attributes would be resolved using internal setter functions + * or custom functions that were passed in the constructor. + * @param {Object} options + */ + + + clipboard_createClass(Clipboard, [{ + key: "resolveOptions", + value: function resolveOptions() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + this.action = typeof options.action === 'function' ? options.action : this.defaultAction; + this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; + this.text = typeof options.text === 'function' ? options.text : this.defaultText; + this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; + } + /** + * Adds a click event listener to the passed trigger. + * @param {String|HTMLElement|HTMLCollection|NodeList} trigger + */ + + }, { + key: "listenClick", + value: function listenClick(trigger) { + var _this2 = this; + + this.listener = listen_default()(trigger, 'click', function (e) { + return _this2.onClick(e); + }); + } + /** + * Defines a new `ClipboardAction` on each click event. + * @param {Event} e + */ + + }, { + key: "onClick", + value: function onClick(e) { + var trigger = e.delegateTarget || e.currentTarget; + + if (this.clipboardAction) { + this.clipboardAction = null; + } + + this.clipboardAction = new clipboard_action({ + action: this.action(trigger), + target: this.target(trigger), + text: this.text(trigger), + container: this.container, + trigger: trigger, + emitter: this + }); + } + /** + * Default `action` lookup function. + * @param {Element} trigger + */ + + }, { + key: "defaultAction", + value: function defaultAction(trigger) { + return getAttributeValue('action', trigger); + } + /** + * Default `target` lookup function. + * @param {Element} trigger + */ + + }, { + key: "defaultTarget", + value: function defaultTarget(trigger) { + var selector = getAttributeValue('target', trigger); + + if (selector) { + return document.querySelector(selector); + } + } + /** + * Returns the support of the given action, or all actions if no action is + * given. + * @param {String} [action] + */ + + }, { + key: "defaultText", + + /** + * Default `text` lookup function. + * @param {Element} trigger + */ + value: function defaultText(trigger) { + return getAttributeValue('text', trigger); + } + /** + * Destroy lifecycle. + */ + + }, { + key: "destroy", + value: function destroy() { + this.listener.destroy(); + + if (this.clipboardAction) { + this.clipboardAction.destroy(); + this.clipboardAction = null; + } + } + }], [{ + key: "isSupported", + value: function isSupported() { + var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; + var actions = typeof action === 'string' ? [action] : action; + var support = !!document.queryCommandSupported; + actions.forEach(function (action) { + support = support && !!document.queryCommandSupported(action); + }); + return support; + } + }]); + + return Clipboard; +}((tiny_emitter_default())); + +/* harmony default export */ var clipboard = (Clipboard); + +/***/ }), + +/***/ 828: +/***/ (function(module) { + +var DOCUMENT_NODE_TYPE = 9; + +/** + * A polyfill for Element.matches() + */ +if (typeof Element !== 'undefined' && !Element.prototype.matches) { + var proto = Element.prototype; + + proto.matches = proto.matchesSelector || + proto.mozMatchesSelector || + proto.msMatchesSelector || + proto.oMatchesSelector || + proto.webkitMatchesSelector; +} + +/** + * Finds the closest parent that matches a selector. + * + * @param {Element} element + * @param {String} selector + * @return {Function} + */ +function closest (element, selector) { + while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { + if (typeof element.matches === 'function' && + element.matches(selector)) { + return element; + } + element = element.parentNode; + } +} + +module.exports = closest; /***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { -var is = __webpack_require__(3); -var delegate = __webpack_require__(4); +/***/ 438: +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var closest = __webpack_require__(828); + +/** + * Delegates event to a selector. + * + * @param {Element} element + * @param {String} selector + * @param {String} type + * @param {Function} callback + * @param {Boolean} useCapture + * @return {Object} + */ +function _delegate(element, selector, type, callback, useCapture) { + var listenerFn = listener.apply(this, arguments); + + element.addEventListener(type, listenerFn, useCapture); + + return { + destroy: function() { + element.removeEventListener(type, listenerFn, useCapture); + } + } +} + +/** + * Delegates event to a selector. + * + * @param {Element|String|Array} [elements] + * @param {String} selector + * @param {String} type + * @param {Function} callback + * @param {Boolean} useCapture + * @return {Object} + */ +function delegate(elements, selector, type, callback, useCapture) { + // Handle the regular Element usage + if (typeof elements.addEventListener === 'function') { + return _delegate.apply(null, arguments); + } + + // Handle Element-less usage, it defaults to global delegation + if (typeof type === 'function') { + // Use `document` as the first parameter, then apply arguments + // This is a short way to .unshift `arguments` without running into deoptimizations + return _delegate.bind(null, document).apply(null, arguments); + } + + // Handle Selector-based usage + if (typeof elements === 'string') { + elements = document.querySelectorAll(elements); + } + + // Handle Array-like based usage + return Array.prototype.map.call(elements, function (element) { + return _delegate(element, selector, type, callback, useCapture); + }); +} + +/** + * Finds closest match and invokes callback. + * + * @param {Element} element + * @param {String} selector + * @param {String} type + * @param {Function} callback + * @return {Function} + */ +function listener(element, selector, type, callback) { + return function(e) { + e.delegateTarget = closest(e.target, selector); + + if (e.delegateTarget) { + callback.call(element, e); + } + } +} + +module.exports = delegate; + + +/***/ }), + +/***/ 879: +/***/ (function(__unused_webpack_module, exports) { + +/** + * Check if argument is a HTML element. + * + * @param {Object} value + * @return {Boolean} + */ +exports.node = function(value) { + return value !== undefined + && value instanceof HTMLElement + && value.nodeType === 1; +}; + +/** + * Check if argument is a list of HTML elements. + * + * @param {Object} value + * @return {Boolean} + */ +exports.nodeList = function(value) { + var type = Object.prototype.toString.call(value); + + return value !== undefined + && (type === '[object NodeList]' || type === '[object HTMLCollection]') + && ('length' in value) + && (value.length === 0 || exports.node(value[0])); +}; + +/** + * Check if argument is a string. + * + * @param {Object} value + * @return {Boolean} + */ +exports.string = function(value) { + return typeof value === 'string' + || value instanceof String; +}; + +/** + * Check if argument is a function. + * + * @param {Object} value + * @return {Boolean} + */ +exports.fn = function(value) { + var type = Object.prototype.toString.call(value); + + return type === '[object Function]'; +}; + + +/***/ }), + +/***/ 370: +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +var is = __webpack_require__(879); +var delegate = __webpack_require__(438); /** * Validates all params and calls the right @@ -10799,652 +11238,193 @@ module.exports = listen; /***/ }), -/* 3 */ -/***/ (function(module, exports) { -/** - * Check if argument is a HTML element. - * - * @param {Object} value - * @return {Boolean} - */ -exports.node = function(value) { - return value !== undefined - && value instanceof HTMLElement - && value.nodeType === 1; -}; +/***/ 817: +/***/ (function(module) { -/** - * Check if argument is a list of HTML elements. - * - * @param {Object} value - * @return {Boolean} - */ -exports.nodeList = function(value) { - var type = Object.prototype.toString.call(value); +function select(element) { + var selectedText; - return value !== undefined - && (type === '[object NodeList]' || type === '[object HTMLCollection]') - && ('length' in value) - && (value.length === 0 || exports.node(value[0])); -}; + if (element.nodeName === 'SELECT') { + element.focus(); -/** - * Check if argument is a string. - * - * @param {Object} value - * @return {Boolean} - */ -exports.string = function(value) { - return typeof value === 'string' - || value instanceof String; -}; + selectedText = element.value; + } + else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { + var isReadOnly = element.hasAttribute('readonly'); -/** - * Check if argument is a function. - * - * @param {Object} value - * @return {Boolean} - */ -exports.fn = function(value) { - var type = Object.prototype.toString.call(value); + if (!isReadOnly) { + element.setAttribute('readonly', ''); + } - return type === '[object Function]'; -}; + element.select(); + element.setSelectionRange(0, element.value.length); + + if (!isReadOnly) { + element.removeAttribute('readonly'); + } + + selectedText = element.value; + } + else { + if (element.hasAttribute('contenteditable')) { + element.focus(); + } + + var selection = window.getSelection(); + var range = document.createRange(); + + range.selectNodeContents(element); + selection.removeAllRanges(); + selection.addRange(range); + + selectedText = selection.toString(); + } + + return selectedText; +} + +module.exports = select; /***/ }), -/* 4 */ -/***/ (function(module, exports, __webpack_require__) { -var closest = __webpack_require__(5); +/***/ 279: +/***/ (function(module) { -/** - * Delegates event to a selector. - * - * @param {Element} element - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @param {Boolean} useCapture - * @return {Object} - */ -function _delegate(element, selector, type, callback, useCapture) { - var listenerFn = listener.apply(this, arguments); - - element.addEventListener(type, listenerFn, useCapture); - - return { - destroy: function() { - element.removeEventListener(type, listenerFn, useCapture); - } - } +function E () { + // Keep this empty so it's easier to inherit from + // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) } -/** - * Delegates event to a selector. - * - * @param {Element|String|Array} [elements] - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @param {Boolean} useCapture - * @return {Object} - */ -function delegate(elements, selector, type, callback, useCapture) { - // Handle the regular Element usage - if (typeof elements.addEventListener === 'function') { - return _delegate.apply(null, arguments); - } +E.prototype = { + on: function (name, callback, ctx) { + var e = this.e || (this.e = {}); - // Handle Element-less usage, it defaults to global delegation - if (typeof type === 'function') { - // Use `document` as the first parameter, then apply arguments - // This is a short way to .unshift `arguments` without running into deoptimizations - return _delegate.bind(null, document).apply(null, arguments); - } - - // Handle Selector-based usage - if (typeof elements === 'string') { - elements = document.querySelectorAll(elements); - } - - // Handle Array-like based usage - return Array.prototype.map.call(elements, function (element) { - return _delegate(element, selector, type, callback, useCapture); + (e[name] || (e[name] = [])).push({ + fn: callback, + ctx: ctx }); -} -/** - * Finds closest match and invokes callback. - * - * @param {Element} element - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @return {Function} - */ -function listener(element, selector, type, callback) { - return function(e) { - e.delegateTarget = closest(e.target, selector); + return this; + }, - if (e.delegateTarget) { - callback.call(element, e); - } - } -} + once: function (name, callback, ctx) { + var self = this; + function listener () { + self.off(name, listener); + callback.apply(ctx, arguments); + }; -module.exports = delegate; + listener._ = callback + return this.on(name, listener, ctx); + }, + emit: function (name) { + var data = [].slice.call(arguments, 1); + var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); + var i = 0; + var len = evtArr.length; -/***/ }), -/* 5 */ -/***/ (function(module, exports) { - -var DOCUMENT_NODE_TYPE = 9; - -/** - * A polyfill for Element.matches() - */ -if (typeof Element !== 'undefined' && !Element.prototype.matches) { - var proto = Element.prototype; - - proto.matches = proto.matchesSelector || - proto.mozMatchesSelector || - proto.msMatchesSelector || - proto.oMatchesSelector || - proto.webkitMatchesSelector; -} - -/** - * Finds the closest parent that matches a selector. - * - * @param {Element} element - * @param {String} selector - * @return {Function} - */ -function closest (element, selector) { - while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { - if (typeof element.matches === 'function' && - element.matches(selector)) { - return element; - } - element = element.parentNode; - } -} - -module.exports = closest; - - -/***/ }), -/* 6 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); - -// EXTERNAL MODULE: ./node_modules/select/src/select.js -var src_select = __webpack_require__(0); -var select_default = /*#__PURE__*/__webpack_require__.n(src_select); - -// CONCATENATED MODULE: ./src/clipboard-action.js -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -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"); } } - - - -/** - * Inner class which performs selection from either `text` or `target` - * properties and then executes copy or cut operations. - */ - -var clipboard_action_ClipboardAction = function () { - /** - * @param {Object} options - */ - function ClipboardAction(options) { - _classCallCheck(this, ClipboardAction); - - this.resolveOptions(options); - this.initSelection(); + for (i; i < len; i++) { + evtArr[i].fn.apply(evtArr[i].ctx, data); } - /** - * Defines base properties passed from constructor. - * @param {Object} options - */ + return this; + }, + off: function (name, callback) { + var e = this.e || (this.e = {}); + var evts = e[name]; + var liveEvents = []; - _createClass(ClipboardAction, [{ - key: 'resolveOptions', - value: function resolveOptions() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - this.action = options.action; - this.container = options.container; - this.emitter = options.emitter; - this.target = options.target; - this.text = options.text; - this.trigger = options.trigger; - - this.selectedText = ''; - } - - /** - * Decides which selection strategy is going to be applied based - * on the existence of `text` and `target` properties. - */ - - }, { - key: 'initSelection', - value: function initSelection() { - if (this.text) { - this.selectFake(); - } else if (this.target) { - this.selectTarget(); - } - } - - /** - * Creates a fake textarea element, sets its value from `text` property, - * and makes a selection on it. - */ - - }, { - key: 'selectFake', - value: function selectFake() { - var _this = this; - - var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; - - this.removeFake(); - - this.fakeHandlerCallback = function () { - return _this.removeFake(); - }; - this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; - - this.fakeElem = document.createElement('textarea'); - // Prevent zooming on iOS - this.fakeElem.style.fontSize = '12pt'; - // Reset box model - this.fakeElem.style.border = '0'; - this.fakeElem.style.padding = '0'; - this.fakeElem.style.margin = '0'; - // Move element out of screen horizontally - this.fakeElem.style.position = 'absolute'; - this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; - // Move element to the same position vertically - var yPosition = window.pageYOffset || document.documentElement.scrollTop; - this.fakeElem.style.top = yPosition + 'px'; - - this.fakeElem.setAttribute('readonly', ''); - this.fakeElem.value = this.text; - - this.container.appendChild(this.fakeElem); - - this.selectedText = select_default()(this.fakeElem); - this.copyText(); - } - - /** - * Only removes the fake element after another click event, that way - * a user can hit `Ctrl+C` to copy because selection still exists. - */ - - }, { - key: 'removeFake', - value: function removeFake() { - if (this.fakeHandler) { - this.container.removeEventListener('click', this.fakeHandlerCallback); - this.fakeHandler = null; - this.fakeHandlerCallback = null; - } - - if (this.fakeElem) { - this.container.removeChild(this.fakeElem); - this.fakeElem = null; - } - } - - /** - * Selects the content from element passed on `target` property. - */ - - }, { - key: 'selectTarget', - value: function selectTarget() { - this.selectedText = select_default()(this.target); - this.copyText(); - } - - /** - * Executes the copy operation based on the current selection. - */ - - }, { - key: 'copyText', - value: function copyText() { - var succeeded = void 0; - - try { - succeeded = document.execCommand(this.action); - } catch (err) { - succeeded = false; - } - - this.handleResult(succeeded); - } - - /** - * Fires an event based on the copy operation result. - * @param {Boolean} succeeded - */ - - }, { - key: 'handleResult', - value: function handleResult(succeeded) { - this.emitter.emit(succeeded ? 'success' : 'error', { - action: this.action, - text: this.selectedText, - trigger: this.trigger, - clearSelection: this.clearSelection.bind(this) - }); - } - - /** - * Moves focus away from `target` and back to the trigger, removes current selection. - */ - - }, { - key: 'clearSelection', - value: function clearSelection() { - if (this.trigger) { - this.trigger.focus(); - } - document.activeElement.blur(); - window.getSelection().removeAllRanges(); - } - - /** - * Sets the `action` to be performed which can be either 'copy' or 'cut'. - * @param {String} action - */ - - }, { - key: 'destroy', - - - /** - * Destroy lifecycle. - */ - value: function destroy() { - this.removeFake(); - } - }, { - key: 'action', - set: function set() { - var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; - - this._action = action; - - if (this._action !== 'copy' && this._action !== 'cut') { - throw new Error('Invalid "action" value, use either "copy" or "cut"'); - } - } - - /** - * Gets the `action` property. - * @return {String} - */ - , - get: function get() { - return this._action; - } - - /** - * Sets the `target` property using an element - * that will be have its content copied. - * @param {Element} target - */ - - }, { - key: 'target', - set: function set(target) { - if (target !== undefined) { - if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { - if (this.action === 'copy' && target.hasAttribute('disabled')) { - throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); - } - - if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { - throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); - } - - this._target = target; - } else { - throw new Error('Invalid "target" value, use a valid Element'); - } - } - } - - /** - * Gets the `target` property. - * @return {String|HTMLElement} - */ - , - get: function get() { - return this._target; - } - }]); - - return ClipboardAction; -}(); - -/* harmony default export */ var clipboard_action = (clipboard_action_ClipboardAction); -// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js -var tiny_emitter = __webpack_require__(1); -var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter); - -// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js -var listen = __webpack_require__(2); -var listen_default = /*#__PURE__*/__webpack_require__.n(listen); - -// CONCATENATED MODULE: ./src/clipboard.js -var clipboard_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -var clipboard_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 clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - - - - -/** - * Base class which takes one or more elements, adds event listeners to them, - * and instantiates a new `ClipboardAction` on each click. - */ - -var clipboard_Clipboard = function (_Emitter) { - _inherits(Clipboard, _Emitter); - - /** - * @param {String|HTMLElement|HTMLCollection|NodeList} trigger - * @param {Object} options - */ - function Clipboard(trigger, options) { - clipboard_classCallCheck(this, Clipboard); - - var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); - - _this.resolveOptions(options); - _this.listenClick(trigger); - return _this; + if (evts && callback) { + for (var i = 0, len = evts.length; i < len; i++) { + if (evts[i].fn !== callback && evts[i].fn._ !== callback) + liveEvents.push(evts[i]); + } } - /** - * Defines if attributes would be resolved using internal setter functions - * or custom functions that were passed in the constructor. - * @param {Object} options - */ + // Remove event from queue to prevent memory leak + // Suggested by https://github.com/lazd + // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 + (liveEvents.length) + ? e[name] = liveEvents + : delete e[name]; - clipboard_createClass(Clipboard, [{ - key: 'resolveOptions', - value: function resolveOptions() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return this; + } +}; - this.action = typeof options.action === 'function' ? options.action : this.defaultAction; - this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; - this.text = typeof options.text === 'function' ? options.text : this.defaultText; - this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; - } +module.exports = E; +module.exports.TinyEmitter = E; - /** - * Adds a click event listener to the passed trigger. - * @param {String|HTMLElement|HTMLCollection|NodeList} trigger - */ - - }, { - key: 'listenClick', - value: function listenClick(trigger) { - var _this2 = this; - - this.listener = listen_default()(trigger, 'click', function (e) { - return _this2.onClick(e); - }); - } - - /** - * Defines a new `ClipboardAction` on each click event. - * @param {Event} e - */ - - }, { - key: 'onClick', - value: function onClick(e) { - var trigger = e.delegateTarget || e.currentTarget; - - if (this.clipboardAction) { - this.clipboardAction = null; - } - - this.clipboardAction = new clipboard_action({ - action: this.action(trigger), - target: this.target(trigger), - text: this.text(trigger), - container: this.container, - trigger: trigger, - emitter: this - }); - } - - /** - * Default `action` lookup function. - * @param {Element} trigger - */ - - }, { - key: 'defaultAction', - value: function defaultAction(trigger) { - return getAttributeValue('action', trigger); - } - - /** - * Default `target` lookup function. - * @param {Element} trigger - */ - - }, { - key: 'defaultTarget', - value: function defaultTarget(trigger) { - var selector = getAttributeValue('target', trigger); - - if (selector) { - return document.querySelector(selector); - } - } - - /** - * Returns the support of the given action, or all actions if no action is - * given. - * @param {String} [action] - */ - - }, { - key: 'defaultText', - - - /** - * Default `text` lookup function. - * @param {Element} trigger - */ - value: function defaultText(trigger) { - return getAttributeValue('text', trigger); - } - - /** - * Destroy lifecycle. - */ - - }, { - key: 'destroy', - value: function destroy() { - this.listener.destroy(); - - if (this.clipboardAction) { - this.clipboardAction.destroy(); - this.clipboardAction = null; - } - } - }], [{ - key: 'isSupported', - value: function isSupported() { - var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; - - var actions = typeof action === 'string' ? [action] : action; - var support = !!document.queryCommandSupported; - - actions.forEach(function (action) { - support = support && !!document.queryCommandSupported(action); - }); - - return support; - } - }]); - - return Clipboard; -}(tiny_emitter_default.a); - -/** - * Helper function to retrieve attribute value. - * @param {String} suffix - * @param {Element} element - */ - - -function getAttributeValue(suffix, element) { - var attribute = 'data-clipboard-' + suffix; - - if (!element.hasAttribute(attribute)) { - return; - } - - return element.getAttribute(attribute); -} - -/* harmony default export */ var clipboard = __webpack_exports__["default"] = (clipboard_Clipboard); /***/ }) -/******/ ])["default"]; + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +/******/ // module exports must be returned from runtime so entry inlining is disabled +/******/ // startup +/******/ // Load entry module and return exports +/******/ return __webpack_require__(134); +/******/ })() +.default; }); },{}],80:[function(require,module,exports){ (function (global,Buffer){(function (){ @@ -25823,16 +25803,18 @@ exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); },{"./decode":189,"./encode":190}],192:[function(require,module,exports){ +(function (global){(function (){ /*! queue-microtask. MIT License. Feross Aboukhadijeh */ let promise module.exports = typeof queueMicrotask === 'function' - ? queueMicrotask.bind(globalThis) + ? queueMicrotask.bind(typeof window !== 'undefined' ? window : global) // reuse resolved promise, and allocate it lazily : cb => (promise || (promise = Promise.resolve())) .then(cb) .catch(err => setTimeout(() => { throw err }, 0)) +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],193:[function(require,module,exports){ var iterate = function (list) { var offset = 0 @@ -27893,7 +27875,7 @@ class Peer extends stream.Duplex { try { this._pc = new (this._wrtc.RTCPeerConnection)(this.config) } catch (err) { - queueMicrotask(() => this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR'))) + this.destroy(errCode(err, 'ERR_PC_CONSTRUCTOR')) return } @@ -27917,6 +27899,13 @@ class Peer extends stream.Duplex { this._onIceCandidate(event) } + // HACK: Fix for odd Firefox behavior, see: https://github.com/feross/simple-peer/pull/783 + if (typeof this._pc.peerIdentity === 'object') { + this._pc.peerIdentity.catch(err => { + this.destroy(errCode(err, 'ERR_PC_PEER_IDENTITY')) + }) + } + // Other spec events, unused by this implementation: // - onconnectionstatechange // - onicecandidateerror @@ -27966,7 +27955,8 @@ class Peer extends stream.Duplex { } signal (data) { - if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_SIGNALING') + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED') if (typeof data === 'string') { try { data = JSON.parse(data) @@ -28029,6 +28019,8 @@ class Peer extends stream.Duplex { * @param {ArrayBufferView|ArrayBuffer|Buffer|string|Blob} chunk */ send (chunk) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED') this._channel.send(chunk) } @@ -28038,6 +28030,8 @@ class Peer extends stream.Duplex { * @param {Object} init */ addTransceiver (kind, init) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED') this._debug('addTransceiver()') if (this.initiator) { @@ -28060,6 +28054,8 @@ class Peer extends stream.Duplex { * @param {MediaStream} stream */ addStream (stream) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED') this._debug('addStream()') stream.getTracks().forEach(track => { @@ -28073,6 +28069,8 @@ class Peer extends stream.Duplex { * @param {MediaStream} stream */ addTrack (track, stream) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED') this._debug('addTrack()') const submap = this._senderMap.get(track) || new Map() // nested Maps map [track, stream] to sender @@ -28096,6 +28094,8 @@ class Peer extends stream.Duplex { * @param {MediaStream} stream */ replaceTrack (oldTrack, newTrack, stream) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED') this._debug('replaceTrack()') const submap = this._senderMap.get(oldTrack) @@ -28118,6 +28118,8 @@ class Peer extends stream.Duplex { * @param {MediaStream} stream */ removeTrack (track, stream) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED') this._debug('removeSender()') const submap = this._senderMap.get(track) @@ -28143,6 +28145,8 @@ class Peer extends stream.Duplex { * @param {MediaStream} stream */ removeStream (stream) { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED') this._debug('removeSenders()') stream.getTracks().forEach(track => { @@ -28167,6 +28171,9 @@ class Peer extends stream.Duplex { } negotiate () { + if (this.destroying) return + if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') + if (this.initiator) { if (this._isNegotiating) { this._queuedNegotiation = true diff --git a/bin/bundle.min.js b/bin/bundle.min.js index b2ca7a1..749f1d4 100644 --- a/bin/bundle.min.js +++ b/bin/bundle.min.js @@ -1,6 +1,6 @@ -!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){for(var t=navigator.userAgent.toLowerCase().includes("firefox"),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||["transform","perspective"].includes(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])}),[]),O=[].concat(C,[S]).reduce((function(e,t){return e.concat([t,t+"-"+T,t+"-"+j])}),[]),R=["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=q(i.top,t.top),t.right=D(i.right,t.right),t.bottom=D(i.bottom,t.bottom),t.left=q(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 K(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 Y(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=Y("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=K({reference:j,element:E,strategy:"absolute",placement:s}),O=z(Object.assign({},E,I)),R=f===L?O:j,B={top:T.top-R.top+b.top,bottom:R.bottom-T.bottom+b.bottom,left:T.left-R.left+b.left,right:R.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]=K({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,O=Object.assign({position:a},p&&oe);return c?Object.assign({},O,((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({},O,((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=O.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?O: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:O,boundary:p,rootBoundary:u,altBoundary:d,padding:l}),q=U?B?k:E:B?w:_;y[P]>C[P]&&(q=ue(q));var D=ue(q),H=[];if(o&&H.push(M[R]<=0),a&&H.push(M[q]<=0,M[D]<=0),H.every((function(e){return e}))){L=O,A=!1;break}j.set(O,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 q(e,D(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,O="function"==typeof g?g(Object.assign({},t.rects,{placement:t.placement})):g,R={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],K=t.elements.arrow,Y=f&&K?h(K):{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],Y[P]),te=S?L[P]/2-z-ee-Z-O:W-ee-Z-O,ne=S?-L[P]/2+z+ee+Q+O:$+ee+Q+O,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?D(H,se):H,M,f?q(F,ae):F);A[C]=ce,R[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?D(de,se):de,ue,f?q(fe,ae):fe);A[j]=he,R[j]=he-ue}}t.modifiersData[i]=R}},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 Y("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:186}],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:57}],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){function i(e){let t=e>>3;return e%8!=0&&t++,t}void 0!==t&&(t.exports=class{constructor(e=0,t){const n=null!=t&&t.grow;this.grow=n&&isFinite(n)&&i(n)||n||0,this.buffer="number"==typeof e?new Uint8Array(i(e)):e}get(e){const t=e>>3;return t>e%8)}set(e,t=!0){const n=e>>3;if(t){if(this.buffer.length>e%8}else n>e%8))}})},{}],11:[function(e,t,n){(function(n){(function(){ +!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){for(var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox"),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:186}],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:57}],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){function i(e){let t=e>>3;return e%8!=0&&t++,t}void 0!==t&&(t.exports=class{constructor(e=0,t){const n=null!=t&&t.grow;this.grow=n&&isFinite(n)&&i(n)||n||0,this.buffer="number"==typeof e?new Uint8Array(i(e)):e}get(e){const t=e>>3;return t>e%8)}set(e,t=!0){const n=e>>3;if(t){if(this.buffer.length>e%8}else n>e%8))}})},{}],11:[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>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},{}],13:[function(e,t,n){(function(i){(function(){n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let i=0,r=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==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":14,_process:186}],14:[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))}},{}],16:[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},{}],17:[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):O(e,s)):T(e,s,t,!1)}else i||(s.reading=!1,O(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 O(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 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 q(e){var t=e._readableState;l("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(D,t,e))}function D(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?q(this):L(this),null;if(0===(e=A(e,t))&&t.ended)return 0===t.length&&q(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&&q(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":16,"./_stream_duplex":17,"./internal/streams/destroy":24,"./internal/streams/state":28,"./internal/streams/stream":29,_process:186,buffer:57,inherits:119,"util-deprecate":305}],22:[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":25,_process:186}],23:[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":16,"./end-of-stream":25}],28:[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":16}],29:[function(e,t,n){t.exports=e("events").EventEmitter},{events:98}],30:[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":17,"./lib/_stream_passthrough.js":18,"./lib/_stream_readable.js":19,"./lib/_stream_transform.js":20,"./lib/_stream_writable.js":21,"./lib/internal/streams/end-of-stream.js":25,"./lib/internal/streams/pipeline.js":27}],31:[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":55,"./lib/client/udp-tracker":55,"./lib/client/websocket-tracker":33,"./lib/common":34,_process:186,buffer:57,debug:35,events:98,once:182,"queue-microtask":192,"run-parallel":217,"simple-peer":222}],32:[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:98}],33:[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,10);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)})),s.signal(e.offer),this.client.emit("peer",s)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);s=this.peers[t],s?(s.id=a.binaryToHex(e.peer_id),s.signal(e.answer),this.client.emit("peer",s),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":34,"./tracker":32,debug:35,randombytes:194,"simple-peer":222,"simple-websocket":243}],34:[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":55,buffer:57}],35:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":36,_process:186,dup:13}],36:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:37}],37:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],38:[function(e,t,n){(function(e){(function(){ +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>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},{}],13:[function(e,t,n){(function(i){(function(){n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let i=0,r=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==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":14,_process:186}],14:[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))}},{}],16:[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},{}],17:[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":16,"./_stream_duplex":17,"./internal/streams/destroy":24,"./internal/streams/state":28,"./internal/streams/stream":29,_process:186,buffer:57,inherits:119,"util-deprecate":305}],22:[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":25,_process:186}],23:[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":16,"./end-of-stream":25}],28:[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":16}],29:[function(e,t,n){t.exports=e("events").EventEmitter},{events:98}],30:[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":17,"./lib/_stream_passthrough.js":18,"./lib/_stream_readable.js":19,"./lib/_stream_transform.js":20,"./lib/_stream_writable.js":21,"./lib/internal/streams/end-of-stream.js":25,"./lib/internal/streams/pipeline.js":27}],31:[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":55,"./lib/client/udp-tracker":55,"./lib/client/websocket-tracker":33,"./lib/common":34,_process:186,buffer:57,debug:35,events:98,once:182,"queue-microtask":192,"run-parallel":217,"simple-peer":222}],32:[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:98}],33:[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,10);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)})),s.signal(e.offer),this.client.emit("peer",s)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);s=this.peers[t],s?(s.id=a.binaryToHex(e.peer_id),s.signal(e.answer),this.client.emit("peer",s),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":34,"./tracker":32,debug:35,randombytes:194,"simple-peer":222,"simple-websocket":243}],34:[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":55,buffer:57}],35:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":36,_process:186,dup:13}],36:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:37}],37:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],38:[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:57}],39:[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 * @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(D(e,ArrayBuffer)||e&&D(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)||D(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(D(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 O(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 R(e,t,n,r,o){return t=+t,n>>>=0,o||O(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||O(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 R(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return R(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 q(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function D(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:57,ieee754:117}],58:[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:57}],59:[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:57,"buffer-alloc-unsafe":58,"buffer-fill":60}],60:[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:57}],61:[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"}},{}],62:[function(e,t,n){ +"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:57,ieee754:117}],58:[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:57}],59:[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:57,"buffer-alloc-unsafe":58,"buffer-fill":60}],60:[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:57}],61:[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"}},{}],62:[function(e,t,n){ /*! * bytes * Copyright(c) 2012-2014 TJ Holowaychuk * Copyright(c) 2015 Jed Watson * MIT Licensed */ -"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+)$/,o={b:1,kb:1024,mb:1<<20,gb:1<<30,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},s=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function a(e,t){if(!Number.isFinite(e))return null;var n=Math.abs(e),s=t&&t.thousandsSeparator||"",a=t&&t.unitSeparator||"",c=t&&void 0!==t.decimalPlaces?t.decimalPlaces:2,l=Boolean(t&&t.fixedDecimals),p=t&&t.unit||"";p&&o[p.toLowerCase()]||(p=n>=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)}},{}],63:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],64:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":66,"./_stream_writable":68,_process:186,dup:17,inherits:119}],65:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":67,dup:18,inherits:119}],66:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":63,"./_stream_duplex":64,"./internal/streams/async_iterator":69,"./internal/streams/buffer_list":70,"./internal/streams/destroy":71,"./internal/streams/from":73,"./internal/streams/state":75,"./internal/streams/stream":76,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],67:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":63,"./_stream_duplex":64,dup:20,inherits:119}],68:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":63,"./_stream_duplex":64,"./internal/streams/destroy":71,"./internal/streams/state":75,"./internal/streams/stream":76,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],69:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":72,_process:186,dup:22}],70:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],71:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],72:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":63,dup:25}],73:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],74:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":63,"./end-of-stream":72,dup:27}],75:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":63,dup:28}],76:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],77:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":64,"./lib/_stream_passthrough.js":65,"./lib/_stream_readable.js":66,"./lib/_stream_transform.js":67,"./lib/_stream_writable.js":68,"./lib/internal/streams/end-of-stream.js":72,"./lib/internal/streams/pipeline.js":74,dup:30}],78:[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,{zeroPadding:r}),this._outstandingPuts=0;let o=0;this._blockstream.on("data",(t=>{this.destroyed||(this._outstandingPuts+=1,e.put(o,t,(e=>{if(e)return this.destroy(e);this._outstandingPuts-=1,0===this._outstandingPuts&&"function"==typeof this._finalCb&&(this._finalCb(null),this._finalCb=null)})),o+=1)})).on("error",(e=>{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":39,"readable-stream":77}],79:[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+)$/,o={b:1,kb:1024,mb:1<<20,gb:1<<30,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},s=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function a(e,t){if(!Number.isFinite(e))return null;var n=Math.abs(e),s=t&&t.thousandsSeparator||"",a=t&&t.unitSeparator||"",c=t&&void 0!==t.decimalPlaces?t.decimalPlaces:2,l=Boolean(t&&t.fixedDecimals),p=t&&t.unit||"";p&&o[p.toLowerCase()]||(p=n>=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)}},{}],63:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],64:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":66,"./_stream_writable":68,_process:186,dup:17,inherits:119}],65:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":67,dup:18,inherits:119}],66:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":63,"./_stream_duplex":64,"./internal/streams/async_iterator":69,"./internal/streams/buffer_list":70,"./internal/streams/destroy":71,"./internal/streams/from":73,"./internal/streams/state":75,"./internal/streams/stream":76,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],67:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":63,"./_stream_duplex":64,dup:20,inherits:119}],68:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":63,"./_stream_duplex":64,"./internal/streams/destroy":71,"./internal/streams/state":75,"./internal/streams/stream":76,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],69:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":72,_process:186,dup:22}],70:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],71:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],72:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":63,dup:25}],73:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],74:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":63,"./end-of-stream":72,dup:27}],75:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":63,dup:28}],76:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],77:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":64,"./lib/_stream_passthrough.js":65,"./lib/_stream_readable.js":66,"./lib/_stream_transform.js":67,"./lib/_stream_writable.js":68,"./lib/internal/streams/end-of-stream.js":72,"./lib/internal/streams/pipeline.js":74,dup:30}],78:[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":39,"readable-stream":77}],79:[function(e,t,n){ /*! - * clipboard.js v2.0.6 + * clipboard.js v2.0.8 * https://clipboardjs.com/ - * + * * Licensed MIT © Zeno Rocha */ -var i,r;i=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,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return 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=6)}([function(e,t){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}},function(e,t){function n(){}n.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:"selectFake",value:function(){var e=this,t="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,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[t?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=r()(this.fakeElem),this.copyText()}},{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=r()(this.target),this.copyText()}},{key:"copyText",value:function(){var e=void 0;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"!==(void 0===e?"undefined":o(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}}]),e}(),c=n(1),l=n.n(c),p=n(2),u=n.n(p),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},f=function(){function e(e,t){for(var n=0;n0&&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=u()(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 a({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 m("action",e)}},{key:"defaultTarget",value:function(e){var t=m("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return m("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&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}}]),t}(l.a);function m(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}t.default=h}]).default},"object"==typeof n&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof n?n.ClipboardJS=r():i.ClipboardJS=r()},{}],80:[function(e,t,n){(function(n,i){(function(){ +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;i */ 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=a.pieceLength||s(e.reduce(_,0));p.info["piece length"]=f,function(e,t,n){n=d(n);const r=[];let s=0;const a=e.map((e=>e.getStream));let c=0,l=0,p=!1;const f=new u(a),h=new o(t,{zeroPadding:!1});function g(e){s+=e.length;const t=l;m(e,(e=>{r[t]=e,c-=1,y()})),c+=1,l+=1}function v(){p=!0,y()}function b(e){x(),n(e)}function x(){f.removeListener("error",b),h.removeListener("data",g),h.removeListener("end",v),h.removeListener("error",b)}function y(){p&&0===c&&(x(),n(null,i.from(r.join(""),"hex"),s))}f.on("error",b),f.pipe(h).on("data",g).on("end",v).on("error",b)}(e,f,((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":55,bencode:7,"block-stream2":39,buffer:57,"filestream/read":114,"is-file":55,junk:122,multistream:165,once:182,path:184,"piece-length":185,"queue-microtask":192,"readable-stream":95,"run-parallel":217,"simple-sha1":241}],81:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],82:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":84,"./_stream_writable":86,_process:186,dup:17,inherits:119}],83:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":85,dup:18,inherits:119}],84:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":81,"./_stream_duplex":82,"./internal/streams/async_iterator":87,"./internal/streams/buffer_list":88,"./internal/streams/destroy":89,"./internal/streams/from":91,"./internal/streams/state":93,"./internal/streams/stream":94,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],85:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":81,"./_stream_duplex":82,dup:20,inherits:119}],86:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":81,"./_stream_duplex":82,"./internal/streams/destroy":89,"./internal/streams/state":93,"./internal/streams/stream":94,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],87:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":90,_process:186,dup:22}],88:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],89:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],90:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":81,dup:25}],91:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],92:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":81,"./end-of-stream":90,dup:27}],93:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":81,dup:28}],94:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],95:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":82,"./lib/_stream_passthrough.js":83,"./lib/_stream_readable.js":84,"./lib/_stream_transform.js":85,"./lib/_stream_writable.js":86,"./lib/internal/streams/end-of-stream.js":90,"./lib/internal/streams/pipeline.js":92,dup:30}],96:[function(e,t,n){var i=e("once"),r=function(){},o=function(e,t,n){if("function"==typeof t)return o(e,null,t);t||(t={}),n=i(n||r);var s=e._writableState,a=e._readableState,c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,p=function(){e.writable||u()},u=function(){l=!1,c||n.call(e)},d=function(){c=!1,l||n.call(e)},f=function(t){n.call(e,t?new Error("exited with error code: "+t):null)},h=function(t){n.call(e,t)},m=function(){return(!c||a&&a.ended)&&(!l||s&&s.ended)?void 0:n.call(e,new Error("premature close"))},g=function(){e.req.on("finish",u)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!s&&(e.on("end",p),e.on("close",p)):(e.on("complete",u),e.on("abort",m),e.req?g():e.on("request",g)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",f),e.on("end",d),e.on("finish",u),!1!==t.error&&e.on("error",h),e.on("close",m),function(){e.removeListener("complete",u),e.removeListener("abort",m),e.removeListener("request",g),e.req&&e.req.removeListener("finish",u),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",u),e.removeListener("exit",f),e.removeListener("end",d),e.removeListener("error",h),e.removeListener("close",m)}};t.exports=o},{once:182}],97:[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=void 0),null!=t&&(n.code=t);try{return i(e,n)}catch(t){n.message=e.message,n.stack=e.stack;const r=function(){};return r.prototype=Object.create(Object.getPrototypeOf(e)),i(new r,n)}}},{}],98:[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):[]}},{}],99:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],100:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":102,"./_stream_writable":104,_process:186,dup:17,inherits:119}],101:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":103,dup:18,inherits:119}],102:[function(e,t,n){arguments[4][19][0].apply(n,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:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],103:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":99,"./_stream_duplex":100,dup:20,inherits:119}],104:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":99,"./_stream_duplex":100,"./internal/streams/destroy":107,"./internal/streams/state":111,"./internal/streams/stream":112,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],105:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":108,_process:186,dup:22}],106:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],107:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],108:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":99,dup:25}],109:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],110:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":99,"./end-of-stream":108,dup:27}],111:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":99,dup:28}],112:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],113:[function(e,t,n){arguments[4][30][0].apply(n,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:30}],114:[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":113,"typedarray-to-buffer":295}],115:[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}},{}],116:[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:263,url:298}],117:[function(e,t,n){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ @@ -50,9 +50,9 @@ t.exports=e("./db.json")},{"./db.json":141}],143:[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:182,"readable-stream":180}],166:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],167:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":169,"./_stream_writable":171,_process:186,dup:17,inherits:119}],168:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":170,dup:18,inherits:119}],169:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":166,"./_stream_duplex":167,"./internal/streams/async_iterator":172,"./internal/streams/buffer_list":173,"./internal/streams/destroy":174,"./internal/streams/from":176,"./internal/streams/state":178,"./internal/streams/stream":179,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],170:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":166,"./_stream_duplex":167,dup:20,inherits:119}],171:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":166,"./_stream_duplex":167,"./internal/streams/destroy":174,"./internal/streams/state":178,"./internal/streams/stream":179,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],172:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":175,_process:186,dup:22}],173:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],174:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],175:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":166,dup:25}],176:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],177:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":166,"./end-of-stream":175,dup:27}],178:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":166,dup:28}],179:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],180:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":167,"./lib/_stream_passthrough.js":168,"./lib/_stream_readable.js":169,"./lib/_stream_transform.js":170,"./lib/_stream_writable.js":171,"./lib/internal/streams/end-of-stream.js":175,"./lib/internal/streams/pipeline.js":177,dup:30}],181:[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}}},{}],182:[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:334}],183:[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":38,buffer:57,fs:55,"magnet-uri":123,path:184,"queue-microtask":192,"simple-get":221,"simple-sha1":241}],184:[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:186}],185:[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:186,"end-of-stream":96,fs:55,once:182}],188:[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:{})},{}],189:[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)}},{}],190:[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{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":38,buffer:57,fs:55,"magnet-uri":123,path:184,"queue-microtask":192,"simple-get":221,"simple-sha1":241}],184:[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:186}],185:[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:186,"end-of-stream":96,fs:55,once:182}],188:[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:{})},{}],189:[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)}},{}],190:[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 */ -let i;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind(globalThis):e=>(i||(i=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0)))},{}],193:[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}}},{}],194:[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":210}],196:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],197:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":199,"./_stream_writable":201,_process:186,dup:17,inherits:119}],198:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":200,dup:18,inherits:119}],199:[function(e,t,n){arguments[4][19][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:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],200:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,dup:20,inherits:119}],201:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,"./internal/streams/destroy":204,"./internal/streams/state":208,"./internal/streams/stream":209,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],202:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":205,_process:186,dup:22}],203:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],204:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],205:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":196,dup:25}],206:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],207:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":196,"./end-of-stream":205,dup:27}],208:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":196,dup:28}],209:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],210:[function(e,t,n){arguments[4][30][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:30}],211:[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:{})},{}],193:[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}}},{}],194:[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":210}],196:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],197:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":199,"./_stream_writable":201,_process:186,dup:17,inherits:119}],198:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":200,dup:18,inherits:119}],199:[function(e,t,n){arguments[4][19][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:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],200:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,dup:20,inherits:119}],201:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":196,"./_stream_duplex":197,"./internal/streams/destroy":204,"./internal/streams/state":208,"./internal/streams/stream":209,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],202:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":205,_process:186,dup:22}],203:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],204:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],205:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":196,dup:25}],206:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],207:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":196,"./end-of-stream":205,dup:27}],208:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":196,dup:28}],209:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],210:[function(e,t,n){arguments[4][30][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:30}],211:[function(e,t,n){ /*! render-media. MIT License. Feross Aboukhadijeh */ n.render=function(e,t,n,i){"function"==typeof n&&(i=n,n={});n||(n={});i||(i=function(){});x(e),y(n),"string"==typeof t&&(t=document.querySelector(t));v(e,(function(i){if(t.nodeName!==i.toUpperCase()){var r=s.extname(e.name).toLowerCase();throw new Error('Cannot render "'+r+'" 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=function(){});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){var n=document.createElement(e);return t.appendChild(n),n}v(e,(function(e){return"video"===e||"audio"===e?function(e){var 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");var 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){var v,x=s.extname(e.name).toLowerCase(),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){_()&&(v=t(n),b(e,(function(e,t){if(e)return C(e);v.addEventListener("error",C),v.addEventListener("loadstart",k),v.addEventListener("canplay",E),v.src=t})))}function k(){v.removeEventListener("loadstart",k),n.autoplay&&v.play()}function E(){v.removeEventListener("canplay",E),a(null,v)}function S(){b(e,(function(e,n){if(e)return C(e);".pdf"!==x?((v=t("iframe")).sandbox="allow-forms allow-scripts",v.src=n):((v=t("object")).setAttribute("typemustmatch",!0),v.setAttribute("type","application/pdf"),v.setAttribute("data",n)),a(null,v)}))}function C(t){t.message='Error rendering file "'+e.name+'": '+t.message,i(t.message),a(t)}u.indexOf(x)>=0?function(){var n=p.indexOf(x)>=0?"video":"audio";g?l.indexOf(x)>=0?r():a():u();function r(){i("Use `videostream` package for "+e.name),h(),v.addEventListener("error",d),v.addEventListener("loadstart",k),v.addEventListener("canplay",E),new c(e,v)}function a(){i("Use MediaSource API for "+e.name),h(),v.addEventListener("error",f),v.addEventListener("loadstart",k),v.addEventListener("canplay",E);var t,n=new o(v).createWriteStream((t=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(t).toLowerCase()]));e.createReadStream().pipe(n),y&&(v.currentTime=y)}function u(){i("Use Blob URL for "+e.name),h(),v.addEventListener("error",C),v.addEventListener("loadstart",k),v.addEventListener("canplay",E),b(e,(function(e,t){if(e)return C(e);v.src=t,y&&(v.currentTime=y)}))}function d(e){i("videostream error: fallback to MediaSource API: %o",e.message||e),v.removeEventListener("error",d),v.removeEventListener("canplay",E),a()}function f(e){i("MediaSource API error: fallback to Blob URL: %o",e.message||e),_()&&(v.removeEventListener("error",f),v.removeEventListener("canplay",E),u())}function h(){v||(v=t(n)).addEventListener("progress",(function(){y=v.currentTime}))}}():d.indexOf(x)>=0?w("video"):f.indexOf(x)>=0?w("audio"):h.indexOf(x)>=0?(v=t("img"),b(e,(function(t,n){if(t)return C(t);v.src=n,v.alt=e.name,a(null,v)}))):m.indexOf(x)>=0?S():function(){i('Unknown file extension "%s" - will attempt to render into iframe',x);var t="";function n(){r(t)?(i('File extension "%s" appears ascii, so will render.',x),S()):(i('File extension "%s" appears non-ascii, will not render.',x),a(new Error('Unsupported file type "'+x+'": Cannot append to DOM')))}e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",(function(e){t+=e})).on("end",n).on("error",a)}()}function b(e,t){var 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":212,debug:213,"is-ascii":120,mediasource:124,path:184,"stream-to-blob-url":282,videostream:307}],212:[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"}},{}],213:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":214,_process:186,dup:13}],214:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:215}],215:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],216:[function(e,t,n){ /*! run-parallel-limit. MIT License. Feross Aboukhadijeh */ @@ -66,7 +66,7 @@ t.exports=function(t,n){var i=[];t.on("data",(function(e){i.push(e)})),t.once("e /*! 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:57,"decompress-response":55,http:263,https:116,once:182,querystring:191,"simple-concat":220,url:298}],222:[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 a((()=>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)},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.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_SIGNALING");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){this._channel.send(e)}addTransceiver(e,t){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){this._debug("addStream()"),e.getTracks().forEach((t=>{this.addTrack(t,e)}))}addTrack(e,t){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){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){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){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(){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=>{this.destroy(c(e,"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:57,debug:223,"err-code":97,"get-browser-rtc":115,"queue-microtask":192,randombytes:194,"readable-stream":240}],223:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":224,_process:186,dup:13}],224:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:225}],225:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],226:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],227:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":229,"./_stream_writable":231,_process:186,dup:17,inherits:119}],228:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":230,dup:18,inherits:119}],229:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":226,"./_stream_duplex":227,"./internal/streams/async_iterator":232,"./internal/streams/buffer_list":233,"./internal/streams/destroy":234,"./internal/streams/from":236,"./internal/streams/state":238,"./internal/streams/stream":239,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],230:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":226,"./_stream_duplex":227,dup:20,inherits:119}],231:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":226,"./_stream_duplex":227,"./internal/streams/destroy":234,"./internal/streams/state":238,"./internal/streams/stream":239,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],232:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":235,_process:186,dup:22}],233:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],234:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],235:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":226,dup:25}],236:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],237:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":226,"./end-of-stream":235,dup:27}],238:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":226,dup:28}],239:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],240:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":227,"./lib/_stream_passthrough.js":228,"./lib/_stream_readable.js":229,"./lib/_stream_transform.js":230,"./lib/_stream_writable.js":231,"./lib/internal/streams/end-of-stream.js":235,"./lib/internal/streams/pipeline.js":237,dup:30}],241:[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":242,rusha:218}],242:[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:218}],243:[function(e,t,n){(function(n){(function(){ +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=>{this.destroy(c(e,"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:57,debug:223,"err-code":97,"get-browser-rtc":115,"queue-microtask":192,randombytes:194,"readable-stream":240}],223:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":224,_process:186,dup:13}],224:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:225}],225:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],226:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],227:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":229,"./_stream_writable":231,_process:186,dup:17,inherits:119}],228:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":230,dup:18,inherits:119}],229:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":226,"./_stream_duplex":227,"./internal/streams/async_iterator":232,"./internal/streams/buffer_list":233,"./internal/streams/destroy":234,"./internal/streams/from":236,"./internal/streams/state":238,"./internal/streams/stream":239,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],230:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":226,"./_stream_duplex":227,dup:20,inherits:119}],231:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":226,"./_stream_duplex":227,"./internal/streams/destroy":234,"./internal/streams/state":238,"./internal/streams/stream":239,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],232:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":235,_process:186,dup:22}],233:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],234:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],235:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":226,dup:25}],236:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],237:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":226,"./end-of-stream":235,dup:27}],238:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":226,dup:28}],239:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],240:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":227,"./lib/_stream_passthrough.js":228,"./lib/_stream_readable.js":229,"./lib/_stream_transform.js":230,"./lib/_stream_writable.js":231,"./lib/internal/streams/end-of-stream.js":235,"./lib/internal/streams/pipeline.js":237,dup:30}],241:[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":242,rusha:218}],242:[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:218}],243:[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:57,debug:244,"queue-microtask":192,randombytes:194,"readable-stream":261,ws:55}],244:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":245,_process:186,dup:13}],245:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:246}],246:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],247:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],248:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":250,"./_stream_writable":252,_process:186,dup:17,inherits:119}],249:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":251,dup:18,inherits:119}],250:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":247,"./_stream_duplex":248,"./internal/streams/async_iterator":253,"./internal/streams/buffer_list":254,"./internal/streams/destroy":255,"./internal/streams/from":257,"./internal/streams/state":259,"./internal/streams/stream":260,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],251:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":247,"./_stream_duplex":248,dup:20,inherits:119}],252:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":247,"./_stream_duplex":248,"./internal/streams/destroy":255,"./internal/streams/state":259,"./internal/streams/stream":260,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],253:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":256,_process:186,dup:22}],254:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],255:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],256:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":247,dup:25}],257:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],258:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":247,"./end-of-stream":256,dup:27}],259:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":247,dup:28}],260:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],261:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":248,"./lib/_stream_passthrough.js":249,"./lib/_stream_readable.js":250,"./lib/_stream_transform.js":251,"./lib/_stream_writable.js":252,"./lib/internal/streams/end-of-stream.js":256,"./lib/internal/streams/pipeline.js":258,dup:30}],262:[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.lengthe._pos){var o=n.substr(e._pos);if("x-user-defined"===e._charset){for(var s=r.alloc(o.length),a=0;ae._pos&&(e.push(r.from(new Uint8Array(l.result.slice(e._pos)))),e._pos=l.result.byteLength)},l.onload=function(){e.push(null)},l.readAsArrayBuffer(n)}e._xhr.readyState===c.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":264,_process:186,buffer:57,inherits:119,"readable-stream":281}],267:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],268:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":270,"./_stream_writable":272,_process:186,dup:17,inherits:119}],269:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":271,dup:18,inherits:119}],270:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":267,"./_stream_duplex":268,"./internal/streams/async_iterator":273,"./internal/streams/buffer_list":274,"./internal/streams/destroy":275,"./internal/streams/from":277,"./internal/streams/state":279,"./internal/streams/stream":280,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],271:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":267,"./_stream_duplex":268,dup:20,inherits:119}],272:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":267,"./_stream_duplex":268,"./internal/streams/destroy":275,"./internal/streams/state":279,"./internal/streams/stream":280,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],273:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":276,_process:186,dup:22}],274:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],275:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],276:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":267,dup:25}],277:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],278:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":267,"./end-of-stream":276,dup:27}],279:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":267,dup:28}],280:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],281:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":268,"./lib/_stream_passthrough.js":269,"./lib/_stream_readable.js":270,"./lib/_stream_transform.js":271,"./lib/_stream_writable.js":272,"./lib/internal/streams/end-of-stream.js":276,"./lib/internal/streams/pipeline.js":278,dup:30}],282:[function(e,t,n){ /*! stream-to-blob-url. MIT License. Feross Aboukhadijeh */ @@ -80,10 +80,10 @@ var i=e("once");t.exports=function(e,t,r){r=i(r);var o=n.alloc(t),s=0;e.on("data * (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 O,R="undefined"!=typeof window&&"undefined"!=typeof document?navigator.userAgent:"",B=/MSIE |Trident\//.test(R);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 q(e,t){var n;e&&!O.has(t)&&(O.add(t),(n=console).warn.apply(n,N(t)))}function D(e,t){var n;e&&!O.has(t)&&(O.add(t),(n=console).error.apply(n,N(t)))}"production"!==t.env.NODE_ENV&&(O=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),q(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 K(e){var t=b();return!0===e?t.className=s:(t.className=a,x(e)?t.appendChild(e):G(t,e)),t}function Y(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||Y(s,e.props),i.arrow?a?n.arrow!==i.arrow&&(o.removeChild(a),o.appendChild(K(i.arrow))):o.appendChild(K(i.arrow)):a&&o.removeChild(a)}return i.className=r,i.setAttribute("data-state","hidden"),Y(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,O=!1,R=[],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&&q(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&&q(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&&!O){if(O=!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&&q(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&&q(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,O=!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&&q(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&&q(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&&q(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&&D(!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 K=N.map((function(e){return e.fn(H)})),Y=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),K.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(){!Y&&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),R.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(){R.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),R=[]}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;D(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),D(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;q(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&&D(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&&D(!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&&D(!(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:186}],289:[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 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:186}],289:[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:186,"bittorrent-dht/client":55,"bittorrent-lsd":55,"bittorrent-tracker/client":31,debug:291,events:98,"run-parallel":217}],291:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":292,_process:186,dup:13}],292:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:293}],293:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],294:[function(e,t,n){(function(e){(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"]),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?R+="x":R+=O[B];if(!R.match(f)){var P=L.slice(0,T),M=L.slice(T+1),N=O.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 q=this.port?":"+this.port:"",D=this.hostname||"";this.host=D+q,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":299,punycode:188,querystring:191}],299:[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}}},{}],300:[function(e,t,n){(function(n){(function(){ +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:186,"bittorrent-dht/client":55,"bittorrent-lsd":55,"bittorrent-tracker/client":31,debug:291,events:98,"run-parallel":217}],291:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":292,_process:186,dup:13}],292:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:293}],293:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],294:[function(e,t,n){(function(e){(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"]),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":299,punycode:188,querystring:191}],299:[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}}},{}],300:[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:301,buffer:57,debug:302,events:98,"simple-sha1":241}],301:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{dup:12}],302:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":303,_process:186,dup:13}],303:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:304}],304:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],305:[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:{})},{}],306:[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":306,mediasource:124,pump:187}],308:[function(e,t,n){(function(n,i,r){(function(){ /*! webtorrent. MIT License. WebTorrent LLC */ -const{EventEmitter:o}=e("events"),s=e("simple-concat"),a=e("create-torrent"),c=e("debug")("webtorrent"),l=e("bittorrent-dht/client"),p=e("load-ip-set"),u=e("run-parallel"),d=e("parse-torrent"),f=e("path"),h=e("simple-peer"),m=e("randombytes"),g=e("speedometer"),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 o{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:r.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=r.from(_+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=r.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:r.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=r.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.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),i.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=i.WRTC)),"function"==typeof v?this._connPool=new v(this):n.nextTick((()=>{this._onListening()})),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(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 p&&null!=e.blocklist?p(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()})):n.nextTick(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=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}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=f.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)},o=this.add(null,t,(e=>{const t=[t=>{if(i)return t();e.load(c,t)}];this.dht&&t.push((t=>{e.once("dhtAnnounce",t)})),u(t,(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]),u(e.map((e=>t=>{!function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?t(null,e):s(e,t)})),((e,n)=>{if(!this.destroyed)return e?o._destroy(e):void a.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return o._destroy(e);c=i.map((e=>e.getStream)),a(n,t,((e,t)=>{if(this.destroyed)return;if(e)return o._destroy(e);const n=this.get(t);n?o._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):o._onTorrentId(t)}))}}))})),o}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)})),u(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]}`,c(...e)}}w.WEBRTC_SUPPORT=h.WEBRTC_SUPPORT,w.VERSION=x,t.exports=w}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./lib/conn-pool":55,"./lib/torrent":313,"./package.json":333,_process:186,"bittorrent-dht/client":55,buffer:57,"create-torrent":80,debug:315,events:98,"load-ip-set":55,"parse-torrent":183,path:184,randombytes:194,"run-parallel":217,"simple-concat":220,"simple-peer":222,speedometer:262}],309:[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.length,t&&t.message),t)return this._destroy(t);this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing{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}}}).call(this)}).call(this,e("_process"))},{"./file-stream":309,_process:186,"end-of-stream":96,events:98,path:184,"readable-stream":332,"render-media":211,"stream-to-blob":283,"stream-to-blob-url":282,"stream-with-known-length-to-buffer":284}],311:[function(e,t,n){const i=e("unordered-array-remove"),r=e("debug")("webtorrent:peer"),o=e("bittorrent-protocol"),s=e("./webconn");n.createWebRTCPeer=(e,t)=>{const n=new l(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",(()=>{n.onConnect()})),n.conn.once("error",(e=>{n.destroy(e)})),n.startConnectTimeout()),n},n.createTCPIncomingPeer=e=>a(e,"tcpIncoming"),n.createUTPIncomingPeer=e=>a(e,"utpIncoming"),n.createTCPOutgoingPeer=(e,t)=>c(e,t,"tcpOutgoing"),n.createUTPOutgoingPeer=(e,t)=>c(e,t,"utpOutgoing");const a=(e,t)=>{const n=`${e.remoteAddress}:${e.remotePort}`,i=new l(n,t);return i.conn=e,i.addr=n,i.onConnect(),i},c=(e,t,n)=>{const i=new l(e,n);return i.addr=e,i.swarm=t,i};n.createWebSeedPeer=(e,t)=>{const n=new l(e,"webSeed");return n.swarm=t,n.conn=new s(e,t),n.onConnect(),n};class l{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)}}},{"./webconn":314,"bittorrent-protocol":11,debug:315,"unordered-array-remove":297}],312:[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)}))):x.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=y.join(N,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=x.toMagnetURI(e),this.torrentFile=x.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:()=>{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 c({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:M}),this.discovery.on("error",(e=>{this._destroy(e)})),this.discovery.on("peer",(e=>{"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":M}};let r;try{r=d.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=x(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)}));v(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=x(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 I(this),this.store=new f(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map((e=>({path:y.join(this.path,e.path),length:e.length,offset:e.offset}))),length:this.length,name:this.infoHash})),this.files=this.files.map((e=>new A(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 _(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===u?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=[];b(this.files.map(((e,n)=>i=>{p.stat(y.join(this.path,e.path),((e,r)=>{if(e&&"ENOENT"!==e.code)return i(e);t[n]=r&&r.mtime.getTime(),i(null)}))})),U,(n=>{this._debug("done getting file modtimes"),e(n,t)}))}_verifyPieces(e){b(this.pieces.map(((e,t)=>e=>{if(this.destroyed)return e(new Error("torrent is destroyed"));this.store.get(t,((i,r)=>this.destroyed?e(new Error("torrent is destroyed")):i?n.nextTick(e,null):void E(r,(n=>{if(this.destroyed)return e(new Error("torrent is destroyed"));if(n===this._hashes[t]){if(!this.pieces[t])return e(null);this._debug("piece verified %s",t),this._markVerified(t)}else this._debug("piece invalid %s",t);e(null)}))))})),U,e)}rescanFiles(e){if(this.destroyed)throw new Error("torrent is destroyed");e||(e=D),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 A&&e._destroy()}));const i=this._servers.map((e=>t=>{e.destroy(t)}));this.discovery&&i.push((e=>{this.discovery.destroy(e)})),this.store&&i.push((e=>{t&&t.destroyStore?this.store.destroy(e):this.store.close(e)})),v(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?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");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=L.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_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()})),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(C(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 T||this.private||(e.use(T()),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()}))),this.emit("wire",e,t),this.metadata&&n.nextTick((()=>{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,R),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.once("interested",(()=>{e.unchoke()})),e.once("close",(()=>{clearTimeout(t)})),e.on("choke",(()=>{clearTimeout(t),t=setTimeout(n,R),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,R),t.unref&&t.unref()),e.isSeeder=!1,r()}_updateSelections(){this.ready&&!this.destroyed&&(n.nextTick((()=>{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=q(e,.5);if(e.requests.length>=n)return;const i=q(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>B)return()=>!0;const i=Math.max(1,e.requests.length)*_.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<_.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const i=this._reservations[t];if(!i)return!1;let r,o,s=1/0;for(o=0;o=B||(2*a>n||a>s||(r=t,s=a))}if(!r)return!1;for(o=0;o=(s?Math.min(function(e,t,n){return 1+Math.ceil(t*e.downloadSpeed()/n)}(e,1,r.pieceLength),r.maxWebConns):q(e,1)))return!1;const a=r.pieces[t];let c=s?a.reserveRemaining():a.reserve();if(-1===c&&i&&r._hotswap(e,t)&&(c=s?a.reserveRemaining():a.reserve()),-1===c)return!1;let l=r._reservations[t];l||(l=r._reservations[t]=[]);let p=l.indexOf(null);-1===p&&(p=l.length),l[p]=e;const u=a.chunkOffset(c),d=s?a.chunkLengthRemaining(c):a.chunkLength(c);function f(){n.nextTick((()=>{r._update()}))}return e.request(t,u,d,(function n(i,o){if(r.destroyed)return;if(!r.ready)return r.once("ready",(()=>{n(i,o)}));if(l[p]===e&&(l[p]=null),a!==r.pieces[t])return f();if(i)return r._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,u,d,`${e.remoteAddress}:${e.remotePort}`,i.message),s?a.cancelRemaining(c):a.cancel(c),void f();if(r._debug("got piece %s (offset: %s length: %s) from %s",t,u,d,`${e.remoteAddress}:${e.remotePort}`),!a.set(c,o,e))return f();const h=a.flush();E(h,(e=>{if(!r.destroyed){if(e===r._hashes[t]){if(!r.pieces[t])return;r._debug("piece verified %s",t),r.pieces[t]=null,r._reservations[t]=null,r.bitfield.set(t,!0),r.store.put(t,h),r.wires.forEach((e=>{e.have(t)})),r._checkDone()&&!r.destroyed&&r.discovery.complete()}else r.pieces[t]=new _(a.length),r.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(let t=0;t{this.load(e,t)}));Array.isArray(e)||(e=[e]),t||(t=D);const n=new h(e),i=new s(this.store,this.pieceLength);w(n,i,(e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)}))}createServer(e){if("function"!=typeof O)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new O(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]}`,a(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof m.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=j.connect(n.port,n.host):e.conn=m.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>=P.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,P.length);return}const t=P[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":333,"./file":310,"./peer":311,"./rarity-map":312,"./server":55,_process:186,"addr-to-ip-port":3,bitfield:10,"chunk-store-stream/write":78,debug:315,events:98,fs:56,"fs-chunk-store":140,"immediate-chunk-store":118,multistream:165,net:55,os:55,"parse-torrent":183,path:184,pump:187,"random-iterate":193,"run-parallel":217,"run-parallel-limit":216,"simple-get":221,"simple-sha1":241,speedometer:262,"torrent-discovery":290,"torrent-piece":294,ut_metadata:300,ut_pex:55,"utp-native":55}],314:[function(e,t,n){(function(n){(function(){const i=e("bitfield"),r=e("debug")("webtorrent:webconn"),o=e("simple-get"),s=e("simple-sha1"),a=e("bittorrent-protocol"),c=e("../package.json").version;t.exports=class extends a{constructor(e,t){super(),this.url=e,this.webPeerId=s.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),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.on("request",((e,t,n,i)=>{r("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,i)}))}httpRequest(e,t,i,s){const a=e*this._torrent.pieceLength+t,l=a+i-1,p=this._torrent.files;let u;if(p.length<=1)u=[{url:this.url,start:a,end:l}];else{const e=p.filter((e=>e.offset<=l&&e.offset+e.length>a));if(e.length<1)return s(new Error("Could not find file corresponnding 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,l-e.offset)}}))}let d,f=0,h=!1;u.length>1&&(d=n.alloc(i)),u.forEach((n=>{const a=n.url,l=n.start,p=n.end;r("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,i,l,p);const m={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${c} (https://webtorrent.io)`,range:`bytes=${l}-${p}`}};function g(e,t){if(e.statusCode<200||e.statusCode>=300)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":333,bitfield:10,"bittorrent-protocol":11,buffer:57,debug:315,"simple-get":221,"simple-sha1":241}],315:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":316,_process:186,dup:13}],316:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:317}],317:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],318:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],319:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":321,"./_stream_writable":323,_process:186,dup:17,inherits:119}],320:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":322,dup:18,inherits:119}],321:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":318,"./_stream_duplex":319,"./internal/streams/async_iterator":324,"./internal/streams/buffer_list":325,"./internal/streams/destroy":326,"./internal/streams/from":328,"./internal/streams/state":330,"./internal/streams/stream":331,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],322:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":318,"./_stream_duplex":319,dup:20,inherits:119}],323:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":318,"./_stream_duplex":319,"./internal/streams/destroy":326,"./internal/streams/state":330,"./internal/streams/stream":331,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],324:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":327,_process:186,dup:22}],325:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],326:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],327:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":318,dup:25}],328:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],329:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":318,"./end-of-stream":327,dup:27}],330:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":318,dup:28}],331:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],332:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":319,"./lib/_stream_passthrough.js":320,"./lib/_stream_readable.js":321,"./lib/_stream_transform.js":322,"./lib/_stream_writable.js":323,"./lib/internal/streams/end-of-stream.js":327,"./lib/internal/streams/pipeline.js":329,dup:30}],333:[function(e,t,n){t.exports={version:"0.110.1"}},{}],334:[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"}),q.setProps({placement:"right"}),D.setProps({placement:"right"})):(N.setProps({placement:"top"}),q.setProps({placement:"top"}),D.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(O.innerHTML="",u.files&&u.files.length){if(R.style.display="none",u.files.length<100)for(let e of u.files){let t=K(a.lookup(e.name));O.appendChild(G(t,e.name,e.length))}else{for(let e=0;e<100;e++){let t=K(a.lookup(u.files[e].name));O.appendChild(G(t,u.files[e].name,u.files[e].length))}O.appendChild(G("","...and another "+(u.files.length-100)+" more files",""))}O.appendChild(G("folder-tree","",u.length)),D.setContent("Download Torrent file"),M.addEventListener("click",ie),M.disabled=!1}else H.torrents.length>0?(R.style.display="none",O.innerHTML=''):(R.style.display="block",O.innerHTML=''),D.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 K(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 Y(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())),R.style.display="block",O.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..."),R.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",Y),x.addEventListener("change",Y),x.addEventListener("reset",Y),x.addEventListener("paste",Y),y.addEventListener("click",X),k.addEventListener("input",Y),k.addEventListener("change",Y),k.addEventListener("reset",Y),k.addEventListener("paste",Y),S.addEventListener("click",J),C.addEventListener("click",Z),T.addEventListener("click",(()=>ee("announce"))),L.addEventListener("click",Z),I.addEventListener("click",(()=>ee("urlList"))),R.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:62,clipboard:79,"mime-types":143,"parse-torrent":183,"tippy.js":288,webtorrent:308}]},{},[336]); \ No newline at end of file +const{EventEmitter:o}=e("events"),s=e("simple-concat"),a=e("create-torrent"),c=e("debug")("webtorrent"),l=e("bittorrent-dht/client"),p=e("load-ip-set"),u=e("run-parallel"),d=e("parse-torrent"),f=e("path"),h=e("simple-peer"),m=e("randombytes"),g=e("speedometer"),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 o{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:r.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=r.from(_+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=r.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:r.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=r.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.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),i.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=i.WRTC)),"function"==typeof v?this._connPool=new v(this):n.nextTick((()=>{this._onListening()})),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(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 p&&null!=e.blocklist?p(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()})):n.nextTick(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=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}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=f.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)},o=this.add(null,t,(e=>{const t=[t=>{if(i)return t();e.load(c,t)}];this.dht&&t.push((t=>{e.once("dhtAnnounce",t)})),u(t,(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]),u(e.map((e=>t=>{!function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?t(null,e):s(e,t)})),((e,n)=>{if(!this.destroyed)return e?o._destroy(e):void a.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return o._destroy(e);c=i.map((e=>e.getStream)),a(n,t,((e,t)=>{if(this.destroyed)return;if(e)return o._destroy(e);const n=this.get(t);n?o._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):o._onTorrentId(t)}))}}))})),o}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)})),u(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]}`,c(...e)}}w.WEBRTC_SUPPORT=h.WEBRTC_SUPPORT,w.VERSION=x,t.exports=w}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./lib/conn-pool":55,"./lib/torrent":313,"./package.json":333,_process:186,"bittorrent-dht/client":55,buffer:57,"create-torrent":80,debug:315,events:98,"load-ip-set":55,"parse-torrent":183,path:184,randombytes:194,"run-parallel":217,"simple-concat":220,"simple-peer":222,speedometer:262}],309:[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.length,t&&t.message),t)return this._destroy(t);this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing{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}}}).call(this)}).call(this,e("_process"))},{"./file-stream":309,_process:186,"end-of-stream":96,events:98,path:184,"readable-stream":332,"render-media":211,"stream-to-blob":283,"stream-to-blob-url":282,"stream-with-known-length-to-buffer":284}],311:[function(e,t,n){const i=e("unordered-array-remove"),r=e("debug")("webtorrent:peer"),o=e("bittorrent-protocol"),s=e("./webconn");n.createWebRTCPeer=(e,t)=>{const n=new l(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",(()=>{n.onConnect()})),n.conn.once("error",(e=>{n.destroy(e)})),n.startConnectTimeout()),n},n.createTCPIncomingPeer=e=>a(e,"tcpIncoming"),n.createUTPIncomingPeer=e=>a(e,"utpIncoming"),n.createTCPOutgoingPeer=(e,t)=>c(e,t,"tcpOutgoing"),n.createUTPOutgoingPeer=(e,t)=>c(e,t,"utpOutgoing");const a=(e,t)=>{const n=`${e.remoteAddress}:${e.remotePort}`,i=new l(n,t);return i.conn=e,i.addr=n,i.onConnect(),i},c=(e,t,n)=>{const i=new l(e,n);return i.addr=e,i.swarm=t,i};n.createWebSeedPeer=(e,t)=>{const n=new l(e,"webSeed");return n.swarm=t,n.conn=new s(e,t),n.onConnect(),n};class l{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)}}},{"./webconn":314,"bittorrent-protocol":11,debug:315,"unordered-array-remove":297}],312:[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)}))):x.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=y.join(N,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=x.toMagnetURI(e),this.torrentFile=x.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:()=>{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 c({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:M}),this.discovery.on("error",(e=>{this._destroy(e)})),this.discovery.on("peer",(e=>{"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":M}};let r;try{r=d.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=x(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)}));v(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=x(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 I(this),this.store=new f(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map((e=>({path:y.join(this.path,e.path),length:e.length,offset:e.offset}))),length:this.length,name:this.infoHash})),this.files=this.files.map((e=>new A(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 _(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===u?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=[];b(this.files.map(((e,n)=>i=>{p.stat(y.join(this.path,e.path),((e,r)=>{if(e&&"ENOENT"!==e.code)return i(e);t[n]=r&&r.mtime.getTime(),i(null)}))})),U,(n=>{this._debug("done getting file modtimes"),e(n,t)}))}_verifyPieces(e){b(this.pieces.map(((e,t)=>e=>{if(this.destroyed)return e(new Error("torrent is destroyed"));this.store.get(t,((i,r)=>this.destroyed?e(new Error("torrent is destroyed")):i?n.nextTick(e,null):void E(r,(n=>{if(this.destroyed)return e(new Error("torrent is destroyed"));if(n===this._hashes[t]){if(!this.pieces[t])return e(null);this._debug("piece verified %s",t),this._markVerified(t)}else this._debug("piece invalid %s",t);e(null)}))))})),U,e)}rescanFiles(e){if(this.destroyed)throw new Error("torrent is destroyed");e||(e=q),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 A&&e._destroy()}));const i=this._servers.map((e=>t=>{e.destroy(t)}));this.discovery&&i.push((e=>{this.discovery.destroy(e)})),this.store&&i.push((e=>{t&&t.destroyStore?this.store.destroy(e):this.store.close(e)})),v(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?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");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=L.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_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()})),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(C(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 T||this.private||(e.use(T()),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()}))),this.emit("wire",e,t),this.metadata&&n.nextTick((()=>{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,O),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.once("interested",(()=>{e.unchoke()})),e.once("close",(()=>{clearTimeout(t)})),e.on("choke",(()=>{clearTimeout(t),t=setTimeout(n,O),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,O),t.unref&&t.unref()),e.isSeeder=!1,r()}_updateSelections(){this.ready&&!this.destroyed&&(n.nextTick((()=>{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=D(e,.5);if(e.requests.length>=n)return;const i=D(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>B)return()=>!0;const i=Math.max(1,e.requests.length)*_.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<_.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const i=this._reservations[t];if(!i)return!1;let r,o,s=1/0;for(o=0;o=B||(2*a>n||a>s||(r=t,s=a))}if(!r)return!1;for(o=0;o=(s?Math.min(function(e,t,n){return 1+Math.ceil(t*e.downloadSpeed()/n)}(e,1,r.pieceLength),r.maxWebConns):D(e,1)))return!1;const a=r.pieces[t];let c=s?a.reserveRemaining():a.reserve();if(-1===c&&i&&r._hotswap(e,t)&&(c=s?a.reserveRemaining():a.reserve()),-1===c)return!1;let l=r._reservations[t];l||(l=r._reservations[t]=[]);let p=l.indexOf(null);-1===p&&(p=l.length),l[p]=e;const u=a.chunkOffset(c),d=s?a.chunkLengthRemaining(c):a.chunkLength(c);function f(){n.nextTick((()=>{r._update()}))}return e.request(t,u,d,(function n(i,o){if(r.destroyed)return;if(!r.ready)return r.once("ready",(()=>{n(i,o)}));if(l[p]===e&&(l[p]=null),a!==r.pieces[t])return f();if(i)return r._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,u,d,`${e.remoteAddress}:${e.remotePort}`,i.message),s?a.cancelRemaining(c):a.cancel(c),void f();if(r._debug("got piece %s (offset: %s length: %s) from %s",t,u,d,`${e.remoteAddress}:${e.remotePort}`),!a.set(c,o,e))return f();const h=a.flush();E(h,(e=>{if(!r.destroyed){if(e===r._hashes[t]){if(!r.pieces[t])return;r._debug("piece verified %s",t),r.pieces[t]=null,r._reservations[t]=null,r.bitfield.set(t,!0),r.store.put(t,h),r.wires.forEach((e=>{e.have(t)})),r._checkDone()&&!r.destroyed&&r.discovery.complete()}else r.pieces[t]=new _(a.length),r.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(let t=0;t{this.load(e,t)}));Array.isArray(e)||(e=[e]),t||(t=q);const n=new h(e),i=new s(this.store,this.pieceLength);w(n,i,(e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)}))}createServer(e){if("function"!=typeof R)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new R(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]}`,a(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof m.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=j.connect(n.port,n.host):e.conn=m.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>=P.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,P.length);return}const t=P[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":333,"./file":310,"./peer":311,"./rarity-map":312,"./server":55,_process:186,"addr-to-ip-port":3,bitfield:10,"chunk-store-stream/write":78,debug:315,events:98,fs:56,"fs-chunk-store":140,"immediate-chunk-store":118,multistream:165,net:55,os:55,"parse-torrent":183,path:184,pump:187,"random-iterate":193,"run-parallel":217,"run-parallel-limit":216,"simple-get":221,"simple-sha1":241,speedometer:262,"torrent-discovery":290,"torrent-piece":294,ut_metadata:300,ut_pex:55,"utp-native":55}],314:[function(e,t,n){(function(n){(function(){const i=e("bitfield"),r=e("debug")("webtorrent:webconn"),o=e("simple-get"),s=e("simple-sha1"),a=e("bittorrent-protocol"),c=e("../package.json").version;t.exports=class extends a{constructor(e,t){super(),this.url=e,this.webPeerId=s.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),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.on("request",((e,t,n,i)=>{r("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,i)}))}httpRequest(e,t,i,s){const a=e*this._torrent.pieceLength+t,l=a+i-1,p=this._torrent.files;let u;if(p.length<=1)u=[{url:this.url,start:a,end:l}];else{const e=p.filter((e=>e.offset<=l&&e.offset+e.length>a));if(e.length<1)return s(new Error("Could not find file corresponnding 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,l-e.offset)}}))}let d,f=0,h=!1;u.length>1&&(d=n.alloc(i)),u.forEach((n=>{const a=n.url,l=n.start,p=n.end;r("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,i,l,p);const m={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${c} (https://webtorrent.io)`,range:`bytes=${l}-${p}`}};function g(e,t){if(e.statusCode<200||e.statusCode>=300)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":333,bitfield:10,"bittorrent-protocol":11,buffer:57,debug:315,"simple-get":221,"simple-sha1":241}],315:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./common":316,_process:186,dup:13}],316:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14,ms:317}],317:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],318:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16}],319:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_readable":321,"./_stream_writable":323,_process:186,dup:17,inherits:119}],320:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_transform":322,dup:18,inherits:119}],321:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":318,"./_stream_duplex":319,"./internal/streams/async_iterator":324,"./internal/streams/buffer_list":325,"./internal/streams/destroy":326,"./internal/streams/from":328,"./internal/streams/state":330,"./internal/streams/stream":331,_process:186,buffer:57,dup:19,events:98,inherits:119,"string_decoder/":285,util:55}],322:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":318,"./_stream_duplex":319,dup:20,inherits:119}],323:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"../errors":318,"./_stream_duplex":319,"./internal/streams/destroy":326,"./internal/streams/state":330,"./internal/streams/stream":331,_process:186,buffer:57,dup:21,inherits:119,"util-deprecate":305}],324:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./end-of-stream":327,_process:186,dup:22}],325:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{buffer:57,dup:23,util:55}],326:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{_process:186,dup:24}],327:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{"../../../errors":318,dup:25}],328:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{dup:26}],329:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":318,"./end-of-stream":327,dup:27}],330:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{"../../../errors":318,dup:28}],331:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{dup:29,events:98}],332:[function(e,t,n){arguments[4][30][0].apply(n,arguments)},{"./lib/_stream_duplex.js":319,"./lib/_stream_passthrough.js":320,"./lib/_stream_readable.js":321,"./lib/_stream_transform.js":322,"./lib/_stream_writable.js":323,"./lib/internal/streams/end-of-stream.js":327,"./lib/internal/streams/pipeline.js":329,dup:30}],333:[function(e,t,n){t.exports={version:"0.110.1"}},{}],334:[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:62,clipboard:79,"mime-types":143,"parse-torrent":183,"tippy.js":288,webtorrent:308}]},{},[336]); \ No newline at end of file