From f2e6c4cba6208d5f74f8dfc615d4fa4eb3b62205 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 21 Nov 2016 02:48:09 +0000 Subject: [PATCH] Webpack build: 66845e2f681412619f4badc4a8f51df78207d60d --- discord.indev.js | 29645 +++++------------------------------------ discord.indev.min.js | 122 +- 2 files changed, 3503 insertions(+), 26264 deletions(-) diff --git a/discord.indev.js b/discord.indev.js index 419d475a..b1db2413 100644 --- a/discord.indev.js +++ b/discord.indev.js @@ -61,13 +61,1023 @@ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 340); +/******/ return __webpack_require__(__webpack_require__.s = 196); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { +/* WEBPACK VAR INJECTION */(function(process) {exports.Package = __webpack_require__(38); + +/** + * Options for a Client. + * @typedef {Object} ClientOptions + * @property {string} [apiRequestMethod='sequential'] 'sequential' or 'burst'. Sequential executes all requests in + * the order they are triggered, whereas burst runs multiple at a time, and doesn't guarantee a particular order. + * @property {number} [shardId=0] The ID of this shard + * @property {number} [shardCount=0] The number of shards + * @property {number} [messageCacheMaxSize=200] Maximum number of messages to cache per channel + * (-1 or Infinity for unlimited - don't do this without message sweeping, otherwise memory usage will climb + * indefinitely) + * @property {number} [messageCacheLifetime=0] How long until a message should be uncached by the message sweeping + * (in seconds, 0 for forever) + * @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than + * the message cache lifetime (in seconds, 0 for never) + * @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup, as well as + * upon joining a guild + * @property {boolean} [disableEveryone=false] Default value for MessageOptions.disableEveryone + * @property {boolean} [sync=false] Whether to periodically sync guilds (for userbots) + * @property {number} [restWsBridgeTimeout=5000] Maximum time permitted between REST responses and their + * corresponding websocket events + * @property {string[]} [disabledEvents] An array of disabled websocket events. Events in this array will not be + * processed. Disabling useless events such as 'TYPING_START' can result in significant performance increases on + * large-scale bots. + * @property {WebsocketOptions} [ws] Options for the websocket + */ +exports.DefaultOptions = { + apiRequestMethod: 'sequential', + shardId: 0, + shardCount: 0, + messageCacheMaxSize: 200, + messageCacheLifetime: 0, + messageSweepInterval: 0, + fetchAllMembers: false, + disableEveryone: false, + sync: false, + restWsBridgeTimeout: 5000, + disabledEvents: [], + + /** + * Websocket options. These are left as snake_case to match the API. + * @typedef {Object} WebsocketOptions + * @property {number} [large_threshold=250] Number of members in a guild to be considered large + * @property {boolean} [compress=true] Whether to compress data sent on the connection. + * Defaults to `false` for browsers. + */ + ws: { + large_threshold: 250, + compress: typeof window === 'undefined', + properties: { + $os: process ? process.platform : 'discord.js', + $browser: 'discord.js', + $device: 'discord.js', + $referrer: '', + $referring_domain: '', + }, + }, +}; + +exports.Errors = { + NO_TOKEN: 'Request to use token, but token was unavailable to the client.', + NO_BOT_ACCOUNT: 'Only bot accounts are able to make use of this feature.', + NO_USER_ACCOUNT: 'Only user accounts are able to make use of this feature.', + BAD_WS_MESSAGE: 'A bad message was received from the websocket; either bad compression, or not JSON.', + TOOK_TOO_LONG: 'Something took too long to do.', + NOT_A_PERMISSION: 'Invalid permission string or number.', + INVALID_RATE_LIMIT_METHOD: 'Unknown rate limiting method.', + BAD_LOGIN: 'Incorrect login details were provided.', + INVALID_SHARD: 'Invalid shard settings were provided.', +}; + +const PROTOCOL_VERSION = exports.PROTOCOL_VERSION = 6; +const API = exports.API = `https://discordapp.com/api/v${PROTOCOL_VERSION}`; +const Endpoints = exports.Endpoints = { + // general + login: `${API}/auth/login`, + logout: `${API}/auth/logout`, + gateway: `${API}/gateway`, + botGateway: `${API}/gateway/bot`, + invite: (id) => `${API}/invite/${id}`, + inviteLink: (id) => `https://discord.gg/${id}`, + CDN: 'https://cdn.discordapp.com', + + // users + user: (userID) => `${API}/users/${userID}`, + userChannels: (userID) => `${Endpoints.user(userID)}/channels`, + userProfile: (userID) => `${Endpoints.user(userID)}/profile`, + avatar: (userID, avatar) => userID === '1' ? avatar : `${Endpoints.user(userID)}/avatars/${avatar}.jpg`, + me: `${API}/users/@me`, + meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`, + relationships: (userID) => `${Endpoints.user(userID)}/relationships`, + note: (userID) => `${Endpoints.me}/notes/${userID}`, + + // guilds + guilds: `${API}/guilds`, + guild: (guildID) => `${Endpoints.guilds}/${guildID}`, + guildIcon: (guildID, hash) => `${Endpoints.guild(guildID)}/icons/${hash}.jpg`, + guildPrune: (guildID) => `${Endpoints.guild(guildID)}/prune`, + guildEmbed: (guildID) => `${Endpoints.guild(guildID)}/embed`, + guildInvites: (guildID) => `${Endpoints.guild(guildID)}/invites`, + guildRoles: (guildID) => `${Endpoints.guild(guildID)}/roles`, + guildRole: (guildID, roleID) => `${Endpoints.guildRoles(guildID)}/${roleID}`, + guildBans: (guildID) => `${Endpoints.guild(guildID)}/bans`, + guildIntegrations: (guildID) => `${Endpoints.guild(guildID)}/integrations`, + guildMembers: (guildID) => `${Endpoints.guild(guildID)}/members`, + guildMember: (guildID, memberID) => `${Endpoints.guildMembers(guildID)}/${memberID}`, + stupidInconsistentGuildEndpoint: (guildID) => `${Endpoints.guildMember(guildID, '@me')}/nick`, + guildChannels: (guildID) => `${Endpoints.guild(guildID)}/channels`, + guildEmojis: (guildID) => `${Endpoints.guild(guildID)}/emojis`, + + // channels + channels: `${API}/channels`, + channel: (channelID) => `${Endpoints.channels}/${channelID}`, + channelMessages: (channelID) => `${Endpoints.channel(channelID)}/messages`, + channelInvites: (channelID) => `${Endpoints.channel(channelID)}/invites`, + channelTyping: (channelID) => `${Endpoints.channel(channelID)}/typing`, + channelPermissions: (channelID) => `${Endpoints.channel(channelID)}/permissions`, + channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`, + channelWebhooks: (channelID) => `${Endpoints.channel(channelID)}/webhooks`, + + // message reactions + messageReactions: (channelID, messageID) => `${Endpoints.channelMessage(channelID, messageID)}/reactions`, + messageReaction: + (channel, msg, emoji, limit) => + `${Endpoints.messageReactions(channel, msg)}/${emoji}` + + `${limit ? `?limit=${limit}` : ''}`, + selfMessageReaction: (channel, msg, emoji, limit) => + `${Endpoints.messageReaction(channel, msg, emoji, limit)}/@me`, + userMessageReaction: (channel, msg, emoji, limit, id) => + `${Endpoints.messageReaction(channel, msg, emoji, limit)}/${id}`, + + // webhooks + webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`, + + // oauth + myApplication: `${API}/oauth2/applications/@me`, + getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`, +}; + +exports.Status = { + READY: 0, + CONNECTING: 1, + RECONNECTING: 2, + IDLE: 3, + NEARLY: 4, +}; + +exports.ChannelTypes = { + text: 0, + DM: 1, + voice: 2, + groupDM: 3, +}; + +exports.OPCodes = { + DISPATCH: 0, + HEARTBEAT: 1, + IDENTIFY: 2, + STATUS_UPDATE: 3, + VOICE_STATE_UPDATE: 4, + VOICE_GUILD_PING: 5, + RESUME: 6, + RECONNECT: 7, + REQUEST_GUILD_MEMBERS: 8, + INVALID_SESSION: 9, + HELLO: 10, + HEARTBEAT_ACK: 11, +}; + +exports.VoiceOPCodes = { + IDENTIFY: 0, + SELECT_PROTOCOL: 1, + READY: 2, + HEARTBEAT: 3, + SESSION_DESCRIPTION: 4, + SPEAKING: 5, +}; + +exports.Events = { + READY: 'ready', + GUILD_CREATE: 'guildCreate', + GUILD_DELETE: 'guildDelete', + GUILD_UPDATE: 'guildUpdate', + GUILD_UNAVAILABLE: 'guildUnavailable', + GUILD_AVAILABLE: 'guildAvailable', + GUILD_MEMBER_ADD: 'guildMemberAdd', + GUILD_MEMBER_REMOVE: 'guildMemberRemove', + GUILD_MEMBER_UPDATE: 'guildMemberUpdate', + GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable', + GUILD_MEMBER_SPEAKING: 'guildMemberSpeaking', + GUILD_MEMBERS_CHUNK: 'guildMembersChunk', + GUILD_ROLE_CREATE: 'roleCreate', + GUILD_ROLE_DELETE: 'roleDelete', + GUILD_ROLE_UPDATE: 'roleUpdate', + GUILD_EMOJI_CREATE: 'guildEmojiCreate', + GUILD_EMOJI_DELETE: 'guildEmojiDelete', + GUILD_EMOJI_UPDATE: 'guildEmojiUpdate', + GUILD_BAN_ADD: 'guildBanAdd', + GUILD_BAN_REMOVE: 'guildBanRemove', + CHANNEL_CREATE: 'channelCreate', + CHANNEL_DELETE: 'channelDelete', + CHANNEL_UPDATE: 'channelUpdate', + CHANNEL_PINS_UPDATE: 'channelPinsUpdate', + MESSAGE_CREATE: 'message', + MESSAGE_DELETE: 'messageDelete', + MESSAGE_UPDATE: 'messageUpdate', + MESSAGE_BULK_DELETE: 'messageDeleteBulk', + MESSAGE_REACTION_ADD: 'messageReactionAdd', + MESSAGE_REACTION_REMOVE: 'messageReactionRemove', + MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll', + USER_UPDATE: 'userUpdate', + USER_NOTE_UPDATE: 'userNoteUpdate', + PRESENCE_UPDATE: 'presenceUpdate', + VOICE_STATE_UPDATE: 'voiceStateUpdate', + TYPING_START: 'typingStart', + TYPING_STOP: 'typingStop', + DISCONNECT: 'disconnect', + RECONNECTING: 'reconnecting', + ERROR: 'error', + WARN: 'warn', + DEBUG: 'debug', +}; + +exports.WSEvents = { + READY: 'READY', + GUILD_SYNC: 'GUILD_SYNC', + GUILD_CREATE: 'GUILD_CREATE', + GUILD_DELETE: 'GUILD_DELETE', + GUILD_UPDATE: 'GUILD_UPDATE', + GUILD_MEMBER_ADD: 'GUILD_MEMBER_ADD', + GUILD_MEMBER_REMOVE: 'GUILD_MEMBER_REMOVE', + GUILD_MEMBER_UPDATE: 'GUILD_MEMBER_UPDATE', + GUILD_MEMBERS_CHUNK: 'GUILD_MEMBERS_CHUNK', + GUILD_ROLE_CREATE: 'GUILD_ROLE_CREATE', + GUILD_ROLE_DELETE: 'GUILD_ROLE_DELETE', + GUILD_ROLE_UPDATE: 'GUILD_ROLE_UPDATE', + GUILD_BAN_ADD: 'GUILD_BAN_ADD', + GUILD_BAN_REMOVE: 'GUILD_BAN_REMOVE', + CHANNEL_CREATE: 'CHANNEL_CREATE', + CHANNEL_DELETE: 'CHANNEL_DELETE', + CHANNEL_UPDATE: 'CHANNEL_UPDATE', + CHANNEL_PINS_UPDATE: 'CHANNEL_PINS_UPDATE', + MESSAGE_CREATE: 'MESSAGE_CREATE', + MESSAGE_DELETE: 'MESSAGE_DELETE', + MESSAGE_UPDATE: 'MESSAGE_UPDATE', + MESSAGE_DELETE_BULK: 'MESSAGE_DELETE_BULK', + MESSAGE_REACTION_ADD: 'MESSAGE_REACTION_ADD', + MESSAGE_REACTION_REMOVE: 'MESSAGE_REACTION_REMOVE', + MESSAGE_REACTION_REMOVE_ALL: 'MESSAGE_REACTION_REMOVE_ALL', + USER_UPDATE: 'USER_UPDATE', + USER_NOTE_UPDATE: 'USER_NOTE_UPDATE', + PRESENCE_UPDATE: 'PRESENCE_UPDATE', + VOICE_STATE_UPDATE: 'VOICE_STATE_UPDATE', + TYPING_START: 'TYPING_START', + FRIEND_ADD: 'RELATIONSHIP_ADD', + FRIEND_REMOVE: 'RELATIONSHIP_REMOVE', + VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE', + RELATIONSHIP_ADD: 'RELATIONSHIP_ADD', + RELATIONSHIP_REMOVE: 'RELATIONSHIP_REMOVE', +}; + +exports.MessageTypes = { + 0: 'DEFAULT', + 1: 'RECIPIENT_ADD', + 2: 'RECIPIENT_REMOVE', + 3: 'CALL', + 4: 'CHANNEL_NAME_CHANGE', + 5: 'CHANNEL_ICON_CHANGE', + 6: 'PINS_ADD', +}; + +const PermissionFlags = exports.PermissionFlags = { + CREATE_INSTANT_INVITE: 1 << 0, + KICK_MEMBERS: 1 << 1, + BAN_MEMBERS: 1 << 2, + ADMINISTRATOR: 1 << 3, + MANAGE_CHANNELS: 1 << 4, + MANAGE_GUILD: 1 << 5, + ADD_REACTIONS: 1 << 6, + + READ_MESSAGES: 1 << 10, + SEND_MESSAGES: 1 << 11, + SEND_TTS_MESSAGES: 1 << 12, + MANAGE_MESSAGES: 1 << 13, + EMBED_LINKS: 1 << 14, + ATTACH_FILES: 1 << 15, + READ_MESSAGE_HISTORY: 1 << 16, + MENTION_EVERYONE: 1 << 17, + EXTERNAL_EMOJIS: 1 << 18, + + CONNECT: 1 << 20, + SPEAK: 1 << 21, + MUTE_MEMBERS: 1 << 22, + DEAFEN_MEMBERS: 1 << 23, + MOVE_MEMBERS: 1 << 24, + USE_VAD: 1 << 25, + + CHANGE_NICKNAME: 1 << 26, + MANAGE_NICKNAMES: 1 << 27, + MANAGE_ROLES_OR_PERMISSIONS: 1 << 28, + MANAGE_WEBHOOKS: 1 << 29, + MANAGE_EMOJIS: 1 << 30, +}; + +let _ALL_PERMISSIONS = 0; +for (const key in PermissionFlags) _ALL_PERMISSIONS |= PermissionFlags[key]; +exports.ALL_PERMISSIONS = _ALL_PERMISSIONS; +exports.DEFAULT_PERMISSIONS = 104324097; + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + +class AbstractHandler { + constructor(packetManager) { + this.packetManager = packetManager; + } + + handle(packet) { + return packet; + } +} + +module.exports = AbstractHandler; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + +/* + +ABOUT ACTIONS + +Actions are similar to WebSocket Packet Handlers, but since introducing +the REST API methods, in order to prevent rewriting code to handle data, +"actions" have been introduced. They're basically what Packet Handlers +used to be but they're strictly for manipulating data and making sure +that WebSocket events don't clash with REST methods. + +*/ + +class GenericAction { + constructor(client) { + this.client = client; + } + + handle(data) { + return data; + } +} + +module.exports = GenericAction; + + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + +/** + * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has + * an ID, for significantly improved performance and ease-of-use. + * @extends {Map} + */ +class Collection extends Map { + constructor(iterable) { + super(iterable); + + /** + * Cached array for the `array()` method - will be reset to `null` whenever `set()` or `delete()` are called. + * @type {?Array} + * @private + */ + this._array = null; + + /** + * Cached array for the `keyArray()` method - will be reset to `null` whenever `set()` or `delete()` are called. + * @type {?Array} + * @private + */ + this._keyArray = null; + } + + set(key, val) { + super.set(key, val); + this._array = null; + this._keyArray = null; + } + + delete(key) { + super.delete(key); + this._array = null; + this._keyArray = null; + } + + /** + * Creates an ordered array of the values of this collection, and caches it internally. The array will only be + * reconstructed if an item is added to or removed from the collection, or if you change the length of the array + * itself. If you don't want this caching behaviour, use `Array.from(collection.values())` instead. + * @returns {Array} + */ + array() { + if (!this._array || this._array.length !== this.size) this._array = Array.from(this.values()); + return this._array; + } + + /** + * Creates an ordered array of the keys of this collection, and caches it internally. The array will only be + * reconstructed if an item is added to or removed from the collection, or if you change the length of the array + * itself. If you don't want this caching behaviour, use `Array.from(collection.keys())` instead. + * @returns {Array} + */ + keyArray() { + if (!this._keyArray || this._keyArray.length !== this.size) this._keyArray = Array.from(this.keys()); + return this._keyArray; + } + + /** + * Obtains the first item in this collection. + * @returns {*} + */ + first() { + return this.values().next().value; + } + + /** + * Obtains the first key in this collection. + * @returns {*} + */ + firstKey() { + return this.keys().next().value; + } + + /** + * Obtains the last item in this collection. This relies on the `array()` method, and thus the caching mechanism + * applies here as well. + * @returns {*} + */ + last() { + const arr = this.array(); + return arr[arr.length - 1]; + } + + /** + * Obtains the last key in this collection. This relies on the `keyArray()` method, and thus the caching mechanism + * applies here as well. + * @returns {*} + */ + lastKey() { + const arr = this.keyArray(); + return arr[arr.length - 1]; + } + + /** + * Obtains a random item from this collection. This relies on the `array()` method, and thus the caching mechanism + * applies here as well. + * @returns {*} + */ + random() { + const arr = this.array(); + return arr[Math.floor(Math.random() * arr.length)]; + } + + /** + * Obtains a random key from this collection. This relies on the `keyArray()` method, and thus the caching mechanism + * applies here as well. + * @returns {*} + */ + randomKey() { + const arr = this.keyArray(); + return arr[Math.floor(Math.random() * arr.length)]; + } + + /** + * Searches for all items where their specified property's value is identical to the given value + * (`item[prop] === value`). + * @param {string} prop The property to test against + * @param {*} value The expected value + * @returns {Array} + * @example + * collection.findAll('username', 'Bob'); + */ + findAll(prop, value) { + if (typeof prop !== 'string') throw new TypeError('Key must be a string.'); + if (typeof value === 'undefined') throw new Error('Value must be specified.'); + const results = []; + for (const item of this.values()) { + if (item[prop] === value) results.push(item); + } + return results; + } + + /** + * Searches for a single item where its specified property's value is identical to the given value + * (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to + * [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find). + * Do not use this to obtain an item by its ID. Instead, use `collection.get(id)`. See + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details. + * @param {string|Function} propOrFn The property to test against, or the function to test with + * @param {*} [value] The expected value - only applicable and required if using a property for the first argument + * @returns {*} + * @example + * collection.find('username', 'Bob'); + * @example + * collection.find(val => val.username === 'Bob'); + */ + find(propOrFn, value) { + if (typeof propOrFn === 'string') { + if (typeof value === 'undefined') throw new Error('Value must be specified.'); + if (propOrFn === 'id') throw new RangeError('Don\'t use .find() with IDs. Instead, use .get(id).'); + for (const item of this.values()) { + if (item[propOrFn] === value) return item; + } + return null; + } else if (typeof propOrFn === 'function') { + for (const [key, val] of this) { + if (propOrFn(val, key, this)) return val; + } + return null; + } else { + throw new Error('First argument must be a property string or a function.'); + } + } + + /* eslint-disable max-len */ + /** + * Searches for the key of a single item where its specified property's value is identical to the given value + * (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to + * [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex). + * @param {string|Function} propOrFn The property to test against, or the function to test with + * @param {*} [value] The expected value - only applicable and required if using a property for the first argument + * @returns {*} + * @example + * collection.findKey('username', 'Bob'); + * @example + * collection.findKey(val => val.username === 'Bob'); + */ + /* eslint-enable max-len */ + findKey(propOrFn, value) { + if (typeof propOrFn === 'string') { + if (typeof value === 'undefined') throw new Error('Value must be specified.'); + for (const [key, val] of this) { + if (val[propOrFn] === value) return key; + } + return null; + } else if (typeof propOrFn === 'function') { + for (const [key, val] of this) { + if (propOrFn(val, key, this)) return key; + } + return null; + } else { + throw new Error('First argument must be a property string or a function.'); + } + } + + /** + * Searches for the existence of a single item where its specified property's value is identical to the given value + * (`item[prop] === value`). + * Do not use this to check for an item by its ID. Instead, use `collection.has(id)`. See + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details. + * @param {string} prop The property to test against + * @param {*} value The expected value + * @returns {boolean} + * @example + * if (collection.exists('username', 'Bob')) { + * console.log('user here!'); + * } + */ + exists(prop, value) { + if (prop === 'id') throw new RangeError('Don\'t use .exists() with IDs. Instead, use .has(id).'); + return Boolean(this.find(prop, value)); + } + + /** + * Identical to + * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter), + * but returns a Collection instead of an Array. + * @param {Function} fn Function used to test (should return a boolean) + * @param {Object} [thisArg] Value to use as `this` when executing function + * @returns {Collection} + */ + filter(fn, thisArg) { + if (thisArg) fn = fn.bind(thisArg); + const results = new Collection(); + for (const [key, val] of this) { + if (fn(val, key, this)) results.set(key, val); + } + return results; + } + + /** + * Identical to + * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). + * @param {Function} fn Function used to test (should return a boolean) + * @param {Object} [thisArg] Value to use as `this` when executing function + * @returns {Array} + */ + filterArray(fn, thisArg) { + if (thisArg) fn = fn.bind(thisArg); + const results = []; + for (const [key, val] of this) { + if (fn(val, key, this)) results.push(val); + } + return results; + } + + /** + * Identical to + * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map). + * @param {Function} fn Function that produces an element of the new array, taking three arguments + * @param {*} [thisArg] Value to use as `this` when executing function + * @returns {Array} + */ + map(fn, thisArg) { + if (thisArg) fn = fn.bind(thisArg); + const arr = new Array(this.size); + let i = 0; + for (const [key, val] of this) arr[i++] = fn(val, key, this); + return arr; + } + + /** + * Identical to + * [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some). + * @param {Function} fn Function used to test (should return a boolean) + * @param {Object} [thisArg] Value to use as `this` when executing function + * @returns {boolean} + */ + some(fn, thisArg) { + if (thisArg) fn = fn.bind(thisArg); + for (const [key, val] of this) { + if (fn(val, key, this)) return true; + } + return false; + } + + /** + * Identical to + * [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every). + * @param {Function} fn Function used to test (should return a boolean) + * @param {Object} [thisArg] Value to use as `this` when executing function + * @returns {boolean} + */ + every(fn, thisArg) { + if (thisArg) fn = fn.bind(thisArg); + for (const [key, val] of this) { + if (!fn(val, key, this)) return false; + } + return true; + } + + /** + * Identical to + * [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce). + * @param {Function} fn Function used to reduce + * @param {*} [startVal] The starting value + * @returns {*} + */ + reduce(fn, startVal) { + let currentVal = startVal; + for (const [key, val] of this) currentVal = fn(currentVal, val, key, this); + return currentVal; + } + + /** + * Combines this collection with others into a new collection. None of the source collections are modified. + * @param {Collection} collections Collections to merge (infinite/rest argument, not an array) + * @returns {Collection} + * @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl); + */ + concat(...collections) { + const newColl = new this.constructor(); + for (const [key, val] of this) newColl.set(key, val); + for (const coll of collections) { + for (const [key, val] of coll) newColl.set(key, val); + } + return newColl; + } + + /** + * Calls the `delete()` method on all items that have it. + * @returns {Promise[]} + */ + deleteAll() { + const returns = []; + for (const item of this.values()) { + if (item.delete) returns.push(item.delete()); + } + return returns; + } +} + +module.exports = Collection; + + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + "use strict"; /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*! * The buffer module from node.js, for the browser. @@ -79,9 +1089,9 @@ 'use strict' -var base64 = __webpack_require__(150) -var ieee754 = __webpack_require__(200) -var isArray = __webpack_require__(106) +var base64 = __webpack_require__(81) +var ieee754 = __webpack_require__(85) +var isArray = __webpack_require__(58) exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer @@ -1859,4485 +2869,12 @@ function isnan (val) { return val !== val // eslint-disable-line no-self-compare } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer, __webpack_require__(18))) - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {exports.Package = __webpack_require__(64); - -/** - * Options for a Client. - * @typedef {Object} ClientOptions - * @property {string} [apiRequestMethod='sequential'] 'sequential' or 'burst'. Sequential executes all requests in - * the order they are triggered, whereas burst runs multiple at a time, and doesn't guarantee a particular order. - * @property {number} [shardId=0] The ID of this shard - * @property {number} [shardCount=0] The number of shards - * @property {number} [messageCacheMaxSize=200] Maximum number of messages to cache per channel - * (-1 or Infinity for unlimited - don't do this without message sweeping, otherwise memory usage will climb - * indefinitely) - * @property {number} [messageCacheLifetime=0] How long until a message should be uncached by the message sweeping - * (in seconds, 0 for forever) - * @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than - * the message cache lifetime (in seconds, 0 for never) - * @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup, as well as - * upon joining a guild - * @property {boolean} [disableEveryone=false] Default value for MessageOptions.disableEveryone - * @property {boolean} [sync=false] Whether to periodically sync guilds (for userbots) - * @property {number} [restWsBridgeTimeout=5000] Maximum time permitted between REST responses and their - * corresponding websocket events - * @property {string[]} [disabledEvents] An array of disabled websocket events. Events in this array will not be - * processed. Disabling useless events such as 'TYPING_START' can result in significant performance increases on - * large-scale bots. - * @property {WebsocketOptions} [ws] Options for the websocket - */ -exports.DefaultOptions = { - apiRequestMethod: 'sequential', - shardId: 0, - shardCount: 0, - messageCacheMaxSize: 200, - messageCacheLifetime: 0, - messageSweepInterval: 0, - fetchAllMembers: false, - disableEveryone: false, - sync: false, - restWsBridgeTimeout: 5000, - disabledEvents: [], - - /** - * Websocket options. These are left as snake_case to match the API. - * @typedef {Object} WebsocketOptions - * @property {number} [large_threshold=250] Number of members in a guild to be considered large - * @property {boolean} [compress=true] Whether to compress data sent on the connection. - * Defaults to `false` for browsers. - */ - ws: { - large_threshold: 250, - compress: typeof window === 'undefined', - properties: { - $os: process ? process.platform : 'discord.js', - $browser: 'discord.js', - $device: 'discord.js', - $referrer: '', - $referring_domain: '', - }, - }, -}; - -exports.Errors = { - NO_TOKEN: 'Request to use token, but token was unavailable to the client.', - NO_BOT_ACCOUNT: 'Only bot accounts are able to make use of this feature.', - NO_USER_ACCOUNT: 'Only user accounts are able to make use of this feature.', - BAD_WS_MESSAGE: 'A bad message was received from the websocket; either bad compression, or not JSON.', - TOOK_TOO_LONG: 'Something took too long to do.', - NOT_A_PERMISSION: 'Invalid permission string or number.', - INVALID_RATE_LIMIT_METHOD: 'Unknown rate limiting method.', - BAD_LOGIN: 'Incorrect login details were provided.', - INVALID_SHARD: 'Invalid shard settings were provided.', -}; - -const PROTOCOL_VERSION = exports.PROTOCOL_VERSION = 6; -const API = exports.API = `https://discordapp.com/api/v${PROTOCOL_VERSION}`; -const Endpoints = exports.Endpoints = { - // general - login: `${API}/auth/login`, - logout: `${API}/auth/logout`, - gateway: `${API}/gateway`, - botGateway: `${API}/gateway/bot`, - invite: (id) => `${API}/invite/${id}`, - inviteLink: (id) => `https://discord.gg/${id}`, - CDN: 'https://cdn.discordapp.com', - - // users - user: (userID) => `${API}/users/${userID}`, - userChannels: (userID) => `${Endpoints.user(userID)}/channels`, - userProfile: (userID) => `${Endpoints.user(userID)}/profile`, - avatar: (userID, avatar) => userID === '1' ? avatar : `${Endpoints.user(userID)}/avatars/${avatar}.jpg`, - me: `${API}/users/@me`, - meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`, - relationships: (userID) => `${Endpoints.user(userID)}/relationships`, - note: (userID) => `${Endpoints.me}/notes/${userID}`, - - // guilds - guilds: `${API}/guilds`, - guild: (guildID) => `${Endpoints.guilds}/${guildID}`, - guildIcon: (guildID, hash) => `${Endpoints.guild(guildID)}/icons/${hash}.jpg`, - guildPrune: (guildID) => `${Endpoints.guild(guildID)}/prune`, - guildEmbed: (guildID) => `${Endpoints.guild(guildID)}/embed`, - guildInvites: (guildID) => `${Endpoints.guild(guildID)}/invites`, - guildRoles: (guildID) => `${Endpoints.guild(guildID)}/roles`, - guildRole: (guildID, roleID) => `${Endpoints.guildRoles(guildID)}/${roleID}`, - guildBans: (guildID) => `${Endpoints.guild(guildID)}/bans`, - guildIntegrations: (guildID) => `${Endpoints.guild(guildID)}/integrations`, - guildMembers: (guildID) => `${Endpoints.guild(guildID)}/members`, - guildMember: (guildID, memberID) => `${Endpoints.guildMembers(guildID)}/${memberID}`, - stupidInconsistentGuildEndpoint: (guildID) => `${Endpoints.guildMember(guildID, '@me')}/nick`, - guildChannels: (guildID) => `${Endpoints.guild(guildID)}/channels`, - guildEmojis: (guildID) => `${Endpoints.guild(guildID)}/emojis`, - - // channels - channels: `${API}/channels`, - channel: (channelID) => `${Endpoints.channels}/${channelID}`, - channelMessages: (channelID) => `${Endpoints.channel(channelID)}/messages`, - channelInvites: (channelID) => `${Endpoints.channel(channelID)}/invites`, - channelTyping: (channelID) => `${Endpoints.channel(channelID)}/typing`, - channelPermissions: (channelID) => `${Endpoints.channel(channelID)}/permissions`, - channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`, - channelWebhooks: (channelID) => `${Endpoints.channel(channelID)}/webhooks`, - - // message reactions - messageReactions: (channelID, messageID) => `${Endpoints.channelMessage(channelID, messageID)}/reactions`, - messageReaction: - (channel, msg, emoji, limit) => - `${Endpoints.messageReactions(channel, msg)}/${emoji}` + - `${limit ? `?limit=${limit}` : ''}`, - selfMessageReaction: (channel, msg, emoji, limit) => - `${Endpoints.messageReaction(channel, msg, emoji, limit)}/@me`, - userMessageReaction: (channel, msg, emoji, limit, id) => - `${Endpoints.messageReaction(channel, msg, emoji, limit)}/${id}`, - - // webhooks - webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`, - - // oauth - myApplication: `${API}/oauth2/applications/@me`, - getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`, -}; - -exports.Status = { - READY: 0, - CONNECTING: 1, - RECONNECTING: 2, - IDLE: 3, - NEARLY: 4, -}; - -exports.ChannelTypes = { - text: 0, - DM: 1, - voice: 2, - groupDM: 3, -}; - -exports.OPCodes = { - DISPATCH: 0, - HEARTBEAT: 1, - IDENTIFY: 2, - STATUS_UPDATE: 3, - VOICE_STATE_UPDATE: 4, - VOICE_GUILD_PING: 5, - RESUME: 6, - RECONNECT: 7, - REQUEST_GUILD_MEMBERS: 8, - INVALID_SESSION: 9, - HELLO: 10, - HEARTBEAT_ACK: 11, -}; - -exports.VoiceOPCodes = { - IDENTIFY: 0, - SELECT_PROTOCOL: 1, - READY: 2, - HEARTBEAT: 3, - SESSION_DESCRIPTION: 4, - SPEAKING: 5, -}; - -exports.Events = { - READY: 'ready', - GUILD_CREATE: 'guildCreate', - GUILD_DELETE: 'guildDelete', - GUILD_UPDATE: 'guildUpdate', - GUILD_UNAVAILABLE: 'guildUnavailable', - GUILD_AVAILABLE: 'guildAvailable', - GUILD_MEMBER_ADD: 'guildMemberAdd', - GUILD_MEMBER_REMOVE: 'guildMemberRemove', - GUILD_MEMBER_UPDATE: 'guildMemberUpdate', - GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable', - GUILD_MEMBER_SPEAKING: 'guildMemberSpeaking', - GUILD_MEMBERS_CHUNK: 'guildMembersChunk', - GUILD_ROLE_CREATE: 'roleCreate', - GUILD_ROLE_DELETE: 'roleDelete', - GUILD_ROLE_UPDATE: 'roleUpdate', - GUILD_EMOJI_CREATE: 'guildEmojiCreate', - GUILD_EMOJI_DELETE: 'guildEmojiDelete', - GUILD_EMOJI_UPDATE: 'guildEmojiUpdate', - GUILD_BAN_ADD: 'guildBanAdd', - GUILD_BAN_REMOVE: 'guildBanRemove', - CHANNEL_CREATE: 'channelCreate', - CHANNEL_DELETE: 'channelDelete', - CHANNEL_UPDATE: 'channelUpdate', - CHANNEL_PINS_UPDATE: 'channelPinsUpdate', - MESSAGE_CREATE: 'message', - MESSAGE_DELETE: 'messageDelete', - MESSAGE_UPDATE: 'messageUpdate', - MESSAGE_BULK_DELETE: 'messageDeleteBulk', - MESSAGE_REACTION_ADD: 'messageReactionAdd', - MESSAGE_REACTION_REMOVE: 'messageReactionRemove', - MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll', - USER_UPDATE: 'userUpdate', - USER_NOTE_UPDATE: 'userNoteUpdate', - PRESENCE_UPDATE: 'presenceUpdate', - VOICE_STATE_UPDATE: 'voiceStateUpdate', - TYPING_START: 'typingStart', - TYPING_STOP: 'typingStop', - DISCONNECT: 'disconnect', - RECONNECTING: 'reconnecting', - ERROR: 'error', - WARN: 'warn', - DEBUG: 'debug', -}; - -exports.WSEvents = { - READY: 'READY', - GUILD_SYNC: 'GUILD_SYNC', - GUILD_CREATE: 'GUILD_CREATE', - GUILD_DELETE: 'GUILD_DELETE', - GUILD_UPDATE: 'GUILD_UPDATE', - GUILD_MEMBER_ADD: 'GUILD_MEMBER_ADD', - GUILD_MEMBER_REMOVE: 'GUILD_MEMBER_REMOVE', - GUILD_MEMBER_UPDATE: 'GUILD_MEMBER_UPDATE', - GUILD_MEMBERS_CHUNK: 'GUILD_MEMBERS_CHUNK', - GUILD_ROLE_CREATE: 'GUILD_ROLE_CREATE', - GUILD_ROLE_DELETE: 'GUILD_ROLE_DELETE', - GUILD_ROLE_UPDATE: 'GUILD_ROLE_UPDATE', - GUILD_BAN_ADD: 'GUILD_BAN_ADD', - GUILD_BAN_REMOVE: 'GUILD_BAN_REMOVE', - CHANNEL_CREATE: 'CHANNEL_CREATE', - CHANNEL_DELETE: 'CHANNEL_DELETE', - CHANNEL_UPDATE: 'CHANNEL_UPDATE', - CHANNEL_PINS_UPDATE: 'CHANNEL_PINS_UPDATE', - MESSAGE_CREATE: 'MESSAGE_CREATE', - MESSAGE_DELETE: 'MESSAGE_DELETE', - MESSAGE_UPDATE: 'MESSAGE_UPDATE', - MESSAGE_DELETE_BULK: 'MESSAGE_DELETE_BULK', - MESSAGE_REACTION_ADD: 'MESSAGE_REACTION_ADD', - MESSAGE_REACTION_REMOVE: 'MESSAGE_REACTION_REMOVE', - MESSAGE_REACTION_REMOVE_ALL: 'MESSAGE_REACTION_REMOVE_ALL', - USER_UPDATE: 'USER_UPDATE', - USER_NOTE_UPDATE: 'USER_NOTE_UPDATE', - PRESENCE_UPDATE: 'PRESENCE_UPDATE', - VOICE_STATE_UPDATE: 'VOICE_STATE_UPDATE', - TYPING_START: 'TYPING_START', - FRIEND_ADD: 'RELATIONSHIP_ADD', - FRIEND_REMOVE: 'RELATIONSHIP_REMOVE', - VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE', - RELATIONSHIP_ADD: 'RELATIONSHIP_ADD', - RELATIONSHIP_REMOVE: 'RELATIONSHIP_REMOVE', -}; - -exports.MessageTypes = { - 0: 'DEFAULT', - 1: 'RECIPIENT_ADD', - 2: 'RECIPIENT_REMOVE', - 3: 'CALL', - 4: 'CHANNEL_NAME_CHANGE', - 5: 'CHANNEL_ICON_CHANGE', - 6: 'PINS_ADD', -}; - -const PermissionFlags = exports.PermissionFlags = { - CREATE_INSTANT_INVITE: 1 << 0, - KICK_MEMBERS: 1 << 1, - BAN_MEMBERS: 1 << 2, - ADMINISTRATOR: 1 << 3, - MANAGE_CHANNELS: 1 << 4, - MANAGE_GUILD: 1 << 5, - ADD_REACTIONS: 1 << 6, - - READ_MESSAGES: 1 << 10, - SEND_MESSAGES: 1 << 11, - SEND_TTS_MESSAGES: 1 << 12, - MANAGE_MESSAGES: 1 << 13, - EMBED_LINKS: 1 << 14, - ATTACH_FILES: 1 << 15, - READ_MESSAGE_HISTORY: 1 << 16, - MENTION_EVERYONE: 1 << 17, - EXTERNAL_EMOJIS: 1 << 18, - - CONNECT: 1 << 20, - SPEAK: 1 << 21, - MUTE_MEMBERS: 1 << 22, - DEAFEN_MEMBERS: 1 << 23, - MOVE_MEMBERS: 1 << 24, - USE_VAD: 1 << 25, - - CHANGE_NICKNAME: 1 << 26, - MANAGE_NICKNAMES: 1 << 27, - MANAGE_ROLES_OR_PERMISSIONS: 1 << 28, - MANAGE_WEBHOOKS: 1 << 29, - MANAGE_EMOJIS: 1 << 30, -}; - -let _ALL_PERMISSIONS = 0; -for (const key in PermissionFlags) _ALL_PERMISSIONS |= PermissionFlags[key]; -exports.ALL_PERMISSIONS = _ALL_PERMISSIONS; -exports.DEFAULT_PERMISSIONS = 104324097; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) - -/***/ }, -/* 2 */ -/***/ function(module, exports) { - -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - -class AbstractHandler { - constructor(packetManager) { - this.packetManager = packetManager; - } - - handle(packet) { - return packet; - } -} - -module.exports = AbstractHandler; - - -/***/ }, -/* 4 */ -/***/ function(module, exports) { - -/* - -ABOUT ACTIONS - -Actions are similar to WebSocket Packet Handlers, but since introducing -the REST API methods, in order to prevent rewriting code to handle data, -"actions" have been introduced. They're basically what Packet Handlers -used to be but they're strictly for manipulating data and making sure -that WebSocket events don't clash with REST methods. - -*/ - -class GenericAction { - constructor(client) { - this.client = client; - } - - handle(data) { - return data; - } -} - -module.exports = GenericAction; - - -/***/ }, -/* 5 */ -/***/ function(module, exports) { - -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer, __webpack_require__(18))) /***/ }, /* 6 */ /***/ function(module, exports) { -/** - * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has - * an ID, for significantly improved performance and ease-of-use. - * @extends {Map} - */ -class Collection extends Map { - constructor(iterable) { - super(iterable); - - /** - * Cached array for the `array()` method - will be reset to `null` whenever `set()` or `delete()` are called. - * @type {?Array} - * @private - */ - this._array = null; - - /** - * Cached array for the `keyArray()` method - will be reset to `null` whenever `set()` or `delete()` are called. - * @type {?Array} - * @private - */ - this._keyArray = null; - } - - set(key, val) { - super.set(key, val); - this._array = null; - this._keyArray = null; - } - - delete(key) { - super.delete(key); - this._array = null; - this._keyArray = null; - } - - /** - * Creates an ordered array of the values of this collection, and caches it internally. The array will only be - * reconstructed if an item is added to or removed from the collection, or if you change the length of the array - * itself. If you don't want this caching behaviour, use `Array.from(collection.values())` instead. - * @returns {Array} - */ - array() { - if (!this._array || this._array.length !== this.size) this._array = Array.from(this.values()); - return this._array; - } - - /** - * Creates an ordered array of the keys of this collection, and caches it internally. The array will only be - * reconstructed if an item is added to or removed from the collection, or if you change the length of the array - * itself. If you don't want this caching behaviour, use `Array.from(collection.keys())` instead. - * @returns {Array} - */ - keyArray() { - if (!this._keyArray || this._keyArray.length !== this.size) this._keyArray = Array.from(this.keys()); - return this._keyArray; - } - - /** - * Obtains the first item in this collection. - * @returns {*} - */ - first() { - return this.values().next().value; - } - - /** - * Obtains the first key in this collection. - * @returns {*} - */ - firstKey() { - return this.keys().next().value; - } - - /** - * Obtains the last item in this collection. This relies on the `array()` method, and thus the caching mechanism - * applies here as well. - * @returns {*} - */ - last() { - const arr = this.array(); - return arr[arr.length - 1]; - } - - /** - * Obtains the last key in this collection. This relies on the `keyArray()` method, and thus the caching mechanism - * applies here as well. - * @returns {*} - */ - lastKey() { - const arr = this.keyArray(); - return arr[arr.length - 1]; - } - - /** - * Obtains a random item from this collection. This relies on the `array()` method, and thus the caching mechanism - * applies here as well. - * @returns {*} - */ - random() { - const arr = this.array(); - return arr[Math.floor(Math.random() * arr.length)]; - } - - /** - * Obtains a random key from this collection. This relies on the `keyArray()` method, and thus the caching mechanism - * applies here as well. - * @returns {*} - */ - randomKey() { - const arr = this.keyArray(); - return arr[Math.floor(Math.random() * arr.length)]; - } - - /** - * Searches for all items where their specified property's value is identical to the given value - * (`item[prop] === value`). - * @param {string} prop The property to test against - * @param {*} value The expected value - * @returns {Array} - * @example - * collection.findAll('username', 'Bob'); - */ - findAll(prop, value) { - if (typeof prop !== 'string') throw new TypeError('Key must be a string.'); - if (typeof value === 'undefined') throw new Error('Value must be specified.'); - const results = []; - for (const item of this.values()) { - if (item[prop] === value) results.push(item); - } - return results; - } - - /** - * Searches for a single item where its specified property's value is identical to the given value - * (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to - * [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find). - * Do not use this to obtain an item by its ID. Instead, use `collection.get(id)`. See - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details. - * @param {string|Function} propOrFn The property to test against, or the function to test with - * @param {*} [value] The expected value - only applicable and required if using a property for the first argument - * @returns {*} - * @example - * collection.find('username', 'Bob'); - * @example - * collection.find(val => val.username === 'Bob'); - */ - find(propOrFn, value) { - if (typeof propOrFn === 'string') { - if (typeof value === 'undefined') throw new Error('Value must be specified.'); - if (propOrFn === 'id') throw new RangeError('Don\'t use .find() with IDs. Instead, use .get(id).'); - for (const item of this.values()) { - if (item[propOrFn] === value) return item; - } - return null; - } else if (typeof propOrFn === 'function') { - for (const [key, val] of this) { - if (propOrFn(val, key, this)) return val; - } - return null; - } else { - throw new Error('First argument must be a property string or a function.'); - } - } - - /* eslint-disable max-len */ - /** - * Searches for the key of a single item where its specified property's value is identical to the given value - * (`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to - * [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex). - * @param {string|Function} propOrFn The property to test against, or the function to test with - * @param {*} [value] The expected value - only applicable and required if using a property for the first argument - * @returns {*} - * @example - * collection.findKey('username', 'Bob'); - * @example - * collection.findKey(val => val.username === 'Bob'); - */ - /* eslint-enable max-len */ - findKey(propOrFn, value) { - if (typeof propOrFn === 'string') { - if (typeof value === 'undefined') throw new Error('Value must be specified.'); - for (const [key, val] of this) { - if (val[propOrFn] === value) return key; - } - return null; - } else if (typeof propOrFn === 'function') { - for (const [key, val] of this) { - if (propOrFn(val, key, this)) return key; - } - return null; - } else { - throw new Error('First argument must be a property string or a function.'); - } - } - - /** - * Searches for the existence of a single item where its specified property's value is identical to the given value - * (`item[prop] === value`). - * Do not use this to check for an item by its ID. Instead, use `collection.has(id)`. See - * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details. - * @param {string} prop The property to test against - * @param {*} value The expected value - * @returns {boolean} - * @example - * if (collection.exists('username', 'Bob')) { - * console.log('user here!'); - * } - */ - exists(prop, value) { - if (prop === 'id') throw new RangeError('Don\'t use .exists() with IDs. Instead, use .has(id).'); - return Boolean(this.find(prop, value)); - } - - /** - * Identical to - * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter), - * but returns a Collection instead of an Array. - * @param {Function} fn Function used to test (should return a boolean) - * @param {Object} [thisArg] Value to use as `this` when executing function - * @returns {Collection} - */ - filter(fn, thisArg) { - if (thisArg) fn = fn.bind(thisArg); - const results = new Collection(); - for (const [key, val] of this) { - if (fn(val, key, this)) results.set(key, val); - } - return results; - } - - /** - * Identical to - * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). - * @param {Function} fn Function used to test (should return a boolean) - * @param {Object} [thisArg] Value to use as `this` when executing function - * @returns {Array} - */ - filterArray(fn, thisArg) { - if (thisArg) fn = fn.bind(thisArg); - const results = []; - for (const [key, val] of this) { - if (fn(val, key, this)) results.push(val); - } - return results; - } - - /** - * Identical to - * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map). - * @param {Function} fn Function that produces an element of the new array, taking three arguments - * @param {*} [thisArg] Value to use as `this` when executing function - * @returns {Array} - */ - map(fn, thisArg) { - if (thisArg) fn = fn.bind(thisArg); - const arr = new Array(this.size); - let i = 0; - for (const [key, val] of this) arr[i++] = fn(val, key, this); - return arr; - } - - /** - * Identical to - * [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some). - * @param {Function} fn Function used to test (should return a boolean) - * @param {Object} [thisArg] Value to use as `this` when executing function - * @returns {boolean} - */ - some(fn, thisArg) { - if (thisArg) fn = fn.bind(thisArg); - for (const [key, val] of this) { - if (fn(val, key, this)) return true; - } - return false; - } - - /** - * Identical to - * [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every). - * @param {Function} fn Function used to test (should return a boolean) - * @param {Object} [thisArg] Value to use as `this` when executing function - * @returns {boolean} - */ - every(fn, thisArg) { - if (thisArg) fn = fn.bind(thisArg); - for (const [key, val] of this) { - if (!fn(val, key, this)) return false; - } - return true; - } - - /** - * Identical to - * [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce). - * @param {Function} fn Function used to reduce - * @param {*} [startVal] The starting value - * @returns {*} - */ - reduce(fn, startVal) { - let currentVal = startVal; - for (const [key, val] of this) currentVal = fn(currentVal, val, key, this); - return currentVal; - } - - /** - * Combines this collection with others into a new collection. None of the source collections are modified. - * @param {Collection} collections Collections to merge (infinite/rest argument, not an array) - * @returns {Collection} - * @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl); - */ - concat(...collections) { - const newColl = new this.constructor(); - for (const [key, val] of this) newColl.set(key, val); - for (const coll of collections) { - for (const [key, val] of coll) newColl.set(key, val); - } - return newColl; - } - - /** - * Calls the `delete()` method on all items that have it. - * @returns {Promise[]} - */ - deleteAll() { - const returns = []; - for (const item of this.values()) { - if (item.delete) returns.push(item.delete()); - } - return returns; - } -} - -module.exports = Collection; - - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) { - 'use strict'; - - // Utils - function assert (val, msg) { - if (!val) throw new Error(msg || 'Assertion failed'); - } - - // Could use `inherits` module, but don't want to move from single file - // architecture yet. - function inherits (ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - - // BN - - function BN (number, base, endian) { - if (BN.isBN(number)) { - return number; - } - - this.negative = 0; - this.words = null; - this.length = 0; - - // Reduction context - this.red = null; - - if (number !== null) { - if (base === 'le' || base === 'be') { - endian = base; - base = 10; - } - - this._init(number || 0, base || 10, endian || 'be'); - } - } - if (typeof module === 'object') { - module.exports = BN; - } else { - exports.BN = BN; - } - - BN.BN = BN; - BN.wordSize = 26; - - var Buffer; - try { - Buffer = __webpack_require__(0).Buffer; - } catch (e) { - } - - BN.isBN = function isBN (num) { - if (num instanceof BN) { - return true; - } - - return num !== null && typeof num === 'object' && - num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); - }; - - BN.max = function max (left, right) { - if (left.cmp(right) > 0) return left; - return right; - }; - - BN.min = function min (left, right) { - if (left.cmp(right) < 0) return left; - return right; - }; - - BN.prototype._init = function init (number, base, endian) { - if (typeof number === 'number') { - return this._initNumber(number, base, endian); - } - - if (typeof number === 'object') { - return this._initArray(number, base, endian); - } - - if (base === 'hex') { - base = 16; - } - assert(base === (base | 0) && base >= 2 && base <= 36); - - number = number.toString().replace(/\s+/g, ''); - var start = 0; - if (number[0] === '-') { - start++; - } - - if (base === 16) { - this._parseHex(number, start); - } else { - this._parseBase(number, base, start); - } - - if (number[0] === '-') { - this.negative = 1; - } - - this.strip(); - - if (endian !== 'le') return; - - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initNumber = function _initNumber (number, base, endian) { - if (number < 0) { - this.negative = 1; - number = -number; - } - if (number < 0x4000000) { - this.words = [ number & 0x3ffffff ]; - this.length = 1; - } else if (number < 0x10000000000000) { - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff - ]; - this.length = 2; - } else { - assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff, - 1 - ]; - this.length = 3; - } - - if (endian !== 'le') return; - - // Reverse the bytes - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initArray = function _initArray (number, base, endian) { - // Perhaps a Uint8Array - assert(typeof number.length === 'number'); - if (number.length <= 0) { - this.words = [ 0 ]; - this.length = 1; - return this; - } - - this.length = Math.ceil(number.length / 3); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - var off = 0; - if (endian === 'be') { - for (i = number.length - 1, j = 0; i >= 0; i -= 3) { - w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } else if (endian === 'le') { - for (i = 0, j = 0; i < number.length; i += 3) { - w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } - return this.strip(); - }; - - function parseHex (str, start, end) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r <<= 4; - - // 'a' - 'f' - if (c >= 49 && c <= 54) { - r |= c - 49 + 0xa; - - // 'A' - 'F' - } else if (c >= 17 && c <= 22) { - r |= c - 17 + 0xa; - - // '0' - '9' - } else { - r |= c & 0xf; - } - } - return r; - } - - BN.prototype._parseHex = function _parseHex (number, start) { - // Create possibly bigger array to ensure that it fits the number - this.length = Math.ceil((number.length - start) / 6); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - // Scan 24-bit chunks and add them to the number - var off = 0; - for (i = number.length - 6, j = 0; i >= start; i -= 6) { - w = parseHex(number, i, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - if (i + 6 !== start) { - w = parseHex(number, start, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - } - this.strip(); - }; - - function parseBase (str, start, end, mul) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r *= mul; - - // 'a' - if (c >= 49) { - r += c - 49 + 0xa; - - // 'A' - } else if (c >= 17) { - r += c - 17 + 0xa; - - // '0' - '9' - } else { - r += c; - } - } - return r; - } - - BN.prototype._parseBase = function _parseBase (number, base, start) { - // Initialize as zero - this.words = [ 0 ]; - this.length = 1; - - // Find length of limb in base - for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { - limbLen++; - } - limbLen--; - limbPow = (limbPow / base) | 0; - - var total = number.length - start; - var mod = total % limbLen; - var end = Math.min(total, total - mod) + start; - - var word = 0; - for (var i = start; i < end; i += limbLen) { - word = parseBase(number, i, i + limbLen, base); - - this.imuln(limbPow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - if (mod !== 0) { - var pow = 1; - word = parseBase(number, i, number.length, base); - - for (i = 0; i < mod; i++) { - pow *= base; - } - - this.imuln(pow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - }; - - BN.prototype.copy = function copy (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - dest.words[i] = this.words[i]; - } - dest.length = this.length; - dest.negative = this.negative; - dest.red = this.red; - }; - - BN.prototype.clone = function clone () { - var r = new BN(null); - this.copy(r); - return r; - }; - - BN.prototype._expand = function _expand (size) { - while (this.length < size) { - this.words[this.length++] = 0; - } - return this; - }; - - // Remove leading `0` from `this` - BN.prototype.strip = function strip () { - while (this.length > 1 && this.words[this.length - 1] === 0) { - this.length--; - } - return this._normSign(); - }; - - BN.prototype._normSign = function _normSign () { - // -0 = 0 - if (this.length === 1 && this.words[0] === 0) { - this.negative = 0; - } - return this; - }; - - BN.prototype.inspect = function inspect () { - return (this.red ? ''; - }; - - /* - - var zeros = []; - var groupSizes = []; - var groupBases = []; - - var s = ''; - var i = -1; - while (++i < BN.wordSize) { - zeros[i] = s; - s += '0'; - } - groupSizes[0] = 0; - groupSizes[1] = 0; - groupBases[0] = 0; - groupBases[1] = 0; - var base = 2 - 1; - while (++base < 36 + 1) { - var groupSize = 0; - var groupBase = 1; - while (groupBase < (1 << BN.wordSize) / base) { - groupBase *= base; - groupSize += 1; - } - groupSizes[base] = groupSize; - groupBases[base] = groupBase; - } - - */ - - var zeros = [ - '', - '0', - '00', - '000', - '0000', - '00000', - '000000', - '0000000', - '00000000', - '000000000', - '0000000000', - '00000000000', - '000000000000', - '0000000000000', - '00000000000000', - '000000000000000', - '0000000000000000', - '00000000000000000', - '000000000000000000', - '0000000000000000000', - '00000000000000000000', - '000000000000000000000', - '0000000000000000000000', - '00000000000000000000000', - '000000000000000000000000', - '0000000000000000000000000' - ]; - - var groupSizes = [ - 0, 0, - 25, 16, 12, 11, 10, 9, 8, - 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 6, 6, 5, 5, - 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5 - ]; - - var groupBases = [ - 0, 0, - 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, - 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, - 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, - 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, - 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 - ]; - - BN.prototype.toString = function toString (base, padding) { - base = base || 10; - padding = padding | 0 || 1; - - var out; - if (base === 16 || base === 'hex') { - out = ''; - var off = 0; - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = this.words[i]; - var word = (((w << off) | carry) & 0xffffff).toString(16); - carry = (w >>> (24 - off)) & 0xffffff; - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - } - if (carry !== 0) { - out = carry.toString(16) + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - if (base === (base | 0) && base >= 2 && base <= 36) { - // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); - var groupSize = groupSizes[base]; - // var groupBase = Math.pow(base, groupSize); - var groupBase = groupBases[base]; - out = ''; - var c = this.clone(); - c.negative = 0; - while (!c.isZero()) { - var r = c.modn(groupBase).toString(base); - c = c.idivn(groupBase); - - if (!c.isZero()) { - out = zeros[groupSize - r.length] + r + out; - } else { - out = r + out; - } - } - if (this.isZero()) { - out = '0' + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - assert(false, 'Base should be between 2 and 36'); - }; - - BN.prototype.toNumber = function toNumber () { - var ret = this.words[0]; - if (this.length === 2) { - ret += this.words[1] * 0x4000000; - } else if (this.length === 3 && this.words[2] === 0x01) { - // NOTE: at this stage it is known that the top bit is set - ret += 0x10000000000000 + (this.words[1] * 0x4000000); - } else if (this.length > 2) { - assert(false, 'Number can only safely store up to 53 bits'); - } - return (this.negative !== 0) ? -ret : ret; - }; - - BN.prototype.toJSON = function toJSON () { - return this.toString(16); - }; - - BN.prototype.toBuffer = function toBuffer (endian, length) { - assert(typeof Buffer !== 'undefined'); - return this.toArrayLike(Buffer, endian, length); - }; - - BN.prototype.toArray = function toArray (endian, length) { - return this.toArrayLike(Array, endian, length); - }; - - BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { - var byteLength = this.byteLength(); - var reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, 'byte array longer than desired length'); - assert(reqLength > 0, 'Requested array length <= 0'); - - this.strip(); - var littleEndian = endian === 'le'; - var res = new ArrayType(reqLength); - - var b, i; - var q = this.clone(); - if (!littleEndian) { - // Assume big-endian - for (i = 0; i < reqLength - byteLength; i++) { - res[i] = 0; - } - - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[reqLength - i - 1] = b; - } - } else { - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[i] = b; - } - - for (; i < reqLength; i++) { - res[i] = 0; - } - } - - return res; - }; - - if (Math.clz32) { - BN.prototype._countBits = function _countBits (w) { - return 32 - Math.clz32(w); - }; - } else { - BN.prototype._countBits = function _countBits (w) { - var t = w; - var r = 0; - if (t >= 0x1000) { - r += 13; - t >>>= 13; - } - if (t >= 0x40) { - r += 7; - t >>>= 7; - } - if (t >= 0x8) { - r += 4; - t >>>= 4; - } - if (t >= 0x02) { - r += 2; - t >>>= 2; - } - return r + t; - }; - } - - BN.prototype._zeroBits = function _zeroBits (w) { - // Short-cut - if (w === 0) return 26; - - var t = w; - var r = 0; - if ((t & 0x1fff) === 0) { - r += 13; - t >>>= 13; - } - if ((t & 0x7f) === 0) { - r += 7; - t >>>= 7; - } - if ((t & 0xf) === 0) { - r += 4; - t >>>= 4; - } - if ((t & 0x3) === 0) { - r += 2; - t >>>= 2; - } - if ((t & 0x1) === 0) { - r++; - } - return r; - }; - - // Return number of used bits in a BN - BN.prototype.bitLength = function bitLength () { - var w = this.words[this.length - 1]; - var hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }; - - function toBitArray (num) { - var w = new Array(num.bitLength()); - - for (var bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0; - var wbit = bit % 26; - - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - - return w; - } - - // Number of trailing zero bits - BN.prototype.zeroBits = function zeroBits () { - if (this.isZero()) return 0; - - var r = 0; - for (var i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - r += b; - if (b !== 26) break; - } - return r; - }; - - BN.prototype.byteLength = function byteLength () { - return Math.ceil(this.bitLength() / 8); - }; - - BN.prototype.toTwos = function toTwos (width) { - if (this.negative !== 0) { - return this.abs().inotn(width).iaddn(1); - } - return this.clone(); - }; - - BN.prototype.fromTwos = function fromTwos (width) { - if (this.testn(width - 1)) { - return this.notn(width).iaddn(1).ineg(); - } - return this.clone(); - }; - - BN.prototype.isNeg = function isNeg () { - return this.negative !== 0; - }; - - // Return negative clone of `this` - BN.prototype.neg = function neg () { - return this.clone().ineg(); - }; - - BN.prototype.ineg = function ineg () { - if (!this.isZero()) { - this.negative ^= 1; - } - - return this; - }; - - // Or `num` with `this` in-place - BN.prototype.iuor = function iuor (num) { - while (this.length < num.length) { - this.words[this.length++] = 0; - } - - for (var i = 0; i < num.length; i++) { - this.words[i] = this.words[i] | num.words[i]; - } - - return this.strip(); - }; - - BN.prototype.ior = function ior (num) { - assert((this.negative | num.negative) === 0); - return this.iuor(num); - }; - - // Or `num` with `this` - BN.prototype.or = function or (num) { - if (this.length > num.length) return this.clone().ior(num); - return num.clone().ior(this); - }; - - BN.prototype.uor = function uor (num) { - if (this.length > num.length) return this.clone().iuor(num); - return num.clone().iuor(this); - }; - - // And `num` with `this` in-place - BN.prototype.iuand = function iuand (num) { - // b = min-length(num, this) - var b; - if (this.length > num.length) { - b = num; - } else { - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = this.words[i] & num.words[i]; - } - - this.length = b.length; - - return this.strip(); - }; - - BN.prototype.iand = function iand (num) { - assert((this.negative | num.negative) === 0); - return this.iuand(num); - }; - - // And `num` with `this` - BN.prototype.and = function and (num) { - if (this.length > num.length) return this.clone().iand(num); - return num.clone().iand(this); - }; - - BN.prototype.uand = function uand (num) { - if (this.length > num.length) return this.clone().iuand(num); - return num.clone().iuand(this); - }; - - // Xor `num` with `this` in-place - BN.prototype.iuxor = function iuxor (num) { - // a.length > b.length - var a; - var b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = a.words[i] ^ b.words[i]; - } - - if (this !== a) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = a.length; - - return this.strip(); - }; - - BN.prototype.ixor = function ixor (num) { - assert((this.negative | num.negative) === 0); - return this.iuxor(num); - }; - - // Xor `num` with `this` - BN.prototype.xor = function xor (num) { - if (this.length > num.length) return this.clone().ixor(num); - return num.clone().ixor(this); - }; - - BN.prototype.uxor = function uxor (num) { - if (this.length > num.length) return this.clone().iuxor(num); - return num.clone().iuxor(this); - }; - - // Not ``this`` with ``width`` bitwidth - BN.prototype.inotn = function inotn (width) { - assert(typeof width === 'number' && width >= 0); - - var bytesNeeded = Math.ceil(width / 26) | 0; - var bitsLeft = width % 26; - - // Extend the buffer with leading zeroes - this._expand(bytesNeeded); - - if (bitsLeft > 0) { - bytesNeeded--; - } - - // Handle complete words - for (var i = 0; i < bytesNeeded; i++) { - this.words[i] = ~this.words[i] & 0x3ffffff; - } - - // Handle the residue - if (bitsLeft > 0) { - this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); - } - - // And remove leading zeroes - return this.strip(); - }; - - BN.prototype.notn = function notn (width) { - return this.clone().inotn(width); - }; - - // Set `bit` of `this` - BN.prototype.setn = function setn (bit, val) { - assert(typeof bit === 'number' && bit >= 0); - - var off = (bit / 26) | 0; - var wbit = bit % 26; - - this._expand(off + 1); - - if (val) { - this.words[off] = this.words[off] | (1 << wbit); - } else { - this.words[off] = this.words[off] & ~(1 << wbit); - } - - return this.strip(); - }; - - // Add `num` to `this` in-place - BN.prototype.iadd = function iadd (num) { - var r; - - // negative + positive - if (this.negative !== 0 && num.negative === 0) { - this.negative = 0; - r = this.isub(num); - this.negative ^= 1; - return this._normSign(); - - // positive + negative - } else if (this.negative === 0 && num.negative !== 0) { - num.negative = 0; - r = this.isub(num); - num.negative = 1; - return r._normSign(); - } - - // a.length > b.length - var a, b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) + (b.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - - this.length = a.length; - if (carry !== 0) { - this.words[this.length] = carry; - this.length++; - // Copy the rest of the words - } else if (a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - return this; - }; - - // Add `num` to `this` - BN.prototype.add = function add (num) { - var res; - if (num.negative !== 0 && this.negative === 0) { - num.negative = 0; - res = this.sub(num); - num.negative ^= 1; - return res; - } else if (num.negative === 0 && this.negative !== 0) { - this.negative = 0; - res = num.sub(this); - this.negative = 1; - return res; - } - - if (this.length > num.length) return this.clone().iadd(num); - - return num.clone().iadd(this); - }; - - // Subtract `num` from `this` in-place - BN.prototype.isub = function isub (num) { - // this - (-num) = this + num - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - num.negative = 1; - return r._normSign(); - - // -this - num = -(this + num) - } else if (this.negative !== 0) { - this.negative = 0; - this.iadd(num); - this.negative = 1; - return this._normSign(); - } - - // At this point both numbers are positive - var cmp = this.cmp(num); - - // Optimization - zeroify - if (cmp === 0) { - this.negative = 0; - this.length = 1; - this.words[0] = 0; - return this; - } - - // a > b - var a, b; - if (cmp > 0) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) - (b.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - - // Copy rest of the words - if (carry === 0 && i < a.length && a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = Math.max(this.length, i); - - if (a !== this) { - this.negative = 1; - } - - return this.strip(); - }; - - // Subtract `num` from `this` - BN.prototype.sub = function sub (num) { - return this.clone().isub(num); - }; - - function smallMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - var len = (self.length + num.length) | 0; - out.length = len; - len = (len - 1) | 0; - - // Peel one iteration (compiler can't do it, because of code complexity) - var a = self.words[0] | 0; - var b = num.words[0] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - var carry = (r / 0x4000000) | 0; - out.words[0] = lo; - - for (var k = 1; k < len; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = carry >>> 26; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = (k - j) | 0; - a = self.words[i] | 0; - b = num.words[j] | 0; - r = a * b + rword; - ncarry += (r / 0x4000000) | 0; - rword = r & 0x3ffffff; - } - out.words[k] = rword | 0; - carry = ncarry | 0; - } - if (carry !== 0) { - out.words[k] = carry | 0; - } else { - out.length--; - } - - return out.strip(); - } - - // TODO(indutny): it may be reasonable to omit it for users who don't need - // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit - // multiplication (like elliptic secp256k1). - var comb10MulTo = function comb10MulTo (self, num, out) { - var a = self.words; - var b = num.words; - var o = out.words; - var c = 0; - var lo; - var mid; - var hi; - var a0 = a[0] | 0; - var al0 = a0 & 0x1fff; - var ah0 = a0 >>> 13; - var a1 = a[1] | 0; - var al1 = a1 & 0x1fff; - var ah1 = a1 >>> 13; - var a2 = a[2] | 0; - var al2 = a2 & 0x1fff; - var ah2 = a2 >>> 13; - var a3 = a[3] | 0; - var al3 = a3 & 0x1fff; - var ah3 = a3 >>> 13; - var a4 = a[4] | 0; - var al4 = a4 & 0x1fff; - var ah4 = a4 >>> 13; - var a5 = a[5] | 0; - var al5 = a5 & 0x1fff; - var ah5 = a5 >>> 13; - var a6 = a[6] | 0; - var al6 = a6 & 0x1fff; - var ah6 = a6 >>> 13; - var a7 = a[7] | 0; - var al7 = a7 & 0x1fff; - var ah7 = a7 >>> 13; - var a8 = a[8] | 0; - var al8 = a8 & 0x1fff; - var ah8 = a8 >>> 13; - var a9 = a[9] | 0; - var al9 = a9 & 0x1fff; - var ah9 = a9 >>> 13; - var b0 = b[0] | 0; - var bl0 = b0 & 0x1fff; - var bh0 = b0 >>> 13; - var b1 = b[1] | 0; - var bl1 = b1 & 0x1fff; - var bh1 = b1 >>> 13; - var b2 = b[2] | 0; - var bl2 = b2 & 0x1fff; - var bh2 = b2 >>> 13; - var b3 = b[3] | 0; - var bl3 = b3 & 0x1fff; - var bh3 = b3 >>> 13; - var b4 = b[4] | 0; - var bl4 = b4 & 0x1fff; - var bh4 = b4 >>> 13; - var b5 = b[5] | 0; - var bl5 = b5 & 0x1fff; - var bh5 = b5 >>> 13; - var b6 = b[6] | 0; - var bl6 = b6 & 0x1fff; - var bh6 = b6 >>> 13; - var b7 = b[7] | 0; - var bl7 = b7 & 0x1fff; - var bh7 = b7 >>> 13; - var b8 = b[8] | 0; - var bl8 = b8 & 0x1fff; - var bh8 = b8 >>> 13; - var b9 = b[9] | 0; - var bl9 = b9 & 0x1fff; - var bh9 = b9 >>> 13; - - out.negative = self.negative ^ num.negative; - out.length = 19; - /* k = 0 */ - lo = Math.imul(al0, bl0); - mid = Math.imul(al0, bh0); - mid = (mid + Math.imul(ah0, bl0)) | 0; - hi = Math.imul(ah0, bh0); - var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; - w0 &= 0x3ffffff; - /* k = 1 */ - lo = Math.imul(al1, bl0); - mid = Math.imul(al1, bh0); - mid = (mid + Math.imul(ah1, bl0)) | 0; - hi = Math.imul(ah1, bh0); - lo = (lo + Math.imul(al0, bl1)) | 0; - mid = (mid + Math.imul(al0, bh1)) | 0; - mid = (mid + Math.imul(ah0, bl1)) | 0; - hi = (hi + Math.imul(ah0, bh1)) | 0; - var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; - w1 &= 0x3ffffff; - /* k = 2 */ - lo = Math.imul(al2, bl0); - mid = Math.imul(al2, bh0); - mid = (mid + Math.imul(ah2, bl0)) | 0; - hi = Math.imul(ah2, bh0); - lo = (lo + Math.imul(al1, bl1)) | 0; - mid = (mid + Math.imul(al1, bh1)) | 0; - mid = (mid + Math.imul(ah1, bl1)) | 0; - hi = (hi + Math.imul(ah1, bh1)) | 0; - lo = (lo + Math.imul(al0, bl2)) | 0; - mid = (mid + Math.imul(al0, bh2)) | 0; - mid = (mid + Math.imul(ah0, bl2)) | 0; - hi = (hi + Math.imul(ah0, bh2)) | 0; - var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; - w2 &= 0x3ffffff; - /* k = 3 */ - lo = Math.imul(al3, bl0); - mid = Math.imul(al3, bh0); - mid = (mid + Math.imul(ah3, bl0)) | 0; - hi = Math.imul(ah3, bh0); - lo = (lo + Math.imul(al2, bl1)) | 0; - mid = (mid + Math.imul(al2, bh1)) | 0; - mid = (mid + Math.imul(ah2, bl1)) | 0; - hi = (hi + Math.imul(ah2, bh1)) | 0; - lo = (lo + Math.imul(al1, bl2)) | 0; - mid = (mid + Math.imul(al1, bh2)) | 0; - mid = (mid + Math.imul(ah1, bl2)) | 0; - hi = (hi + Math.imul(ah1, bh2)) | 0; - lo = (lo + Math.imul(al0, bl3)) | 0; - mid = (mid + Math.imul(al0, bh3)) | 0; - mid = (mid + Math.imul(ah0, bl3)) | 0; - hi = (hi + Math.imul(ah0, bh3)) | 0; - var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; - w3 &= 0x3ffffff; - /* k = 4 */ - lo = Math.imul(al4, bl0); - mid = Math.imul(al4, bh0); - mid = (mid + Math.imul(ah4, bl0)) | 0; - hi = Math.imul(ah4, bh0); - lo = (lo + Math.imul(al3, bl1)) | 0; - mid = (mid + Math.imul(al3, bh1)) | 0; - mid = (mid + Math.imul(ah3, bl1)) | 0; - hi = (hi + Math.imul(ah3, bh1)) | 0; - lo = (lo + Math.imul(al2, bl2)) | 0; - mid = (mid + Math.imul(al2, bh2)) | 0; - mid = (mid + Math.imul(ah2, bl2)) | 0; - hi = (hi + Math.imul(ah2, bh2)) | 0; - lo = (lo + Math.imul(al1, bl3)) | 0; - mid = (mid + Math.imul(al1, bh3)) | 0; - mid = (mid + Math.imul(ah1, bl3)) | 0; - hi = (hi + Math.imul(ah1, bh3)) | 0; - lo = (lo + Math.imul(al0, bl4)) | 0; - mid = (mid + Math.imul(al0, bh4)) | 0; - mid = (mid + Math.imul(ah0, bl4)) | 0; - hi = (hi + Math.imul(ah0, bh4)) | 0; - var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; - w4 &= 0x3ffffff; - /* k = 5 */ - lo = Math.imul(al5, bl0); - mid = Math.imul(al5, bh0); - mid = (mid + Math.imul(ah5, bl0)) | 0; - hi = Math.imul(ah5, bh0); - lo = (lo + Math.imul(al4, bl1)) | 0; - mid = (mid + Math.imul(al4, bh1)) | 0; - mid = (mid + Math.imul(ah4, bl1)) | 0; - hi = (hi + Math.imul(ah4, bh1)) | 0; - lo = (lo + Math.imul(al3, bl2)) | 0; - mid = (mid + Math.imul(al3, bh2)) | 0; - mid = (mid + Math.imul(ah3, bl2)) | 0; - hi = (hi + Math.imul(ah3, bh2)) | 0; - lo = (lo + Math.imul(al2, bl3)) | 0; - mid = (mid + Math.imul(al2, bh3)) | 0; - mid = (mid + Math.imul(ah2, bl3)) | 0; - hi = (hi + Math.imul(ah2, bh3)) | 0; - lo = (lo + Math.imul(al1, bl4)) | 0; - mid = (mid + Math.imul(al1, bh4)) | 0; - mid = (mid + Math.imul(ah1, bl4)) | 0; - hi = (hi + Math.imul(ah1, bh4)) | 0; - lo = (lo + Math.imul(al0, bl5)) | 0; - mid = (mid + Math.imul(al0, bh5)) | 0; - mid = (mid + Math.imul(ah0, bl5)) | 0; - hi = (hi + Math.imul(ah0, bh5)) | 0; - var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; - w5 &= 0x3ffffff; - /* k = 6 */ - lo = Math.imul(al6, bl0); - mid = Math.imul(al6, bh0); - mid = (mid + Math.imul(ah6, bl0)) | 0; - hi = Math.imul(ah6, bh0); - lo = (lo + Math.imul(al5, bl1)) | 0; - mid = (mid + Math.imul(al5, bh1)) | 0; - mid = (mid + Math.imul(ah5, bl1)) | 0; - hi = (hi + Math.imul(ah5, bh1)) | 0; - lo = (lo + Math.imul(al4, bl2)) | 0; - mid = (mid + Math.imul(al4, bh2)) | 0; - mid = (mid + Math.imul(ah4, bl2)) | 0; - hi = (hi + Math.imul(ah4, bh2)) | 0; - lo = (lo + Math.imul(al3, bl3)) | 0; - mid = (mid + Math.imul(al3, bh3)) | 0; - mid = (mid + Math.imul(ah3, bl3)) | 0; - hi = (hi + Math.imul(ah3, bh3)) | 0; - lo = (lo + Math.imul(al2, bl4)) | 0; - mid = (mid + Math.imul(al2, bh4)) | 0; - mid = (mid + Math.imul(ah2, bl4)) | 0; - hi = (hi + Math.imul(ah2, bh4)) | 0; - lo = (lo + Math.imul(al1, bl5)) | 0; - mid = (mid + Math.imul(al1, bh5)) | 0; - mid = (mid + Math.imul(ah1, bl5)) | 0; - hi = (hi + Math.imul(ah1, bh5)) | 0; - lo = (lo + Math.imul(al0, bl6)) | 0; - mid = (mid + Math.imul(al0, bh6)) | 0; - mid = (mid + Math.imul(ah0, bl6)) | 0; - hi = (hi + Math.imul(ah0, bh6)) | 0; - var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; - w6 &= 0x3ffffff; - /* k = 7 */ - lo = Math.imul(al7, bl0); - mid = Math.imul(al7, bh0); - mid = (mid + Math.imul(ah7, bl0)) | 0; - hi = Math.imul(ah7, bh0); - lo = (lo + Math.imul(al6, bl1)) | 0; - mid = (mid + Math.imul(al6, bh1)) | 0; - mid = (mid + Math.imul(ah6, bl1)) | 0; - hi = (hi + Math.imul(ah6, bh1)) | 0; - lo = (lo + Math.imul(al5, bl2)) | 0; - mid = (mid + Math.imul(al5, bh2)) | 0; - mid = (mid + Math.imul(ah5, bl2)) | 0; - hi = (hi + Math.imul(ah5, bh2)) | 0; - lo = (lo + Math.imul(al4, bl3)) | 0; - mid = (mid + Math.imul(al4, bh3)) | 0; - mid = (mid + Math.imul(ah4, bl3)) | 0; - hi = (hi + Math.imul(ah4, bh3)) | 0; - lo = (lo + Math.imul(al3, bl4)) | 0; - mid = (mid + Math.imul(al3, bh4)) | 0; - mid = (mid + Math.imul(ah3, bl4)) | 0; - hi = (hi + Math.imul(ah3, bh4)) | 0; - lo = (lo + Math.imul(al2, bl5)) | 0; - mid = (mid + Math.imul(al2, bh5)) | 0; - mid = (mid + Math.imul(ah2, bl5)) | 0; - hi = (hi + Math.imul(ah2, bh5)) | 0; - lo = (lo + Math.imul(al1, bl6)) | 0; - mid = (mid + Math.imul(al1, bh6)) | 0; - mid = (mid + Math.imul(ah1, bl6)) | 0; - hi = (hi + Math.imul(ah1, bh6)) | 0; - lo = (lo + Math.imul(al0, bl7)) | 0; - mid = (mid + Math.imul(al0, bh7)) | 0; - mid = (mid + Math.imul(ah0, bl7)) | 0; - hi = (hi + Math.imul(ah0, bh7)) | 0; - var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; - w7 &= 0x3ffffff; - /* k = 8 */ - lo = Math.imul(al8, bl0); - mid = Math.imul(al8, bh0); - mid = (mid + Math.imul(ah8, bl0)) | 0; - hi = Math.imul(ah8, bh0); - lo = (lo + Math.imul(al7, bl1)) | 0; - mid = (mid + Math.imul(al7, bh1)) | 0; - mid = (mid + Math.imul(ah7, bl1)) | 0; - hi = (hi + Math.imul(ah7, bh1)) | 0; - lo = (lo + Math.imul(al6, bl2)) | 0; - mid = (mid + Math.imul(al6, bh2)) | 0; - mid = (mid + Math.imul(ah6, bl2)) | 0; - hi = (hi + Math.imul(ah6, bh2)) | 0; - lo = (lo + Math.imul(al5, bl3)) | 0; - mid = (mid + Math.imul(al5, bh3)) | 0; - mid = (mid + Math.imul(ah5, bl3)) | 0; - hi = (hi + Math.imul(ah5, bh3)) | 0; - lo = (lo + Math.imul(al4, bl4)) | 0; - mid = (mid + Math.imul(al4, bh4)) | 0; - mid = (mid + Math.imul(ah4, bl4)) | 0; - hi = (hi + Math.imul(ah4, bh4)) | 0; - lo = (lo + Math.imul(al3, bl5)) | 0; - mid = (mid + Math.imul(al3, bh5)) | 0; - mid = (mid + Math.imul(ah3, bl5)) | 0; - hi = (hi + Math.imul(ah3, bh5)) | 0; - lo = (lo + Math.imul(al2, bl6)) | 0; - mid = (mid + Math.imul(al2, bh6)) | 0; - mid = (mid + Math.imul(ah2, bl6)) | 0; - hi = (hi + Math.imul(ah2, bh6)) | 0; - lo = (lo + Math.imul(al1, bl7)) | 0; - mid = (mid + Math.imul(al1, bh7)) | 0; - mid = (mid + Math.imul(ah1, bl7)) | 0; - hi = (hi + Math.imul(ah1, bh7)) | 0; - lo = (lo + Math.imul(al0, bl8)) | 0; - mid = (mid + Math.imul(al0, bh8)) | 0; - mid = (mid + Math.imul(ah0, bl8)) | 0; - hi = (hi + Math.imul(ah0, bh8)) | 0; - var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; - w8 &= 0x3ffffff; - /* k = 9 */ - lo = Math.imul(al9, bl0); - mid = Math.imul(al9, bh0); - mid = (mid + Math.imul(ah9, bl0)) | 0; - hi = Math.imul(ah9, bh0); - lo = (lo + Math.imul(al8, bl1)) | 0; - mid = (mid + Math.imul(al8, bh1)) | 0; - mid = (mid + Math.imul(ah8, bl1)) | 0; - hi = (hi + Math.imul(ah8, bh1)) | 0; - lo = (lo + Math.imul(al7, bl2)) | 0; - mid = (mid + Math.imul(al7, bh2)) | 0; - mid = (mid + Math.imul(ah7, bl2)) | 0; - hi = (hi + Math.imul(ah7, bh2)) | 0; - lo = (lo + Math.imul(al6, bl3)) | 0; - mid = (mid + Math.imul(al6, bh3)) | 0; - mid = (mid + Math.imul(ah6, bl3)) | 0; - hi = (hi + Math.imul(ah6, bh3)) | 0; - lo = (lo + Math.imul(al5, bl4)) | 0; - mid = (mid + Math.imul(al5, bh4)) | 0; - mid = (mid + Math.imul(ah5, bl4)) | 0; - hi = (hi + Math.imul(ah5, bh4)) | 0; - lo = (lo + Math.imul(al4, bl5)) | 0; - mid = (mid + Math.imul(al4, bh5)) | 0; - mid = (mid + Math.imul(ah4, bl5)) | 0; - hi = (hi + Math.imul(ah4, bh5)) | 0; - lo = (lo + Math.imul(al3, bl6)) | 0; - mid = (mid + Math.imul(al3, bh6)) | 0; - mid = (mid + Math.imul(ah3, bl6)) | 0; - hi = (hi + Math.imul(ah3, bh6)) | 0; - lo = (lo + Math.imul(al2, bl7)) | 0; - mid = (mid + Math.imul(al2, bh7)) | 0; - mid = (mid + Math.imul(ah2, bl7)) | 0; - hi = (hi + Math.imul(ah2, bh7)) | 0; - lo = (lo + Math.imul(al1, bl8)) | 0; - mid = (mid + Math.imul(al1, bh8)) | 0; - mid = (mid + Math.imul(ah1, bl8)) | 0; - hi = (hi + Math.imul(ah1, bh8)) | 0; - lo = (lo + Math.imul(al0, bl9)) | 0; - mid = (mid + Math.imul(al0, bh9)) | 0; - mid = (mid + Math.imul(ah0, bl9)) | 0; - hi = (hi + Math.imul(ah0, bh9)) | 0; - var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; - w9 &= 0x3ffffff; - /* k = 10 */ - lo = Math.imul(al9, bl1); - mid = Math.imul(al9, bh1); - mid = (mid + Math.imul(ah9, bl1)) | 0; - hi = Math.imul(ah9, bh1); - lo = (lo + Math.imul(al8, bl2)) | 0; - mid = (mid + Math.imul(al8, bh2)) | 0; - mid = (mid + Math.imul(ah8, bl2)) | 0; - hi = (hi + Math.imul(ah8, bh2)) | 0; - lo = (lo + Math.imul(al7, bl3)) | 0; - mid = (mid + Math.imul(al7, bh3)) | 0; - mid = (mid + Math.imul(ah7, bl3)) | 0; - hi = (hi + Math.imul(ah7, bh3)) | 0; - lo = (lo + Math.imul(al6, bl4)) | 0; - mid = (mid + Math.imul(al6, bh4)) | 0; - mid = (mid + Math.imul(ah6, bl4)) | 0; - hi = (hi + Math.imul(ah6, bh4)) | 0; - lo = (lo + Math.imul(al5, bl5)) | 0; - mid = (mid + Math.imul(al5, bh5)) | 0; - mid = (mid + Math.imul(ah5, bl5)) | 0; - hi = (hi + Math.imul(ah5, bh5)) | 0; - lo = (lo + Math.imul(al4, bl6)) | 0; - mid = (mid + Math.imul(al4, bh6)) | 0; - mid = (mid + Math.imul(ah4, bl6)) | 0; - hi = (hi + Math.imul(ah4, bh6)) | 0; - lo = (lo + Math.imul(al3, bl7)) | 0; - mid = (mid + Math.imul(al3, bh7)) | 0; - mid = (mid + Math.imul(ah3, bl7)) | 0; - hi = (hi + Math.imul(ah3, bh7)) | 0; - lo = (lo + Math.imul(al2, bl8)) | 0; - mid = (mid + Math.imul(al2, bh8)) | 0; - mid = (mid + Math.imul(ah2, bl8)) | 0; - hi = (hi + Math.imul(ah2, bh8)) | 0; - lo = (lo + Math.imul(al1, bl9)) | 0; - mid = (mid + Math.imul(al1, bh9)) | 0; - mid = (mid + Math.imul(ah1, bl9)) | 0; - hi = (hi + Math.imul(ah1, bh9)) | 0; - var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; - w10 &= 0x3ffffff; - /* k = 11 */ - lo = Math.imul(al9, bl2); - mid = Math.imul(al9, bh2); - mid = (mid + Math.imul(ah9, bl2)) | 0; - hi = Math.imul(ah9, bh2); - lo = (lo + Math.imul(al8, bl3)) | 0; - mid = (mid + Math.imul(al8, bh3)) | 0; - mid = (mid + Math.imul(ah8, bl3)) | 0; - hi = (hi + Math.imul(ah8, bh3)) | 0; - lo = (lo + Math.imul(al7, bl4)) | 0; - mid = (mid + Math.imul(al7, bh4)) | 0; - mid = (mid + Math.imul(ah7, bl4)) | 0; - hi = (hi + Math.imul(ah7, bh4)) | 0; - lo = (lo + Math.imul(al6, bl5)) | 0; - mid = (mid + Math.imul(al6, bh5)) | 0; - mid = (mid + Math.imul(ah6, bl5)) | 0; - hi = (hi + Math.imul(ah6, bh5)) | 0; - lo = (lo + Math.imul(al5, bl6)) | 0; - mid = (mid + Math.imul(al5, bh6)) | 0; - mid = (mid + Math.imul(ah5, bl6)) | 0; - hi = (hi + Math.imul(ah5, bh6)) | 0; - lo = (lo + Math.imul(al4, bl7)) | 0; - mid = (mid + Math.imul(al4, bh7)) | 0; - mid = (mid + Math.imul(ah4, bl7)) | 0; - hi = (hi + Math.imul(ah4, bh7)) | 0; - lo = (lo + Math.imul(al3, bl8)) | 0; - mid = (mid + Math.imul(al3, bh8)) | 0; - mid = (mid + Math.imul(ah3, bl8)) | 0; - hi = (hi + Math.imul(ah3, bh8)) | 0; - lo = (lo + Math.imul(al2, bl9)) | 0; - mid = (mid + Math.imul(al2, bh9)) | 0; - mid = (mid + Math.imul(ah2, bl9)) | 0; - hi = (hi + Math.imul(ah2, bh9)) | 0; - var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; - w11 &= 0x3ffffff; - /* k = 12 */ - lo = Math.imul(al9, bl3); - mid = Math.imul(al9, bh3); - mid = (mid + Math.imul(ah9, bl3)) | 0; - hi = Math.imul(ah9, bh3); - lo = (lo + Math.imul(al8, bl4)) | 0; - mid = (mid + Math.imul(al8, bh4)) | 0; - mid = (mid + Math.imul(ah8, bl4)) | 0; - hi = (hi + Math.imul(ah8, bh4)) | 0; - lo = (lo + Math.imul(al7, bl5)) | 0; - mid = (mid + Math.imul(al7, bh5)) | 0; - mid = (mid + Math.imul(ah7, bl5)) | 0; - hi = (hi + Math.imul(ah7, bh5)) | 0; - lo = (lo + Math.imul(al6, bl6)) | 0; - mid = (mid + Math.imul(al6, bh6)) | 0; - mid = (mid + Math.imul(ah6, bl6)) | 0; - hi = (hi + Math.imul(ah6, bh6)) | 0; - lo = (lo + Math.imul(al5, bl7)) | 0; - mid = (mid + Math.imul(al5, bh7)) | 0; - mid = (mid + Math.imul(ah5, bl7)) | 0; - hi = (hi + Math.imul(ah5, bh7)) | 0; - lo = (lo + Math.imul(al4, bl8)) | 0; - mid = (mid + Math.imul(al4, bh8)) | 0; - mid = (mid + Math.imul(ah4, bl8)) | 0; - hi = (hi + Math.imul(ah4, bh8)) | 0; - lo = (lo + Math.imul(al3, bl9)) | 0; - mid = (mid + Math.imul(al3, bh9)) | 0; - mid = (mid + Math.imul(ah3, bl9)) | 0; - hi = (hi + Math.imul(ah3, bh9)) | 0; - var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; - w12 &= 0x3ffffff; - /* k = 13 */ - lo = Math.imul(al9, bl4); - mid = Math.imul(al9, bh4); - mid = (mid + Math.imul(ah9, bl4)) | 0; - hi = Math.imul(ah9, bh4); - lo = (lo + Math.imul(al8, bl5)) | 0; - mid = (mid + Math.imul(al8, bh5)) | 0; - mid = (mid + Math.imul(ah8, bl5)) | 0; - hi = (hi + Math.imul(ah8, bh5)) | 0; - lo = (lo + Math.imul(al7, bl6)) | 0; - mid = (mid + Math.imul(al7, bh6)) | 0; - mid = (mid + Math.imul(ah7, bl6)) | 0; - hi = (hi + Math.imul(ah7, bh6)) | 0; - lo = (lo + Math.imul(al6, bl7)) | 0; - mid = (mid + Math.imul(al6, bh7)) | 0; - mid = (mid + Math.imul(ah6, bl7)) | 0; - hi = (hi + Math.imul(ah6, bh7)) | 0; - lo = (lo + Math.imul(al5, bl8)) | 0; - mid = (mid + Math.imul(al5, bh8)) | 0; - mid = (mid + Math.imul(ah5, bl8)) | 0; - hi = (hi + Math.imul(ah5, bh8)) | 0; - lo = (lo + Math.imul(al4, bl9)) | 0; - mid = (mid + Math.imul(al4, bh9)) | 0; - mid = (mid + Math.imul(ah4, bl9)) | 0; - hi = (hi + Math.imul(ah4, bh9)) | 0; - var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; - w13 &= 0x3ffffff; - /* k = 14 */ - lo = Math.imul(al9, bl5); - mid = Math.imul(al9, bh5); - mid = (mid + Math.imul(ah9, bl5)) | 0; - hi = Math.imul(ah9, bh5); - lo = (lo + Math.imul(al8, bl6)) | 0; - mid = (mid + Math.imul(al8, bh6)) | 0; - mid = (mid + Math.imul(ah8, bl6)) | 0; - hi = (hi + Math.imul(ah8, bh6)) | 0; - lo = (lo + Math.imul(al7, bl7)) | 0; - mid = (mid + Math.imul(al7, bh7)) | 0; - mid = (mid + Math.imul(ah7, bl7)) | 0; - hi = (hi + Math.imul(ah7, bh7)) | 0; - lo = (lo + Math.imul(al6, bl8)) | 0; - mid = (mid + Math.imul(al6, bh8)) | 0; - mid = (mid + Math.imul(ah6, bl8)) | 0; - hi = (hi + Math.imul(ah6, bh8)) | 0; - lo = (lo + Math.imul(al5, bl9)) | 0; - mid = (mid + Math.imul(al5, bh9)) | 0; - mid = (mid + Math.imul(ah5, bl9)) | 0; - hi = (hi + Math.imul(ah5, bh9)) | 0; - var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; - w14 &= 0x3ffffff; - /* k = 15 */ - lo = Math.imul(al9, bl6); - mid = Math.imul(al9, bh6); - mid = (mid + Math.imul(ah9, bl6)) | 0; - hi = Math.imul(ah9, bh6); - lo = (lo + Math.imul(al8, bl7)) | 0; - mid = (mid + Math.imul(al8, bh7)) | 0; - mid = (mid + Math.imul(ah8, bl7)) | 0; - hi = (hi + Math.imul(ah8, bh7)) | 0; - lo = (lo + Math.imul(al7, bl8)) | 0; - mid = (mid + Math.imul(al7, bh8)) | 0; - mid = (mid + Math.imul(ah7, bl8)) | 0; - hi = (hi + Math.imul(ah7, bh8)) | 0; - lo = (lo + Math.imul(al6, bl9)) | 0; - mid = (mid + Math.imul(al6, bh9)) | 0; - mid = (mid + Math.imul(ah6, bl9)) | 0; - hi = (hi + Math.imul(ah6, bh9)) | 0; - var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; - w15 &= 0x3ffffff; - /* k = 16 */ - lo = Math.imul(al9, bl7); - mid = Math.imul(al9, bh7); - mid = (mid + Math.imul(ah9, bl7)) | 0; - hi = Math.imul(ah9, bh7); - lo = (lo + Math.imul(al8, bl8)) | 0; - mid = (mid + Math.imul(al8, bh8)) | 0; - mid = (mid + Math.imul(ah8, bl8)) | 0; - hi = (hi + Math.imul(ah8, bh8)) | 0; - lo = (lo + Math.imul(al7, bl9)) | 0; - mid = (mid + Math.imul(al7, bh9)) | 0; - mid = (mid + Math.imul(ah7, bl9)) | 0; - hi = (hi + Math.imul(ah7, bh9)) | 0; - var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; - w16 &= 0x3ffffff; - /* k = 17 */ - lo = Math.imul(al9, bl8); - mid = Math.imul(al9, bh8); - mid = (mid + Math.imul(ah9, bl8)) | 0; - hi = Math.imul(ah9, bh8); - lo = (lo + Math.imul(al8, bl9)) | 0; - mid = (mid + Math.imul(al8, bh9)) | 0; - mid = (mid + Math.imul(ah8, bl9)) | 0; - hi = (hi + Math.imul(ah8, bh9)) | 0; - var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; - w17 &= 0x3ffffff; - /* k = 18 */ - lo = Math.imul(al9, bl9); - mid = Math.imul(al9, bh9); - mid = (mid + Math.imul(ah9, bl9)) | 0; - hi = Math.imul(ah9, bh9); - var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; - w18 &= 0x3ffffff; - o[0] = w0; - o[1] = w1; - o[2] = w2; - o[3] = w3; - o[4] = w4; - o[5] = w5; - o[6] = w6; - o[7] = w7; - o[8] = w8; - o[9] = w9; - o[10] = w10; - o[11] = w11; - o[12] = w12; - o[13] = w13; - o[14] = w14; - o[15] = w15; - o[16] = w16; - o[17] = w17; - o[18] = w18; - if (c !== 0) { - o[19] = c; - out.length++; - } - return out; - }; - - // Polyfill comb - if (!Math.imul) { - comb10MulTo = smallMulTo; - } - - function bigMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - out.length = self.length + num.length; - - var carry = 0; - var hncarry = 0; - for (var k = 0; k < out.length - 1; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = hncarry; - hncarry = 0; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = k - j; - var a = self.words[i] | 0; - var b = num.words[j] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; - lo = (lo + rword) | 0; - rword = lo & 0x3ffffff; - ncarry = (ncarry + (lo >>> 26)) | 0; - - hncarry += ncarry >>> 26; - ncarry &= 0x3ffffff; - } - out.words[k] = rword; - carry = ncarry; - ncarry = hncarry; - } - if (carry !== 0) { - out.words[k] = carry; - } else { - out.length--; - } - - return out.strip(); - } - - function jumboMulTo (self, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self, num, out); - } - - BN.prototype.mulTo = function mulTo (num, out) { - var res; - var len = this.length + num.length; - if (this.length === 10 && num.length === 10) { - res = comb10MulTo(this, num, out); - } else if (len < 63) { - res = smallMulTo(this, num, out); - } else if (len < 1024) { - res = bigMulTo(this, num, out); - } else { - res = jumboMulTo(this, num, out); - } - - return res; - }; - - // Cooley-Tukey algorithm for FFT - // slightly revisited to rely on looping instead of recursion - - function FFTM (x, y) { - this.x = x; - this.y = y; - } - - FFTM.prototype.makeRBT = function makeRBT (N) { - var t = new Array(N); - var l = BN.prototype._countBits(N) - 1; - for (var i = 0; i < N; i++) { - t[i] = this.revBin(i, l, N); - } - - return t; - }; - - // Returns binary-reversed representation of `x` - FFTM.prototype.revBin = function revBin (x, l, N) { - if (x === 0 || x === N - 1) return x; - - var rb = 0; - for (var i = 0; i < l; i++) { - rb |= (x & 1) << (l - i - 1); - x >>= 1; - } - - return rb; - }; - - // Performs "tweedling" phase, therefore 'emulating' - // behaviour of the recursive algorithm - FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) { - rtws[i] = rws[rbt[i]]; - itws[i] = iws[rbt[i]]; - } - }; - - FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - - for (var s = 1; s < N; s <<= 1) { - var l = s << 1; - - var rtwdf = Math.cos(2 * Math.PI / l); - var itwdf = Math.sin(2 * Math.PI / l); - - for (var p = 0; p < N; p += l) { - var rtwdf_ = rtwdf; - var itwdf_ = itwdf; - - for (var j = 0; j < s; j++) { - var re = rtws[p + j]; - var ie = itws[p + j]; - - var ro = rtws[p + j + s]; - var io = itws[p + j + s]; - - var rx = rtwdf_ * ro - itwdf_ * io; - - io = rtwdf_ * io + itwdf_ * ro; - ro = rx; - - rtws[p + j] = re + ro; - itws[p + j] = ie + io; - - rtws[p + j + s] = re - ro; - itws[p + j + s] = ie - io; - - /* jshint maxdepth : false */ - if (j !== l) { - rx = rtwdf * rtwdf_ - itwdf * itwdf_; - - itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; - rtwdf_ = rx; - } - } - } - } - }; - - FFTM.prototype.guessLen13b = function guessLen13b (n, m) { - var N = Math.max(m, n) | 1; - var odd = N & 1; - var i = 0; - for (N = N / 2 | 0; N; N = N >>> 1) { - i++; - } - - return 1 << i + 1 + odd; - }; - - FFTM.prototype.conjugate = function conjugate (rws, iws, N) { - if (N <= 1) return; - - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - - rws[i] = rws[N - i - 1]; - rws[N - i - 1] = t; - - t = iws[i]; - - iws[i] = -iws[N - i - 1]; - iws[N - i - 1] = -t; - } - }; - - FFTM.prototype.normalize13b = function normalize13b (ws, N) { - var carry = 0; - for (var i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + - Math.round(ws[2 * i] / N) + - carry; - - ws[i] = w & 0x3ffffff; - - if (w < 0x4000000) { - carry = 0; - } else { - carry = w / 0x4000000 | 0; - } - } - - return ws; - }; - - FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { - var carry = 0; - for (var i = 0; i < len; i++) { - carry = carry + (ws[i] | 0); - - rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; - rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; - } - - // Pad with zeroes - for (i = 2 * len; i < N; ++i) { - rws[i] = 0; - } - - assert(carry === 0); - assert((carry & ~0x1fff) === 0); - }; - - FFTM.prototype.stub = function stub (N) { - var ph = new Array(N); - for (var i = 0; i < N; i++) { - ph[i] = 0; - } - - return ph; - }; - - FFTM.prototype.mulp = function mulp (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length); - - var rbt = this.makeRBT(N); - - var _ = this.stub(N); - - var rws = new Array(N); - var rwst = new Array(N); - var iwst = new Array(N); - - var nrws = new Array(N); - var nrwst = new Array(N); - var niwst = new Array(N); - - var rmws = out.words; - rmws.length = N; - - this.convert13b(x.words, x.length, rws, N); - this.convert13b(y.words, y.length, nrws, N); - - this.transform(rws, _, rwst, iwst, N, rbt); - this.transform(nrws, _, nrwst, niwst, N, rbt); - - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; - rwst[i] = rx; - } - - this.conjugate(rwst, iwst, N); - this.transform(rwst, iwst, rmws, _, N, rbt); - this.conjugate(rmws, _, N); - this.normalize13b(rmws, N); - - out.negative = x.negative ^ y.negative; - out.length = x.length + y.length; - return out.strip(); - }; - - // Multiply `this` by `num` - BN.prototype.mul = function mul (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return this.mulTo(num, out); - }; - - // Multiply employing FFT - BN.prototype.mulf = function mulf (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return jumboMulTo(this, num, out); - }; - - // In-place Multiplication - BN.prototype.imul = function imul (num) { - return this.clone().mulTo(num, this); - }; - - BN.prototype.imuln = function imuln (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - - // Carry - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num; - var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); - carry >>= 26; - carry += (w / 0x4000000) | 0; - // NOTE: lo is 27bit maximum - carry += lo >>> 26; - this.words[i] = lo & 0x3ffffff; - } - - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - - return this; - }; - - BN.prototype.muln = function muln (num) { - return this.clone().imuln(num); - }; - - // `this` * `this` - BN.prototype.sqr = function sqr () { - return this.mul(this); - }; - - // `this` * `this` in-place - BN.prototype.isqr = function isqr () { - return this.imul(this.clone()); - }; - - // Math.pow(`this`, `num`) - BN.prototype.pow = function pow (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - - // Skip leading zeroes - var res = this; - for (var i = 0; i < w.length; i++, res = res.sqr()) { - if (w[i] !== 0) break; - } - - if (++i < w.length) { - for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { - if (w[i] === 0) continue; - - res = res.mul(q); - } - } - - return res; - }; - - // Shift-left in-place - BN.prototype.iushln = function iushln (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); - var i; - - if (r !== 0) { - var carry = 0; - - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask; - var c = ((this.words[i] | 0) - newCarry) << r; - this.words[i] = c | carry; - carry = newCarry >>> (26 - r); - } - - if (carry) { - this.words[i] = carry; - this.length++; - } - } - - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) { - this.words[i + s] = this.words[i]; - } - - for (i = 0; i < s; i++) { - this.words[i] = 0; - } - - this.length += s; - } - - return this.strip(); - }; - - BN.prototype.ishln = function ishln (bits) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushln(bits); - }; - - // Shift-right in-place - // NOTE: `hint` is a lowest bit before trailing zeroes - // NOTE: if `extended` is present - it will be filled with destroyed bits - BN.prototype.iushrn = function iushrn (bits, hint, extended) { - assert(typeof bits === 'number' && bits >= 0); - var h; - if (hint) { - h = (hint - (hint % 26)) / 26; - } else { - h = 0; - } - - var r = bits % 26; - var s = Math.min((bits - r) / 26, this.length); - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - var maskedWords = extended; - - h -= s; - h = Math.max(0, h); - - // Extended mode, copy masked part - if (maskedWords) { - for (var i = 0; i < s; i++) { - maskedWords.words[i] = this.words[i]; - } - maskedWords.length = s; - } - - if (s === 0) { - // No-op, we should not move anything at all - } else if (this.length > s) { - this.length -= s; - for (i = 0; i < this.length; i++) { - this.words[i] = this.words[i + s]; - } - } else { - this.words[0] = 0; - this.length = 1; - } - - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - this.words[i] = (carry << (26 - r)) | (word >>> r); - carry = word & mask; - } - - // Push carried bits as a mask - if (maskedWords && carry !== 0) { - maskedWords.words[maskedWords.length++] = carry; - } - - if (this.length === 0) { - this.words[0] = 0; - this.length = 1; - } - - return this.strip(); - }; - - BN.prototype.ishrn = function ishrn (bits, hint, extended) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushrn(bits, hint, extended); - }; - - // Shift-left - BN.prototype.shln = function shln (bits) { - return this.clone().ishln(bits); - }; - - BN.prototype.ushln = function ushln (bits) { - return this.clone().iushln(bits); - }; - - // Shift-right - BN.prototype.shrn = function shrn (bits) { - return this.clone().ishrn(bits); - }; - - BN.prototype.ushrn = function ushrn (bits) { - return this.clone().iushrn(bits); - }; - - // Test if n bit is set - BN.prototype.testn = function testn (bit) { - assert(typeof bit === 'number' && bit >= 0); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) return false; - - // Check bit and return - var w = this.words[s]; - - return !!(w & q); - }; - - // Return only lowers bits of number (in-place) - BN.prototype.imaskn = function imaskn (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - - assert(this.negative === 0, 'imaskn works only with positive numbers'); - - if (this.length <= s) { - return this; - } - - if (r !== 0) { - s++; - } - this.length = Math.min(s, this.length); - - if (r !== 0) { - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - this.words[this.length - 1] &= mask; - } - - return this.strip(); - }; - - // Return only lowers bits of number - BN.prototype.maskn = function maskn (bits) { - return this.clone().imaskn(bits); - }; - - // Add plain number `num` to `this` - BN.prototype.iaddn = function iaddn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.isubn(-num); - - // Possible sign change - if (this.negative !== 0) { - if (this.length === 1 && (this.words[0] | 0) < num) { - this.words[0] = num - (this.words[0] | 0); - this.negative = 0; - return this; - } - - this.negative = 0; - this.isubn(num); - this.negative = 1; - return this; - } - - // Add without checks - return this._iaddn(num); - }; - - BN.prototype._iaddn = function _iaddn (num) { - this.words[0] += num; - - // Carry - for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { - this.words[i] -= 0x4000000; - if (i === this.length - 1) { - this.words[i + 1] = 1; - } else { - this.words[i + 1]++; - } - } - this.length = Math.max(this.length, i + 1); - - return this; - }; - - // Subtract plain number `num` from `this` - BN.prototype.isubn = function isubn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.iaddn(-num); - - if (this.negative !== 0) { - this.negative = 0; - this.iaddn(num); - this.negative = 1; - return this; - } - - this.words[0] -= num; - - if (this.length === 1 && this.words[0] < 0) { - this.words[0] = -this.words[0]; - this.negative = 1; - } else { - // Carry - for (var i = 0; i < this.length && this.words[i] < 0; i++) { - this.words[i] += 0x4000000; - this.words[i + 1] -= 1; - } - } - - return this.strip(); - }; - - BN.prototype.addn = function addn (num) { - return this.clone().iaddn(num); - }; - - BN.prototype.subn = function subn (num) { - return this.clone().isubn(num); - }; - - BN.prototype.iabs = function iabs () { - this.negative = 0; - - return this; - }; - - BN.prototype.abs = function abs () { - return this.clone().iabs(); - }; - - BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { - var len = num.length + shift; - var i; - - this._expand(len); - - var w; - var carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - w -= right & 0x3ffffff; - carry = (w >> 26) - ((right / 0x4000000) | 0); - this.words[i + shift] = w & 0x3ffffff; - } - for (; i < this.length - shift; i++) { - w = (this.words[i + shift] | 0) + carry; - carry = w >> 26; - this.words[i + shift] = w & 0x3ffffff; - } - - if (carry === 0) return this.strip(); - - // Subtraction overflow - assert(carry === -1); - carry = 0; - for (i = 0; i < this.length; i++) { - w = -(this.words[i] | 0) + carry; - carry = w >> 26; - this.words[i] = w & 0x3ffffff; - } - this.negative = 1; - - return this.strip(); - }; - - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; - - var a = this.clone(); - var b = num; - - // Normalize - var bhi = b.words[b.length - 1] | 0; - var bhiBits = this._countBits(bhi); - shift = 26 - bhiBits; - if (shift !== 0) { - b = b.ushln(shift); - a.iushln(shift); - bhi = b.words[b.length - 1] | 0; - } - - // Initialize quotient - var m = a.length - b.length; - var q; - - if (mode !== 'mod') { - q = new BN(null); - q.length = m + 1; - q.words = new Array(q.length); - for (var i = 0; i < q.length; i++) { - q.words[i] = 0; - } - } - - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } - - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); - - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); - - a._ishlnsubmul(b, qj, j); - while (a.negative !== 0) { - qj--; - a.negative = 0; - a._ishlnsubmul(b, 1, j); - if (!a.isZero()) { - a.negative ^= 1; - } - } - if (q) { - q.words[j] = qj; - } - } - if (q) { - q.strip(); - } - a.strip(); - - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } - - return { - div: q || null, - mod: a - }; - }; - - // NOTE: 1) `mode` can be set to `mod` to request mod only, - // to `div` to request div only, or be absent to - // request both div & mod - // 2) `positive` is true if unsigned mod is requested - BN.prototype.divmod = function divmod (num, mode, positive) { - assert(!num.isZero()); - - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } - - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } - - return { - div: div, - mod: mod - }; - } - - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - return { - div: div, - mod: res.mod - }; - } - - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } - - return { - div: res.div, - mod: mod - }; - } - - // Both numbers are positive at this point - - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; - } - - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } - - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } - - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } - - return this._wordDiv(num, mode); - }; - - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; - - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; - - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; - - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); - - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; - - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); - - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; - - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; - - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; - - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } - - return acc; - }; - - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); - - var carry = 0; - for (var i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 0x4000000; - this.words[i] = (w / num) | 0; - carry = w % num; - } - - return this.strip(); - }; - - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; - - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var x = this; - var y = p.clone(); - - if (x.negative !== 0) { - x = x.umod(p); - } else { - x = x.clone(); - } - - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); - - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); - - var g = 0; - - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; - } - - var yp = y.clone(); - var xp = x.clone(); - - while (!x.isZero()) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - x.iushrn(i); - while (i-- > 0) { - if (A.isOdd() || B.isOdd()) { - A.iadd(yp); - B.isub(xp); - } - - A.iushrn(1); - B.iushrn(1); - } - } - - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - y.iushrn(j); - while (j-- > 0) { - if (C.isOdd() || D.isOdd()) { - C.iadd(yp); - D.isub(xp); - } - - C.iushrn(1); - D.iushrn(1); - } - } - - if (x.cmp(y) >= 0) { - x.isub(y); - A.isub(C); - B.isub(D); - } else { - y.isub(x); - C.isub(A); - D.isub(B); - } - } - - return { - a: C, - b: D, - gcd: y.iushln(g) - }; - }; - - // This is reduced incarnation of the binary EEA - // above, designated to invert members of the - // _prime_ fields F(p) at a maximal speed - BN.prototype._invmp = function _invmp (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var a = this; - var b = p.clone(); - - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } - - var x1 = new BN(1); - var x2 = new BN(0); - - var delta = b.clone(); - - while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - a.iushrn(i); - while (i-- > 0) { - if (x1.isOdd()) { - x1.iadd(delta); - } - - x1.iushrn(1); - } - } - - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - b.iushrn(j); - while (j-- > 0) { - if (x2.isOdd()) { - x2.iadd(delta); - } - - x2.iushrn(1); - } - } - - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } - - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } - - if (res.cmpn(0) < 0) { - res.iadd(p); - } - - return res; - }; - - BN.prototype.gcd = function gcd (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - - var a = this.clone(); - var b = num.clone(); - a.negative = 0; - b.negative = 0; - - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } - - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); - } - - var r = a.cmp(b); - if (r < 0) { - // Swap `a` and `b` to make `a` always bigger than `b` - var t = a; - a = b; - b = t; - } else if (r === 0 || b.cmpn(1) === 0) { - break; - } - - a.isub(b); - } while (true); - - return b.iushln(shift); - }; - - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; - - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; - }; - - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; - }; - - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; - }; - - // Increment at the bit position in-line - BN.prototype.bincn = function bincn (bit) { - assert(typeof bit === 'number'); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; - } - - // Add bit and propagate, if needed - var carry = q; - for (var i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - w += carry; - carry = w >>> 26; - w &= 0x3ffffff; - this.words[i] = w; - } - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - return this; - }; - - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; - }; - - BN.prototype.cmpn = function cmpn (num) { - var negative = num < 0; - - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - - this.strip(); - - var res; - if (this.length > 1) { - res = 1; - } else { - if (negative) { - num = -num; - } - - assert(num <= 0x3ffffff, 'Number is too big'); - - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Compare two numbers and return: - // 1 - if `this` > `num` - // 0 - if `this` == `num` - // -1 - if `this` < `num` - BN.prototype.cmp = function cmp (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Unsigned comparison - BN.prototype.ucmp = function ucmp (num) { - // At this point both numbers have the same sign - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; - - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; - } - break; - } - return res; - }; - - BN.prototype.gtn = function gtn (num) { - return this.cmpn(num) === 1; - }; - - BN.prototype.gt = function gt (num) { - return this.cmp(num) === 1; - }; - - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; - - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; - - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; - - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; - - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 0; - }; - - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; - }; - - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; - - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; - - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; - - BN.prototype.toRed = function toRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - assert(this.negative === 0, 'red works only with positives'); - return ctx.convertTo(this)._forceRed(ctx); - }; - - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; - - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; - - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; - - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; - - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; - - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; - - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); - }; - - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; - - BN.prototype.redMul = function redMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.mul(this, num); - }; - - BN.prototype.redIMul = function redIMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.imul(this, num); - }; - - BN.prototype.redSqr = function redSqr () { - assert(this.red, 'redSqr works only with red numbers'); - this.red._verify1(this); - return this.red.sqr(this); - }; - - BN.prototype.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); - }; - - // Square root over p - BN.prototype.redSqrt = function redSqrt () { - assert(this.red, 'redSqrt works only with red numbers'); - this.red._verify1(this); - return this.red.sqrt(this); - }; - - BN.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(this); - }; - - // Return negative clone of `this` % `red modulo` - BN.prototype.redNeg = function redNeg () { - assert(this.red, 'redNeg works only with red numbers'); - this.red._verify1(this); - return this.red.neg(this); - }; - - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); - }; - - // Prime numbers with efficient reduction - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null - }; - - // Pseudo-Mersenne prime - function MPrime (name, p) { - // P = 2 ^ N - K - this.name = name; - this.p = new BN(p, 16); - this.n = this.p.bitLength(); - this.k = new BN(1).iushln(this.n).isub(this.p); - - this.tmp = this._tmp(); - } - - MPrime.prototype._tmp = function _tmp () { - var tmp = new BN(null); - tmp.words = new Array(Math.ceil(this.n / 13)); - return tmp; - }; - - MPrime.prototype.ireduce = function ireduce (num) { - // Assumes that `num` is less than `P^2` - // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) - var r = num; - var rlen; - - do { - this.split(r, this.tmp); - r = this.imulK(r); - r = r.iadd(this.tmp); - rlen = r.bitLength(); - } while (rlen > this.n); - - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - if (cmp === 0) { - r.words[0] = 0; - r.length = 1; - } else if (cmp > 0) { - r.isub(this.p); - } else { - r.strip(); - } - - return r; - }; - - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); - }; - - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); - }; - - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); - - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; - - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; - } - output.length = outLen; - - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; - } - - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; - - for (i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); - prev = next; - } - prev >>>= 22; - input.words[i - 10] = prev; - if (prev === 0 && input.length > 10) { - input.length -= 10; - } else { - input.length -= 9; - } - }; - - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; - - // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 - var lo = 0; - for (var i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - lo += w * 0x3d1; - num.words[i] = lo & 0x3ffffff; - lo = w * 0x40 + ((lo / 0x4000000) | 0); - } - - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; - } - } - return num; - }; - - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); - } - inherits(P224, MPrime); - - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); - } - inherits(P192, MPrime); - - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); - } - inherits(P25519, MPrime); - - P25519.prototype.imulK = function imulK (num) { - // K = 0x13 - var carry = 0; - for (var i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 0x13 + carry; - var lo = hi & 0x3ffffff; - hi >>>= 26; - - num.words[i] = lo; - carry = hi; - } - if (carry !== 0) { - num.words[num.length++] = carry; - } - return num; - }; - - // Exported mostly for testing purposes, use plain name instead - BN._prime = function prime (name) { - // Cached version of prime - if (primes[name]) return primes[name]; - - var prime; - if (name === 'k256') { - prime = new K256(); - } else if (name === 'p224') { - prime = new P224(); - } else if (name === 'p192') { - prime = new P192(); - } else if (name === 'p25519') { - prime = new P25519(); - } else { - throw new Error('Unknown prime ' + name); - } - primes[name] = prime; - - return prime; - }; - - // - // Base reduction engine - // - function Red (m) { - if (typeof m === 'string') { - var prime = BN._prime(m); - this.m = prime.p; - this.prime = prime; - } else { - assert(m.gtn(1), 'modulus must be greater than 1'); - this.m = m; - this.prime = null; - } - } - - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); - }; - - Red.prototype._verify2 = function _verify2 (a, b) { - assert((a.negative | b.negative) === 0, 'red works only with positives'); - assert(a.red && a.red === b.red, - 'red works only with red numbers'); - }; - - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(this); - }; - - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); - } - - return this.m.sub(a)._forceRed(this); - }; - - Red.prototype.add = function add (a, b) { - this._verify2(a, b); - - var res = a.add(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.iadd = function iadd (a, b) { - this._verify2(a, b); - - var res = a.iadd(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res; - }; - - Red.prototype.sub = function sub (a, b) { - this._verify2(a, b); - - var res = a.sub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.isub = function isub (a, b) { - this._verify2(a, b); - - var res = a.isub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res; - }; - - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); - }; - - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); - }; - - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); - }; - - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); - }; - - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); - }; - - Red.prototype.sqrt = function sqrt (a) { - if (a.isZero()) return a.clone(); - - var mod3 = this.m.andln(3); - assert(mod3 % 2 === 1); - - // Fast case - if (mod3 === 3) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - - // Tonelli-Shanks algorithm (Totally unoptimized and slow) - // - // Find Q and S, that Q * 2 ^ S = (P - 1) - var q = this.m.subn(1); - var s = 0; - while (!q.isZero() && q.andln(1) === 0) { - s++; - q.iushrn(1); - } - assert(!q.isZero()); - - var one = new BN(1).toRed(this); - var nOne = one.redNeg(); - - // Find quadratic non-residue - // NOTE: Max is such because of generalized Riemann hypothesis. - var lpow = this.m.subn(1).iushrn(1); - var z = this.m.bitLength(); - z = new BN(2 * z * z).toRed(this); - - while (this.pow(z, lpow).cmp(nOne) !== 0) { - z.redIAdd(nOne); - } - - var c = this.pow(z, q); - var r = this.pow(a, q.addn(1).iushrn(1)); - var t = this.pow(a, q); - var m = s; - while (t.cmp(one) !== 0) { - var tmp = t; - for (var i = 0; tmp.cmp(one) !== 0; i++) { - tmp = tmp.redSqr(); - } - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - - r = r.redMul(b); - c = b.redSqr(); - t = t.redMul(c); - m = i; - } - - return r; - }; - - Red.prototype.invm = function invm (a) { - var inv = a._invmp(this.m); - if (inv.negative !== 0) { - inv.negative = 0; - return this.imod(inv).redNeg(); - } else { - return this.imod(inv); - } - }; - - Red.prototype.pow = function pow (a, num) { - if (num.isZero()) return new BN(1); - if (num.cmpn(1) === 0) return a.clone(); - - var windowSize = 4; - var wnd = new Array(1 << windowSize); - wnd[0] = new BN(1).toRed(this); - wnd[1] = a; - for (var i = 2; i < wnd.length; i++) { - wnd[i] = this.mul(wnd[i - 1], a); - } - - var res = wnd[0]; - var current = 0; - var currentLen = 0; - var start = num.bitLength() % 26; - if (start === 0) { - start = 26; - } - - for (i = num.length - 1; i >= 0; i--) { - var word = num.words[i]; - for (var j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if (res !== wnd[0]) { - res = this.sqr(res); - } - - if (bit === 0 && current === 0) { - currentLen = 0; - continue; - } - - current <<= 1; - current |= bit; - currentLen++; - if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - - res = this.mul(res, wnd[current]); - currentLen = 0; - current = 0; - } - start = 26; - } - - return res; - }; - - Red.prototype.convertTo = function convertTo (num) { - var r = num.umod(this.m); - - return r === num ? r.clone() : r; - }; - - Red.prototype.convertFrom = function convertFrom (num) { - var res = num.clone(); - res.red = null; - return res; - }; - - // - // Montgomery method engine - // - - BN.mont = function mont (num) { - return new Mont(num); - }; - - function Mont (m) { - Red.call(this, m); - - this.shift = this.m.bitLength(); - if (this.shift % 26 !== 0) { - this.shift += 26 - (this.shift % 26); - } - - this.r = new BN(1).iushln(this.shift); - this.r2 = this.imod(this.r.sqr()); - this.rinv = this.r._invmp(this.m); - - this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); - this.minv = this.minv.umod(this.r); - this.minv = this.r.sub(this.minv); - } - inherits(Mont, Red); - - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); - }; - - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; - return r; - }; - - Mont.prototype.imul = function imul (a, b) { - if (a.isZero() || b.isZero()) { - a.words[0] = 0; - a.length = 1; - return a; - } - - var t = a.imul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - - var t = a.mul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.invm = function invm (a) { - // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }; -})(typeof module === 'undefined' || module, this); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(121)(module))) - -/***/ }, -/* 8 */ -/***/ function(module, exports) { - // shim for using process in browser var process = module.exports = {}; @@ -6521,754 +3058,7 @@ process.umask = function() { return 0; }; /***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var elliptic = exports; - -elliptic.version = __webpack_require__(203).version; -elliptic.utils = __webpack_require__(192); -elliptic.rand = __webpack_require__(90); -elliptic.hmacDRBG = __webpack_require__(190); -elliptic.curve = __webpack_require__(40); -elliptic.curves = __webpack_require__(183); - -// Protocols -elliptic.ec = __webpack_require__(184); -elliptic.eddsa = __webpack_require__(187); - - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var formatRegExp = /%[sdj%]/g; -exports.format = function(f) { - if (!isString(f)) { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(inspect(arguments[i])); - } - return objects.join(' '); - } - - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } - default: - return x; - } - }); - for (var x = args[i]; i < len; x = args[++i]) { - if (isNull(x) || !isObject(x)) { - str += ' ' + x; - } else { - str += ' ' + inspect(x); - } - } - return str; -}; - - -// Mark that a method should not be used. -// Returns a modified function which warns once by default. -// If --no-deprecation is set, then it is a no-op. -exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (isUndefined(global.process)) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } - - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (process.throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; -}; - - -var debugs = {}; -var debugEnviron; -exports.debuglog = function(set) { - if (isUndefined(debugEnviron)) - debugEnviron = process.env.NODE_DEBUG || ''; - set = set.toUpperCase(); - if (!debugs[set]) { - if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { - var pid = process.pid; - debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); - console.error('%s %d: %s', set, pid, msg); - }; - } else { - debugs[set] = function() {}; - } - } - return debugs[set]; -}; - - -/** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Object} opts Optional options object that alters the output. - */ -/* legacy: obj, showHidden, depth, colors*/ -function inspect(obj, opts) { - // default options - var ctx = { - seen: [], - stylize: stylizeNoColor - }; - // legacy... - if (arguments.length >= 3) ctx.depth = arguments[2]; - if (arguments.length >= 4) ctx.colors = arguments[3]; - if (isBoolean(opts)) { - // legacy... - ctx.showHidden = opts; - } else if (opts) { - // got an "options" object - exports._extend(ctx, opts); - } - // set default options - if (isUndefined(ctx.showHidden)) ctx.showHidden = false; - if (isUndefined(ctx.depth)) ctx.depth = 2; - if (isUndefined(ctx.colors)) ctx.colors = false; - if (isUndefined(ctx.customInspect)) ctx.customInspect = true; - if (ctx.colors) ctx.stylize = stylizeWithColor; - return formatValue(ctx, obj, ctx.depth); -} -exports.inspect = inspect; - - -// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics -inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] -}; - -// Don't use 'blue' not visible on cmd.exe -inspect.styles = { - 'special': 'cyan', - 'number': 'yellow', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' -}; - - -function stylizeWithColor(str, styleType) { - var style = inspect.styles[styleType]; - - if (style) { - return '\u001b[' + inspect.colors[style][0] + 'm' + str + - '\u001b[' + inspect.colors[style][1] + 'm'; - } else { - return str; - } -} - - -function stylizeNoColor(str, styleType) { - return str; -} - - -function arrayToHash(array) { - var hash = {}; - - array.forEach(function(val, idx) { - hash[val] = true; - }); - - return hash; -} - - -function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (ctx.customInspect && - value && - isFunction(value.inspect) && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - var ret = value.inspect(recurseTimes, ctx); - if (!isString(ret)) { - ret = formatValue(ctx, ret, recurseTimes); - } - return ret; - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); - - if (ctx.showHidden) { - keys = Object.getOwnPropertyNames(value); - } - - // IE doesn't make error fields non-enumerable - // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx - if (isError(value) - && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { - return formatError(value); - } - - // Some type of object without properties can be shortcutted. - if (keys.length === 0) { - if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); - } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toString.call(value), 'date'); - } - if (isError(value)) { - return formatError(value); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - base = ' ' + formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); -} - - -function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); - if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); - // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); -} - - -function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; -} - - -function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); - } else { - output.push(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; -} - - -function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; - desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; - if (desc.get) { - if (desc.set) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } - } - if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(desc.value) < 0) { - if (isNull(recurseTimes)) { - str = formatValue(ctx, desc.value, null); - } else { - str = formatValue(ctx, desc.value, recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (isUndefined(name)) { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); - } - } - - return name + ': ' + str; -} - - -function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; -} - - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. -function isArray(ar) { - return Array.isArray(ar); -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; - -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; - -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; - -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; - -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; - -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; - -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; - -function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; - -function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; - -function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; - -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = __webpack_require__(234); - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - - -function pad(n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); -} - - -var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - -// 26 Feb 16:19:34 -function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], time].join(' '); -} - - -// log is just a thin wrapper to console.log that prepends a timestamp -exports.log = function() { - console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); -}; - - -/** - * Inherit the prototype methods from one constructor into another. - * - * The Function.prototype.inherits from lang.js rewritten as a standalone - * function (not on Function.prototype). NOTE: If this file is to be loaded - * during bootstrapping this function needs to be rewritten using some native - * functions as prototype setup using normal JavaScript does not work as - * expected during bootstrapping (see mirror.js in r114903). - * - * @param {function} ctor Constructor function which needs to inherit the - * prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ -exports.inherits = __webpack_require__(233); - -exports._extend = function(origin, add) { - // Don't do anything if add isn't an object - if (!add || !isObject(add)) return origin; - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin; -}; - -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18), __webpack_require__(8))) - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -module.exports = Stream; - -var EE = __webpack_require__(5).EventEmitter; -var inherits = __webpack_require__(2); - -inherits(Stream, EE); -Stream.Readable = __webpack_require__(225); -Stream.Writable = __webpack_require__(226); -Stream.Duplex = __webpack_require__(222); -Stream.Transform = __webpack_require__(118); -Stream.PassThrough = __webpack_require__(224); - -// Backwards-compat with node 0.4.x -Stream.Stream = Stream; - - - -// old-style streams. Note that the pipe method (the only relevant -// part of this class) is overridden in the Readable class. - -function Stream() { - EE.call(this); -} - -Stream.prototype.pipe = function(dest, options) { - var source = this; - - function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } - } - } - - source.on('data', ondata); - - function ondrain() { - if (source.readable && source.resume) { - source.resume(); - } - } - - dest.on('drain', ondrain); - - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend); - source.on('close', onclose); - } - - var didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; - - dest.end(); - } - - - function onclose() { - if (didOnEnd) return; - didOnEnd = true; - - if (typeof dest.destroy === 'function') dest.destroy(); - } - - // don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, 'error') === 0) { - throw er; // Unhandled stream error in pipe. - } - } - - source.on('error', onerror); - dest.on('error', onerror); - - // remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata); - dest.removeListener('drain', ondrain); - - source.removeListener('end', onend); - source.removeListener('close', onclose); - - source.removeListener('error', onerror); - dest.removeListener('error', onerror); - - source.removeListener('end', cleanup); - source.removeListener('close', cleanup); - - dest.removeListener('close', cleanup); - } - - source.on('end', cleanup); - source.on('close', cleanup); - - dest.on('close', cleanup); - - dest.emit('pipe', source); - - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; -}; - - -/***/ }, -/* 12 */ +/* 7 */ /***/ function(module, exports) { module.exports = function cloneObject(obj) { @@ -7279,18 +3069,12 @@ module.exports = function cloneObject(obj) { /***/ }, -/* 13 */ -/***/ function(module, exports) { - - - -/***/ }, -/* 14 */ +/* 8 */ /***/ function(module, exports, __webpack_require__) { -const TextBasedChannel = __webpack_require__(31); -const Constants = __webpack_require__(1); -const Presence = __webpack_require__(15).Presence; +const TextBasedChannel = __webpack_require__(19); +const Constants = __webpack_require__(0); +const Presence = __webpack_require__(9).Presence; /** * Represents a user on Discord. @@ -7531,7 +3315,7 @@ module.exports = User; /***/ }, -/* 15 */ +/* 9 */ /***/ function(module, exports) { /** @@ -7629,28 +3413,7 @@ exports.Game = Game; /***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - -var hash = exports; - -hash.utils = __webpack_require__(197); -hash.common = __webpack_require__(193); -hash.sha = __webpack_require__(196); -hash.ripemd = __webpack_require__(195); -hash.hmac = __webpack_require__(194); - -// Proxy hash functions to the main object -hash.sha1 = hash.sha.sha1; -hash.sha256 = hash.sha.sha256; -hash.sha224 = hash.sha.sha224; -hash.sha384 = hash.sha.sha384; -hash.sha512 = hash.sha.sha512; -hash.ripemd160 = hash.ripemd.ripemd160; - - -/***/ }, -/* 17 */ +/* 10 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -7674,16 +3437,16 @@ var objectKeys = Object.keys || function (obj) { module.exports = Duplex; /**/ -var processNextTick = __webpack_require__(56); +var processNextTick = __webpack_require__(32); /**/ /**/ -var util = __webpack_require__(28); -util.inherits = __webpack_require__(2); +var util = __webpack_require__(16); +util.inherits = __webpack_require__(12); /**/ -var Readable = __webpack_require__(117); -var Writable = __webpack_require__(58); +var Readable = __webpack_require__(63); +var Writable = __webpack_require__(34); util.inherits(Duplex, Readable); @@ -7731,35 +3494,10 @@ function forEach(xs, f) { } /***/ }, -/* 18 */ -/***/ function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { return this; })(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }, -/* 19 */ +/* 11 */ /***/ function(module, exports, __webpack_require__) { -const Constants = __webpack_require__(1); +const Constants = __webpack_require__(0); /** * Represents a role on Discord @@ -8101,240 +3839,352 @@ module.exports = Role; /***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { +/* 12 */ +/***/ function(module, exports) { -/* WEBPACK VAR INJECTION */(function(Buffer) {var Transform = __webpack_require__(11).Transform -var inherits = __webpack_require__(2) -var StringDecoder = __webpack_require__(59).StringDecoder -module.exports = CipherBase -inherits(CipherBase, Transform) -function CipherBase (hashMode) { - Transform.call(this) - this.hashMode = typeof hashMode === 'string' - if (this.hashMode) { - this[hashMode] = this._finalOrDigest - } else { - this.final = this._finalOrDigest +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor } - this._decoder = null - this._encoding = null -} -CipherBase.prototype.update = function (data, inputEnc, outputEnc) { - if (typeof data === 'string') { - data = new Buffer(data, inputEnc) - } - var outData = this._update(data) - if (this.hashMode) { - return this - } - if (outputEnc) { - outData = this._toString(outData, outputEnc) - } - return outData } -CipherBase.prototype.setAutoPadding = function () {} - -CipherBase.prototype.getAuthTag = function () { - throw new Error('trying to get auth tag in unsupported state') -} - -CipherBase.prototype.setAuthTag = function () { - throw new Error('trying to set auth tag in unsupported state') -} - -CipherBase.prototype.setAAD = function () { - throw new Error('trying to set aad in unsupported state') -} - -CipherBase.prototype._transform = function (data, _, next) { - var err - try { - if (this.hashMode) { - this._update(data) - } else { - this.push(this._update(data)) - } - } catch (e) { - err = e - } finally { - next(err) - } -} -CipherBase.prototype._flush = function (done) { - var err - try { - this.push(this._final()) - } catch (e) { - err = e - } finally { - done(err) - } -} -CipherBase.prototype._finalOrDigest = function (outputEnc) { - var outData = this._final() || new Buffer('') - if (outputEnc) { - outData = this._toString(outData, outputEnc, true) - } - return outData -} - -CipherBase.prototype._toString = function (value, enc, fin) { - if (!this._decoder) { - this._decoder = new StringDecoder(enc) - this._encoding = enc - } - if (this._encoding !== enc) { - throw new Error('can\'t switch encodings') - } - var out = this._decoder.write(value) - if (fin) { - out += this._decoder.end() - } - return out -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) /***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { +/* 13 */ +/***/ function(module, exports) { -"use strict"; -/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; -var inherits = __webpack_require__(2) -var md5 = __webpack_require__(102) -var rmd160 = __webpack_require__(166) -var sha = __webpack_require__(167) -var Base = __webpack_require__(20) - -function HashNoConstructor(hash) { - Base.call(this, 'digest') - - this._hash = hash - this.buffers = [] -} - -inherits(HashNoConstructor, Base) - -HashNoConstructor.prototype._update = function (data) { - this.buffers.push(data) -} - -HashNoConstructor.prototype._final = function () { - var buf = Buffer.concat(this.buffers) - var r = this._hash(buf) - this.buffers = null - - return r -} - -function Hash(hash) { - Base.call(this, 'digest') - - this._hash = hash -} - -inherits(Hash, Base) - -Hash.prototype._update = function (data) { - this._hash.update(data) -} - -Hash.prototype._final = function () { - return this._hash.digest() -} - -module.exports = function createHash (alg) { - alg = alg.toLowerCase() - if ('md5' === alg) return new HashNoConstructor(md5) - if ('rmd160' === alg || 'ripemd160' === alg) return new HashNoConstructor(rmd160) - - return new Hash(sha(alg)) -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) /***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { +/* 14 */ +/***/ function(module, exports) { -/* WEBPACK VAR INJECTION */(function(Buffer) {// prototype class for hash functions -function Hash (blockSize, finalSize) { - this._block = new Buffer(blockSize) - this._finalSize = finalSize - this._blockSize = blockSize - this._len = 0 - this._s = 0 -} +/** + * Represents any channel on Discord + */ +class Channel { + constructor(client, data) { + /** + * The client that instantiated the Channel + * @type {Client} + */ + this.client = client; + Object.defineProperty(this, 'client', { enumerable: false, configurable: false }); -Hash.prototype.update = function (data, enc) { - if (typeof data === 'string') { - enc = enc || 'utf8' - data = new Buffer(data, enc) + /** + * The type of the channel, either: + * * `dm` - a DM channel + * * `group` - a Group DM channel + * * `text` - a guild text channel + * * `voice` - a guild voice channel + * @type {string} + */ + this.type = null; + + if (data) this.setup(data); } - var l = this._len += data.length - var s = this._s || 0 - var f = 0 - var buffer = this._block - - while (s < l) { - var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize)) - var ch = (t - f) - - for (var i = 0; i < ch; i++) { - buffer[(s % this._blockSize) + i] = data[i + f] - } - - s += ch - f += ch - - if ((s % this._blockSize) === 0) { - this._update(buffer) - } - } - this._s = s - - return this -} - -Hash.prototype.digest = function (enc) { - // Suppose the length of the message M, in bits, is l - var l = this._len * 8 - - // Append the bit 1 to the end of the message - this._block[this._len % this._blockSize] = 0x80 - - // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize - this._block.fill(0, this._len % this._blockSize + 1) - - if (l % (this._blockSize * 8) >= this._finalSize * 8) { - this._update(this._block) - this._block.fill(0) + setup(data) { + /** + * The unique ID of the channel + * @type {string} + */ + this.id = data.id; } - // to this append the block which is equal to the number l written in binary - // TODO: handle case where l is > Math.pow(2, 29) - this._block.writeInt32BE(l, this._blockSize - 4) + /** + * The timestamp the channel was created at + * @type {number} + * @readonly + */ + get createdTimestamp() { + return (this.id / 4194304) + 1420070400000; + } - var hash = this._update(this._block) || this._hash() + /** + * The time the channel was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } - return enc ? hash.toString(enc) : hash + /** + * Deletes the channel + * @returns {Promise} + * @example + * // delete the channel + * channel.delete() + * .then() // success + * .catch(console.error); // log error + */ + delete() { + return this.client.rest.methods.deleteChannel(this); + } } -Hash.prototype._update = function () { - throw new Error('_update must be implemented by subclass') -} +module.exports = Channel; -module.exports = Hash - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) /***/ }, -/* 23 */ +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + +const Constants = __webpack_require__(0); +const Collection = __webpack_require__(3); + +/** + * Represents a custom emoji + */ +class Emoji { + constructor(guild, data) { + /** + * The Client that instantiated this object + * @type {Client} + */ + this.client = guild.client; + Object.defineProperty(this, 'client', { enumerable: false, configurable: false }); + + /** + * The guild this emoji is part of + * @type {Guild} + */ + this.guild = guild; + + this.setup(data); + } + + setup(data) { + /** + * The ID of the emoji + * @type {string} + */ + this.id = data.id; + + /** + * The name of the emoji + * @type {string} + */ + this.name = data.name; + + /** + * Whether or not this emoji requires colons surrounding it + * @type {boolean} + */ + this.requiresColons = data.require_colons; + + /** + * Whether this emoji is managed by an external service + * @type {boolean} + */ + this.managed = data.managed; + + this._roles = data.roles; + } + + /** + * The timestamp the emoji was created at + * @type {number} + * @readonly + */ + get createdTimestamp() { + return (this.id / 4194304) + 1420070400000; + } + + /** + * The time the emoji was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * A collection of roles this emoji is active for (empty if all), mapped by role ID. + * @type {Collection} + * @readonly + */ + get roles() { + const roles = new Collection(); + for (const role of this._roles) { + if (this.guild.roles.has(role)) roles.set(role, this.guild.roles.get(role)); + } + return roles; + } + + /** + * The URL to the emoji file + * @type {string} + * @readonly + */ + get url() { + return `${Constants.Endpoints.CDN}/emojis/${this.id}.png`; + } + + /** + * When concatenated with a string, this automatically returns the emoji mention rather than the object. + * @returns {string} + * @example + * // send an emoji: + * const emoji = guild.emojis.first(); + * msg.reply(`Hello! ${emoji}`); + */ + toString() { + return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name; + } + + /** + * The identifier of this emoji, used for message reactions + * @readonly + * @type {string} + */ + get identifier() { + if (this.id) { + return `${this.name}:${this.id}`; + } + return encodeURIComponent(this.name); + } +} + +module.exports = Emoji; + + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) + +/***/ }, +/* 17 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -8562,417 +4412,42 @@ var substr = 'ab'.substr(-1) === 'b' } ; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 24 */ +/* 18 */ /***/ function(module, exports) { -/** - * Represents any channel on Discord - */ -class Channel { - constructor(client, data) { - /** - * The client that instantiated the Channel - * @type {Client} - */ - this.client = client; - Object.defineProperty(this, 'client', { enumerable: false, configurable: false }); - - /** - * The type of the channel, either: - * * `dm` - a DM channel - * * `group` - a Group DM channel - * * `text` - a guild text channel - * * `voice` - a guild voice channel - * @type {string} - */ - this.type = null; - - if (data) this.setup(data); - } - - setup(data) { - /** - * The unique ID of the channel - * @type {string} - */ - this.id = data.id; - } - - /** - * The timestamp the channel was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return (this.id / 4194304) + 1420070400000; - } - - /** - * The time the channel was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * Deletes the channel - * @returns {Promise} - * @example - * // delete the channel - * channel.delete() - * .then() // success - * .catch(console.error); // log error - */ - delete() { - return this.client.rest.methods.deleteChannel(this); - } -} - -module.exports = Channel; +var g; + +// This works in non-strict mode +g = (function() { return this; })(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; /***/ }, -/* 25 */ +/* 19 */ /***/ function(module, exports, __webpack_require__) { -const Constants = __webpack_require__(1); -const Collection = __webpack_require__(6); - -/** - * Represents a custom emoji - */ -class Emoji { - constructor(guild, data) { - /** - * The Client that instantiated this object - * @type {Client} - */ - this.client = guild.client; - Object.defineProperty(this, 'client', { enumerable: false, configurable: false }); - - /** - * The guild this emoji is part of - * @type {Guild} - */ - this.guild = guild; - - this.setup(data); - } - - setup(data) { - /** - * The ID of the emoji - * @type {string} - */ - this.id = data.id; - - /** - * The name of the emoji - * @type {string} - */ - this.name = data.name; - - /** - * Whether or not this emoji requires colons surrounding it - * @type {boolean} - */ - this.requiresColons = data.require_colons; - - /** - * Whether this emoji is managed by an external service - * @type {boolean} - */ - this.managed = data.managed; - - this._roles = data.roles; - } - - /** - * The timestamp the emoji was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return (this.id / 4194304) + 1420070400000; - } - - /** - * The time the emoji was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * A collection of roles this emoji is active for (empty if all), mapped by role ID. - * @type {Collection} - * @readonly - */ - get roles() { - const roles = new Collection(); - for (const role of this._roles) { - if (this.guild.roles.has(role)) roles.set(role, this.guild.roles.get(role)); - } - return roles; - } - - /** - * The URL to the emoji file - * @type {string} - * @readonly - */ - get url() { - return `${Constants.Endpoints.CDN}/emojis/${this.id}.png`; - } - - /** - * When concatenated with a string, this automatically returns the emoji mention rather than the object. - * @returns {string} - * @example - * // send an emoji: - * const emoji = guild.emojis.first(); - * msg.reply(`Hello! ${emoji}`); - */ - toString() { - return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name; - } - - /** - * The identifier of this emoji, used for message reactions - * @readonly - * @type {string} - */ - get identifier() { - if (this.id) { - return `${this.name}:${this.id}`; - } - return encodeURIComponent(this.name); - } -} - -module.exports = Emoji; - - -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - -var base = exports; - -base.Reporter = __webpack_require__(143).Reporter; -base.DecoderBuffer = __webpack_require__(84).DecoderBuffer; -base.EncoderBuffer = __webpack_require__(84).EncoderBuffer; -base.Node = __webpack_require__(142); - - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {module.exports = function xor (a, b) { - var length = Math.min(a.length, b.length) - var buffer = new Buffer(length) - - for (var i = 0; i < length; ++i) { - buffer[i] = a[i] ^ b[i] - } - - return buffer -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 28 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. - -function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); - } - return objectToString(arg) === '[object Array]'; -} -exports.isArray = isArray; - -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; - -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; - -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; - -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; - -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; - -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; - -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; - -function isRegExp(re) { - return objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; - -function isDate(d) { - return objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; - -function isError(e) { - return (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; - -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = Buffer.isBuffer; - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 29 */ -/***/ function(module, exports) { - -module.exports = assert; - -function assert(val, msg) { - if (!val) - throw new Error(msg || 'Assertion failed'); -} - -assert.equal = function assertEqual(l, r, msg) { - if (l != r) - throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); -}; - - -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(global, Buffer, process) {'use strict' - -function oldBrowser () { - throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11') -} - -var crypto = global.crypto || global.msCrypto - -if (crypto && crypto.getRandomValues) { - module.exports = randomBytes -} else { - module.exports = oldBrowser -} - -function randomBytes (size, cb) { - // phantomjs needs to throw - if (size > 65536) throw new Error('requested too many random bytes') - // in case browserify isn't using the Uint8Array version - var rawBytes = new global.Uint8Array(size) - - // This will not work in older browsers. - // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues - if (size > 0) { // getRandomValues fails on IE if size == 0 - crypto.getRandomValues(rawBytes) - } - // phantomjs doesn't like a buffer being passed here - var bytes = new Buffer(rawBytes.buffer) - - if (typeof cb === 'function') { - return process.nextTick(function () { - cb(null, bytes) - }) - } - - return bytes -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18), __webpack_require__(0).Buffer, __webpack_require__(8))) - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - -const path = __webpack_require__(23); -const Message = __webpack_require__(34); -const MessageCollector = __webpack_require__(73); -const Collection = __webpack_require__(6); -const escapeMarkdown = __webpack_require__(35); +const path = __webpack_require__(17); +const Message = __webpack_require__(22); +const MessageCollector = __webpack_require__(47); +const Collection = __webpack_require__(3); +const escapeMarkdown = __webpack_require__(23); /** * Interface for classes that have text-channel-like features @@ -9320,16 +4795,16 @@ function applyProp(structure, prop) { /***/ }, -/* 32 */ +/* 20 */ /***/ function(module, exports, __webpack_require__) { -const Channel = __webpack_require__(24); -const Role = __webpack_require__(19); -const PermissionOverwrites = __webpack_require__(79); -const EvaluatedPermissions = __webpack_require__(46); -const Constants = __webpack_require__(1); -const Collection = __webpack_require__(6); -const arraysEqual = __webpack_require__(63); +const Channel = __webpack_require__(14); +const Role = __webpack_require__(11); +const PermissionOverwrites = __webpack_require__(53); +const EvaluatedPermissions = __webpack_require__(27); +const Constants = __webpack_require__(0); +const Collection = __webpack_require__(3); +const arraysEqual = __webpack_require__(37); /** * Represents a guild channel (i.e. text channels and voice channels) @@ -9618,15 +5093,15 @@ module.exports = GuildChannel; /***/ }, -/* 33 */ +/* 21 */ /***/ function(module, exports, __webpack_require__) { -const TextBasedChannel = __webpack_require__(31); -const Role = __webpack_require__(19); -const EvaluatedPermissions = __webpack_require__(46); -const Constants = __webpack_require__(1); -const Collection = __webpack_require__(6); -const Presence = __webpack_require__(15).Presence; +const TextBasedChannel = __webpack_require__(19); +const Role = __webpack_require__(11); +const EvaluatedPermissions = __webpack_require__(27); +const Constants = __webpack_require__(0); +const Collection = __webpack_require__(3); +const Presence = __webpack_require__(9).Presence; /** * Represents a member of a guild on Discord @@ -10047,15 +5522,15 @@ module.exports = GuildMember; /***/ }, -/* 34 */ +/* 22 */ /***/ function(module, exports, __webpack_require__) { -const Attachment = __webpack_require__(72); -const Embed = __webpack_require__(74); -const Collection = __webpack_require__(6); -const Constants = __webpack_require__(1); -const escapeMarkdown = __webpack_require__(35); -const MessageReaction = __webpack_require__(75); +const Attachment = __webpack_require__(46); +const Embed = __webpack_require__(48); +const Collection = __webpack_require__(3); +const Constants = __webpack_require__(0); +const escapeMarkdown = __webpack_require__(23); +const MessageReaction = __webpack_require__(49); /** * Represents a message on Discord @@ -10588,7 +6063,7 @@ module.exports = Message; /***/ }, -/* 35 */ +/* 23 */ /***/ function(module, exports) { module.exports = function escapeMarkdown(text, onlyCodeBlock = false, onlyInlineCode = false) { @@ -10599,511 +6074,7 @@ module.exports = function escapeMarkdown(text, onlyCodeBlock = false, onlyInline /***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - -var asn1 = exports; - -asn1.bignum = __webpack_require__(7); - -asn1.define = __webpack_require__(141).define; -asn1.base = __webpack_require__(26); -asn1.constants = __webpack_require__(85); -asn1.decoders = __webpack_require__(145); -asn1.encoders = __webpack_require__(147); - - -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {// based on the aes implimentation in triple sec -// https://github.com/keybase/triplesec - -// which is in turn based on the one from crypto-js -// https://code.google.com/p/crypto-js/ - -var uint_max = Math.pow(2, 32) -function fixup_uint32 (x) { - var ret, x_pos - ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x - return ret -} -function scrub_vec (v) { - for (var i = 0; i < v.length; v++) { - v[i] = 0 - } - return false -} - -function Global () { - this.SBOX = [] - this.INV_SBOX = [] - this.SUB_MIX = [[], [], [], []] - this.INV_SUB_MIX = [[], [], [], []] - this.init() - this.RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36] -} - -Global.prototype.init = function () { - var d, i, sx, t, x, x2, x4, x8, xi, _i - d = (function () { - var _i, _results - _results = [] - for (i = _i = 0; _i < 256; i = ++_i) { - if (i < 128) { - _results.push(i << 1) - } else { - _results.push((i << 1) ^ 0x11b) - } - } - return _results - })() - x = 0 - xi = 0 - for (i = _i = 0; _i < 256; i = ++_i) { - sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4) - sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63 - this.SBOX[x] = sx - this.INV_SBOX[sx] = x - x2 = d[x] - x4 = d[x2] - x8 = d[x4] - t = (d[sx] * 0x101) ^ (sx * 0x1010100) - this.SUB_MIX[0][x] = (t << 24) | (t >>> 8) - this.SUB_MIX[1][x] = (t << 16) | (t >>> 16) - this.SUB_MIX[2][x] = (t << 8) | (t >>> 24) - this.SUB_MIX[3][x] = t - t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100) - this.INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8) - this.INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16) - this.INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24) - this.INV_SUB_MIX[3][sx] = t - if (x === 0) { - x = xi = 1 - } else { - x = x2 ^ d[d[d[x8 ^ x2]]] - xi ^= d[d[xi]] - } - } - return true -} - -var G = new Global() - -AES.blockSize = 4 * 4 - -AES.prototype.blockSize = AES.blockSize - -AES.keySize = 256 / 8 - -AES.prototype.keySize = AES.keySize - -function bufferToArray (buf) { - var len = buf.length / 4 - var out = new Array(len) - var i = -1 - while (++i < len) { - out[i] = buf.readUInt32BE(i * 4) - } - return out -} -function AES (key) { - this._key = bufferToArray(key) - this._doReset() -} - -AES.prototype._doReset = function () { - var invKsRow, keySize, keyWords, ksRow, ksRows, t - keyWords = this._key - keySize = keyWords.length - this._nRounds = keySize + 6 - ksRows = (this._nRounds + 1) * 4 - this._keySchedule = [] - for (ksRow = 0; ksRow < ksRows; ksRow++) { - this._keySchedule[ksRow] = ksRow < keySize ? keyWords[ksRow] : (t = this._keySchedule[ksRow - 1], (ksRow % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(ksRow / keySize) | 0] << 24) : keySize > 6 && ksRow % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._keySchedule[ksRow - keySize] ^ t) - } - this._invKeySchedule = [] - for (invKsRow = 0; invKsRow < ksRows; invKsRow++) { - ksRow = ksRows - invKsRow - t = this._keySchedule[ksRow - (invKsRow % 4 ? 0 : 4)] - this._invKeySchedule[invKsRow] = invKsRow < 4 || ksRow <= 4 ? t : G.INV_SUB_MIX[0][G.SBOX[t >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[(t >>> 16) & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[(t >>> 8) & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[t & 0xff]] - } - return true -} - -AES.prototype.encryptBlock = function (M) { - M = bufferToArray(new Buffer(M)) - var out = this._doCryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX) - var buf = new Buffer(16) - buf.writeUInt32BE(out[0], 0) - buf.writeUInt32BE(out[1], 4) - buf.writeUInt32BE(out[2], 8) - buf.writeUInt32BE(out[3], 12) - return buf -} - -AES.prototype.decryptBlock = function (M) { - M = bufferToArray(new Buffer(M)) - var temp = [M[3], M[1]] - M[1] = temp[0] - M[3] = temp[1] - var out = this._doCryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX) - var buf = new Buffer(16) - buf.writeUInt32BE(out[0], 0) - buf.writeUInt32BE(out[3], 4) - buf.writeUInt32BE(out[2], 8) - buf.writeUInt32BE(out[1], 12) - return buf -} - -AES.prototype.scrub = function () { - scrub_vec(this._keySchedule) - scrub_vec(this._invKeySchedule) - scrub_vec(this._key) -} - -AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) { - var ksRow, s0, s1, s2, s3, t0, t1, t2, t3 - - s0 = M[0] ^ keySchedule[0] - s1 = M[1] ^ keySchedule[1] - s2 = M[2] ^ keySchedule[2] - s3 = M[3] ^ keySchedule[3] - ksRow = 4 - for (var round = 1; round < this._nRounds; round++) { - t0 = SUB_MIX[0][s0 >>> 24] ^ SUB_MIX[1][(s1 >>> 16) & 0xff] ^ SUB_MIX[2][(s2 >>> 8) & 0xff] ^ SUB_MIX[3][s3 & 0xff] ^ keySchedule[ksRow++] - t1 = SUB_MIX[0][s1 >>> 24] ^ SUB_MIX[1][(s2 >>> 16) & 0xff] ^ SUB_MIX[2][(s3 >>> 8) & 0xff] ^ SUB_MIX[3][s0 & 0xff] ^ keySchedule[ksRow++] - t2 = SUB_MIX[0][s2 >>> 24] ^ SUB_MIX[1][(s3 >>> 16) & 0xff] ^ SUB_MIX[2][(s0 >>> 8) & 0xff] ^ SUB_MIX[3][s1 & 0xff] ^ keySchedule[ksRow++] - t3 = SUB_MIX[0][s3 >>> 24] ^ SUB_MIX[1][(s0 >>> 16) & 0xff] ^ SUB_MIX[2][(s1 >>> 8) & 0xff] ^ SUB_MIX[3][s2 & 0xff] ^ keySchedule[ksRow++] - s0 = t0 - s1 = t1 - s2 = t2 - s3 = t3 - } - t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++] - t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++] - t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++] - t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++] - return [ - fixup_uint32(t0), - fixup_uint32(t1), - fixup_uint32(t2), - fixup_uint32(t3) - ] -} - -exports.AES = AES - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 38 */ -/***/ function(module, exports) { - -exports['aes-128-ecb'] = { - cipher: 'AES', - key: 128, - iv: 0, - mode: 'ECB', - type: 'block' -} -exports['aes-192-ecb'] = { - cipher: 'AES', - key: 192, - iv: 0, - mode: 'ECB', - type: 'block' -} -exports['aes-256-ecb'] = { - cipher: 'AES', - key: 256, - iv: 0, - mode: 'ECB', - type: 'block' -} -exports['aes-128-cbc'] = { - cipher: 'AES', - key: 128, - iv: 16, - mode: 'CBC', - type: 'block' -} -exports['aes-192-cbc'] = { - cipher: 'AES', - key: 192, - iv: 16, - mode: 'CBC', - type: 'block' -} -exports['aes-256-cbc'] = { - cipher: 'AES', - key: 256, - iv: 16, - mode: 'CBC', - type: 'block' -} -exports['aes128'] = exports['aes-128-cbc'] -exports['aes192'] = exports['aes-192-cbc'] -exports['aes256'] = exports['aes-256-cbc'] -exports['aes-128-cfb'] = { - cipher: 'AES', - key: 128, - iv: 16, - mode: 'CFB', - type: 'stream' -} -exports['aes-192-cfb'] = { - cipher: 'AES', - key: 192, - iv: 16, - mode: 'CFB', - type: 'stream' -} -exports['aes-256-cfb'] = { - cipher: 'AES', - key: 256, - iv: 16, - mode: 'CFB', - type: 'stream' -} -exports['aes-128-cfb8'] = { - cipher: 'AES', - key: 128, - iv: 16, - mode: 'CFB8', - type: 'stream' -} -exports['aes-192-cfb8'] = { - cipher: 'AES', - key: 192, - iv: 16, - mode: 'CFB8', - type: 'stream' -} -exports['aes-256-cfb8'] = { - cipher: 'AES', - key: 256, - iv: 16, - mode: 'CFB8', - type: 'stream' -} -exports['aes-128-cfb1'] = { - cipher: 'AES', - key: 128, - iv: 16, - mode: 'CFB1', - type: 'stream' -} -exports['aes-192-cfb1'] = { - cipher: 'AES', - key: 192, - iv: 16, - mode: 'CFB1', - type: 'stream' -} -exports['aes-256-cfb1'] = { - cipher: 'AES', - key: 256, - iv: 16, - mode: 'CFB1', - type: 'stream' -} -exports['aes-128-ofb'] = { - cipher: 'AES', - key: 128, - iv: 16, - mode: 'OFB', - type: 'stream' -} -exports['aes-192-ofb'] = { - cipher: 'AES', - key: 192, - iv: 16, - mode: 'OFB', - type: 'stream' -} -exports['aes-256-ofb'] = { - cipher: 'AES', - key: 256, - iv: 16, - mode: 'OFB', - type: 'stream' -} -exports['aes-128-ctr'] = { - cipher: 'AES', - key: 128, - iv: 16, - mode: 'CTR', - type: 'stream' -} -exports['aes-192-ctr'] = { - cipher: 'AES', - key: 192, - iv: 16, - mode: 'CTR', - type: 'stream' -} -exports['aes-256-ctr'] = { - cipher: 'AES', - key: 256, - iv: 16, - mode: 'CTR', - type: 'stream' -} -exports['aes-128-gcm'] = { - cipher: 'AES', - key: 128, - iv: 12, - mode: 'GCM', - type: 'auth' -} -exports['aes-192-gcm'] = { - cipher: 'AES', - key: 192, - iv: 12, - mode: 'GCM', - type: 'auth' -} -exports['aes-256-gcm'] = { - cipher: 'AES', - key: 256, - iv: 12, - mode: 'GCM', - type: 'auth' -} - - -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(27) - -function incr32 (iv) { - var len = iv.length - var item - while (len--) { - item = iv.readUInt8(len) - if (item === 255) { - iv.writeUInt8(0, len) - } else { - item++ - iv.writeUInt8(item, len) - break - } - } -} - -function getBlock (self) { - var out = self._cipher.encryptBlock(self._prev) - incr32(self._prev) - return out -} - -exports.encrypt = function (self, chunk) { - while (self._cache.length < chunk.length) { - self._cache = Buffer.concat([self._cache, getBlock(self)]) - } - var pad = self._cache.slice(0, chunk.length) - self._cache = self._cache.slice(chunk.length) - return xor(chunk, pad) -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var curve = exports; - -curve.base = __webpack_require__(179); -curve.short = __webpack_require__(182); -curve.mont = __webpack_require__(181); -curve.edwards = __webpack_require__(180); - - -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var md5 = __webpack_require__(102) -module.exports = EVP_BytesToKey -function EVP_BytesToKey (password, salt, keyLen, ivLen) { - if (!Buffer.isBuffer(password)) { - password = new Buffer(password, 'binary') - } - if (salt && !Buffer.isBuffer(salt)) { - salt = new Buffer(salt, 'binary') - } - keyLen = keyLen / 8 - ivLen = ivLen || 0 - var ki = 0 - var ii = 0 - var key = new Buffer(keyLen) - var iv = new Buffer(ivLen) - var addmd = 0 - var md_buf - var i - var bufs = [] - while (true) { - if (addmd++ > 0) { - bufs.push(md_buf) - } - bufs.push(password) - if (salt) { - bufs.push(salt) - } - md_buf = md5(Buffer.concat(bufs)) - bufs = [] - i = 0 - if (keyLen > 0) { - while (true) { - if (keyLen === 0) { - break - } - if (i === md_buf.length) { - break - } - key[ki++] = md_buf[i] - keyLen-- - i++ - } - } - if (ivLen > 0 && i !== md_buf.length) { - while (true) { - if (ivLen === 0) { - break - } - if (i === md_buf.length) { - break - } - iv[ii++] = md_buf[i] - ivLen-- - i++ - } - } - if (keyLen === 0 && ivLen === 0) { - break - } - } - for (i = 0; i < md_buf.length; i++) { - md_buf[i] = 0 - } - return { - key: key, - iv: iv - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 42 */ +/* 24 */ /***/ function(module, exports) { "use strict"; @@ -11212,459 +6183,140 @@ exports.setTyped(TYPED_OK); /***/ }, -/* 43 */ +/* 25 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {var asn1 = __webpack_require__(212) -var aesid = __webpack_require__(204) -var fixProc = __webpack_require__(213) -var ciphers = __webpack_require__(50) -var compat = __webpack_require__(112) -module.exports = parseKeys +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -function parseKeys (buffer) { - var password - if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { - password = buffer.passphrase - buffer = buffer.key - } - if (typeof buffer === 'string') { - buffer = new Buffer(buffer) - } +module.exports = Stream; - var stripped = fixProc(buffer, password) +var EE = __webpack_require__(4).EventEmitter; +var inherits = __webpack_require__(12); - var type = stripped.tag - var data = stripped.data - var subtype, ndata - switch (type) { - case 'PUBLIC KEY': - ndata = asn1.PublicKey.decode(data, 'der') - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') - case '1.2.840.10045.2.1': - ndata.subjectPrivateKey = ndata.subjectPublicKey - return { - type: 'ec', - data: ndata - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') - return { - type: 'dsa', - data: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) - } - throw new Error('unknown key type ' + type) - case 'ENCRYPTED PRIVATE KEY': - data = asn1.EncryptedPrivateKey.decode(data, 'der') - data = decrypt(data, password) - // falls through - case 'PRIVATE KEY': - ndata = asn1.PrivateKey.decode(data, 'der') - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') - case '1.2.840.10045.2.1': - return { - curve: ndata.algorithm.curve, - privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') - return { - type: 'dsa', - params: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) - } - throw new Error('unknown key type ' + type) - case 'RSA PUBLIC KEY': - return asn1.RSAPublicKey.decode(data, 'der') - case 'RSA PRIVATE KEY': - return asn1.RSAPrivateKey.decode(data, 'der') - case 'DSA PRIVATE KEY': - return { - type: 'dsa', - params: asn1.DSAPrivateKey.decode(data, 'der') - } - case 'EC PRIVATE KEY': - data = asn1.ECPrivateKey.decode(data, 'der') - return { - curve: data.parameters.value, - privateKey: data.privateKey - } - default: throw new Error('unknown key type ' + type) - } -} -parseKeys.signature = asn1.signature -function decrypt (data, password) { - var salt = data.algorithm.decrypt.kde.kdeparams.salt - var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) - var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] - var iv = data.algorithm.decrypt.cipher.iv - var cipherText = data.subjectPrivateKey - var keylen = parseInt(algo.split('-')[1], 10) / 8 - var key = compat.pbkdf2Sync(password, salt, iters, keylen) - var cipher = ciphers.createDecipheriv(algo, key, iv) - var out = [] - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - return Buffer.concat(out) +inherits(Stream, EE); +Stream.Readable = __webpack_require__(96); +Stream.Writable = __webpack_require__(97); +Stream.Duplex = __webpack_require__(93); +Stream.Transform = __webpack_require__(64); +Stream.PassThrough = __webpack_require__(95); + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + /***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) { -var zlib = __webpack_require__(101); - -var AVAILABLE_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]; -var DEFAULT_WINDOW_BITS = 15; -var DEFAULT_MEM_LEVEL = 8; - -PerMessageDeflate.extensionName = 'permessage-deflate'; - -/** - * Per-message Compression Extensions implementation - */ - -function PerMessageDeflate(options, isServer,maxPayload) { - if (this instanceof PerMessageDeflate === false) { - throw new TypeError("Classes can't be function-called"); - } - - this._options = options || {}; - this._isServer = !!isServer; - this._inflate = null; - this._deflate = null; - this.params = null; - this._maxPayload = maxPayload || 0; -} - -/** - * Create extension parameters offer - * - * @api public - */ - -PerMessageDeflate.prototype.offer = function() { - var params = {}; - if (this._options.serverNoContextTakeover) { - params.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - params.client_no_context_takeover = true; - } - if (this._options.serverMaxWindowBits) { - params.server_max_window_bits = this._options.serverMaxWindowBits; - } - if (this._options.clientMaxWindowBits) { - params.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits == null) { - params.client_max_window_bits = true; - } - return params; -}; - -/** - * Accept extension offer - * - * @api public - */ - -PerMessageDeflate.prototype.accept = function(paramsList) { - paramsList = this.normalizeParams(paramsList); - - var params; - if (this._isServer) { - params = this.acceptAsServer(paramsList); - } else { - params = this.acceptAsClient(paramsList); - } - - this.params = params; - return params; -}; - -/** - * Releases all resources used by the extension - * - * @api public - */ - -PerMessageDeflate.prototype.cleanup = function() { - if (this._inflate) { - if (this._inflate.writeInProgress) { - this._inflate.pendingClose = true; - } else { - if (this._inflate.close) this._inflate.close(); - this._inflate = null; - } - } - if (this._deflate) { - if (this._deflate.writeInProgress) { - this._deflate.pendingClose = true; - } else { - if (this._deflate.close) this._deflate.close(); - this._deflate = null; - } - } -}; - -/** - * Accept extension offer from client - * - * @api private - */ - -PerMessageDeflate.prototype.acceptAsServer = function(paramsList) { - var accepted = {}; - var result = paramsList.some(function(params) { - accepted = {}; - if (this._options.serverNoContextTakeover === false && params.server_no_context_takeover) { - return; - } - if (this._options.serverMaxWindowBits === false && params.server_max_window_bits) { - return; - } - if (typeof this._options.serverMaxWindowBits === 'number' && - typeof params.server_max_window_bits === 'number' && - this._options.serverMaxWindowBits > params.server_max_window_bits) { - return; - } - if (typeof this._options.clientMaxWindowBits === 'number' && !params.client_max_window_bits) { - return; - } - - if (this._options.serverNoContextTakeover || params.server_no_context_takeover) { - accepted.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - accepted.client_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover !== false && params.client_no_context_takeover) { - accepted.client_no_context_takeover = true; - } - if (typeof this._options.serverMaxWindowBits === 'number') { - accepted.server_max_window_bits = this._options.serverMaxWindowBits; - } else if (typeof params.server_max_window_bits === 'number') { - accepted.server_max_window_bits = params.server_max_window_bits; - } - if (typeof this._options.clientMaxWindowBits === 'number') { - accepted.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits !== false && typeof params.client_max_window_bits === 'number') { - accepted.client_max_window_bits = params.client_max_window_bits; - } - return true; - }, this); - - if (!result) { - throw new Error('Doesn\'t support the offered configuration'); - } - - return accepted; -}; - -/** - * Accept extension response from server - * - * @api privaye - */ - -PerMessageDeflate.prototype.acceptAsClient = function(paramsList) { - var params = paramsList[0]; - if (this._options.clientNoContextTakeover != null) { - if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) { - throw new Error('Invalid value for "client_no_context_takeover"'); - } - } - if (this._options.clientMaxWindowBits != null) { - if (this._options.clientMaxWindowBits === false && params.client_max_window_bits) { - throw new Error('Invalid value for "client_max_window_bits"'); - } - if (typeof this._options.clientMaxWindowBits === 'number' && - (!params.client_max_window_bits || params.client_max_window_bits > this._options.clientMaxWindowBits)) { - throw new Error('Invalid value for "client_max_window_bits"'); - } - } - return params; -}; - -/** - * Normalize extensions parameters - * - * @api private - */ - -PerMessageDeflate.prototype.normalizeParams = function(paramsList) { - return paramsList.map(function(params) { - Object.keys(params).forEach(function(key) { - var value = params[key]; - if (value.length > 1) { - throw new Error('Multiple extension parameters for ' + key); - } - - value = value[0]; - - switch (key) { - case 'server_no_context_takeover': - case 'client_no_context_takeover': - if (value !== true) { - throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); - } - params[key] = true; - break; - case 'server_max_window_bits': - case 'client_max_window_bits': - if (typeof value === 'string') { - value = parseInt(value, 10); - if (!~AVAILABLE_WINDOW_BITS.indexOf(value)) { - throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); - } - } - if (!this._isServer && value === true) { - throw new Error('Missing extension parameter value for ' + key); - } - params[key] = value; - break; - default: - throw new Error('Not defined extension parameter (' + key + ')'); - } - }, this); - return params; - }, this); -}; - -/** - * Decompress message - * - * @api public - */ - -PerMessageDeflate.prototype.decompress = function (data, fin, callback) { - var endpoint = this._isServer ? 'client' : 'server'; - - if (!this._inflate) { - var maxWindowBits = this.params[endpoint + '_max_window_bits']; - this._inflate = zlib.createInflateRaw({ - windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS - }); - } - this._inflate.writeInProgress = true; - - var self = this; - var buffers = []; - var cumulativeBufferLength=0; - - this._inflate.on('error', onError).on('data', onData); - this._inflate.write(data); - if (fin) { - this._inflate.write(new Buffer([0x00, 0x00, 0xff, 0xff])); - } - this._inflate.flush(function() { - cleanup(); - callback(null, Buffer.concat(buffers)); - }); - - function onError(err) { - cleanup(); - callback(err); - } - - function onData(data) { - if(self._maxPayload!==undefined && self._maxPayload!==null && self._maxPayload>0){ - cumulativeBufferLength+=data.length; - if(cumulativeBufferLength>self._maxPayload){ - buffers=[]; - cleanup(); - var err={type:1009}; - callback(err); - return; - } - } - buffers.push(data); - } - - function cleanup() { - if (!self._inflate) return; - self._inflate.removeListener('error', onError); - self._inflate.removeListener('data', onData); - self._inflate.writeInProgress = false; - if ((fin && self.params[endpoint + '_no_context_takeover']) || self._inflate.pendingClose) { - if (self._inflate.close) self._inflate.close(); - self._inflate = null; - } - } -}; - -/** - * Compress message - * - * @api public - */ - -PerMessageDeflate.prototype.compress = function (data, fin, callback) { - var endpoint = this._isServer ? 'server' : 'client'; - - if (!this._deflate) { - var maxWindowBits = this.params[endpoint + '_max_window_bits']; - this._deflate = zlib.createDeflateRaw({ - flush: zlib.Z_SYNC_FLUSH, - windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS, - memLevel: this._options.memLevel || DEFAULT_MEM_LEVEL - }); - } - this._deflate.writeInProgress = true; - - var self = this; - var buffers = []; - - this._deflate.on('error', onError).on('data', onData); - this._deflate.write(data); - this._deflate.flush(function() { - cleanup(); - var data = Buffer.concat(buffers); - if (fin) { - data = data.slice(0, data.length - 4); - } - callback(null, data); - }); - - function onError(err) { - cleanup(); - callback(err); - } - - function onData(data) { - buffers.push(data); - } - - function cleanup() { - if (!self._deflate) return; - self._deflate.removeListener('error', onError); - self._deflate.removeListener('data', onData); - self._deflate.writeInProgress = false; - if ((fin && self.params[endpoint + '_no_context_takeover']) || self._deflate.pendingClose) { - if (self._deflate.close) self._deflate.close(); - self._deflate = null; - } - } -}; - -module.exports = PerMessageDeflate; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 45 */ +/* 26 */ /***/ function(module, exports) { module.exports = function merge(def, given) { @@ -11682,10 +6334,10 @@ module.exports = function merge(def, given) { /***/ }, -/* 46 */ +/* 27 */ /***/ function(module, exports, __webpack_require__) { -const Constants = __webpack_require__(1); +const Constants = __webpack_require__(0); /** * The final evaluated permissions for a member in a channel @@ -11755,18 +6407,18 @@ module.exports = EvaluatedPermissions; /***/ }, -/* 47 */ +/* 28 */ /***/ function(module, exports, __webpack_require__) { -const User = __webpack_require__(14); -const Role = __webpack_require__(19); -const Emoji = __webpack_require__(25); -const Presence = __webpack_require__(15).Presence; -const GuildMember = __webpack_require__(33); -const Constants = __webpack_require__(1); -const Collection = __webpack_require__(6); -const cloneObject = __webpack_require__(12); -const arraysEqual = __webpack_require__(63); +const User = __webpack_require__(8); +const Role = __webpack_require__(11); +const Emoji = __webpack_require__(15); +const Presence = __webpack_require__(9).Presence; +const GuildMember = __webpack_require__(21); +const Constants = __webpack_require__(0); +const Collection = __webpack_require__(3); +const cloneObject = __webpack_require__(7); +const arraysEqual = __webpack_require__(37); /** * Represents a guild (or a server) on Discord. @@ -12576,7 +7228,7 @@ module.exports = Guild; /***/ }, -/* 48 */ +/* 29 */ /***/ function(module, exports) { /** @@ -12631,11 +7283,11 @@ module.exports = ReactionEmoji; /***/ }, -/* 49 */ +/* 30 */ /***/ function(module, exports, __webpack_require__) { -const path = __webpack_require__(23); -const escapeMarkdown = __webpack_require__(35); +const path = __webpack_require__(17); +const escapeMarkdown = __webpack_require__(23); /** * Represents a webhook @@ -12836,77 +7488,13 @@ module.exports = Webhook; /***/ }, -/* 50 */ -/***/ function(module, exports, __webpack_require__) { - -var ciphers = __webpack_require__(152) -exports.createCipher = exports.Cipher = ciphers.createCipher -exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv -var deciphers = __webpack_require__(151) -exports.createDecipher = exports.Decipher = deciphers.createDecipher -exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv -var modes = __webpack_require__(38) -function getCiphers () { - return Object.keys(modes) -} -exports.listCiphers = exports.getCiphers = getCiphers - - -/***/ }, -/* 51 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(7); -var randomBytes = __webpack_require__(30); -module.exports = crt; -function blind(priv) { - var r = getr(priv); - var blinder = r.toRed(bn.mont(priv.modulus)) - .redPow(new bn(priv.publicExponent)).fromRed(); - return { - blinder: blinder, - unblinder:r.invm(priv.modulus) - }; -} -function crt(msg, priv) { - var blinds = blind(priv); - var len = priv.modulus.byteLength(); - var mod = bn.mont(priv.modulus); - var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus); - var c1 = blinded.toRed(bn.mont(priv.prime1)); - var c2 = blinded.toRed(bn.mont(priv.prime2)); - var qinv = priv.coefficient; - var p = priv.prime1; - var q = priv.prime2; - var m1 = c1.redPow(priv.exponent1); - var m2 = c2.redPow(priv.exponent2); - m1 = m1.fromRed(); - m2 = m2.fromRed(); - var h = m1.isub(m2).imul(qinv).umod(p); - h.imul(q); - m2.iadd(h); - return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len)); -} -crt.getr = getr; -function getr(priv) { - var len = priv.modulus.byteLength(); - var r = new bn(randomBytes(len)); - while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) { - r = new bn(randomBytes(len)); - } - return r; -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 52 */ +/* 31 */ /***/ function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) {'use strict'; -var buffer = __webpack_require__(0); +var buffer = __webpack_require__(5); var Buffer = buffer.Buffer; var SlowBuffer = buffer.SlowBuffer; var MAX_LEN = buffer.kMaxLength || 2147483647; @@ -13016,247 +7604,7 @@ exports.allocUnsafeSlow = function allocUnsafeSlow(size) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18))) /***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; -var createHash = __webpack_require__(21); -var inherits = __webpack_require__(2) - -var Transform = __webpack_require__(11).Transform - -var ZEROS = new Buffer(128) -ZEROS.fill(0) - -function Hmac(alg, key) { - Transform.call(this) - alg = alg.toLowerCase() - if (typeof key === 'string') { - key = new Buffer(key) - } - - var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64 - - this._alg = alg - this._key = key - - if (key.length > blocksize) { - key = createHash(alg).update(key).digest() - - } else if (key.length < blocksize) { - key = Buffer.concat([key, ZEROS], blocksize) - } - - var ipad = this._ipad = new Buffer(blocksize) - var opad = this._opad = new Buffer(blocksize) - - for (var i = 0; i < blocksize; i++) { - ipad[i] = key[i] ^ 0x36 - opad[i] = key[i] ^ 0x5C - } - - this._hash = createHash(alg).update(ipad) -} - -inherits(Hmac, Transform) - -Hmac.prototype.update = function (data, enc) { - this._hash.update(data, enc) - - return this -} - -Hmac.prototype._transform = function (data, _, next) { - this._hash.update(data) - - next() -} - -Hmac.prototype._flush = function (next) { - this.push(this.digest()) - - next() -} - -Hmac.prototype.digest = function (enc) { - var h = this._hash.digest() - - return createHash(this._alg).update(this._opad).update(h).digest(enc) -} - -module.exports = function createHmac(alg, key) { - return new Hmac(alg, key) -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -exports.utils = __webpack_require__(176); -exports.Cipher = __webpack_require__(173); -exports.DES = __webpack_require__(174); -exports.CBC = __webpack_require__(172); -exports.EDE = __webpack_require__(175); - - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - -var http = module.exports; -var EventEmitter = __webpack_require__(5).EventEmitter; -var Request = __webpack_require__(198); -var url = __webpack_require__(62) - -http.request = function (params, cb) { - if (typeof params === 'string') { - params = url.parse(params) - } - if (!params) params = {}; - if (!params.host && !params.port) { - params.port = parseInt(window.location.port, 10); - } - if (!params.host && params.hostname) { - params.host = params.hostname; - } - - if (!params.protocol) { - if (params.scheme) { - params.protocol = params.scheme + ':'; - } else { - params.protocol = window.location.protocol; - } - } - - if (!params.host) { - params.host = window.location.hostname || window.location.host; - } - if (/:/.test(params.host)) { - if (!params.port) { - params.port = params.host.split(':')[1]; - } - params.host = params.host.split(':')[0]; - } - if (!params.port) params.port = params.protocol == 'https:' ? 443 : 80; - - var req = new Request(new xhrHttp, params); - if (cb) req.on('response', cb); - return req; -}; - -http.get = function (params, cb) { - params.method = 'GET'; - var req = http.request(params, cb); - req.end(); - return req; -}; - -http.Agent = function () {}; -http.Agent.defaultMaxSockets = 4; - -var xhrHttp = (function () { - if (typeof window === 'undefined') { - throw new Error('no window object present'); - } - else if (window.XMLHttpRequest) { - return window.XMLHttpRequest; - } - else if (window.ActiveXObject) { - var axs = [ - 'Msxml2.XMLHTTP.6.0', - 'Msxml2.XMLHTTP.3.0', - 'Microsoft.XMLHTTP' - ]; - for (var i = 0; i < axs.length; i++) { - try { - var ax = new(window.ActiveXObject)(axs[i]); - return function () { - if (ax) { - var ax_ = ax; - ax = null; - return ax_; - } - else { - return new(window.ActiveXObject)(axs[i]); - } - }; - } - catch (e) {} - } - throw new Error('ajax not supported in this browser') - } - else { - throw new Error('ajax not supported in this browser'); - } -})(); - -http.STATUS_CODES = { - 100 : 'Continue', - 101 : 'Switching Protocols', - 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918 - 200 : 'OK', - 201 : 'Created', - 202 : 'Accepted', - 203 : 'Non-Authoritative Information', - 204 : 'No Content', - 205 : 'Reset Content', - 206 : 'Partial Content', - 207 : 'Multi-Status', // RFC 4918 - 300 : 'Multiple Choices', - 301 : 'Moved Permanently', - 302 : 'Moved Temporarily', - 303 : 'See Other', - 304 : 'Not Modified', - 305 : 'Use Proxy', - 307 : 'Temporary 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 Time-out', - 409 : 'Conflict', - 410 : 'Gone', - 411 : 'Length Required', - 412 : 'Precondition Failed', - 413 : 'Request Entity Too Large', - 414 : 'Request-URI Too Large', - 415 : 'Unsupported Media Type', - 416 : 'Requested Range Not Satisfiable', - 417 : 'Expectation Failed', - 418 : 'I\'m a teapot', // RFC 2324 - 422 : 'Unprocessable Entity', // RFC 4918 - 423 : 'Locked', // RFC 4918 - 424 : 'Failed Dependency', // RFC 4918 - 425 : 'Unordered Collection', // RFC 4918 - 426 : 'Upgrade Required', // RFC 2817 - 428 : 'Precondition Required', // RFC 6585 - 429 : 'Too Many Requests', // RFC 6585 - 431 : 'Request Header Fields Too Large',// RFC 6585 - 500 : 'Internal Server Error', - 501 : 'Not Implemented', - 502 : 'Bad Gateway', - 503 : 'Service Unavailable', - 504 : 'Gateway Time-out', - 505 : 'HTTP Version Not Supported', - 506 : 'Variant Also Negotiates', // RFC 2295 - 507 : 'Insufficient Storage', // RFC 4918 - 509 : 'Bandwidth Limit Exceeded', - 510 : 'Not Extended', // RFC 2774 - 511 : 'Network Authentication Required' // RFC 6585 -}; - -/***/ }, -/* 56 */ +/* 32 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -13304,10 +7652,10 @@ function nextTick(fn, arg1, arg2, arg3) { } } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 57 */ +/* 33 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -13357,11 +7705,11 @@ function nextTick(fn, arg1, arg2, arg3) { module.exports = Transform; -var Duplex = __webpack_require__(17); +var Duplex = __webpack_require__(10); /**/ -var util = __webpack_require__(28); -util.inherits = __webpack_require__(2); +var util = __webpack_require__(16); +util.inherits = __webpack_require__(12); /**/ util.inherits(Transform, Duplex); @@ -13493,7 +7841,7 @@ function done(stream, er) { } /***/ }, -/* 58 */ +/* 34 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -13506,7 +7854,7 @@ function done(stream, er) { module.exports = Writable; /**/ -var processNextTick = __webpack_require__(56); +var processNextTick = __webpack_require__(32); /**/ /**/ @@ -13516,13 +7864,13 @@ var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version. Writable.WritableState = WritableState; /**/ -var util = __webpack_require__(28); -util.inherits = __webpack_require__(2); +var util = __webpack_require__(16); +util.inherits = __webpack_require__(12); /**/ /**/ var internalUtil = { - deprecate: __webpack_require__(232) + deprecate: __webpack_require__(100) }; /**/ @@ -13530,16 +7878,16 @@ var internalUtil = { var Stream; (function () { try { - Stream = __webpack_require__(11); + Stream = __webpack_require__(25); } catch (_) {} finally { - if (!Stream) Stream = __webpack_require__(5).EventEmitter; + if (!Stream) Stream = __webpack_require__(4).EventEmitter; } })(); /**/ -var Buffer = __webpack_require__(0).Buffer; +var Buffer = __webpack_require__(5).Buffer; /**/ -var bufferShim = __webpack_require__(52); +var bufferShim = __webpack_require__(31); /**/ util.inherits(Writable, Stream); @@ -13555,7 +7903,7 @@ function WriteReq(chunk, encoding, cb) { var Duplex; function WritableState(options, stream) { - Duplex = Duplex || __webpack_require__(17); + Duplex = Duplex || __webpack_require__(10); options = options || {}; @@ -13671,7 +8019,7 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() { var Duplex; function Writable(options) { - Duplex = Duplex || __webpack_require__(17); + Duplex = Duplex || __webpack_require__(10); // Writable ctor is applied to Duplexes, though they're not // instanceof Writable, they're instanceof Readable. @@ -14023,237 +8371,10 @@ function CorkedRequest(state) { } }; } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(61).setImmediate)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6), __webpack_require__(36).setImmediate)) /***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { - -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var Buffer = __webpack_require__(0).Buffer; - -var isBufferEncoding = Buffer.isEncoding - || function(encoding) { - switch (encoding && encoding.toLowerCase()) { - case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; - default: return false; - } - } - - -function assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. CESU-8 is handled as part of the UTF-8 encoding. -// -// @TODO Handling all encodings inside a single object makes it very difficult -// to reason about this code, so it should be split up in the future. -// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code -// points as used by CESU-8. -var StringDecoder = exports.StringDecoder = function(encoding) { - this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); - assertEncoding(encoding); - switch (this.encoding) { - case 'utf8': - // CESU-8 represents each of Surrogate Pair by 3-bytes - this.surrogateSize = 3; - break; - case 'ucs2': - case 'utf16le': - // UTF-16 represents each of Surrogate Pair by 2-bytes - this.surrogateSize = 2; - this.detectIncompleteChar = utf16DetectIncompleteChar; - break; - case 'base64': - // Base-64 stores 3 bytes in 4 chars, and pads the remainder. - this.surrogateSize = 3; - this.detectIncompleteChar = base64DetectIncompleteChar; - break; - default: - this.write = passThroughWrite; - return; - } - - // Enough space to store all bytes of a single character. UTF-8 needs 4 - // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); - // Number of bytes received for the current incomplete multi-byte character. - this.charReceived = 0; - // Number of bytes expected for the current incomplete multi-byte character. - this.charLength = 0; -}; - - -// write decodes the given buffer and returns it as JS string that is -// guaranteed to not contain any partial multi-byte characters. Any partial -// character found at the end of the buffer is buffered up, and will be -// returned when calling write again with the remaining bytes. -// -// Note: Converting a Buffer containing an orphan surrogate to a String -// currently works, but converting a String to a Buffer (via `new Buffer`, or -// Buffer#write) will replace incomplete surrogates with the unicode -// replacement character. See https://codereview.chromium.org/121173009/ . -StringDecoder.prototype.write = function(buffer) { - var charStr = ''; - // if our last write ended with an incomplete multibyte character - while (this.charLength) { - // determine how many remaining bytes this buffer has to offer for this char - var available = (buffer.length >= this.charLength - this.charReceived) ? - this.charLength - this.charReceived : - buffer.length; - - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; - - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } - - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); - - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); - - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - var charCode = charStr.charCodeAt(charStr.length - 1); - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - this.charLength += this.surrogateSize; - charStr = ''; - continue; - } - this.charReceived = this.charLength = 0; - - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } - - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); - - var end = buffer.length; - if (this.charLength) { - // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); - end -= this.charReceived; - } - - charStr += buffer.toString(this.encoding, 0, end); - - var end = charStr.length - 1; - var charCode = charStr.charCodeAt(end); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - var size = this.surrogateSize; - this.charLength += size; - this.charReceived += size; - this.charBuffer.copy(this.charBuffer, size, 0, size); - buffer.copy(this.charBuffer, 0, 0, size); - return charStr.substring(0, end); - } - - // or just emit the charStr - return charStr; -}; - -// detectIncompleteChar determines if there is an incomplete UTF-8 character at -// the end of the given buffer. If so, it sets this.charLength to the byte -// length that character, and sets this.charReceived to the number of bytes -// that are available for this character. -StringDecoder.prototype.detectIncompleteChar = function(buffer) { - // determine how many bytes we have to check at the end of this buffer - var i = (buffer.length >= 3) ? 3 : buffer.length; - - // Figure out if one of the last i bytes of our buffer announces an - // incomplete char. - for (; i > 0; i--) { - var c = buffer[buffer.length - i]; - - // See http://en.wikipedia.org/wiki/UTF-8#Description - - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; - } - - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } - - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } - } - this.charReceived = i; -}; - -StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); - - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); - } - - return res; -}; - -function passThroughWrite(buffer) { - return buffer.toString(this.encoding); -} - -function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; -} - -function base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; -} - - -/***/ }, -/* 60 */ +/* 35 */ /***/ function(module, exports, __webpack_require__) { /** @@ -14270,9 +8391,9 @@ if (typeof window !== 'undefined') { // Browser window root = this; } -var Emitter = __webpack_require__(163); -var RequestBase = __webpack_require__(227); -var isObject = __webpack_require__(119); +var Emitter = __webpack_require__(84); +var RequestBase = __webpack_require__(98); +var isObject = __webpack_require__(66); /** * Noop. @@ -14284,7 +8405,7 @@ function noop(){}; * Expose `request`. */ -var request = module.exports = __webpack_require__(228).bind(null, Request); +var request = module.exports = __webpack_require__(99).bind(null, Request); /** * Determine XHR. @@ -15273,10 +9394,10 @@ request.put = function(url, data, fn){ /***/ }, -/* 61 */ +/* 36 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(8).nextTick; +/* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(6).nextTick; var apply = Function.prototype.apply; var slice = Array.prototype.slice; var immediateIds = {}; @@ -15352,749 +9473,10 @@ exports.setImmediate = typeof setImmediate === "function" ? setImmediate : funct exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { delete immediateIds[id]; }; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(61).setImmediate, __webpack_require__(61).clearImmediate)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(36).setImmediate, __webpack_require__(36).clearImmediate)) /***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var punycode = __webpack_require__(218); -var util = __webpack_require__(239); - -exports.parse = urlParse; -exports.resolve = urlResolve; -exports.resolveObject = urlResolveObject; -exports.format = urlFormat; - -exports.Url = Url; - -function Url() { - this.protocol = null; - this.slashes = null; - this.auth = null; - this.host = null; - this.port = null; - this.hostname = null; - this.hash = null; - this.search = null; - this.query = null; - this.pathname = null; - this.path = null; - this.href = null; -} - -// Reference: RFC 3986, RFC 1808, RFC 2396 - -// define these here so at least they only have to be -// compiled once on the first module load. -var protocolPattern = /^([a-z0-9.+-]+:)/i, - portPattern = /:[0-9]*$/, - - // Special case for a simple path URL - simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - - // RFC 2396: characters reserved for delimiting URLs. - // We actually just auto-escape these. - delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], - - // RFC 2396: characters not allowed for various reasons. - unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), - - // Allowed by RFCs, but cause of XSS attacks. Always escape these. - autoEscape = ['\''].concat(unwise), - // Characters that are never ever allowed in a hostname. - // Note that any invalid chars are also handled, but these - // are the ones that are *expected* to be seen, so we fast-path - // them. - nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), - hostEndingChars = ['/', '?', '#'], - hostnameMaxLen = 255, - hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, - hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, - // protocols that can allow "unsafe" and "unwise" chars. - unsafeProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that never have a hostname. - hostlessProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that always contain a // bit. - slashedProtocol = { - 'http': true, - 'https': true, - 'ftp': true, - 'gopher': true, - 'file': true, - 'http:': true, - 'https:': true, - 'ftp:': true, - 'gopher:': true, - 'file:': true - }, - querystring = __webpack_require__(221); - -function urlParse(url, parseQueryString, slashesDenoteHost) { - if (url && util.isObject(url) && url instanceof Url) return url; - - var u = new Url; - u.parse(url, parseQueryString, slashesDenoteHost); - return u; -} - -Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { - if (!util.isString(url)) { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); - } - - // Copy chrome, IE, opera backslash-handling behavior. - // Back slashes before the query string get converted to forward slashes - // See: https://code.google.com/p/chromium/issues/detail?id=25916 - var queryIndex = url.indexOf('?'), - splitter = - (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', - uSplit = url.split(splitter), - slashRegex = /\\/g; - uSplit[0] = uSplit[0].replace(slashRegex, '/'); - url = uSplit.join(splitter); - - var rest = url; - - // trim before proceeding. - // This is to support parse stuff like " http://foo.com \n" - rest = rest.trim(); - - if (!slashesDenoteHost && url.split('#').length === 1) { - // Try fast path regexp - var simplePath = simplePathPattern.exec(rest); - if (simplePath) { - this.path = rest; - this.href = rest; - this.pathname = simplePath[1]; - if (simplePath[2]) { - this.search = simplePath[2]; - if (parseQueryString) { - this.query = querystring.parse(this.search.substr(1)); - } else { - this.query = this.search.substr(1); - } - } else if (parseQueryString) { - this.search = ''; - this.query = {}; - } - return this; - } - } - - var proto = protocolPattern.exec(rest); - if (proto) { - proto = proto[0]; - var lowerProto = proto.toLowerCase(); - this.protocol = lowerProto; - rest = rest.substr(proto.length); - } - - // figure out if it's got a host - // user@server is *always* interpreted as a hostname, and url - // resolution will treat //foo/bar as host=foo,path=bar because that's - // how the browser resolves relative URLs. - if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var slashes = rest.substr(0, 2) === '//'; - if (slashes && !(proto && hostlessProtocol[proto])) { - rest = rest.substr(2); - this.slashes = true; - } - } - - if (!hostlessProtocol[proto] && - (slashes || (proto && !slashedProtocol[proto]))) { - - // there's a hostname. - // the first instance of /, ?, ;, or # ends the host. - // - // If there is an @ in the hostname, then non-host chars *are* allowed - // to the left of the last @ sign, unless some host-ending character - // comes *before* the @-sign. - // URLs are obnoxious. - // - // ex: - // http://a@b@c/ => user:a@b host:c - // http://a@b?@c => user:a host:c path:/?@c - - // v0.12 TODO(isaacs): This is not quite how Chrome does things. - // Review our test case against browsers more comprehensively. - - // find the first instance of any hostEndingChars - var hostEnd = -1; - for (var i = 0; i < hostEndingChars.length; i++) { - var hec = rest.indexOf(hostEndingChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - - // at this point, either we have an explicit point where the - // auth portion cannot go past, or the last @ char is the decider. - var auth, atSign; - if (hostEnd === -1) { - // atSign can be anywhere. - atSign = rest.lastIndexOf('@'); - } else { - // atSign must be in auth portion. - // http://a@b/c@d => host:b auth:a path:/c@d - atSign = rest.lastIndexOf('@', hostEnd); - } - - // Now we have a portion which is definitely the auth. - // Pull that off. - if (atSign !== -1) { - auth = rest.slice(0, atSign); - rest = rest.slice(atSign + 1); - this.auth = decodeURIComponent(auth); - } - - // the host is the remaining to the left of the first non-host char - hostEnd = -1; - for (var i = 0; i < nonHostChars.length; i++) { - var hec = rest.indexOf(nonHostChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - // if we still have not hit it, then the entire thing is a host. - if (hostEnd === -1) - hostEnd = rest.length; - - this.host = rest.slice(0, hostEnd); - rest = rest.slice(hostEnd); - - // pull out port. - this.parseHost(); - - // we've indicated that there is a hostname, - // so even if it's empty, it has to be present. - this.hostname = this.hostname || ''; - - // if hostname begins with [ and ends with ] - // assume that it's an IPv6 address. - var ipv6Hostname = this.hostname[0] === '[' && - this.hostname[this.hostname.length - 1] === ']'; - - // validate a little. - if (!ipv6Hostname) { - var hostparts = this.hostname.split(/\./); - for (var i = 0, l = hostparts.length; i < l; i++) { - var part = hostparts[i]; - if (!part) continue; - if (!part.match(hostnamePartPattern)) { - var newpart = ''; - for (var j = 0, k = part.length; j < k; j++) { - if (part.charCodeAt(j) > 127) { - // we replace non-ASCII char with a temporary placeholder - // we need this to make sure size of hostname is not - // broken by replacing non-ASCII by nothing - newpart += 'x'; - } else { - newpart += part[j]; - } - } - // we test again with ASCII char only - if (!newpart.match(hostnamePartPattern)) { - var validParts = hostparts.slice(0, i); - var notHost = hostparts.slice(i + 1); - var bit = part.match(hostnamePartStart); - if (bit) { - validParts.push(bit[1]); - notHost.unshift(bit[2]); - } - if (notHost.length) { - rest = '/' + notHost.join('.') + rest; - } - this.hostname = validParts.join('.'); - break; - } - } - } - } - - if (this.hostname.length > hostnameMaxLen) { - this.hostname = ''; - } else { - // hostnames are always lower case. - this.hostname = this.hostname.toLowerCase(); - } - - if (!ipv6Hostname) { - // IDNA Support: Returns a punycoded representation of "domain". - // It only converts parts of the domain name that - // have non-ASCII characters, i.e. it doesn't matter if - // you call it with a domain that already is ASCII-only. - this.hostname = punycode.toASCII(this.hostname); - } - - var p = this.port ? ':' + this.port : ''; - var h = this.hostname || ''; - this.host = h + p; - this.href += this.host; - - // strip [ and ] from the hostname - // the host field still retains them, though - if (ipv6Hostname) { - this.hostname = this.hostname.substr(1, this.hostname.length - 2); - if (rest[0] !== '/') { - rest = '/' + rest; - } - } - } - - // now rest is set to the post-host stuff. - // chop off any delim chars. - if (!unsafeProtocol[lowerProto]) { - - // First, make 100% sure that any "autoEscape" chars get - // escaped, even if encodeURIComponent doesn't think they - // need to be. - for (var i = 0, l = autoEscape.length; i < l; i++) { - var ae = autoEscape[i]; - if (rest.indexOf(ae) === -1) - continue; - var esc = encodeURIComponent(ae); - if (esc === ae) { - esc = escape(ae); - } - rest = rest.split(ae).join(esc); - } - } - - - // chop off from the tail first. - var hash = rest.indexOf('#'); - if (hash !== -1) { - // got a fragment string. - this.hash = rest.substr(hash); - rest = rest.slice(0, hash); - } - var qm = rest.indexOf('?'); - if (qm !== -1) { - this.search = rest.substr(qm); - this.query = rest.substr(qm + 1); - if (parseQueryString) { - this.query = querystring.parse(this.query); - } - rest = rest.slice(0, qm); - } else if (parseQueryString) { - // no query string, but parseQueryString still requested - this.search = ''; - this.query = {}; - } - if (rest) this.pathname = rest; - if (slashedProtocol[lowerProto] && - this.hostname && !this.pathname) { - this.pathname = '/'; - } - - //to support http.request - if (this.pathname || this.search) { - var p = this.pathname || ''; - var s = this.search || ''; - this.path = p + s; - } - - // finally, reconstruct the href based on what has been validated. - this.href = this.format(); - return this; -}; - -// format a parsed object into a url string -function urlFormat(obj) { - // ensure it's an object, and not a string url. - // If it's an obj, this is a no-op. - // this way, you can call url_format() on strings - // to clean up potentially wonky urls. - if (util.isString(obj)) obj = urlParse(obj); - if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - return obj.format(); -} - -Url.prototype.format = function() { - var auth = this.auth || ''; - if (auth) { - auth = encodeURIComponent(auth); - auth = auth.replace(/%3A/i, ':'); - auth += '@'; - } - - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; - - if (this.host) { - host = auth + this.host; - } else if (this.hostname) { - host = auth + (this.hostname.indexOf(':') === -1 ? - this.hostname : - '[' + this.hostname + ']'); - if (this.port) { - host += ':' + this.port; - } - } - - if (this.query && - util.isObject(this.query) && - Object.keys(this.query).length) { - query = querystring.stringify(this.query); - } - - var search = this.search || (query && ('?' + query)) || ''; - - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; - - // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. - // unless they had them to begin with. - if (this.slashes || - (!protocol || slashedProtocol[protocol]) && host !== false) { - host = '//' + (host || ''); - if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; - } else if (!host) { - host = ''; - } - - if (hash && hash.charAt(0) !== '#') hash = '#' + hash; - if (search && search.charAt(0) !== '?') search = '?' + search; - - pathname = pathname.replace(/[?#]/g, function(match) { - return encodeURIComponent(match); - }); - search = search.replace('#', '%23'); - - return protocol + host + pathname + search + hash; -}; - -function urlResolve(source, relative) { - return urlParse(source, false, true).resolve(relative); -} - -Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, false, true)).format(); -}; - -function urlResolveObject(source, relative) { - if (!source) return relative; - return urlParse(source, false, true).resolveObject(relative); -} - -Url.prototype.resolveObject = function(relative) { - if (util.isString(relative)) { - var rel = new Url(); - rel.parse(relative, false, true); - relative = rel; - } - - var result = new Url(); - var tkeys = Object.keys(this); - for (var tk = 0; tk < tkeys.length; tk++) { - var tkey = tkeys[tk]; - result[tkey] = this[tkey]; - } - - // hash is always overridden, no matter what. - // even href="" will remove it. - result.hash = relative.hash; - - // if the relative url is empty, then there's nothing left to do here. - if (relative.href === '') { - result.href = result.format(); - return result; - } - - // hrefs like //foo/bar always cut to the protocol. - if (relative.slashes && !relative.protocol) { - // take everything except the protocol from relative - var rkeys = Object.keys(relative); - for (var rk = 0; rk < rkeys.length; rk++) { - var rkey = rkeys[rk]; - if (rkey !== 'protocol') - result[rkey] = relative[rkey]; - } - - //urlParse appends trailing / to urls like http://www.example.com - if (slashedProtocol[result.protocol] && - result.hostname && !result.pathname) { - result.path = result.pathname = '/'; - } - - result.href = result.format(); - return result; - } - - if (relative.protocol && relative.protocol !== result.protocol) { - // if it's a known url protocol, then changing - // the protocol does weird things - // first, if it's not file:, then we MUST have a host, - // and if there was a path - // to begin with, then we MUST have a path. - // if it is file:, then the host is dropped, - // because that's known to be hostless. - // anything else is assumed to be absolute. - if (!slashedProtocol[relative.protocol]) { - var keys = Object.keys(relative); - for (var v = 0; v < keys.length; v++) { - var k = keys[v]; - result[k] = relative[k]; - } - result.href = result.format(); - return result; - } - - result.protocol = relative.protocol; - if (!relative.host && !hostlessProtocol[relative.protocol]) { - var relPath = (relative.pathname || '').split('/'); - while (relPath.length && !(relative.host = relPath.shift())); - if (!relative.host) relative.host = ''; - if (!relative.hostname) relative.hostname = ''; - if (relPath[0] !== '') relPath.unshift(''); - if (relPath.length < 2) relPath.unshift(''); - result.pathname = relPath.join('/'); - } else { - result.pathname = relative.pathname; - } - result.search = relative.search; - result.query = relative.query; - result.host = relative.host || ''; - result.auth = relative.auth; - result.hostname = relative.hostname || relative.host; - result.port = relative.port; - // to support http.request - if (result.pathname || result.search) { - var p = result.pathname || ''; - var s = result.search || ''; - result.path = p + s; - } - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; - } - - var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), - isRelAbs = ( - relative.host || - relative.pathname && relative.pathname.charAt(0) === '/' - ), - mustEndAbs = (isRelAbs || isSourceAbs || - (result.host && relative.pathname)), - removeAllDots = mustEndAbs, - srcPath = result.pathname && result.pathname.split('/') || [], - relPath = relative.pathname && relative.pathname.split('/') || [], - psychotic = result.protocol && !slashedProtocol[result.protocol]; - - // if the url is a non-slashed url, then relative - // links like ../.. should be able - // to crawl up to the hostname, as well. This is strange. - // result.protocol has already been set by now. - // Later on, put the first path part into the host field. - if (psychotic) { - result.hostname = ''; - result.port = null; - if (result.host) { - if (srcPath[0] === '') srcPath[0] = result.host; - else srcPath.unshift(result.host); - } - result.host = ''; - if (relative.protocol) { - relative.hostname = null; - relative.port = null; - if (relative.host) { - if (relPath[0] === '') relPath[0] = relative.host; - else relPath.unshift(relative.host); - } - relative.host = null; - } - mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); - } - - if (isRelAbs) { - // it's absolute. - result.host = (relative.host || relative.host === '') ? - relative.host : result.host; - result.hostname = (relative.hostname || relative.hostname === '') ? - relative.hostname : result.hostname; - result.search = relative.search; - result.query = relative.query; - srcPath = relPath; - // fall through to the dot-handling below. - } else if (relPath.length) { - // it's relative - // throw away the existing file, and take the new path instead. - if (!srcPath) srcPath = []; - srcPath.pop(); - srcPath = srcPath.concat(relPath); - result.search = relative.search; - result.query = relative.query; - } else if (!util.isNullOrUndefined(relative.search)) { - // just pull out the search. - // like href='?foo'. - // Put this after the other two cases because it simplifies the booleans - if (psychotic) { - result.hostname = result.host = srcPath.shift(); - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - result.search = relative.search; - result.query = relative.query; - //to support http.request - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.href = result.format(); - return result; - } - - if (!srcPath.length) { - // no path at all. easy. - // we've already handled the other stuff above. - result.pathname = null; - //to support http.request - if (result.search) { - result.path = '/' + result.search; - } else { - result.path = null; - } - result.href = result.format(); - return result; - } - - // if a url ENDs in . or .., then it must get a trailing slash. - // however, if it ends in anything else non-slashy, - // then it must NOT get a trailing slash. - var last = srcPath.slice(-1)[0]; - var hasTrailingSlash = ( - (result.host || relative.host || srcPath.length > 1) && - (last === '.' || last === '..') || last === ''); - - // strip single dots, resolve double dots to parent dir - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = srcPath.length; i >= 0; i--) { - last = srcPath[i]; - if (last === '.') { - srcPath.splice(i, 1); - } else if (last === '..') { - srcPath.splice(i, 1); - up++; - } else if (up) { - srcPath.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (!mustEndAbs && !removeAllDots) { - for (; up--; up) { - srcPath.unshift('..'); - } - } - - if (mustEndAbs && srcPath[0] !== '' && - (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { - srcPath.unshift(''); - } - - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); - } - - var isAbsolute = srcPath[0] === '' || - (srcPath[0] && srcPath[0].charAt(0) === '/'); - - // put the host back - if (psychotic) { - result.hostname = result.host = isAbsolute ? '' : - srcPath.length ? srcPath.shift() : ''; - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - - mustEndAbs = mustEndAbs || (result.host && srcPath.length); - - if (mustEndAbs && !isAbsolute) { - srcPath.unshift(''); - } - - if (!srcPath.length) { - result.pathname = null; - result.path = null; - } else { - result.pathname = srcPath.join('/'); - } - - //to support request.http - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.auth = relative.auth || result.auth; - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; -}; - -Url.prototype.parseHost = function() { - var host = this.host; - var port = portPattern.exec(host); - if (port) { - port = port[0]; - if (port !== ':') { - this.port = port.substr(1); - } - host = host.substr(0, host.length - port.length); - } - if (host) this.hostname = host; -}; - - -/***/ }, -/* 63 */ +/* 37 */ /***/ function(module, exports) { module.exports = function arraysEqual(a, b) { @@ -16114,7 +9496,7 @@ module.exports = function arraysEqual(a, b) { /***/ }, -/* 64 */ +/* 38 */ /***/ function(module, exports) { module.exports = { @@ -16173,13 +9555,13 @@ module.exports = { }; /***/ }, -/* 65 */ +/* 39 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {const childProcess = __webpack_require__(13); -const path = __webpack_require__(23); -const makeError = __webpack_require__(135); -const makePlainError = __webpack_require__(136); +const path = __webpack_require__(17); +const makeError = __webpack_require__(74); +const makePlainError = __webpack_require__(75); /** * Represents a Shard spawned by the ShardingManager. @@ -16335,14 +9717,14 @@ class Shard { module.exports = Shard; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 66 */ +/* 40 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {const makeError = __webpack_require__(135); -const makePlainError = __webpack_require__(136); +/* WEBPACK VAR INJECTION */(function(process) {const makeError = __webpack_require__(74); +const makePlainError = __webpack_require__(75); /** * Helper class for sharded clients spawned as a child process, such as from a ShardingManager @@ -16484,14 +9866,14 @@ class ShardClientUtil { module.exports = ShardClientUtil; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 67 */ +/* 41 */ /***/ function(module, exports, __webpack_require__) { -const User = __webpack_require__(14); -const OAuth2Application = __webpack_require__(76); +const User = __webpack_require__(8); +const OAuth2Application = __webpack_require__(50); /** * Represents the client's OAuth2 Application @@ -16519,11 +9901,11 @@ module.exports = ClientOAuth2Application; /***/ }, -/* 68 */ +/* 42 */ /***/ function(module, exports, __webpack_require__) { -const User = __webpack_require__(14); -const Collection = __webpack_require__(6); +const User = __webpack_require__(8); +const Collection = __webpack_require__(3); /** * Represents the logged in client's Discord user @@ -16764,12 +10146,12 @@ module.exports = ClientUser; /***/ }, -/* 69 */ +/* 43 */ /***/ function(module, exports, __webpack_require__) { -const Channel = __webpack_require__(24); -const TextBasedChannel = __webpack_require__(31); -const Collection = __webpack_require__(6); +const Channel = __webpack_require__(14); +const TextBasedChannel = __webpack_require__(19); +const Collection = __webpack_require__(3); /** * Represents a direct message channel between two users. @@ -16829,13 +10211,13 @@ module.exports = DMChannel; /***/ }, -/* 70 */ +/* 44 */ /***/ function(module, exports, __webpack_require__) { -const Channel = __webpack_require__(24); -const TextBasedChannel = __webpack_require__(31); -const Collection = __webpack_require__(6); -const arraysEqual = __webpack_require__(63); +const Channel = __webpack_require__(14); +const TextBasedChannel = __webpack_require__(19); +const Collection = __webpack_require__(3); +const arraysEqual = __webpack_require__(37); /* { type: 3, @@ -16981,12 +10363,12 @@ module.exports = GroupDMChannel; /***/ }, -/* 71 */ +/* 45 */ /***/ function(module, exports, __webpack_require__) { -const PartialGuild = __webpack_require__(77); -const PartialGuildChannel = __webpack_require__(78); -const Constants = __webpack_require__(1); +const PartialGuild = __webpack_require__(51); +const PartialGuildChannel = __webpack_require__(52); +const Constants = __webpack_require__(0); /* { max_age: 86400, @@ -17145,7 +10527,7 @@ module.exports = Invite; /***/ }, -/* 72 */ +/* 46 */ /***/ function(module, exports) { /** @@ -17218,11 +10600,11 @@ module.exports = MessageAttachment; /***/ }, -/* 73 */ +/* 47 */ /***/ function(module, exports, __webpack_require__) { -const EventEmitter = __webpack_require__(5).EventEmitter; -const Collection = __webpack_require__(6); +const EventEmitter = __webpack_require__(4).EventEmitter; +const Collection = __webpack_require__(3); /** * Collects messages based on a specified filter, then emits them. @@ -17375,7 +10757,7 @@ module.exports = MessageCollector; /***/ }, -/* 74 */ +/* 48 */ /***/ function(module, exports) { /** @@ -17650,12 +11032,12 @@ module.exports = MessageEmbed; /***/ }, -/* 75 */ +/* 49 */ /***/ function(module, exports, __webpack_require__) { -const Collection = __webpack_require__(6); -const Emoji = __webpack_require__(25); -const ReactionEmoji = __webpack_require__(48); +const Collection = __webpack_require__(3); +const Emoji = __webpack_require__(15); +const ReactionEmoji = __webpack_require__(29); /** * Represents a reaction to a message @@ -17749,7 +11131,7 @@ module.exports = MessageReaction; /***/ }, -/* 76 */ +/* 50 */ /***/ function(module, exports) { /** @@ -17836,7 +11218,7 @@ module.exports = OAuth2Application; /***/ }, -/* 77 */ +/* 51 */ /***/ function(module, exports) { /* @@ -17892,10 +11274,10 @@ module.exports = PartialGuild; /***/ }, -/* 78 */ +/* 52 */ /***/ function(module, exports, __webpack_require__) { -const Constants = __webpack_require__(1); +const Constants = __webpack_require__(0); /* { type: 0, id: '123123', name: 'heavy-testing' } } @@ -17941,7 +11323,7 @@ module.exports = PartialGuildChannel; /***/ }, -/* 79 */ +/* 53 */ /***/ function(module, exports) { /** @@ -17988,12 +11370,12 @@ module.exports = PermissionOverwrites; /***/ }, -/* 80 */ +/* 54 */ /***/ function(module, exports, __webpack_require__) { -const GuildChannel = __webpack_require__(32); -const TextBasedChannel = __webpack_require__(31); -const Collection = __webpack_require__(6); +const GuildChannel = __webpack_require__(20); +const TextBasedChannel = __webpack_require__(19); +const Collection = __webpack_require__(3); /** * Represents a guild text channel on Discord. @@ -18089,11 +11471,11 @@ module.exports = TextChannel; /***/ }, -/* 81 */ +/* 55 */ /***/ function(module, exports, __webpack_require__) { -const GuildChannel = __webpack_require__(32); -const Collection = __webpack_require__(6); +const GuildChannel = __webpack_require__(20); +const Collection = __webpack_require__(3); /** * Represents a guild voice channel on Discord. @@ -18212,11 +11594,11 @@ module.exports = VoiceChannel; /***/ }, -/* 82 */ +/* 56 */ /***/ function(module, exports, __webpack_require__) { -const superagent = __webpack_require__(60); -const botGateway = __webpack_require__(1).Endpoints.botGateway; +const superagent = __webpack_require__(35); +const botGateway = __webpack_require__(0).Endpoints.botGateway; /** * Gets the recommended shard count from Discord @@ -18237,7 +11619,7 @@ module.exports = function fetchRecommendedShards(token) { /***/ }, -/* 83 */ +/* 57 */ /***/ function(module, exports) { module.exports = function splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) { @@ -18259,2725 +11641,7 @@ module.exports = function splitMessage(text, { maxLength = 1950, char = '\n', pr /***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { - -var inherits = __webpack_require__(2); -var Reporter = __webpack_require__(26).Reporter; -var Buffer = __webpack_require__(0).Buffer; - -function DecoderBuffer(base, options) { - Reporter.call(this, options); - if (!Buffer.isBuffer(base)) { - this.error('Input not Buffer'); - return; - } - - this.base = base; - this.offset = 0; - this.length = base.length; -} -inherits(DecoderBuffer, Reporter); -exports.DecoderBuffer = DecoderBuffer; - -DecoderBuffer.prototype.save = function save() { - return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; -}; - -DecoderBuffer.prototype.restore = function restore(save) { - // Return skipped data - var res = new DecoderBuffer(this.base); - res.offset = save.offset; - res.length = this.offset; - - this.offset = save.offset; - Reporter.prototype.restore.call(this, save.reporter); - - return res; -}; - -DecoderBuffer.prototype.isEmpty = function isEmpty() { - return this.offset === this.length; -}; - -DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { - if (this.offset + 1 <= this.length) - return this.base.readUInt8(this.offset++, true); - else - return this.error(fail || 'DecoderBuffer overrun'); -} - -DecoderBuffer.prototype.skip = function skip(bytes, fail) { - if (!(this.offset + bytes <= this.length)) - return this.error(fail || 'DecoderBuffer overrun'); - - var res = new DecoderBuffer(this.base); - - // Share reporter state - res._reporterState = this._reporterState; - - res.offset = this.offset; - res.length = this.offset + bytes; - this.offset += bytes; - return res; -} - -DecoderBuffer.prototype.raw = function raw(save) { - return this.base.slice(save ? save.offset : this.offset, this.length); -} - -function EncoderBuffer(value, reporter) { - if (Array.isArray(value)) { - this.length = 0; - this.value = value.map(function(item) { - if (!(item instanceof EncoderBuffer)) - item = new EncoderBuffer(item, reporter); - this.length += item.length; - return item; - }, this); - } else if (typeof value === 'number') { - if (!(0 <= value && value <= 0xff)) - return reporter.error('non-byte EncoderBuffer value'); - this.value = value; - this.length = 1; - } else if (typeof value === 'string') { - this.value = value; - this.length = Buffer.byteLength(value); - } else if (Buffer.isBuffer(value)) { - this.value = value; - this.length = value.length; - } else { - return reporter.error('Unsupported type: ' + typeof value); - } -} -exports.EncoderBuffer = EncoderBuffer; - -EncoderBuffer.prototype.join = function join(out, offset) { - if (!out) - out = new Buffer(this.length); - if (!offset) - offset = 0; - - if (this.length === 0) - return out; - - if (Array.isArray(this.value)) { - this.value.forEach(function(item) { - item.join(out, offset); - offset += item.length; - }); - } else { - if (typeof this.value === 'number') - out[offset] = this.value; - else if (typeof this.value === 'string') - out.write(this.value, offset); - else if (Buffer.isBuffer(this.value)) - this.value.copy(out, offset); - offset += this.length; - } - - return out; -}; - - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - -var constants = exports; - -// Helper -constants._reverse = function reverse(map) { - var res = {}; - - Object.keys(map).forEach(function(key) { - // Convert key to integer if it is stringified - if ((key | 0) == key) - key = key | 0; - - var value = map[key]; - res[value] = key; - }); - - return res; -}; - -constants.der = __webpack_require__(144); - - -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { - -var inherits = __webpack_require__(2); - -var asn1 = __webpack_require__(36); -var base = asn1.base; -var bignum = asn1.bignum; - -// Import DER constants -var der = asn1.constants.der; - -function DERDecoder(entity) { - this.enc = 'der'; - this.name = entity.name; - this.entity = entity; - - // Construct base tree - this.tree = new DERNode(); - this.tree._init(entity.body); -}; -module.exports = DERDecoder; - -DERDecoder.prototype.decode = function decode(data, options) { - if (!(data instanceof base.DecoderBuffer)) - data = new base.DecoderBuffer(data, options); - - return this.tree._decode(data, options); -}; - -// Tree methods - -function DERNode(parent) { - base.Node.call(this, 'der', parent); -} -inherits(DERNode, base.Node); - -DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { - if (buffer.isEmpty()) - return false; - - var state = buffer.save(); - var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); - if (buffer.isError(decodedTag)) - return decodedTag; - - buffer.restore(state); - - return decodedTag.tag === tag || decodedTag.tagStr === tag || - (decodedTag.tagStr + 'of') === tag || any; -}; - -DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { - var decodedTag = derDecodeTag(buffer, - 'Failed to decode tag of "' + tag + '"'); - if (buffer.isError(decodedTag)) - return decodedTag; - - var len = derDecodeLen(buffer, - decodedTag.primitive, - 'Failed to get length of "' + tag + '"'); - - // Failure - if (buffer.isError(len)) - return len; - - if (!any && - decodedTag.tag !== tag && - decodedTag.tagStr !== tag && - decodedTag.tagStr + 'of' !== tag) { - return buffer.error('Failed to match tag: "' + tag + '"'); - } - - if (decodedTag.primitive || len !== null) - return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); - - // Indefinite length... find END tag - var state = buffer.save(); - var res = this._skipUntilEnd( - buffer, - 'Failed to skip indefinite length body: "' + this.tag + '"'); - if (buffer.isError(res)) - return res; - - len = buffer.offset - state.offset; - buffer.restore(state); - return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); -}; - -DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { - while (true) { - var tag = derDecodeTag(buffer, fail); - if (buffer.isError(tag)) - return tag; - var len = derDecodeLen(buffer, tag.primitive, fail); - if (buffer.isError(len)) - return len; - - var res; - if (tag.primitive || len !== null) - res = buffer.skip(len) - else - res = this._skipUntilEnd(buffer, fail); - - // Failure - if (buffer.isError(res)) - return res; - - if (tag.tagStr === 'end') - break; - } -}; - -DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, - options) { - var result = []; - while (!buffer.isEmpty()) { - var possibleEnd = this._peekTag(buffer, 'end'); - if (buffer.isError(possibleEnd)) - return possibleEnd; - - var res = decoder.decode(buffer, 'der', options); - if (buffer.isError(res) && possibleEnd) - break; - result.push(res); - } - return result; -}; - -DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { - if (tag === 'bitstr') { - var unused = buffer.readUInt8(); - if (buffer.isError(unused)) - return unused; - return { unused: unused, data: buffer.raw() }; - } else if (tag === 'bmpstr') { - var raw = buffer.raw(); - if (raw.length % 2 === 1) - return buffer.error('Decoding of string type: bmpstr length mismatch'); - - var str = ''; - for (var i = 0; i < raw.length / 2; i++) { - str += String.fromCharCode(raw.readUInt16BE(i * 2)); - } - return str; - } else if (tag === 'numstr') { - var numstr = buffer.raw().toString('ascii'); - if (!this._isNumstr(numstr)) { - return buffer.error('Decoding of string type: ' + - 'numstr unsupported characters'); - } - return numstr; - } else if (tag === 'octstr') { - return buffer.raw(); - } else if (tag === 'objDesc') { - return buffer.raw(); - } else if (tag === 'printstr') { - var printstr = buffer.raw().toString('ascii'); - if (!this._isPrintstr(printstr)) { - return buffer.error('Decoding of string type: ' + - 'printstr unsupported characters'); - } - return printstr; - } else if (/str$/.test(tag)) { - return buffer.raw().toString(); - } else { - return buffer.error('Decoding of string type: ' + tag + ' unsupported'); - } -}; - -DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { - var result; - var identifiers = []; - var ident = 0; - while (!buffer.isEmpty()) { - var subident = buffer.readUInt8(); - ident <<= 7; - ident |= subident & 0x7f; - if ((subident & 0x80) === 0) { - identifiers.push(ident); - ident = 0; - } - } - if (subident & 0x80) - identifiers.push(ident); - - var first = (identifiers[0] / 40) | 0; - var second = identifiers[0] % 40; - - if (relative) - result = identifiers; - else - result = [first, second].concat(identifiers.slice(1)); - - if (values) { - var tmp = values[result.join(' ')]; - if (tmp === undefined) - tmp = values[result.join('.')]; - if (tmp !== undefined) - result = tmp; - } - - return result; -}; - -DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { - var str = buffer.raw().toString(); - if (tag === 'gentime') { - var year = str.slice(0, 4) | 0; - var mon = str.slice(4, 6) | 0; - var day = str.slice(6, 8) | 0; - var hour = str.slice(8, 10) | 0; - var min = str.slice(10, 12) | 0; - var sec = str.slice(12, 14) | 0; - } else if (tag === 'utctime') { - var year = str.slice(0, 2) | 0; - var mon = str.slice(2, 4) | 0; - var day = str.slice(4, 6) | 0; - var hour = str.slice(6, 8) | 0; - var min = str.slice(8, 10) | 0; - var sec = str.slice(10, 12) | 0; - if (year < 70) - year = 2000 + year; - else - year = 1900 + year; - } else { - return buffer.error('Decoding ' + tag + ' time is not supported yet'); - } - - return Date.UTC(year, mon - 1, day, hour, min, sec, 0); -}; - -DERNode.prototype._decodeNull = function decodeNull(buffer) { - return null; -}; - -DERNode.prototype._decodeBool = function decodeBool(buffer) { - var res = buffer.readUInt8(); - if (buffer.isError(res)) - return res; - else - return res !== 0; -}; - -DERNode.prototype._decodeInt = function decodeInt(buffer, values) { - // Bigint, return as it is (assume big endian) - var raw = buffer.raw(); - var res = new bignum(raw); - - if (values) - res = values[res.toString(10)] || res; - - return res; -}; - -DERNode.prototype._use = function use(entity, obj) { - if (typeof entity === 'function') - entity = entity(obj); - return entity._getDecoder('der').tree; -}; - -// Utility methods - -function derDecodeTag(buf, fail) { - var tag = buf.readUInt8(fail); - if (buf.isError(tag)) - return tag; - - var cls = der.tagClass[tag >> 6]; - var primitive = (tag & 0x20) === 0; - - // Multi-octet tag - load - if ((tag & 0x1f) === 0x1f) { - var oct = tag; - tag = 0; - while ((oct & 0x80) === 0x80) { - oct = buf.readUInt8(fail); - if (buf.isError(oct)) - return oct; - - tag <<= 7; - tag |= oct & 0x7f; - } - } else { - tag &= 0x1f; - } - var tagStr = der.tag[tag]; - - return { - cls: cls, - primitive: primitive, - tag: tag, - tagStr: tagStr - }; -} - -function derDecodeLen(buf, primitive, fail) { - var len = buf.readUInt8(fail); - if (buf.isError(len)) - return len; - - // Indefinite form - if (!primitive && len === 0x80) - return null; - - // Definite form - if ((len & 0x80) === 0) { - // Short form - return len; - } - - // Long form - var num = len & 0x7f; - if (num >= 4) - return buf.error('length octect is too long'); - - len = 0; - for (var i = 0; i < num; i++) { - len <<= 8; - var j = buf.readUInt8(fail); - if (buf.isError(j)) - return j; - len |= j; - } - - return len; -} - - -/***/ }, -/* 87 */ -/***/ function(module, exports, __webpack_require__) { - -var inherits = __webpack_require__(2); -var Buffer = __webpack_require__(0).Buffer; - -var asn1 = __webpack_require__(36); -var base = asn1.base; - -// Import DER constants -var der = asn1.constants.der; - -function DEREncoder(entity) { - this.enc = 'der'; - this.name = entity.name; - this.entity = entity; - - // Construct base tree - this.tree = new DERNode(); - this.tree._init(entity.body); -}; -module.exports = DEREncoder; - -DEREncoder.prototype.encode = function encode(data, reporter) { - return this.tree._encode(data, reporter).join(); -}; - -// Tree methods - -function DERNode(parent) { - base.Node.call(this, 'der', parent); -} -inherits(DERNode, base.Node); - -DERNode.prototype._encodeComposite = function encodeComposite(tag, - primitive, - cls, - content) { - var encodedTag = encodeTag(tag, primitive, cls, this.reporter); - - // Short form - if (content.length < 0x80) { - var header = new Buffer(2); - header[0] = encodedTag; - header[1] = content.length; - return this._createEncoderBuffer([ header, content ]); - } - - // Long form - // Count octets required to store length - var lenOctets = 1; - for (var i = content.length; i >= 0x100; i >>= 8) - lenOctets++; - - var header = new Buffer(1 + 1 + lenOctets); - header[0] = encodedTag; - header[1] = 0x80 | lenOctets; - - for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) - header[i] = j & 0xff; - - return this._createEncoderBuffer([ header, content ]); -}; - -DERNode.prototype._encodeStr = function encodeStr(str, tag) { - if (tag === 'bitstr') { - return this._createEncoderBuffer([ str.unused | 0, str.data ]); - } else if (tag === 'bmpstr') { - var buf = new Buffer(str.length * 2); - for (var i = 0; i < str.length; i++) { - buf.writeUInt16BE(str.charCodeAt(i), i * 2); - } - return this._createEncoderBuffer(buf); - } else if (tag === 'numstr') { - if (!this._isNumstr(str)) { - return this.reporter.error('Encoding of string type: numstr supports ' + - 'only digits and space'); - } - return this._createEncoderBuffer(str); - } else if (tag === 'printstr') { - if (!this._isPrintstr(str)) { - return this.reporter.error('Encoding of string type: printstr supports ' + - 'only latin upper and lower case letters, ' + - 'digits, space, apostrophe, left and rigth ' + - 'parenthesis, plus sign, comma, hyphen, ' + - 'dot, slash, colon, equal sign, ' + - 'question mark'); - } - return this._createEncoderBuffer(str); - } else if (/str$/.test(tag)) { - return this._createEncoderBuffer(str); - } else if (tag === 'objDesc') { - return this._createEncoderBuffer(str); - } else { - return this.reporter.error('Encoding of string type: ' + tag + - ' unsupported'); - } -}; - -DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { - if (typeof id === 'string') { - if (!values) - return this.reporter.error('string objid given, but no values map found'); - if (!values.hasOwnProperty(id)) - return this.reporter.error('objid not found in values map'); - id = values[id].split(/[\s\.]+/g); - for (var i = 0; i < id.length; i++) - id[i] |= 0; - } else if (Array.isArray(id)) { - id = id.slice(); - for (var i = 0; i < id.length; i++) - id[i] |= 0; - } - - if (!Array.isArray(id)) { - return this.reporter.error('objid() should be either array or string, ' + - 'got: ' + JSON.stringify(id)); - } - - if (!relative) { - if (id[1] >= 40) - return this.reporter.error('Second objid identifier OOB'); - id.splice(0, 2, id[0] * 40 + id[1]); - } - - // Count number of octets - var size = 0; - for (var i = 0; i < id.length; i++) { - var ident = id[i]; - for (size++; ident >= 0x80; ident >>= 7) - size++; - } - - var objid = new Buffer(size); - var offset = objid.length - 1; - for (var i = id.length - 1; i >= 0; i--) { - var ident = id[i]; - objid[offset--] = ident & 0x7f; - while ((ident >>= 7) > 0) - objid[offset--] = 0x80 | (ident & 0x7f); - } - - return this._createEncoderBuffer(objid); -}; - -function two(num) { - if (num < 10) - return '0' + num; - else - return num; -} - -DERNode.prototype._encodeTime = function encodeTime(time, tag) { - var str; - var date = new Date(time); - - if (tag === 'gentime') { - str = [ - two(date.getFullYear()), - two(date.getUTCMonth() + 1), - two(date.getUTCDate()), - two(date.getUTCHours()), - two(date.getUTCMinutes()), - two(date.getUTCSeconds()), - 'Z' - ].join(''); - } else if (tag === 'utctime') { - str = [ - two(date.getFullYear() % 100), - two(date.getUTCMonth() + 1), - two(date.getUTCDate()), - two(date.getUTCHours()), - two(date.getUTCMinutes()), - two(date.getUTCSeconds()), - 'Z' - ].join(''); - } else { - this.reporter.error('Encoding ' + tag + ' time is not supported yet'); - } - - return this._encodeStr(str, 'octstr'); -}; - -DERNode.prototype._encodeNull = function encodeNull() { - return this._createEncoderBuffer(''); -}; - -DERNode.prototype._encodeInt = function encodeInt(num, values) { - if (typeof num === 'string') { - if (!values) - return this.reporter.error('String int or enum given, but no values map'); - if (!values.hasOwnProperty(num)) { - return this.reporter.error('Values map doesn\'t contain: ' + - JSON.stringify(num)); - } - num = values[num]; - } - - // Bignum, assume big endian - if (typeof num !== 'number' && !Buffer.isBuffer(num)) { - var numArray = num.toArray(); - if (!num.sign && numArray[0] & 0x80) { - numArray.unshift(0); - } - num = new Buffer(numArray); - } - - if (Buffer.isBuffer(num)) { - var size = num.length; - if (num.length === 0) - size++; - - var out = new Buffer(size); - num.copy(out); - if (num.length === 0) - out[0] = 0 - return this._createEncoderBuffer(out); - } - - if (num < 0x80) - return this._createEncoderBuffer(num); - - if (num < 0x100) - return this._createEncoderBuffer([0, num]); - - var size = 1; - for (var i = num; i >= 0x100; i >>= 8) - size++; - - var out = new Array(size); - for (var i = out.length - 1; i >= 0; i--) { - out[i] = num & 0xff; - num >>= 8; - } - if(out[0] & 0x80) { - out.unshift(0); - } - - return this._createEncoderBuffer(new Buffer(out)); -}; - -DERNode.prototype._encodeBool = function encodeBool(value) { - return this._createEncoderBuffer(value ? 0xff : 0); -}; - -DERNode.prototype._use = function use(entity, obj) { - if (typeof entity === 'function') - entity = entity(obj); - return entity._getEncoder('der').tree; -}; - -DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { - var state = this._baseState; - var i; - if (state['default'] === null) - return false; - - var data = dataBuffer.join(); - if (state.defaultBuffer === undefined) - state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); - - if (data.length !== state.defaultBuffer.length) - return false; - - for (i=0; i < data.length; i++) - if (data[i] !== state.defaultBuffer[i]) - return false; - - return true; -}; - -// Utility methods - -function encodeTag(tag, primitive, cls, reporter) { - var res; - - if (tag === 'seqof') - tag = 'seq'; - else if (tag === 'setof') - tag = 'set'; - - if (der.tagByName.hasOwnProperty(tag)) - res = der.tagByName[tag]; - else if (typeof tag === 'number' && (tag | 0) === tag) - res = tag; - else - return reporter.error('Unknown tag: ' + tag); - - if (res >= 0x1f) - return reporter.error('Multi-octet tag encoding unsupported'); - - if (!primitive) - res |= 0x20; - - res |= (der.tagClassByName[cls || 'universal'] << 6); - - return res; -} - - -/***/ }, -/* 88 */ -/***/ function(module, exports) { - -function webpackEmptyContext(req) { - throw new Error("Cannot find module '" + req + "'."); -} -webpackEmptyContext.keys = function() { return []; }; -webpackEmptyContext.resolve = webpackEmptyContext; -module.exports = webpackEmptyContext; -webpackEmptyContext.id = 88; - - -/***/ }, -/* 89 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process, __filename) { -/** - * Module dependencies. - */ - -var fs = __webpack_require__(13) - , path = __webpack_require__(23) - , join = path.join - , dirname = path.dirname - , exists = fs.existsSync || path.existsSync - , defaults = { - arrow: process.env.NODE_BINDINGS_ARROW || ' → ' - , compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled' - , platform: process.platform - , arch: process.arch - , version: process.versions.node - , bindings: 'bindings.node' - , try: [ - // node-gyp's linked version in the "build" dir - [ 'module_root', 'build', 'bindings' ] - // node-waf and gyp_addon (a.k.a node-gyp) - , [ 'module_root', 'build', 'Debug', 'bindings' ] - , [ 'module_root', 'build', 'Release', 'bindings' ] - // Debug files, for development (legacy behavior, remove for node v0.9) - , [ 'module_root', 'out', 'Debug', 'bindings' ] - , [ 'module_root', 'Debug', 'bindings' ] - // Release files, but manually compiled (legacy behavior, remove for node v0.9) - , [ 'module_root', 'out', 'Release', 'bindings' ] - , [ 'module_root', 'Release', 'bindings' ] - // Legacy from node-waf, node <= 0.4.x - , [ 'module_root', 'build', 'default', 'bindings' ] - // Production "Release" buildtype binary (meh...) - , [ 'module_root', 'compiled', 'version', 'platform', 'arch', 'bindings' ] - ] - } - -/** - * The main `bindings()` function loads the compiled bindings for a given module. - * It uses V8's Error API to determine the parent filename that this function is - * being invoked from, which is then used to find the root directory. - */ - -function bindings (opts) { - - // Argument surgery - if (typeof opts == 'string') { - opts = { bindings: opts } - } else if (!opts) { - opts = {} - } - opts.__proto__ = defaults - - // Get the module root - if (!opts.module_root) { - opts.module_root = exports.getRoot(exports.getFileName()) - } - - // Ensure the given bindings name ends with .node - if (path.extname(opts.bindings) != '.node') { - opts.bindings += '.node' - } - - var tries = [] - , i = 0 - , l = opts.try.length - , n - , b - , err - - for (; i> (i % 8)) - self._prev = shiftIn(self._prev, decrypt ? bit : value) - } - return out -} -exports.encrypt = function (self, chunk, decrypt) { - var len = chunk.length - var out = new Buffer(len) - var i = -1 - while (++i < len) { - out[i] = encryptByte(self, chunk[i], decrypt) - } - return out -} -function shiftIn (buffer, value) { - var len = buffer.length - var i = -1 - var out = new Buffer(buffer.length) - buffer = Buffer.concat([buffer, new Buffer([value])]) - while (++i < len) { - out[i] = buffer[i] << 1 | buffer[i + 1] >> (7) - } - return out -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 95 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {function encryptByte (self, byteParam, decrypt) { - var pad = self._cipher.encryptBlock(self._prev) - var out = pad[0] ^ byteParam - self._prev = Buffer.concat([self._prev.slice(1), new Buffer([decrypt ? byteParam : out])]) - return out -} -exports.encrypt = function (self, chunk, decrypt) { - var len = chunk.length - var out = new Buffer(len) - var i = -1 - while (++i < len) { - out[i] = encryptByte(self, chunk[i], decrypt) - } - return out -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 96 */ -/***/ function(module, exports) { - -exports.encrypt = function (self, block) { - return self._cipher.encryptBlock(block) -} -exports.decrypt = function (self, block) { - return self._cipher.decryptBlock(block) -} - - -/***/ }, -/* 97 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(27) - -function getBlock (self) { - self._prev = self._cipher.encryptBlock(self._prev) - return self._prev -} - -exports.encrypt = function (self, chunk) { - while (self._cache.length < chunk.length) { - self._cache = Buffer.concat([self._cache, getBlock(self)]) - } - - var pad = self._cache.slice(0, chunk.length) - self._cache = self._cache.slice(chunk.length) - return xor(chunk, pad) -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 98 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(37) -var Transform = __webpack_require__(20) -var inherits = __webpack_require__(2) - -inherits(StreamCipher, Transform) -module.exports = StreamCipher -function StreamCipher (mode, key, iv, decrypt) { - if (!(this instanceof StreamCipher)) { - return new StreamCipher(mode, key, iv) - } - Transform.call(this) - this._cipher = new aes.AES(key) - this._prev = new Buffer(iv.length) - this._cache = new Buffer('') - this._secCache = new Buffer('') - this._decrypt = decrypt - iv.copy(this._prev) - this._mode = mode -} -StreamCipher.prototype._update = function (chunk) { - return this._mode.encrypt(this, chunk, this._decrypt) -} -StreamCipher.prototype._final = function () { - this._cipher.scrub() -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 99 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict' -exports['RSA-SHA224'] = exports.sha224WithRSAEncryption = { - sign: 'rsa', - hash: 'sha224', - id: new Buffer('302d300d06096086480165030402040500041c', 'hex') -} -exports['RSA-SHA256'] = exports.sha256WithRSAEncryption = { - sign: 'rsa', - hash: 'sha256', - id: new Buffer('3031300d060960864801650304020105000420', 'hex') -} -exports['RSA-SHA384'] = exports.sha384WithRSAEncryption = { - sign: 'rsa', - hash: 'sha384', - id: new Buffer('3041300d060960864801650304020205000430', 'hex') -} -exports['RSA-SHA512'] = exports.sha512WithRSAEncryption = { - sign: 'rsa', - hash: 'sha512', - id: new Buffer('3051300d060960864801650304020305000440', 'hex') -} -exports['RSA-SHA1'] = { - sign: 'rsa', - hash: 'sha1', - id: new Buffer('3021300906052b0e03021a05000414', 'hex') -} -exports['ecdsa-with-SHA1'] = { - sign: 'ecdsa', - hash: 'sha1', - id: new Buffer('', 'hex') -} - -exports.DSA = exports['DSA-SHA1'] = exports['DSA-SHA'] = { - sign: 'dsa', - hash: 'sha1', - id: new Buffer('', 'hex') -} -exports['DSA-SHA224'] = exports['DSA-WITH-SHA224'] = { - sign: 'dsa', - hash: 'sha224', - id: new Buffer('', 'hex') -} -exports['DSA-SHA256'] = exports['DSA-WITH-SHA256'] = { - sign: 'dsa', - hash: 'sha256', - id: new Buffer('', 'hex') -} -exports['DSA-SHA384'] = exports['DSA-WITH-SHA384'] = { - sign: 'dsa', - hash: 'sha384', - id: new Buffer('', 'hex') -} -exports['DSA-SHA512'] = exports['DSA-WITH-SHA512'] = { - sign: 'dsa', - hash: 'sha512', - id: new Buffer('', 'hex') -} -exports['DSA-RIPEMD160'] = { - sign: 'dsa', - hash: 'rmd160', - id: new Buffer('', 'hex') -} -exports['RSA-RIPEMD160'] = exports.ripemd160WithRSA = { - sign: 'rsa', - hash: 'rmd160', - id: new Buffer('3021300906052b2403020105000414', 'hex') -} -exports['RSA-MD5'] = exports.md5WithRSAEncryption = { - sign: 'rsa', - hash: 'md5', - id: new Buffer('3020300c06082a864886f70d020505000410', 'hex') -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 100 */ -/***/ function(module, exports) { - -"use strict"; -'use strict' -exports['1.3.132.0.10'] = 'secp256k1' - -exports['1.3.132.0.33'] = 'p224' - -exports['1.2.840.10045.3.1.1'] = 'p192' - -exports['1.2.840.10045.3.1.7'] = 'p256' - -exports['1.3.132.0.34'] = 'p384' - -exports['1.3.132.0.35'] = 'p521' - - -/***/ }, -/* 101 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer, process) {// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var Transform = __webpack_require__(118); - -var binding = __webpack_require__(160); -var util = __webpack_require__(10); -var assert = __webpack_require__(149).ok; - -// zlib doesn't provide these, so kludge them in following the same -// const naming scheme zlib uses. -binding.Z_MIN_WINDOWBITS = 8; -binding.Z_MAX_WINDOWBITS = 15; -binding.Z_DEFAULT_WINDOWBITS = 15; - -// fewer than 64 bytes per chunk is stupid. -// technically it could work with as few as 8, but even 64 bytes -// is absurdly low. Usually a MB or more is best. -binding.Z_MIN_CHUNK = 64; -binding.Z_MAX_CHUNK = Infinity; -binding.Z_DEFAULT_CHUNK = (16 * 1024); - -binding.Z_MIN_MEMLEVEL = 1; -binding.Z_MAX_MEMLEVEL = 9; -binding.Z_DEFAULT_MEMLEVEL = 8; - -binding.Z_MIN_LEVEL = -1; -binding.Z_MAX_LEVEL = 9; -binding.Z_DEFAULT_LEVEL = binding.Z_DEFAULT_COMPRESSION; - -// expose all the zlib constants -Object.keys(binding).forEach(function(k) { - if (k.match(/^Z/)) exports[k] = binding[k]; -}); - -// translation table for return codes. -exports.codes = { - Z_OK: binding.Z_OK, - Z_STREAM_END: binding.Z_STREAM_END, - Z_NEED_DICT: binding.Z_NEED_DICT, - Z_ERRNO: binding.Z_ERRNO, - Z_STREAM_ERROR: binding.Z_STREAM_ERROR, - Z_DATA_ERROR: binding.Z_DATA_ERROR, - Z_MEM_ERROR: binding.Z_MEM_ERROR, - Z_BUF_ERROR: binding.Z_BUF_ERROR, - Z_VERSION_ERROR: binding.Z_VERSION_ERROR -}; - -Object.keys(exports.codes).forEach(function(k) { - exports.codes[exports.codes[k]] = k; -}); - -exports.Deflate = Deflate; -exports.Inflate = Inflate; -exports.Gzip = Gzip; -exports.Gunzip = Gunzip; -exports.DeflateRaw = DeflateRaw; -exports.InflateRaw = InflateRaw; -exports.Unzip = Unzip; - -exports.createDeflate = function(o) { - return new Deflate(o); -}; - -exports.createInflate = function(o) { - return new Inflate(o); -}; - -exports.createDeflateRaw = function(o) { - return new DeflateRaw(o); -}; - -exports.createInflateRaw = function(o) { - return new InflateRaw(o); -}; - -exports.createGzip = function(o) { - return new Gzip(o); -}; - -exports.createGunzip = function(o) { - return new Gunzip(o); -}; - -exports.createUnzip = function(o) { - return new Unzip(o); -}; - - -// Convenience methods. -// compress/decompress a string or buffer in one step. -exports.deflate = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Deflate(opts), buffer, callback); -}; - -exports.deflateSync = function(buffer, opts) { - return zlibBufferSync(new Deflate(opts), buffer); -}; - -exports.gzip = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Gzip(opts), buffer, callback); -}; - -exports.gzipSync = function(buffer, opts) { - return zlibBufferSync(new Gzip(opts), buffer); -}; - -exports.deflateRaw = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new DeflateRaw(opts), buffer, callback); -}; - -exports.deflateRawSync = function(buffer, opts) { - return zlibBufferSync(new DeflateRaw(opts), buffer); -}; - -exports.unzip = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Unzip(opts), buffer, callback); -}; - -exports.unzipSync = function(buffer, opts) { - return zlibBufferSync(new Unzip(opts), buffer); -}; - -exports.inflate = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Inflate(opts), buffer, callback); -}; - -exports.inflateSync = function(buffer, opts) { - return zlibBufferSync(new Inflate(opts), buffer); -}; - -exports.gunzip = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new Gunzip(opts), buffer, callback); -}; - -exports.gunzipSync = function(buffer, opts) { - return zlibBufferSync(new Gunzip(opts), buffer); -}; - -exports.inflateRaw = function(buffer, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } - return zlibBuffer(new InflateRaw(opts), buffer, callback); -}; - -exports.inflateRawSync = function(buffer, opts) { - return zlibBufferSync(new InflateRaw(opts), buffer); -}; - -function zlibBuffer(engine, buffer, callback) { - var buffers = []; - var nread = 0; - - engine.on('error', onError); - engine.on('end', onEnd); - - engine.end(buffer); - flow(); - - function flow() { - var chunk; - while (null !== (chunk = engine.read())) { - buffers.push(chunk); - nread += chunk.length; - } - engine.once('readable', flow); - } - - function onError(err) { - engine.removeListener('end', onEnd); - engine.removeListener('readable', flow); - callback(err); - } - - function onEnd() { - var buf = Buffer.concat(buffers, nread); - buffers = []; - callback(null, buf); - engine.close(); - } -} - -function zlibBufferSync(engine, buffer) { - if (typeof buffer === 'string') - buffer = new Buffer(buffer); - if (!Buffer.isBuffer(buffer)) - throw new TypeError('Not a string or buffer'); - - var flushFlag = binding.Z_FINISH; - - return engine._processChunk(buffer, flushFlag); -} - -// generic zlib -// minimal 2-byte header -function Deflate(opts) { - if (!(this instanceof Deflate)) return new Deflate(opts); - Zlib.call(this, opts, binding.DEFLATE); -} - -function Inflate(opts) { - if (!(this instanceof Inflate)) return new Inflate(opts); - Zlib.call(this, opts, binding.INFLATE); -} - - - -// gzip - bigger header, same deflate compression -function Gzip(opts) { - if (!(this instanceof Gzip)) return new Gzip(opts); - Zlib.call(this, opts, binding.GZIP); -} - -function Gunzip(opts) { - if (!(this instanceof Gunzip)) return new Gunzip(opts); - Zlib.call(this, opts, binding.GUNZIP); -} - - - -// raw - no header -function DeflateRaw(opts) { - if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts); - Zlib.call(this, opts, binding.DEFLATERAW); -} - -function InflateRaw(opts) { - if (!(this instanceof InflateRaw)) return new InflateRaw(opts); - Zlib.call(this, opts, binding.INFLATERAW); -} - - -// auto-detect header. -function Unzip(opts) { - if (!(this instanceof Unzip)) return new Unzip(opts); - Zlib.call(this, opts, binding.UNZIP); -} - - -// the Zlib class they all inherit from -// This thing manages the queue of requests, and returns -// true or false if there is anything in the queue when -// you call the .write() method. - -function Zlib(opts, mode) { - this._opts = opts = opts || {}; - this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK; - - Transform.call(this, opts); - - if (opts.flush) { - if (opts.flush !== binding.Z_NO_FLUSH && - opts.flush !== binding.Z_PARTIAL_FLUSH && - opts.flush !== binding.Z_SYNC_FLUSH && - opts.flush !== binding.Z_FULL_FLUSH && - opts.flush !== binding.Z_FINISH && - opts.flush !== binding.Z_BLOCK) { - throw new Error('Invalid flush flag: ' + opts.flush); - } - } - this._flushFlag = opts.flush || binding.Z_NO_FLUSH; - - if (opts.chunkSize) { - if (opts.chunkSize < exports.Z_MIN_CHUNK || - opts.chunkSize > exports.Z_MAX_CHUNK) { - throw new Error('Invalid chunk size: ' + opts.chunkSize); - } - } - - if (opts.windowBits) { - if (opts.windowBits < exports.Z_MIN_WINDOWBITS || - opts.windowBits > exports.Z_MAX_WINDOWBITS) { - throw new Error('Invalid windowBits: ' + opts.windowBits); - } - } - - if (opts.level) { - if (opts.level < exports.Z_MIN_LEVEL || - opts.level > exports.Z_MAX_LEVEL) { - throw new Error('Invalid compression level: ' + opts.level); - } - } - - if (opts.memLevel) { - if (opts.memLevel < exports.Z_MIN_MEMLEVEL || - opts.memLevel > exports.Z_MAX_MEMLEVEL) { - throw new Error('Invalid memLevel: ' + opts.memLevel); - } - } - - if (opts.strategy) { - if (opts.strategy != exports.Z_FILTERED && - opts.strategy != exports.Z_HUFFMAN_ONLY && - opts.strategy != exports.Z_RLE && - opts.strategy != exports.Z_FIXED && - opts.strategy != exports.Z_DEFAULT_STRATEGY) { - throw new Error('Invalid strategy: ' + opts.strategy); - } - } - - if (opts.dictionary) { - if (!Buffer.isBuffer(opts.dictionary)) { - throw new Error('Invalid dictionary: it should be a Buffer instance'); - } - } - - this._binding = new binding.Zlib(mode); - - var self = this; - this._hadError = false; - this._binding.onerror = function(message, errno) { - // there is no way to cleanly recover. - // continuing only obscures problems. - self._binding = null; - self._hadError = true; - - var error = new Error(message); - error.errno = errno; - error.code = exports.codes[errno]; - self.emit('error', error); - }; - - var level = exports.Z_DEFAULT_COMPRESSION; - if (typeof opts.level === 'number') level = opts.level; - - var strategy = exports.Z_DEFAULT_STRATEGY; - if (typeof opts.strategy === 'number') strategy = opts.strategy; - - this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, - level, - opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, - strategy, - opts.dictionary); - - this._buffer = new Buffer(this._chunkSize); - this._offset = 0; - this._closed = false; - this._level = level; - this._strategy = strategy; - - this.once('end', this.close); -} - -util.inherits(Zlib, Transform); - -Zlib.prototype.params = function(level, strategy, callback) { - if (level < exports.Z_MIN_LEVEL || - level > exports.Z_MAX_LEVEL) { - throw new RangeError('Invalid compression level: ' + level); - } - if (strategy != exports.Z_FILTERED && - strategy != exports.Z_HUFFMAN_ONLY && - strategy != exports.Z_RLE && - strategy != exports.Z_FIXED && - strategy != exports.Z_DEFAULT_STRATEGY) { - throw new TypeError('Invalid strategy: ' + strategy); - } - - if (this._level !== level || this._strategy !== strategy) { - var self = this; - this.flush(binding.Z_SYNC_FLUSH, function() { - self._binding.params(level, strategy); - if (!self._hadError) { - self._level = level; - self._strategy = strategy; - if (callback) callback(); - } - }); - } else { - process.nextTick(callback); - } -}; - -Zlib.prototype.reset = function() { - return this._binding.reset(); -}; - -// This is the _flush function called by the transform class, -// internally, when the last chunk has been written. -Zlib.prototype._flush = function(callback) { - this._transform(new Buffer(0), '', callback); -}; - -Zlib.prototype.flush = function(kind, callback) { - var ws = this._writableState; - - if (typeof kind === 'function' || (kind === void 0 && !callback)) { - callback = kind; - kind = binding.Z_FULL_FLUSH; - } - - if (ws.ended) { - if (callback) - process.nextTick(callback); - } else if (ws.ending) { - if (callback) - this.once('end', callback); - } else if (ws.needDrain) { - var self = this; - this.once('drain', function() { - self.flush(callback); - }); - } else { - this._flushFlag = kind; - this.write(new Buffer(0), '', callback); - } -}; - -Zlib.prototype.close = function(callback) { - if (callback) - process.nextTick(callback); - - if (this._closed) - return; - - this._closed = true; - - this._binding.close(); - - var self = this; - process.nextTick(function() { - self.emit('close'); - }); -}; - -Zlib.prototype._transform = function(chunk, encoding, cb) { - var flushFlag; - var ws = this._writableState; - var ending = ws.ending || ws.ended; - var last = ending && (!chunk || ws.length === chunk.length); - - if (!chunk === null && !Buffer.isBuffer(chunk)) - return cb(new Error('invalid input')); - - // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag. - // If it's explicitly flushing at some other time, then we use - // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression - // goodness. - if (last) - flushFlag = binding.Z_FINISH; - else { - flushFlag = this._flushFlag; - // once we've flushed the last of the queue, stop flushing and - // go back to the normal behavior. - if (chunk.length >= ws.length) { - this._flushFlag = this._opts.flush || binding.Z_NO_FLUSH; - } - } - - var self = this; - this._processChunk(chunk, flushFlag, cb); -}; - -Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { - var availInBefore = chunk && chunk.length; - var availOutBefore = this._chunkSize - this._offset; - var inOff = 0; - - var self = this; - - var async = typeof cb === 'function'; - - if (!async) { - var buffers = []; - var nread = 0; - - var error; - this.on('error', function(er) { - error = er; - }); - - do { - var res = this._binding.writeSync(flushFlag, - chunk, // in - inOff, // in_off - availInBefore, // in_len - this._buffer, // out - this._offset, //out_off - availOutBefore); // out_len - } while (!this._hadError && callback(res[0], res[1])); - - if (this._hadError) { - throw error; - } - - var buf = Buffer.concat(buffers, nread); - this.close(); - - return buf; - } - - var req = this._binding.write(flushFlag, - chunk, // in - inOff, // in_off - availInBefore, // in_len - this._buffer, // out - this._offset, //out_off - availOutBefore); // out_len - - req.buffer = chunk; - req.callback = callback; - - function callback(availInAfter, availOutAfter) { - if (self._hadError) - return; - - var have = availOutBefore - availOutAfter; - assert(have >= 0, 'have should not go down'); - - if (have > 0) { - var out = self._buffer.slice(self._offset, self._offset + have); - self._offset += have; - // serve some output to the consumer. - if (async) { - self.push(out); - } else { - buffers.push(out); - nread += out.length; - } - } - - // exhausted the output buffer, or used all the input create a new one. - if (availOutAfter === 0 || self._offset >= self._chunkSize) { - availOutBefore = self._chunkSize; - self._offset = 0; - self._buffer = new Buffer(self._chunkSize); - } - - if (availOutAfter === 0) { - // Not actually done. Need to reprocess. - // Also, update the availInBefore to the availInAfter value, - // so that if we have to hit it a third (fourth, etc.) time, - // it'll have the correct byte counts. - inOff += (availInBefore - availInAfter); - availInBefore = availInAfter; - - if (!async) - return true; - - var newReq = self._binding.write(flushFlag, - chunk, - inOff, - availInBefore, - self._buffer, - self._offset, - self._chunkSize); - newReq.callback = callback; // this same function - newReq.buffer = chunk; - return; - } - - if (!async) - return false; - - // finished with the chunk. - cb(); - } -}; - -util.inherits(Deflate, Zlib); -util.inherits(Inflate, Zlib); -util.inherits(Gzip, Zlib); -util.inherits(Gunzip, Zlib); -util.inherits(DeflateRaw, Zlib); -util.inherits(InflateRaw, Zlib); -util.inherits(Unzip, Zlib); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer, __webpack_require__(8))) - -/***/ }, -/* 102 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; -/* - * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message - * Digest Algorithm, as defined in RFC 1321. - * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for more info. - */ - -var helpers = __webpack_require__(165); - -/* - * Calculate the MD5 of an array of little-endian words, and a bit length - */ -function core_md5(x, len) -{ - /* append padding */ - x[len >> 5] |= 0x80 << ((len) % 32); - x[(((len + 64) >>> 9) << 4) + 14] = len; - - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - - for(var i = 0; i < x.length; i += 16) - { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - - a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); - d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); - c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); - b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); - a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); - d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); - c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); - b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); - a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); - d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); - c = md5_ff(c, d, a, b, x[i+10], 17, -42063); - b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); - a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); - d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); - c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); - b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); - - a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); - d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); - c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); - b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); - a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); - d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); - c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); - b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); - a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); - d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); - c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); - b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); - a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); - d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); - c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); - b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); - - a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); - d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); - c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); - b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); - a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); - d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); - c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); - b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); - a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); - d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); - c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); - b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); - a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); - d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); - c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); - b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); - - a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); - d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); - c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); - b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); - a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); - d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); - c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); - b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); - a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); - d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); - c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); - b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); - a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); - d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); - c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); - b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); - - a = safe_add(a, olda); - b = safe_add(b, oldb); - c = safe_add(c, oldc); - d = safe_add(d, oldd); - } - return Array(a, b, c, d); - -} - -/* - * These functions implement the four basic operations the algorithm uses. - */ -function md5_cmn(q, a, b, x, s, t) -{ - return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); -} -function md5_ff(a, b, c, d, x, s, t) -{ - return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); -} -function md5_gg(a, b, c, d, x, s, t) -{ - return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); -} -function md5_hh(a, b, c, d, x, s, t) -{ - return md5_cmn(b ^ c ^ d, a, b, x, s, t); -} -function md5_ii(a, b, c, d, x, s, t) -{ - return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); -} - -/* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - */ -function safe_add(x, y) -{ - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); -} - -/* - * Bitwise rotate a 32-bit number to the left. - */ -function bit_rol(num, cnt) -{ - return (num << cnt) | (num >>> (32 - cnt)); -} - -module.exports = function md5(buf) { - return helpers.hash(buf, core_md5, 16); -}; - -/***/ }, -/* 103 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - -var inherits = __webpack_require__(2) -var Hash = __webpack_require__(22) - -var K = [ - 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, - 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, - 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, - 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, - 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, - 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, - 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, - 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, - 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, - 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, - 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, - 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, - 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, - 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, - 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, - 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 -] - -var W = new Array(64) - -function Sha256 () { - this.init() - - this._w = W // new Array(64) - - Hash.call(this, 64, 56) -} - -inherits(Sha256, Hash) - -Sha256.prototype.init = function () { - this._a = 0x6a09e667 - this._b = 0xbb67ae85 - this._c = 0x3c6ef372 - this._d = 0xa54ff53a - this._e = 0x510e527f - this._f = 0x9b05688c - this._g = 0x1f83d9ab - this._h = 0x5be0cd19 - - return this -} - -function ch (x, y, z) { - return z ^ (x & (y ^ z)) -} - -function maj (x, y, z) { - return (x & y) | (z & (x | y)) -} - -function sigma0 (x) { - return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) -} - -function sigma1 (x) { - return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) -} - -function gamma0 (x) { - return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) -} - -function gamma1 (x) { - return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) -} - -Sha256.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - var f = this._f | 0 - var g = this._g | 0 - var h = this._h | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 - - for (var j = 0; j < 64; ++j) { - var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 - var T2 = (sigma0(a) + maj(a, b, c)) | 0 - - h = g - g = f - f = e - e = (d + T1) | 0 - d = c - c = b - b = a - a = (T1 + T2) | 0 - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 - this._f = (f + this._f) | 0 - this._g = (g + this._g) | 0 - this._h = (h + this._h) | 0 -} - -Sha256.prototype._hash = function () { - var H = new Buffer(32) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - H.writeInt32BE(this._h, 28) - - return H -} - -module.exports = Sha256 - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 104 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var inherits = __webpack_require__(2) -var Hash = __webpack_require__(22) - -var K = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 -] - -var W = new Array(160) - -function Sha512 () { - this.init() - this._w = W - - Hash.call(this, 128, 112) -} - -inherits(Sha512, Hash) - -Sha512.prototype.init = function () { - this._ah = 0x6a09e667 - this._bh = 0xbb67ae85 - this._ch = 0x3c6ef372 - this._dh = 0xa54ff53a - this._eh = 0x510e527f - this._fh = 0x9b05688c - this._gh = 0x1f83d9ab - this._hh = 0x5be0cd19 - - this._al = 0xf3bcc908 - this._bl = 0x84caa73b - this._cl = 0xfe94f82b - this._dl = 0x5f1d36f1 - this._el = 0xade682d1 - this._fl = 0x2b3e6c1f - this._gl = 0xfb41bd6b - this._hl = 0x137e2179 - - return this -} - -function Ch (x, y, z) { - return z ^ (x & (y ^ z)) -} - -function maj (x, y, z) { - return (x & y) | (z & (x | y)) -} - -function sigma0 (x, xl) { - return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) -} - -function sigma1 (x, xl) { - return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) -} - -function Gamma0 (x, xl) { - return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) -} - -function Gamma0l (x, xl) { - return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) -} - -function Gamma1 (x, xl) { - return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) -} - -function Gamma1l (x, xl) { - return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) -} - -function getCarry (a, b) { - return (a >>> 0) < (b >>> 0) ? 1 : 0 -} - -Sha512.prototype._update = function (M) { - var W = this._w - - var ah = this._ah | 0 - var bh = this._bh | 0 - var ch = this._ch | 0 - var dh = this._dh | 0 - var eh = this._eh | 0 - var fh = this._fh | 0 - var gh = this._gh | 0 - var hh = this._hh | 0 - - var al = this._al | 0 - var bl = this._bl | 0 - var cl = this._cl | 0 - var dl = this._dl | 0 - var el = this._el | 0 - var fl = this._fl | 0 - var gl = this._gl | 0 - var hl = this._hl | 0 - - for (var i = 0; i < 32; i += 2) { - W[i] = M.readInt32BE(i * 4) - W[i + 1] = M.readInt32BE(i * 4 + 4) - } - for (; i < 160; i += 2) { - var xh = W[i - 15 * 2] - var xl = W[i - 15 * 2 + 1] - var gamma0 = Gamma0(xh, xl) - var gamma0l = Gamma0l(xl, xh) - - xh = W[i - 2 * 2] - xl = W[i - 2 * 2 + 1] - var gamma1 = Gamma1(xh, xl) - var gamma1l = Gamma1l(xl, xh) - - // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] - var Wi7h = W[i - 7 * 2] - var Wi7l = W[i - 7 * 2 + 1] - - var Wi16h = W[i - 16 * 2] - var Wi16l = W[i - 16 * 2 + 1] - - var Wil = (gamma0l + Wi7l) | 0 - var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 - Wil = (Wil + gamma1l) | 0 - Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 - Wil = (Wil + Wi16l) | 0 - Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 - - W[i] = Wih - W[i + 1] = Wil - } - - for (var j = 0; j < 160; j += 2) { - Wih = W[j] - Wil = W[j + 1] - - var majh = maj(ah, bh, ch) - var majl = maj(al, bl, cl) - - var sigma0h = sigma0(ah, al) - var sigma0l = sigma0(al, ah) - var sigma1h = sigma1(eh, el) - var sigma1l = sigma1(el, eh) - - // t1 = h + sigma1 + ch + K[j] + W[j] - var Kih = K[j] - var Kil = K[j + 1] - - var chh = Ch(eh, fh, gh) - var chl = Ch(el, fl, gl) - - var t1l = (hl + sigma1l) | 0 - var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 - t1l = (t1l + chl) | 0 - t1h = (t1h + chh + getCarry(t1l, chl)) | 0 - t1l = (t1l + Kil) | 0 - t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 - t1l = (t1l + Wil) | 0 - t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 - - // t2 = sigma0 + maj - var t2l = (sigma0l + majl) | 0 - var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 - - hh = gh - hl = gl - gh = fh - gl = fl - fh = eh - fl = el - el = (dl + t1l) | 0 - eh = (dh + t1h + getCarry(el, dl)) | 0 - dh = ch - dl = cl - ch = bh - cl = bl - bh = ah - bl = al - al = (t1l + t2l) | 0 - ah = (t1h + t2h + getCarry(al, t1l)) | 0 - } - - this._al = (this._al + al) | 0 - this._bl = (this._bl + bl) | 0 - this._cl = (this._cl + cl) | 0 - this._dl = (this._dl + dl) | 0 - this._el = (this._el + el) | 0 - this._fl = (this._fl + fl) | 0 - this._gl = (this._gl + gl) | 0 - this._hl = (this._hl + hl) | 0 - - this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 - this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 - this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 - this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0 - this._eh = (this._eh + eh + getCarry(this._el, el)) | 0 - this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0 - this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 - this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 -} - -Sha512.prototype._hash = function () { - var H = new Buffer(64) - - function writeInt64BE (h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._ah, this._al, 0) - writeInt64BE(this._bh, this._bl, 8) - writeInt64BE(this._ch, this._cl, 16) - writeInt64BE(this._dh, this._dl, 24) - writeInt64BE(this._eh, this._el, 32) - writeInt64BE(this._fh, this._fl, 40) - writeInt64BE(this._gh, this._gl, 48) - writeInt64BE(this._hh, this._hl, 56) - - return H -} - -module.exports = Sha512 - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 105 */ -/***/ function(module, exports, __webpack_require__) { - -var randomBytes = __webpack_require__(30); -module.exports = findPrime; -findPrime.simpleSieve = simpleSieve; -findPrime.fermatTest = fermatTest; -var BN = __webpack_require__(7); -var TWENTYFOUR = new BN(24); -var MillerRabin = __webpack_require__(107); -var millerRabin = new MillerRabin(); -var ONE = new BN(1); -var TWO = new BN(2); -var FIVE = new BN(5); -var SIXTEEN = new BN(16); -var EIGHT = new BN(8); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var ELEVEN = new BN(11); -var FOUR = new BN(4); -var TWELVE = new BN(12); -var primes = null; - -function _getPrimes() { - if (primes !== null) - return primes; - - var limit = 0x100000; - var res = []; - res[0] = 2; - for (var i = 1, k = 3; k < limit; k += 2) { - var sqrt = Math.ceil(Math.sqrt(k)); - for (var j = 0; j < i && res[j] <= sqrt; j++) - if (k % res[j] === 0) - break; - - if (i !== j && res[j] <= sqrt) - continue; - - res[i++] = k; - } - primes = res; - return res; -} - -function simpleSieve(p) { - var primes = _getPrimes(); - - for (var i = 0; i < primes.length; i++) - if (p.modn(primes[i]) === 0) { - if (p.cmpn(primes[i]) === 0) { - return true; - } else { - return false; - } - } - - return true; -} - -function fermatTest(p) { - var red = BN.mont(p); - return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; -} - -function findPrime(bits, gen) { - if (bits < 16) { - // this is what openssl does - if (gen === 2 || gen === 5) { - return new BN([0x8c, 0x7b]); - } else { - return new BN([0x8c, 0x27]); - } - } - gen = new BN(gen); - - var num, n2; - - while (true) { - num = new BN(randomBytes(Math.ceil(bits / 8))); - while (num.bitLength() > bits) { - num.ishrn(1); - } - if (num.isEven()) { - num.iadd(ONE); - } - if (!num.testn(1)) { - num.iadd(TWO); - } - if (!gen.cmp(TWO)) { - while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { - num.iadd(FOUR); - } - } else if (!gen.cmp(FIVE)) { - while (num.mod(TEN).cmp(THREE)) { - num.iadd(FOUR); - } - } - n2 = num.shrn(1); - if (simpleSieve(n2) && simpleSieve(num) && - fermatTest(n2) && fermatTest(num) && - millerRabin.test(n2) && millerRabin.test(num)) { - return num; - } - } - -} - - -/***/ }, -/* 106 */ +/* 58 */ /***/ function(module, exports) { var toString = {}.toString; @@ -20988,218 +11652,7 @@ module.exports = Array.isArray || function (arr) { /***/ }, -/* 107 */ -/***/ function(module, exports, __webpack_require__) { - -var bn = __webpack_require__(7); -var brorand = __webpack_require__(90); - -function MillerRabin(rand) { - this.rand = rand || new brorand.Rand(); -} -module.exports = MillerRabin; - -MillerRabin.create = function create(rand) { - return new MillerRabin(rand); -}; - -MillerRabin.prototype._rand = function _rand(n) { - var len = n.bitLength(); - var buf = this.rand.generate(Math.ceil(len / 8)); - - // Set low bits - buf[0] |= 3; - - // Mask high bits - var mask = len & 0x7; - if (mask !== 0) - buf[buf.length - 1] >>= 7 - mask; - - return new bn(buf); -} - -MillerRabin.prototype.test = function test(n, k, cb) { - var len = n.bitLength(); - var red = bn.mont(n); - var rone = new bn(1).toRed(red); - - if (!k) - k = Math.max(1, (len / 48) | 0); - - // Find d and s, (n - 1) = (2 ^ s) * d; - var n1 = n.subn(1); - var n2 = n1.subn(1); - for (var s = 0; !n1.testn(s); s++) {} - var d = n.shrn(s); - - var rn1 = n1.toRed(red); - - var prime = true; - for (; k > 0; k--) { - var a = this._rand(n2); - if (cb) - cb(a); - - var x = a.toRed(red).redPow(d); - if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) - continue; - - for (var i = 1; i < s; i++) { - x = x.redSqr(); - - if (x.cmp(rone) === 0) - return false; - if (x.cmp(rn1) === 0) - break; - } - - if (i === s) - return false; - } - - return prime; -}; - -MillerRabin.prototype.getDivisor = function getDivisor(n, k) { - var len = n.bitLength(); - var red = bn.mont(n); - var rone = new bn(1).toRed(red); - - if (!k) - k = Math.max(1, (len / 48) | 0); - - // Find d and s, (n - 1) = (2 ^ s) * d; - var n1 = n.subn(1); - var n2 = n1.subn(1); - for (var s = 0; !n1.testn(s); s++) {} - var d = n.shrn(s); - - var rn1 = n1.toRed(red); - - for (; k > 0; k--) { - var a = this._rand(n2); - - var g = n.gcd(a); - if (g.cmpn(1) !== 0) - return g; - - var x = a.toRed(red).redPow(d); - if (x.cmp(rone) === 0 || x.cmp(rn1) === 0) - continue; - - for (var i = 1; i < s; i++) { - x = x.redSqr(); - - if (x.cmp(rone) === 0) - return x.fromRed().subn(1).gcd(n); - if (x.cmp(rn1) === 0) - break; - } - - if (i === s) { - x = x.redSqr(); - return x.fromRed().subn(1).gcd(n); - } - } - - return false; -}; - - -/***/ }, -/* 108 */ -/***/ function(module, exports, __webpack_require__) { - -/*! - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var fs = __webpack_require__(13); - -function Options(defaults) { - var internalValues = {}; - var values = this.value = {}; - Object.keys(defaults).forEach(function(key) { - internalValues[key] = defaults[key]; - Object.defineProperty(values, key, { - get: function() { return internalValues[key]; }, - configurable: false, - enumerable: true - }); - }); - this.reset = function() { - Object.keys(defaults).forEach(function(key) { - internalValues[key] = defaults[key]; - }); - return this; - }; - this.merge = function(options, required) { - options = options || {}; - if (Object.prototype.toString.call(required) === '[object Array]') { - var missing = []; - for (var i = 0, l = required.length; i < l; ++i) { - var key = required[i]; - if (!(key in options)) { - missing.push(key); - } - } - if (missing.length > 0) { - if (missing.length > 1) { - throw new Error('options ' + - missing.slice(0, missing.length - 1).join(', ') + ' and ' + - missing[missing.length - 1] + ' must be defined'); - } - else throw new Error('option ' + missing[0] + ' must be defined'); - } - } - Object.keys(options).forEach(function(key) { - if (key in internalValues) { - internalValues[key] = options[key]; - } - }); - return this; - }; - this.copy = function(keys) { - var obj = {}; - Object.keys(defaults).forEach(function(key) { - if (keys.indexOf(key) !== -1) { - obj[key] = values[key]; - } - }); - return obj; - }; - this.read = function(filename, cb) { - if (typeof cb == 'function') { - var self = this; - fs.readFile(filename, function(error, data) { - if (error) return cb(error); - var conf = JSON.parse(data); - self.merge(conf); - cb(); - }); - } - else { - var conf = JSON.parse(fs.readFileSync(filename)); - this.merge(conf); - } - return this; - }; - this.isDefined = function(key) { - return typeof values[key] != 'undefined'; - }; - this.isDefinedAndNonNull = function(key) { - return typeof values[key] != 'undefined' && values[key] !== null; - }; - Object.freeze(values); - Object.freeze(this); -} - -module.exports = Options; - - -/***/ }, -/* 109 */ +/* 59 */ /***/ function(module, exports) { "use strict"; @@ -21238,7 +11691,7 @@ module.exports = adler32; /***/ }, -/* 110 */ +/* 60 */ /***/ function(module, exports) { "use strict"; @@ -21286,7 +11739,7 @@ module.exports = crc32; /***/ }, -/* 111 */ +/* 61 */ /***/ function(module, exports) { "use strict"; @@ -21306,133 +11759,7 @@ module.exports = { /***/ }, -/* 112 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process, Buffer) {var createHmac = __webpack_require__(53) -var checkParameters = __webpack_require__(214) - -exports.pbkdf2 = function (password, salt, iterations, keylen, digest, callback) { - if (typeof digest === 'function') { - callback = digest - digest = undefined - } - - checkParameters(iterations, keylen) - if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2') - - setTimeout(function () { - callback(null, exports.pbkdf2Sync(password, salt, iterations, keylen, digest)) - }) -} - -var defaultEncoding -if (process.browser) { - defaultEncoding = 'utf-8' -} else { - var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10) - - defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary' -} - -exports.pbkdf2Sync = function (password, salt, iterations, keylen, digest) { - if (!Buffer.isBuffer(password)) password = new Buffer(password, defaultEncoding) - if (!Buffer.isBuffer(salt)) salt = new Buffer(salt, defaultEncoding) - - checkParameters(iterations, keylen) - - digest = digest || 'sha1' - - var hLen - var l = 1 - var DK = new Buffer(keylen) - var block1 = new Buffer(salt.length + 4) - salt.copy(block1, 0, 0, salt.length) - - var r - var T - - for (var i = 1; i <= l; i++) { - block1.writeUInt32BE(i, salt.length) - var U = createHmac(digest, password).update(block1).digest() - - if (!hLen) { - hLen = U.length - T = new Buffer(hLen) - l = Math.ceil(keylen / hLen) - r = keylen - (l - 1) * hLen - } - - U.copy(T, 0, 0, hLen) - - for (var j = 1; j < iterations; j++) { - U = createHmac(digest, password).update(U).digest() - for (var k = 0; k < hLen; k++) T[k] ^= U[k] - } - - var destPos = (i - 1) * hLen - var len = (i === l ? r : hLen) - T.copy(DK, destPos, 0, len) - } - - return DK -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(0).Buffer)) - -/***/ }, -/* 113 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(21); -module.exports = function (seed, len) { - var t = new Buffer(''); - var i = 0, c; - while (t.length < len) { - c = i2ops(i++); - t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]); - } - return t.slice(0, len); -}; - -function i2ops(c) { - var out = new Buffer(4); - out.writeUInt32BE(c,0); - return out; -} -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 114 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(7); -function withPublic(paddedMsg, key) { - return new Buffer(paddedMsg - .toRed(bn.mont(key.modulus)) - .redPow(new bn(key.publicExponent)) - .fromRed() - .toArray()); -} - -module.exports = withPublic; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 115 */ -/***/ function(module, exports) { - -module.exports = function xor(a, b) { - var len = a.length; - var i = -1; - while (++i < len) { - a[i] ^= b[i]; - } - return a -}; - -/***/ }, -/* 116 */ +/* 62 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -21444,11 +11771,11 @@ module.exports = function xor(a, b) { module.exports = PassThrough; -var Transform = __webpack_require__(57); +var Transform = __webpack_require__(33); /**/ -var util = __webpack_require__(28); -util.inherits = __webpack_require__(2); +var util = __webpack_require__(16); +util.inherits = __webpack_require__(12); /**/ util.inherits(PassThrough, Transform); @@ -21464,7 +11791,7 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { }; /***/ }, -/* 117 */ +/* 63 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -21473,17 +11800,17 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { module.exports = Readable; /**/ -var processNextTick = __webpack_require__(56); +var processNextTick = __webpack_require__(32); /**/ /**/ -var isArray = __webpack_require__(106); +var isArray = __webpack_require__(58); /**/ Readable.ReadableState = ReadableState; /**/ -var EE = __webpack_require__(5).EventEmitter; +var EE = __webpack_require__(4).EventEmitter; var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; @@ -21494,25 +11821,25 @@ var EElistenerCount = function (emitter, type) { var Stream; (function () { try { - Stream = __webpack_require__(11); + Stream = __webpack_require__(25); } catch (_) {} finally { - if (!Stream) Stream = __webpack_require__(5).EventEmitter; + if (!Stream) Stream = __webpack_require__(4).EventEmitter; } })(); /**/ -var Buffer = __webpack_require__(0).Buffer; +var Buffer = __webpack_require__(5).Buffer; /**/ -var bufferShim = __webpack_require__(52); +var bufferShim = __webpack_require__(31); /**/ /**/ -var util = __webpack_require__(28); -util.inherits = __webpack_require__(2); +var util = __webpack_require__(16); +util.inherits = __webpack_require__(12); /**/ /**/ -var debugUtil = __webpack_require__(338); +var debugUtil = __webpack_require__(194); var debug = void 0; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); @@ -21521,7 +11848,7 @@ if (debugUtil && debugUtil.debuglog) { } /**/ -var BufferList = __webpack_require__(223); +var BufferList = __webpack_require__(94); var StringDecoder; util.inherits(Readable, Stream); @@ -21540,7 +11867,7 @@ function prependListener(emitter, event, fn) { var Duplex; function ReadableState(options, stream) { - Duplex = Duplex || __webpack_require__(17); + Duplex = Duplex || __webpack_require__(10); options = options || {}; @@ -21602,7 +11929,7 @@ function ReadableState(options, stream) { this.decoder = null; this.encoding = null; if (options.encoding) { - if (!StringDecoder) StringDecoder = __webpack_require__(59).StringDecoder; + if (!StringDecoder) StringDecoder = __webpack_require__(65).StringDecoder; this.decoder = new StringDecoder(options.encoding); this.encoding = options.encoding; } @@ -21610,7 +11937,7 @@ function ReadableState(options, stream) { var Duplex; function Readable(options) { - Duplex = Duplex || __webpack_require__(17); + Duplex = Duplex || __webpack_require__(10); if (!(this instanceof Readable)) return new Readable(options); @@ -21713,7 +12040,7 @@ function needMoreData(state) { // backwards compatibility. Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = __webpack_require__(59).StringDecoder; + if (!StringDecoder) StringDecoder = __webpack_require__(65).StringDecoder; this._readableState.decoder = new StringDecoder(enc); this._readableState.encoding = enc; return this; @@ -22405,17 +12732,244 @@ function indexOf(xs, x) { } return -1; } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 118 */ +/* 64 */ /***/ function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(57) +module.exports = __webpack_require__(33) /***/ }, -/* 119 */ +/* 65 */ +/***/ function(module, exports, __webpack_require__) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var Buffer = __webpack_require__(5).Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} + + +/***/ }, +/* 66 */ /***/ function(module, exports) { /** @@ -22434,7 +12988,7 @@ module.exports = isObject; /***/ }, -/* 120 */ +/* 67 */ /***/ function(module, exports, __webpack_require__) { (function(nacl) { @@ -24813,7 +15367,7 @@ nacl.setPRNG = function(fn) { }); } else if (true) { // Node.js. - crypto = __webpack_require__(339); + crypto = __webpack_require__(195); if (crypto && crypto.randomBytes) { nacl.setPRNG(function(x, n) { var i, v = crypto.randomBytes(n); @@ -24828,2439 +15382,615 @@ nacl.setPRNG = function(fn) { /***/ }, -/* 121 */ -/***/ function(module, exports) { - -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - configurable: false, - get: function() { return module.l; } - }); - Object.defineProperty(module, "id", { - enumerable: true, - configurable: false, - get: function() { return module.i; } - }); - module.webpackPolyfill = 1; - } - return module; -} - - -/***/ }, -/* 122 */ +/* 68 */ /***/ function(module, exports, __webpack_require__) { -"use strict"; -'use strict' +/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(30) -exports.createHash = exports.Hash = __webpack_require__(21) -exports.createHmac = exports.Hmac = __webpack_require__(53) - -var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(__webpack_require__(99))) -exports.getHashes = function () { - return hashes -} - -var p = __webpack_require__(112) -exports.pbkdf2 = p.pbkdf2 -exports.pbkdf2Sync = p.pbkdf2Sync - -var aes = __webpack_require__(154) -;[ - 'Cipher', - 'createCipher', - 'Cipheriv', - 'createCipheriv', - 'Decipher', - 'createDecipher', - 'Decipheriv', - 'createDecipheriv', - 'getCiphers', - 'listCiphers' -].forEach(function (key) { - exports[key] = aes[key] -}) - -var dh = __webpack_require__(177) -;[ - 'DiffieHellmanGroup', - 'createDiffieHellmanGroup', - 'getDiffieHellman', - 'createDiffieHellman', - 'DiffieHellman' -].forEach(function (key) { - exports[key] = dh[key] -}) - -var sign = __webpack_require__(157) -;[ - 'createSign', - 'Sign', - 'createVerify', - 'Verify' -].forEach(function (key) { - exports[key] = sign[key] -}) - -exports.createECDH = __webpack_require__(164) - -var publicEncrypt = __webpack_require__(215) - -;[ - 'publicEncrypt', - 'privateEncrypt', - 'publicDecrypt', - 'privateDecrypt' -].forEach(function (key) { - exports[key] = publicEncrypt[key] -}) - -// the least I can do is make error messages for the rest of the node.js/crypto api. -;[ - 'createCredentials' -].forEach(function (name) { - exports[name] = function () { - throw new Error([ - 'sorry, ' + name + ' is not implemented yet', - 'we accept pull requests', - 'https://github.com/crypto-browserify/crypto-browserify' - ].join('\n')) - } -}) - - -/***/ }, -/* 123 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var WS = module.exports = __webpack_require__(129); - -WS.Server = __webpack_require__(246); -WS.Sender = __webpack_require__(128); -WS.Receiver = __webpack_require__(127); - -/** - * Create a new WebSocket server. - * - * @param {Object} options Server options - * @param {Function} fn Optional connection listener. - * @returns {WS.Server} - * @api public - */ -WS.createServer = function createServer(options, fn) { - var server = new WS.Server(options); - - if (typeof fn === 'function') { - server.on('connection', fn); +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); } - return server; -}; - -/** - * Create a new WebSocket connection. - * - * @param {String} address The URL/address we need to connect to. - * @param {Function} fn Open listener. - * @returns {WS} - * @api public - */ -WS.connect = WS.createConnection = function connect(address, fn) { - var client = new WS(address); - - if (typeof fn === 'function') { - client.on('open', fn); - } - - return client; -}; - - -/***/ }, -/* 124 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -try { - module.exports = __webpack_require__(162); -} catch (e) { - module.exports = __webpack_require__(241); -} - - -/***/ }, -/* 125 */ -/***/ function(module, exports) { - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -module.exports = { - isValidErrorCode: function(code) { - return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) || - (code >= 3000 && code <= 4999); - }, - 1000: 'normal', - 1001: 'going away', - 1002: 'protocol error', - 1003: 'unsupported data', - 1004: 'reserved', - 1005: 'reserved for extensions', - 1006: 'reserved for extensions', - 1007: 'inconsistent or invalid data', - 1008: 'policy violation', - 1009: 'message too big', - 1010: 'extension handshake missing', - 1011: 'an unexpected condition prevented the request from being fulfilled', -}; - -/***/ }, -/* 126 */ -/***/ function(module, exports, __webpack_require__) { - - -var util = __webpack_require__(10); - -/** - * Module exports. - */ - -exports.parse = parse; -exports.format = format; - -/** - * Parse extensions header value - */ - -function parse(value) { - value = value || ''; - - var extensions = {}; - - value.split(',').forEach(function(v) { - var params = v.split(';'); - var token = params.shift().trim(); - var paramsList = extensions[token] = extensions[token] || []; - var parsedParams = {}; - - params.forEach(function(param) { - var parts = param.trim().split('='); - var key = parts[0]; - var value = parts[1]; - if (typeof value === 'undefined') { - value = true; - } else { - // unquote value - if (value[0] === '"') { - value = value.slice(1); + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; } - if (value[value.length - 1] === '"') { - value = value.slice(0, value.length - 1); - } - } - (parsedParams[key] = parsedParams[key] || []).push(value); - }); - - paramsList.push(parsedParams); + default: + return x; + } }); - - return extensions; -} - -/** - * Format extensions header value - */ - -function format(value) { - return Object.keys(value).map(function(token) { - var paramsList = value[token]; - if (!util.isArray(paramsList)) { - paramsList = [paramsList]; - } - return paramsList.map(function(params) { - return [token].concat(Object.keys(params).map(function(k) { - var p = params[k]; - if (!util.isArray(p)) p = [p]; - return p.map(function(v) { - return v === true ? k : k + '=' + v; - }).join('; '); - })).join('; '); - }).join(', '); - }).join(', '); -} - - -/***/ }, -/* 127 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = __webpack_require__(10) - , Validation = __webpack_require__(245).Validation - , ErrorCodes = __webpack_require__(125) - , BufferPool = __webpack_require__(240) - , bufferUtil = __webpack_require__(124).BufferUtil - , PerMessageDeflate = __webpack_require__(44); - -/** - * HyBi Receiver implementation - */ - -function Receiver (extensions,maxPayload) { - if (this instanceof Receiver === false) { - throw new TypeError("Classes can't be function-called"); - } - if(typeof extensions==='number'){ - maxPayload=extensions; - extensions={}; - } - - - // memory pool for fragmented messages - var fragmentedPoolPrevUsed = -1; - this.fragmentedBufferPool = new BufferPool(1024, function(db, length) { - return db.used + length; - }, function(db) { - return fragmentedPoolPrevUsed = fragmentedPoolPrevUsed >= 0 ? - Math.ceil((fragmentedPoolPrevUsed + db.used) / 2) : - db.used; - }); - - // memory pool for unfragmented messages - var unfragmentedPoolPrevUsed = -1; - this.unfragmentedBufferPool = new BufferPool(1024, function(db, length) { - return db.used + length; - }, function(db) { - return unfragmentedPoolPrevUsed = unfragmentedPoolPrevUsed >= 0 ? - Math.ceil((unfragmentedPoolPrevUsed + db.used) / 2) : - db.used; - }); - this.extensions = extensions || {}; - this.maxPayload = maxPayload || 0; - this.currentPayloadLength = 0; - this.state = { - activeFragmentedOperation: null, - lastFragment: false, - masked: false, - opcode: 0, - fragmentedOperation: false - }; - this.overflow = []; - this.headerBuffer = new Buffer(10); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - this.currentMessage = []; - this.currentMessageLength = 0; - this.messageHandlers = []; - this.expectHeader(2, this.processPacket); - this.dead = false; - this.processing = false; - - this.onerror = function() {}; - this.ontext = function() {}; - this.onbinary = function() {}; - this.onclose = function() {}; - this.onping = function() {}; - this.onpong = function() {}; -} - -module.exports = Receiver; - -/** - * Add new data to the parser. - * - * @api public - */ - -Receiver.prototype.add = function(data) { - if (this.dead) return; - var dataLength = data.length; - if (dataLength == 0) return; - if (this.expectBuffer == null) { - this.overflow.push(data); - return; - } - var toRead = Math.min(dataLength, this.expectBuffer.length - this.expectOffset); - fastCopy(toRead, data, this.expectBuffer, this.expectOffset); - this.expectOffset += toRead; - if (toRead < dataLength) { - this.overflow.push(data.slice(toRead)); - } - while (this.expectBuffer && this.expectOffset == this.expectBuffer.length) { - var bufferForHandler = this.expectBuffer; - this.expectBuffer = null; - this.expectOffset = 0; - this.expectHandler.call(this, bufferForHandler); - } -}; - -/** - * Releases all resources used by the receiver. - * - * @api public - */ - -Receiver.prototype.cleanup = function() { - this.dead = true; - this.overflow = null; - this.headerBuffer = null; - this.expectBuffer = null; - this.expectHandler = null; - this.unfragmentedBufferPool = null; - this.fragmentedBufferPool = null; - this.state = null; - this.currentMessage = null; - this.onerror = null; - this.ontext = null; - this.onbinary = null; - this.onclose = null; - this.onping = null; - this.onpong = null; -}; - -/** - * Waits for a certain amount of header bytes to be available, then fires a callback. - * - * @api private - */ - -Receiver.prototype.expectHeader = function(length, handler) { - if (length == 0) { - handler(null); - return; - } - this.expectBuffer = this.headerBuffer.slice(this.expectOffset, this.expectOffset + length); - this.expectHandler = handler; - var toRead = length; - while (toRead > 0 && this.overflow.length > 0) { - var fromOverflow = this.overflow.pop(); - if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); - var read = Math.min(fromOverflow.length, toRead); - fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); - this.expectOffset += read; - toRead -= read; - } -}; - -/** - * Waits for a certain amount of data bytes to be available, then fires a callback. - * - * @api private - */ - -Receiver.prototype.expectData = function(length, handler) { - if (length == 0) { - handler(null); - return; - } - this.expectBuffer = this.allocateFromPool(length, this.state.fragmentedOperation); - this.expectHandler = handler; - var toRead = length; - while (toRead > 0 && this.overflow.length > 0) { - var fromOverflow = this.overflow.pop(); - if (toRead < fromOverflow.length) this.overflow.push(fromOverflow.slice(toRead)); - var read = Math.min(fromOverflow.length, toRead); - fastCopy(read, fromOverflow, this.expectBuffer, this.expectOffset); - this.expectOffset += read; - toRead -= read; - } -}; - -/** - * Allocates memory from the buffer pool. - * - * @api private - */ - -Receiver.prototype.allocateFromPool = function(length, isFragmented) { - return (isFragmented ? this.fragmentedBufferPool : this.unfragmentedBufferPool).get(length); -}; - -/** - * Start processing a new packet. - * - * @api private - */ - -Receiver.prototype.processPacket = function (data) { - if (this.extensions[PerMessageDeflate.extensionName]) { - if ((data[0] & 0x30) != 0) { - this.error('reserved fields (2, 3) must be empty', 1002); - return; - } - } else { - if ((data[0] & 0x70) != 0) { - this.error('reserved fields must be empty', 1002); - return; - } - } - this.state.lastFragment = (data[0] & 0x80) == 0x80; - this.state.masked = (data[1] & 0x80) == 0x80; - var compressed = (data[0] & 0x40) == 0x40; - var opcode = data[0] & 0xf; - if (opcode === 0) { - if (compressed) { - this.error('continuation frame cannot have the Per-message Compressed bits', 1002); - return; - } - // continuation frame - this.state.fragmentedOperation = true; - this.state.opcode = this.state.activeFragmentedOperation; - if (!(this.state.opcode == 1 || this.state.opcode == 2)) { - this.error('continuation frame cannot follow current opcode', 1002); - return; - } - } - else { - if (opcode < 3 && this.state.activeFragmentedOperation != null) { - this.error('data frames after the initial data frame must have opcode 0', 1002); - return; - } - if (opcode >= 8 && compressed) { - this.error('control frames cannot have the Per-message Compressed bits', 1002); - return; - } - this.state.compressed = compressed; - this.state.opcode = opcode; - if (this.state.lastFragment === false) { - this.state.fragmentedOperation = true; - this.state.activeFragmentedOperation = opcode; - } - else this.state.fragmentedOperation = false; - } - var handler = opcodes[this.state.opcode]; - if (typeof handler == 'undefined') this.error('no handler for opcode ' + this.state.opcode, 1002); - else { - handler.start.call(this, data); - } -}; - -/** - * Endprocessing a packet. - * - * @api private - */ - -Receiver.prototype.endPacket = function() { - if (this.dead) return; - if (!this.state.fragmentedOperation) this.unfragmentedBufferPool.reset(true); - else if (this.state.lastFragment) this.fragmentedBufferPool.reset(true); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - if (this.state.lastFragment && this.state.opcode === this.state.activeFragmentedOperation) { - // end current fragmented operation - this.state.activeFragmentedOperation = null; - } - this.currentPayloadLength = 0; - this.state.lastFragment = false; - this.state.opcode = this.state.activeFragmentedOperation != null ? this.state.activeFragmentedOperation : 0; - this.state.masked = false; - this.expectHeader(2, this.processPacket); -}; - -/** - * Reset the parser state. - * - * @api private - */ - -Receiver.prototype.reset = function() { - if (this.dead) return; - this.state = { - activeFragmentedOperation: null, - lastFragment: false, - masked: false, - opcode: 0, - fragmentedOperation: false - }; - this.fragmentedBufferPool.reset(true); - this.unfragmentedBufferPool.reset(true); - this.expectOffset = 0; - this.expectBuffer = null; - this.expectHandler = null; - this.overflow = []; - this.currentMessage = []; - this.currentMessageLength = 0; - this.messageHandlers = []; - this.currentPayloadLength = 0; -}; - -/** - * Unmask received data. - * - * @api private - */ - -Receiver.prototype.unmask = function (mask, buf, binary) { - if (mask != null && buf != null) bufferUtil.unmask(buf, mask); - if (binary) return buf; - return buf != null ? buf.toString('utf8') : ''; -}; - -/** - * Handles an error - * - * @api private - */ - -Receiver.prototype.error = function (reason, protocolErrorCode) { - if (this.dead) return; - this.reset(); - if(typeof reason == 'string'){ - this.onerror(new Error(reason), protocolErrorCode); - } - else if(reason.constructor == Error){ - this.onerror(reason, protocolErrorCode); - } - else{ - this.onerror(new Error("An error occured"),protocolErrorCode); - } - return this; -}; - -/** - * Execute message handler buffers - * - * @api private - */ - -Receiver.prototype.flush = function() { - if (this.processing || this.dead) return; - - var handler = this.messageHandlers.shift(); - if (!handler) return; - - this.processing = true; - var self = this; - - handler(function() { - self.processing = false; - self.flush(); - }); -}; - -/** - * Apply extensions to message - * - * @api private - */ - -Receiver.prototype.applyExtensions = function(messageBuffer, fin, compressed, callback) { - var self = this; - if (compressed) { - this.extensions[PerMessageDeflate.extensionName].decompress(messageBuffer, fin, function(err, buffer) { - if (self.dead) return; - if (err) { - callback(new Error('invalid compressed data')); - return; - } - callback(null, buffer); - }); - } else { - callback(null, messageBuffer); - } -}; - -/** -* Checks payload size, disconnects socket when it exceeds maxPayload -* -* @api private -*/ -Receiver.prototype.maxPayloadExceeded = function(length) { - if (this.maxPayload=== undefined || this.maxPayload === null || this.maxPayload < 1) { - return false; - } - var fullLength = this.currentPayloadLength + length; - if (fullLength < this.maxPayload) { - this.currentPayloadLength = fullLength; - return false; - } - this.error('payload cannot exceed ' + this.maxPayload + ' bytes', 1009); - this.messageBuffer=[]; - this.cleanup(); - - return true; -}; - -/** - * Buffer utilities - */ - -function readUInt16BE(start) { - return (this[start]<<8) + - this[start+1]; -} - -function readUInt32BE(start) { - return (this[start]<<24) + - (this[start+1]<<16) + - (this[start+2]<<8) + - this[start+3]; -} - -function fastCopy(length, srcBuffer, dstBuffer, dstOffset) { - switch (length) { - default: srcBuffer.copy(dstBuffer, dstOffset, 0, length); break; - case 16: dstBuffer[dstOffset+15] = srcBuffer[15]; - case 15: dstBuffer[dstOffset+14] = srcBuffer[14]; - case 14: dstBuffer[dstOffset+13] = srcBuffer[13]; - case 13: dstBuffer[dstOffset+12] = srcBuffer[12]; - case 12: dstBuffer[dstOffset+11] = srcBuffer[11]; - case 11: dstBuffer[dstOffset+10] = srcBuffer[10]; - case 10: dstBuffer[dstOffset+9] = srcBuffer[9]; - case 9: dstBuffer[dstOffset+8] = srcBuffer[8]; - case 8: dstBuffer[dstOffset+7] = srcBuffer[7]; - case 7: dstBuffer[dstOffset+6] = srcBuffer[6]; - case 6: dstBuffer[dstOffset+5] = srcBuffer[5]; - case 5: dstBuffer[dstOffset+4] = srcBuffer[4]; - case 4: dstBuffer[dstOffset+3] = srcBuffer[3]; - case 3: dstBuffer[dstOffset+2] = srcBuffer[2]; - case 2: dstBuffer[dstOffset+1] = srcBuffer[1]; - case 1: dstBuffer[dstOffset] = srcBuffer[0]; - } -} - -function clone(obj) { - var cloned = {}; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - cloned[k] = obj[k]; - } - } - return cloned; -} - -/** - * Opcode handlers - */ - -var opcodes = { - // text - '1': { - start: function(data) { - var self = this; - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - if (self.maxPayloadExceeded(firstLength)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, firstLength); - } - else if (firstLength == 126) { - self.expectHeader(2, function(data) { - var length = readUInt16BE.call(data, 0); - if (self.maxPayloadExceeded(length)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, length); - }); - } - else if (firstLength == 127) { - self.expectHeader(8, function(data) { - if (readUInt32BE.call(data, 0) != 0) { - self.error('packets with length spanning more than 32 bit is currently not supported', 1008); - return; - } - var length = readUInt32BE.call(data, 4); - if (self.maxPayloadExceeded(length)){ - self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['1'].getData.call(self, readUInt32BE.call(data, 4)); - }); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['1'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['1'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - var packet = this.unmask(mask, data, true) || new Buffer(0); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { - if (err) { - if(err.type===1009){ - return self.error('Maximumpayload exceeded in compressed text message. Aborting...', 1009); - } - return self.error(err.message, 1007); - } - if (buffer != null) { - if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ - self.currentMessage.push(buffer); - } - else{ - self.currentMessage=null; - self.currentMessage = []; - self.currentMessageLength = 0; - self.error(new Error('Maximum payload exceeded. maxPayload: '+self.maxPayload), 1009); - return; - } - self.currentMessageLength += buffer.length; - } - if (state.lastFragment) { - var messageBuffer = Buffer.concat(self.currentMessage); - self.currentMessage = []; - self.currentMessageLength = 0; - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); - return; - } - self.ontext(messageBuffer.toString('utf8'), {masked: state.masked, buffer: messageBuffer}); - } - callback(); - }); - }); - this.flush(); - this.endPacket(); - } - }, - // binary - '2': { - start: function(data) { - var self = this; - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - if (self.maxPayloadExceeded(firstLength)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, firstLength); - } - else if (firstLength == 126) { - self.expectHeader(2, function(data) { - var length = readUInt16BE.call(data, 0); - if (self.maxPayloadExceeded(length)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, length); - }); - } - else if (firstLength == 127) { - self.expectHeader(8, function(data) { - if (readUInt32BE.call(data, 0) != 0) { - self.error('packets with length spanning more than 32 bit is currently not supported', 1008); - return; - } - var length = readUInt32BE.call(data, 4, true); - if (self.maxPayloadExceeded(length)){ - self.error('Max payload exceeded in compressed text message. Aborting...', 1009); - return; - } - opcodes['2'].getData.call(self, length); - }); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['2'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['2'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - var packet = this.unmask(mask, data, true) || new Buffer(0); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { - if (err) { - if(err.type===1009){ - return self.error('Max payload exceeded in compressed binary message. Aborting...', 1009); - } - return self.error(err.message, 1007); - } - if (buffer != null) { - if( self.maxPayload==0 || (self.maxPayload > 0 && (self.currentMessageLength + buffer.length) < self.maxPayload) ){ - self.currentMessage.push(buffer); - } - else{ - self.currentMessage=null; - self.currentMessage = []; - self.currentMessageLength = 0; - self.error(new Error('Maximum payload exceeded'), 1009); - return; - } - self.currentMessageLength += buffer.length; - } - if (state.lastFragment) { - var messageBuffer = Buffer.concat(self.currentMessage); - self.currentMessage = []; - self.currentMessageLength = 0; - self.onbinary(messageBuffer, {masked: state.masked, buffer: messageBuffer}); - } - callback(); - }); - }); - this.flush(); - this.endPacket(); - } - }, - // close - '8': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented close is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['8'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['8'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['8'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = self.unmask(mask, data, true); - - var state = clone(this.state); - this.messageHandlers.push(function() { - if (data && data.length == 1) { - self.error('close packets with data must be at least two bytes long', 1002); - return; - } - var code = data && data.length > 1 ? readUInt16BE.call(data, 0) : 1000; - if (!ErrorCodes.isValidErrorCode(code)) { - self.error('invalid error code', 1002); - return; - } - var message = ''; - if (data && data.length > 2) { - var messageBuffer = data.slice(2); - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); - return; - } - message = messageBuffer.toString('utf8'); - } - self.onclose(code, message, {masked: state.masked}); - self.reset(); - }); - this.flush(); - }, - }, - // ping - '9': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented ping is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['9'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (self.state.masked) { - self.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['9'].finish.call(self, mask, data); - }); - }); - } - else { - self.expectData(length, function(data) { - opcodes['9'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = this.unmask(mask, data, true); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.onping(data, {masked: state.masked, binary: true}); - callback(); - }); - this.flush(); - this.endPacket(); - } - }, - // pong - '10': { - start: function(data) { - var self = this; - if (self.state.lastFragment == false) { - self.error('fragmented pong is not supported', 1002); - return; - } - - // decode length - var firstLength = data[1] & 0x7f; - if (firstLength < 126) { - opcodes['10'].getData.call(self, firstLength); - } - else { - self.error('control frames cannot have more than 125 bytes of data', 1002); - } - }, - getData: function(length) { - var self = this; - if (this.state.masked) { - this.expectHeader(4, function(data) { - var mask = data; - self.expectData(length, function(data) { - opcodes['10'].finish.call(self, mask, data); - }); - }); - } - else { - this.expectData(length, function(data) { - opcodes['10'].finish.call(self, null, data); - }); - } - }, - finish: function(mask, data) { - var self = this; - data = self.unmask(mask, data, true); - var state = clone(this.state); - this.messageHandlers.push(function(callback) { - self.onpong(data, {masked: state.masked, binary: true}); - callback(); - }); - this.flush(); - this.endPacket(); - } - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 128 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var events = __webpack_require__(5) - , util = __webpack_require__(10) - , EventEmitter = events.EventEmitter - , ErrorCodes = __webpack_require__(125) - , bufferUtil = __webpack_require__(124).BufferUtil - , PerMessageDeflate = __webpack_require__(44); - -/** - * HyBi Sender implementation - */ - -function Sender(socket, extensions) { - if (this instanceof Sender === false) { - throw new TypeError("Classes can't be function-called"); - } - - events.EventEmitter.call(this); - - this._socket = socket; - this.extensions = extensions || {}; - this.firstFragment = true; - this.compress = false; - this.messageHandlers = []; - this.processing = false; -} - -/** - * Inherits from EventEmitter. - */ - -util.inherits(Sender, events.EventEmitter); - -/** - * Sends a close instruction to the remote party. - * - * @api public - */ - -Sender.prototype.close = function(code, data, mask, cb) { - if (typeof code !== 'undefined') { - if (typeof code !== 'number' || - !ErrorCodes.isValidErrorCode(code)) throw new Error('first argument must be a valid error code number'); - } - code = code || 1000; - var dataBuffer = new Buffer(2 + (data ? Buffer.byteLength(data) : 0)); - writeUInt16BE.call(dataBuffer, code, 0); - if (dataBuffer.length > 2) dataBuffer.write(data, 2); - - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0x8, dataBuffer, true, mask); - callback(); - if (typeof cb == 'function') cb(); - }); - this.flush(); -}; - -/** - * Sends a ping message to the remote party. - * - * @api public - */ - -Sender.prototype.ping = function(data, options) { - var mask = options && options.mask; - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0x9, data || '', true, mask); - callback(); - }); - this.flush(); -}; - -/** - * Sends a pong message to the remote party. - * - * @api public - */ - -Sender.prototype.pong = function(data, options) { - var mask = options && options.mask; - var self = this; - this.messageHandlers.push(function(callback) { - self.frameAndSend(0xa, data || '', true, mask); - callback(); - }); - this.flush(); -}; - -/** - * Sends text or binary data to the remote party. - * - * @api public - */ - -Sender.prototype.send = function(data, options, cb) { - var finalFragment = options && options.fin === false ? false : true; - var mask = options && options.mask; - var compress = options && options.compress; - var opcode = options && options.binary ? 2 : 1; - if (this.firstFragment === false) { - opcode = 0; - compress = false; - } else { - this.firstFragment = false; - this.compress = compress; - } - if (finalFragment) this.firstFragment = true - - var compressFragment = this.compress; - - var self = this; - this.messageHandlers.push(function(callback) { - self.applyExtensions(data, finalFragment, compressFragment, function(err, data) { - if (err) { - if (typeof cb == 'function') cb(err); - else self.emit('error', err); - return; - } - self.frameAndSend(opcode, data, finalFragment, mask, compress, cb); - callback(); - }); - }); - this.flush(); -}; - -/** - * Frames and sends a piece of data according to the HyBi WebSocket protocol. - * - * @api private - */ - -Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, compressed, cb) { - var canModifyData = false; - - if (!data) { - try { - this._socket.write(new Buffer([opcode | (finalFragment ? 0x80 : 0), 0 | (maskData ? 0x80 : 0)].concat(maskData ? [0, 0, 0, 0] : [])), 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - return; - } - - if (!Buffer.isBuffer(data)) { - canModifyData = true; - if (data && (typeof data.byteLength !== 'undefined' || typeof data.buffer !== 'undefined')) { - data = getArrayBuffer(data); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; } else { - // - // If people want to send a number, this would allocate the number in - // bytes as memory size instead of storing the number as buffer value. So - // we need to transform it to string in order to prevent possible - // vulnerabilities / memory attacks. - // - if (typeof data === 'number') data = data.toString(); - - data = new Buffer(data); - } - } - - var dataLength = data.length - , dataOffset = maskData ? 6 : 2 - , secondByte = dataLength; - - if (dataLength >= 65536) { - dataOffset += 8; - secondByte = 127; - } - else if (dataLength > 125) { - dataOffset += 2; - secondByte = 126; - } - - var mergeBuffers = dataLength < 32768 || (maskData && !canModifyData); - var totalLength = mergeBuffers ? dataLength + dataOffset : dataOffset; - var outputBuffer = new Buffer(totalLength); - outputBuffer[0] = finalFragment ? opcode | 0x80 : opcode; - if (compressed) outputBuffer[0] |= 0x40; - - switch (secondByte) { - case 126: - writeUInt16BE.call(outputBuffer, dataLength, 2); - break; - case 127: - writeUInt32BE.call(outputBuffer, 0, 2); - writeUInt32BE.call(outputBuffer, dataLength, 6); - } - - if (maskData) { - outputBuffer[1] = secondByte | 0x80; - var mask = getRandomMask(); - outputBuffer[dataOffset - 4] = mask[0]; - outputBuffer[dataOffset - 3] = mask[1]; - outputBuffer[dataOffset - 2] = mask[2]; - outputBuffer[dataOffset - 1] = mask[3]; - if (mergeBuffers) { - bufferUtil.mask(data, mask, outputBuffer, dataOffset, dataLength); - try { - this._socket.write(outputBuffer, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - else { - bufferUtil.mask(data, mask, data, 0, dataLength); - try { - this._socket.write(outputBuffer, 'binary'); - this._socket.write(data, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - } - else { - outputBuffer[1] = secondByte; - if (mergeBuffers) { - data.copy(outputBuffer, dataOffset); - try { - this._socket.write(outputBuffer, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } - } - else { - try { - this._socket.write(outputBuffer, 'binary'); - this._socket.write(data, 'binary', cb); - } - catch (e) { - if (typeof cb == 'function') cb(e); - else this.emit('error', e); - } + str += ' ' + inspect(x); } } + return str; }; -/** - * Execute message handler buffers - * - * @api private - */ -Sender.prototype.flush = function() { - if (this.processing) return; - - var handler = this.messageHandlers.shift(); - if (!handler) return; - - this.processing = true; - - var self = this; - - handler(function() { - self.processing = false; - self.flush(); - }); -}; - -/** - * Apply extensions to message - * - * @api private - */ - -Sender.prototype.applyExtensions = function(data, fin, compress, callback) { - if (compress && data) { - if ((data.buffer || data) instanceof ArrayBuffer) { - data = getArrayBuffer(data); - } - this.extensions[PerMessageDeflate.extensionName].compress(data, fin, callback); - } else { - callback(null, data); - } -}; - -module.exports = Sender; - -function writeUInt16BE(value, offset) { - this[offset] = (value & 0xff00)>>8; - this[offset+1] = value & 0xff; -} - -function writeUInt32BE(value, offset) { - this[offset] = (value & 0xff000000)>>24; - this[offset+1] = (value & 0xff0000)>>16; - this[offset+2] = (value & 0xff00)>>8; - this[offset+3] = value & 0xff; -} - -function getArrayBuffer(data) { - // data is either an ArrayBuffer or ArrayBufferView. - var array = new Uint8Array(data.buffer || data) - , l = data.byteLength || data.length - , o = data.byteOffset || 0 - , buffer = new Buffer(l); - for (var i = 0; i < l; ++i) { - buffer[i] = array[o+i]; - } - return buffer; -} - -function getRandomMask() { - return new Buffer([ - ~~(Math.random() * 255), - ~~(Math.random() * 255), - ~~(Math.random() * 255), - ~~(Math.random() * 255) - ]); -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 129 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(Buffer, process) {'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var url = __webpack_require__(62) - , util = __webpack_require__(10) - , http = __webpack_require__(55) - , https = __webpack_require__(236) - , crypto = __webpack_require__(122) - , stream = __webpack_require__(11) - , Ultron = __webpack_require__(229) - , Options = __webpack_require__(108) - , Sender = __webpack_require__(128) - , Receiver = __webpack_require__(127) - , SenderHixie = __webpack_require__(243) - , ReceiverHixie = __webpack_require__(242) - , Extensions = __webpack_require__(126) - , PerMessageDeflate = __webpack_require__(44) - , EventEmitter = __webpack_require__(5).EventEmitter; - -/** - * Constants - */ - -// Default protocol version - -var protocolVersion = 13; - -// Close timeout - -var closeTimeout = 30 * 1000; // Allow 30 seconds to terminate the connection cleanly - -/** - * WebSocket implementation - * - * @constructor - * @param {String} address Connection address. - * @param {String|Array} protocols WebSocket protocols. - * @param {Object} options Additional connection options. - * @api public - */ -function WebSocket(address, protocols, options) { - if (this instanceof WebSocket === false) { - return new WebSocket(address, protocols, options); +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; } - EventEmitter.call(this); - - if (protocols && !Array.isArray(protocols) && 'object' === typeof protocols) { - // accept the "options" Object as the 2nd argument - options = protocols; - protocols = null; + if (process.noDeprecation === true) { + return fn; } - if ('string' === typeof protocols) { - protocols = [ protocols ]; - } - - if (!Array.isArray(protocols)) { - protocols = []; - } - - this._socket = null; - this._ultron = null; - this._closeReceived = false; - this.bytesReceived = 0; - this.readyState = null; - this.supports = {}; - this.extensions = {}; - this._binaryType = 'nodebuffer'; - - if (Array.isArray(address)) { - initAsServerClient.apply(this, address.concat(options)); - } else { - initAsClient.apply(this, [address, protocols, options]); - } -} - -/** - * Inherits from EventEmitter. - */ -util.inherits(WebSocket, EventEmitter); - -/** - * Ready States - */ -["CONNECTING", "OPEN", "CLOSING", "CLOSED"].forEach(function each(state, index) { - WebSocket.prototype[state] = WebSocket[state] = index; -}); - -/** - * Gracefully closes the connection, after sending a description message to the server - * - * @param {Object} data to be sent to the server - * @api public - */ -WebSocket.prototype.close = function close(code, data) { - if (this.readyState === WebSocket.CLOSED) return; - - if (this.readyState === WebSocket.CONNECTING) { - this.readyState = WebSocket.CLOSED; - return; - } - - if (this.readyState === WebSocket.CLOSING) { - if (this._closeReceived && this._isServer) { - this.terminate(); - } - return; - } - - var self = this; - try { - this.readyState = WebSocket.CLOSING; - this._closeCode = code; - this._closeMessage = data; - var mask = !this._isServer; - this._sender.close(code, data, mask, function(err) { - if (err) self.emit('error', err); - - if (self._closeReceived && self._isServer) { - self.terminate(); + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); } else { - // ensure that the connection is cleaned up even when no response of closing handshake. - clearTimeout(self._closeTimer); - self._closeTimer = setTimeout(cleanupWebsocketResources.bind(self, true), closeTimeout); - } - }); - } catch (e) { - this.emit('error', e); - } -}; - -/** - * Pause the client stream - * - * @api public - */ -WebSocket.prototype.pause = function pauser() { - if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); - - return this._socket.pause(); -}; - -/** - * Sends a ping - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean - * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open - * @api public - */ -WebSocket.prototype.ping = function ping(data, options, dontFailWhenClosed) { - if (this.readyState !== WebSocket.OPEN) { - if (dontFailWhenClosed === true) return; - throw new Error('not opened'); - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - - this._sender.ping(data, options); -}; - -/** - * Sends a pong - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean - * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open - * @api public - */ -WebSocket.prototype.pong = function(data, options, dontFailWhenClosed) { - if (this.readyState !== WebSocket.OPEN) { - if (dontFailWhenClosed === true) return; - throw new Error('not opened'); - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - - this._sender.pong(data, options); -}; - -/** - * Resume the client stream - * - * @api public - */ -WebSocket.prototype.resume = function resume() { - if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); - - return this._socket.resume(); -}; - -/** - * Sends a piece of data - * - * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean - * @param {function} Optional callback which is executed after the send completes - * @api public - */ - -WebSocket.prototype.send = function send(data, options, cb) { - if (typeof options === 'function') { - cb = options; - options = {}; - } - - if (this.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else throw new Error('not opened'); - return; - } - - if (!data) data = ''; - if (this._queue) { - var self = this; - this._queue.push(function() { self.send(data, options, cb); }); - return; - } - - options = options || {}; - options.fin = true; - - if (typeof options.binary === 'undefined') { - options.binary = (data instanceof ArrayBuffer || data instanceof Buffer || - data instanceof Uint8Array || - data instanceof Uint16Array || - data instanceof Uint32Array || - data instanceof Int8Array || - data instanceof Int16Array || - data instanceof Int32Array || - data instanceof Float32Array || - data instanceof Float64Array); - } - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - if (typeof options.compress === 'undefined') options.compress = true; - if (!this.extensions[PerMessageDeflate.extensionName]) { - options.compress = false; - } - - var readable = typeof stream.Readable === 'function' - ? stream.Readable - : stream.Stream; - - if (data instanceof readable) { - startQueue(this); - var self = this; - - sendStream(this, data, options, function send(error) { - process.nextTick(function tock() { - executeQueueSends(self); - }); - - if (typeof cb === 'function') cb(error); - }); - } else { - this._sender.send(data, options, cb); - } -}; - -/** - * Streams data through calls to a user supplied function - * - * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean - * @param {function} 'function (error, send)' which is executed on successive ticks of which send is 'function (data, final)'. - * @api public - */ -WebSocket.prototype.stream = function stream(options, cb) { - if (typeof options === 'function') { - cb = options; - options = {}; - } - - var self = this; - - if (typeof cb !== 'function') throw new Error('callback must be provided'); - - if (this.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else throw new Error('not opened'); - return; - } - - if (this._queue) { - this._queue.push(function () { self.stream(options, cb); }); - return; - } - - options = options || {}; - - if (typeof options.mask === 'undefined') options.mask = !this._isServer; - if (typeof options.compress === 'undefined') options.compress = true; - if (!this.extensions[PerMessageDeflate.extensionName]) { - options.compress = false; - } - - startQueue(this); - - function send(data, final) { - try { - if (self.readyState !== WebSocket.OPEN) throw new Error('not opened'); - options.fin = final === true; - self._sender.send(data, options); - if (!final) process.nextTick(cb.bind(null, null, send)); - else executeQueueSends(self); - } catch (e) { - if (typeof cb === 'function') cb(e); - else { - delete self._queue; - self.emit('error', e); + console.error(msg); } + warned = true; } + return fn.apply(this, arguments); } - process.nextTick(cb.bind(null, null, send)); + return deprecated; }; -/** - * Immediately shuts down the connection - * - * @api public - */ -WebSocket.prototype.terminate = function terminate() { - if (this.readyState === WebSocket.CLOSED) return; - if (this._socket) { - this.readyState = WebSocket.CLOSING; - - // End the connection - try { this._socket.end(); } - catch (e) { - // Socket error during end() call, so just destroy it right now - cleanupWebsocketResources.call(this, true); - return; - } - - // Add a timeout to ensure that the connection is completely - // cleaned up within 30 seconds, even if the clean close procedure - // fails for whatever reason - // First cleanup any pre-existing timeout from an earlier "terminate" call, - // if one exists. Otherwise terminate calls in quick succession will leak timeouts - // and hold the program open for `closeTimout` time. - if (this._closeTimer) { clearTimeout(this._closeTimer); } - this._closeTimer = setTimeout(cleanupWebsocketResources.bind(this, true), closeTimeout); - } else if (this.readyState === WebSocket.CONNECTING) { - cleanupWebsocketResources.call(this, true); - } -}; - -/** - * Expose bufferedAmount - * - * @api public - */ -Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { - get: function get() { - var amount = 0; - if (this._socket) { - amount = this._socket.bufferSize || 0; - } - return amount; - } -}); - -/** - * Expose binaryType - * - * This deviates from the W3C interface since ws doesn't support the required - * default "blob" type (instead we define a custom "nodebuffer" type). - * - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ -Object.defineProperty(WebSocket.prototype, 'binaryType', { - get: function get() { - return this._binaryType; - }, - set: function set(type) { - if (type === 'arraybuffer' || type === 'nodebuffer') - this._binaryType = type; - else - throw new SyntaxError('unsupported binaryType: must be either "nodebuffer" or "arraybuffer"'); - } -}); - -/** - * Emulates the W3C Browser based WebSocket interface using function members. - * - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ -['open', 'error', 'close', 'message'].forEach(function(method) { - Object.defineProperty(WebSocket.prototype, 'on' + method, { - /** - * Returns the current listener - * - * @returns {Mixed} the set function or undefined - * @api public - */ - get: function get() { - var listener = this.listeners(method)[0]; - return listener ? (listener._listener ? listener._listener : listener) : undefined; - }, - - /** - * Start listening for events - * - * @param {Function} listener the listener - * @returns {Mixed} the set function or undefined - * @api public - */ - set: function set(listener) { - this.removeAllListeners(method); - this.addEventListener(method, listener); - } - }); -}); - -/** - * Emulates the W3C Browser based WebSocket interface using addEventListener. - * - * @see https://developer.mozilla.org/en/DOM/element.addEventListener - * @see http://dev.w3.org/html5/websockets/#the-websocket-interface - * @api public - */ -WebSocket.prototype.addEventListener = function(method, listener) { - var target = this; - - function onMessage (data, flags) { - if (flags.binary && this.binaryType === 'arraybuffer') - data = new Uint8Array(data).buffer; - listener.call(target, new MessageEvent(data, !!flags.binary, target)); - } - - function onClose (code, message) { - listener.call(target, new CloseEvent(code, message, target)); - } - - function onError (event) { - event.type = 'error'; - event.target = target; - listener.call(target, event); - } - - function onOpen () { - listener.call(target, new OpenEvent(target)); - } - - if (typeof listener === 'function') { - if (method === 'message') { - // store a reference so we can return the original function from the - // addEventListener hook - onMessage._listener = listener; - this.on(method, onMessage); - } else if (method === 'close') { - // store a reference so we can return the original function from the - // addEventListener hook - onClose._listener = listener; - this.on(method, onClose); - } else if (method === 'error') { - // store a reference so we can return the original function from the - // addEventListener hook - onError._listener = listener; - this.on(method, onError); - } else if (method === 'open') { - // store a reference so we can return the original function from the - // addEventListener hook - onOpen._listener = listener; - this.on(method, onOpen); +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; } else { - this.on(method, listener); + debugs[set] = function() {}; } } + return debugs[set]; }; -module.exports = WebSocket; -module.exports.buildHostHeader = buildHostHeader /** - * W3C MessageEvent + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. */ -function MessageEvent(dataArg, isBinary, target) { - this.type = 'message'; - this.data = dataArg; - this.target = target; - this.binary = isBinary; // non-standard. -} - -/** - * W3C CloseEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ -function CloseEvent(code, reason, target) { - this.type = 'close'; - this.wasClean = (typeof code === 'undefined' || code === 1000); - this.code = code; - this.reason = reason; - this.target = target; -} - -/** - * W3C OpenEvent - * - * @see http://www.w3.org/TR/html5/comms.html - * @constructor - * @api private - */ -function OpenEvent(target) { - this.type = 'open'; - this.target = target; -} - -// Append port number to Host header, only if specified in the url -// and non-default -function buildHostHeader(isSecure, hostname, port) { - var headerHost = hostname; - if (hostname) { - if ((isSecure && (port != 443)) || (!isSecure && (port != 80))){ - headerHost = headerHost + ':' + port; - } +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); } - return headerHost; + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); } +exports.inspect = inspect; -/** - * Entirely private apis, - * which may or may not be bound to a sepcific WebSocket instance. - */ -function initAsServerClient(req, socket, upgradeHead, options) { - options = new Options({ - protocolVersion: protocolVersion, - protocol: null, - extensions: {}, - maxPayload: 0 - }).merge(options); - // expose state properties - this.protocol = options.value.protocol; - this.protocolVersion = options.value.protocolVersion; - this.extensions = options.value.extensions; - this.supports.binary = (this.protocolVersion !== 'hixie-76'); - this.upgradeReq = req; - this.readyState = WebSocket.CONNECTING; - this._isServer = true; - this.maxPayload = options.value.maxPayload; - // establish connection - if (options.value.protocolVersion === 'hixie-76') { - establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead); +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; } else { - establishConnection.call(this, Receiver, Sender, socket, upgradeHead); + return str; } } -function initAsClient(address, protocols, options) { - options = new Options({ - origin: null, - protocolVersion: protocolVersion, - host: null, - headers: null, - protocol: protocols.join(','), - agent: null, - // ssl-related options - pfx: null, - key: null, - passphrase: null, - cert: null, - ca: null, - ciphers: null, - rejectUnauthorized: null, - perMessageDeflate: true, - localAddress: null - }).merge(options); - - if (options.value.protocolVersion !== 8 && options.value.protocolVersion !== 13) { - throw new Error('unsupported protocol version'); - } - - // verify URL and establish http class - var serverUrl = url.parse(address); - var isUnixSocket = serverUrl.protocol === 'ws+unix:'; - if (!serverUrl.host && !isUnixSocket) throw new Error('invalid url'); - var isSecure = serverUrl.protocol === 'wss:' || serverUrl.protocol === 'https:'; - var httpObj = isSecure ? https : http; - var port = serverUrl.port || (isSecure ? 443 : 80); - var auth = serverUrl.auth; - - // prepare extensions - var extensionsOffer = {}; - var perMessageDeflate; - if (options.value.perMessageDeflate) { - perMessageDeflate = new PerMessageDeflate(typeof options.value.perMessageDeflate !== true ? options.value.perMessageDeflate : {}, false); - extensionsOffer[PerMessageDeflate.extensionName] = perMessageDeflate.offer(); - } - - // expose state properties - this._isServer = false; - this.url = address; - this.protocolVersion = options.value.protocolVersion; - this.supports.binary = (this.protocolVersion !== 'hixie-76'); - - // begin handshake - var key = new Buffer(options.value.protocolVersion + '-' + Date.now()).toString('base64'); - var shasum = crypto.createHash('sha1'); - shasum.update(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'); - var expectedServerKey = shasum.digest('base64'); - - var agent = options.value.agent; - - var headerHost = buildHostHeader(isSecure, serverUrl.hostname, port) - - var requestOptions = { - port: port, - host: serverUrl.hostname, - headers: { - 'Connection': 'Upgrade', - 'Upgrade': 'websocket', - 'Host': headerHost, - 'Sec-WebSocket-Version': options.value.protocolVersion, - 'Sec-WebSocket-Key': key - } - }; - - // If we have basic auth. - if (auth) { - requestOptions.headers.Authorization = 'Basic ' + new Buffer(auth).toString('base64'); - } - - if (options.value.protocol) { - requestOptions.headers['Sec-WebSocket-Protocol'] = options.value.protocol; - } - - if (options.value.host) { - requestOptions.headers.Host = options.value.host; - } - - if (options.value.headers) { - for (var header in options.value.headers) { - if (options.value.headers.hasOwnProperty(header)) { - requestOptions.headers[header] = options.value.headers[header]; - } - } - } - - if (Object.keys(extensionsOffer).length) { - requestOptions.headers['Sec-WebSocket-Extensions'] = Extensions.format(extensionsOffer); - } - - if (options.isDefinedAndNonNull('pfx') - || options.isDefinedAndNonNull('key') - || options.isDefinedAndNonNull('passphrase') - || options.isDefinedAndNonNull('cert') - || options.isDefinedAndNonNull('ca') - || options.isDefinedAndNonNull('ciphers') - || options.isDefinedAndNonNull('rejectUnauthorized')) { - - if (options.isDefinedAndNonNull('pfx')) requestOptions.pfx = options.value.pfx; - if (options.isDefinedAndNonNull('key')) requestOptions.key = options.value.key; - if (options.isDefinedAndNonNull('passphrase')) requestOptions.passphrase = options.value.passphrase; - if (options.isDefinedAndNonNull('cert')) requestOptions.cert = options.value.cert; - if (options.isDefinedAndNonNull('ca')) requestOptions.ca = options.value.ca; - if (options.isDefinedAndNonNull('ciphers')) requestOptions.ciphers = options.value.ciphers; - if (options.isDefinedAndNonNull('rejectUnauthorized')) requestOptions.rejectUnauthorized = options.value.rejectUnauthorized; - - if (!agent) { - // global agent ignores client side certificates - agent = new httpObj.Agent(requestOptions); - } - } - - requestOptions.path = serverUrl.path || '/'; - - if (agent) { - requestOptions.agent = agent; - } - - if (isUnixSocket) { - requestOptions.socketPath = serverUrl.pathname; - } - - if (options.value.localAddress) { - requestOptions.localAddress = options.value.localAddress; - } - - if (options.value.origin) { - if (options.value.protocolVersion < 13) requestOptions.headers['Sec-WebSocket-Origin'] = options.value.origin; - else requestOptions.headers.Origin = options.value.origin; - } - - var self = this; - var req = httpObj.request(requestOptions); - - req.on('error', function onerror(error) { - self.emit('error', error); - cleanupWebsocketResources.call(self, error); - }); - - req.once('response', function response(res) { - var error; - - if (!self.emit('unexpected-response', req, res)) { - error = new Error('unexpected server response (' + res.statusCode + ')'); - req.abort(); - self.emit('error', error); - } - - cleanupWebsocketResources.call(self, error); - }); - - req.once('upgrade', function upgrade(res, socket, upgradeHead) { - if (self.readyState === WebSocket.CLOSED) { - // client closed before server accepted connection - self.emit('close'); - self.removeAllListeners(); - socket.end(); - return; - } - - var serverKey = res.headers['sec-websocket-accept']; - if (typeof serverKey === 'undefined' || serverKey !== expectedServerKey) { - self.emit('error', 'invalid server key'); - self.removeAllListeners(); - socket.end(); - return; - } - - var serverProt = res.headers['sec-websocket-protocol']; - var protList = (options.value.protocol || "").split(/, */); - var protError = null; - - if (!options.value.protocol && serverProt) { - protError = 'server sent a subprotocol even though none requested'; - } else if (options.value.protocol && !serverProt) { - protError = 'server sent no subprotocol even though requested'; - } else if (serverProt && protList.indexOf(serverProt) === -1) { - protError = 'server responded with an invalid protocol'; - } - - if (protError) { - self.emit('error', protError); - self.removeAllListeners(); - socket.end(); - return; - } else if (serverProt) { - self.protocol = serverProt; - } - - var serverExtensions = Extensions.parse(res.headers['sec-websocket-extensions']); - if (perMessageDeflate && serverExtensions[PerMessageDeflate.extensionName]) { - try { - perMessageDeflate.accept(serverExtensions[PerMessageDeflate.extensionName]); - } catch (err) { - self.emit('error', 'invalid extension parameter'); - self.removeAllListeners(); - socket.end(); - return; - } - self.extensions[PerMessageDeflate.extensionName] = perMessageDeflate; - } - - establishConnection.call(self, Receiver, Sender, socket, upgradeHead); - - // perform cleanup on http resources - req.removeAllListeners(); - req = null; - agent = null; - }); - - req.end(); - this.readyState = WebSocket.CONNECTING; +function stylizeNoColor(str, styleType) { + return str; } -function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { - var ultron = this._ultron = new Ultron(socket) - , called = false - , self = this; - socket.setTimeout(0); - socket.setNoDelay(true); +function arrayToHash(array) { + var hash = {}; - this._receiver = new ReceiverClass(this.extensions,this.maxPayload); - this._socket = socket; - - // socket cleanup handlers - ultron.on('end', cleanupWebsocketResources.bind(this)); - ultron.on('close', cleanupWebsocketResources.bind(this)); - ultron.on('error', cleanupWebsocketResources.bind(this)); - - // ensure that the upgradeHead is added to the receiver - function firstHandler(data) { - if (called || self.readyState === WebSocket.CLOSED) return; - - called = true; - socket.removeListener('data', firstHandler); - ultron.on('data', realHandler); - - if (upgradeHead && upgradeHead.length > 0) { - realHandler(upgradeHead); - upgradeHead = null; - } - - if (data) realHandler(data); - } - - // subsequent packets are pushed straight to the receiver - function realHandler(data) { - self.bytesReceived += data.length; - self._receiver.add(data); - } - - ultron.on('data', firstHandler); - - // if data was passed along with the http upgrade, - // this will schedule a push of that on to the receiver. - // this has to be done on next tick, since the caller - // hasn't had a chance to set event handlers on this client - // object yet. - process.nextTick(firstHandler); - - // receiver event handlers - self._receiver.ontext = function ontext(data, flags) { - flags = flags || {}; - - self.emit('message', data, flags); - }; - - self._receiver.onbinary = function onbinary(data, flags) { - flags = flags || {}; - - flags.binary = true; - self.emit('message', data, flags); - }; - - self._receiver.onping = function onping(data, flags) { - flags = flags || {}; - - self.pong(data, { - mask: !self._isServer, - binary: flags.binary === true - }, true); - - self.emit('ping', data, flags); - }; - - self._receiver.onpong = function onpong(data, flags) { - self.emit('pong', data, flags || {}); - }; - - self._receiver.onclose = function onclose(code, data, flags) { - flags = flags || {}; - - self._closeReceived = true; - self.close(code, data); - }; - - self._receiver.onerror = function onerror(reason, errorCode) { - // close the connection when the receiver reports a HyBi error code - self.close(typeof errorCode !== 'undefined' ? errorCode : 1002, ''); - self.emit('error', (reason instanceof Error) ? reason : (new Error(reason))); - }; - - // finalize the client - this._sender = new SenderClass(socket, this.extensions); - this._sender.on('error', function onerror(error) { - self.close(1002, ''); - self.emit('error', error); + array.forEach(function(val, idx) { + hash[val] = true; }); - this.readyState = WebSocket.OPEN; - this.emit('open'); + return hash; } -function startQueue(instance) { - instance._queue = instance._queue || []; -} -function executeQueueSends(instance) { - var queue = instance._queue; - if (typeof queue === 'undefined') return; - - delete instance._queue; - for (var i = 0, l = queue.length; i < l; ++i) { - queue[i](); - } -} - -function sendStream(instance, stream, options, cb) { - stream.on('data', function incoming(data) { - if (instance.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else { - delete instance._queue; - instance.emit('error', new Error('not opened')); - } - return; +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); } - - options.fin = false; - instance._sender.send(data, options); - }); - - stream.on('end', function end() { - if (instance.readyState !== WebSocket.OPEN) { - if (typeof cb === 'function') cb(new Error('not opened')); - else { - delete instance._queue; - instance.emit('error', new Error('not opened')); - } - return; - } - - options.fin = true; - instance._sender.send(null, options); - - if (typeof cb === 'function') cb(null); - }); -} - -function cleanupWebsocketResources(error) { - if (this.readyState === WebSocket.CLOSED) return; - - this.readyState = WebSocket.CLOSED; - - clearTimeout(this._closeTimer); - this._closeTimer = null; - - // If the connection was closed abnormally (with an error), or if - // the close control frame was not received then the close code - // must default to 1006. - if (error || !this._closeReceived) { - this._closeCode = 1006; + return ret; } - this.emit('close', this._closeCode || 1000, this._closeMessage || ''); - if (this._socket) { - if (this._ultron) this._ultron.destroy(); - this._socket.on('error', function onerror() { - try { this.destroy(); } - catch (e) {} + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); }); - - try { - if (!error) this._socket.end(); - else this._socket.destroy(); - } catch (e) { /* Ignore termination errors */ } - - this._socket = null; - this._ultron = null; } - if (this._sender) { - this._sender.removeAllListeners(); - this._sender = null; - } + ctx.seen.pop(); - if (this._receiver) { - this._receiver.cleanup(); - this._receiver = null; - } - - if (this.extensions[PerMessageDeflate.extensionName]) { - this.extensions[PerMessageDeflate.extensionName].cleanup(); - } - - this.extensions = null; - - this.removeAllListeners(); - this.on('error', function onerror() {}); // catch all errors after this - delete this._queue; + return reduceToSingleString(output, base, braces); } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer, __webpack_require__(8))) + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = __webpack_require__(102); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = __webpack_require__(101); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18), __webpack_require__(6))) /***/ }, -/* 130 */ +/* 69 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(23); +/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(17); const fs = __webpack_require__(13); -const request = __webpack_require__(60); +const request = __webpack_require__(35); -const Constants = __webpack_require__(1); -const convertArrayBuffer = __webpack_require__(134); -const User = __webpack_require__(14); -const Message = __webpack_require__(34); -const Guild = __webpack_require__(47); -const Channel = __webpack_require__(24); -const GuildMember = __webpack_require__(33); -const Emoji = __webpack_require__(25); -const ReactionEmoji = __webpack_require__(48); +const Constants = __webpack_require__(0); +const convertArrayBuffer = __webpack_require__(73); +const User = __webpack_require__(8); +const Message = __webpack_require__(22); +const Guild = __webpack_require__(28); +const Channel = __webpack_require__(14); +const GuildMember = __webpack_require__(21); +const Emoji = __webpack_require__(15); +const ReactionEmoji = __webpack_require__(29); /** * The DataResolver identifies different objects and tries to resolve a specific piece of information from them, e.g. @@ -27544,18 +16274,18 @@ class ClientDataResolver { module.exports = ClientDataResolver; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }, -/* 131 */ +/* 70 */ /***/ function(module, exports, __webpack_require__) { -const UserAgentManager = __webpack_require__(281); -const RESTMethods = __webpack_require__(278); -const SequentialRequestHandler = __webpack_require__(280); -const BurstRequestHandler = __webpack_require__(279); -const APIRequest = __webpack_require__(277); -const Constants = __webpack_require__(1); +const UserAgentManager = __webpack_require__(138); +const RESTMethods = __webpack_require__(135); +const SequentialRequestHandler = __webpack_require__(137); +const BurstRequestHandler = __webpack_require__(136); +const APIRequest = __webpack_require__(134); +const Constants = __webpack_require__(0); class RESTManager { constructor(client) { @@ -27604,7 +16334,7 @@ module.exports = RESTManager; /***/ }, -/* 132 */ +/* 71 */ /***/ function(module, exports) { /** @@ -27661,7 +16391,7 @@ module.exports = RequestHandler; /***/ }, -/* 133 */ +/* 72 */ /***/ function(module, exports) { class BaseOpus { @@ -27682,7 +16412,7 @@ module.exports = BaseOpus; /***/ }, -/* 134 */ +/* 73 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {function arrayBufferToBuffer(ab) { @@ -27704,10 +16434,10 @@ module.exports = function convertArrayBuffer(x) { return arrayBufferToBuffer(x); }; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }, -/* 135 */ +/* 74 */ /***/ function(module, exports) { module.exports = function makeError(obj) { @@ -27719,7 +16449,7 @@ module.exports = function makeError(obj) { /***/ }, -/* 136 */ +/* 75 */ /***/ function(module, exports) { module.exports = function makePlainError(err) { @@ -27732,22 +16462,28 @@ module.exports = function makePlainError(err) { /***/ }, -/* 137 */ +/* 76 */ +/***/ function(module, exports) { + +module.exports = undefined; + +/***/ }, +/* 77 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {const EventEmitter = __webpack_require__(5).EventEmitter; -const mergeDefault = __webpack_require__(45); -const Constants = __webpack_require__(1); -const RESTManager = __webpack_require__(131); -const ClientDataManager = __webpack_require__(248); -const ClientManager = __webpack_require__(249); -const ClientDataResolver = __webpack_require__(130); -const ClientVoiceManager = __webpack_require__(282); -const WebSocketManager = __webpack_require__(297); -const ActionsManager = __webpack_require__(250); -const Collection = __webpack_require__(6); -const Presence = __webpack_require__(15).Presence; -const ShardClientUtil = __webpack_require__(66); +/* WEBPACK VAR INJECTION */(function(process) {const EventEmitter = __webpack_require__(4).EventEmitter; +const mergeDefault = __webpack_require__(26); +const Constants = __webpack_require__(0); +const RESTManager = __webpack_require__(70); +const ClientDataManager = __webpack_require__(105); +const ClientManager = __webpack_require__(106); +const ClientDataResolver = __webpack_require__(69); +const ClientVoiceManager = __webpack_require__(139); +const WebSocketManager = __webpack_require__(154); +const ActionsManager = __webpack_require__(107); +const Collection = __webpack_require__(3); +const Presence = __webpack_require__(9).Presence; +const ShardClientUtil = __webpack_require__(40); /** * The starting point for making a Discord Bot. @@ -28185,17 +16921,17 @@ module.exports = Client; * @param {string} The debug information */ -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 138 */ +/* 78 */ /***/ function(module, exports, __webpack_require__) { -const Webhook = __webpack_require__(49); -const RESTManager = __webpack_require__(131); -const ClientDataResolver = __webpack_require__(130); -const mergeDefault = __webpack_require__(45); -const Constants = __webpack_require__(1); +const Webhook = __webpack_require__(30); +const RESTManager = __webpack_require__(70); +const ClientDataResolver = __webpack_require__(69); +const mergeDefault = __webpack_require__(26); +const Constants = __webpack_require__(0); /** * The Webhook Client @@ -28240,16 +16976,16 @@ module.exports = WebhookClient; /***/ }, -/* 139 */ +/* 79 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {const path = __webpack_require__(23); +/* WEBPACK VAR INJECTION */(function(process) {const path = __webpack_require__(17); const fs = __webpack_require__(13); -const EventEmitter = __webpack_require__(5).EventEmitter; -const mergeDefault = __webpack_require__(45); -const Shard = __webpack_require__(65); -const Collection = __webpack_require__(6); -const fetchRecommendedShards = __webpack_require__(82); +const EventEmitter = __webpack_require__(4).EventEmitter; +const mergeDefault = __webpack_require__(26); +const Shard = __webpack_require__(39); +const Collection = __webpack_require__(3); +const fetchRecommendedShards = __webpack_require__(56); /** * This is a utility class that can be used to help you spawn shards of your Client. Each shard is completely separate @@ -28437,1060 +17173,10 @@ class ShardingManager extends EventEmitter { module.exports = ShardingManager; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 140 */ -/***/ function(module, exports, __webpack_require__) { - -;(function () { - - var object = true ? exports : this; // #8: web workers - var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - - function InvalidCharacterError(message) { - this.message = message; - } - InvalidCharacterError.prototype = new Error; - InvalidCharacterError.prototype.name = 'InvalidCharacterError'; - - // encoder - // [https://gist.github.com/999166] by [https://github.com/nignag] - object.btoa || ( - object.btoa = function (input) { - for ( - // initialize result and counter - var block, charCode, idx = 0, map = chars, output = ''; - // if the next input index does not exist: - // change the mapping table to "=" - // check if d has no fractional digits - input.charAt(idx | 0) || (map = '=', idx % 1); - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 - output += map.charAt(63 & block >> 8 - idx % 1 * 8) - ) { - charCode = input.charCodeAt(idx += 3/4); - if (charCode > 0xFF) { - throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); - } - block = block << 8 | charCode; - } - return output; - }); - - // decoder - // [https://gist.github.com/1020396] by [https://github.com/atk] - object.atob || ( - object.atob = function (input) { - input = input.replace(/=+$/, ''); - if (input.length % 4 == 1) { - throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); - } - for ( - // initialize result and counters - var bc = 0, bs, buffer, idx = 0, output = ''; - // get next character - buffer = input.charAt(idx++); - // character found in table? initialize bit storage and add its ascii value; - ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, - // and if not first of each 4 characters, - // convert the first 8 bits to one ascii character - bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 - ) { - // try to find character in table (0-63, not found => -1) - buffer = chars.indexOf(buffer); - } - return output; - }); - -}()); - - -/***/ }, -/* 141 */ -/***/ function(module, exports, __webpack_require__) { - -var asn1 = __webpack_require__(36); -var inherits = __webpack_require__(2); - -var api = exports; - -api.define = function define(name, body) { - return new Entity(name, body); -}; - -function Entity(name, body) { - this.name = name; - this.body = body; - - this.decoders = {}; - this.encoders = {}; -}; - -Entity.prototype._createNamed = function createNamed(base) { - var named; - try { - named = __webpack_require__(235).runInThisContext( - '(function ' + this.name + '(entity) {\n' + - ' this._initNamed(entity);\n' + - '})' - ); - } catch (e) { - named = function (entity) { - this._initNamed(entity); - }; - } - inherits(named, base); - named.prototype._initNamed = function initnamed(entity) { - base.call(this, entity); - }; - - return new named(this); -}; - -Entity.prototype._getDecoder = function _getDecoder(enc) { - enc = enc || 'der'; - // Lazily create decoder - if (!this.decoders.hasOwnProperty(enc)) - this.decoders[enc] = this._createNamed(asn1.decoders[enc]); - return this.decoders[enc]; -}; - -Entity.prototype.decode = function decode(data, enc, options) { - return this._getDecoder(enc).decode(data, options); -}; - -Entity.prototype._getEncoder = function _getEncoder(enc) { - enc = enc || 'der'; - // Lazily create encoder - if (!this.encoders.hasOwnProperty(enc)) - this.encoders[enc] = this._createNamed(asn1.encoders[enc]); - return this.encoders[enc]; -}; - -Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { - return this._getEncoder(enc).encode(data, reporter); -}; - - -/***/ }, -/* 142 */ -/***/ function(module, exports, __webpack_require__) { - -var Reporter = __webpack_require__(26).Reporter; -var EncoderBuffer = __webpack_require__(26).EncoderBuffer; -var DecoderBuffer = __webpack_require__(26).DecoderBuffer; -var assert = __webpack_require__(29); - -// Supported tags -var tags = [ - 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', - 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', - 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', - 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr' -]; - -// Public methods list -var methods = [ - 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', - 'any', 'contains' -].concat(tags); - -// Overrided methods list -var overrided = [ - '_peekTag', '_decodeTag', '_use', - '_decodeStr', '_decodeObjid', '_decodeTime', - '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', - - '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime', - '_encodeNull', '_encodeInt', '_encodeBool' -]; - -function Node(enc, parent) { - var state = {}; - this._baseState = state; - - state.enc = enc; - - state.parent = parent || null; - state.children = null; - - // State - state.tag = null; - state.args = null; - state.reverseArgs = null; - state.choice = null; - state.optional = false; - state.any = false; - state.obj = false; - state.use = null; - state.useDecoder = null; - state.key = null; - state['default'] = null; - state.explicit = null; - state.implicit = null; - state.contains = null; - - // Should create new instance on each method - if (!state.parent) { - state.children = []; - this._wrap(); - } -} -module.exports = Node; - -var stateProps = [ - 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', - 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', - 'implicit', 'contains' -]; - -Node.prototype.clone = function clone() { - var state = this._baseState; - var cstate = {}; - stateProps.forEach(function(prop) { - cstate[prop] = state[prop]; - }); - var res = new this.constructor(cstate.parent); - res._baseState = cstate; - return res; -}; - -Node.prototype._wrap = function wrap() { - var state = this._baseState; - methods.forEach(function(method) { - this[method] = function _wrappedMethod() { - var clone = new this.constructor(this); - state.children.push(clone); - return clone[method].apply(clone, arguments); - }; - }, this); -}; - -Node.prototype._init = function init(body) { - var state = this._baseState; - - assert(state.parent === null); - body.call(this); - - // Filter children - state.children = state.children.filter(function(child) { - return child._baseState.parent === this; - }, this); - assert.equal(state.children.length, 1, 'Root node can have only one child'); -}; - -Node.prototype._useArgs = function useArgs(args) { - var state = this._baseState; - - // Filter children and args - var children = args.filter(function(arg) { - return arg instanceof this.constructor; - }, this); - args = args.filter(function(arg) { - return !(arg instanceof this.constructor); - }, this); - - if (children.length !== 0) { - assert(state.children === null); - state.children = children; - - // Replace parent to maintain backward link - children.forEach(function(child) { - child._baseState.parent = this; - }, this); - } - if (args.length !== 0) { - assert(state.args === null); - state.args = args; - state.reverseArgs = args.map(function(arg) { - if (typeof arg !== 'object' || arg.constructor !== Object) - return arg; - - var res = {}; - Object.keys(arg).forEach(function(key) { - if (key == (key | 0)) - key |= 0; - var value = arg[key]; - res[value] = key; - }); - return res; - }); - } -}; - -// -// Overrided methods -// - -overrided.forEach(function(method) { - Node.prototype[method] = function _overrided() { - var state = this._baseState; - throw new Error(method + ' not implemented for encoding: ' + state.enc); - }; -}); - -// -// Public methods -// - -tags.forEach(function(tag) { - Node.prototype[tag] = function _tagMethod() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); - - assert(state.tag === null); - state.tag = tag; - - this._useArgs(args); - - return this; - }; -}); - -Node.prototype.use = function use(item) { - assert(item); - var state = this._baseState; - - assert(state.use === null); - state.use = item; - - return this; -}; - -Node.prototype.optional = function optional() { - var state = this._baseState; - - state.optional = true; - - return this; -}; - -Node.prototype.def = function def(val) { - var state = this._baseState; - - assert(state['default'] === null); - state['default'] = val; - state.optional = true; - - return this; -}; - -Node.prototype.explicit = function explicit(num) { - var state = this._baseState; - - assert(state.explicit === null && state.implicit === null); - state.explicit = num; - - return this; -}; - -Node.prototype.implicit = function implicit(num) { - var state = this._baseState; - - assert(state.explicit === null && state.implicit === null); - state.implicit = num; - - return this; -}; - -Node.prototype.obj = function obj() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); - - state.obj = true; - - if (args.length !== 0) - this._useArgs(args); - - return this; -}; - -Node.prototype.key = function key(newKey) { - var state = this._baseState; - - assert(state.key === null); - state.key = newKey; - - return this; -}; - -Node.prototype.any = function any() { - var state = this._baseState; - - state.any = true; - - return this; -}; - -Node.prototype.choice = function choice(obj) { - var state = this._baseState; - - assert(state.choice === null); - state.choice = obj; - this._useArgs(Object.keys(obj).map(function(key) { - return obj[key]; - })); - - return this; -}; - -Node.prototype.contains = function contains(item) { - var state = this._baseState; - - assert(state.use === null); - state.contains = item; - - return this; -}; - -// -// Decoding -// - -Node.prototype._decode = function decode(input, options) { - var state = this._baseState; - - // Decode root node - if (state.parent === null) - return input.wrapResult(state.children[0]._decode(input, options)); - - var result = state['default']; - var present = true; - - var prevKey = null; - if (state.key !== null) - prevKey = input.enterKey(state.key); - - // Check if tag is there - if (state.optional) { - var tag = null; - if (state.explicit !== null) - tag = state.explicit; - else if (state.implicit !== null) - tag = state.implicit; - else if (state.tag !== null) - tag = state.tag; - - if (tag === null && !state.any) { - // Trial and Error - var save = input.save(); - try { - if (state.choice === null) - this._decodeGeneric(state.tag, input, options); - else - this._decodeChoice(input, options); - present = true; - } catch (e) { - present = false; - } - input.restore(save); - } else { - present = this._peekTag(input, tag, state.any); - - if (input.isError(present)) - return present; - } - } - - // Push object on stack - var prevObj; - if (state.obj && present) - prevObj = input.enterObject(); - - if (present) { - // Unwrap explicit values - if (state.explicit !== null) { - var explicit = this._decodeTag(input, state.explicit); - if (input.isError(explicit)) - return explicit; - input = explicit; - } - - var start = input.offset; - - // Unwrap implicit and normal values - if (state.use === null && state.choice === null) { - if (state.any) - var save = input.save(); - var body = this._decodeTag( - input, - state.implicit !== null ? state.implicit : state.tag, - state.any - ); - if (input.isError(body)) - return body; - - if (state.any) - result = input.raw(save); - else - input = body; - } - - if (options && options.track && state.tag !== null) - options.track(input.path(), start, input.length, 'tagged'); - - if (options && options.track && state.tag !== null) - options.track(input.path(), input.offset, input.length, 'content'); - - // Select proper method for tag - if (state.any) - result = result; - else if (state.choice === null) - result = this._decodeGeneric(state.tag, input, options); - else - result = this._decodeChoice(input, options); - - if (input.isError(result)) - return result; - - // Decode children - if (!state.any && state.choice === null && state.children !== null) { - state.children.forEach(function decodeChildren(child) { - // NOTE: We are ignoring errors here, to let parser continue with other - // parts of encoded data - child._decode(input, options); - }); - } - - // Decode contained/encoded by schema, only in bit or octet strings - if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { - var data = new DecoderBuffer(result); - result = this._getUse(state.contains, input._reporterState.obj) - ._decode(data, options); - } - } - - // Pop object - if (state.obj && present) - result = input.leaveObject(prevObj); - - // Set key - if (state.key !== null && (result !== null || present === true)) - input.leaveKey(prevKey, state.key, result); - else if (prevKey !== null) - input.exitKey(prevKey); - - return result; -}; - -Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { - var state = this._baseState; - - if (tag === 'seq' || tag === 'set') - return null; - if (tag === 'seqof' || tag === 'setof') - return this._decodeList(input, tag, state.args[0], options); - else if (/str$/.test(tag)) - return this._decodeStr(input, tag, options); - else if (tag === 'objid' && state.args) - return this._decodeObjid(input, state.args[0], state.args[1], options); - else if (tag === 'objid') - return this._decodeObjid(input, null, null, options); - else if (tag === 'gentime' || tag === 'utctime') - return this._decodeTime(input, tag, options); - else if (tag === 'null_') - return this._decodeNull(input, options); - else if (tag === 'bool') - return this._decodeBool(input, options); - else if (tag === 'objDesc') - return this._decodeStr(input, tag, options); - else if (tag === 'int' || tag === 'enum') - return this._decodeInt(input, state.args && state.args[0], options); - - if (state.use !== null) { - return this._getUse(state.use, input._reporterState.obj) - ._decode(input, options); - } else { - return input.error('unknown tag: ' + tag); - } -}; - -Node.prototype._getUse = function _getUse(entity, obj) { - - var state = this._baseState; - // Create altered use decoder if implicit is set - state.useDecoder = this._use(entity, obj); - assert(state.useDecoder._baseState.parent === null); - state.useDecoder = state.useDecoder._baseState.children[0]; - if (state.implicit !== state.useDecoder._baseState.implicit) { - state.useDecoder = state.useDecoder.clone(); - state.useDecoder._baseState.implicit = state.implicit; - } - return state.useDecoder; -}; - -Node.prototype._decodeChoice = function decodeChoice(input, options) { - var state = this._baseState; - var result = null; - var match = false; - - Object.keys(state.choice).some(function(key) { - var save = input.save(); - var node = state.choice[key]; - try { - var value = node._decode(input, options); - if (input.isError(value)) - return false; - - result = { type: key, value: value }; - match = true; - } catch (e) { - input.restore(save); - return false; - } - return true; - }, this); - - if (!match) - return input.error('Choice not matched'); - - return result; -}; - -// -// Encoding -// - -Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { - return new EncoderBuffer(data, this.reporter); -}; - -Node.prototype._encode = function encode(data, reporter, parent) { - var state = this._baseState; - if (state['default'] !== null && state['default'] === data) - return; - - var result = this._encodeValue(data, reporter, parent); - if (result === undefined) - return; - - if (this._skipDefault(result, reporter, parent)) - return; - - return result; -}; - -Node.prototype._encodeValue = function encode(data, reporter, parent) { - var state = this._baseState; - - // Decode root node - if (state.parent === null) - return state.children[0]._encode(data, reporter || new Reporter()); - - var result = null; - - // Set reporter to share it with a child class - this.reporter = reporter; - - // Check if data is there - if (state.optional && data === undefined) { - if (state['default'] !== null) - data = state['default'] - else - return; - } - - // Encode children first - var content = null; - var primitive = false; - if (state.any) { - // Anything that was given is translated to buffer - result = this._createEncoderBuffer(data); - } else if (state.choice) { - result = this._encodeChoice(data, reporter); - } else if (state.contains) { - content = this._getUse(state.contains, parent)._encode(data, reporter); - primitive = true; - } else if (state.children) { - content = state.children.map(function(child) { - if (child._baseState.tag === 'null_') - return child._encode(null, reporter, data); - - if (child._baseState.key === null) - return reporter.error('Child should have a key'); - var prevKey = reporter.enterKey(child._baseState.key); - - if (typeof data !== 'object') - return reporter.error('Child expected, but input is not object'); - - var res = child._encode(data[child._baseState.key], reporter, data); - reporter.leaveKey(prevKey); - - return res; - }, this).filter(function(child) { - return child; - }); - content = this._createEncoderBuffer(content); - } else { - if (state.tag === 'seqof' || state.tag === 'setof') { - // TODO(indutny): this should be thrown on DSL level - if (!(state.args && state.args.length === 1)) - return reporter.error('Too many args for : ' + state.tag); - - if (!Array.isArray(data)) - return reporter.error('seqof/setof, but data is not Array'); - - var child = this.clone(); - child._baseState.implicit = null; - content = this._createEncoderBuffer(data.map(function(item) { - var state = this._baseState; - - return this._getUse(state.args[0], data)._encode(item, reporter); - }, child)); - } else if (state.use !== null) { - result = this._getUse(state.use, parent)._encode(data, reporter); - } else { - content = this._encodePrimitive(state.tag, data); - primitive = true; - } - } - - // Encode data itself - var result; - if (!state.any && state.choice === null) { - var tag = state.implicit !== null ? state.implicit : state.tag; - var cls = state.implicit === null ? 'universal' : 'context'; - - if (tag === null) { - if (state.use === null) - reporter.error('Tag could be ommited only for .use()'); - } else { - if (state.use === null) - result = this._encodeComposite(tag, primitive, cls, content); - } - } - - // Wrap in explicit - if (state.explicit !== null) - result = this._encodeComposite(state.explicit, false, 'context', result); - - return result; -}; - -Node.prototype._encodeChoice = function encodeChoice(data, reporter) { - var state = this._baseState; - - var node = state.choice[data.type]; - if (!node) { - assert( - false, - data.type + ' not found in ' + - JSON.stringify(Object.keys(state.choice))); - } - return node._encode(data.value, reporter); -}; - -Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { - var state = this._baseState; - - if (/str$/.test(tag)) - return this._encodeStr(data, tag); - else if (tag === 'objid' && state.args) - return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); - else if (tag === 'objid') - return this._encodeObjid(data, null, null); - else if (tag === 'gentime' || tag === 'utctime') - return this._encodeTime(data, tag); - else if (tag === 'null_') - return this._encodeNull(); - else if (tag === 'int' || tag === 'enum') - return this._encodeInt(data, state.args && state.reverseArgs[0]); - else if (tag === 'bool') - return this._encodeBool(data); - else if (tag === 'objDesc') - return this._encodeStr(data, tag); - else - throw new Error('Unsupported tag: ' + tag); -}; - -Node.prototype._isNumstr = function isNumstr(str) { - return /^[0-9 ]*$/.test(str); -}; - -Node.prototype._isPrintstr = function isPrintstr(str) { - return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str); -}; - - -/***/ }, -/* 143 */ -/***/ function(module, exports, __webpack_require__) { - -var inherits = __webpack_require__(2); - -function Reporter(options) { - this._reporterState = { - obj: null, - path: [], - options: options || {}, - errors: [] - }; -} -exports.Reporter = Reporter; - -Reporter.prototype.isError = function isError(obj) { - return obj instanceof ReporterError; -}; - -Reporter.prototype.save = function save() { - var state = this._reporterState; - - return { obj: state.obj, pathLen: state.path.length }; -}; - -Reporter.prototype.restore = function restore(data) { - var state = this._reporterState; - - state.obj = data.obj; - state.path = state.path.slice(0, data.pathLen); -}; - -Reporter.prototype.enterKey = function enterKey(key) { - return this._reporterState.path.push(key); -}; - -Reporter.prototype.exitKey = function exitKey(index) { - var state = this._reporterState; - - state.path = state.path.slice(0, index - 1); -}; - -Reporter.prototype.leaveKey = function leaveKey(index, key, value) { - var state = this._reporterState; - - this.exitKey(index); - if (state.obj !== null) - state.obj[key] = value; -}; - -Reporter.prototype.path = function path() { - return this._reporterState.path.join('/'); -}; - -Reporter.prototype.enterObject = function enterObject() { - var state = this._reporterState; - - var prev = state.obj; - state.obj = {}; - return prev; -}; - -Reporter.prototype.leaveObject = function leaveObject(prev) { - var state = this._reporterState; - - var now = state.obj; - state.obj = prev; - return now; -}; - -Reporter.prototype.error = function error(msg) { - var err; - var state = this._reporterState; - - var inherited = msg instanceof ReporterError; - if (inherited) { - err = msg; - } else { - err = new ReporterError(state.path.map(function(elem) { - return '[' + JSON.stringify(elem) + ']'; - }).join(''), msg.message || msg, msg.stack); - } - - if (!state.options.partial) - throw err; - - if (!inherited) - state.errors.push(err); - - return err; -}; - -Reporter.prototype.wrapResult = function wrapResult(result) { - var state = this._reporterState; - if (!state.options.partial) - return result; - - return { - result: this.isError(result) ? null : result, - errors: state.errors - }; -}; - -function ReporterError(path, msg) { - this.path = path; - this.rethrow(msg); -}; -inherits(ReporterError, Error); - -ReporterError.prototype.rethrow = function rethrow(msg) { - this.message = msg + ' at: ' + (this.path || '(shallow)'); - if (Error.captureStackTrace) - Error.captureStackTrace(this, ReporterError); - - if (!this.stack) { - try { - // IE only adds stack when thrown - throw new Error(this.message); - } catch (e) { - this.stack = e.stack; - } - } - return this; -}; - - -/***/ }, -/* 144 */ -/***/ function(module, exports, __webpack_require__) { - -var constants = __webpack_require__(85); - -exports.tagClass = { - 0: 'universal', - 1: 'application', - 2: 'context', - 3: 'private' -}; -exports.tagClassByName = constants._reverse(exports.tagClass); - -exports.tag = { - 0x00: 'end', - 0x01: 'bool', - 0x02: 'int', - 0x03: 'bitstr', - 0x04: 'octstr', - 0x05: 'null_', - 0x06: 'objid', - 0x07: 'objDesc', - 0x08: 'external', - 0x09: 'real', - 0x0a: 'enum', - 0x0b: 'embed', - 0x0c: 'utf8str', - 0x0d: 'relativeOid', - 0x10: 'seq', - 0x11: 'set', - 0x12: 'numstr', - 0x13: 'printstr', - 0x14: 't61str', - 0x15: 'videostr', - 0x16: 'ia5str', - 0x17: 'utctime', - 0x18: 'gentime', - 0x19: 'graphstr', - 0x1a: 'iso646str', - 0x1b: 'genstr', - 0x1c: 'unistr', - 0x1d: 'charstr', - 0x1e: 'bmpstr' -}; -exports.tagByName = constants._reverse(exports.tag); - - -/***/ }, -/* 145 */ -/***/ function(module, exports, __webpack_require__) { - -var decoders = exports; - -decoders.der = __webpack_require__(86); -decoders.pem = __webpack_require__(146); - - -/***/ }, -/* 146 */ -/***/ function(module, exports, __webpack_require__) { - -var inherits = __webpack_require__(2); -var Buffer = __webpack_require__(0).Buffer; - -var DERDecoder = __webpack_require__(86); - -function PEMDecoder(entity) { - DERDecoder.call(this, entity); - this.enc = 'pem'; -}; -inherits(PEMDecoder, DERDecoder); -module.exports = PEMDecoder; - -PEMDecoder.prototype.decode = function decode(data, options) { - var lines = data.toString().split(/[\r\n]+/g); - - var label = options.label.toUpperCase(); - - var re = /^-----(BEGIN|END) ([^-]+)-----$/; - var start = -1; - var end = -1; - for (var i = 0; i < lines.length; i++) { - var match = lines[i].match(re); - if (match === null) - continue; - - if (match[2] !== label) - continue; - - if (start === -1) { - if (match[1] !== 'BEGIN') - break; - start = i; - } else { - if (match[1] !== 'END') - break; - end = i; - break; - } - } - if (start === -1 || end === -1) - throw new Error('PEM section not found for: ' + label); - - var base64 = lines.slice(start + 1, end).join(''); - // Remove excessive symbols - base64.replace(/[^a-z0-9\+\/=]+/gi, ''); - - var input = new Buffer(base64, 'base64'); - return DERDecoder.prototype.decode.call(this, input, options); -}; - - -/***/ }, -/* 147 */ -/***/ function(module, exports, __webpack_require__) { - -var encoders = exports; - -encoders.der = __webpack_require__(87); -encoders.pem = __webpack_require__(148); - - -/***/ }, -/* 148 */ -/***/ function(module, exports, __webpack_require__) { - -var inherits = __webpack_require__(2); - -var DEREncoder = __webpack_require__(87); - -function PEMEncoder(entity) { - DEREncoder.call(this, entity); - this.enc = 'pem'; -}; -inherits(PEMEncoder, DEREncoder); -module.exports = PEMEncoder; - -PEMEncoder.prototype.encode = function encode(data, options) { - var buf = DEREncoder.prototype.encode.call(this, data); - - var p = buf.toString('base64'); - var out = [ '-----BEGIN ' + options.label + '-----' ]; - for (var i = 0; i < p.length; i += 64) - out.push(p.slice(i, i + 64)); - out.push('-----END ' + options.label + '-----'); - return out.join('\n'); -}; - - -/***/ }, -/* 149 */ +/* 80 */ /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -29562,7 +17248,7 @@ function isBuffer(b) { // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -var util = __webpack_require__(10); +var util = __webpack_require__(68); var hasOwn = Object.prototype.hasOwnProperty; var pSlice = Array.prototype.slice; var functionsHaveNames = (function () { @@ -29988,7 +17674,7 @@ var objectKeys = Object.keys || function (obj) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18))) /***/ }, -/* 150 */ +/* 81 */ /***/ function(module, exports) { "use strict"; @@ -30109,963 +17795,14 @@ function fromByteArray (uint8) { /***/ }, -/* 151 */ +/* 82 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(37) -var Transform = __webpack_require__(20) -var inherits = __webpack_require__(2) -var modes = __webpack_require__(38) -var StreamCipher = __webpack_require__(98) -var AuthCipher = __webpack_require__(91) -var ebtk = __webpack_require__(41) - -inherits(Decipher, Transform) -function Decipher (mode, key, iv) { - if (!(this instanceof Decipher)) { - return new Decipher(mode, key, iv) - } - Transform.call(this) - this._cache = new Splitter() - this._last = void 0 - this._cipher = new aes.AES(key) - this._prev = new Buffer(iv.length) - iv.copy(this._prev) - this._mode = mode - this._autopadding = true -} -Decipher.prototype._update = function (data) { - this._cache.add(data) - var chunk - var thing - var out = [] - while ((chunk = this._cache.get(this._autopadding))) { - thing = this._mode.decrypt(this, chunk) - out.push(thing) - } - return Buffer.concat(out) -} -Decipher.prototype._final = function () { - var chunk = this._cache.flush() - if (this._autopadding) { - return unpad(this._mode.decrypt(this, chunk)) - } else if (chunk) { - throw new Error('data not multiple of block length') - } -} -Decipher.prototype.setAutoPadding = function (setTo) { - this._autopadding = !!setTo - return this -} -function Splitter () { - if (!(this instanceof Splitter)) { - return new Splitter() - } - this.cache = new Buffer('') -} -Splitter.prototype.add = function (data) { - this.cache = Buffer.concat([this.cache, data]) -} - -Splitter.prototype.get = function (autoPadding) { - var out - if (autoPadding) { - if (this.cache.length > 16) { - out = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - return out - } - } else { - if (this.cache.length >= 16) { - out = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - return out - } - } - return null -} -Splitter.prototype.flush = function () { - if (this.cache.length) { - return this.cache - } -} -function unpad (last) { - var padded = last[15] - var i = -1 - while (++i < padded) { - if (last[(i + (16 - padded))] !== padded) { - throw new Error('unable to decrypt data') - } - } - if (padded === 16) { - return - } - return last.slice(0, 16 - padded) -} - -var modelist = { - ECB: __webpack_require__(96), - CBC: __webpack_require__(92), - CFB: __webpack_require__(93), - CFB8: __webpack_require__(95), - CFB1: __webpack_require__(94), - OFB: __webpack_require__(97), - CTR: __webpack_require__(39), - GCM: __webpack_require__(39) -} - -function createDecipheriv (suite, password, iv) { - var config = modes[suite.toLowerCase()] - if (!config) { - throw new TypeError('invalid suite type') - } - if (typeof iv === 'string') { - iv = new Buffer(iv) - } - if (typeof password === 'string') { - password = new Buffer(password) - } - if (password.length !== config.key / 8) { - throw new TypeError('invalid key length ' + password.length) - } - if (iv.length !== config.iv) { - throw new TypeError('invalid iv length ' + iv.length) - } - if (config.type === 'stream') { - return new StreamCipher(modelist[config.mode], password, iv, true) - } else if (config.type === 'auth') { - return new AuthCipher(modelist[config.mode], password, iv, true) - } - return new Decipher(modelist[config.mode], password, iv) -} - -function createDecipher (suite, password) { - var config = modes[suite.toLowerCase()] - if (!config) { - throw new TypeError('invalid suite type') - } - var keys = ebtk(password, false, config.key, config.iv) - return createDecipheriv(suite, keys.key, keys.iv) -} -exports.createDecipher = createDecipher -exports.createDecipheriv = createDecipheriv - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 152 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(37) -var Transform = __webpack_require__(20) -var inherits = __webpack_require__(2) -var modes = __webpack_require__(38) -var ebtk = __webpack_require__(41) -var StreamCipher = __webpack_require__(98) -var AuthCipher = __webpack_require__(91) -inherits(Cipher, Transform) -function Cipher (mode, key, iv) { - if (!(this instanceof Cipher)) { - return new Cipher(mode, key, iv) - } - Transform.call(this) - this._cache = new Splitter() - this._cipher = new aes.AES(key) - this._prev = new Buffer(iv.length) - iv.copy(this._prev) - this._mode = mode - this._autopadding = true -} -Cipher.prototype._update = function (data) { - this._cache.add(data) - var chunk - var thing - var out = [] - while ((chunk = this._cache.get())) { - thing = this._mode.encrypt(this, chunk) - out.push(thing) - } - return Buffer.concat(out) -} -Cipher.prototype._final = function () { - var chunk = this._cache.flush() - if (this._autopadding) { - chunk = this._mode.encrypt(this, chunk) - this._cipher.scrub() - return chunk - } else if (chunk.toString('hex') !== '10101010101010101010101010101010') { - this._cipher.scrub() - throw new Error('data not multiple of block length') - } -} -Cipher.prototype.setAutoPadding = function (setTo) { - this._autopadding = !!setTo - return this -} - -function Splitter () { - if (!(this instanceof Splitter)) { - return new Splitter() - } - this.cache = new Buffer('') -} -Splitter.prototype.add = function (data) { - this.cache = Buffer.concat([this.cache, data]) -} - -Splitter.prototype.get = function () { - if (this.cache.length > 15) { - var out = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - return out - } - return null -} -Splitter.prototype.flush = function () { - var len = 16 - this.cache.length - var padBuff = new Buffer(len) - - var i = -1 - while (++i < len) { - padBuff.writeUInt8(len, i) - } - var out = Buffer.concat([this.cache, padBuff]) - return out -} -var modelist = { - ECB: __webpack_require__(96), - CBC: __webpack_require__(92), - CFB: __webpack_require__(93), - CFB8: __webpack_require__(95), - CFB1: __webpack_require__(94), - OFB: __webpack_require__(97), - CTR: __webpack_require__(39), - GCM: __webpack_require__(39) -} - -function createCipheriv (suite, password, iv) { - var config = modes[suite.toLowerCase()] - if (!config) { - throw new TypeError('invalid suite type') - } - if (typeof iv === 'string') { - iv = new Buffer(iv) - } - if (typeof password === 'string') { - password = new Buffer(password) - } - if (password.length !== config.key / 8) { - throw new TypeError('invalid key length ' + password.length) - } - if (iv.length !== config.iv) { - throw new TypeError('invalid iv length ' + iv.length) - } - if (config.type === 'stream') { - return new StreamCipher(modelist[config.mode], password, iv) - } else if (config.type === 'auth') { - return new AuthCipher(modelist[config.mode], password, iv) - } - return new Cipher(modelist[config.mode], password, iv) -} -function createCipher (suite, password) { - var config = modes[suite.toLowerCase()] - if (!config) { - throw new TypeError('invalid suite type') - } - var keys = ebtk(password, false, config.key, config.iv) - return createCipheriv(suite, keys.key, keys.iv) -} - -exports.createCipheriv = createCipheriv -exports.createCipher = createCipher - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 153 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var zeros = new Buffer(16) -zeros.fill(0) -module.exports = GHASH -function GHASH (key) { - this.h = key - this.state = new Buffer(16) - this.state.fill(0) - this.cache = new Buffer('') -} -// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html -// by Juho Vähä-Herttua -GHASH.prototype.ghash = function (block) { - var i = -1 - while (++i < block.length) { - this.state[i] ^= block[i] - } - this._multiply() -} - -GHASH.prototype._multiply = function () { - var Vi = toArray(this.h) - var Zi = [0, 0, 0, 0] - var j, xi, lsb_Vi - var i = -1 - while (++i < 128) { - xi = (this.state[~~(i / 8)] & (1 << (7 - i % 8))) !== 0 - if (xi) { - // Z_i+1 = Z_i ^ V_i - Zi = xor(Zi, Vi) - } - - // Store the value of LSB(V_i) - lsb_Vi = (Vi[3] & 1) !== 0 - - // V_i+1 = V_i >> 1 - for (j = 3; j > 0; j--) { - Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31) - } - Vi[0] = Vi[0] >>> 1 - - // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R - if (lsb_Vi) { - Vi[0] = Vi[0] ^ (0xe1 << 24) - } - } - this.state = fromArray(Zi) -} -GHASH.prototype.update = function (buf) { - this.cache = Buffer.concat([this.cache, buf]) - var chunk - while (this.cache.length >= 16) { - chunk = this.cache.slice(0, 16) - this.cache = this.cache.slice(16) - this.ghash(chunk) - } -} -GHASH.prototype.final = function (abl, bl) { - if (this.cache.length) { - this.ghash(Buffer.concat([this.cache, zeros], 16)) - } - this.ghash(fromArray([ - 0, abl, - 0, bl - ])) - return this.state -} - -function toArray (buf) { - return [ - buf.readUInt32BE(0), - buf.readUInt32BE(4), - buf.readUInt32BE(8), - buf.readUInt32BE(12) - ] -} -function fromArray (out) { - out = out.map(fixup_uint32) - var buf = new Buffer(16) - buf.writeUInt32BE(out[0], 0) - buf.writeUInt32BE(out[1], 4) - buf.writeUInt32BE(out[2], 8) - buf.writeUInt32BE(out[3], 12) - return buf -} -var uint_max = Math.pow(2, 32) -function fixup_uint32 (x) { - var ret, x_pos - ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x - return ret -} -function xor (a, b) { - return [ - a[0] ^ b[0], - a[1] ^ b[1], - a[2] ^ b[2], - a[3] ^ b[3] - ] -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 154 */ -/***/ function(module, exports, __webpack_require__) { - -var ebtk = __webpack_require__(41) -var aes = __webpack_require__(50) -var DES = __webpack_require__(155) -var desModes = __webpack_require__(156) -var aesModes = __webpack_require__(38) -function createCipher (suite, password) { - var keyLen, ivLen - suite = suite.toLowerCase() - if (aesModes[suite]) { - keyLen = aesModes[suite].key - ivLen = aesModes[suite].iv - } else if (desModes[suite]) { - keyLen = desModes[suite].key * 8 - ivLen = desModes[suite].iv - } else { - throw new TypeError('invalid suite type') - } - var keys = ebtk(password, false, keyLen, ivLen) - return createCipheriv(suite, keys.key, keys.iv) -} -function createDecipher (suite, password) { - var keyLen, ivLen - suite = suite.toLowerCase() - if (aesModes[suite]) { - keyLen = aesModes[suite].key - ivLen = aesModes[suite].iv - } else if (desModes[suite]) { - keyLen = desModes[suite].key * 8 - ivLen = desModes[suite].iv - } else { - throw new TypeError('invalid suite type') - } - var keys = ebtk(password, false, keyLen, ivLen) - return createDecipheriv(suite, keys.key, keys.iv) -} - -function createCipheriv (suite, key, iv) { - suite = suite.toLowerCase() - if (aesModes[suite]) { - return aes.createCipheriv(suite, key, iv) - } else if (desModes[suite]) { - return new DES({ - key: key, - iv: iv, - mode: suite - }) - } else { - throw new TypeError('invalid suite type') - } -} -function createDecipheriv (suite, key, iv) { - suite = suite.toLowerCase() - if (aesModes[suite]) { - return aes.createDecipheriv(suite, key, iv) - } else if (desModes[suite]) { - return new DES({ - key: key, - iv: iv, - mode: suite, - decrypt: true - }) - } else { - throw new TypeError('invalid suite type') - } -} -exports.createCipher = exports.Cipher = createCipher -exports.createCipheriv = exports.Cipheriv = createCipheriv -exports.createDecipher = exports.Decipher = createDecipher -exports.createDecipheriv = exports.Decipheriv = createDecipheriv -function getCiphers () { - return Object.keys(desModes).concat(aes.getCiphers()) -} -exports.listCiphers = exports.getCiphers = getCiphers - - -/***/ }, -/* 155 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var CipherBase = __webpack_require__(20) -var des = __webpack_require__(54) -var inherits = __webpack_require__(2) - -var modes = { - 'des-ede3-cbc': des.CBC.instantiate(des.EDE), - 'des-ede3': des.EDE, - 'des-ede-cbc': des.CBC.instantiate(des.EDE), - 'des-ede': des.EDE, - 'des-cbc': des.CBC.instantiate(des.DES), - 'des-ecb': des.DES -} -modes.des = modes['des-cbc'] -modes.des3 = modes['des-ede3-cbc'] -module.exports = DES -inherits(DES, CipherBase) -function DES (opts) { - CipherBase.call(this) - var modeName = opts.mode.toLowerCase() - var mode = modes[modeName] - var type - if (opts.decrypt) { - type = 'decrypt' - } else { - type = 'encrypt' - } - var key = opts.key - if (modeName === 'des-ede' || modeName === 'des-ede-cbc') { - key = Buffer.concat([key, key.slice(0, 8)]) - } - var iv = opts.iv - this._des = mode.create({ - key: key, - iv: iv, - type: type - }) -} -DES.prototype._update = function (data) { - return new Buffer(this._des.update(data)) -} -DES.prototype._final = function () { - return new Buffer(this._des.final()) -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 156 */ -/***/ function(module, exports) { - -exports['des-ecb'] = { - key: 8, - iv: 0 -} -exports['des-cbc'] = exports.des = { - key: 8, - iv: 8 -} -exports['des-ede3-cbc'] = exports.des3 = { - key: 24, - iv: 8 -} -exports['des-ede3'] = { - key: 24, - iv: 0 -} -exports['des-ede-cbc'] = { - key: 16, - iv: 8 -} -exports['des-ede'] = { - key: 16, - iv: 0 -} - - -/***/ }, -/* 157 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var _algos = __webpack_require__(99) -var createHash = __webpack_require__(21) -var inherits = __webpack_require__(2) -var sign = __webpack_require__(158) -var stream = __webpack_require__(11) -var verify = __webpack_require__(159) - -var algos = {} -Object.keys(_algos).forEach(function (key) { - algos[key] = algos[key.toLowerCase()] = _algos[key] -}) - -function Sign (algorithm) { - stream.Writable.call(this) - - var data = algos[algorithm] - if (!data) { - throw new Error('Unknown message digest') - } - - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Sign, stream.Writable) - -Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} - -Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') { - data = new Buffer(data, enc) - } - - this._hash.update(data) - return this -} - -Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(Buffer.concat([this._tag, hash]), key, this._hashType, this._signType) - - return enc ? sig.toString(enc) : sig -} - -function Verify (algorithm) { - stream.Writable.call(this) - - var data = algos[algorithm] - if (!data) { - throw new Error('Unknown message digest') - } - - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Verify, stream.Writable) - -Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - - done() -} - -Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') { - data = new Buffer(data, enc) - } - - this._hash.update(data) - return this -} - -Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') { - sig = new Buffer(sig, enc) - } - - this.end() - var hash = this._hash.digest() - - return verify(sig, Buffer.concat([this._tag, hash]), key, this._signType) -} - -function createSign (algorithm) { - return new Sign(algorithm) -} - -function createVerify (algorithm) { - return new Verify(algorithm) -} - -module.exports = { - Sign: createSign, - Verify: createVerify, - createSign: createSign, - createVerify: createVerify -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 158 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var createHmac = __webpack_require__(53) -var crt = __webpack_require__(51) -var curves = __webpack_require__(100) -var elliptic = __webpack_require__(9) -var parseKeys = __webpack_require__(43) - -var BN = __webpack_require__(7) -var EC = elliptic.ec - -function sign (hash, key, hashType, signType) { - var priv = parseKeys(key) - if (priv.curve) { - if (signType !== 'ecdsa') throw new Error('wrong private key type') - - return ecSign(hash, priv) - } else if (priv.type === 'dsa') { - if (signType !== 'dsa') { - throw new Error('wrong private key type') - } - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa') throw new Error('wrong private key type') - } - - var len = priv.modulus.byteLength() - var pad = [ 0, 1 ] - while (hash.length + pad.length + 1 < len) { - pad.push(0xff) - } - pad.push(0x00) - var i = -1 - while (++i < hash.length) { - pad.push(hash[i]) - } - - var out = crt(pad, priv) - return out -} - -function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - - var curve = new EC(curveId) - var key = curve.genKeyPair() - - key._importPrivate(priv.privateKey) - var out = key.sign(hash) - - return new Buffer(out.toDER()) -} - -function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) - while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) - if (!s.cmpn(0)) { - s = false - r = new BN(0) - } - } - return toDER(r, s) -} - -function toDER (r, s) { - r = r.toArray() - s = s.toArray() - - // Pad values - if (r[0] & 0x80) { - r = [ 0 ].concat(r) - } - // Pad values - if (s[0] & 0x80) { - s = [0].concat(s) - } - - var total = r.length + s.length + 4 - var res = [ 0x30, total, 0x02, r.length ] - res = res.concat(r, [ 0x02, s.length ], s) - return new Buffer(res) -} - -function getKey (x, q, hash, algo) { - x = new Buffer(x.toArray()) - if (x.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - x.length) - zeros.fill(0) - x = Buffer.concat([zeros, x]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = new Buffer(hlen) - v.fill(1) - var k = new Buffer(hlen) - k.fill(0) - k = createHmac(algo, k) - .update(v) - .update(new Buffer([0])) - .update(x) - .update(hbits) - .digest() - v = createHmac(algo, k) - .update(v) - .digest() - k = createHmac(algo, k) - .update(v) - .update(new Buffer([1])) - .update(x) - .update(hbits) - .digest() - v = createHmac(algo, k) - .update(v) - .digest() - return { - k: k, - v: v - } -} - -function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) { - bits.ishrn(shift) - } - return bits -} - -function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = new Buffer(bits.toArray()) - if (out.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - out.length) - zeros.fill(0) - out = Buffer.concat([zeros, out]) - } - return out -} - -function makeKey (q, kv, algo) { - var t, k - - do { - t = new Buffer('') - - while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k) - .update(kv.v) - .digest() - t = Buffer.concat([t, kv.v]) - } - - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k) - .update(kv.v) - .update(new Buffer([0])) - .digest() - kv.v = createHmac(algo, kv.k) - .update(kv.v) - .digest() - } while (k.cmp(q) !== -1) - - return k -} - -function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) -} - -module.exports = sign -module.exports.getKey = getKey -module.exports.makeKey = makeKey - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 159 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var curves = __webpack_require__(100) -var elliptic = __webpack_require__(9) -var parseKeys = __webpack_require__(43) - -var BN = __webpack_require__(7) -var EC = elliptic.ec - -function verify (sig, hash, key, signType) { - var pub = parseKeys(key) - if (pub.type === 'ec') { - if (signType !== 'ecdsa') { - throw new Error('wrong public key type') - } - return ecVerify(sig, hash, pub) - } else if (pub.type === 'dsa') { - if (signType !== 'dsa') { - throw new Error('wrong public key type') - } - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa') { - throw new Error('wrong public key type') - } - } - var len = pub.modulus.byteLength() - var pad = [ 1 ] - var padNum = 0 - while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ - } - pad.push(0x00) - var i = -1 - while (++i < hash.length) { - pad.push(hash[i]) - } - pad = new Buffer(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) - - sig = sig.redPow(new BN(pub.publicExponent)) - - sig = new Buffer(sig.fromRed().toArray()) - var out = 0 - if (padNum < 8) { - out = 1 - } - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) { - out = 1 - } - - i = -1 - while (++i < len) { - out |= (sig[i] ^ pad[i]) - } - return out === 0 -} - -function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) - - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data - - return curve.verify(hash, sig, pubkey) -} - -function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) - var v = g.toRed(montp) - .redPow(new BN(hash).mul(w).mod(q)) - .fromRed() - .mul( - y.toRed(montp) - .redPow(r.mul(w).mod(q)) - .fromRed() - ).mod(p).mod(q) - return !v.cmp(r) -} - -function checkValue (b, q) { - if (b.cmpn(0) <= 0) { - throw new Error('invalid sig') - } - if (b.cmp(q) >= q) { - throw new Error('invalid sig') - } -} - -module.exports = verify - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 160 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process, Buffer) {var msg = __webpack_require__(111); -var zstream = __webpack_require__(211); -var zlib_deflate = __webpack_require__(206); -var zlib_inflate = __webpack_require__(208); -var constants = __webpack_require__(205); +/* WEBPACK VAR INJECTION */(function(process, Buffer) {var msg = __webpack_require__(61); +var zstream = __webpack_require__(92); +var zlib_deflate = __webpack_require__(87); +var zlib_inflate = __webpack_require__(89); +var constants = __webpack_require__(86); for (var key in constants) { exports[key] = constants[key]; @@ -31298,88 +18035,627 @@ Zlib.prototype._error = function(status) { exports.Zlib = Zlib; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(0).Buffer)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6), __webpack_require__(5).Buffer)) /***/ }, -/* 161 */ -/***/ function(module, exports) { +/* 83 */ +/***/ function(module, exports, __webpack_require__) { -"use strict"; -'use strict'; +/* WEBPACK VAR INJECTION */(function(Buffer, process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -/*! - * bufferutil: WebSocket buffer utils - * Copyright(c) 2015 Einar Otto Stangvik - * MIT Licensed - */ +var Transform = __webpack_require__(64); -module.exports.BufferUtil = { - merge: function(mergedBuffer, buffers) { - for (var i = 0, offset = 0, l = buffers.length; i < l; ++i) { - var buf = buffers[i]; +var binding = __webpack_require__(82); +var util = __webpack_require__(68); +var assert = __webpack_require__(80).ok; - buf.copy(mergedBuffer, offset); - offset += buf.length; - } - }, +// zlib doesn't provide these, so kludge them in following the same +// const naming scheme zlib uses. +binding.Z_MIN_WINDOWBITS = 8; +binding.Z_MAX_WINDOWBITS = 15; +binding.Z_DEFAULT_WINDOWBITS = 15; - mask: function(source, mask, output, offset, length) { - var maskNum = mask.readUInt32LE(0, true) - , i = 0 - , num; +// fewer than 64 bytes per chunk is stupid. +// technically it could work with as few as 8, but even 64 bytes +// is absurdly low. Usually a MB or more is best. +binding.Z_MIN_CHUNK = 64; +binding.Z_MAX_CHUNK = Infinity; +binding.Z_DEFAULT_CHUNK = (16 * 1024); - for (; i < length - 3; i += 4) { - num = maskNum ^ source.readUInt32LE(i, true); +binding.Z_MIN_MEMLEVEL = 1; +binding.Z_MAX_MEMLEVEL = 9; +binding.Z_DEFAULT_MEMLEVEL = 8; - if (num < 0) num = 4294967296 + num; - output.writeUInt32LE(num, offset + i, true); - } +binding.Z_MIN_LEVEL = -1; +binding.Z_MAX_LEVEL = 9; +binding.Z_DEFAULT_LEVEL = binding.Z_DEFAULT_COMPRESSION; - switch (length % 4) { - case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; - case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; - case 1: output[offset + i] = source[i] ^ mask[0]; - } - }, +// expose all the zlib constants +Object.keys(binding).forEach(function(k) { + if (k.match(/^Z/)) exports[k] = binding[k]; +}); - unmask: function(data, mask) { - var maskNum = mask.readUInt32LE(0, true) - , length = data.length - , i = 0 - , num; +// translation table for return codes. +exports.codes = { + Z_OK: binding.Z_OK, + Z_STREAM_END: binding.Z_STREAM_END, + Z_NEED_DICT: binding.Z_NEED_DICT, + Z_ERRNO: binding.Z_ERRNO, + Z_STREAM_ERROR: binding.Z_STREAM_ERROR, + Z_DATA_ERROR: binding.Z_DATA_ERROR, + Z_MEM_ERROR: binding.Z_MEM_ERROR, + Z_BUF_ERROR: binding.Z_BUF_ERROR, + Z_VERSION_ERROR: binding.Z_VERSION_ERROR +}; - for (; i < length - 3; i += 4) { - num = maskNum ^ data.readUInt32LE(i, true); +Object.keys(exports.codes).forEach(function(k) { + exports.codes[exports.codes[k]] = k; +}); - if (num < 0) num = 4294967296 + num; - data.writeUInt32LE(num, i, true); - } +exports.Deflate = Deflate; +exports.Inflate = Inflate; +exports.Gzip = Gzip; +exports.Gunzip = Gunzip; +exports.DeflateRaw = DeflateRaw; +exports.InflateRaw = InflateRaw; +exports.Unzip = Unzip; - switch (length % 4) { - case 3: data[i + 2] = data[i + 2] ^ mask[2]; - case 2: data[i + 1] = data[i + 1] ^ mask[1]; - case 1: data[i] = data[i] ^ mask[0]; - } - } +exports.createDeflate = function(o) { + return new Deflate(o); +}; + +exports.createInflate = function(o) { + return new Inflate(o); +}; + +exports.createDeflateRaw = function(o) { + return new DeflateRaw(o); +}; + +exports.createInflateRaw = function(o) { + return new InflateRaw(o); +}; + +exports.createGzip = function(o) { + return new Gzip(o); +}; + +exports.createGunzip = function(o) { + return new Gunzip(o); +}; + +exports.createUnzip = function(o) { + return new Unzip(o); }; -/***/ }, -/* 162 */ -/***/ function(module, exports, __webpack_require__) { +// Convenience methods. +// compress/decompress a string or buffer in one step. +exports.deflate = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Deflate(opts), buffer, callback); +}; -"use strict"; -'use strict'; +exports.deflateSync = function(buffer, opts) { + return zlibBufferSync(new Deflate(opts), buffer); +}; -try { - module.exports = __webpack_require__(89)('bufferutil'); -} catch (e) { - module.exports = __webpack_require__(161); +exports.gzip = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Gzip(opts), buffer, callback); +}; + +exports.gzipSync = function(buffer, opts) { + return zlibBufferSync(new Gzip(opts), buffer); +}; + +exports.deflateRaw = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new DeflateRaw(opts), buffer, callback); +}; + +exports.deflateRawSync = function(buffer, opts) { + return zlibBufferSync(new DeflateRaw(opts), buffer); +}; + +exports.unzip = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Unzip(opts), buffer, callback); +}; + +exports.unzipSync = function(buffer, opts) { + return zlibBufferSync(new Unzip(opts), buffer); +}; + +exports.inflate = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Inflate(opts), buffer, callback); +}; + +exports.inflateSync = function(buffer, opts) { + return zlibBufferSync(new Inflate(opts), buffer); +}; + +exports.gunzip = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new Gunzip(opts), buffer, callback); +}; + +exports.gunzipSync = function(buffer, opts) { + return zlibBufferSync(new Gunzip(opts), buffer); +}; + +exports.inflateRaw = function(buffer, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + return zlibBuffer(new InflateRaw(opts), buffer, callback); +}; + +exports.inflateRawSync = function(buffer, opts) { + return zlibBufferSync(new InflateRaw(opts), buffer); +}; + +function zlibBuffer(engine, buffer, callback) { + var buffers = []; + var nread = 0; + + engine.on('error', onError); + engine.on('end', onEnd); + + engine.end(buffer); + flow(); + + function flow() { + var chunk; + while (null !== (chunk = engine.read())) { + buffers.push(chunk); + nread += chunk.length; + } + engine.once('readable', flow); + } + + function onError(err) { + engine.removeListener('end', onEnd); + engine.removeListener('readable', flow); + callback(err); + } + + function onEnd() { + var buf = Buffer.concat(buffers, nread); + buffers = []; + callback(null, buf); + engine.close(); + } +} + +function zlibBufferSync(engine, buffer) { + if (typeof buffer === 'string') + buffer = new Buffer(buffer); + if (!Buffer.isBuffer(buffer)) + throw new TypeError('Not a string or buffer'); + + var flushFlag = binding.Z_FINISH; + + return engine._processChunk(buffer, flushFlag); +} + +// generic zlib +// minimal 2-byte header +function Deflate(opts) { + if (!(this instanceof Deflate)) return new Deflate(opts); + Zlib.call(this, opts, binding.DEFLATE); +} + +function Inflate(opts) { + if (!(this instanceof Inflate)) return new Inflate(opts); + Zlib.call(this, opts, binding.INFLATE); } + +// gzip - bigger header, same deflate compression +function Gzip(opts) { + if (!(this instanceof Gzip)) return new Gzip(opts); + Zlib.call(this, opts, binding.GZIP); +} + +function Gunzip(opts) { + if (!(this instanceof Gunzip)) return new Gunzip(opts); + Zlib.call(this, opts, binding.GUNZIP); +} + + + +// raw - no header +function DeflateRaw(opts) { + if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts); + Zlib.call(this, opts, binding.DEFLATERAW); +} + +function InflateRaw(opts) { + if (!(this instanceof InflateRaw)) return new InflateRaw(opts); + Zlib.call(this, opts, binding.INFLATERAW); +} + + +// auto-detect header. +function Unzip(opts) { + if (!(this instanceof Unzip)) return new Unzip(opts); + Zlib.call(this, opts, binding.UNZIP); +} + + +// the Zlib class they all inherit from +// This thing manages the queue of requests, and returns +// true or false if there is anything in the queue when +// you call the .write() method. + +function Zlib(opts, mode) { + this._opts = opts = opts || {}; + this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK; + + Transform.call(this, opts); + + if (opts.flush) { + if (opts.flush !== binding.Z_NO_FLUSH && + opts.flush !== binding.Z_PARTIAL_FLUSH && + opts.flush !== binding.Z_SYNC_FLUSH && + opts.flush !== binding.Z_FULL_FLUSH && + opts.flush !== binding.Z_FINISH && + opts.flush !== binding.Z_BLOCK) { + throw new Error('Invalid flush flag: ' + opts.flush); + } + } + this._flushFlag = opts.flush || binding.Z_NO_FLUSH; + + if (opts.chunkSize) { + if (opts.chunkSize < exports.Z_MIN_CHUNK || + opts.chunkSize > exports.Z_MAX_CHUNK) { + throw new Error('Invalid chunk size: ' + opts.chunkSize); + } + } + + if (opts.windowBits) { + if (opts.windowBits < exports.Z_MIN_WINDOWBITS || + opts.windowBits > exports.Z_MAX_WINDOWBITS) { + throw new Error('Invalid windowBits: ' + opts.windowBits); + } + } + + if (opts.level) { + if (opts.level < exports.Z_MIN_LEVEL || + opts.level > exports.Z_MAX_LEVEL) { + throw new Error('Invalid compression level: ' + opts.level); + } + } + + if (opts.memLevel) { + if (opts.memLevel < exports.Z_MIN_MEMLEVEL || + opts.memLevel > exports.Z_MAX_MEMLEVEL) { + throw new Error('Invalid memLevel: ' + opts.memLevel); + } + } + + if (opts.strategy) { + if (opts.strategy != exports.Z_FILTERED && + opts.strategy != exports.Z_HUFFMAN_ONLY && + opts.strategy != exports.Z_RLE && + opts.strategy != exports.Z_FIXED && + opts.strategy != exports.Z_DEFAULT_STRATEGY) { + throw new Error('Invalid strategy: ' + opts.strategy); + } + } + + if (opts.dictionary) { + if (!Buffer.isBuffer(opts.dictionary)) { + throw new Error('Invalid dictionary: it should be a Buffer instance'); + } + } + + this._binding = new binding.Zlib(mode); + + var self = this; + this._hadError = false; + this._binding.onerror = function(message, errno) { + // there is no way to cleanly recover. + // continuing only obscures problems. + self._binding = null; + self._hadError = true; + + var error = new Error(message); + error.errno = errno; + error.code = exports.codes[errno]; + self.emit('error', error); + }; + + var level = exports.Z_DEFAULT_COMPRESSION; + if (typeof opts.level === 'number') level = opts.level; + + var strategy = exports.Z_DEFAULT_STRATEGY; + if (typeof opts.strategy === 'number') strategy = opts.strategy; + + this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, + level, + opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, + strategy, + opts.dictionary); + + this._buffer = new Buffer(this._chunkSize); + this._offset = 0; + this._closed = false; + this._level = level; + this._strategy = strategy; + + this.once('end', this.close); +} + +util.inherits(Zlib, Transform); + +Zlib.prototype.params = function(level, strategy, callback) { + if (level < exports.Z_MIN_LEVEL || + level > exports.Z_MAX_LEVEL) { + throw new RangeError('Invalid compression level: ' + level); + } + if (strategy != exports.Z_FILTERED && + strategy != exports.Z_HUFFMAN_ONLY && + strategy != exports.Z_RLE && + strategy != exports.Z_FIXED && + strategy != exports.Z_DEFAULT_STRATEGY) { + throw new TypeError('Invalid strategy: ' + strategy); + } + + if (this._level !== level || this._strategy !== strategy) { + var self = this; + this.flush(binding.Z_SYNC_FLUSH, function() { + self._binding.params(level, strategy); + if (!self._hadError) { + self._level = level; + self._strategy = strategy; + if (callback) callback(); + } + }); + } else { + process.nextTick(callback); + } +}; + +Zlib.prototype.reset = function() { + return this._binding.reset(); +}; + +// This is the _flush function called by the transform class, +// internally, when the last chunk has been written. +Zlib.prototype._flush = function(callback) { + this._transform(new Buffer(0), '', callback); +}; + +Zlib.prototype.flush = function(kind, callback) { + var ws = this._writableState; + + if (typeof kind === 'function' || (kind === void 0 && !callback)) { + callback = kind; + kind = binding.Z_FULL_FLUSH; + } + + if (ws.ended) { + if (callback) + process.nextTick(callback); + } else if (ws.ending) { + if (callback) + this.once('end', callback); + } else if (ws.needDrain) { + var self = this; + this.once('drain', function() { + self.flush(callback); + }); + } else { + this._flushFlag = kind; + this.write(new Buffer(0), '', callback); + } +}; + +Zlib.prototype.close = function(callback) { + if (callback) + process.nextTick(callback); + + if (this._closed) + return; + + this._closed = true; + + this._binding.close(); + + var self = this; + process.nextTick(function() { + self.emit('close'); + }); +}; + +Zlib.prototype._transform = function(chunk, encoding, cb) { + var flushFlag; + var ws = this._writableState; + var ending = ws.ending || ws.ended; + var last = ending && (!chunk || ws.length === chunk.length); + + if (!chunk === null && !Buffer.isBuffer(chunk)) + return cb(new Error('invalid input')); + + // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag. + // If it's explicitly flushing at some other time, then we use + // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression + // goodness. + if (last) + flushFlag = binding.Z_FINISH; + else { + flushFlag = this._flushFlag; + // once we've flushed the last of the queue, stop flushing and + // go back to the normal behavior. + if (chunk.length >= ws.length) { + this._flushFlag = this._opts.flush || binding.Z_NO_FLUSH; + } + } + + var self = this; + this._processChunk(chunk, flushFlag, cb); +}; + +Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { + var availInBefore = chunk && chunk.length; + var availOutBefore = this._chunkSize - this._offset; + var inOff = 0; + + var self = this; + + var async = typeof cb === 'function'; + + if (!async) { + var buffers = []; + var nread = 0; + + var error; + this.on('error', function(er) { + error = er; + }); + + do { + var res = this._binding.writeSync(flushFlag, + chunk, // in + inOff, // in_off + availInBefore, // in_len + this._buffer, // out + this._offset, //out_off + availOutBefore); // out_len + } while (!this._hadError && callback(res[0], res[1])); + + if (this._hadError) { + throw error; + } + + var buf = Buffer.concat(buffers, nread); + this.close(); + + return buf; + } + + var req = this._binding.write(flushFlag, + chunk, // in + inOff, // in_off + availInBefore, // in_len + this._buffer, // out + this._offset, //out_off + availOutBefore); // out_len + + req.buffer = chunk; + req.callback = callback; + + function callback(availInAfter, availOutAfter) { + if (self._hadError) + return; + + var have = availOutBefore - availOutAfter; + assert(have >= 0, 'have should not go down'); + + if (have > 0) { + var out = self._buffer.slice(self._offset, self._offset + have); + self._offset += have; + // serve some output to the consumer. + if (async) { + self.push(out); + } else { + buffers.push(out); + nread += out.length; + } + } + + // exhausted the output buffer, or used all the input create a new one. + if (availOutAfter === 0 || self._offset >= self._chunkSize) { + availOutBefore = self._chunkSize; + self._offset = 0; + self._buffer = new Buffer(self._chunkSize); + } + + if (availOutAfter === 0) { + // Not actually done. Need to reprocess. + // Also, update the availInBefore to the availInAfter value, + // so that if we have to hit it a third (fourth, etc.) time, + // it'll have the correct byte counts. + inOff += (availInBefore - availInAfter); + availInBefore = availInAfter; + + if (!async) + return true; + + var newReq = self._binding.write(flushFlag, + chunk, + inOff, + availInBefore, + self._buffer, + self._offset, + self._chunkSize); + newReq.callback = callback; // this same function + newReq.buffer = chunk; + return; + } + + if (!async) + return false; + + // finished with the chunk. + cb(); + } +}; + +util.inherits(Deflate, Zlib); +util.inherits(Inflate, Zlib); +util.inherits(Gzip, Zlib); +util.inherits(Gunzip, Zlib); +util.inherits(DeflateRaw, Zlib); +util.inherits(InflateRaw, Zlib); +util.inherits(Unzip, Zlib); + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer, __webpack_require__(6))) + /***/ }, -/* 163 */ +/* 84 */ /***/ function(module, exports, __webpack_require__) { @@ -31548,7185 +18824,7 @@ Emitter.prototype.hasListeners = function(event){ /***/ }, -/* 164 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var elliptic = __webpack_require__(9); -var BN = __webpack_require__(7); - -module.exports = function createECDH(curve) { - return new ECDH(curve); -}; - -var aliases = { - secp256k1: { - name: 'secp256k1', - byteLength: 32 - }, - secp224r1: { - name: 'p224', - byteLength: 28 - }, - prime256v1: { - name: 'p256', - byteLength: 32 - }, - prime192v1: { - name: 'p192', - byteLength: 24 - }, - ed25519: { - name: 'ed25519', - byteLength: 32 - }, - secp384r1: { - name: 'p384', - byteLength: 48 - }, - secp521r1: { - name: 'p521', - byteLength: 66 - } -}; - -aliases.p224 = aliases.secp224r1; -aliases.p256 = aliases.secp256r1 = aliases.prime256v1; -aliases.p192 = aliases.secp192r1 = aliases.prime192v1; -aliases.p384 = aliases.secp384r1; -aliases.p521 = aliases.secp521r1; - -function ECDH(curve) { - this.curveType = aliases[curve]; - if (!this.curveType ) { - this.curveType = { - name: curve - }; - } - this.curve = new elliptic.ec(this.curveType.name); - this.keys = void 0; -} - -ECDH.prototype.generateKeys = function (enc, format) { - this.keys = this.curve.genKeyPair(); - return this.getPublicKey(enc, format); -}; - -ECDH.prototype.computeSecret = function (other, inenc, enc) { - inenc = inenc || 'utf8'; - if (!Buffer.isBuffer(other)) { - other = new Buffer(other, inenc); - } - var otherPub = this.curve.keyFromPublic(other).getPublic(); - var out = otherPub.mul(this.keys.getPrivate()).getX(); - return formatReturnValue(out, enc, this.curveType.byteLength); -}; - -ECDH.prototype.getPublicKey = function (enc, format) { - var key = this.keys.getPublic(format === 'compressed', true); - if (format === 'hybrid') { - if (key[key.length - 1] % 2) { - key[0] = 7; - } else { - key [0] = 6; - } - } - return formatReturnValue(key, enc); -}; - -ECDH.prototype.getPrivateKey = function (enc) { - return formatReturnValue(this.keys.getPrivate(), enc); -}; - -ECDH.prototype.setPublicKey = function (pub, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc); - } - this.keys._importPublic(pub); - return this; -}; - -ECDH.prototype.setPrivateKey = function (priv, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc); - } - var _priv = new BN(priv); - _priv = _priv.toString(16); - this.keys._importPrivate(_priv); - return this; -}; - -function formatReturnValue(bn, enc, len) { - if (!Array.isArray(bn)) { - bn = bn.toArray(); - } - var buf = new Buffer(bn); - if (len && buf.length < len) { - var zeros = new Buffer(len - buf.length); - zeros.fill(0); - buf = Buffer.concat([zeros, buf]); - } - if (!enc) { - return buf; - } else { - return buf.toString(enc); - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 165 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; -var intSize = 4; -var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0); -var chrsz = 8; - -function toArray(buf, bigEndian) { - if ((buf.length % intSize) !== 0) { - var len = buf.length + (intSize - (buf.length % intSize)); - buf = Buffer.concat([buf, zeroBuffer], len); - } - - var arr = []; - var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE; - for (var i = 0; i < buf.length; i += intSize) { - arr.push(fn.call(buf, i)); - } - return arr; -} - -function toBuffer(arr, size, bigEndian) { - var buf = new Buffer(size); - var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE; - for (var i = 0; i < arr.length; i++) { - fn.call(buf, arr[i], i * 4, true); - } - return buf; -} - -function hash(buf, fn, hashSize, bigEndian) { - if (!Buffer.isBuffer(buf)) buf = new Buffer(buf); - var arr = fn(toArray(buf, bigEndian), buf.length * chrsz); - return toBuffer(arr, hashSize, bigEndian); -} -exports.hash = hash; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 166 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/* -CryptoJS v3.1.2 -code.google.com/p/crypto-js -(c) 2009-2013 by Jeff Mott. All rights reserved. -code.google.com/p/crypto-js/wiki/License -*/ -/** @preserve -(c) 2012 by Cédric Mesnil. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// constants table -var zl = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 -] - -var zr = [ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 -] - -var sl = [ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 -] - -var sr = [ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 -] - -var hl = [0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E] -var hr = [0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000] - -function bytesToWords (bytes) { - var words = [] - for (var i = 0, b = 0; i < bytes.length; i++, b += 8) { - words[b >>> 5] |= bytes[i] << (24 - b % 32) - } - return words -} - -function wordsToBytes (words) { - var bytes = [] - for (var b = 0; b < words.length * 32; b += 8) { - bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF) - } - return bytes -} - -function processBlock (H, M, offset) { - // swap endian - for (var i = 0; i < 16; i++) { - var offset_i = offset + i - var M_offset_i = M[offset_i] - - // Swap - M[offset_i] = ( - (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | - (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) - ) - } - - // Working variables - var al, bl, cl, dl, el - var ar, br, cr, dr, er - - ar = al = H[0] - br = bl = H[1] - cr = cl = H[2] - dr = dl = H[3] - er = el = H[4] - - // computation - var t - for (i = 0; i < 80; i += 1) { - t = (al + M[offset + zl[i]]) | 0 - if (i < 16) { - t += f1(bl, cl, dl) + hl[0] - } else if (i < 32) { - t += f2(bl, cl, dl) + hl[1] - } else if (i < 48) { - t += f3(bl, cl, dl) + hl[2] - } else if (i < 64) { - t += f4(bl, cl, dl) + hl[3] - } else {// if (i<80) { - t += f5(bl, cl, dl) + hl[4] - } - t = t | 0 - t = rotl(t, sl[i]) - t = (t + el) | 0 - al = el - el = dl - dl = rotl(cl, 10) - cl = bl - bl = t - - t = (ar + M[offset + zr[i]]) | 0 - if (i < 16) { - t += f5(br, cr, dr) + hr[0] - } else if (i < 32) { - t += f4(br, cr, dr) + hr[1] - } else if (i < 48) { - t += f3(br, cr, dr) + hr[2] - } else if (i < 64) { - t += f2(br, cr, dr) + hr[3] - } else {// if (i<80) { - t += f1(br, cr, dr) + hr[4] - } - - t = t | 0 - t = rotl(t, sr[i]) - t = (t + er) | 0 - ar = er - er = dr - dr = rotl(cr, 10) - cr = br - br = t - } - - // intermediate hash value - t = (H[1] + cl + dr) | 0 - H[1] = (H[2] + dl + er) | 0 - H[2] = (H[3] + el + ar) | 0 - H[3] = (H[4] + al + br) | 0 - H[4] = (H[0] + bl + cr) | 0 - H[0] = t -} - -function f1 (x, y, z) { - return ((x) ^ (y) ^ (z)) -} - -function f2 (x, y, z) { - return (((x) & (y)) | ((~x) & (z))) -} - -function f3 (x, y, z) { - return (((x) | (~(y))) ^ (z)) -} - -function f4 (x, y, z) { - return (((x) & (z)) | ((y) & (~(z)))) -} - -function f5 (x, y, z) { - return ((x) ^ ((y) | (~(z)))) -} - -function rotl (x, n) { - return (x << n) | (x >>> (32 - n)) -} - -function ripemd160 (message) { - var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0] - - if (typeof message === 'string') { - message = new Buffer(message, 'utf8') - } - - var m = bytesToWords(message) - - var nBitsLeft = message.length * 8 - var nBitsTotal = message.length * 8 - - // Add padding - m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32) - m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( - (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | - (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) - ) - - for (var i = 0; i < m.length; i += 16) { - processBlock(H, m, i) - } - - // swap endian - for (i = 0; i < 5; i++) { - // shortcut - var H_i = H[i] - - // Swap - H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | - (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00) - } - - var digestbytes = wordsToBytes(H) - return new Buffer(digestbytes) -} - -module.exports = ripemd160 - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 167 */ -/***/ function(module, exports, __webpack_require__) { - -var exports = module.exports = function SHA (algorithm) { - algorithm = algorithm.toLowerCase() - - var Algorithm = exports[algorithm] - if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') - - return new Algorithm() -} - -exports.sha = __webpack_require__(168) -exports.sha1 = __webpack_require__(169) -exports.sha224 = __webpack_require__(170) -exports.sha256 = __webpack_require__(103) -exports.sha384 = __webpack_require__(171) -exports.sha512 = __webpack_require__(104) - - -/***/ }, -/* 168 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined - * in FIPS PUB 180-1 - * This source code is derived from sha1.js of the same repository. - * The difference between SHA-0 and SHA-1 is just a bitwise rotate left - * operation was added. - */ - -var inherits = __webpack_require__(2) -var Hash = __webpack_require__(22) - -var K = [ - 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 -] - -var W = new Array(80) - -function Sha () { - this.init() - this._w = W - - Hash.call(this, 64, 56) -} - -inherits(Sha, Hash) - -Sha.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - return this -} - -function rotl5 (num) { - return (num << 5) | (num >>> 27) -} - -function rotl30 (num) { - return (num << 30) | (num >>> 2) -} - -function ft (s, b, c, d) { - if (s === 0) return (b & c) | ((~b) & d) - if (s === 2) return (b & c) | (b & d) | (c & d) - return b ^ c ^ d -} - -Sha.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] - - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20) - var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - - e = d - d = c - c = rotl30(b) - b = a - a = t - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 -} - -Sha.prototype._hash = function () { - var H = new Buffer(20) - - H.writeInt32BE(this._a | 0, 0) - H.writeInt32BE(this._b | 0, 4) - H.writeInt32BE(this._c | 0, 8) - H.writeInt32BE(this._d | 0, 12) - H.writeInt32BE(this._e | 0, 16) - - return H -} - -module.exports = Sha - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 169 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined - * in FIPS PUB 180-1 - * Version 2.1a Copyright Paul Johnston 2000 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for details. - */ - -var inherits = __webpack_require__(2) -var Hash = __webpack_require__(22) - -var K = [ - 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 -] - -var W = new Array(80) - -function Sha1 () { - this.init() - this._w = W - - Hash.call(this, 64, 56) -} - -inherits(Sha1, Hash) - -Sha1.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - return this -} - -function rotl1 (num) { - return (num << 1) | (num >>> 31) -} - -function rotl5 (num) { - return (num << 5) | (num >>> 27) -} - -function rotl30 (num) { - return (num << 30) | (num >>> 2) -} - -function ft (s, b, c, d) { - if (s === 0) return (b & c) | ((~b) & d) - if (s === 2) return (b & c) | (b & d) | (c & d) - return b ^ c ^ d -} - -Sha1.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) - - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20) - var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - - e = d - d = c - c = rotl30(b) - b = a - a = t - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 -} - -Sha1.prototype._hash = function () { - var H = new Buffer(20) - - H.writeInt32BE(this._a | 0, 0) - H.writeInt32BE(this._b | 0, 4) - H.writeInt32BE(this._c | 0, 8) - H.writeInt32BE(this._d | 0, 12) - H.writeInt32BE(this._e | 0, 16) - - return H -} - -module.exports = Sha1 - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 170 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - -var inherits = __webpack_require__(2) -var Sha256 = __webpack_require__(103) -var Hash = __webpack_require__(22) - -var W = new Array(64) - -function Sha224 () { - this.init() - - this._w = W // new Array(64) - - Hash.call(this, 64, 56) -} - -inherits(Sha224, Sha256) - -Sha224.prototype.init = function () { - this._a = 0xc1059ed8 - this._b = 0x367cd507 - this._c = 0x3070dd17 - this._d = 0xf70e5939 - this._e = 0xffc00b31 - this._f = 0x68581511 - this._g = 0x64f98fa7 - this._h = 0xbefa4fa4 - - return this -} - -Sha224.prototype._hash = function () { - var H = new Buffer(28) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - - return H -} - -module.exports = Sha224 - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 171 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var inherits = __webpack_require__(2) -var SHA512 = __webpack_require__(104) -var Hash = __webpack_require__(22) - -var W = new Array(160) - -function Sha384 () { - this.init() - this._w = W - - Hash.call(this, 128, 112) -} - -inherits(Sha384, SHA512) - -Sha384.prototype.init = function () { - this._ah = 0xcbbb9d5d - this._bh = 0x629a292a - this._ch = 0x9159015a - this._dh = 0x152fecd8 - this._eh = 0x67332667 - this._fh = 0x8eb44a87 - this._gh = 0xdb0c2e0d - this._hh = 0x47b5481d - - this._al = 0xc1059ed8 - this._bl = 0x367cd507 - this._cl = 0x3070dd17 - this._dl = 0xf70e5939 - this._el = 0xffc00b31 - this._fl = 0x68581511 - this._gl = 0x64f98fa7 - this._hl = 0xbefa4fa4 - - return this -} - -Sha384.prototype._hash = function () { - var H = new Buffer(48) - - function writeInt64BE (h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._ah, this._al, 0) - writeInt64BE(this._bh, this._bl, 8) - writeInt64BE(this._ch, this._cl, 16) - writeInt64BE(this._dh, this._dl, 24) - writeInt64BE(this._eh, this._el, 32) - writeInt64BE(this._fh, this._fl, 40) - - return H -} - -module.exports = Sha384 - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 172 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var assert = __webpack_require__(29); -var inherits = __webpack_require__(2); - -var proto = {}; - -function CBCState(iv) { - assert.equal(iv.length, 8, 'Invalid IV length'); - - this.iv = new Array(8); - for (var i = 0; i < this.iv.length; i++) - this.iv[i] = iv[i]; -} - -function instantiate(Base) { - function CBC(options) { - Base.call(this, options); - this._cbcInit(); - } - inherits(CBC, Base); - - var keys = Object.keys(proto); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - CBC.prototype[key] = proto[key]; - } - - CBC.create = function create(options) { - return new CBC(options); - }; - - return CBC; -} - -exports.instantiate = instantiate; - -proto._cbcInit = function _cbcInit() { - var state = new CBCState(this.options.iv); - this._cbcState = state; -}; - -proto._update = function _update(inp, inOff, out, outOff) { - var state = this._cbcState; - var superProto = this.constructor.super_.prototype; - - var iv = state.iv; - if (this.type === 'encrypt') { - for (var i = 0; i < this.blockSize; i++) - iv[i] ^= inp[inOff + i]; - - superProto._update.call(this, iv, 0, out, outOff); - - for (var i = 0; i < this.blockSize; i++) - iv[i] = out[outOff + i]; - } else { - superProto._update.call(this, inp, inOff, out, outOff); - - for (var i = 0; i < this.blockSize; i++) - out[outOff + i] ^= iv[i]; - - for (var i = 0; i < this.blockSize; i++) - iv[i] = inp[inOff + i]; - } -}; - - -/***/ }, -/* 173 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var assert = __webpack_require__(29); - -function Cipher(options) { - this.options = options; - - this.type = this.options.type; - this.blockSize = 8; - this._init(); - - this.buffer = new Array(this.blockSize); - this.bufferOff = 0; -} -module.exports = Cipher; - -Cipher.prototype._init = function _init() { - // Might be overrided -}; - -Cipher.prototype.update = function update(data) { - if (data.length === 0) - return []; - - if (this.type === 'decrypt') - return this._updateDecrypt(data); - else - return this._updateEncrypt(data); -}; - -Cipher.prototype._buffer = function _buffer(data, off) { - // Append data to buffer - var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); - for (var i = 0; i < min; i++) - this.buffer[this.bufferOff + i] = data[off + i]; - this.bufferOff += min; - - // Shift next - return min; -}; - -Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { - this._update(this.buffer, 0, out, off); - this.bufferOff = 0; - return this.blockSize; -}; - -Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { - var inputOff = 0; - var outputOff = 0; - - var count = ((this.bufferOff + data.length) / this.blockSize) | 0; - var out = new Array(count * this.blockSize); - - if (this.bufferOff !== 0) { - inputOff += this._buffer(data, inputOff); - - if (this.bufferOff === this.buffer.length) - outputOff += this._flushBuffer(out, outputOff); - } - - // Write blocks - var max = data.length - ((data.length - inputOff) % this.blockSize); - for (; inputOff < max; inputOff += this.blockSize) { - this._update(data, inputOff, out, outputOff); - outputOff += this.blockSize; - } - - // Queue rest - for (; inputOff < data.length; inputOff++, this.bufferOff++) - this.buffer[this.bufferOff] = data[inputOff]; - - return out; -}; - -Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { - var inputOff = 0; - var outputOff = 0; - - var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; - var out = new Array(count * this.blockSize); - - // TODO(indutny): optimize it, this is far from optimal - for (; count > 0; count--) { - inputOff += this._buffer(data, inputOff); - outputOff += this._flushBuffer(out, outputOff); - } - - // Buffer rest of the input - inputOff += this._buffer(data, inputOff); - - return out; -}; - -Cipher.prototype.final = function final(buffer) { - var first; - if (buffer) - first = this.update(buffer); - - var last; - if (this.type === 'encrypt') - last = this._finalEncrypt(); - else - last = this._finalDecrypt(); - - if (first) - return first.concat(last); - else - return last; -}; - -Cipher.prototype._pad = function _pad(buffer, off) { - if (off === 0) - return false; - - while (off < buffer.length) - buffer[off++] = 0; - - return true; -}; - -Cipher.prototype._finalEncrypt = function _finalEncrypt() { - if (!this._pad(this.buffer, this.bufferOff)) - return []; - - var out = new Array(this.blockSize); - this._update(this.buffer, 0, out, 0); - return out; -}; - -Cipher.prototype._unpad = function _unpad(buffer) { - return buffer; -}; - -Cipher.prototype._finalDecrypt = function _finalDecrypt() { - assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); - var out = new Array(this.blockSize); - this._flushBuffer(out, 0); - - return this._unpad(out); -}; - - -/***/ }, -/* 174 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var assert = __webpack_require__(29); -var inherits = __webpack_require__(2); - -var des = __webpack_require__(54); -var utils = des.utils; -var Cipher = des.Cipher; - -function DESState() { - this.tmp = new Array(2); - this.keys = null; -} - -function DES(options) { - Cipher.call(this, options); - - var state = new DESState(); - this._desState = state; - - this.deriveKeys(state, options.key); -} -inherits(DES, Cipher); -module.exports = DES; - -DES.create = function create(options) { - return new DES(options); -}; - -var shiftTable = [ - 1, 1, 2, 2, 2, 2, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 1 -]; - -DES.prototype.deriveKeys = function deriveKeys(state, key) { - state.keys = new Array(16 * 2); - - assert.equal(key.length, this.blockSize, 'Invalid key length'); - - var kL = utils.readUInt32BE(key, 0); - var kR = utils.readUInt32BE(key, 4); - - utils.pc1(kL, kR, state.tmp, 0); - kL = state.tmp[0]; - kR = state.tmp[1]; - for (var i = 0; i < state.keys.length; i += 2) { - var shift = shiftTable[i >>> 1]; - kL = utils.r28shl(kL, shift); - kR = utils.r28shl(kR, shift); - utils.pc2(kL, kR, state.keys, i); - } -}; - -DES.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._desState; - - var l = utils.readUInt32BE(inp, inOff); - var r = utils.readUInt32BE(inp, inOff + 4); - - // Initial Permutation - utils.ip(l, r, state.tmp, 0); - l = state.tmp[0]; - r = state.tmp[1]; - - if (this.type === 'encrypt') - this._encrypt(state, l, r, state.tmp, 0); - else - this._decrypt(state, l, r, state.tmp, 0); - - l = state.tmp[0]; - r = state.tmp[1]; - - utils.writeUInt32BE(out, l, outOff); - utils.writeUInt32BE(out, r, outOff + 4); -}; - -DES.prototype._pad = function _pad(buffer, off) { - var value = buffer.length - off; - for (var i = off; i < buffer.length; i++) - buffer[i] = value; - - return true; -}; - -DES.prototype._unpad = function _unpad(buffer) { - var pad = buffer[buffer.length - 1]; - for (var i = buffer.length - pad; i < buffer.length; i++) - assert.equal(buffer[i], pad); - - return buffer.slice(0, buffer.length - pad); -}; - -DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { - var l = lStart; - var r = rStart; - - // Apply f() x16 times - for (var i = 0; i < state.keys.length; i += 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; - - // f(r, k) - utils.expand(r, state.tmp, 0); - - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); - - var t = r; - r = (l ^ f) >>> 0; - l = t; - } - - // Reverse Initial Permutation - utils.rip(r, l, out, off); -}; - -DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { - var l = rStart; - var r = lStart; - - // Apply f() x16 times - for (var i = state.keys.length - 2; i >= 0; i -= 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; - - // f(r, k) - utils.expand(l, state.tmp, 0); - - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); - - var t = l; - l = (r ^ f) >>> 0; - r = t; - } - - // Reverse Initial Permutation - utils.rip(l, r, out, off); -}; - - -/***/ }, -/* 175 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var assert = __webpack_require__(29); -var inherits = __webpack_require__(2); - -var des = __webpack_require__(54); -var Cipher = des.Cipher; -var DES = des.DES; - -function EDEState(type, key) { - assert.equal(key.length, 24, 'Invalid key length'); - - var k1 = key.slice(0, 8); - var k2 = key.slice(8, 16); - var k3 = key.slice(16, 24); - - if (type === 'encrypt') { - this.ciphers = [ - DES.create({ type: 'encrypt', key: k1 }), - DES.create({ type: 'decrypt', key: k2 }), - DES.create({ type: 'encrypt', key: k3 }) - ]; - } else { - this.ciphers = [ - DES.create({ type: 'decrypt', key: k3 }), - DES.create({ type: 'encrypt', key: k2 }), - DES.create({ type: 'decrypt', key: k1 }) - ]; - } -} - -function EDE(options) { - Cipher.call(this, options); - - var state = new EDEState(this.type, this.options.key); - this._edeState = state; -} -inherits(EDE, Cipher); - -module.exports = EDE; - -EDE.create = function create(options) { - return new EDE(options); -}; - -EDE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edeState; - - state.ciphers[0]._update(inp, inOff, out, outOff); - state.ciphers[1]._update(out, outOff, out, outOff); - state.ciphers[2]._update(out, outOff, out, outOff); -}; - -EDE.prototype._pad = DES.prototype._pad; -EDE.prototype._unpad = DES.prototype._unpad; - - -/***/ }, -/* 176 */ -/***/ function(module, exports) { - -"use strict"; -'use strict'; - -exports.readUInt32BE = function readUInt32BE(bytes, off) { - var res = (bytes[0 + off] << 24) | - (bytes[1 + off] << 16) | - (bytes[2 + off] << 8) | - bytes[3 + off]; - return res >>> 0; -}; - -exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { - bytes[0 + off] = value >>> 24; - bytes[1 + off] = (value >>> 16) & 0xff; - bytes[2 + off] = (value >>> 8) & 0xff; - bytes[3 + off] = value & 0xff; -}; - -exports.ip = function ip(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - for (var i = 6; i >= 0; i -= 2) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - - for (var i = 6; i >= 0; i -= 2) { - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - } - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; - -exports.rip = function rip(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - for (var i = 0; i < 4; i++) { - for (var j = 24; j >= 0; j -= 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - for (var i = 4; i < 8; i++) { - for (var j = 24; j >= 0; j -= 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; - -exports.pc1 = function pc1(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - // 7, 15, 23, 31, 39, 47, 55, 63 - // 6, 14, 22, 30, 39, 47, 55, 63 - // 5, 13, 21, 29, 39, 47, 55, 63 - // 4, 12, 20, 28 - for (var i = 7; i >= 5; i--) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - - // 1, 9, 17, 25, 33, 41, 49, 57 - // 2, 10, 18, 26, 34, 42, 50, 58 - // 3, 11, 19, 27, 35, 43, 51, 59 - // 36, 44, 52, 60 - for (var i = 1; i <= 3; i++) { - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; - -exports.r28shl = function r28shl(num, shift) { - return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); -}; - -var pc2table = [ - // inL => outL - 14, 11, 17, 4, 27, 23, 25, 0, - 13, 22, 7, 18, 5, 9, 16, 24, - 2, 20, 12, 21, 1, 8, 15, 26, - - // inR => outR - 15, 4, 25, 19, 9, 1, 26, 16, - 5, 11, 23, 8, 12, 7, 17, 0, - 22, 3, 10, 14, 6, 20, 27, 24 -]; - -exports.pc2 = function pc2(inL, inR, out, off) { - var outL = 0; - var outR = 0; - - var len = pc2table.length >>> 1; - for (var i = 0; i < len; i++) { - outL <<= 1; - outL |= (inL >>> pc2table[i]) & 0x1; - } - for (var i = len; i < pc2table.length; i++) { - outR <<= 1; - outR |= (inR >>> pc2table[i]) & 0x1; - } - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; - -exports.expand = function expand(r, out, off) { - var outL = 0; - var outR = 0; - - outL = ((r & 1) << 5) | (r >>> 27); - for (var i = 23; i >= 15; i -= 4) { - outL <<= 6; - outL |= (r >>> i) & 0x3f; - } - for (var i = 11; i >= 3; i -= 4) { - outR |= (r >>> i) & 0x3f; - outR <<= 6; - } - outR |= ((r & 0x1f) << 1) | (r >>> 31); - - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; - -var sTable = [ - 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, - 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, - 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, - 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, - - 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, - 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, - 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, - 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, - - 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, - 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, - 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, - 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, - - 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, - 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, - 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, - 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, - - 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, - 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, - 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, - 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, - - 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, - 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, - 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, - 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, - - 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, - 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, - 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, - 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, - - 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, - 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, - 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, - 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 -]; - -exports.substitute = function substitute(inL, inR) { - var out = 0; - for (var i = 0; i < 4; i++) { - var b = (inL >>> (18 - i * 6)) & 0x3f; - var sb = sTable[i * 0x40 + b]; - - out <<= 4; - out |= sb; - } - for (var i = 0; i < 4; i++) { - var b = (inR >>> (18 - i * 6)) & 0x3f; - var sb = sTable[4 * 0x40 + i * 0x40 + b]; - - out <<= 4; - out |= sb; - } - return out >>> 0; -}; - -var permuteTable = [ - 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, - 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 -]; - -exports.permute = function permute(num) { - var out = 0; - for (var i = 0; i < permuteTable.length; i++) { - out <<= 1; - out |= (num >>> permuteTable[i]) & 0x1; - } - return out >>> 0; -}; - -exports.padSplit = function padSplit(num, size, group) { - var str = num.toString(2); - while (str.length < size) - str = '0' + str; - - var out = []; - for (var i = 0; i < size; i += group) - out.push(str.slice(i, i + group)); - return out.join(' '); -}; - - -/***/ }, -/* 177 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var generatePrime = __webpack_require__(105) -var primes = __webpack_require__(202) - -var DH = __webpack_require__(178) - -function getDiffieHellman (mod) { - var prime = new Buffer(primes[mod].prime, 'hex') - var gen = new Buffer(primes[mod].gen, 'hex') - - return new DH(prime, gen) -} - -var ENCODINGS = { - 'binary': true, 'hex': true, 'base64': true -} - -function createDiffieHellman (prime, enc, generator, genc) { - if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { - return createDiffieHellman(prime, 'binary', enc, generator) - } - - enc = enc || 'binary' - genc = genc || 'binary' - generator = generator || new Buffer([2]) - - if (!Buffer.isBuffer(generator)) { - generator = new Buffer(generator, genc) - } - - if (typeof prime === 'number') { - return new DH(generatePrime(prime, generator), generator, true) - } - - if (!Buffer.isBuffer(prime)) { - prime = new Buffer(prime, enc) - } - - return new DH(prime, generator, true) -} - -exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman -exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 178 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var BN = __webpack_require__(7); -var MillerRabin = __webpack_require__(107); -var millerRabin = new MillerRabin(); -var TWENTYFOUR = new BN(24); -var ELEVEN = new BN(11); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var primes = __webpack_require__(105); -var randomBytes = __webpack_require__(30); -module.exports = DH; - -function setPublicKey(pub, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc); - } - this._pub = new BN(pub); - return this; -} - -function setPrivateKey(priv, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc); - } - this._priv = new BN(priv); - return this; -} - -var primeCache = {}; -function checkPrime(prime, generator) { - var gen = generator.toString('hex'); - var hex = [gen, prime.toString(16)].join('_'); - if (hex in primeCache) { - return primeCache[hex]; - } - var error = 0; - - if (prime.isEven() || - !primes.simpleSieve || - !primes.fermatTest(prime) || - !millerRabin.test(prime)) { - //not a prime so +1 - error += 1; - - if (gen === '02' || gen === '05') { - // we'd be able to check the generator - // it would fail so +8 - error += 8; - } else { - //we wouldn't be able to test the generator - // so +4 - error += 4; - } - primeCache[hex] = error; - return error; - } - if (!millerRabin.test(prime.shrn(1))) { - //not a safe prime - error += 2; - } - var rem; - switch (gen) { - case '02': - if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { - // unsuidable generator - error += 8; - } - break; - case '05': - rem = prime.mod(TEN); - if (rem.cmp(THREE) && rem.cmp(SEVEN)) { - // prime mod 10 needs to equal 3 or 7 - error += 8; - } - break; - default: - error += 4; - } - primeCache[hex] = error; - return error; -} - -function DH(prime, generator, malleable) { - this.setGenerator(generator); - this.__prime = new BN(prime); - this._prime = BN.mont(this.__prime); - this._primeLen = prime.length; - this._pub = undefined; - this._priv = undefined; - this._primeCode = undefined; - if (malleable) { - this.setPublicKey = setPublicKey; - this.setPrivateKey = setPrivateKey; - } else { - this._primeCode = 8; - } -} -Object.defineProperty(DH.prototype, 'verifyError', { - enumerable: true, - get: function () { - if (typeof this._primeCode !== 'number') { - this._primeCode = checkPrime(this.__prime, this.__gen); - } - return this._primeCode; - } -}); -DH.prototype.generateKeys = function () { - if (!this._priv) { - this._priv = new BN(randomBytes(this._primeLen)); - } - this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); - return this.getPublicKey(); -}; - -DH.prototype.computeSecret = function (other) { - other = new BN(other); - other = other.toRed(this._prime); - var secret = other.redPow(this._priv).fromRed(); - var out = new Buffer(secret.toArray()); - var prime = this.getPrime(); - if (out.length < prime.length) { - var front = new Buffer(prime.length - out.length); - front.fill(0); - out = Buffer.concat([front, out]); - } - return out; -}; - -DH.prototype.getPublicKey = function getPublicKey(enc) { - return formatReturnValue(this._pub, enc); -}; - -DH.prototype.getPrivateKey = function getPrivateKey(enc) { - return formatReturnValue(this._priv, enc); -}; - -DH.prototype.getPrime = function (enc) { - return formatReturnValue(this.__prime, enc); -}; - -DH.prototype.getGenerator = function (enc) { - return formatReturnValue(this._gen, enc); -}; - -DH.prototype.setGenerator = function (gen, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(gen)) { - gen = new Buffer(gen, enc); - } - this.__gen = gen; - this._gen = new BN(gen); - return this; -}; - -function formatReturnValue(bn, enc) { - var buf = new Buffer(bn.toArray()); - if (!enc) { - return buf; - } else { - return buf.toString(enc); - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 179 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var BN = __webpack_require__(7); -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; - -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); - - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); - - // Useful for many curves - this.zero = new BN(0).toRed(this.red); - this.one = new BN(1).toRed(this.red); - this.two = new BN(2).toRed(this.red); - - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); - - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); - - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; - } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); - } -} -module.exports = BaseCurve; - -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; - -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; - -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); - - var naf = getNAF(k, 1); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; - - // Translate into more windowed form - var repr = []; - for (var j = 0; j < naf.length; j += doubles.step) { - var nafW = 0; - for (var k = j + doubles.step - 1; k >= j; k--) - nafW = (nafW << 1) + naf[k]; - repr.push(nafW); - } - - var a = this.jpoint(null, null, null); - var b = this.jpoint(null, null, null); - for (var i = I; i > 0; i--) { - for (var j = 0; j < repr.length; j++) { - var nafW = repr[j]; - if (nafW === i) - b = b.mixedAdd(doubles.points[j]); - else if (nafW === -i) - b = b.mixedAdd(doubles.points[j].neg()); - } - a = a.add(b); - } - return a.toP(); -}; - -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; - - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; - - // Get NAF form - var naf = getNAF(k, w); - - // Add `this`*(N+1) for every w-NAF index - var acc = this.jpoint(null, null, null); - for (var i = naf.length - 1; i >= 0; i--) { - // Count zeroes - for (var k = 0; i >= 0 && naf[i] === 0; i--) - k++; - if (i >= 0) - k++; - acc = acc.dblp(k); - - if (i < 0) - break; - var z = naf[i]; - assert(z !== 0); - if (p.type === 'affine') { - // J +- P - if (z > 0) - acc = acc.mixedAdd(wnd[(z - 1) >> 1]); - else - acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); - } else { - // J +- J - if (z > 0) - acc = acc.add(wnd[(z - 1) >> 1]); - else - acc = acc.add(wnd[(-z - 1) >> 1].neg()); - } - } - return p.type === 'affine' ? acc.toP() : acc; -}; - -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; - - // Fill all arrays - var max = 0; - for (var i = 0; i < len; i++) { - var p = points[i]; - var nafPoints = p._getNAFPoints(defW); - wndWidth[i] = nafPoints.wnd; - wnd[i] = nafPoints.points; - } - - // Comb small window NAFs - for (var i = len - 1; i >= 1; i -= 2) { - var a = i - 1; - var b = i; - if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { - naf[a] = getNAF(coeffs[a], wndWidth[a]); - naf[b] = getNAF(coeffs[b], wndWidth[b]); - max = Math.max(naf[a].length, max); - max = Math.max(naf[b].length, max); - continue; - } - - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b] /* 7 */ - ]; - - // Try to avoid Projective points, if possible - if (points[a].y.cmp(points[b].y) === 0) { - comb[1] = points[a].add(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].add(points[b].neg()); - } else { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } - - var index = [ - -3, /* -1 -1 */ - -1, /* -1 0 */ - -5, /* -1 1 */ - -7, /* 0 -1 */ - 0, /* 0 0 */ - 7, /* 0 1 */ - 5, /* 1 -1 */ - 1, /* 1 0 */ - 3 /* 1 1 */ - ]; - - var jsf = getJSF(coeffs[a], coeffs[b]); - max = Math.max(jsf[0].length, max); - naf[a] = new Array(max); - naf[b] = new Array(max); - for (var j = 0; j < max; j++) { - var ja = jsf[0][j] | 0; - var jb = jsf[1][j] | 0; - - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } - - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (var i = max; i >= 0; i--) { - var k = 0; - - while (i >= 0) { - var zero = true; - for (var j = 0; j < len; j++) { - tmp[j] = naf[j][i] | 0; - if (tmp[j] !== 0) - zero = false; - } - if (!zero) - break; - k++; - i--; - } - if (i >= 0) - k++; - acc = acc.dblp(k); - if (i < 0) - break; - - for (var j = 0; j < len; j++) { - var z = tmp[j]; - var p; - if (z === 0) - continue; - else if (z > 0) - p = wnd[j][(z - 1) >> 1]; - else if (z < 0) - p = wnd[j][(-z - 1) >> 1].neg(); - - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } - } - // Zeroify references - for (var i = 0; i < len; i++) - wnd[i] = null; - - if (jacobianResult) - return acc; - else - return acc.toP(); -}; - -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; -} -BaseCurve.BasePoint = BasePoint; - -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); -}; - -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); -}; - -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); - - var len = this.p.byteLength(); - - // uncompressed, hybrid-odd, hybrid-even - if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && - bytes.length - 1 === 2 * len) { - if (bytes[0] === 0x06) - assert(bytes[bytes.length - 1] % 2 === 0); - else if (bytes[0] === 0x07) - assert(bytes[bytes.length - 1] % 2 === 1); - - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); - - return res; - } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && - bytes.length - 1 === len) { - return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); - } - throw new Error('Unknown point format'); -}; - -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; - -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); - - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); - - return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; -}; - -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; - -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; - - var precomputed = { - doubles: null, - naf: null, - beta: null - }; - precomputed.naf = this._getNAFPoints(8); - precomputed.doubles = this._getDoubles(4, power); - precomputed.beta = this._getBeta(); - this.precomputed = precomputed; - - return this; -}; - -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; - - var doubles = this.precomputed.doubles; - if (!doubles) - return false; - - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; - -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; - - var doubles = [ this ]; - var acc = this; - for (var i = 0; i < power; i += step) { - for (var j = 0; j < step; j++) - acc = acc.dbl(); - doubles.push(acc); - } - return { - step: step, - points: doubles - }; -}; - -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; - - var res = [ this ]; - var max = (1 << wnd) - 1; - var dbl = max === 1 ? null : this.dbl(); - for (var i = 1; i < max; i++) - res[i] = res[i - 1].add(dbl); - return { - wnd: wnd, - points: res - }; -}; - -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; - -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; - - -/***/ }, -/* 180 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var curve = __webpack_require__(40); -var elliptic = __webpack_require__(9); -var BN = __webpack_require__(7); -var inherits = __webpack_require__(2); -var Base = curve.base; - -var assert = elliptic.utils.assert; - -function EdwardsCurve(conf) { - // NOTE: Important as we are creating point in Base.call() - this.twisted = (conf.a | 0) !== 1; - this.mOneA = this.twisted && (conf.a | 0) === -1; - this.extended = this.mOneA; - - Base.call(this, 'edwards', conf); - - this.a = new BN(conf.a, 16).umod(this.red.m); - this.a = this.a.toRed(this.red); - this.c = new BN(conf.c, 16).toRed(this.red); - this.c2 = this.c.redSqr(); - this.d = new BN(conf.d, 16).toRed(this.red); - this.dd = this.d.redAdd(this.d); - - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; - -EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); - else - return this.a.redMul(num); -}; - -EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); -}; - -// Just for compatibility with Short curve -EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); -}; - -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var x2 = x.redSqr(); - var rhs = this.c2.redSub(this.a.redMul(x2)); - var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); -}; - -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); - - // x^2 = (y^2 - 1) / (d y^2 + 1) - var y2 = y.redSqr(); - var lhs = y2.redSub(this.one); - var rhs = y2.redMul(this.d).redAdd(this.one); - var x2 = lhs.redMul(rhs.redInvm()); - - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } - - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - if (x.isOdd() !== odd) - x = x.redNeg(); - - return this.point(x, y); -}; - -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; - - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); - - var x2 = point.x.redSqr(); - var y2 = point.y.redSqr(); - var lhs = x2.redMul(this.a).redAdd(y2); - var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); - - return lhs.cmp(rhs) === 0; -}; - -function Point(curve, x, y, z, t) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && y === null && z === null) { - this.x = this.curve.zero; - this.y = this.curve.one; - this.z = this.curve.one; - this.t = this.curve.zero; - this.zOne = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = z ? new BN(z, 16) : this.curve.one; - this.t = t && new BN(t, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - if (this.t && !this.t.red) - this.t = this.t.toRed(this.curve.red); - this.zOne = this.z === this.curve.one; - - // Use extended coordinates - if (this.curve.extended && !this.t) { - this.t = this.x.redMul(this.y); - if (!this.zOne) - this.t = this.t.redMul(this.z.redInvm()); - } - } -} -inherits(Point, Base.BasePoint); - -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; - -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); -}; - -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); -}; - -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.x.cmpn(0) === 0 && - this.y.cmp(this.z) === 0; -}; - -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S - - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = 2 * Z1^2 - var c = this.z.redSqr(); - c = c.redIAdd(c); - // D = a * A - var d = this.curve._mulA(a); - // E = (X1 + Y1)^2 - A - B - var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); - // G = D + B - var g = d.redAdd(b); - // F = G - C - var f = g.redSub(c); - // H = D - B - var h = d.redSub(b); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); -}; - -Point.prototype._projDbl = function _projDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #doubling-dbl-2008-bbjlp - // #doubling-dbl-2007-bl - // and others - // Generally 3M + 4S or 2M + 4S - - // B = (X1 + Y1)^2 - var b = this.x.redAdd(this.y).redSqr(); - // C = X1^2 - var c = this.x.redSqr(); - // D = Y1^2 - var d = this.y.redSqr(); - - var nx; - var ny; - var nz; - if (this.curve.twisted) { - // E = a * C - var e = this.curve._mulA(c); - // F = E + D - var f = e.redAdd(d); - if (this.zOne) { - // X3 = (B - C - D) * (F - 2) - nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F^2 - 2 * F - nz = f.redSqr().redSub(f).redSub(f); - } else { - // H = Z1^2 - var h = this.z.redSqr(); - // J = F - 2 * H - var j = f.redSub(h).redISub(h); - // X3 = (B-C-D)*J - nx = b.redSub(c).redISub(d).redMul(j); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F * J - nz = f.redMul(j); - } - } else { - // E = C + D - var e = c.redAdd(d); - // H = (c * Z1)^2 - var h = this.curve._mulC(this.c.redMul(this.z)).redSqr(); - // J = E - 2 * H - var j = e.redSub(h).redSub(h); - // X3 = c * (B - E) * J - nx = this.curve._mulC(b.redISub(e)).redMul(j); - // Y3 = c * E * (C - D) - ny = this.curve._mulC(e).redMul(c.redISub(d)); - // Z3 = E * J - nz = e.redMul(j); - } - return this.curve.point(nx, ny, nz); -}; - -Point.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; - - // Double in extended coordinates - if (this.curve.extended) - return this._extDbl(); - else - return this._projDbl(); -}; - -Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M - - // A = (Y1 - X1) * (Y2 - X2) - var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); - // B = (Y1 + X1) * (Y2 + X2) - var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); - // C = T1 * k * T2 - var c = this.t.redMul(this.curve.dd).redMul(p.t); - // D = Z1 * 2 * Z2 - var d = this.z.redMul(p.z.redAdd(p.z)); - // E = B - A - var e = b.redSub(a); - // F = D - C - var f = d.redSub(c); - // G = D + C - var g = d.redAdd(c); - // H = B + A - var h = b.redAdd(a); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); -}; - -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S - - // A = Z1 * Z2 - var a = this.z.redMul(p.z); - // B = A^2 - var b = a.redSqr(); - // C = X1 * X2 - var c = this.x.redMul(p.x); - // D = Y1 * Y2 - var d = this.y.redMul(p.y); - // E = d * C * D - var e = this.curve.d.redMul(c).redMul(d); - // F = B - E - var f = b.redSub(e); - // G = B + E - var g = b.redAdd(e); - // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) - var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); - var nx = a.redMul(f).redMul(tmp); - var ny; - var nz; - if (this.curve.twisted) { - // Y3 = A * G * (D - a * C) - ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); - // Z3 = F * G - nz = f.redMul(g); - } else { - // Y3 = A * G * (D - C) - ny = a.redMul(g).redMul(d.redSub(c)); - // Z3 = c * F * G - nz = this.curve._mulC(f).redMul(g); - } - return this.curve.point(nx, ny, nz); -}; - -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; - - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; - -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); -}; - -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; - -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; - -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; - - // Normalize coordinates - var zi = this.z.redInvm(); - this.x = this.x.redMul(zi); - this.y = this.y.redMul(zi); - if (this.t) - this.t = this.t.redMul(zi); - this.z = this.curve.one; - this.zOne = true; - return this; -}; - -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); -}; - -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; - -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); -}; - -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; -}; - -Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; - - var xc = x.clone(); - var t = this.curve.redN.redMul(this.z); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; - - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } - return false; -}; - -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; - - -/***/ }, -/* 181 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var curve = __webpack_require__(40); -var BN = __webpack_require__(7); -var inherits = __webpack_require__(2); -var Base = curve.base; - -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; - -function MontCurve(conf) { - Base.call(this, 'mont', conf); - - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.i4 = new BN(4).toRed(this.red).redInvm(); - this.two = new BN(2).toRed(this.red); - this.a24 = this.i4.redMul(this.a.redAdd(this.two)); -} -inherits(MontCurve, Base); -module.exports = MontCurve; - -MontCurve.prototype.validate = function validate(point) { - var x = point.normalize().x; - var x2 = x.redSqr(); - var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); - var y = rhs.redSqrt(); - - return y.redSqr().cmp(rhs) === 0; -}; - -function Point(curve, x, z) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && z === null) { - this.x = this.curve.one; - this.z = this.curve.zero; - } else { - this.x = new BN(x, 16); - this.z = new BN(z, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - } -} -inherits(Point, Base.BasePoint); - -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); -}; - -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); -}; - -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; - -Point.prototype.precompute = function precompute() { - // No-op -}; - -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); -}; - -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; - -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; - -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A - - // A = X1 + Z1 - var a = this.x.redAdd(this.z); - // AA = A^2 - var aa = a.redSqr(); - // B = X1 - Z1 - var b = this.x.redSub(this.z); - // BB = B^2 - var bb = b.redSqr(); - // C = AA - BB - var c = aa.redSub(bb); - // X3 = AA * BB - var nx = aa.redMul(bb); - // Z3 = C * (BB + A24 * C) - var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); - return this.curve.point(nx, nz); -}; - -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); -}; - -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A - - // A = X2 + Z2 - var a = this.x.redAdd(this.z); - // B = X2 - Z2 - var b = this.x.redSub(this.z); - // C = X3 + Z3 - var c = p.x.redAdd(p.z); - // D = X3 - Z3 - var d = p.x.redSub(p.z); - // DA = D * A - var da = d.redMul(a); - // CB = C * B - var cb = c.redMul(b); - // X5 = Z1 * (DA + CB)^2 - var nx = diff.z.redMul(da.redAdd(cb).redSqr()); - // Z5 = X1 * (DA - CB)^2 - var nz = diff.x.redMul(da.redISub(cb).redSqr()); - return this.curve.point(nx, nz); -}; - -Point.prototype.mul = function mul(k) { - var t = k.clone(); - var a = this; // (N / 2) * Q + Q - var b = this.curve.point(null, null); // (N / 2) * Q - var c = this; // Q - - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); - - for (var i = bits.length - 1; i >= 0; i--) { - if (bits[i] === 0) { - // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q - a = a.diffAdd(b, c); - // N * Q = 2 * ((N / 2) * Q + Q)) - b = b.dbl(); - } else { - // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) - b = a.diffAdd(b, c); - // N * Q + Q = 2 * ((N / 2) * Q + Q) - a = a.dbl(); - } - } - return b; -}; - -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); -}; - -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); -}; - -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; -}; - -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; -}; - -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); - - return this.x.fromRed(); -}; - - -/***/ }, -/* 182 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var curve = __webpack_require__(40); -var elliptic = __webpack_require__(9); -var BN = __webpack_require__(7); -var inherits = __webpack_require__(2); -var Base = curve.base; - -var assert = elliptic.utils.assert; - -function ShortCurve(conf) { - Base.call(this, 'short', conf); - - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.tinv = this.two.redInvm(); - - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - - // If the curve is endomorphic, precalculate beta and lambda - this.endo = this._getEndomorphism(conf); - this._endoWnafT1 = new Array(4); - this._endoWnafT2 = new Array(4); -} -inherits(ShortCurve, Base); -module.exports = ShortCurve; - -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; - - // Compute beta and lambda, that lambda * P = (beta * Px; Py) - var beta; - var lambda; - if (conf.beta) { - beta = new BN(conf.beta, 16).toRed(this.red); - } else { - var betas = this._getEndoRoots(this.p); - // Choose the smallest beta - beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; - beta = beta.toRed(this.red); - } - if (conf.lambda) { - lambda = new BN(conf.lambda, 16); - } else { - // Choose the lambda that is matching selected beta - var lambdas = this._getEndoRoots(this.n); - if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { - lambda = lambdas[0]; - } else { - lambda = lambdas[1]; - assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); - } - } - - // Get basis vectors, used for balanced length-two representation - var basis; - if (conf.basis) { - basis = conf.basis.map(function(vec) { - return { - a: new BN(vec.a, 16), - b: new BN(vec.b, 16) - }; - }); - } else { - basis = this._getEndoBasis(lambda); - } - - return { - beta: beta, - lambda: lambda, - basis: basis - }; -}; - -ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { - // Find roots of for x^2 + x + 1 in F - // Root = (-1 +- Sqrt(-3)) / 2 - // - var red = num === this.p ? this.red : BN.mont(num); - var tinv = new BN(2).toRed(red).redInvm(); - var ntinv = tinv.redNeg(); - - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; -}; - -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - - // 3.74 - // Run EGCD, until r(L + 1) < aprxSqrt - var u = lambda; - var v = this.n.clone(); - var x1 = new BN(1); - var y1 = new BN(0); - var x2 = new BN(0); - var y2 = new BN(1); - - // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) - var a0; - var b0; - // First vector - var a1; - var b1; - // Second vector - var a2; - var b2; - - var prevR; - var i = 0; - var r; - var x; - while (u.cmpn(0) !== 0) { - var q = v.div(u); - r = v.sub(q.mul(u)); - x = x2.sub(q.mul(x1)); - var y = y2.sub(q.mul(y1)); - - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; - - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; - - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } - - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); - } - - return [ - { a: a1, b: b1 }, - { a: a2, b: b2 } - ]; -}; - -ShortCurve.prototype._endoSplit = function _endoSplit(k) { - var basis = this.endo.basis; - var v1 = basis[0]; - var v2 = basis[1]; - - var c1 = v2.b.mul(k).divRound(this.n); - var c2 = v1.b.neg().mul(k).divRound(this.n); - - var p1 = c1.mul(v1.a); - var p2 = c2.mul(v2.a); - var q1 = c1.mul(v1.b); - var q2 = c2.mul(v2.b); - - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; -}; - -ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - // XXX Is there any way to tell if the number is odd without converting it - // to non-red form? - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); -}; - -ShortCurve.prototype.validate = function validate(point) { - if (point.inf) - return true; - - var x = point.x; - var y = point.y; - - var ax = this.a.redMul(x); - var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); - return y.redSqr().redISub(rhs).cmpn(0) === 0; -}; - -ShortCurve.prototype._endoWnafMulAdd = - function _endoWnafMulAdd(points, coeffs, jacobianResult) { - var npoints = this._endoWnafT1; - var ncoeffs = this._endoWnafT2; - for (var i = 0; i < points.length; i++) { - var split = this._endoSplit(coeffs[i]); - var p = points[i]; - var beta = p._getBeta(); - - if (split.k1.negative) { - split.k1.ineg(); - p = p.neg(true); - } - if (split.k2.negative) { - split.k2.ineg(); - beta = beta.neg(true); - } - - npoints[i * 2] = p; - npoints[i * 2 + 1] = beta; - ncoeffs[i * 2] = split.k1; - ncoeffs[i * 2 + 1] = split.k2; - } - var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - - // Clean-up references to points and coefficients - for (var j = 0; j < i * 2; j++) { - npoints[j] = null; - ncoeffs[j] = null; - } - return res; -}; - -function Point(curve, x, y, isRed) { - Base.BasePoint.call(this, curve, 'affine'); - if (x === null && y === null) { - this.x = null; - this.y = null; - this.inf = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - // Force redgomery representation when loading from JSON - if (isRed) { - this.x.forceRed(this.curve.red); - this.y.forceRed(this.curve.red); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - this.inf = false; - } -} -inherits(Point, Base.BasePoint); - -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); -}; - -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); -}; - -Point.prototype._getBeta = function _getBeta() { - if (!this.curve.endo) - return; - - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; - - var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (pre) { - var curve = this.curve; - var endoMul = function(p) { - return curve.point(p.x.redMul(curve.endo.beta), p.y); - }; - pre.beta = beta; - beta.precomputed = { - beta: null, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(endoMul) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(endoMul) - } - }; - } - return beta; -}; - -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; - - return [ this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - } ]; -}; - -Point.fromJSON = function fromJSON(curve, obj, red) { - if (typeof obj === 'string') - obj = JSON.parse(obj); - var res = curve.point(obj[0], obj[1], red); - if (!obj[2]) - return res; - - function obj2point(obj) { - return curve.point(obj[0], obj[1], red); - } - - var pre = obj[2]; - res.precomputed = { - beta: null, - doubles: pre.doubles && { - step: pre.doubles.step, - points: [ res ].concat(pre.doubles.points.map(obj2point)) - }, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: [ res ].concat(pre.naf.points.map(obj2point)) - } - }; - return res; -}; - -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -Point.prototype.isInfinity = function isInfinity() { - return this.inf; -}; - -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; - - // P + O = P - if (p.inf) - return this; - - // P + P = 2P - if (this.eq(p)) - return this.dbl(); - - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); - - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); - - var c = this.y.redSub(p.y); - if (c.cmpn(0) !== 0) - c = c.redMul(this.x.redSub(p.x).redInvm()); - var nx = c.redSqr().redISub(this.x).redISub(p.x); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; - -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; - - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); - - var a = this.curve.a; - - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); - - var nx = c.redSqr().redISub(this.x.redAdd(this.x)); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; - -Point.prototype.getX = function getX() { - return this.x.fromRed(); -}; - -Point.prototype.getY = function getY() { - return this.y.fromRed(); -}; - -Point.prototype.mul = function mul(k) { - k = new BN(k, 16); - - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else if (this.curve.endo) - return this.curve._endoWnafMulAdd([ this ], [ k ]); - else - return this.curve._wnafMul(this, k); -}; - -Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2); -}; - -Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs, true); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2, true); -}; - -Point.prototype.eq = function eq(p) { - return this === p || - this.inf === p.inf && - (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); -}; - -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; - - var res = this.curve.point(this.x, this.y.redNeg()); - if (_precompute && this.precomputed) { - var pre = this.precomputed; - var negate = function(p) { - return p.neg(); - }; - res.precomputed = { - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(negate) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(negate) - } - }; - } - return res; -}; - -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); - - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; -}; - -function JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { - this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = new BN(z, 16); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; -} -inherits(JPoint, Base.BasePoint); - -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); -}; - -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); - - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); - - return this.curve.point(ax, ay); -}; - -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; - -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; - - // P + O = P - if (p.isInfinity()) - return this; - - // 12M + 4S + 7A - var pz2 = p.z.redSqr(); - var z2 = this.z.redSqr(); - var u1 = this.x.redMul(pz2); - var u2 = p.x.redMul(z2); - var s1 = this.y.redMul(pz2.redMul(p.z)); - var s2 = p.y.redMul(z2.redMul(this.z)); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } - - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); - - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(p.z).redMul(h); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); - - // P + O = P - if (p.isInfinity()) - return this; - - // 8M + 3S + 7A - var z2 = this.z.redSqr(); - var u1 = this.x; - var u2 = p.x.redMul(z2); - var s1 = this.y; - var s2 = p.y.redMul(z2).redMul(this.z); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } - - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); - - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(h); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); - - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (var i = 0; i < pow; i++) - r = r.dbl(); - return r; - } - - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; - - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); - - // Reuse results - var jyd = jy.redAdd(jy); - for (var i = 0; i < pow; i++) { - var jx2 = jx.redSqr(); - var jyd2 = jyd.redSqr(); - var jyd4 = jyd2.redSqr(); - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - - var t1 = jx.redMul(jyd2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - var dny = c.redMul(t2); - dny = dny.redIAdd(dny).redISub(jyd4); - var nz = jyd.redMul(jz); - if (i + 1 < pow) - jz4 = jz4.redMul(jyd4); - - jx = nx; - jz = nz; - jyd = dny; - } - - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); -}; - -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; - - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); -}; - -JPoint.prototype._zeroDbl = function _zeroDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 14A - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // T = M ^ 2 - 2*S - var t = m.redSqr().redISub(s).redISub(s); - - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2*Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-dbl-2009-l - // 2M + 5S + 13A - - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = B^2 - var c = b.redSqr(); - // D = 2 * ((X1 + B)^2 - A - C) - var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); - d = d.redIAdd(d); - // E = 3 * A - var e = a.redAdd(a).redIAdd(a); - // F = E^2 - var f = e.redSqr(); - - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); - - // X3 = F - 2 * D - nx = f.redISub(d).redISub(d); - // Y3 = E * (D - X3) - 8 * C - ny = e.redMul(d.redISub(nx)).redISub(c8); - // Z3 = 2 * Y1 * Z1 - nz = this.y.redMul(this.z); - nz = nz.redIAdd(nz); - } - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype._threeDbl = function _threeDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 15A - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a - var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); - // T = M^2 - 2 * S - var t = m.redSqr().redISub(s).redISub(s); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2 * Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - // 3M + 5S - - // delta = Z1^2 - var delta = this.z.redSqr(); - // gamma = Y1^2 - var gamma = this.y.redSqr(); - // beta = X1 * gamma - var beta = this.x.redMul(gamma); - // alpha = 3 * (X1 - delta) * (X1 + delta) - var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); - alpha = alpha.redAdd(alpha).redIAdd(alpha); - // X3 = alpha^2 - 8 * beta - var beta4 = beta.redIAdd(beta); - beta4 = beta4.redIAdd(beta4); - var beta8 = beta4.redAdd(beta4); - nx = alpha.redSqr().redISub(beta8); - // Z3 = (Y1 + Z1)^2 - gamma - delta - nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); - // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 - var ggamma8 = gamma.redSqr(); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); - } - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; - - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); - - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); - - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - - var jxd4 = jx.redAdd(jx); - jxd4 = jxd4.redIAdd(jxd4); - var t1 = jxd4.redMul(jy2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - - var jyd8 = jy2.redSqr(); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - var ny = c.redMul(t2).redISub(jyd8); - var nz = jy.redAdd(jy).redMul(jz); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); - - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // ZZ = Z1^2 - var zz = this.z.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // M = 3 * XX + a * ZZ2; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // MM = M^2 - var mm = m.redSqr(); - // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM - var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - e = e.redIAdd(e); - e = e.redAdd(e).redIAdd(e); - e = e.redISub(mm); - // EE = E^2 - var ee = e.redSqr(); - // T = 16*YYYY - var t = yyyy.redIAdd(yyyy); - t = t.redIAdd(t); - t = t.redIAdd(t); - t = t.redIAdd(t); - // U = (M + E)^2 - MM - EE - T - var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); - // X3 = 4 * (X1 * EE - 4 * YY * U) - var yyu4 = yy.redMul(u); - yyu4 = yyu4.redIAdd(yyu4); - yyu4 = yyu4.redIAdd(yyu4); - var nx = this.x.redMul(ee).redISub(yyu4); - nx = nx.redIAdd(nx); - nx = nx.redIAdd(nx); - // Y3 = 8 * Y1 * (U * (T - U) - E * EE) - var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - // Z3 = (Z1 + E)^2 - ZZ - EE - var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); - - return this.curve._wnafMul(this, k); -}; - -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); - - if (this === p) - return true; - - // x1 * z2^2 == x2 * z1^2 - var z2 = this.z.redSqr(); - var pz2 = p.z.redSqr(); - if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) - return false; - - // y1 * z2^3 == y2 * z1^3 - var z3 = z2.redMul(this.z); - var pz3 = pz2.redMul(p.z); - return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; -}; - -JPoint.prototype.eqXToP = function eqXToP(x) { - var zs = this.z.redSqr(); - var rx = x.toRed(this.curve.red).redMul(zs); - if (this.x.cmp(rx) === 0) - return true; - - var xc = x.clone(); - var t = this.curve.redN.redMul(zs); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; - - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } - return false; -}; - -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; - - -/***/ }, -/* 183 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var curves = exports; - -var hash = __webpack_require__(16); -var elliptic = __webpack_require__(9); - -var assert = elliptic.utils.assert; - -function PresetCurve(options) { - if (options.type === 'short') - this.curve = new elliptic.curve.short(options); - else if (options.type === 'edwards') - this.curve = new elliptic.curve.edwards(options); - else - this.curve = new elliptic.curve.mont(options); - this.g = this.curve.g; - this.n = this.curve.n; - this.hash = options.hash; - - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); -} -curves.PresetCurve = PresetCurve; - -function defineCurve(name, options) { - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - get: function() { - var curve = new PresetCurve(options); - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - value: curve - }); - return curve; - } - }); -} - -defineCurve('p192', { - type: 'short', - prime: 'p192', - p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', - b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', - n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash.sha256, - gRed: false, - g: [ - '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', - '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' - ] -}); - -defineCurve('p224', { - type: 'short', - prime: 'p224', - p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', - b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', - n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash.sha256, - gRed: false, - g: [ - 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', - 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' - ] -}); - -defineCurve('p256', { - type: 'short', - prime: null, - p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', - a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', - b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', - n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash.sha256, - gRed: false, - g: [ - '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', - '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' - ] -}); - -defineCurve('p384', { - type: 'short', - prime: null, - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 ffffffff', - a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 fffffffc', - b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + - '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', - n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + - 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash.sha384, - gRed: false, - g: [ - 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + - '5502f25d bf55296c 3a545e38 72760ab7', - '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + - '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' - ] -}); - -defineCurve('p521', { - type: 'short', - prime: null, - p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff', - a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff fffffffc', - b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + - '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + - '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', - n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + - 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash.sha512, - gRed: false, - g: [ - '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + - '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + - 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', - '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + - '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + - '3fad0761 353c7086 a272c240 88be9476 9fd16650' - ] -}); - -defineCurve('curve25519', { - type: 'mont', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '76d06', - b: '0', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '9' - ] -}); - -defineCurve('ed25519', { - type: 'edwards', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '-1', - c: '1', - // -121665 * (121666^(-1)) (mod P) - d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658' - ] -}); - -var pre; -try { - pre = __webpack_require__(191); -} catch (e) { - pre = undefined; -} - -defineCurve('secp256k1', { - type: 'short', - prime: 'k256', - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', - a: '0', - b: '7', - n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', - h: '1', - hash: hash.sha256, - - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3' - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15' - } - ], - - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre - ] -}); - - -/***/ }, -/* 184 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var BN = __webpack_require__(7); -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var assert = utils.assert; - -var KeyPair = __webpack_require__(185); -var Signature = __webpack_require__(186); - -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); - - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); - - options = elliptic.curves[options]; - } - - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof elliptic.curves.PresetCurve) - options = { curve: options }; - - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; - - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); - - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; -} -module.exports = EC; - -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; - -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); -}; - -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); -}; - -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; - - // Instantiate Hmac_DRBG - var drbg = new elliptic.hmacDRBG({ - hash: this.hash, - pers: options.pers, - entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), - nonce: this.n.toArray() - }); - - var bytes = this.n.byteLength(); - var ns2 = this.n.sub(new BN(2)); - do { - var priv = new BN(drbg.generate(bytes)); - if (priv.cmp(ns2) > 0) - continue; - - priv.iaddn(1); - return this.keyFromPrivate(priv); - } while (true); -}; - -EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { - var delta = msg.byteLength() * 8 - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); - else - return msg; -}; - -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; - - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(new BN(msg, 16)); - - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); - - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); - - // Instantiate Hmac_DRBG - var drbg = new elliptic.hmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc - }); - - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); - - for (var iter = 0; true; iter++) { - var k = options.k ? - options.k(iter) : - new BN(drbg.generate(this.n.byteLength())); - k = this._truncateToN(k, true); - if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) - continue; - - var kp = this.g.mul(k); - if (kp.isInfinity()) - continue; - - var kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; - - var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); - s = s.umod(this.n); - if (s.cmpn(0) === 0) - continue; - - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); - - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } - - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); - } -}; - -EC.prototype.verify = function verify(msg, signature, key, enc) { - msg = this._truncateToN(new BN(msg, 16)); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); - - // Perform primitive values validation - var r = signature.r; - var s = signature.s; - if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) - return false; - if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) - return false; - - // Validate signature - var sinv = s.invm(this.n); - var u1 = sinv.mul(msg).umod(this.n); - var u2 = sinv.mul(r).umod(this.n); - - if (!this.curve._maxwellTrick) { - var p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; - - return p.getX().umod(this.n).cmp(r) === 0; - } - - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K - - var p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; - - // Compare `p.x` of Jacobian point with `r`, - // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the - // inverse of `p.z^2` - return p.eqXToP(r); -}; - -EC.prototype.recoverPubKey = function(msg, signature, j, enc) { - assert((3 & j) === j, 'The recovery param is more than two bits'); - signature = new Signature(signature, enc); - - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; - - // A set LSB signifies that the y-coordinate is odd - var isYOdd = j & 1; - var isSecondKey = j >> 1; - if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); - - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); - else - r = this.curve.pointFromX(r, isYOdd); - - var rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); - - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; - -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; - - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; - } - - if (Qprime.eq(Q)) - return i; - } - throw new Error('Unable to find valid recovery factor'); -}; - - -/***/ }, -/* 185 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var BN = __webpack_require__(7); - -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; - - // KeyPair(ec, { priv: ..., pub: ... }) - if (options.priv) - this._importPrivate(options.priv, options.privEnc); - if (options.pub) - this._importPublic(options.pub, options.pubEnc); -} -module.exports = KeyPair; - -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; - - return new KeyPair(ec, { - pub: pub, - pubEnc: enc - }); -}; - -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; - - return new KeyPair(ec, { - priv: priv, - privEnc: enc - }); -}; - -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); - - if (pub.isInfinity()) - return { result: false, reason: 'Invalid public key' }; - if (!pub.validate()) - return { result: false, reason: 'Public key is not a point' }; - if (!pub.mul(this.ec.curve.n).isInfinity()) - return { result: false, reason: 'Public key * N != O' }; - - return { result: true, reason: null }; -}; - -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; - } - - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); - - if (!enc) - return this.pub; - - return this.pub.encode(enc, compact); -}; - -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); - else - return this.priv; -}; - -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); - - // Ensure that the priv won't be bigger than n, otherwise we may fail - // in fixed multiplication method - this.priv = this.priv.umod(this.ec.curve.n); -}; - -KeyPair.prototype._importPublic = function _importPublic(key, enc) { - if (key.x || key.y) { - this.pub = this.ec.curve.point(key.x, key.y); - return; - } - this.pub = this.ec.curve.decodePoint(key, enc); -}; - -// ECDH -KeyPair.prototype.derive = function derive(pub) { - return pub.mul(this.priv).getX(); -}; - -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; - -KeyPair.prototype.verify = function verify(msg, signature) { - return this.ec.verify(msg, signature, this); -}; - -KeyPair.prototype.inspect = function inspect() { - return ''; -}; - - -/***/ }, -/* 186 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var BN = __webpack_require__(7); - -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var assert = utils.assert; - -function Signature(options, enc) { - if (options instanceof Signature) - return options; - - if (this._importDER(options, enc)) - return; - - assert(options.r && options.s, 'Signature without r or s'); - this.r = new BN(options.r, 16); - this.s = new BN(options.s, 16); - if (options.recoveryParam === undefined) - this.recoveryParam = null; - else - this.recoveryParam = options.recoveryParam; -} -module.exports = Signature; - -function Position() { - this.place = 0; -} - -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - } - p.place = off; - return val; -} - -function rmPadding(buf) { - var i = 0; - var len = buf.length - 1; - while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { - i++; - } - if (i === 0) { - return buf; - } - return buf.slice(i); -} - -Signature.prototype._importDER = function _importDER(data, enc) { - data = utils.toArray(data, enc); - var p = new Position(); - if (data[p.place++] !== 0x30) { - return false; - } - var len = getLength(data, p); - if ((len + p.place) !== data.length) { - return false; - } - if (data[p.place++] !== 0x02) { - return false; - } - var rlen = getLength(data, p); - var r = data.slice(p.place, rlen + p.place); - p.place += rlen; - if (data[p.place++] !== 0x02) { - return false; - } - var slen = getLength(data, p); - if (data.length !== slen + p.place) { - return false; - } - var s = data.slice(p.place, slen + p.place); - if (r[0] === 0 && (r[1] & 0x80)) { - r = r.slice(1); - } - if (s[0] === 0 && (s[1] & 0x80)) { - s = s.slice(1); - } - - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; - - return true; -}; - -function constructLength(arr, len) { - if (len < 0x80) { - arr.push(len); - return; - } - var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); - arr.push(octets | 0x80); - while (--octets) { - arr.push((len >>> (octets << 3)) & 0xff); - } - arr.push(len); -} - -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); - - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); - - r = rmPadding(r); - s = rmPadding(s); - - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); - } - var arr = [ 0x02 ]; - constructLength(arr, r.length); - arr = arr.concat(r); - arr.push(0x02); - constructLength(arr, s.length); - var backHalf = arr.concat(s); - var res = [ 0x30 ]; - constructLength(res, backHalf.length); - res = res.concat(backHalf); - return utils.encode(res, enc); -}; - - -/***/ }, -/* 187 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var hash = __webpack_require__(16); -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var KeyPair = __webpack_require__(188); -var Signature = __webpack_require__(189); - -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); - - if (!(this instanceof EDDSA)) - return new EDDSA(curve); - - var curve = elliptic.curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); - - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; -} - -module.exports = EDDSA; - -/** -* @param {Array|String} message - message bytes -* @param {Array|String|KeyPair} secret - secret bytes or a keypair -* @returns {Signature} - signature -*/ -EDDSA.prototype.sign = function sign(message, secret) { - message = parseBytes(message); - var key = this.keyFromSecret(secret); - var r = this.hashInt(key.messagePrefix(), message); - var R = this.g.mul(r); - var Rencoded = this.encodePoint(R); - var s_ = this.hashInt(Rencoded, key.pubBytes(), message) - .mul(key.priv()); - var S = r.add(s_).umod(this.curve.n); - return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); -}; - -/** -* @param {Array} message - message bytes -* @param {Array|String|Signature} sig - sig bytes -* @param {Array|String|Point|KeyPair} pub - public key -* @returns {Boolean} - true if public key matches sig of message -*/ -EDDSA.prototype.verify = function verify(message, sig, pub) { - message = parseBytes(message); - sig = this.makeSignature(sig); - var key = this.keyFromPublic(pub); - var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); - var SG = this.g.mul(sig.S()); - var RplusAh = sig.R().add(key.pub().mul(h)); - return RplusAh.eq(SG); -}; - -EDDSA.prototype.hashInt = function hashInt() { - var hash = this.hash(); - for (var i = 0; i < arguments.length; i++) - hash.update(arguments[i]); - return utils.intFromLE(hash.digest()).umod(this.curve.n); -}; - -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; - -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; - -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; - -/** -* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 -* -* EDDSA defines methods for encoding and decoding points and integers. These are -* helper convenience methods, that pass along to utility functions implied -* parameters. -* -*/ -EDDSA.prototype.encodePoint = function encodePoint(point) { - var enc = point.getY().toArray('le', this.encodingLength); - enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; - return enc; -}; - -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); - - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; - -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; - -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; - -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; - - -/***/ }, -/* 188 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var cachedProperty = utils.cachedProperty; - -/** -* @param {EDDSA} eddsa - instance -* @param {Object} params - public/private key parameters -* -* @param {Array} [params.secret] - secret seed bytes -* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) -* @param {Array} [params.pub] - public key point encoded as bytes -* -*/ -function KeyPair(eddsa, params) { - this.eddsa = eddsa; - this._secret = parseBytes(params.secret); - if (eddsa.isPoint(params.pub)) - this._pub = params.pub; - else - this._pubBytes = parseBytes(params.pub); -} - -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); -}; - -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); -}; - -KeyPair.prototype.secret = function secret() { - return this._secret; -}; - -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); - -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); - -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; - - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; - - return a; -}); - -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); - -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); - -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); - -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; - -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; - -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); -}; - -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); -}; - -module.exports = KeyPair; - - -/***/ }, -/* 189 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var BN = __webpack_require__(7); -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; - -/** -* @param {EDDSA} eddsa - eddsa instance -* @param {Array|Object} sig - -* @param {Array|Point} [sig.R] - R point as Point or bytes -* @param {Array|bn} [sig.S] - S scalar as bn or bytes -* @param {Array} [sig.Rencoded] - R point encoded -* @param {Array} [sig.Sencoded] - S scalar encoded -*/ -function Signature(eddsa, sig) { - this.eddsa = eddsa; - - if (typeof sig !== 'object') - sig = parseBytes(sig); - - if (Array.isArray(sig)) { - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength) - }; - } - - assert(sig.R && sig.S, 'Signature without R or S'); - - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; - - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} - -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); - -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); - -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); - -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); - -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); -}; - -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); -}; - -module.exports = Signature; - - -/***/ }, -/* 190 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var hash = __webpack_require__(16); -var elliptic = __webpack_require__(9); -var utils = elliptic.utils; -var assert = utils.assert; - -function HmacDRBG(options) { - if (!(this instanceof HmacDRBG)) - return new HmacDRBG(options); - this.hash = options.hash; - this.predResist = !!options.predResist; - - this.outLen = this.hash.outSize; - this.minEntropy = options.minEntropy || this.hash.hmacStrength; - - this.reseed = null; - this.reseedInterval = null; - this.K = null; - this.V = null; - - var entropy = utils.toArray(options.entropy, options.entropyEnc); - var nonce = utils.toArray(options.nonce, options.nonceEnc); - var pers = utils.toArray(options.pers, options.persEnc); - assert(entropy.length >= (this.minEntropy / 8), - 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - this._init(entropy, nonce, pers); -} -module.exports = HmacDRBG; - -HmacDRBG.prototype._init = function init(entropy, nonce, pers) { - var seed = entropy.concat(nonce).concat(pers); - - this.K = new Array(this.outLen / 8); - this.V = new Array(this.outLen / 8); - for (var i = 0; i < this.V.length; i++) { - this.K[i] = 0x00; - this.V[i] = 0x01; - } - - this._update(seed); - this.reseed = 1; - this.reseedInterval = 0x1000000000000; // 2^48 -}; - -HmacDRBG.prototype._hmac = function hmac() { - return new hash.hmac(this.hash, this.K); -}; - -HmacDRBG.prototype._update = function update(seed) { - var kmac = this._hmac() - .update(this.V) - .update([ 0x00 ]); - if (seed) - kmac = kmac.update(seed); - this.K = kmac.digest(); - this.V = this._hmac().update(this.V).digest(); - if (!seed) - return; - - this.K = this._hmac() - .update(this.V) - .update([ 0x01 ]) - .update(seed) - .digest(); - this.V = this._hmac().update(this.V).digest(); -}; - -HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { - // Optional entropy enc - if (typeof entropyEnc !== 'string') { - addEnc = add; - add = entropyEnc; - entropyEnc = null; - } - - entropy = utils.toBuffer(entropy, entropyEnc); - add = utils.toBuffer(add, addEnc); - - assert(entropy.length >= (this.minEntropy / 8), - 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - - this._update(entropy.concat(add || [])); - this.reseed = 1; -}; - -HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { - if (this.reseed > this.reseedInterval) - throw new Error('Reseed is required'); - - // Optional encoding - if (typeof enc !== 'string') { - addEnc = add; - add = enc; - enc = null; - } - - // Optional additional data - if (add) { - add = utils.toArray(add, addEnc); - this._update(add); - } - - var temp = []; - while (temp.length < len) { - this.V = this._hmac().update(this.V).digest(); - temp = temp.concat(this.V); - } - - var res = temp.slice(0, len); - this._update(add); - this.reseed++; - return utils.encode(res, enc); -}; - - -/***/ }, -/* 191 */ -/***/ function(module, exports) { - -module.exports = { - doubles: { - step: 4, - points: [ - [ - 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', - 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821' - ], - [ - '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', - '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf' - ], - [ - '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', - 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695' - ], - [ - '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', - '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9' - ], - [ - '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', - '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36' - ], - [ - '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', - '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f' - ], - [ - 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', - '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999' - ], - [ - '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', - 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09' - ], - [ - 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', - '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d' - ], - [ - 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', - 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088' - ], - [ - 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', - '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d' - ], - [ - '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', - '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8' - ], - [ - '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', - '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a' - ], - [ - '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', - '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453' - ], - [ - '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', - '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160' - ], - [ - '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', - '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0' - ], - [ - '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', - '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6' - ], - [ - '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', - '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589' - ], - [ - '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', - 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17' - ], - [ - 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', - '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda' - ], - [ - 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', - '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd' - ], - [ - '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', - '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2' - ], - [ - '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', - '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6' - ], - [ - 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', - '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f' - ], - [ - '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', - 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01' - ], - [ - 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', - '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3' - ], - [ - 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', - 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f' - ], - [ - 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', - '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7' - ], - [ - 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', - 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78' - ], - [ - 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', - '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1' - ], - [ - '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', - 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150' - ], - [ - '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', - '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82' - ], - [ - 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', - '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc' - ], - [ - '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', - 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b' - ], - [ - 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', - '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51' - ], - [ - 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', - '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45' - ], - [ - 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', - 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120' - ], - [ - '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', - '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84' - ], - [ - '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', - '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d' - ], - [ - '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', - 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d' - ], - [ - '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', - '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8' - ], - [ - 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', - '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8' - ], - [ - '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', - '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac' - ], - [ - '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', - 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f' - ], - [ - '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', - '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962' - ], - [ - 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', - '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907' - ], - [ - '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', - 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec' - ], - [ - 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', - 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d' - ], - [ - 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', - '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414' - ], - [ - '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', - 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd' - ], - [ - '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', - 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0' - ], - [ - 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', - '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811' - ], - [ - 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', - '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1' - ], - [ - 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', - '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c' - ], - [ - '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', - 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73' - ], - [ - '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', - '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd' - ], - [ - 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', - 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405' - ], - [ - '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', - 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589' - ], - [ - '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', - '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e' - ], - [ - '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', - '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27' - ], - [ - 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', - 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1' - ], - [ - '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', - '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482' - ], - [ - '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', - '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945' - ], - [ - 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', - '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573' - ], - [ - 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', - 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82' - ] - ] - }, - naf: { - wnd: 7, - points: [ - [ - 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', - '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672' - ], - [ - '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', - 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6' - ], - [ - '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', - '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da' - ], - [ - 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', - 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37' - ], - [ - '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', - 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b' - ], - [ - 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', - 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81' - ], - [ - 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', - '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58' - ], - [ - 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', - '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77' - ], - [ - '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', - '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a' - ], - [ - '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', - '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c' - ], - [ - '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', - '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67' - ], - [ - '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', - '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402' - ], - [ - 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', - 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55' - ], - [ - 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', - '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482' - ], - [ - '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', - 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82' - ], - [ - '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', - 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396' - ], - [ - '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', - '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49' - ], - [ - '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', - '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf' - ], - [ - '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', - '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a' - ], - [ - '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', - 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7' - ], - [ - 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', - 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933' - ], - [ - '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', - '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a' - ], - [ - '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', - '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6' - ], - [ - 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', - 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37' - ], - [ - '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', - '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e' - ], - [ - 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', - 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6' - ], - [ - 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', - 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476' - ], - [ - '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', - '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40' - ], - [ - '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', - '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61' - ], - [ - '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', - '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683' - ], - [ - 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', - '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5' - ], - [ - '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', - '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b' - ], - [ - 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', - '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417' - ], - [ - '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', - 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868' - ], - [ - '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', - 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a' - ], - [ - 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', - 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6' - ], - [ - '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', - '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996' - ], - [ - '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', - 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e' - ], - [ - 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', - 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d' - ], - [ - '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', - '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2' - ], - [ - '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', - 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e' - ], - [ - '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', - '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437' - ], - [ - '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', - 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311' - ], - [ - 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', - '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4' - ], - [ - '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', - '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575' - ], - [ - '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', - 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d' - ], - [ - '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', - 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d' - ], - [ - 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', - 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629' - ], - [ - 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', - 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06' - ], - [ - '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', - '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374' - ], - [ - '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', - '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee' - ], - [ - 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', - '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1' - ], - [ - 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', - 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b' - ], - [ - '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', - '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661' - ], - [ - '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', - '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6' - ], - [ - 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', - '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e' - ], - [ - '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', - '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d' - ], - [ - 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', - 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc' - ], - [ - '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', - 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4' - ], - [ - '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', - '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c' - ], - [ - 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', - '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b' - ], - [ - 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', - '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913' - ], - [ - '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', - '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154' - ], - [ - '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', - '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865' - ], - [ - '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', - 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc' - ], - [ - '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', - 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224' - ], - [ - '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', - '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e' - ], - [ - '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', - '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6' - ], - [ - '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', - '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511' - ], - [ - '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', - 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b' - ], - [ - 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', - 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2' - ], - [ - '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', - 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c' - ], - [ - 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', - '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3' - ], - [ - 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', - '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d' - ], - [ - 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', - '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700' - ], - [ - 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', - '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4' - ], - [ - '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', - 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196' - ], - [ - '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', - '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4' - ], - [ - '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', - 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257' - ], - [ - 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', - 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13' - ], - [ - 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', - '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096' - ], - [ - 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', - 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38' - ], - [ - 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', - '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f' - ], - [ - '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', - '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448' - ], - [ - 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', - '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a' - ], - [ - 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', - '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4' - ], - [ - '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', - '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437' - ], - [ - '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', - 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7' - ], - [ - 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', - '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d' - ], - [ - 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', - '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a' - ], - [ - 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', - '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54' - ], - [ - '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', - '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77' - ], - [ - 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', - 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517' - ], - [ - '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', - 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10' - ], - [ - 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', - 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125' - ], - [ - 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', - '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e' - ], - [ - '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', - 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1' - ], - [ - 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', - '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2' - ], - [ - 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', - '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423' - ], - [ - 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', - '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8' - ], - [ - '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', - 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758' - ], - [ - '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', - 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375' - ], - [ - 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', - '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d' - ], - [ - '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', - 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec' - ], - [ - '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', - '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0' - ], - [ - '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', - 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c' - ], - [ - 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', - 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4' - ], - [ - '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', - 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f' - ], - [ - '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', - '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649' - ], - [ - '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', - 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826' - ], - [ - '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', - '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5' - ], - [ - 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', - 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87' - ], - [ - '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', - '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b' - ], - [ - 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', - '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc' - ], - [ - '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', - '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c' - ], - [ - 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', - 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f' - ], - [ - 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', - '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a' - ], - [ - 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', - 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46' - ], - [ - '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', - 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f' - ], - [ - '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', - '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03' - ], - [ - '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', - 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08' - ], - [ - '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', - '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8' - ], - [ - '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', - '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373' - ], - [ - '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', - 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3' - ], - [ - '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', - '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8' - ], - [ - '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', - '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1' - ], - [ - '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', - '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9' - ] - ] - } -}; - - -/***/ }, -/* 192 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var utils = exports; -var BN = __webpack_require__(7); - -utils.assert = function assert(val, msg) { - if (!val) - throw new Error(msg || 'Assertion failed'); -}; - -function toArray(msg, enc) { - if (Array.isArray(msg)) - return msg.slice(); - if (!msg) - return []; - var res = []; - if (typeof msg !== 'string') { - for (var i = 0; i < msg.length; i++) - res[i] = msg[i] | 0; - return res; - } - if (!enc) { - for (var i = 0; i < msg.length; i++) { - var c = msg.charCodeAt(i); - var hi = c >> 8; - var lo = c & 0xff; - if (hi) - res.push(hi, lo); - else - res.push(lo); - } - } else if (enc === 'hex') { - msg = msg.replace(/[^a-z0-9]+/ig, ''); - if (msg.length % 2 !== 0) - msg = '0' + msg; - for (var i = 0; i < msg.length; i += 2) - res.push(parseInt(msg[i] + msg[i + 1], 16)); - } - return res; -} -utils.toArray = toArray; - -function zero2(word) { - if (word.length === 1) - return '0' + word; - else - return word; -} -utils.zero2 = zero2; - -function toHex(msg) { - var res = ''; - for (var i = 0; i < msg.length; i++) - res += zero2(msg[i].toString(16)); - return res; -} -utils.toHex = toHex; - -utils.encode = function encode(arr, enc) { - if (enc === 'hex') - return toHex(arr); - else - return arr; -}; - -// Represent num in a w-NAF form -function getNAF(num, w) { - var naf = []; - var ws = 1 << (w + 1); - var k = num.clone(); - while (k.cmpn(1) >= 0) { - var z; - if (k.isOdd()) { - var mod = k.andln(ws - 1); - if (mod > (ws >> 1) - 1) - z = (ws >> 1) - mod; - else - z = mod; - k.isubn(z); - } else { - z = 0; - } - naf.push(z); - - // Optimization, shift by word if possible - var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; - for (var i = 1; i < shift; i++) - naf.push(0); - k.iushrn(shift); - } - - return naf; -} -utils.getNAF = getNAF; - -// Represent k1, k2 in a Joint Sparse Form -function getJSF(k1, k2) { - var jsf = [ - [], - [] - ]; - - k1 = k1.clone(); - k2 = k2.clone(); - var d1 = 0; - var d2 = 0; - while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { - - // First phase - var m14 = (k1.andln(3) + d1) & 3; - var m24 = (k2.andln(3) + d2) & 3; - if (m14 === 3) - m14 = -1; - if (m24 === 3) - m24 = -1; - var u1; - if ((m14 & 1) === 0) { - u1 = 0; - } else { - var m8 = (k1.andln(7) + d1) & 7; - if ((m8 === 3 || m8 === 5) && m24 === 2) - u1 = -m14; - else - u1 = m14; - } - jsf[0].push(u1); - - var u2; - if ((m24 & 1) === 0) { - u2 = 0; - } else { - var m8 = (k2.andln(7) + d2) & 7; - if ((m8 === 3 || m8 === 5) && m14 === 2) - u2 = -m24; - else - u2 = m24; - } - jsf[1].push(u2); - - // Second phase - if (2 * d1 === u1 + 1) - d1 = 1 - d1; - if (2 * d2 === u2 + 1) - d2 = 1 - d2; - k1.iushrn(1); - k2.iushrn(1); - } - - return jsf; -} -utils.getJSF = getJSF; - -function cachedProperty(obj, name, computer) { - var key = '_' + name; - obj.prototype[name] = function cachedProperty() { - return this[key] !== undefined ? this[key] : - this[key] = computer.call(this); - }; -} -utils.cachedProperty = cachedProperty; - -function parseBytes(bytes) { - return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : - bytes; -} -utils.parseBytes = parseBytes; - -function intFromLE(bytes) { - return new BN(bytes, 'hex', 'le'); -} -utils.intFromLE = intFromLE; - - - -/***/ }, -/* 193 */ -/***/ function(module, exports, __webpack_require__) { - -var hash = __webpack_require__(16); -var utils = hash.utils; -var assert = utils.assert; - -function BlockHash() { - this.pending = null; - this.pendingTotal = 0; - this.blockSize = this.constructor.blockSize; - this.outSize = this.constructor.outSize; - this.hmacStrength = this.constructor.hmacStrength; - this.padLength = this.constructor.padLength / 8; - this.endian = 'big'; - - this._delta8 = this.blockSize / 8; - this._delta32 = this.blockSize / 32; -} -exports.BlockHash = BlockHash; - -BlockHash.prototype.update = function update(msg, enc) { - // Convert message to array, pad it, and join into 32bit blocks - msg = utils.toArray(msg, enc); - if (!this.pending) - this.pending = msg; - else - this.pending = this.pending.concat(msg); - this.pendingTotal += msg.length; - - // Enough data, try updating - if (this.pending.length >= this._delta8) { - msg = this.pending; - - // Process pending data in blocks - var r = msg.length % this._delta8; - this.pending = msg.slice(msg.length - r, msg.length); - if (this.pending.length === 0) - this.pending = null; - - msg = utils.join32(msg, 0, msg.length - r, this.endian); - for (var i = 0; i < msg.length; i += this._delta32) - this._update(msg, i, i + this._delta32); - } - - return this; -}; - -BlockHash.prototype.digest = function digest(enc) { - this.update(this._pad()); - assert(this.pending === null); - - return this._digest(enc); -}; - -BlockHash.prototype._pad = function pad() { - var len = this.pendingTotal; - var bytes = this._delta8; - var k = bytes - ((len + this.padLength) % bytes); - var res = new Array(k + this.padLength); - res[0] = 0x80; - for (var i = 1; i < k; i++) - res[i] = 0; - - // Append length - len <<= 3; - if (this.endian === 'big') { - for (var t = 8; t < this.padLength; t++) - res[i++] = 0; - - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = (len >>> 24) & 0xff; - res[i++] = (len >>> 16) & 0xff; - res[i++] = (len >>> 8) & 0xff; - res[i++] = len & 0xff; - } else { - res[i++] = len & 0xff; - res[i++] = (len >>> 8) & 0xff; - res[i++] = (len >>> 16) & 0xff; - res[i++] = (len >>> 24) & 0xff; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - - for (var t = 8; t < this.padLength; t++) - res[i++] = 0; - } - - return res; -}; - - -/***/ }, -/* 194 */ -/***/ function(module, exports, __webpack_require__) { - -var hmac = exports; - -var hash = __webpack_require__(16); -var utils = hash.utils; -var assert = utils.assert; - -function Hmac(hash, key, enc) { - if (!(this instanceof Hmac)) - return new Hmac(hash, key, enc); - this.Hash = hash; - this.blockSize = hash.blockSize / 8; - this.outSize = hash.outSize / 8; - this.inner = null; - this.outer = null; - - this._init(utils.toArray(key, enc)); -} -module.exports = Hmac; - -Hmac.prototype._init = function init(key) { - // Shorten key, if needed - if (key.length > this.blockSize) - key = new this.Hash().update(key).digest(); - assert(key.length <= this.blockSize); - - // Add padding to key - for (var i = key.length; i < this.blockSize; i++) - key.push(0); - - for (var i = 0; i < key.length; i++) - key[i] ^= 0x36; - this.inner = new this.Hash().update(key); - - // 0x36 ^ 0x5c = 0x6a - for (var i = 0; i < key.length; i++) - key[i] ^= 0x6a; - this.outer = new this.Hash().update(key); -}; - -Hmac.prototype.update = function update(msg, enc) { - this.inner.update(msg, enc); - return this; -}; - -Hmac.prototype.digest = function digest(enc) { - this.outer.update(this.inner.digest()); - return this.outer.digest(enc); -}; - - -/***/ }, -/* 195 */ -/***/ function(module, exports, __webpack_require__) { - -var hash = __webpack_require__(16); -var utils = hash.utils; - -var rotl32 = utils.rotl32; -var sum32 = utils.sum32; -var sum32_3 = utils.sum32_3; -var sum32_4 = utils.sum32_4; -var BlockHash = hash.common.BlockHash; - -function RIPEMD160() { - if (!(this instanceof RIPEMD160)) - return new RIPEMD160(); - - BlockHash.call(this); - - this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; - this.endian = 'little'; -} -utils.inherits(RIPEMD160, BlockHash); -exports.ripemd160 = RIPEMD160; - -RIPEMD160.blockSize = 512; -RIPEMD160.outSize = 160; -RIPEMD160.hmacStrength = 192; -RIPEMD160.padLength = 64; - -RIPEMD160.prototype._update = function update(msg, start) { - var A = this.h[0]; - var B = this.h[1]; - var C = this.h[2]; - var D = this.h[3]; - var E = this.h[4]; - var Ah = A; - var Bh = B; - var Ch = C; - var Dh = D; - var Eh = E; - for (var j = 0; j < 80; j++) { - var T = sum32( - rotl32( - sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), - s[j]), - E); - A = E; - E = D; - D = rotl32(C, 10); - C = B; - B = T; - T = sum32( - rotl32( - sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), - sh[j]), - Eh); - Ah = Eh; - Eh = Dh; - Dh = rotl32(Ch, 10); - Ch = Bh; - Bh = T; - } - T = sum32_3(this.h[1], C, Dh); - this.h[1] = sum32_3(this.h[2], D, Eh); - this.h[2] = sum32_3(this.h[3], E, Ah); - this.h[3] = sum32_3(this.h[4], A, Bh); - this.h[4] = sum32_3(this.h[0], B, Ch); - this.h[0] = T; -}; - -RIPEMD160.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'little'); - else - return utils.split32(this.h, 'little'); -}; - -function f(j, x, y, z) { - if (j <= 15) - return x ^ y ^ z; - else if (j <= 31) - return (x & y) | ((~x) & z); - else if (j <= 47) - return (x | (~y)) ^ z; - else if (j <= 63) - return (x & z) | (y & (~z)); - else - return x ^ (y | (~z)); -} - -function K(j) { - if (j <= 15) - return 0x00000000; - else if (j <= 31) - return 0x5a827999; - else if (j <= 47) - return 0x6ed9eba1; - else if (j <= 63) - return 0x8f1bbcdc; - else - return 0xa953fd4e; -} - -function Kh(j) { - if (j <= 15) - return 0x50a28be6; - else if (j <= 31) - return 0x5c4dd124; - else if (j <= 47) - return 0x6d703ef3; - else if (j <= 63) - return 0x7a6d76e9; - else - return 0x00000000; -} - -var r = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 -]; - -var rh = [ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 -]; - -var s = [ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 -]; - -var sh = [ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 -]; - - -/***/ }, -/* 196 */ -/***/ function(module, exports, __webpack_require__) { - -var hash = __webpack_require__(16); -var utils = hash.utils; -var assert = utils.assert; - -var rotr32 = utils.rotr32; -var rotl32 = utils.rotl32; -var sum32 = utils.sum32; -var sum32_4 = utils.sum32_4; -var sum32_5 = utils.sum32_5; -var rotr64_hi = utils.rotr64_hi; -var rotr64_lo = utils.rotr64_lo; -var shr64_hi = utils.shr64_hi; -var shr64_lo = utils.shr64_lo; -var sum64 = utils.sum64; -var sum64_hi = utils.sum64_hi; -var sum64_lo = utils.sum64_lo; -var sum64_4_hi = utils.sum64_4_hi; -var sum64_4_lo = utils.sum64_4_lo; -var sum64_5_hi = utils.sum64_5_hi; -var sum64_5_lo = utils.sum64_5_lo; -var BlockHash = hash.common.BlockHash; - -var sha256_K = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -]; - -var sha512_K = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 -]; - -var sha1_K = [ - 0x5A827999, 0x6ED9EBA1, - 0x8F1BBCDC, 0xCA62C1D6 -]; - -function SHA256() { - if (!(this instanceof SHA256)) - return new SHA256(); - - BlockHash.call(this); - this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ]; - this.k = sha256_K; - this.W = new Array(64); -} -utils.inherits(SHA256, BlockHash); -exports.sha256 = SHA256; - -SHA256.blockSize = 512; -SHA256.outSize = 256; -SHA256.hmacStrength = 192; -SHA256.padLength = 64; - -SHA256.prototype._update = function _update(msg, start) { - var W = this.W; - - for (var i = 0; i < 16; i++) - W[i] = msg[start + i]; - for (; i < W.length; i++) - W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); - - var a = this.h[0]; - var b = this.h[1]; - var c = this.h[2]; - var d = this.h[3]; - var e = this.h[4]; - var f = this.h[5]; - var g = this.h[6]; - var h = this.h[7]; - - assert(this.k.length === W.length); - for (var i = 0; i < W.length; i++) { - var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); - var T2 = sum32(s0_256(a), maj32(a, b, c)); - h = g; - g = f; - f = e; - e = sum32(d, T1); - d = c; - c = b; - b = a; - a = sum32(T1, T2); - } - - this.h[0] = sum32(this.h[0], a); - this.h[1] = sum32(this.h[1], b); - this.h[2] = sum32(this.h[2], c); - this.h[3] = sum32(this.h[3], d); - this.h[4] = sum32(this.h[4], e); - this.h[5] = sum32(this.h[5], f); - this.h[6] = sum32(this.h[6], g); - this.h[7] = sum32(this.h[7], h); -}; - -SHA256.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'big'); - else - return utils.split32(this.h, 'big'); -}; - -function SHA224() { - if (!(this instanceof SHA224)) - return new SHA224(); - - SHA256.call(this); - this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, - 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ]; -} -utils.inherits(SHA224, SHA256); -exports.sha224 = SHA224; - -SHA224.blockSize = 512; -SHA224.outSize = 224; -SHA224.hmacStrength = 192; -SHA224.padLength = 64; - -SHA224.prototype._digest = function digest(enc) { - // Just truncate output - if (enc === 'hex') - return utils.toHex32(this.h.slice(0, 7), 'big'); - else - return utils.split32(this.h.slice(0, 7), 'big'); -}; - -function SHA512() { - if (!(this instanceof SHA512)) - return new SHA512(); - - BlockHash.call(this); - this.h = [ 0x6a09e667, 0xf3bcc908, - 0xbb67ae85, 0x84caa73b, - 0x3c6ef372, 0xfe94f82b, - 0xa54ff53a, 0x5f1d36f1, - 0x510e527f, 0xade682d1, - 0x9b05688c, 0x2b3e6c1f, - 0x1f83d9ab, 0xfb41bd6b, - 0x5be0cd19, 0x137e2179 ]; - this.k = sha512_K; - this.W = new Array(160); -} -utils.inherits(SHA512, BlockHash); -exports.sha512 = SHA512; - -SHA512.blockSize = 1024; -SHA512.outSize = 512; -SHA512.hmacStrength = 192; -SHA512.padLength = 128; - -SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { - var W = this.W; - - // 32 x 32bit words - for (var i = 0; i < 32; i++) - W[i] = msg[start + i]; - for (; i < W.length; i += 2) { - var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 - var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); - var c1_hi = W[i - 14]; // i - 7 - var c1_lo = W[i - 13]; - var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 - var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); - var c3_hi = W[i - 32]; // i - 16 - var c3_lo = W[i - 31]; - - W[i] = sum64_4_hi(c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo); - W[i + 1] = sum64_4_lo(c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo); - } -}; - -SHA512.prototype._update = function _update(msg, start) { - this._prepareBlock(msg, start); - - var W = this.W; - - var ah = this.h[0]; - var al = this.h[1]; - var bh = this.h[2]; - var bl = this.h[3]; - var ch = this.h[4]; - var cl = this.h[5]; - var dh = this.h[6]; - var dl = this.h[7]; - var eh = this.h[8]; - var el = this.h[9]; - var fh = this.h[10]; - var fl = this.h[11]; - var gh = this.h[12]; - var gl = this.h[13]; - var hh = this.h[14]; - var hl = this.h[15]; - - assert(this.k.length === W.length); - for (var i = 0; i < W.length; i += 2) { - var c0_hi = hh; - var c0_lo = hl; - var c1_hi = s1_512_hi(eh, el); - var c1_lo = s1_512_lo(eh, el); - var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); - var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); - var c3_hi = this.k[i]; - var c3_lo = this.k[i + 1]; - var c4_hi = W[i]; - var c4_lo = W[i + 1]; - - var T1_hi = sum64_5_hi(c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo, - c4_hi, c4_lo); - var T1_lo = sum64_5_lo(c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo, - c4_hi, c4_lo); - - var c0_hi = s0_512_hi(ah, al); - var c0_lo = s0_512_lo(ah, al); - var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); - var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); - - var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); - var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); - - hh = gh; - hl = gl; - - gh = fh; - gl = fl; - - fh = eh; - fl = el; - - eh = sum64_hi(dh, dl, T1_hi, T1_lo); - el = sum64_lo(dl, dl, T1_hi, T1_lo); - - dh = ch; - dl = cl; - - ch = bh; - cl = bl; - - bh = ah; - bl = al; - - ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); - al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); - } - - sum64(this.h, 0, ah, al); - sum64(this.h, 2, bh, bl); - sum64(this.h, 4, ch, cl); - sum64(this.h, 6, dh, dl); - sum64(this.h, 8, eh, el); - sum64(this.h, 10, fh, fl); - sum64(this.h, 12, gh, gl); - sum64(this.h, 14, hh, hl); -}; - -SHA512.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'big'); - else - return utils.split32(this.h, 'big'); -}; - -function SHA384() { - if (!(this instanceof SHA384)) - return new SHA384(); - - SHA512.call(this); - this.h = [ 0xcbbb9d5d, 0xc1059ed8, - 0x629a292a, 0x367cd507, - 0x9159015a, 0x3070dd17, - 0x152fecd8, 0xf70e5939, - 0x67332667, 0xffc00b31, - 0x8eb44a87, 0x68581511, - 0xdb0c2e0d, 0x64f98fa7, - 0x47b5481d, 0xbefa4fa4 ]; -} -utils.inherits(SHA384, SHA512); -exports.sha384 = SHA384; - -SHA384.blockSize = 1024; -SHA384.outSize = 384; -SHA384.hmacStrength = 192; -SHA384.padLength = 128; - -SHA384.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h.slice(0, 12), 'big'); - else - return utils.split32(this.h.slice(0, 12), 'big'); -}; - -function SHA1() { - if (!(this instanceof SHA1)) - return new SHA1(); - - BlockHash.call(this); - this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, - 0x10325476, 0xc3d2e1f0 ]; - this.W = new Array(80); -} - -utils.inherits(SHA1, BlockHash); -exports.sha1 = SHA1; - -SHA1.blockSize = 512; -SHA1.outSize = 160; -SHA1.hmacStrength = 80; -SHA1.padLength = 64; - -SHA1.prototype._update = function _update(msg, start) { - var W = this.W; - - for (var i = 0; i < 16; i++) - W[i] = msg[start + i]; - - for(; i < W.length; i++) - W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); - - var a = this.h[0]; - var b = this.h[1]; - var c = this.h[2]; - var d = this.h[3]; - var e = this.h[4]; - - for (var i = 0; i < W.length; i++) { - var s = ~~(i / 20); - var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]); - e = d; - d = c; - c = rotl32(b, 30); - b = a; - a = t; - } - - this.h[0] = sum32(this.h[0], a); - this.h[1] = sum32(this.h[1], b); - this.h[2] = sum32(this.h[2], c); - this.h[3] = sum32(this.h[3], d); - this.h[4] = sum32(this.h[4], e); -}; - -SHA1.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'big'); - else - return utils.split32(this.h, 'big'); -}; - -function ch32(x, y, z) { - return (x & y) ^ ((~x) & z); -} - -function maj32(x, y, z) { - return (x & y) ^ (x & z) ^ (y & z); -} - -function p32(x, y, z) { - return x ^ y ^ z; -} - -function s0_256(x) { - return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); -} - -function s1_256(x) { - return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); -} - -function g0_256(x) { - return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3); -} - -function g1_256(x) { - return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10); -} - -function ft_1(s, x, y, z) { - if (s === 0) - return ch32(x, y, z); - if (s === 1 || s === 3) - return p32(x, y, z); - if (s === 2) - return maj32(x, y, z); -} - -function ch64_hi(xh, xl, yh, yl, zh, zl) { - var r = (xh & yh) ^ ((~xh) & zh); - if (r < 0) - r += 0x100000000; - return r; -} - -function ch64_lo(xh, xl, yh, yl, zh, zl) { - var r = (xl & yl) ^ ((~xl) & zl); - if (r < 0) - r += 0x100000000; - return r; -} - -function maj64_hi(xh, xl, yh, yl, zh, zl) { - var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); - if (r < 0) - r += 0x100000000; - return r; -} - -function maj64_lo(xh, xl, yh, yl, zh, zl) { - var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); - if (r < 0) - r += 0x100000000; - return r; -} - -function s0_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 28); - var c1_hi = rotr64_hi(xl, xh, 2); // 34 - var c2_hi = rotr64_hi(xl, xh, 7); // 39 - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function s0_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 28); - var c1_lo = rotr64_lo(xl, xh, 2); // 34 - var c2_lo = rotr64_lo(xl, xh, 7); // 39 - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -function s1_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 14); - var c1_hi = rotr64_hi(xh, xl, 18); - var c2_hi = rotr64_hi(xl, xh, 9); // 41 - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function s1_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 14); - var c1_lo = rotr64_lo(xh, xl, 18); - var c2_lo = rotr64_lo(xl, xh, 9); // 41 - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -function g0_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 1); - var c1_hi = rotr64_hi(xh, xl, 8); - var c2_hi = shr64_hi(xh, xl, 7); - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function g0_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 1); - var c1_lo = rotr64_lo(xh, xl, 8); - var c2_lo = shr64_lo(xh, xl, 7); - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -function g1_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 19); - var c1_hi = rotr64_hi(xl, xh, 29); // 61 - var c2_hi = shr64_hi(xh, xl, 6); - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function g1_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 19); - var c1_lo = rotr64_lo(xl, xh, 29); // 61 - var c2_lo = shr64_lo(xh, xl, 6); - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - - -/***/ }, -/* 197 */ -/***/ function(module, exports, __webpack_require__) { - -var utils = exports; -var inherits = __webpack_require__(2); - -function toArray(msg, enc) { - if (Array.isArray(msg)) - return msg.slice(); - if (!msg) - return []; - var res = []; - if (typeof msg === 'string') { - if (!enc) { - for (var i = 0; i < msg.length; i++) { - var c = msg.charCodeAt(i); - var hi = c >> 8; - var lo = c & 0xff; - if (hi) - res.push(hi, lo); - else - res.push(lo); - } - } else if (enc === 'hex') { - msg = msg.replace(/[^a-z0-9]+/ig, ''); - if (msg.length % 2 !== 0) - msg = '0' + msg; - for (var i = 0; i < msg.length; i += 2) - res.push(parseInt(msg[i] + msg[i + 1], 16)); - } - } else { - for (var i = 0; i < msg.length; i++) - res[i] = msg[i] | 0; - } - return res; -} -utils.toArray = toArray; - -function toHex(msg) { - var res = ''; - for (var i = 0; i < msg.length; i++) - res += zero2(msg[i].toString(16)); - return res; -} -utils.toHex = toHex; - -function htonl(w) { - var res = (w >>> 24) | - ((w >>> 8) & 0xff00) | - ((w << 8) & 0xff0000) | - ((w & 0xff) << 24); - return res >>> 0; -} -utils.htonl = htonl; - -function toHex32(msg, endian) { - var res = ''; - for (var i = 0; i < msg.length; i++) { - var w = msg[i]; - if (endian === 'little') - w = htonl(w); - res += zero8(w.toString(16)); - } - return res; -} -utils.toHex32 = toHex32; - -function zero2(word) { - if (word.length === 1) - return '0' + word; - else - return word; -} -utils.zero2 = zero2; - -function zero8(word) { - if (word.length === 7) - return '0' + word; - else if (word.length === 6) - return '00' + word; - else if (word.length === 5) - return '000' + word; - else if (word.length === 4) - return '0000' + word; - else if (word.length === 3) - return '00000' + word; - else if (word.length === 2) - return '000000' + word; - else if (word.length === 1) - return '0000000' + word; - else - return word; -} -utils.zero8 = zero8; - -function join32(msg, start, end, endian) { - var len = end - start; - assert(len % 4 === 0); - var res = new Array(len / 4); - for (var i = 0, k = start; i < res.length; i++, k += 4) { - var w; - if (endian === 'big') - w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; - else - w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; - res[i] = w >>> 0; - } - return res; -} -utils.join32 = join32; - -function split32(msg, endian) { - var res = new Array(msg.length * 4); - for (var i = 0, k = 0; i < msg.length; i++, k += 4) { - var m = msg[i]; - if (endian === 'big') { - res[k] = m >>> 24; - res[k + 1] = (m >>> 16) & 0xff; - res[k + 2] = (m >>> 8) & 0xff; - res[k + 3] = m & 0xff; - } else { - res[k + 3] = m >>> 24; - res[k + 2] = (m >>> 16) & 0xff; - res[k + 1] = (m >>> 8) & 0xff; - res[k] = m & 0xff; - } - } - return res; -} -utils.split32 = split32; - -function rotr32(w, b) { - return (w >>> b) | (w << (32 - b)); -} -utils.rotr32 = rotr32; - -function rotl32(w, b) { - return (w << b) | (w >>> (32 - b)); -} -utils.rotl32 = rotl32; - -function sum32(a, b) { - return (a + b) >>> 0; -} -utils.sum32 = sum32; - -function sum32_3(a, b, c) { - return (a + b + c) >>> 0; -} -utils.sum32_3 = sum32_3; - -function sum32_4(a, b, c, d) { - return (a + b + c + d) >>> 0; -} -utils.sum32_4 = sum32_4; - -function sum32_5(a, b, c, d, e) { - return (a + b + c + d + e) >>> 0; -} -utils.sum32_5 = sum32_5; - -function assert(cond, msg) { - if (!cond) - throw new Error(msg || 'Assertion failed'); -} -utils.assert = assert; - -utils.inherits = inherits; - -function sum64(buf, pos, ah, al) { - var bh = buf[pos]; - var bl = buf[pos + 1]; - - var lo = (al + bl) >>> 0; - var hi = (lo < al ? 1 : 0) + ah + bh; - buf[pos] = hi >>> 0; - buf[pos + 1] = lo; -} -exports.sum64 = sum64; - -function sum64_hi(ah, al, bh, bl) { - var lo = (al + bl) >>> 0; - var hi = (lo < al ? 1 : 0) + ah + bh; - return hi >>> 0; -}; -exports.sum64_hi = sum64_hi; - -function sum64_lo(ah, al, bh, bl) { - var lo = al + bl; - return lo >>> 0; -}; -exports.sum64_lo = sum64_lo; - -function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { - var carry = 0; - var lo = al; - lo = (lo + bl) >>> 0; - carry += lo < al ? 1 : 0; - lo = (lo + cl) >>> 0; - carry += lo < cl ? 1 : 0; - lo = (lo + dl) >>> 0; - carry += lo < dl ? 1 : 0; - - var hi = ah + bh + ch + dh + carry; - return hi >>> 0; -}; -exports.sum64_4_hi = sum64_4_hi; - -function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { - var lo = al + bl + cl + dl; - return lo >>> 0; -}; -exports.sum64_4_lo = sum64_4_lo; - -function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { - var carry = 0; - var lo = al; - lo = (lo + bl) >>> 0; - carry += lo < al ? 1 : 0; - lo = (lo + cl) >>> 0; - carry += lo < cl ? 1 : 0; - lo = (lo + dl) >>> 0; - carry += lo < dl ? 1 : 0; - lo = (lo + el) >>> 0; - carry += lo < el ? 1 : 0; - - var hi = ah + bh + ch + dh + eh + carry; - return hi >>> 0; -}; -exports.sum64_5_hi = sum64_5_hi; - -function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { - var lo = al + bl + cl + dl + el; - - return lo >>> 0; -}; -exports.sum64_5_lo = sum64_5_lo; - -function rotr64_hi(ah, al, num) { - var r = (al << (32 - num)) | (ah >>> num); - return r >>> 0; -}; -exports.rotr64_hi = rotr64_hi; - -function rotr64_lo(ah, al, num) { - var r = (ah << (32 - num)) | (al >>> num); - return r >>> 0; -}; -exports.rotr64_lo = rotr64_lo; - -function shr64_hi(ah, al, num) { - return ah >>> num; -}; -exports.shr64_hi = shr64_hi; - -function shr64_lo(ah, al, num) { - var r = (ah << (32 - num)) | (al >>> num); - return r >>> 0; -}; -exports.shr64_lo = shr64_lo; - - -/***/ }, -/* 198 */ -/***/ function(module, exports, __webpack_require__) { - -var Stream = __webpack_require__(11); -var Response = __webpack_require__(199); -var Base64 = __webpack_require__(140); -var inherits = __webpack_require__(2); - -var Request = module.exports = function (xhr, params) { - var self = this; - self.writable = true; - self.xhr = xhr; - self.body = []; - - self.uri = (params.protocol || 'http:') + '//' - + params.host - + (params.port ? ':' + params.port : '') - + (params.path || '/') - ; - - if (typeof params.withCredentials === 'undefined') { - params.withCredentials = true; - } - - try { xhr.withCredentials = params.withCredentials } - catch (e) {} - - if (params.responseType) try { xhr.responseType = params.responseType } - catch (e) {} - - xhr.open( - params.method || 'GET', - self.uri, - true - ); - - xhr.onerror = function(event) { - self.emit('error', new Error('Network error')); - }; - - self._headers = {}; - - if (params.headers) { - var keys = objectKeys(params.headers); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!self.isSafeRequestHeader(key)) continue; - var value = params.headers[key]; - self.setHeader(key, value); - } - } - - if (params.auth) { - //basic auth - this.setHeader('Authorization', 'Basic ' + Base64.btoa(params.auth)); - } - - var res = new Response; - res.on('close', function () { - self.emit('close'); - }); - - res.on('ready', function () { - self.emit('response', res); - }); - - res.on('error', function (err) { - self.emit('error', err); - }); - - xhr.onreadystatechange = function () { - // Fix for IE9 bug - // SCRIPT575: Could not complete the operation due to error c00c023f - // It happens when a request is aborted, calling the success callback anyway with readyState === 4 - if (xhr.__aborted) return; - res.handle(xhr); - }; -}; - -inherits(Request, Stream); - -Request.prototype.setHeader = function (key, value) { - this._headers[key.toLowerCase()] = value -}; - -Request.prototype.getHeader = function (key) { - return this._headers[key.toLowerCase()] -}; - -Request.prototype.removeHeader = function (key) { - delete this._headers[key.toLowerCase()] -}; - -Request.prototype.write = function (s) { - this.body.push(s); -}; - -Request.prototype.destroy = function (s) { - this.xhr.__aborted = true; - this.xhr.abort(); - this.emit('close'); -}; - -Request.prototype.end = function (s) { - if (s !== undefined) this.body.push(s); - - var keys = objectKeys(this._headers); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var value = this._headers[key]; - if (isArray(value)) { - for (var j = 0; j < value.length; j++) { - this.xhr.setRequestHeader(key, value[j]); - } - } - else this.xhr.setRequestHeader(key, value) - } - - if (this.body.length === 0) { - this.xhr.send(''); - } - else if (typeof this.body[0] === 'string') { - this.xhr.send(this.body.join('')); - } - else if (isArray(this.body[0])) { - var body = []; - for (var i = 0; i < this.body.length; i++) { - body.push.apply(body, this.body[i]); - } - this.xhr.send(body); - } - else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) { - var len = 0; - for (var i = 0; i < this.body.length; i++) { - len += this.body[i].length; - } - var body = new(this.body[0].constructor)(len); - var k = 0; - - for (var i = 0; i < this.body.length; i++) { - var b = this.body[i]; - for (var j = 0; j < b.length; j++) { - body[k++] = b[j]; - } - } - this.xhr.send(body); - } - else if (isXHR2Compatible(this.body[0])) { - this.xhr.send(this.body[0]); - } - else { - var body = ''; - for (var i = 0; i < this.body.length; i++) { - body += this.body[i].toString(); - } - this.xhr.send(body); - } -}; - -// Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html -Request.unsafeHeaders = [ - "accept-charset", - "accept-encoding", - "access-control-request-headers", - "access-control-request-method", - "connection", - "content-length", - "cookie", - "cookie2", - "content-transfer-encoding", - "date", - "expect", - "host", - "keep-alive", - "origin", - "referer", - "te", - "trailer", - "transfer-encoding", - "upgrade", - "user-agent", - "via" -]; - -Request.prototype.isSafeRequestHeader = function (headerName) { - if (!headerName) return false; - return indexOf(Request.unsafeHeaders, headerName.toLowerCase()) === -1; -}; - -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var indexOf = function (xs, x) { - if (xs.indexOf) return xs.indexOf(x); - for (var i = 0; i < xs.length; i++) { - if (xs[i] === x) return i; - } - return -1; -}; - -var isXHR2Compatible = function (obj) { - if (typeof Blob !== 'undefined' && obj instanceof Blob) return true; - if (typeof ArrayBuffer !== 'undefined' && obj instanceof ArrayBuffer) return true; - if (typeof FormData !== 'undefined' && obj instanceof FormData) return true; -}; - - -/***/ }, -/* 199 */ -/***/ function(module, exports, __webpack_require__) { - -var Stream = __webpack_require__(11); -var util = __webpack_require__(10); - -var Response = module.exports = function (res) { - this.offset = 0; - this.readable = true; -}; - -util.inherits(Response, Stream); - -var capable = { - streaming : true, - status2 : true -}; - -function parseHeaders (res) { - var lines = res.getAllResponseHeaders().split(/\r?\n/); - var headers = {}; - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; - if (line === '') continue; - - var m = line.match(/^([^:]+):\s*(.*)/); - if (m) { - var key = m[1].toLowerCase(), value = m[2]; - - if (headers[key] !== undefined) { - - if (isArray(headers[key])) { - headers[key].push(value); - } - else { - headers[key] = [ headers[key], value ]; - } - } - else { - headers[key] = value; - } - } - else { - headers[line] = true; - } - } - return headers; -} - -Response.prototype.getResponse = function (xhr) { - var respType = String(xhr.responseType).toLowerCase(); - if (respType === 'blob') return xhr.responseBlob || xhr.response; - if (respType === 'arraybuffer') return xhr.response; - return xhr.responseText; -} - -Response.prototype.getHeader = function (key) { - return this.headers[key.toLowerCase()]; -}; - -Response.prototype.handle = function (res) { - if (res.readyState === 2 && capable.status2) { - try { - this.statusCode = res.status; - this.headers = parseHeaders(res); - } - catch (err) { - capable.status2 = false; - } - - if (capable.status2) { - this.emit('ready'); - } - } - else if (capable.streaming && res.readyState === 3) { - try { - if (!this.statusCode) { - this.statusCode = res.status; - this.headers = parseHeaders(res); - this.emit('ready'); - } - } - catch (err) {} - - try { - this._emitData(res); - } - catch (err) { - capable.streaming = false; - } - } - else if (res.readyState === 4) { - if (!this.statusCode) { - this.statusCode = res.status; - this.emit('ready'); - } - this._emitData(res); - - if (res.error) { - this.emit('error', this.getResponse(res)); - } - else this.emit('end'); - - this.emit('close'); - } -}; - -Response.prototype._emitData = function (res) { - var respBody = this.getResponse(res); - if (respBody.toString().match(/ArrayBuffer/)) { - this.emit('data', new Uint8Array(respBody, this.offset)); - this.offset = respBody.byteLength; - return; - } - if (respBody.length > this.offset) { - this.emit('data', respBody.slice(this.offset)); - this.offset = respBody.length; - } -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - - -/***/ }, -/* 200 */ +/* 85 */ /***/ function(module, exports) { exports.read = function (buffer, offset, isLE, mLen, nBytes) { @@ -38816,203 +18914,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { /***/ }, -/* 201 */ -/***/ function(module, exports) { - - -var indexOf = [].indexOf; - -module.exports = function(arr, obj){ - if (indexOf) return arr.indexOf(obj); - for (var i = 0; i < arr.length; ++i) { - if (arr[i] === obj) return i; - } - return -1; -}; - -/***/ }, -/* 202 */ -/***/ function(module, exports) { - -module.exports = { - "modp1": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" - }, - "modp2": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" - }, - "modp5": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" - }, - "modp14": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" - }, - "modp15": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" - }, - "modp16": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" - }, - "modp17": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" - }, - "modp18": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" - } -}; - -/***/ }, -/* 203 */ -/***/ function(module, exports) { - -module.exports = { - "_args": [ - [ - { - "raw": "elliptic@^6.0.0", - "scope": null, - "escapedName": "elliptic", - "name": "elliptic", - "rawSpec": "^6.0.0", - "spec": ">=6.0.0 <7.0.0", - "type": "range" - }, - "/home/travis/build/hydrabolt/discord.js/node_modules/browserify-sign" - ] - ], - "_from": "elliptic@>=6.0.0 <7.0.0", - "_id": "elliptic@6.3.2", - "_inCache": true, - "_location": "/elliptic", - "_nodeVersion": "6.3.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/elliptic-6.3.2.tgz_1473938837205_0.3108903462998569" - }, - "_npmUser": { - "name": "indutny", - "email": "fedor@indutny.com" - }, - "_npmVersion": "3.10.3", - "_phantomChildren": {}, - "_requested": { - "raw": "elliptic@^6.0.0", - "scope": null, - "escapedName": "elliptic", - "name": "elliptic", - "rawSpec": "^6.0.0", - "spec": ">=6.0.0 <7.0.0", - "type": "range" - }, - "_requiredBy": [ - "/browserify-sign", - "/create-ecdh" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz", - "_shasum": "e4c81e0829cf0a65ab70e998b8232723b5c1bc48", - "_shrinkwrap": null, - "_spec": "elliptic@^6.0.0", - "_where": "/home/travis/build/hydrabolt/discord.js/node_modules/browserify-sign", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" - }, - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "dependencies": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "inherits": "^2.0.1" - }, - "description": "EC cryptography", - "devDependencies": { - "brfs": "^1.4.3", - "coveralls": "^2.11.3", - "grunt": "^0.4.5", - "grunt-browserify": "^5.0.0", - "grunt-contrib-connect": "^1.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-uglify": "^1.0.1", - "grunt-mocha-istanbul": "^3.0.1", - "grunt-saucelabs": "^8.6.2", - "istanbul": "^0.4.2", - "jscs": "^2.9.0", - "jshint": "^2.6.0", - "mocha": "^2.1.0" - }, - "directories": {}, - "dist": { - "shasum": "e4c81e0829cf0a65ab70e998b8232723b5c1bc48", - "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz" - }, - "files": [ - "lib" - ], - "gitHead": "cbace4683a4a548dc0306ef36756151a20299cd5", - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "maintainers": [ - { - "name": "indutny", - "email": "fedor@indutny.com" - } - ], - "name": "elliptic", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "lint": "npm run jscs && npm run jshint", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.3.2" -}; - -/***/ }, -/* 204 */ -/***/ function(module, exports) { - -module.exports = { - "2.16.840.1.101.3.4.1.1": "aes-128-ecb", - "2.16.840.1.101.3.4.1.2": "aes-128-cbc", - "2.16.840.1.101.3.4.1.3": "aes-128-ofb", - "2.16.840.1.101.3.4.1.4": "aes-128-cfb", - "2.16.840.1.101.3.4.1.21": "aes-192-ecb", - "2.16.840.1.101.3.4.1.22": "aes-192-cbc", - "2.16.840.1.101.3.4.1.23": "aes-192-ofb", - "2.16.840.1.101.3.4.1.24": "aes-192-cfb", - "2.16.840.1.101.3.4.1.41": "aes-256-ecb", - "2.16.840.1.101.3.4.1.42": "aes-256-cbc", - "2.16.840.1.101.3.4.1.43": "aes-256-ofb", - "2.16.840.1.101.3.4.1.44": "aes-256-cfb" -}; - -/***/ }, -/* 205 */ +/* 86 */ /***/ function(module, exports) { "use strict"; @@ -39069,17 +18971,17 @@ module.exports = { /***/ }, -/* 206 */ +/* 87 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; -var utils = __webpack_require__(42); -var trees = __webpack_require__(210); -var adler32 = __webpack_require__(109); -var crc32 = __webpack_require__(110); -var msg = __webpack_require__(111); +var utils = __webpack_require__(24); +var trees = __webpack_require__(91); +var adler32 = __webpack_require__(59); +var crc32 = __webpack_require__(60); +var msg = __webpack_require__(61); /* Public constants ==========================================================*/ /* ===========================================================================*/ @@ -40931,7 +20833,7 @@ exports.deflateTune = deflateTune; /***/ }, -/* 207 */ +/* 88 */ /***/ function(module, exports) { "use strict"; @@ -41264,18 +21166,18 @@ module.exports = function inflate_fast(strm, start) { /***/ }, -/* 208 */ +/* 89 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; -var utils = __webpack_require__(42); -var adler32 = __webpack_require__(109); -var crc32 = __webpack_require__(110); -var inflate_fast = __webpack_require__(207); -var inflate_table = __webpack_require__(209); +var utils = __webpack_require__(24); +var adler32 = __webpack_require__(59); +var crc32 = __webpack_require__(60); +var inflate_fast = __webpack_require__(88); +var inflate_table = __webpack_require__(90); var CODES = 0; var LENS = 1; @@ -42809,14 +22711,14 @@ exports.inflateUndermine = inflateUndermine; /***/ }, -/* 209 */ +/* 90 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; -var utils = __webpack_require__(42); +var utils = __webpack_require__(24); var MAXBITS = 15; var ENOUGH_LENS = 852; @@ -43143,14 +23045,14 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta /***/ }, -/* 210 */ +/* 91 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; -var utils = __webpack_require__(42); +var utils = __webpack_require__(24); /* Public constants ==========================================================*/ /* ===========================================================================*/ @@ -44352,7 +24254,7 @@ exports._tr_align = _tr_align; /***/ }, -/* 211 */ +/* 92 */ /***/ function(module, exports) { "use strict"; @@ -44388,1168 +24290,22 @@ module.exports = ZStream; /***/ }, -/* 212 */ +/* 93 */ /***/ function(module, exports, __webpack_require__) { -// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js -// Fedor, you are amazing. - -var asn1 = __webpack_require__(36) - -var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('modulus').int(), - this.key('publicExponent').int(), - this.key('privateExponent').int(), - this.key('prime1').int(), - this.key('prime2').int(), - this.key('exponent1').int(), - this.key('exponent2').int(), - this.key('coefficient').int() - ) -}) -exports.RSAPrivateKey = RSAPrivateKey - -var RSAPublicKey = asn1.define('RSAPublicKey', function () { - this.seq().obj( - this.key('modulus').int(), - this.key('publicExponent').int() - ) -}) -exports.RSAPublicKey = RSAPublicKey - -var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) -exports.PublicKey = PublicKey - -var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('none').null_().optional(), - this.key('curve').objid().optional(), - this.key('params').seq().obj( - this.key('p').int(), - this.key('q').int(), - this.key('g').int() - ).optional() - ) -}) - -var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { - this.seq().obj( - this.key('version').int(), - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPrivateKey').octstr() - ) -}) -exports.PrivateKey = PrivateKeyInfo -var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { - this.seq().obj( - this.key('algorithm').seq().obj( - this.key('id').objid(), - this.key('decrypt').seq().obj( - this.key('kde').seq().obj( - this.key('id').objid(), - this.key('kdeparams').seq().obj( - this.key('salt').octstr(), - this.key('iters').int() - ) - ), - this.key('cipher').seq().obj( - this.key('algo').objid(), - this.key('iv').octstr() - ) - ) - ), - this.key('subjectPrivateKey').octstr() - ) -}) - -exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo - -var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('p').int(), - this.key('q').int(), - this.key('g').int(), - this.key('pub_key').int(), - this.key('priv_key').int() - ) -}) -exports.DSAPrivateKey = DSAPrivateKey - -exports.DSAparam = asn1.define('DSAparam', function () { - this.int() -}) -var ECPrivateKey = asn1.define('ECPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('privateKey').octstr(), - this.key('parameters').optional().explicit(0).use(ECParameters), - this.key('publicKey').optional().explicit(1).bitstr() - ) -}) -exports.ECPrivateKey = ECPrivateKey -var ECParameters = asn1.define('ECParameters', function () { - this.choice({ - namedCurve: this.objid() - }) -}) - -exports.signature = asn1.define('signature', function () { - this.seq().obj( - this.key('r').int(), - this.key('s').int() - ) -}) +module.exports = __webpack_require__(10) /***/ }, -/* 213 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {// adapted from https://github.com/apatil/pemstrip -var findProc = /Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\r?\n\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n/m -var startRegex = /^-----BEGIN (.*) KEY-----\r?\n/m -var fullRegex = /^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m -var evp = __webpack_require__(41) -var ciphers = __webpack_require__(50) -module.exports = function (okey, password) { - var key = okey.toString() - var match = key.match(findProc) - var decrypted - if (!match) { - var match2 = key.match(fullRegex) - decrypted = new Buffer(match2[2].replace(/\r?\n/g, ''), 'base64') - } else { - var suite = 'aes' + match[1] - var iv = new Buffer(match[2], 'hex') - var cipherText = new Buffer(match[3].replace(/\r?\n/g, ''), 'base64') - var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key - var out = [] - var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - decrypted = Buffer.concat(out) - } - var tag = key.match(startRegex)[1] + ' KEY' - return { - tag: tag, - data: decrypted - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 214 */ -/***/ function(module, exports) { - -var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs -module.exports = function (iterations, keylen) { - if (typeof iterations !== 'number') { - throw new TypeError('Iterations not a number') - } - - if (iterations < 0) { - throw new TypeError('Bad iterations') - } - - if (typeof keylen !== 'number') { - throw new TypeError('Key length not a number') - } - - if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */ - throw new TypeError('Bad key length') - } -} - - -/***/ }, -/* 215 */ -/***/ function(module, exports, __webpack_require__) { - -exports.publicEncrypt = __webpack_require__(217); -exports.privateDecrypt = __webpack_require__(216); - -exports.privateEncrypt = function privateEncrypt(key, buf) { - return exports.publicEncrypt(key, buf, true); -}; - -exports.publicDecrypt = function publicDecrypt(key, buf) { - return exports.privateDecrypt(key, buf, true); -}; - -/***/ }, -/* 216 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(43); -var mgf = __webpack_require__(113); -var xor = __webpack_require__(115); -var bn = __webpack_require__(7); -var crt = __webpack_require__(51); -var createHash = __webpack_require__(21); -var withPublic = __webpack_require__(114); -module.exports = function privateDecrypt(private_key, enc, reverse) { - var padding; - if (private_key.padding) { - padding = private_key.padding; - } else if (reverse) { - padding = 1; - } else { - padding = 4; - } - - var key = parseKeys(private_key); - var k = key.modulus.byteLength(); - if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) { - throw new Error('decryption error'); - } - var msg; - if (reverse) { - msg = withPublic(new bn(enc), key); - } else { - msg = crt(enc, key); - } - var zBuffer = new Buffer(k - msg.length); - zBuffer.fill(0); - msg = Buffer.concat([zBuffer, msg], k); - if (padding === 4) { - return oaep(key, msg); - } else if (padding === 1) { - return pkcs1(key, msg, reverse); - } else if (padding === 3) { - return msg; - } else { - throw new Error('unknown padding'); - } -}; - -function oaep(key, msg){ - var n = key.modulus; - var k = key.modulus.byteLength(); - var mLen = msg.length; - var iHash = createHash('sha1').update(new Buffer('')).digest(); - var hLen = iHash.length; - var hLen2 = 2 * hLen; - if (msg[0] !== 0) { - throw new Error('decryption error'); - } - var maskedSeed = msg.slice(1, hLen + 1); - var maskedDb = msg.slice(hLen + 1); - var seed = xor(maskedSeed, mgf(maskedDb, hLen)); - var db = xor(maskedDb, mgf(seed, k - hLen - 1)); - if (compare(iHash, db.slice(0, hLen))) { - throw new Error('decryption error'); - } - var i = hLen; - while (db[i] === 0) { - i++; - } - if (db[i++] !== 1) { - throw new Error('decryption error'); - } - return db.slice(i); -} - -function pkcs1(key, msg, reverse){ - var p1 = msg.slice(0, 2); - var i = 2; - var status = 0; - while (msg[i++] !== 0) { - if (i >= msg.length) { - status++; - break; - } - } - var ps = msg.slice(2, i - 1); - var p2 = msg.slice(i - 1, i); - - if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){ - status++; - } - if (ps.length < 8) { - status++; - } - if (status) { - throw new Error('decryption error'); - } - return msg.slice(i); -} -function compare(a, b){ - a = new Buffer(a); - b = new Buffer(b); - var dif = 0; - var len = a.length; - if (a.length !== b.length) { - dif++; - len = Math.min(a.length, b.length); - } - var i = -1; - while (++i < len) { - dif += (a[i] ^ b[i]); - } - return dif; -} -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 217 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(43); -var randomBytes = __webpack_require__(30); -var createHash = __webpack_require__(21); -var mgf = __webpack_require__(113); -var xor = __webpack_require__(115); -var bn = __webpack_require__(7); -var withPublic = __webpack_require__(114); -var crt = __webpack_require__(51); - -var constants = { - RSA_PKCS1_OAEP_PADDING: 4, - RSA_PKCS1_PADDIN: 1, - RSA_NO_PADDING: 3 -}; - -module.exports = function publicEncrypt(public_key, msg, reverse) { - var padding; - if (public_key.padding) { - padding = public_key.padding; - } else if (reverse) { - padding = 1; - } else { - padding = 4; - } - var key = parseKeys(public_key); - var paddedMsg; - if (padding === 4) { - paddedMsg = oaep(key, msg); - } else if (padding === 1) { - paddedMsg = pkcs1(key, msg, reverse); - } else if (padding === 3) { - paddedMsg = new bn(msg); - if (paddedMsg.cmp(key.modulus) >= 0) { - throw new Error('data too long for modulus'); - } - } else { - throw new Error('unknown padding'); - } - if (reverse) { - return crt(paddedMsg, key); - } else { - return withPublic(paddedMsg, key); - } -}; - -function oaep(key, msg){ - var k = key.modulus.byteLength(); - var mLen = msg.length; - var iHash = createHash('sha1').update(new Buffer('')).digest(); - var hLen = iHash.length; - var hLen2 = 2 * hLen; - if (mLen > k - hLen2 - 2) { - throw new Error('message too long'); - } - var ps = new Buffer(k - mLen - hLen2 - 2); - ps.fill(0); - var dblen = k - hLen - 1; - var seed = randomBytes(hLen); - var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen)); - var maskedSeed = xor(seed, mgf(maskedDb, hLen)); - return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k)); -} -function pkcs1(key, msg, reverse){ - var mLen = msg.length; - var k = key.modulus.byteLength(); - if (mLen > k - 11) { - throw new Error('message too long'); - } - var ps; - if (reverse) { - ps = new Buffer(k - mLen - 3); - ps.fill(0xff); - } else { - ps = nonZero(k - mLen - 3); - } - return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k)); -} -function nonZero(len, crypto) { - var out = new Buffer(len); - var i = 0; - var cache = randomBytes(len*2); - var cur = 0; - var num; - while (i < len) { - if (cur === cache.length) { - cache = randomBytes(len*2); - cur = 0; - } - num = cache[cur++]; - if (num) { - out[i++] = num; - } - } - return out; -} -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 218 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; - - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - true - ) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { - return punycode; - }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } - -}(this)); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(121)(module), __webpack_require__(18))) - -/***/ }, -/* 219 */ -/***/ function(module, exports) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; - - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } - - var regexp = /\+/g; - qs = qs.split(sep); - - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } - - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } - - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } - - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); - - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - - -/***/ }, -/* 220 */ -/***/ function(module, exports) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; - - case 'boolean': - return v ? 'true' : 'false'; - - case 'number': - return isFinite(v) ? v : ''; - - default: - return ''; - } -}; - -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } - - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); - - } - - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} - -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; -}; - - -/***/ }, -/* 221 */ +/* 94 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; -exports.decode = exports.parse = __webpack_require__(219); -exports.encode = exports.stringify = __webpack_require__(220); - - -/***/ }, -/* 222 */ -/***/ function(module, exports, __webpack_require__) { - -module.exports = __webpack_require__(17) - - -/***/ }, -/* 223 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -var Buffer = __webpack_require__(0).Buffer; +var Buffer = __webpack_require__(5).Buffer; /**/ -var bufferShim = __webpack_require__(52); +var bufferShim = __webpack_require__(31); /**/ module.exports = BufferList; @@ -45611,50 +24367,50 @@ BufferList.prototype.concat = function (n) { }; /***/ }, -/* 224 */ +/* 95 */ /***/ function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(116) +module.exports = __webpack_require__(62) /***/ }, -/* 225 */ +/* 96 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {var Stream = (function (){ try { - return __webpack_require__(11); // hack to fix a circular dependency issue when used with browserify + return __webpack_require__(25); // hack to fix a circular dependency issue when used with browserify } catch(_){} }()); -exports = module.exports = __webpack_require__(117); +exports = module.exports = __webpack_require__(63); exports.Stream = Stream || exports; exports.Readable = exports; -exports.Writable = __webpack_require__(58); -exports.Duplex = __webpack_require__(17); -exports.Transform = __webpack_require__(57); -exports.PassThrough = __webpack_require__(116); +exports.Writable = __webpack_require__(34); +exports.Duplex = __webpack_require__(10); +exports.Transform = __webpack_require__(33); +exports.PassThrough = __webpack_require__(62); if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) { module.exports = Stream; } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) /***/ }, -/* 226 */ +/* 97 */ /***/ function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(58) +module.exports = __webpack_require__(34) /***/ }, -/* 227 */ +/* 98 */ /***/ function(module, exports, __webpack_require__) { /** * Module of mixed-in functions shared between node and client code */ -var isObject = __webpack_require__(119); +var isObject = __webpack_require__(66); /** * Expose `RequestBase`. @@ -46044,7 +24800,7 @@ RequestBase.prototype.send = function(data){ /***/ }, -/* 228 */ +/* 99 */ /***/ function(module, exports) { // The node and browser modules expose versions of this with the @@ -46082,177 +24838,7 @@ module.exports = request; /***/ }, -/* 229 */ -/***/ function(module, exports) { - -"use strict"; -'use strict'; - -var has = Object.prototype.hasOwnProperty; - -/** - * An auto incrementing id which we can use to create "unique" Ultron instances - * so we can track the event emitters that are added through the Ultron - * interface. - * - * @type {Number} - * @private - */ -var id = 0; - -/** - * Ultron is high-intelligence robot. It gathers intelligence so it can start improving - * upon his rudimentary design. It will learn from your EventEmitting patterns - * and exterminate them. - * - * @constructor - * @param {EventEmitter} ee EventEmitter instance we need to wrap. - * @api public - */ -function Ultron(ee) { - if (!(this instanceof Ultron)) return new Ultron(ee); - - this.id = id++; - this.ee = ee; -} - -/** - * Register a new EventListener for the given event. - * - * @param {String} event Name of the event. - * @param {Functon} fn Callback function. - * @param {Mixed} context The context of the function. - * @returns {Ultron} - * @api public - */ -Ultron.prototype.on = function on(event, fn, context) { - fn.__ultron = this.id; - this.ee.on(event, fn, context); - - return this; -}; -/** - * Add an EventListener that's only called once. - * - * @param {String} event Name of the event. - * @param {Function} fn Callback function. - * @param {Mixed} context The context of the function. - * @returns {Ultron} - * @api public - */ -Ultron.prototype.once = function once(event, fn, context) { - fn.__ultron = this.id; - this.ee.once(event, fn, context); - - return this; -}; - -/** - * Remove the listeners we assigned for the given event. - * - * @returns {Ultron} - * @api public - */ -Ultron.prototype.remove = function remove() { - var args = arguments - , event; - - // - // When no event names are provided we assume that we need to clear all the - // events that were assigned through us. - // - if (args.length === 1 && 'string' === typeof args[0]) { - args = args[0].split(/[, ]+/); - } else if (!args.length) { - args = []; - - for (event in this.ee._events) { - if (has.call(this.ee._events, event)) args.push(event); - } - } - - for (var i = 0; i < args.length; i++) { - var listeners = this.ee.listeners(args[i]); - - for (var j = 0; j < listeners.length; j++) { - event = listeners[j]; - - // - // Once listeners have a `listener` property that stores the real listener - // in the EventEmitter that ships with Node.js. - // - if (event.listener) { - if (event.listener.__ultron !== this.id) continue; - delete event.listener.__ultron; - } else { - if (event.__ultron !== this.id) continue; - delete event.__ultron; - } - - this.ee.removeListener(args[i], event); - } - } - - return this; -}; - -/** - * Destroy the Ultron instance, remove all listeners and release all references. - * - * @returns {Boolean} - * @api public - */ -Ultron.prototype.destroy = function destroy() { - if (!this.ee) return false; - - this.remove(); - this.ee = null; - - return true; -}; - -// -// Expose the module. -// -module.exports = Ultron; - - -/***/ }, -/* 230 */ -/***/ function(module, exports) { - -"use strict"; -'use strict'; - -/*! - * UTF-8 validate: UTF-8 validation for WebSockets. - * Copyright(c) 2015 Einar Otto Stangvik - * MIT Licensed - */ - -module.exports.Validation = { - isValidUTF8: function(buffer) { - return true; - } -}; - - -/***/ }, -/* 231 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -try { - module.exports = __webpack_require__(89)('validation'); -} catch (e) { - module.exports = __webpack_require__(230); -} - - -/***/ }, -/* 232 */ +/* 100 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) { @@ -46326,7 +24912,7 @@ function config (name) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18))) /***/ }, -/* 233 */ +/* 101 */ /***/ function(module, exports) { if (typeof Object.create === 'function') { @@ -46355,7 +24941,7 @@ if (typeof Object.create === 'function') { /***/ }, -/* 234 */ +/* 102 */ /***/ function(module, exports) { module.exports = function isBuffer(arg) { @@ -46366,171 +24952,7 @@ module.exports = function isBuffer(arg) { } /***/ }, -/* 235 */ -/***/ function(module, exports, __webpack_require__) { - -var indexOf = __webpack_require__(201); - -var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var defineProp = (function() { - try { - Object.defineProperty({}, '_', {}); - return function(obj, name, value) { - Object.defineProperty(obj, name, { - writable: true, - enumerable: false, - configurable: true, - value: value - }) - }; - } catch(e) { - return function(obj, name, value) { - obj[name] = value; - }; - } -}()); - -var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function', -'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError', -'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError', -'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', -'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape']; - -function Context() {} -Context.prototype = {}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -Script.prototype.runInContext = function (context) { - if (!(context instanceof Context)) { - throw new TypeError("needs a 'context' argument."); - } - - var iframe = document.createElement('iframe'); - if (!iframe.style) iframe.style = {}; - iframe.style.display = 'none'; - - document.body.appendChild(iframe); - - var win = iframe.contentWindow; - var wEval = win.eval, wExecScript = win.execScript; - - if (!wEval && wExecScript) { - // win.eval() magically appears when this is called in IE: - wExecScript.call(win, 'null'); - wEval = win.eval; - } - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - }); - forEach(globals, function (key) { - if (context[key]) { - win[key] = context[key]; - } - }); - - var winKeys = Object_keys(win); - - var res = wEval.call(win, this.code); - - forEach(Object_keys(win), function (key) { - // Avoid copying circular objects like `top` and `window` by only - // updating existing context properties or new properties in the `win` - // that was only introduced after the eval. - if (key in context || indexOf(winKeys, key) === -1) { - context[key] = win[key]; - } - }); - - forEach(globals, function (key) { - if (!(key in context)) { - defineProp(context, key, win[key]); - } - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInNewContext = function (context) { - var ctx = Script.createContext(context); - var res = this.runInContext(ctx); - - forEach(Object_keys(ctx), function (key) { - context[key] = ctx[key]; - }); - - return res; -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - var copy = new Context(); - if(typeof context === 'object') { - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - } - return copy; -}; - - -/***/ }, -/* 236 */ -/***/ function(module, exports, __webpack_require__) { - -var http = __webpack_require__(55); - -var https = module.exports; - -for (var key in http) { - if (http.hasOwnProperty(key)) https[key] = http[key]; -}; - -https.request = function (params, cb) { - if (!params) params = {}; - params.scheme = 'https'; - params.protocol = 'https:'; - return http.request.call(this, params, cb); -} - - -/***/ }, -/* 237 */ +/* 103 */ /***/ function(module, exports) { exports.lookup = exports.resolve4 = @@ -46551,1090 +24973,7 @@ function () { /***/ }, -/* 238 */ -/***/ function(module, exports) { - -// todo - - -/***/ }, -/* 239 */ -/***/ function(module, exports) { - -"use strict"; -'use strict'; - -module.exports = { - isString: function(arg) { - return typeof(arg) === 'string'; - }, - isObject: function(arg) { - return typeof(arg) === 'object' && arg !== null; - }, - isNull: function(arg) { - return arg === null; - }, - isNullOrUndefined: function(arg) { - return arg == null; - } -}; - - -/***/ }, -/* 240 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = __webpack_require__(10); - -function BufferPool(initialSize, growStrategy, shrinkStrategy) { - if (this instanceof BufferPool === false) { - throw new TypeError("Classes can't be function-called"); - } - - if (typeof initialSize === 'function') { - shrinkStrategy = growStrategy; - growStrategy = initialSize; - initialSize = 0; - } - else if (typeof initialSize === 'undefined') { - initialSize = 0; - } - this._growStrategy = (growStrategy || function(db, size) { - return db.used + size; - }).bind(null, this); - this._shrinkStrategy = (shrinkStrategy || function(db) { - return initialSize; - }).bind(null, this); - this._buffer = initialSize ? new Buffer(initialSize) : null; - this._offset = 0; - this._used = 0; - this._changeFactor = 0; - this.__defineGetter__('size', function(){ - return this._buffer == null ? 0 : this._buffer.length; - }); - this.__defineGetter__('used', function(){ - return this._used; - }); -} - -BufferPool.prototype.get = function(length) { - if (this._buffer == null || this._offset + length > this._buffer.length) { - var newBuf = new Buffer(this._growStrategy(length)); - this._buffer = newBuf; - this._offset = 0; - } - this._used += length; - var buf = this._buffer.slice(this._offset, this._offset + length); - this._offset += length; - return buf; -} - -BufferPool.prototype.reset = function(forceNewBuffer) { - var len = this._shrinkStrategy(); - if (len < this.size) this._changeFactor -= 1; - if (forceNewBuffer || this._changeFactor < -2) { - this._changeFactor = 0; - this._buffer = len ? new Buffer(len) : null; - } - this._offset = 0; - this._used = 0; -} - -module.exports = BufferPool; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 241 */ -/***/ function(module, exports) { - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -exports.BufferUtil = { - merge: function(mergedBuffer, buffers) { - var offset = 0; - for (var i = 0, l = buffers.length; i < l; ++i) { - var buf = buffers[i]; - buf.copy(mergedBuffer, offset); - offset += buf.length; - } - }, - mask: function(source, mask, output, offset, length) { - var maskNum = mask.readUInt32LE(0, true); - var i = 0; - for (; i < length - 3; i += 4) { - var num = maskNum ^ source.readUInt32LE(i, true); - if (num < 0) num = 4294967296 + num; - output.writeUInt32LE(num, offset + i, true); - } - switch (length % 4) { - case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; - case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; - case 1: output[offset + i] = source[i] ^ mask[0]; - case 0:; - } - }, - unmask: function(data, mask) { - var maskNum = mask.readUInt32LE(0, true); - var length = data.length; - var i = 0; - for (; i < length - 3; i += 4) { - var num = maskNum ^ data.readUInt32LE(i, true); - if (num < 0) num = 4294967296 + num; - data.writeUInt32LE(num, i, true); - } - switch (length % 4) { - case 3: data[i + 2] = data[i + 2] ^ mask[2]; - case 2: data[i + 1] = data[i + 1] ^ mask[1]; - case 1: data[i] = data[i] ^ mask[0]; - case 0:; - } - } -} - - -/***/ }, -/* 242 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = __webpack_require__(10); - -/** - * State constants - */ - -var EMPTY = 0 - , BODY = 1; -var BINARYLENGTH = 2 - , BINARYBODY = 3; - -/** - * Hixie Receiver implementation - */ - -function Receiver () { - if (this instanceof Receiver === false) { - throw new TypeError("Classes can't be function-called"); - } - - this.state = EMPTY; - this.buffers = []; - this.messageEnd = -1; - this.spanLength = 0; - this.dead = false; - - this.onerror = function() {}; - this.ontext = function() {}; - this.onbinary = function() {}; - this.onclose = function() {}; - this.onping = function() {}; - this.onpong = function() {}; -} - -module.exports = Receiver; - -/** - * Add new data to the parser. - * - * @api public - */ - -Receiver.prototype.add = function(data) { - if (this.dead) return; - var self = this; - function doAdd() { - if (self.state === EMPTY) { - if (data.length == 2 && data[0] == 0xFF && data[1] == 0x00) { - self.reset(); - self.onclose(); - return; - } - if (data[0] === 0x80) { - self.messageEnd = 0; - self.state = BINARYLENGTH; - data = data.slice(1); - } else { - - if (data[0] !== 0x00) { - self.error('payload must start with 0x00 byte', true); - return; - } - data = data.slice(1); - self.state = BODY; - - } - } - if (self.state === BINARYLENGTH) { - var i = 0; - while ((i < data.length) && (data[i] & 0x80)) { - self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); - ++i; - } - if (i < data.length) { - self.messageEnd = 128 * self.messageEnd + (data[i] & 0x7f); - self.state = BINARYBODY; - ++i; - } - if (i > 0) - data = data.slice(i); - } - if (self.state === BINARYBODY) { - var dataleft = self.messageEnd - self.spanLength; - if (data.length >= dataleft) { - // consume the whole buffer to finish the frame - self.buffers.push(data); - self.spanLength += dataleft; - self.messageEnd = dataleft; - return self.parse(); - } - // frame's not done even if we consume it all - self.buffers.push(data); - self.spanLength += data.length; - return; - } - self.buffers.push(data); - if ((self.messageEnd = bufferIndex(data, 0xFF)) != -1) { - self.spanLength += self.messageEnd; - return self.parse(); - } - else self.spanLength += data.length; - } - while(data) data = doAdd(); -}; - -/** - * Releases all resources used by the receiver. - * - * @api public - */ - -Receiver.prototype.cleanup = function() { - this.dead = true; - this.state = EMPTY; - this.buffers = []; -}; - -/** - * Process buffered data. - * - * @api public - */ - -Receiver.prototype.parse = function() { - var output = new Buffer(this.spanLength); - var outputIndex = 0; - for (var bi = 0, bl = this.buffers.length; bi < bl - 1; ++bi) { - var buffer = this.buffers[bi]; - buffer.copy(output, outputIndex); - outputIndex += buffer.length; - } - var lastBuffer = this.buffers[this.buffers.length - 1]; - if (this.messageEnd > 0) lastBuffer.copy(output, outputIndex, 0, this.messageEnd); - if (this.state !== BODY) --this.messageEnd; - var tail = null; - if (this.messageEnd < lastBuffer.length - 1) { - tail = lastBuffer.slice(this.messageEnd + 1); - } - this.reset(); - this.ontext(output.toString('utf8')); - return tail; -}; - -/** - * Handles an error - * - * @api private - */ - -Receiver.prototype.error = function (reason, terminate) { - if (this.dead) return; - this.reset(); - if(typeof reason == 'string'){ - this.onerror(new Error(reason), terminate); - } - else if(reason.constructor == Error){ - this.onerror(reason, terminate); - } - else{ - this.onerror(new Error("An error occured"),terminate); - } - return this; -}; - -/** - * Reset parser state - * - * @api private - */ - -Receiver.prototype.reset = function (reason) { - if (this.dead) return; - this.state = EMPTY; - this.buffers = []; - this.messageEnd = -1; - this.spanLength = 0; -}; - -/** - * Internal api - */ - -function bufferIndex(buffer, byte) { - for (var i = 0, l = buffer.length; i < l; ++i) { - if (buffer[i] === byte) return i; - } - return -1; -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 243 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var events = __webpack_require__(5) - , util = __webpack_require__(10) - , EventEmitter = events.EventEmitter; - -/** - * Hixie Sender implementation - */ - -function Sender(socket) { - if (this instanceof Sender === false) { - throw new TypeError("Classes can't be function-called"); - } - - events.EventEmitter.call(this); - - this.socket = socket; - this.continuationFrame = false; - this.isClosed = false; -} - -module.exports = Sender; - -/** - * Inherits from EventEmitter. - */ - -util.inherits(Sender, events.EventEmitter); - -/** - * Frames and writes data. - * - * @api public - */ - -Sender.prototype.send = function(data, options, cb) { - if (this.isClosed) return; - - var isString = typeof data == 'string' - , length = isString ? Buffer.byteLength(data) : data.length - , lengthbytes = (length > 127) ? 2 : 1 // assume less than 2**14 bytes - , writeStartMarker = this.continuationFrame == false - , writeEndMarker = !options || !(typeof options.fin != 'undefined' && !options.fin) - , buffer = new Buffer((writeStartMarker ? ((options && options.binary) ? (1 + lengthbytes) : 1) : 0) + length + ((writeEndMarker && !(options && options.binary)) ? 1 : 0)) - , offset = writeStartMarker ? 1 : 0; - - if (writeStartMarker) { - if (options && options.binary) { - buffer.write('\x80', 'binary'); - // assume length less than 2**14 bytes - if (lengthbytes > 1) - buffer.write(String.fromCharCode(128+length/128), offset++, 'binary'); - buffer.write(String.fromCharCode(length&0x7f), offset++, 'binary'); - } else - buffer.write('\x00', 'binary'); - } - - if (isString) buffer.write(data, offset, 'utf8'); - else data.copy(buffer, offset, 0); - - if (writeEndMarker) { - if (options && options.binary) { - // sending binary, not writing end marker - } else - buffer.write('\xff', offset + length, 'binary'); - this.continuationFrame = false; - } - else this.continuationFrame = true; - - try { - this.socket.write(buffer, 'binary', cb); - } catch (e) { - this.error(e.toString()); - } -}; - -/** - * Sends a close instruction to the remote party. - * - * @api public - */ - -Sender.prototype.close = function(code, data, mask, cb) { - if (this.isClosed) return; - this.isClosed = true; - try { - if (this.continuationFrame) this.socket.write(new Buffer([0xff], 'binary')); - this.socket.write(new Buffer([0xff, 0x00]), 'binary', cb); - } catch (e) { - this.error(e.toString()); - } -}; - -/** - * Sends a ping message to the remote party. Not available for hixie. - * - * @api public - */ - -Sender.prototype.ping = function(data, options) {}; - -/** - * Sends a pong message to the remote party. Not available for hixie. - * - * @api public - */ - -Sender.prototype.pong = function(data, options) {}; - -/** - * Handles an error - * - * @api private - */ - -Sender.prototype.error = function (reason) { - this.emit('error', reason); - return this; -}; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 244 */ -/***/ function(module, exports) { - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -exports.Validation = { - isValidUTF8: function(buffer) { - return true; - } -}; - - -/***/ }, -/* 245 */ -/***/ function(module, exports, __webpack_require__) { - -"use strict"; -'use strict'; - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -try { - module.exports = __webpack_require__(231); -} catch (e) { - module.exports = __webpack_require__(244); -} - - -/***/ }, -/* 246 */ -/***/ function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -var util = __webpack_require__(10) - , events = __webpack_require__(5) - , http = __webpack_require__(55) - , crypto = __webpack_require__(122) - , Options = __webpack_require__(108) - , WebSocket = __webpack_require__(129) - , Extensions = __webpack_require__(126) - , PerMessageDeflate = __webpack_require__(44) - , tls = __webpack_require__(238) - , url = __webpack_require__(62); - -/** - * WebSocket Server implementation - */ - -function WebSocketServer(options, callback) { - if (this instanceof WebSocketServer === false) { - return new WebSocketServer(options, callback); - } - - events.EventEmitter.call(this); - - options = new Options({ - host: '0.0.0.0', - port: null, - server: null, - verifyClient: null, - handleProtocols: null, - path: null, - noServer: false, - disableHixie: false, - clientTracking: true, - perMessageDeflate: true, - maxPayload: 100 * 1024 * 1024 - }).merge(options); - - if (!options.isDefinedAndNonNull('port') && !options.isDefinedAndNonNull('server') && !options.value.noServer) { - throw new TypeError('`port` or a `server` must be provided'); - } - - var self = this; - - if (options.isDefinedAndNonNull('port')) { - this._server = http.createServer(function (req, res) { - var body = http.STATUS_CODES[426]; - res.writeHead(426, { - 'Content-Length': body.length, - 'Content-Type': 'text/plain' - }); - res.end(body); - }); - this._server.allowHalfOpen = false; - this._server.listen(options.value.port, options.value.host, callback); - this._closeServer = function() { if (self._server) self._server.close(); }; - } - else if (options.value.server) { - this._server = options.value.server; - if (options.value.path) { - // take note of the path, to avoid collisions when multiple websocket servers are - // listening on the same http server - if (this._server._webSocketPaths && options.value.server._webSocketPaths[options.value.path]) { - throw new Error('two instances of WebSocketServer cannot listen on the same http server path'); - } - if (typeof this._server._webSocketPaths !== 'object') { - this._server._webSocketPaths = {}; - } - this._server._webSocketPaths[options.value.path] = 1; - } - } - if (this._server) { - this._onceServerListening = function() { self.emit('listening'); }; - this._server.once('listening', this._onceServerListening); - } - - if (typeof this._server != 'undefined') { - this._onServerError = function(error) { self.emit('error', error) }; - this._server.on('error', this._onServerError); - this._onServerUpgrade = function(req, socket, upgradeHead) { - //copy upgradeHead to avoid retention of large slab buffers used in node core - var head = new Buffer(upgradeHead.length); - upgradeHead.copy(head); - - self.handleUpgrade(req, socket, head, function(client) { - self.emit('connection'+req.url, client); - self.emit('connection', client); - }); - }; - this._server.on('upgrade', this._onServerUpgrade); - } - - this.options = options.value; - this.path = options.value.path; - this.clients = []; -} - -/** - * Inherits from EventEmitter. - */ - -util.inherits(WebSocketServer, events.EventEmitter); - -/** - * Immediately shuts down the connection. - * - * @api public - */ - -WebSocketServer.prototype.close = function(callback) { - // terminate all associated clients - var error = null; - try { - for (var i = 0, l = this.clients.length; i < l; ++i) { - this.clients[i].terminate(); - } - } - catch (e) { - error = e; - } - - // remove path descriptor, if any - if (this.path && this._server._webSocketPaths) { - delete this._server._webSocketPaths[this.path]; - if (Object.keys(this._server._webSocketPaths).length == 0) { - delete this._server._webSocketPaths; - } - } - - // close the http server if it was internally created - try { - if (typeof this._closeServer !== 'undefined') { - this._closeServer(); - } - } - finally { - if (this._server) { - this._server.removeListener('listening', this._onceServerListening); - this._server.removeListener('error', this._onServerError); - this._server.removeListener('upgrade', this._onServerUpgrade); - } - delete this._server; - } - if(callback) - callback(error); - else if(error) - throw error; -} - -/** - * Handle a HTTP Upgrade request. - * - * @api public - */ - -WebSocketServer.prototype.handleUpgrade = function(req, socket, upgradeHead, cb) { - // check for wrong path - if (this.options.path) { - var u = url.parse(req.url); - if (u && u.pathname !== this.options.path) return; - } - - if (typeof req.headers.upgrade === 'undefined' || req.headers.upgrade.toLowerCase() !== 'websocket') { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - if (req.headers['sec-websocket-key1']) handleHixieUpgrade.apply(this, arguments); - else handleHybiUpgrade.apply(this, arguments); -} - -module.exports = WebSocketServer; - -/** - * Entirely private apis, - * which may or may not be bound to a sepcific WebSocket instance. - */ - -function handleHybiUpgrade(req, socket, upgradeHead, cb) { - // handle premature socket errors - var errorHandler = function() { - try { socket.destroy(); } catch (e) {} - } - socket.on('error', errorHandler); - - // verify key presence - if (!req.headers['sec-websocket-key']) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - // verify version - var version = parseInt(req.headers['sec-websocket-version']); - if ([8, 13].indexOf(version) === -1) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - // verify protocol - var protocols = req.headers['sec-websocket-protocol']; - - // verify client - var origin = version < 13 ? - req.headers['sec-websocket-origin'] : - req.headers['origin']; - - // handle extensions offer - var extensionsOffer = Extensions.parse(req.headers['sec-websocket-extensions']); - - // handler to call when the connection sequence completes - var self = this; - var completeHybiUpgrade2 = function(protocol) { - - // calc key - var key = req.headers['sec-websocket-key']; - var shasum = crypto.createHash('sha1'); - shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); - key = shasum.digest('base64'); - - var headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: websocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Accept: ' + key - ]; - - if (typeof protocol != 'undefined') { - headers.push('Sec-WebSocket-Protocol: ' + protocol); - } - - var extensions = {}; - try { - extensions = acceptExtensions.call(self, extensionsOffer); - } catch (err) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - if (Object.keys(extensions).length) { - var serverExtensions = {}; - Object.keys(extensions).forEach(function(token) { - serverExtensions[token] = [extensions[token].params] - }); - headers.push('Sec-WebSocket-Extensions: ' + Extensions.format(serverExtensions)); - } - - // allows external modification/inspection of handshake headers - self.emit('headers', headers); - - socket.setTimeout(0); - socket.setNoDelay(true); - try { - socket.write(headers.concat('', '').join('\r\n')); - } - catch (e) { - // if the upgrade write fails, shut the connection down hard - try { socket.destroy(); } catch (e) {} - return; - } - - var client = new WebSocket([req, socket, upgradeHead], { - protocolVersion: version, - protocol: protocol, - extensions: extensions, - maxPayload: self.options.maxPayload - }); - - if (self.options.clientTracking) { - self.clients.push(client); - client.on('close', function() { - var index = self.clients.indexOf(client); - if (index != -1) { - self.clients.splice(index, 1); - } - }); - } - - // signal upgrade complete - socket.removeListener('error', errorHandler); - cb(client); - } - - // optionally call external protocol selection handler before - // calling completeHybiUpgrade2 - var completeHybiUpgrade1 = function() { - // choose from the sub-protocols - if (typeof self.options.handleProtocols == 'function') { - var protList = (protocols || "").split(/, */); - var callbackCalled = false; - var res = self.options.handleProtocols(protList, function(result, protocol) { - callbackCalled = true; - if (!result) abortConnection(socket, 401, 'Unauthorized'); - else completeHybiUpgrade2(protocol); - }); - if (!callbackCalled) { - // the handleProtocols handler never called our callback - abortConnection(socket, 501, 'Could not process protocols'); - } - return; - } else { - if (typeof protocols !== 'undefined') { - completeHybiUpgrade2(protocols.split(/, */)[0]); - } - else { - completeHybiUpgrade2(); - } - } - } - - // optionally call external client verification handler - if (typeof this.options.verifyClient == 'function') { - var info = { - origin: origin, - secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', - req: req - }; - if (this.options.verifyClient.length == 2) { - this.options.verifyClient(info, function(result, code, name) { - if (typeof code === 'undefined') code = 401; - if (typeof name === 'undefined') name = http.STATUS_CODES[code]; - - if (!result) abortConnection(socket, code, name); - else completeHybiUpgrade1(); - }); - return; - } - else if (!this.options.verifyClient(info)) { - abortConnection(socket, 401, 'Unauthorized'); - return; - } - } - - completeHybiUpgrade1(); -} - -function handleHixieUpgrade(req, socket, upgradeHead, cb) { - // handle premature socket errors - var errorHandler = function() { - try { socket.destroy(); } catch (e) {} - } - socket.on('error', errorHandler); - - // bail if options prevent hixie - if (this.options.disableHixie) { - abortConnection(socket, 401, 'Hixie support disabled'); - return; - } - - // verify key presence - if (!req.headers['sec-websocket-key2']) { - abortConnection(socket, 400, 'Bad Request'); - return; - } - - var origin = req.headers['origin'] - , self = this; - - // setup handshake completion to run after client has been verified - var onClientVerified = function() { - var wshost; - if (!req.headers['x-forwarded-host']) - wshost = req.headers.host; - else - wshost = req.headers['x-forwarded-host']; - var location = ((req.headers['x-forwarded-proto'] === 'https' || socket.encrypted) ? 'wss' : 'ws') + '://' + wshost + req.url - , protocol = req.headers['sec-websocket-protocol']; - - // build the response header and return a Buffer - var buildResponseHeader = function() { - var headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: WebSocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Location: ' + location - ]; - if (typeof protocol != 'undefined') headers.push('Sec-WebSocket-Protocol: ' + protocol); - if (typeof origin != 'undefined') headers.push('Sec-WebSocket-Origin: ' + origin); - - return new Buffer(headers.concat('', '').join('\r\n')); - }; - - // send handshake response before receiving the nonce - var handshakeResponse = function() { - - socket.setTimeout(0); - socket.setNoDelay(true); - - var headerBuffer = buildResponseHeader(); - - try { - socket.write(headerBuffer, 'binary', function(err) { - // remove listener if there was an error - if (err) socket.removeListener('data', handler); - return; - }); - } catch (e) { - try { socket.destroy(); } catch (e) {} - return; - }; - }; - - // handshake completion code to run once nonce has been successfully retrieved - var completeHandshake = function(nonce, rest, headerBuffer) { - // calculate key - var k1 = req.headers['sec-websocket-key1'] - , k2 = req.headers['sec-websocket-key2'] - , md5 = crypto.createHash('md5'); - - [k1, k2].forEach(function (k) { - var n = parseInt(k.replace(/[^\d]/g, '')) - , spaces = k.replace(/[^ ]/g, '').length; - if (spaces === 0 || n % spaces !== 0){ - abortConnection(socket, 400, 'Bad Request'); - return; - } - n /= spaces; - md5.update(String.fromCharCode( - n >> 24 & 0xFF, - n >> 16 & 0xFF, - n >> 8 & 0xFF, - n & 0xFF)); - }); - md5.update(nonce.toString('binary')); - - socket.setTimeout(0); - socket.setNoDelay(true); - - try { - var hashBuffer = new Buffer(md5.digest('binary'), 'binary'); - var handshakeBuffer = new Buffer(headerBuffer.length + hashBuffer.length); - headerBuffer.copy(handshakeBuffer, 0); - hashBuffer.copy(handshakeBuffer, headerBuffer.length); - - // do a single write, which - upon success - causes a new client websocket to be setup - socket.write(handshakeBuffer, 'binary', function(err) { - if (err) return; // do not create client if an error happens - var client = new WebSocket([req, socket, rest], { - protocolVersion: 'hixie-76', - protocol: protocol - }); - if (self.options.clientTracking) { - self.clients.push(client); - client.on('close', function() { - var index = self.clients.indexOf(client); - if (index != -1) { - self.clients.splice(index, 1); - } - }); - } - - // signal upgrade complete - socket.removeListener('error', errorHandler); - cb(client); - }); - } - catch (e) { - try { socket.destroy(); } catch (e) {} - return; - } - } - - // retrieve nonce - var nonceLength = 8; - if (upgradeHead && upgradeHead.length >= nonceLength) { - var nonce = upgradeHead.slice(0, nonceLength); - var rest = upgradeHead.length > nonceLength ? upgradeHead.slice(nonceLength) : null; - completeHandshake.call(self, nonce, rest, buildResponseHeader()); - } - else { - // nonce not present in upgradeHead - var nonce = new Buffer(nonceLength); - upgradeHead.copy(nonce, 0); - var received = upgradeHead.length; - var rest = null; - var handler = function (data) { - var toRead = Math.min(data.length, nonceLength - received); - if (toRead === 0) return; - data.copy(nonce, received, 0, toRead); - received += toRead; - if (received == nonceLength) { - socket.removeListener('data', handler); - if (toRead < data.length) rest = data.slice(toRead); - - // complete the handshake but send empty buffer for headers since they have already been sent - completeHandshake.call(self, nonce, rest, new Buffer(0)); - } - } - - // handle additional data as we receive it - socket.on('data', handler); - - // send header response before we have the nonce to fix haproxy buffering - handshakeResponse(); - } - } - - // verify client - if (typeof this.options.verifyClient == 'function') { - var info = { - origin: origin, - secure: typeof req.connection.authorized !== 'undefined' || typeof req.connection.encrypted !== 'undefined', - req: req - }; - if (this.options.verifyClient.length == 2) { - var self = this; - this.options.verifyClient(info, function(result, code, name) { - if (typeof code === 'undefined') code = 401; - if (typeof name === 'undefined') name = http.STATUS_CODES[code]; - - if (!result) abortConnection(socket, code, name); - else onClientVerified.apply(self); - }); - return; - } - else if (!this.options.verifyClient(info)) { - abortConnection(socket, 401, 'Unauthorized'); - return; - } - } - - // no client verification required - onClientVerified(); -} - -function acceptExtensions(offer) { - var extensions = {}; - var options = this.options.perMessageDeflate; - var maxPayload = this.options.maxPayload; - if (options && offer[PerMessageDeflate.extensionName]) { - var perMessageDeflate = new PerMessageDeflate(options !== true ? options : {}, true, maxPayload); - perMessageDeflate.accept(offer[PerMessageDeflate.extensionName]); - extensions[PerMessageDeflate.extensionName] = perMessageDeflate; - } - return extensions; -} - -function abortConnection(socket, code, name) { - try { - var response = [ - 'HTTP/1.1 ' + code + ' ' + name, - 'Content-type: text/html' - ]; - socket.write(response.concat('', '').join('\r\n')); - } - catch (e) { /* ignore errors - we've aborted this connection */ } - finally { - // ensure that an early aborted connection is shut down completely - try { socket.destroy(); } catch (e) {} - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) - -/***/ }, -/* 247 */ +/* 104 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process, Buffer) {/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';function q(b){throw b;}var t=void 0,v=!0;var A="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function E(b,a){this.index="number"===typeof a?a:0;this.m=0;this.buffer=b instanceof(A?Uint8Array:Array)?b:new (A?Uint8Array:Array)(32768);2*this.buffer.length<=this.index&&q(Error("invalid index"));this.buffer.length<=this.index&&this.f()}E.prototype.f=function(){var b=this.buffer,a,c=b.length,d=new (A?Uint8Array:Array)(c<<1);if(A)d.set(b);else for(a=0;a { /***/ }, -/* 289 */ +/* 146 */ /***/ function(module, exports, __webpack_require__) { -const OpusEngine = __webpack_require__(133); +const OpusEngine = __webpack_require__(72); let OpusScript; @@ -51140,7 +28479,7 @@ class NodeOpusEngine extends OpusEngine { constructor(player) { super(player); try { - OpusScript = __webpack_require__(336); + OpusScript = __webpack_require__(193); } catch (err) { throw err; } @@ -51162,10 +28501,10 @@ module.exports = NodeOpusEngine; /***/ }, -/* 290 */ +/* 147 */ /***/ function(module, exports, __webpack_require__) { -const EventEmitter = __webpack_require__(5).EventEmitter; +const EventEmitter = __webpack_require__(4).EventEmitter; class ConverterEngine extends EventEmitter { constructor(player) { @@ -51182,19 +28521,19 @@ module.exports = ConverterEngine; /***/ }, -/* 291 */ +/* 148 */ /***/ function(module, exports, __webpack_require__) { -exports.fetch = () => __webpack_require__(292); +exports.fetch = () => __webpack_require__(149); /***/ }, -/* 292 */ +/* 149 */ /***/ function(module, exports, __webpack_require__) { -const ConverterEngine = __webpack_require__(290); +const ConverterEngine = __webpack_require__(147); const ChildProcess = __webpack_require__(13); -const EventEmitter = __webpack_require__(5).EventEmitter; +const EventEmitter = __webpack_require__(4).EventEmitter; class PCMConversionProcess extends EventEmitter { constructor(process) { @@ -51274,13 +28613,13 @@ module.exports = FfmpegConverterEngine; /***/ }, -/* 293 */ +/* 150 */ /***/ function(module, exports, __webpack_require__) { -const PCMConverters = __webpack_require__(291); -const OpusEncoders = __webpack_require__(288); -const EventEmitter = __webpack_require__(5).EventEmitter; -const StreamDispatcher = __webpack_require__(286); +const PCMConverters = __webpack_require__(148); +const OpusEncoders = __webpack_require__(145); +const EventEmitter = __webpack_require__(4).EventEmitter; +const StreamDispatcher = __webpack_require__(143); /** * Represents the Audio Player of a Voice Connection @@ -51360,10 +28699,10 @@ module.exports = AudioPlayer; /***/ }, -/* 294 */ +/* 151 */ /***/ function(module, exports, __webpack_require__) { -const Readable = __webpack_require__(11).Readable; +const Readable = __webpack_require__(25).Readable; class VoiceReadable extends Readable { constructor() { @@ -51385,12 +28724,12 @@ module.exports = VoiceReadable; /***/ }, -/* 295 */ +/* 152 */ /***/ function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const EventEmitter = __webpack_require__(5).EventEmitter; -const NaCl = __webpack_require__(120); -const Readable = __webpack_require__(294); +/* WEBPACK VAR INJECTION */(function(Buffer) {const EventEmitter = __webpack_require__(4).EventEmitter; +const NaCl = __webpack_require__(67); +const Readable = __webpack_require__(151); const nonce = new Buffer(24); nonce.fill(0); @@ -51543,10 +28882,10 @@ class VoiceReceiver extends EventEmitter { module.exports = VoiceReceiver; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0).Buffer)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }, -/* 296 */ +/* 153 */ /***/ function(module, exports) { /** @@ -51568,16 +28907,16 @@ module.exports = SecretKey; /***/ }, -/* 297 */ +/* 154 */ /***/ function(module, exports, __webpack_require__) { const browser = typeof window !== 'undefined'; -const WebSocket = browser ? window.WebSocket : __webpack_require__(123); // eslint-disable-line no-undef -const EventEmitter = __webpack_require__(5).EventEmitter; -const Constants = __webpack_require__(1); -const inflate = browser ? __webpack_require__(247).inflateSync : __webpack_require__(101).inflateSync; -const PacketManager = __webpack_require__(298); -const convertArrayBuffer = __webpack_require__(134); +const WebSocket = browser ? window.WebSocket : __webpack_require__(76); // eslint-disable-line no-undef +const EventEmitter = __webpack_require__(4).EventEmitter; +const Constants = __webpack_require__(0); +const inflate = browser ? __webpack_require__(104).inflateSync : __webpack_require__(83).inflateSync; +const PacketManager = __webpack_require__(155); +const convertArrayBuffer = __webpack_require__(73); /** * The WebSocket Manager of the Client @@ -51875,10 +29214,10 @@ module.exports = WebSocketManager; /***/ }, -/* 298 */ +/* 155 */ /***/ function(module, exports, __webpack_require__) { -const Constants = __webpack_require__(1); +const Constants = __webpack_require__(0); const BeforeReadyWhitelist = [ Constants.WSEvents.READY, @@ -51895,39 +29234,39 @@ class WebSocketPacketManager { this.handlers = {}; this.queue = []; - this.register(Constants.WSEvents.READY, __webpack_require__(324)); - this.register(Constants.WSEvents.GUILD_CREATE, __webpack_require__(305)); - this.register(Constants.WSEvents.GUILD_DELETE, __webpack_require__(306)); - this.register(Constants.WSEvents.GUILD_UPDATE, __webpack_require__(315)); - this.register(Constants.WSEvents.GUILD_BAN_ADD, __webpack_require__(303)); - this.register(Constants.WSEvents.GUILD_BAN_REMOVE, __webpack_require__(304)); - this.register(Constants.WSEvents.GUILD_MEMBER_ADD, __webpack_require__(307)); - this.register(Constants.WSEvents.GUILD_MEMBER_REMOVE, __webpack_require__(308)); - this.register(Constants.WSEvents.GUILD_MEMBER_UPDATE, __webpack_require__(309)); - this.register(Constants.WSEvents.GUILD_ROLE_CREATE, __webpack_require__(311)); - this.register(Constants.WSEvents.GUILD_ROLE_DELETE, __webpack_require__(312)); - this.register(Constants.WSEvents.GUILD_ROLE_UPDATE, __webpack_require__(313)); - this.register(Constants.WSEvents.GUILD_MEMBERS_CHUNK, __webpack_require__(310)); - this.register(Constants.WSEvents.CHANNEL_CREATE, __webpack_require__(299)); - this.register(Constants.WSEvents.CHANNEL_DELETE, __webpack_require__(300)); - this.register(Constants.WSEvents.CHANNEL_UPDATE, __webpack_require__(302)); - this.register(Constants.WSEvents.CHANNEL_PINS_UPDATE, __webpack_require__(301)); - this.register(Constants.WSEvents.PRESENCE_UPDATE, __webpack_require__(323)); - this.register(Constants.WSEvents.USER_UPDATE, __webpack_require__(329)); - this.register(Constants.WSEvents.USER_NOTE_UPDATE, __webpack_require__(328)); - this.register(Constants.WSEvents.VOICE_STATE_UPDATE, __webpack_require__(331)); - this.register(Constants.WSEvents.TYPING_START, __webpack_require__(327)); - this.register(Constants.WSEvents.MESSAGE_CREATE, __webpack_require__(316)); - this.register(Constants.WSEvents.MESSAGE_DELETE, __webpack_require__(317)); - this.register(Constants.WSEvents.MESSAGE_UPDATE, __webpack_require__(322)); - this.register(Constants.WSEvents.MESSAGE_DELETE_BULK, __webpack_require__(318)); - this.register(Constants.WSEvents.VOICE_SERVER_UPDATE, __webpack_require__(330)); - this.register(Constants.WSEvents.GUILD_SYNC, __webpack_require__(314)); - this.register(Constants.WSEvents.RELATIONSHIP_ADD, __webpack_require__(325)); - this.register(Constants.WSEvents.RELATIONSHIP_REMOVE, __webpack_require__(326)); - this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, __webpack_require__(319)); - this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, __webpack_require__(320)); - this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, __webpack_require__(321)); + this.register(Constants.WSEvents.READY, __webpack_require__(181)); + this.register(Constants.WSEvents.GUILD_CREATE, __webpack_require__(162)); + this.register(Constants.WSEvents.GUILD_DELETE, __webpack_require__(163)); + this.register(Constants.WSEvents.GUILD_UPDATE, __webpack_require__(172)); + this.register(Constants.WSEvents.GUILD_BAN_ADD, __webpack_require__(160)); + this.register(Constants.WSEvents.GUILD_BAN_REMOVE, __webpack_require__(161)); + this.register(Constants.WSEvents.GUILD_MEMBER_ADD, __webpack_require__(164)); + this.register(Constants.WSEvents.GUILD_MEMBER_REMOVE, __webpack_require__(165)); + this.register(Constants.WSEvents.GUILD_MEMBER_UPDATE, __webpack_require__(166)); + this.register(Constants.WSEvents.GUILD_ROLE_CREATE, __webpack_require__(168)); + this.register(Constants.WSEvents.GUILD_ROLE_DELETE, __webpack_require__(169)); + this.register(Constants.WSEvents.GUILD_ROLE_UPDATE, __webpack_require__(170)); + this.register(Constants.WSEvents.GUILD_MEMBERS_CHUNK, __webpack_require__(167)); + this.register(Constants.WSEvents.CHANNEL_CREATE, __webpack_require__(156)); + this.register(Constants.WSEvents.CHANNEL_DELETE, __webpack_require__(157)); + this.register(Constants.WSEvents.CHANNEL_UPDATE, __webpack_require__(159)); + this.register(Constants.WSEvents.CHANNEL_PINS_UPDATE, __webpack_require__(158)); + this.register(Constants.WSEvents.PRESENCE_UPDATE, __webpack_require__(180)); + this.register(Constants.WSEvents.USER_UPDATE, __webpack_require__(186)); + this.register(Constants.WSEvents.USER_NOTE_UPDATE, __webpack_require__(185)); + this.register(Constants.WSEvents.VOICE_STATE_UPDATE, __webpack_require__(188)); + this.register(Constants.WSEvents.TYPING_START, __webpack_require__(184)); + this.register(Constants.WSEvents.MESSAGE_CREATE, __webpack_require__(173)); + this.register(Constants.WSEvents.MESSAGE_DELETE, __webpack_require__(174)); + this.register(Constants.WSEvents.MESSAGE_UPDATE, __webpack_require__(179)); + this.register(Constants.WSEvents.MESSAGE_DELETE_BULK, __webpack_require__(175)); + this.register(Constants.WSEvents.VOICE_SERVER_UPDATE, __webpack_require__(187)); + this.register(Constants.WSEvents.GUILD_SYNC, __webpack_require__(171)); + this.register(Constants.WSEvents.RELATIONSHIP_ADD, __webpack_require__(182)); + this.register(Constants.WSEvents.RELATIONSHIP_REMOVE, __webpack_require__(183)); + this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, __webpack_require__(176)); + this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, __webpack_require__(177)); + this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, __webpack_require__(178)); } get client() { @@ -51989,10 +29328,10 @@ module.exports = WebSocketPacketManager; /***/ }, -/* 299 */ +/* 156 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class ChannelCreateHandler extends AbstractHandler { handle(packet) { @@ -52012,12 +29351,12 @@ module.exports = ChannelCreateHandler; /***/ }, -/* 300 */ +/* 157 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); -const Constants = __webpack_require__(1); +const Constants = __webpack_require__(0); class ChannelDeleteHandler extends AbstractHandler { handle(packet) { @@ -52038,11 +29377,11 @@ module.exports = ChannelDeleteHandler; /***/ }, -/* 301 */ +/* 158 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); /* { t: 'CHANNEL_PINS_UPDATE', @@ -52075,10 +29414,10 @@ module.exports = ChannelPinsUpdate; /***/ }, -/* 302 */ +/* 159 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class ChannelUpdateHandler extends AbstractHandler { handle(packet) { @@ -52092,13 +29431,13 @@ module.exports = ChannelUpdateHandler; /***/ }, -/* 303 */ +/* 160 */ /***/ function(module, exports, __webpack_require__) { // ##untested handler## -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); class GuildBanAddHandler extends AbstractHandler { handle(packet) { @@ -52121,12 +29460,12 @@ module.exports = GuildBanAddHandler; /***/ }, -/* 304 */ +/* 161 */ /***/ function(module, exports, __webpack_require__) { // ##untested handler## -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildBanRemoveHandler extends AbstractHandler { handle(packet) { @@ -52147,10 +29486,10 @@ module.exports = GuildBanRemoveHandler; /***/ }, -/* 305 */ +/* 162 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildCreateHandler extends AbstractHandler { handle(packet) { @@ -52175,11 +29514,11 @@ module.exports = GuildCreateHandler; /***/ }, -/* 306 */ +/* 163 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); class GuildDeleteHandler extends AbstractHandler { handle(packet) { @@ -52200,12 +29539,12 @@ module.exports = GuildDeleteHandler; /***/ }, -/* 307 */ +/* 164 */ /***/ function(module, exports, __webpack_require__) { // ##untested handler## -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildMemberAddHandler extends AbstractHandler { handle(packet) { @@ -52223,12 +29562,12 @@ module.exports = GuildMemberAddHandler; /***/ }, -/* 308 */ +/* 165 */ /***/ function(module, exports, __webpack_require__) { // ##untested handler## -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildMemberRemoveHandler extends AbstractHandler { handle(packet) { @@ -52242,12 +29581,12 @@ module.exports = GuildMemberRemoveHandler; /***/ }, -/* 309 */ +/* 166 */ /***/ function(module, exports, __webpack_require__) { // ##untested handler## -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildMemberUpdateHandler extends AbstractHandler { handle(packet) { @@ -52266,13 +29605,13 @@ module.exports = GuildMemberUpdateHandler; /***/ }, -/* 310 */ +/* 167 */ /***/ function(module, exports, __webpack_require__) { // ##untested## -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); class GuildMembersChunkHandler extends AbstractHandler { handle(packet) { @@ -52300,10 +29639,10 @@ module.exports = GuildMembersChunkHandler; /***/ }, -/* 311 */ +/* 168 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildRoleCreateHandler extends AbstractHandler { handle(packet) { @@ -52317,10 +29656,10 @@ module.exports = GuildRoleCreateHandler; /***/ }, -/* 312 */ +/* 169 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildRoleDeleteHandler extends AbstractHandler { handle(packet) { @@ -52334,10 +29673,10 @@ module.exports = GuildRoleDeleteHandler; /***/ }, -/* 313 */ +/* 170 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildRoleUpdateHandler extends AbstractHandler { handle(packet) { @@ -52351,10 +29690,10 @@ module.exports = GuildRoleUpdateHandler; /***/ }, -/* 314 */ +/* 171 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildSyncHandler extends AbstractHandler { handle(packet) { @@ -52368,10 +29707,10 @@ module.exports = GuildSyncHandler; /***/ }, -/* 315 */ +/* 172 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class GuildUpdateHandler extends AbstractHandler { handle(packet) { @@ -52385,11 +29724,11 @@ module.exports = GuildUpdateHandler; /***/ }, -/* 316 */ +/* 173 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); class MessageCreateHandler extends AbstractHandler { handle(packet) { @@ -52410,11 +29749,11 @@ module.exports = MessageCreateHandler; /***/ }, -/* 317 */ +/* 174 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); class MessageDeleteHandler extends AbstractHandler { handle(packet) { @@ -52435,10 +29774,10 @@ module.exports = MessageDeleteHandler; /***/ }, -/* 318 */ +/* 175 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class MessageDeleteBulkHandler extends AbstractHandler { handle(packet) { @@ -52458,10 +29797,10 @@ module.exports = MessageDeleteBulkHandler; /***/ }, -/* 319 */ +/* 176 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class MessageReactionAddHandler extends AbstractHandler { handle(packet) { @@ -52475,10 +29814,10 @@ module.exports = MessageReactionAddHandler; /***/ }, -/* 320 */ +/* 177 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class MessageReactionRemove extends AbstractHandler { handle(packet) { @@ -52492,10 +29831,10 @@ module.exports = MessageReactionRemove; /***/ }, -/* 321 */ +/* 178 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class MessageReactionRemoveAll extends AbstractHandler { handle(packet) { @@ -52509,10 +29848,10 @@ module.exports = MessageReactionRemoveAll; /***/ }, -/* 322 */ +/* 179 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class MessageUpdateHandler extends AbstractHandler { handle(packet) { @@ -52526,12 +29865,12 @@ module.exports = MessageUpdateHandler; /***/ }, -/* 323 */ +/* 180 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); -const cloneObject = __webpack_require__(12); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); +const cloneObject = __webpack_require__(7); class PresenceUpdateHandler extends AbstractHandler { handle(packet) { @@ -52604,12 +29943,12 @@ module.exports = PresenceUpdateHandler; /***/ }, -/* 324 */ +/* 181 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); -const ClientUser = __webpack_require__(68); +const ClientUser = __webpack_require__(42); class ReadyHandler extends AbstractHandler { handle(packet) { @@ -52677,10 +30016,10 @@ module.exports = ReadyHandler; /***/ }, -/* 325 */ +/* 182 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class RelationshipAddHandler extends AbstractHandler { handle(packet) { @@ -52702,10 +30041,10 @@ module.exports = RelationshipAddHandler; /***/ }, -/* 326 */ +/* 183 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class RelationshipRemoveHandler extends AbstractHandler { handle(packet) { @@ -52727,11 +30066,11 @@ module.exports = RelationshipRemoveHandler; /***/ }, -/* 327 */ +/* 184 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); -const Constants = __webpack_require__(1); +const AbstractHandler = __webpack_require__(1); +const Constants = __webpack_require__(0); class TypingStartHandler extends AbstractHandler { handle(packet) { @@ -52801,10 +30140,10 @@ module.exports = TypingStartHandler; /***/ }, -/* 328 */ +/* 185 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class UserNoteUpdateHandler extends AbstractHandler { handle(packet) { @@ -52819,10 +30158,10 @@ module.exports = UserNoteUpdateHandler; /***/ }, -/* 329 */ +/* 186 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); class UserUpdateHandler extends AbstractHandler { handle(packet) { @@ -52836,10 +30175,10 @@ module.exports = UserUpdateHandler; /***/ }, -/* 330 */ +/* 187 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); /* { @@ -52861,13 +30200,13 @@ module.exports = VoiceServerUpdate; /***/ }, -/* 331 */ +/* 188 */ /***/ function(module, exports, __webpack_require__) { -const AbstractHandler = __webpack_require__(3); +const AbstractHandler = __webpack_require__(1); -const Constants = __webpack_require__(1); -const cloneObject = __webpack_require__(12); +const Constants = __webpack_require__(0); +const cloneObject = __webpack_require__(7); class VoiceStateUpdateHandler extends AbstractHandler { handle(packet) { @@ -52916,7 +30255,7 @@ module.exports = VoiceStateUpdateHandler; /***/ }, -/* 332 */ +/* 189 */ /***/ function(module, exports) { /** @@ -52970,11 +30309,11 @@ module.exports = UserConnection; /***/ }, -/* 333 */ +/* 190 */ /***/ function(module, exports, __webpack_require__) { -const Collection = __webpack_require__(6); -const UserConnection = __webpack_require__(332); +const Collection = __webpack_require__(3); +const UserConnection = __webpack_require__(189); /** * Represents a user's profile on Discord. @@ -53025,7 +30364,7 @@ module.exports = UserProfile; /***/ }, -/* 334 */ +/* 191 */ /***/ function(module, exports) { module.exports = function parseEmoji(text) { @@ -53045,83 +30384,77 @@ module.exports = function parseEmoji(text) { /***/ }, -/* 335 */ +/* 192 */ /***/ function(module, exports) { if(typeof undefined === 'undefined') {var e = new Error("Cannot find module \"undefined\""); e.code = 'MODULE_NOT_FOUND'; throw e;} module.exports = undefined; /***/ }, -/* 336 */ +/* 193 */ /***/ function(module, exports) { if(typeof undefined === 'undefined') {var e = new Error("Cannot find module \"undefined\""); e.code = 'MODULE_NOT_FOUND'; throw e;} module.exports = undefined; /***/ }, -/* 337 */ +/* 194 */ /***/ function(module, exports) { /* (ignored) */ /***/ }, -/* 338 */ +/* 195 */ /***/ function(module, exports) { /* (ignored) */ /***/ }, -/* 339 */ -/***/ function(module, exports) { - -/* (ignored) */ - -/***/ }, -/* 340 */ +/* 196 */ /***/ function(module, exports, __webpack_require__) { module.exports = { - Client: __webpack_require__(137), - WebhookClient: __webpack_require__(138), - Shard: __webpack_require__(65), - ShardClientUtil: __webpack_require__(66), - ShardingManager: __webpack_require__(139), + Client: __webpack_require__(77), + WebhookClient: __webpack_require__(78), + Shard: __webpack_require__(39), + ShardClientUtil: __webpack_require__(40), + ShardingManager: __webpack_require__(79), - Collection: __webpack_require__(6), - splitMessage: __webpack_require__(83), - escapeMarkdown: __webpack_require__(35), - fetchRecommendedShards: __webpack_require__(82), + Collection: __webpack_require__(3), + splitMessage: __webpack_require__(57), + escapeMarkdown: __webpack_require__(23), + fetchRecommendedShards: __webpack_require__(56), - Channel: __webpack_require__(24), - ClientOAuth2Application: __webpack_require__(67), - ClientUser: __webpack_require__(68), - DMChannel: __webpack_require__(69), - Emoji: __webpack_require__(25), - EvaluatedPermissions: __webpack_require__(46), - Game: __webpack_require__(15).Game, - GroupDMChannel: __webpack_require__(70), - Guild: __webpack_require__(47), - GuildChannel: __webpack_require__(32), - GuildMember: __webpack_require__(33), - Invite: __webpack_require__(71), - Message: __webpack_require__(34), - MessageAttachment: __webpack_require__(72), - MessageCollector: __webpack_require__(73), - MessageEmbed: __webpack_require__(74), - MessageReaction: __webpack_require__(75), - OAuth2Application: __webpack_require__(76), - PartialGuild: __webpack_require__(77), - PartialGuildChannel: __webpack_require__(78), - PermissionOverwrites: __webpack_require__(79), - Presence: __webpack_require__(15).Presence, - ReactionEmoji: __webpack_require__(48), - Role: __webpack_require__(19), - TextChannel: __webpack_require__(80), - User: __webpack_require__(14), - VoiceChannel: __webpack_require__(81), - Webhook: __webpack_require__(49), + Channel: __webpack_require__(14), + ClientOAuth2Application: __webpack_require__(41), + ClientUser: __webpack_require__(42), + DMChannel: __webpack_require__(43), + Emoji: __webpack_require__(15), + EvaluatedPermissions: __webpack_require__(27), + Game: __webpack_require__(9).Game, + GroupDMChannel: __webpack_require__(44), + Guild: __webpack_require__(28), + GuildChannel: __webpack_require__(20), + GuildMember: __webpack_require__(21), + Invite: __webpack_require__(45), + Message: __webpack_require__(22), + MessageAttachment: __webpack_require__(46), + MessageCollector: __webpack_require__(47), + MessageEmbed: __webpack_require__(48), + MessageReaction: __webpack_require__(49), + OAuth2Application: __webpack_require__(50), + PartialGuild: __webpack_require__(51), + PartialGuildChannel: __webpack_require__(52), + PermissionOverwrites: __webpack_require__(53), + Presence: __webpack_require__(9).Presence, + ReactionEmoji: __webpack_require__(29), + Role: __webpack_require__(11), + TextChannel: __webpack_require__(54), + User: __webpack_require__(8), + VoiceChannel: __webpack_require__(55), + Webhook: __webpack_require__(30), - version: __webpack_require__(64).version, + version: __webpack_require__(38).version, }; if (typeof window !== 'undefined') window.Discord = module.exports; // eslint-disable-line no-undef diff --git a/discord.indev.min.js b/discord.indev.min.js index 8eded83b..2423d802 100644 --- a/discord.indev.min.js +++ b/discord.indev.min.js @@ -1,117 +1,23 @@ -!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=340)}([function(e,t,n){"use strict";(function(e,i){function r(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}function s(){return e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,n){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function m(t){return+t!=t&&(t=0),e.alloc(+t)}function g(t,n){if(e.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var r=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Z(t).length;default:if(r)return W(t).length;n=(""+n).toLowerCase(),r=!0}}function v(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,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return C(this,t,n);case"latin1":case"binary":return D(this,t,n);case"base64":return R(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function y(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function _(t,n,i,r,s){if(0===t.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(s)return-1;i=t.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof n&&(n=e.from(n,r)),e.isBuffer(n))return 0===n.length?-1:w(t,n,i,r,s);if("number"==typeof n)return n&=255,e.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,n,i):Uint8Array.prototype.lastIndexOf.call(t,n,i):w(t,[n],i,r,s);throw new TypeError("val must be string, number or Buffer")}function w(e,t,n,i,r){function s(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,c=t.length;if(void 0!==i&&(i=String(i).toLowerCase(),"ucs2"===i||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,n/=2}var h;if(r){var f=-1;for(h=n;ha&&(n=a-c),h=n;h>=0;h--){for(var u=!0,d=0;dr&&(i=r)):i=r;var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o239?4:s>223?3:s>191?2:1;if(r+a<=n){var c,h,f,u;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[r+1],128===(192&c)&&(u=(31&s)<<6|63&c,u>127&&(o=u));break;case 3:c=e[r+1],h=e[r+2],128===(192&c)&&128===(192&h)&&(u=(15&s)<<12|(63&c)<<6|63&h,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:c=e[r+1],h=e[r+2],f=e[r+3],128===(192&c)&&128===(192&h)&&128===(192&f)&&(u=(15&s)<<18|(63&c)<<12|(63&h)<<6|63&f,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),r+=a}return T(i)}function T(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var n="",i=0;ii)&&(n=i);for(var r="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function O(t,n,i,r,s,o){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>s||nt.length)throw new RangeError("Index out of range")}function U(e,t,n,i){t<0&&(t=65535+t+1);for(var r=0,s=Math.min(e.length-n,2);r>>8*(i?r:1-r)}function N(e,t,n,i){t<0&&(t=4294967295+t+1);for(var r=0,s=Math.min(e.length-n,4);r>>8*(i?r:3-r)&255}function j(e,t,n,i,r,s){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function q(e,t,n,i,r){return r||j(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(e,t,n,i,23,4),n+4}function z(e,t,n,i,r){return r||j(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(e,t,n,i,52,8),n+8}function F(e){if(e=G(e).replace(te,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function G(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function W(e,t){t=t||1/0;for(var n,i=e.length,r=null,s=[],o=0;o55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),r=n;continue}n=(r-55296<<10|n-56320)+65536}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function V(e){for(var t=[],n=0;n>8,r=n%256,s.push(r),s.push(i);return s}function Z(e){return J.toByteArray(F(e))}function Y(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function X(e){return e!==e}var J=n(150),$=n(200),Q=n(106);t.Buffer=e,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,e.TYPED_ARRAY_SUPPORT=void 0!==i.TYPED_ARRAY_SUPPORT?i.TYPED_ARRAY_SUPPORT:r(),t.kMaxLength=s(),e.poolSize=8192,e._augment=function(t){return t.__proto__=e.prototype,t},e.from=function(e,t,n){return a(null,e,t,n)},e.TYPED_ARRAY_SUPPORT&&(e.prototype.__proto__=Uint8Array.prototype,e.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&e[Symbol.species]===e&&Object.defineProperty(e,Symbol.species,{value:null,configurable:!0})),e.alloc=function(e,t,n){return h(null,e,t,n)},e.allocUnsafe=function(e){return f(null,e)},e.allocUnsafeSlow=function(e){return f(null,e)},e.isBuffer=function(e){return!(null==e||!e._isBuffer)},e.compare=function(t,n){if(!e.isBuffer(t)||!e.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var i=t.length,r=n.length,s=0,o=Math.min(i,r);s0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},e.prototype.compare=function(t,n,i,r,s){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===i&&(i=t?t.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),n<0||i>t.length||r<0||s>this.length)throw new RangeError("out of range index");if(r>=s&&n>=i)return 0;if(r>=s)return-1;if(n>=i)return 1;if(n>>>=0,i>>>=0,r>>>=0,s>>>=0,this===t)return 0;for(var o=s-r,a=i-n,c=Math.min(o,a),h=this.slice(r,s),f=t.slice(n,i),u=0;ur)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return k(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return M(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;e.prototype.slice=function(t,n){var i=this.length;t=~~t,n=void 0===n?i:~~n,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),n<0?(n+=i,n<0&&(n=0)):n>i&&(n=i),n0&&(r*=256);)i+=this[e+--t]*r;return i},e.prototype.readUInt8=function(e,t){return t||L(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return t||L(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return t||L(e,2,this.length),this[e]<<8|this[e+1]},e.prototype.readUInt32LE=function(e,t){return t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},e.prototype.readUInt32BE=function(e,t){return t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},e.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var i=this[e],r=1,s=0;++s=r&&(i-=Math.pow(2,8*t)),i},e.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var i=t,r=1,s=this[e+--i];i>0&&(r*=256);)s+=this[e+--i]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},e.prototype.readInt8=function(e,t){return t||L(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},e.prototype.readInt16LE=function(e,t){t||L(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},e.prototype.readInt16BE=function(e,t){t||L(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},e.prototype.readInt32LE=function(e,t){return t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},e.prototype.readInt32BE=function(e,t){return t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},e.prototype.readFloatLE=function(e,t){return t||L(e,4,this.length),$.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return t||L(e,4,this.length),$.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return t||L(e,8,this.length),$.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return t||L(e,8,this.length),$.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t|=0,n|=0,!i){var r=Math.pow(2,8*n)-1;O(this,e,t,n,r,0)}var s=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+s]=e/o&255;return t+n},e.prototype.writeUInt8=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,1,255,0),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=255&t,n+1},e.prototype.writeUInt16LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):U(this,t,n,!0),n+2},e.prototype.writeUInt16BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):U(this,t,n,!1),n+2},e.prototype.writeUInt32LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,4294967295,0),e.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):N(this,t,n,!0),n+4},e.prototype.writeUInt32BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,4294967295,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):N(this,t,n,!1),n+4},e.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);O(this,e,t,n,r-1,-r)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);O(this,e,t,n,r-1,-r)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},e.prototype.writeInt8=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,1,127,-128),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=255&t,n+1},e.prototype.writeInt16LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):U(this,t,n,!0),n+2},e.prototype.writeInt16BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):U(this,t,n,!1),n+2},e.prototype.writeInt32LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,2147483647,-2147483648),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):N(this,t,n,!0),n+4},e.prototype.writeInt32BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):N(this,t,n,!1),n+4},e.prototype.writeFloatLE=function(e,t,n){return q(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return q(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return z(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return z(this,e,t,!1,n)},e.prototype.copy=function(t,n,i,r){if(i||(i=0),r||0===r||(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n=0;--s)t[s+n]=this[s+i];else if(o<1e3||!e.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,i=void 0===i?this.length:i>>>0,t||(t=0);var o;if("number"==typeof t)for(o=n;o`${r}/invite/${e}`,inviteLink:e=>`https://discord.gg/${e}`,CDN:"https://cdn.discordapp.com",user:e=>`${r}/users/${e}`,userChannels:e=>`${s.user(e)}/channels`,userProfile:e=>`${s.user(e)}/profile`,avatar:(e,t)=>"1"===e?t:`${s.user(e)}/avatars/${t}.jpg`,me:`${r}/users/@me`,meGuild:e=>`${s.me}/guilds/${e}`,relationships:e=>`${s.user(e)}/relationships`,note:e=>`${s.me}/notes/${e}`,guilds:`${r}/guilds`,guild:e=>`${s.guilds}/${e}`,guildIcon:(e,t)=>`${s.guild(e)}/icons/${t}.jpg`,guildPrune:e=>`${s.guild(e)}/prune`,guildEmbed:e=>`${s.guild(e)}/embed`,guildInvites:e=>`${s.guild(e)}/invites`,guildRoles:e=>`${s.guild(e)}/roles`,guildRole:(e,t)=>`${s.guildRoles(e)}/${t}`,guildBans:e=>`${s.guild(e)}/bans`,guildIntegrations:e=>`${s.guild(e)}/integrations`,guildMembers:e=>`${s.guild(e)}/members`,guildMember:(e,t)=>`${s.guildMembers(e)}/${t}`,stupidInconsistentGuildEndpoint:e=>`${s.guildMember(e,"@me")}/nick`,guildChannels:e=>`${s.guild(e)}/channels`,guildEmojis:e=>`${s.guild(e)}/emojis`,channels:`${r}/channels`,channel:e=>`${s.channels}/${e}`,channelMessages:e=>`${s.channel(e)}/messages`,channelInvites:e=>`${s.channel(e)}/invites`,channelTyping:e=>`${s.channel(e)}/typing`,channelPermissions:e=>`${s.channel(e)}/permissions`,channelMessage:(e,t)=>`${s.channelMessages(e)}/${t}`,channelWebhooks:e=>`${s.channel(e)}/webhooks`,messageReactions:(e,t)=>`${s.channelMessage(e,t)}/reactions`,messageReaction:(e,t,n,i)=>`${s.messageReactions(e,t)}/${n}`+`${i?`?limit=${i}`:""}`,selfMessageReaction:(e,t,n,i)=>`${s.messageReaction(e,t,n,i)}/@me`,userMessageReaction:(e,t,n,i,r)=>`${s.messageReaction(e,t,n,i)}/${r}`,webhook:(e,t)=>`${r}/webhooks/${e}${t?`/${t}`:""}`,myApplication:`${r}/oauth2/applications/@me`,getApp:e=>`${r}/oauth2/authorize?client_id=${e}`};t.Status={READY:0,CONNECTING:1,RECONNECTING:2,IDLE:3,NEARLY:4},t.ChannelTypes={text:0,DM:1,voice:2,groupDM:3},t.OPCodes={DISPATCH:0,HEARTBEAT:1,IDENTIFY:2,STATUS_UPDATE:3,VOICE_STATE_UPDATE:4,VOICE_GUILD_PING:5,RESUME:6,RECONNECT:7,REQUEST_GUILD_MEMBERS:8,INVALID_SESSION:9,HELLO:10,HEARTBEAT_ACK:11},t.VoiceOPCodes={IDENTIFY:0,SELECT_PROTOCOL:1,READY:2,HEARTBEAT:3,SESSION_DESCRIPTION:4,SPEAKING:5},t.Events={READY:"ready",GUILD_CREATE:"guildCreate",GUILD_DELETE:"guildDelete",GUILD_UPDATE:"guildUpdate",GUILD_UNAVAILABLE:"guildUnavailable",GUILD_AVAILABLE:"guildAvailable",GUILD_MEMBER_ADD:"guildMemberAdd",GUILD_MEMBER_REMOVE:"guildMemberRemove",GUILD_MEMBER_UPDATE:"guildMemberUpdate",GUILD_MEMBER_AVAILABLE:"guildMemberAvailable",GUILD_MEMBER_SPEAKING:"guildMemberSpeaking",GUILD_MEMBERS_CHUNK:"guildMembersChunk",GUILD_ROLE_CREATE:"roleCreate",GUILD_ROLE_DELETE:"roleDelete",GUILD_ROLE_UPDATE:"roleUpdate",GUILD_EMOJI_CREATE:"guildEmojiCreate",GUILD_EMOJI_DELETE:"guildEmojiDelete",GUILD_EMOJI_UPDATE:"guildEmojiUpdate",GUILD_BAN_ADD:"guildBanAdd",GUILD_BAN_REMOVE:"guildBanRemove",CHANNEL_CREATE:"channelCreate",CHANNEL_DELETE:"channelDelete",CHANNEL_UPDATE:"channelUpdate",CHANNEL_PINS_UPDATE:"channelPinsUpdate",MESSAGE_CREATE:"message",MESSAGE_DELETE:"messageDelete",MESSAGE_UPDATE:"messageUpdate",MESSAGE_BULK_DELETE:"messageDeleteBulk",MESSAGE_REACTION_ADD:"messageReactionAdd",MESSAGE_REACTION_REMOVE:"messageReactionRemove",MESSAGE_REACTION_REMOVE_ALL:"messageReactionRemoveAll",USER_UPDATE:"userUpdate",USER_NOTE_UPDATE:"userNoteUpdate",PRESENCE_UPDATE:"presenceUpdate",VOICE_STATE_UPDATE:"voiceStateUpdate",TYPING_START:"typingStart",TYPING_STOP:"typingStop",DISCONNECT:"disconnect",RECONNECTING:"reconnecting",ERROR:"error",WARN:"warn",DEBUG:"debug"},t.WSEvents={READY:"READY",GUILD_SYNC:"GUILD_SYNC",GUILD_CREATE:"GUILD_CREATE",GUILD_DELETE:"GUILD_DELETE",GUILD_UPDATE:"GUILD_UPDATE",GUILD_MEMBER_ADD:"GUILD_MEMBER_ADD",GUILD_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",GUILD_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",GUILD_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",GUILD_ROLE_CREATE:"GUILD_ROLE_CREATE",GUILD_ROLE_DELETE:"GUILD_ROLE_DELETE",GUILD_ROLE_UPDATE:"GUILD_ROLE_UPDATE",GUILD_BAN_ADD:"GUILD_BAN_ADD",GUILD_BAN_REMOVE:"GUILD_BAN_REMOVE",CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",CHANNEL_PINS_UPDATE:"CHANNEL_PINS_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",MESSAGE_DELETE_BULK:"MESSAGE_DELETE_BULK",MESSAGE_REACTION_ADD:"MESSAGE_REACTION_ADD",MESSAGE_REACTION_REMOVE:"MESSAGE_REACTION_REMOVE",MESSAGE_REACTION_REMOVE_ALL:"MESSAGE_REACTION_REMOVE_ALL",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",TYPING_START:"TYPING_START",FRIEND_ADD:"RELATIONSHIP_ADD",FRIEND_REMOVE:"RELATIONSHIP_REMOVE",VOICE_SERVER_UPDATE:"VOICE_SERVER_UPDATE",RELATIONSHIP_ADD:"RELATIONSHIP_ADD",RELATIONSHIP_REMOVE:"RELATIONSHIP_REMOVE"},t.MessageTypes={0:"DEFAULT",1:"RECIPIENT_ADD",2:"RECIPIENT_REMOVE",3:"CALL",4:"CHANNEL_NAME_CHANGE",5:"CHANNEL_ICON_CHANGE",6:"PINS_ADD"};const o=t.PermissionFlags={CREATE_INSTANT_INVITE:1,KICK_MEMBERS:2,BAN_MEMBERS:4,ADMINISTRATOR:8,MANAGE_CHANNELS:16,MANAGE_GUILD:32,ADD_REACTIONS:64,READ_MESSAGES:1024,SEND_MESSAGES:2048,SEND_TTS_MESSAGES:4096,MANAGE_MESSAGES:8192,EMBED_LINKS:16384,ATTACH_FILES:32768,READ_MESSAGE_HISTORY:65536,MENTION_EVERYONE:1<<17,EXTERNAL_EMOJIS:1<<18,CONNECT:1<<20,SPEAK:1<<21,MUTE_MEMBERS:1<<22,DEAFEN_MEMBERS:1<<23,MOVE_MEMBERS:1<<24,USE_VAD:1<<25,CHANGE_NICKNAME:1<<26,MANAGE_NICKNAMES:1<<27,MANAGE_ROLES_OR_PERMISSIONS:1<<28,MANAGE_WEBHOOKS:1<<29,MANAGE_EMOJIS:1<<30};let a=0;for(const c in o)a|=o[c];t.ALL_PERMISSIONS=a,t.DEFAULT_PERMISSIONS=104324097}).call(t,n(8))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){class n{constructor(e){this.packetManager=e}handle(e){return e}}e.exports=n},function(e,t){class n{constructor(e){this.client=e}handle(e){return e}}e.exports=n},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function r(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!r(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,r,a,c,h;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(n=this._events[e],o(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(s(n))for(a=Array.prototype.slice.call(arguments,1),h=n.slice(),r=h.length,c=0;c0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,r,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t){class n extends Map{constructor(e){super(e),this._array=null,this._keyArray=null}set(e,t){super.set(e,t),this._array=null,this._keyArray=null}delete(e){super.delete(e),this._array=null,this._keyArray=null}array(){return this._array&&this._array.length===this.size||(this._array=Array.from(this.values())),this._array}keyArray(){return this._keyArray&&this._keyArray.length===this.size||(this._keyArray=Array.from(this.keys())),this._keyArray}first(){return this.values().next().value}firstKey(){return this.keys().next().value}last(){const e=this.array();return e[e.length-1]}lastKey(){const e=this.keyArray();return e[e.length-1]}random(){const e=this.array();return e[Math.floor(Math.random()*e.length)]; -}randomKey(){const e=this.keyArray();return e[Math.floor(Math.random()*e.length)]}findAll(e,t){if("string"!=typeof e)throw new TypeError("Key must be a string.");if("undefined"==typeof t)throw new Error("Value must be specified.");const n=[];for(const i of this.values())i[e]===t&&n.push(i);return n}find(e,t){if("string"==typeof e){if("undefined"==typeof t)throw new Error("Value must be specified.");if("id"===e)throw new RangeError("Don't use .find() with IDs. Instead, use .get(id).");for(const n of this.values())if(n[e]===t)return n;return null}if("function"==typeof e){for(const[t,n]of this)if(e(n,t,this))return n;return null}throw new Error("First argument must be a property string or a function.")}findKey(e,t){if("string"==typeof e){if("undefined"==typeof t)throw new Error("Value must be specified.");for(const[n,i]of this)if(i[e]===t)return n;return null}if("function"==typeof e){for(const[t,n]of this)if(e(n,t,this))return t;return null}throw new Error("First argument must be a property string or a function.")}exists(e,t){if("id"===e)throw new RangeError("Don't use .exists() with IDs. Instead, use .has(id).");return Boolean(this.find(e,t))}filter(e,t){t&&(e=e.bind(t));const i=new n;for(const[r,s]of this)e(s,r,this)&&i.set(r,s);return i}filterArray(e,t){t&&(e=e.bind(t));const n=[];for(const[i,r]of this)e(r,i,this)&&n.push(r);return n}map(e,t){t&&(e=e.bind(t));const n=new Array(this.size);let i=0;for(const[r,s]of this)n[i++]=e(s,r,this);return n}some(e,t){t&&(e=e.bind(t));for(const[n,i]of this)if(e(i,n,this))return!0;return!1}every(e,t){t&&(e=e.bind(t));for(const[n,i]of this)if(!e(i,n,this))return!1;return!0}reduce(e,t){let n=t;for(const[i,r]of this)n=e(n,r,i,this);return n}concat(...e){const t=new this.constructor;for(const[n,i]of this)t.set(n,i);for(const r of e)for(const[n,i]of r)t.set(n,i);return t}deleteAll(){const e=[];for(const t of this.values())t.delete&&e.push(t.delete());return e}}e.exports=n},function(e,t,n){(function(e){!function(e,t){"use strict";function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function s(e,t,n){return s.isBN(e)?e:(this.negative=0,this.words=null,this.length=0,this.red=null,void(null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))))}function o(e,t,n){for(var i=0,r=Math.min(e.length,n),s=t;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return i}function a(e,t,n,i){for(var r=0,s=Math.min(e.length,n),o=t;o=49?a-49+10:a>=17?a-17+10:a}return r}function c(e){for(var t=new Array(e.bitLength()),n=0;n>>r}return t}function h(e,t,n){n.negative=t.negative^e.negative;var i=e.length+t.length|0;n.length=i,i=i-1|0;var r=0|e.words[0],s=0|t.words[0],o=r*s,a=67108863&o,c=o/67108864|0;n.words[0]=a;for(var h=1;h>>26,u=67108863&c,d=Math.min(h,t.length-1),l=Math.max(0,h-e.length+1);l<=d;l++){var p=h-l|0;r=0|e.words[p],s=0|t.words[l],o=r*s+u,f+=o/67108864|0,u=67108863&o}n.words[h]=0|u,c=0|f}return 0!==c?n.words[h]=0|c:n.length--,n.strip()}function f(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var i=0,r=0,s=0;s>>26)|0,r+=o>>>26,o&=67108863}n.words[s]=a,i=o,o=r}return 0!==i?n.words[s]=i:n.length--,n.strip()}function u(e,t,n){var i=new d;return i.mulp(e,t,n)}function d(e,t){this.x=e,this.y=t}function l(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function p(){l.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){l.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function m(){l.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function g(){l.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function v(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function y(e){v.call(this,e),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof e?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var _;try{_=n(0).Buffer}catch(e){}s.isBN=function(e){return e instanceof s||null!==e&&"object"==typeof e&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,"");var r=0;"-"===e[0]&&r++,16===t?this._parseHex(e,r):this._parseBase(e,t,r),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},s.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(i(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},s.prototype._initArray=function(e,t,n){if(i("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)o=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[s]|=o<>>26-a&67108863,a+=24,a>=26&&(a-=26,s++);else if("le"===n)for(r=0,s=0;r>>26-a&67108863,a+=24,a>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=6)r=o(e,n,n+6),this.words[i]|=r<>>26-s&4194303,s+=24,s>=26&&(s-=26,i++);n+6!==t&&(r=o(e,t,n+6),this.words[i]|=r<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var i=0,r=1;r<=67108863;r*=t)i++;i--,r=r/t|0;for(var s=e.length-n,o=s%i,c=Math.min(s,s-o)+n,h=0,f=n;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var w=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],E=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],S=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(e,t){e=e||10,t=0|t||1;var n;if(16===e||"hex"===e){n="";for(var r=0,s=0,o=0;o>>24-r&16777215,n=0!==s||o!==this.length-1?w[6-c.length]+c+n:c+n,r+=2,r>=26&&(r-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=E[e],f=S[e];n="";var u=this.clone();for(u.negative=0;!u.isZero();){var d=u.modn(f).toString(e);u=u.idivn(f),n=u.isZero()?d+n:w[h-d.length]+d+n}for(this.isZero()&&(n="0"+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return i("undefined"!=typeof _),this.toArrayLike(_,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,n){var r=this.byteLength(),s=n||Math.max(1,r);i(r<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===t,h=new e(s),f=this.clone();if(c){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),h[a]=o;for(;a=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0===(8191&t)&&(n+=13,t>>>=13),0===(127&t)&&(n+=7,t>>>=7),0===(15&t)&&(n+=4,t>>>=4),0===(3&t)&&(n+=2,t>>>=2),0===(1&t)&&n++,n},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-n),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var n=e/26|0,r=e%26;return this._expand(n+1),t?this.words[n]=this.words[n]|1<e.length?(n=this,i=e):(n=e,i=this);for(var r=0,s=0;s>>26;for(;0!==r&&s>>26;if(this.length=n.length,0!==r)this.words[this.length]=r,this.length++;else if(n!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;var i,r;n>0?(i=this,r=e):(i=e,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,l=0|o[1],p=8191&l,b=l>>>13,m=0|o[2],g=8191&m,v=m>>>13,y=0|o[3],_=8191&y,w=y>>>13,E=0|o[4],S=8191&E,k=E>>>13,A=0|o[5],M=8191&A,x=A>>>13,R=0|o[6],I=8191&R,T=R>>>13,C=0|o[7],D=8191&C,P=C>>>13,B=0|o[8],L=8191&B,O=B>>>13,U=0|o[9],N=8191&U,j=U>>>13,q=0|a[0],z=8191&q,F=q>>>13,G=0|a[1],H=8191&G,W=G>>>13,V=0|a[2],K=8191&V,Z=V>>>13,Y=0|a[3],X=8191&Y,J=Y>>>13,$=0|a[4],Q=8191&$,ee=$>>>13,te=0|a[5],ne=8191&te,ie=te>>>13,re=0|a[6],se=8191&re,oe=re>>>13,ae=0|a[7],ce=8191&ae,he=ae>>>13,fe=0|a[8],ue=8191&fe,de=fe>>>13,le=0|a[9],pe=8191&le,be=le>>>13;n.negative=e.negative^t.negative,n.length=19,i=Math.imul(u,z),r=Math.imul(u,F),r=r+Math.imul(d,z)|0,s=Math.imul(d,F);var me=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(me>>>26)|0,me&=67108863,i=Math.imul(p,z),r=Math.imul(p,F),r=r+Math.imul(b,z)|0,s=Math.imul(b,F),i=i+Math.imul(u,H)|0,r=r+Math.imul(u,W)|0,r=r+Math.imul(d,H)|0,s=s+Math.imul(d,W)|0;var ge=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,z),r=Math.imul(g,F),r=r+Math.imul(v,z)|0,s=Math.imul(v,F),i=i+Math.imul(p,H)|0,r=r+Math.imul(p,W)|0,r=r+Math.imul(b,H)|0,s=s+Math.imul(b,W)|0,i=i+Math.imul(u,K)|0,r=r+Math.imul(u,Z)|0,r=r+Math.imul(d,K)|0,s=s+Math.imul(d,Z)|0;var ve=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(_,z),r=Math.imul(_,F),r=r+Math.imul(w,z)|0,s=Math.imul(w,F),i=i+Math.imul(g,H)|0,r=r+Math.imul(g,W)|0,r=r+Math.imul(v,H)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,K)|0,r=r+Math.imul(p,Z)|0,r=r+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(u,X)|0,r=r+Math.imul(u,J)|0,r=r+Math.imul(d,X)|0,s=s+Math.imul(d,J)|0;var ye=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(S,z),r=Math.imul(S,F),r=r+Math.imul(k,z)|0,s=Math.imul(k,F),i=i+Math.imul(_,H)|0,r=r+Math.imul(_,W)|0,r=r+Math.imul(w,H)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(g,K)|0,r=r+Math.imul(g,Z)|0,r=r+Math.imul(v,K)|0,s=s+Math.imul(v,Z)|0,i=i+Math.imul(p,X)|0,r=r+Math.imul(p,J)|0,r=r+Math.imul(b,X)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(u,Q)|0,r=r+Math.imul(u,ee)|0,r=r+Math.imul(d,Q)|0,s=s+Math.imul(d,ee)|0;var _e=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(M,z),r=Math.imul(M,F),r=r+Math.imul(x,z)|0,s=Math.imul(x,F),i=i+Math.imul(S,H)|0,r=r+Math.imul(S,W)|0,r=r+Math.imul(k,H)|0,s=s+Math.imul(k,W)|0,i=i+Math.imul(_,K)|0,r=r+Math.imul(_,Z)|0,r=r+Math.imul(w,K)|0,s=s+Math.imul(w,Z)|0,i=i+Math.imul(g,X)|0,r=r+Math.imul(g,J)|0,r=r+Math.imul(v,X)|0,s=s+Math.imul(v,J)|0,i=i+Math.imul(p,Q)|0,r=r+Math.imul(p,ee)|0,r=r+Math.imul(b,Q)|0,s=s+Math.imul(b,ee)|0,i=i+Math.imul(u,ne)|0,r=r+Math.imul(u,ie)|0,r=r+Math.imul(d,ne)|0,s=s+Math.imul(d,ie)|0;var we=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(I,z),r=Math.imul(I,F),r=r+Math.imul(T,z)|0,s=Math.imul(T,F),i=i+Math.imul(M,H)|0,r=r+Math.imul(M,W)|0,r=r+Math.imul(x,H)|0,s=s+Math.imul(x,W)|0,i=i+Math.imul(S,K)|0,r=r+Math.imul(S,Z)|0,r=r+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(_,X)|0,r=r+Math.imul(_,J)|0,r=r+Math.imul(w,X)|0,s=s+Math.imul(w,J)|0,i=i+Math.imul(g,Q)|0,r=r+Math.imul(g,ee)|0,r=r+Math.imul(v,Q)|0,s=s+Math.imul(v,ee)|0,i=i+Math.imul(p,ne)|0,r=r+Math.imul(p,ie)|0,r=r+Math.imul(b,ne)|0,s=s+Math.imul(b,ie)|0,i=i+Math.imul(u,se)|0,r=r+Math.imul(u,oe)|0,r=r+Math.imul(d,se)|0,s=s+Math.imul(d,oe)|0;var Ee=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(D,z),r=Math.imul(D,F),r=r+Math.imul(P,z)|0,s=Math.imul(P,F),i=i+Math.imul(I,H)|0,r=r+Math.imul(I,W)|0,r=r+Math.imul(T,H)|0,s=s+Math.imul(T,W)|0,i=i+Math.imul(M,K)|0,r=r+Math.imul(M,Z)|0,r=r+Math.imul(x,K)|0,s=s+Math.imul(x,Z)|0,i=i+Math.imul(S,X)|0,r=r+Math.imul(S,J)|0,r=r+Math.imul(k,X)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(_,Q)|0,r=r+Math.imul(_,ee)|0,r=r+Math.imul(w,Q)|0,s=s+Math.imul(w,ee)|0,i=i+Math.imul(g,ne)|0,r=r+Math.imul(g,ie)|0,r=r+Math.imul(v,ne)|0,s=s+Math.imul(v,ie)|0,i=i+Math.imul(p,se)|0,r=r+Math.imul(p,oe)|0,r=r+Math.imul(b,se)|0,s=s+Math.imul(b,oe)|0,i=i+Math.imul(u,ce)|0,r=r+Math.imul(u,he)|0,r=r+Math.imul(d,ce)|0,s=s+Math.imul(d,he)|0;var Se=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(L,z),r=Math.imul(L,F),r=r+Math.imul(O,z)|0,s=Math.imul(O,F),i=i+Math.imul(D,H)|0,r=r+Math.imul(D,W)|0,r=r+Math.imul(P,H)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(I,K)|0,r=r+Math.imul(I,Z)|0,r=r+Math.imul(T,K)|0,s=s+Math.imul(T,Z)|0,i=i+Math.imul(M,X)|0,r=r+Math.imul(M,J)|0,r=r+Math.imul(x,X)|0,s=s+Math.imul(x,J)|0,i=i+Math.imul(S,Q)|0,r=r+Math.imul(S,ee)|0,r=r+Math.imul(k,Q)|0,s=s+Math.imul(k,ee)|0,i=i+Math.imul(_,ne)|0,r=r+Math.imul(_,ie)|0,r=r+Math.imul(w,ne)|0,s=s+Math.imul(w,ie)|0,i=i+Math.imul(g,se)|0,r=r+Math.imul(g,oe)|0,r=r+Math.imul(v,se)|0,s=s+Math.imul(v,oe)|0,i=i+Math.imul(p,ce)|0,r=r+Math.imul(p,he)|0,r=r+Math.imul(b,ce)|0,s=s+Math.imul(b,he)|0,i=i+Math.imul(u,ue)|0,r=r+Math.imul(u,de)|0,r=r+Math.imul(d,ue)|0,s=s+Math.imul(d,de)|0;var ke=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(N,z),r=Math.imul(N,F),r=r+Math.imul(j,z)|0,s=Math.imul(j,F),i=i+Math.imul(L,H)|0,r=r+Math.imul(L,W)|0,r=r+Math.imul(O,H)|0,s=s+Math.imul(O,W)|0,i=i+Math.imul(D,K)|0,r=r+Math.imul(D,Z)|0,r=r+Math.imul(P,K)|0,s=s+Math.imul(P,Z)|0,i=i+Math.imul(I,X)|0,r=r+Math.imul(I,J)|0,r=r+Math.imul(T,X)|0,s=s+Math.imul(T,J)|0,i=i+Math.imul(M,Q)|0,r=r+Math.imul(M,ee)|0,r=r+Math.imul(x,Q)|0,s=s+Math.imul(x,ee)|0,i=i+Math.imul(S,ne)|0,r=r+Math.imul(S,ie)|0,r=r+Math.imul(k,ne)|0,s=s+Math.imul(k,ie)|0,i=i+Math.imul(_,se)|0,r=r+Math.imul(_,oe)|0,r=r+Math.imul(w,se)|0,s=s+Math.imul(w,oe)|0,i=i+Math.imul(g,ce)|0,r=r+Math.imul(g,he)|0,r=r+Math.imul(v,ce)|0,s=s+Math.imul(v,he)|0,i=i+Math.imul(p,ue)|0,r=r+Math.imul(p,de)|0,r=r+Math.imul(b,ue)|0,s=s+Math.imul(b,de)|0,i=i+Math.imul(u,pe)|0,r=r+Math.imul(u,be)|0,r=r+Math.imul(d,pe)|0,s=s+Math.imul(d,be)|0;var Ae=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(N,H),r=Math.imul(N,W),r=r+Math.imul(j,H)|0,s=Math.imul(j,W),i=i+Math.imul(L,K)|0,r=r+Math.imul(L,Z)|0,r=r+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(D,X)|0,r=r+Math.imul(D,J)|0,r=r+Math.imul(P,X)|0,s=s+Math.imul(P,J)|0,i=i+Math.imul(I,Q)|0,r=r+Math.imul(I,ee)|0,r=r+Math.imul(T,Q)|0,s=s+Math.imul(T,ee)|0,i=i+Math.imul(M,ne)|0,r=r+Math.imul(M,ie)|0,r=r+Math.imul(x,ne)|0,s=s+Math.imul(x,ie)|0,i=i+Math.imul(S,se)|0,r=r+Math.imul(S,oe)|0,r=r+Math.imul(k,se)|0,s=s+Math.imul(k,oe)|0,i=i+Math.imul(_,ce)|0,r=r+Math.imul(_,he)|0,r=r+Math.imul(w,ce)|0,s=s+Math.imul(w,he)|0,i=i+Math.imul(g,ue)|0,r=r+Math.imul(g,de)|0,r=r+Math.imul(v,ue)|0,s=s+Math.imul(v,de)|0,i=i+Math.imul(p,pe)|0,r=r+Math.imul(p,be)|0,r=r+Math.imul(b,pe)|0,s=s+Math.imul(b,be)|0;var Me=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(N,K),r=Math.imul(N,Z),r=r+Math.imul(j,K)|0,s=Math.imul(j,Z),i=i+Math.imul(L,X)|0,r=r+Math.imul(L,J)|0,r=r+Math.imul(O,X)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(D,Q)|0,r=r+Math.imul(D,ee)|0,r=r+Math.imul(P,Q)|0,s=s+Math.imul(P,ee)|0,i=i+Math.imul(I,ne)|0,r=r+Math.imul(I,ie)|0,r=r+Math.imul(T,ne)|0,s=s+Math.imul(T,ie)|0,i=i+Math.imul(M,se)|0,r=r+Math.imul(M,oe)|0,r=r+Math.imul(x,se)|0,s=s+Math.imul(x,oe)|0,i=i+Math.imul(S,ce)|0,r=r+Math.imul(S,he)|0,r=r+Math.imul(k,ce)|0,s=s+Math.imul(k,he)|0,i=i+Math.imul(_,ue)|0,r=r+Math.imul(_,de)|0,r=r+Math.imul(w,ue)|0,s=s+Math.imul(w,de)|0,i=i+Math.imul(g,pe)|0,r=r+Math.imul(g,be)|0,r=r+Math.imul(v,pe)|0,s=s+Math.imul(v,be)|0;var xe=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(N,X),r=Math.imul(N,J),r=r+Math.imul(j,X)|0,s=Math.imul(j,J),i=i+Math.imul(L,Q)|0,r=r+Math.imul(L,ee)|0,r=r+Math.imul(O,Q)|0,s=s+Math.imul(O,ee)|0,i=i+Math.imul(D,ne)|0,r=r+Math.imul(D,ie)|0,r=r+Math.imul(P,ne)|0,s=s+Math.imul(P,ie)|0,i=i+Math.imul(I,se)|0,r=r+Math.imul(I,oe)|0,r=r+Math.imul(T,se)|0,s=s+Math.imul(T,oe)|0,i=i+Math.imul(M,ce)|0,r=r+Math.imul(M,he)|0,r=r+Math.imul(x,ce)|0,s=s+Math.imul(x,he)|0,i=i+Math.imul(S,ue)|0,r=r+Math.imul(S,de)|0,r=r+Math.imul(k,ue)|0,s=s+Math.imul(k,de)|0,i=i+Math.imul(_,pe)|0,r=r+Math.imul(_,be)|0,r=r+Math.imul(w,pe)|0,s=s+Math.imul(w,be)|0;var Re=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(N,Q),r=Math.imul(N,ee),r=r+Math.imul(j,Q)|0,s=Math.imul(j,ee),i=i+Math.imul(L,ne)|0,r=r+Math.imul(L,ie)|0,r=r+Math.imul(O,ne)|0,s=s+Math.imul(O,ie)|0,i=i+Math.imul(D,se)|0,r=r+Math.imul(D,oe)|0,r=r+Math.imul(P,se)|0,s=s+Math.imul(P,oe)|0,i=i+Math.imul(I,ce)|0,r=r+Math.imul(I,he)|0,r=r+Math.imul(T,ce)|0,s=s+Math.imul(T,he)|0,i=i+Math.imul(M,ue)|0,r=r+Math.imul(M,de)|0,r=r+Math.imul(x,ue)|0,s=s+Math.imul(x,de)|0,i=i+Math.imul(S,pe)|0,r=r+Math.imul(S,be)|0,r=r+Math.imul(k,pe)|0,s=s+Math.imul(k,be)|0;var Ie=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(N,ne),r=Math.imul(N,ie),r=r+Math.imul(j,ne)|0,s=Math.imul(j,ie),i=i+Math.imul(L,se)|0,r=r+Math.imul(L,oe)|0,r=r+Math.imul(O,se)|0,s=s+Math.imul(O,oe)|0,i=i+Math.imul(D,ce)|0,r=r+Math.imul(D,he)|0,r=r+Math.imul(P,ce)|0,s=s+Math.imul(P,he)|0,i=i+Math.imul(I,ue)|0,r=r+Math.imul(I,de)|0,r=r+Math.imul(T,ue)|0,s=s+Math.imul(T,de)|0,i=i+Math.imul(M,pe)|0,r=r+Math.imul(M,be)|0,r=r+Math.imul(x,pe)|0,s=s+Math.imul(x,be)|0;var Te=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(N,se),r=Math.imul(N,oe),r=r+Math.imul(j,se)|0,s=Math.imul(j,oe),i=i+Math.imul(L,ce)|0,r=r+Math.imul(L,he)|0,r=r+Math.imul(O,ce)|0,s=s+Math.imul(O,he)|0,i=i+Math.imul(D,ue)|0,r=r+Math.imul(D,de)|0,r=r+Math.imul(P,ue)|0,s=s+Math.imul(P,de)|0,i=i+Math.imul(I,pe)|0,r=r+Math.imul(I,be)|0,r=r+Math.imul(T,pe)|0,s=s+Math.imul(T,be)|0;var Ce=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(N,ce),r=Math.imul(N,he),r=r+Math.imul(j,ce)|0,s=Math.imul(j,he),i=i+Math.imul(L,ue)|0,r=r+Math.imul(L,de)|0,r=r+Math.imul(O,ue)|0,s=s+Math.imul(O,de)|0,i=i+Math.imul(D,pe)|0,r=r+Math.imul(D,be)|0,r=r+Math.imul(P,pe)|0,s=s+Math.imul(P,be)|0;var De=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(De>>>26)|0,De&=67108863,i=Math.imul(N,ue),r=Math.imul(N,de),r=r+Math.imul(j,ue)|0,s=Math.imul(j,de),i=i+Math.imul(L,pe)|0,r=r+Math.imul(L,be)|0,r=r+Math.imul(O,pe)|0,s=s+Math.imul(O,be)|0;var Pe=(h+i|0)+((8191&r)<<13)|0;h=(s+(r>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(N,pe),r=Math.imul(N,be),r=r+Math.imul(j,pe)|0,s=Math.imul(j,be);var Be=(h+i|0)+((8191&r)<<13)|0;return h=(s+(r>>>13)|0)+(Be>>>26)|0,Be&=67108863,c[0]=me,c[1]=ge,c[2]=ve,c[3]=ye,c[4]=_e,c[5]=we,c[6]=Ee,c[7]=Se,c[8]=ke,c[9]=Ae,c[10]=Me,c[11]=xe,c[12]=Re,c[13]=Ie,c[14]=Te,c[15]=Ce,c[16]=De,c[17]=Pe,c[18]=Be,0!==h&&(c[19]=h,n.length++),n};Math.imul||(k=h),s.prototype.mulTo=function(e,t){var n,i=this.length+e.length;return n=10===this.length&&10===e.length?k(this,e,t):i<63?h(this,e,t):i<1024?f(this,e,t):u(this,e,t)},d.prototype.makeRBT=function(e){for(var t=new Array(e),n=s.prototype._countBits(e)-1,i=0;i>=1;return i},d.prototype.permute=function(e,t,n,i,r,s){for(var o=0;o>>=1)r++;return 1<>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,t+=r/67108864|0,t+=s>>>26,this.words[n]=67108863&s}return 0!==t&&(this.words[n]=t,this.length++),this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=c(e);if(0===t.length)return new s(1);for(var n=this,i=0;i=0);var t,n=e%26,r=(e-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(t=0;t>>26-n}o&&(this.words[t]=o,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t=0);var r;r=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,h=0;h=0&&(0!==f||h>=r);h--){var u=0|this.words[h];this.words[h]=f<<26-s|u>>>s,f=u&a}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(e,t,n){return i(0===this.negative),this.iushrn(e,t,n)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,r=1<=0);var t=e%26,n=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var r=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[r+n]=67108863&o}for(;r>26,this.words[r+n]=67108863&o;if(0===a)return this.strip();for(i(a===-1),a=0, -r=0;r>26,this.words[r]=67108863&o;return this.negative=1,this.strip()},s.prototype._wordDiv=function(e,t){var n=this.length-e.length,i=this.clone(),r=e,o=0|r.words[r.length-1],a=this._countBits(o);n=26-a,0!==n&&(r=r.ushln(n),i.iushln(n),o=0|r.words[r.length-1]);var c,h=i.length-r.length;if("mod"!==t){c=new s(null),c.length=h+1,c.words=new Array(c.length);for(var f=0;f=0;d--){var l=67108864*(0|i.words[r.length+d])+(0|i.words[r.length+d-1]);for(l=Math.min(l/o|0,67108863),i._ishlnsubmul(r,l,d);0!==i.negative;)l--,i.negative=0,i._ishlnsubmul(r,1,d),i.isZero()||(i.negative^=1);c&&(c.words[d]=l)}return c&&c.strip(),i.strip(),"div"!==t&&0!==n&&i.iushrn(n),{div:c||null,mod:i}},s.prototype.divmod=function(e,t,n){if(i(!e.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var r,o,a;return 0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(r=a.div.neg()),"div"!==t&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(e)),{div:r,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(r=a.div.neg()),{div:r,mod:a.mod}):0!==(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modn(e.words[0]))}:this._wordDiv(e,t)},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),r=e.andln(1),s=n.cmp(i);return s<0||1===r&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modn=function(e){i(e<=67108863);for(var t=(1<<26)%e,n=0,r=this.length-1;r>=0;r--)n=(t*n+(0|this.words[r]))%e;return n},s.prototype.idivn=function(e){i(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var r=(0|this.words[n])+67108864*t;this.words[n]=r/e|0,t=r%e}return this.strip()},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new s(1),o=new s(0),a=new s(0),c=new s(1),h=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++h;for(var f=n.clone(),u=t.clone();!t.isZero();){for(var d=0,l=1;0===(t.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(r.isOdd()||o.isOdd())&&(r.iadd(f),o.isub(u)),r.iushrn(1),o.iushrn(1);for(var p=0,b=1;0===(n.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(u)),a.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),r.isub(a),o.isub(c)):(n.isub(t),a.isub(r),c.isub(o))}return{a:a,b:c,gcd:n.iushln(h)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new s(1),o=new s(0),a=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,h=1;0===(t.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(t.iushrn(c);c-- >0;)r.isOdd()&&r.iadd(a),r.iushrn(1);for(var f=0,u=1;0===(n.words[0]&u)&&f<26;++f,u<<=1);if(f>0)for(n.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);t.cmp(n)>=0?(t.isub(n),r.isub(o)):(n.isub(t),o.isub(r))}var d;return d=0===t.cmpn(1)?r:o,d.cmpn(0)<0&&d.iadd(e),d},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var i=0;t.isEven()&&n.isEven();i++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var r=t.cmp(n);if(r<0){var s=t;t=n,n=s}else if(0===r||0===n.cmpn(1))break;t.isub(n)}return n.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0===(1&this.words[0])},s.prototype.isOdd=function(){return 1===(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,n=(e-t)/26,r=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t=e<0;if(0!==this.negative&&!t)return-1;if(0===this.negative&&t)return 1;this.strip();var n;if(this.length>1)n=1;else{t&&(e=-e),i(e<=67108863,"Number is too big");var r=0|this.words[0];n=r===e?0:re.length)return 1;if(this.length=0;n--){var i=0|this.words[n],r=0|e.words[n];if(i!==r){ir&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return this.cmpn(e)===-1},s.prototype.lt=function(e){return this.cmp(e)===-1},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new v(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var A={k256:null,p224:null,p192:null,p25519:null};l.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},l.prototype.ireduce=function(e){var t,n=e;do this.split(n,this.tmp),n=this.imulK(n),n=n.iadd(this.tmp),t=n.bitLength();while(t>this.n);var i=t0?n.isub(this.p):n.strip(),n},l.prototype.split=function(e,t){e.iushrn(this.n,0,t)},l.prototype.imulK=function(e){return e.imul(this.k)},r(p,l),p.prototype.split=function(e,t){for(var n=4194303,i=Math.min(e.length,9),r=0;r>>22,s=o}s>>>=22,e.words[r-10]=s,0===s&&e.length>10?e.length-=10:e.length-=9},p.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=r,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function e(t){if(A[t])return A[t];var e;if("k256"===t)e=new p;else if("p224"===t)e=new b;else if("p192"===t)e=new m;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new g}return A[t]=e,e},v.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},v.prototype._verify2=function(e,t){i(0===(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},v.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},v.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},v.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},v.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},v.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},v.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},v.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},v.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},v.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},v.prototype.isqr=function(e){return this.imul(e,e.clone())},v.prototype.sqr=function(e){return this.mul(e,e)},v.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2===1),3===t){var n=this.m.add(new s(1)).iushrn(2);return this.pow(e,n)}for(var r=this.m.subn(1),o=0;!r.isZero()&&0===r.andln(1);)o++,r.iushrn(1);i(!r.isZero());var a=new s(1).toRed(this),c=a.redNeg(),h=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,h).cmp(c);)f.redIAdd(c);for(var u=this.pow(f,r),d=this.pow(e,r.addn(1).iushrn(1)),l=this.pow(e,r),p=o;0!==l.cmp(a);){for(var b=l,m=0;0!==b.cmp(a);m++)b=b.redSqr();i(m=0;r--){for(var f=t.words[r],u=h-1;u>=0;u--){var d=f>>u&1;o!==i[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,c++,(c===n||0===r&&0===u)&&(o=this.mul(o,i[a]),c=0,a=0)):c=0}h=26}return o},v.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},v.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new y(e)},r(y,v),y.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},y.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},y.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),s=r;return r.cmp(this.m)>=0?s=r.isub(this.m):r.cmpn(0)<0&&(s=r.iadd(this.m)),s._forceRed(this)},y.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var n=e.mul(t),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),o=r;return r.cmp(this.m)>=0?o=r.isub(this.m):r.cmpn(0)<0&&(o=r.iadd(this.m)),o._forceRed(this)},y.prototype.invm=function(e){var t=this.imod(e._invmp(this.m).mul(this.r2));return t._forceRed(this)}}("undefined"==typeof e||e,this)}).call(t,n(121)(e))},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function r(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function s(e){if(u===clearTimeout)return clearTimeout(e);if((u===i||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{return u(e)}catch(t){try{return u.call(null,e)}catch(t){return u.call(this,e)}}}function o(){b&&l&&(b=!1,l.length?p=l.concat(p):m=-1,p.length&&a())}function a(){if(!b){var e=r(o);b=!0;for(var t=p.length;t;){for(l=p,p=[];++m1)for(var n=1;n=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),b(n)?i.showHidden=n:n&&t._extend(i,n),w(i.showHidden)&&(i.showHidden=!1),w(i.depth)&&(i.depth=2),w(i.colors)&&(i.colors=!1),w(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=s),c(i,e,i.depth)}function s(e,t){var n=r.styles[t];return n?"["+r.colors[n][0]+"m"+e+"["+r.colors[n][1]+"m":e}function o(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function c(e,n,i){if(e.customInspect&&n&&M(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var r=n.inspect(i,e);return y(r)||(r=c(e,r,i)),r}var s=h(e,n);if(s)return s;var o=Object.keys(n),b=a(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(n)),A(n)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(n);if(0===o.length){if(M(n)){var m=n.name?": "+n.name:"";return e.stylize("[Function"+m+"]","special")}if(E(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(k(n))return e.stylize(Date.prototype.toString.call(n),"date");if(A(n))return f(n)}var g="",v=!1,_=["{","}"];if(p(n)&&(v=!0,_=["[","]"]),M(n)){var w=n.name?": "+n.name:"";g=" [Function"+w+"]"}if(E(n)&&(g=" "+RegExp.prototype.toString.call(n)),k(n)&&(g=" "+Date.prototype.toUTCString.call(n)),A(n)&&(g=" "+f(n)),0===o.length&&(!v||0==n.length))return _[0]+g+_[1];if(i<0)return E(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var S;return S=v?u(e,n,i,b,o):o.map(function(t){return d(e,n,i,b,t,v)}),e.seen.pop(),l(S,g,_)}function h(e,t){if(w(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):b(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function u(e,t,n,i,r){for(var s=[],o=0,a=t.length;o-1&&(a=s?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),w(o)){if(s&&r.match(/^\d+$/))return a;o=JSON.stringify(""+r),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+a}function l(e,t,n){var i=0,r=e.reduce(function(e,t){return i++,t.indexOf("\n")>=0&&i++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function p(e){return Array.isArray(e)}function b(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return null==e}function v(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return"symbol"==typeof e}function w(e){return void 0===e}function E(e){return S(e)&&"[object RegExp]"===R(e)}function S(e){return"object"==typeof e&&null!==e}function k(e){return S(e)&&"[object Date]"===R(e)}function A(e){return S(e)&&("[object Error]"===R(e)||e instanceof Error)}function M(e){return"function"==typeof e}function x(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function R(e){return Object.prototype.toString.call(e)}function I(e){return e<10?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[I(e.getHours()),I(e.getMinutes()),I(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function C(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var D=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],n=0;n=s)return e;switch(e){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(e){return"[Circular]"}default:return e}}),a=i[n];n`}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}}i.applyToClass(o),e.exports=o},function(e,t){class n{constructor(e={}){this.status=e.status||"offline",this.game=e.game?new i(e.game):null}update(e){this.status=e.status||this.status,this.game=e.game?new i(e.game):null}equals(e){return e&&this.status===e.status&&this.game?this.game.equals(e.game):!e.game}}class i{constructor(e){this.name=e.name,this.type=e.type,this.url=e.url||null}get streaming(){return 1===this.type}equals(e){return e&&this.name===e.name&&this.type===e.type&&this.url===e.url}}t.Presence=n,t.Game=i},function(e,t,n){var i=t;i.utils=n(197),i.common=n(193),i.sha=n(196),i.ripemd=n(195),i.hmac=n(194),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},function(e,t,n){"use strict";function i(e){return this instanceof i?(h.call(this,e),f.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",r)):new i(e)}function r(){this.allowHalfOpen||this._writableState.ended||a(s,this)}function s(e){e.end()}var o=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=i;var a=n(56),c=n(28);c.inherits=n(2);var h=n(117),f=n(58);c.inherits(i,h);for(var u=o(f.prototype),d=0;de.roles.has(this.id))}serialize(){const e={};for(const t in i.PermissionFlags)e[t]=this.hasPermission(t);return e}hasPermission(e,t=false){return e=this.client.resolver.resolvePermission(e),!t&&(this.permissions&i.PermissionFlags.ADMINISTRATOR)>0||(this.permissions&e)>0}hasPermissions(e,t=false){return e.every(e=>this.hasPermission(e,t))}comparePositionTo(e){return this.constructor.comparePositions(this,e)}edit(e){return this.client.rest.methods.updateGuildRole(this,e)}setName(e){return this.edit({name:e})}setColor(e){return this.edit({color:e})}setHoist(e){return this.edit({hoist:e})}setPosition(e){return this.guild.setRolePosition(this,e)}setPermissions(e){return this.edit({permissions:e})}setMentionable(e){return this.edit({mentionable:e})}delete(){return this.client.rest.methods.deleteGuildRole(this)}get editable(){if(this.managed)return!1;const e=this.guild.member(this.client.user);return!!e.hasPermission(i.PermissionFlags.MANAGE_ROLES_OR_PERMISSIONS)&&e.highestRole.comparePositionTo(this)>0}equals(e){return e&&this.id===e.id&&this.name===e.name&&this.color===e.color&&this.hoist===e.hoist&&this.position===e.position&&this.permissions===e.permissions&&this.managed===e.managed}toString(){return`<@&${this.id}>`}static comparePositions(e,t){return e.position===t.position?t.id-e.id:e.position-t.position}}e.exports=r},function(e,t,n){(function(t){function i(e){r.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._decoder=null,this._encoding=null}var r=n(11).Transform,s=n(2),o=n(59).StringDecoder;e.exports=i,s(i,r),i.prototype.update=function(e,n,i){"string"==typeof e&&(e=new t(e,n));var r=this._update(e);return this.hashMode?this:(i&&(r=this._toString(r,i)),r)},i.prototype.setAutoPadding=function(){},i.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},i.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},i.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},i.prototype._transform=function(e,t,n){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){i=e}finally{n(i)}},i.prototype._flush=function(e){var t;try{this.push(this._final())}catch(e){t=e}finally{e(t)}},i.prototype._finalOrDigest=function(e){var n=this._final()||new t("");return e&&(n=this._toString(n,e,!0)),n},i.prototype._toString=function(e,t,n){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return n&&(i+=this._decoder.end()),i}}).call(t,n(0).Buffer)},function(e,t,n){"use strict";(function(t){function i(e){h.call(this,"digest"),this._hash=e,this.buffers=[]}function r(e){h.call(this,"digest"),this._hash=e}var s=n(2),o=n(102),a=n(166),c=n(167),h=n(20);s(i,h),i.prototype._update=function(e){this.buffers.push(e)},i.prototype._final=function(){var e=t.concat(this.buffers),n=this._hash(e);return this.buffers=null,n},s(r,h),r.prototype._update=function(e){this._hash.update(e)},r.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return e=e.toLowerCase(),"md5"===e?new i(o):"rmd160"===e||"ripemd160"===e?new i(a):new r(c(e))}}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function n(e,n){this._block=new t(e),this._finalSize=n,this._blockSize=e,this._len=0,this._s=0}n.prototype.update=function(e,n){"string"==typeof e&&(n=n||"utf8",e=new t(e,n));for(var i=this._len+=e.length,r=this._s||0,s=0,o=this._block;r=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(t,this._blockSize-4);var n=this._update(this._block)||this._hash();return e?n.toString(e):n},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n}).call(t,n(0).Buffer)},function(e,t,n){(function(e){function n(e,t){for(var n=0,i=e.length-1;i>=0;i--){var r=e[i];"."===r?e.splice(i,1):".."===r?(e.splice(i,1),n++):n&&(e.splice(i,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function i(e,t){if(e.filter)return e.filter(t);for(var n=[],i=0;i=-1&&!r;s--){var o=s>=0?arguments[s]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,r="/"===o.charAt(0))}return t=n(i(t.split("/"),function(e){return!!e}),!r).join("/"),(r?"/":"")+t||"."},t.normalize=function(e){var r=t.isAbsolute(e),s="/"===o(e,-1);return e=n(i(e.split("/"),function(e){return!!e}),!r).join("/"),e||r||(e="."),e&&s&&(e+="/"),(r?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(i(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function i(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var r=i(e.split("/")),s=i(n.split("/")),o=Math.min(r.length,s.length),a=o,c=0;c`:this.name}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}}e.exports=s},function(e,t,n){var i=t;i.Reporter=n(143).Reporter,i.DecoderBuffer=n(84).DecoderBuffer,i.EncoderBuffer=n(84).EncoderBuffer,i.Node=n(142)},function(e,t,n){(function(t){e.exports=function(e,n){for(var i=Math.min(e.length,n.length),r=new t(i),s=0;s65536)throw new Error("requested too many random bytes");var s=new t.Uint8Array(e);e>0&&o.getRandomValues(s);var a=new n(s.buffer);return"function"==typeof r?i.nextTick(function(){r(null,a)}):a}var o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=s:e.exports=r}).call(t,n(18),n(0).Buffer,n(8))},function(e,t,n){function i(e,t){Object.defineProperty(e.prototype,t,Object.getOwnPropertyDescriptor(h.prototype,t))}const r=n(23),s=n(34),o=n(73),a=n(6),c=n(35);class h{constructor(){this.messages=new a,this.lastMessageID=null}sendMessage(e,t={}){return this.client.rest.methods.sendMessage(this,e,t)}sendTTSMessage(e,t={}){return Object.assign(t,{tts:!0}),this.client.rest.methods.sendMessage(this,e,t)}sendFile(e,t,n,i={}){return t||(t="string"==typeof e?r.basename(e):e&&e.path?r.basename(e.path):"file.jpg"),this.client.resolver.resolveBuffer(e).then(e=>this.client.rest.methods.sendMessage(this,n,i,{file:e,name:t}))}sendCode(e,t,n={}){return n.split&&("object"!=typeof n.split&&(n.split={}),n.split.prepend||(n.split.prepend=`\`\`\`${e||""} -`),n.split.append||(n.split.append="\n```")),t=c(this.client.resolver.resolveString(t),!0),this.sendMessage(`\`\`\`${e||""} +!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=196)}([function(e,t,n){(function(e){t.Package=n(38),t.DefaultOptions={apiRequestMethod:"sequential",shardId:0,shardCount:0,messageCacheMaxSize:200,messageCacheLifetime:0,messageSweepInterval:0,fetchAllMembers:!1,disableEveryone:!1,sync:!1,restWsBridgeTimeout:5e3,disabledEvents:[],ws:{large_threshold:250,compress:"undefined"==typeof window,properties:{$os:e?e.platform:"discord.js",$browser:"discord.js",$device:"discord.js",$referrer:"",$referring_domain:""}}},t.Errors={NO_TOKEN:"Request to use token, but token was unavailable to the client.",NO_BOT_ACCOUNT:"Only bot accounts are able to make use of this feature.",NO_USER_ACCOUNT:"Only user accounts are able to make use of this feature.",BAD_WS_MESSAGE:"A bad message was received from the websocket; either bad compression, or not JSON.",TOOK_TOO_LONG:"Something took too long to do.",NOT_A_PERMISSION:"Invalid permission string or number.",INVALID_RATE_LIMIT_METHOD:"Unknown rate limiting method.",BAD_LOGIN:"Incorrect login details were provided.",INVALID_SHARD:"Invalid shard settings were provided."};const i=t.PROTOCOL_VERSION=6,r=t.API=`https://discordapp.com/api/v${i}`,s=t.Endpoints={login:`${r}/auth/login`,logout:`${r}/auth/logout`,gateway:`${r}/gateway`,botGateway:`${r}/gateway/bot`,invite:e=>`${r}/invite/${e}`,inviteLink:e=>`https://discord.gg/${e}`,CDN:"https://cdn.discordapp.com",user:e=>`${r}/users/${e}`,userChannels:e=>`${s.user(e)}/channels`,userProfile:e=>`${s.user(e)}/profile`,avatar:(e,t)=>"1"===e?t:`${s.user(e)}/avatars/${t}.jpg`,me:`${r}/users/@me`,meGuild:e=>`${s.me}/guilds/${e}`,relationships:e=>`${s.user(e)}/relationships`,note:e=>`${s.me}/notes/${e}`,guilds:`${r}/guilds`,guild:e=>`${s.guilds}/${e}`,guildIcon:(e,t)=>`${s.guild(e)}/icons/${t}.jpg`,guildPrune:e=>`${s.guild(e)}/prune`,guildEmbed:e=>`${s.guild(e)}/embed`,guildInvites:e=>`${s.guild(e)}/invites`,guildRoles:e=>`${s.guild(e)}/roles`,guildRole:(e,t)=>`${s.guildRoles(e)}/${t}`,guildBans:e=>`${s.guild(e)}/bans`,guildIntegrations:e=>`${s.guild(e)}/integrations`,guildMembers:e=>`${s.guild(e)}/members`,guildMember:(e,t)=>`${s.guildMembers(e)}/${t}`,stupidInconsistentGuildEndpoint:e=>`${s.guildMember(e,"@me")}/nick`,guildChannels:e=>`${s.guild(e)}/channels`,guildEmojis:e=>`${s.guild(e)}/emojis`,channels:`${r}/channels`,channel:e=>`${s.channels}/${e}`,channelMessages:e=>`${s.channel(e)}/messages`,channelInvites:e=>`${s.channel(e)}/invites`,channelTyping:e=>`${s.channel(e)}/typing`,channelPermissions:e=>`${s.channel(e)}/permissions`,channelMessage:(e,t)=>`${s.channelMessages(e)}/${t}`,channelWebhooks:e=>`${s.channel(e)}/webhooks`,messageReactions:(e,t)=>`${s.channelMessage(e,t)}/reactions`,messageReaction:(e,t,n,i)=>`${s.messageReactions(e,t)}/${n}`+`${i?`?limit=${i}`:""}`,selfMessageReaction:(e,t,n,i)=>`${s.messageReaction(e,t,n,i)}/@me`,userMessageReaction:(e,t,n,i,r)=>`${s.messageReaction(e,t,n,i)}/${r}`,webhook:(e,t)=>`${r}/webhooks/${e}${t?`/${t}`:""}`,myApplication:`${r}/oauth2/applications/@me`,getApp:e=>`${r}/oauth2/authorize?client_id=${e}`};t.Status={READY:0,CONNECTING:1,RECONNECTING:2,IDLE:3,NEARLY:4},t.ChannelTypes={text:0,DM:1,voice:2,groupDM:3},t.OPCodes={DISPATCH:0,HEARTBEAT:1,IDENTIFY:2,STATUS_UPDATE:3,VOICE_STATE_UPDATE:4,VOICE_GUILD_PING:5,RESUME:6,RECONNECT:7,REQUEST_GUILD_MEMBERS:8,INVALID_SESSION:9,HELLO:10,HEARTBEAT_ACK:11},t.VoiceOPCodes={IDENTIFY:0,SELECT_PROTOCOL:1,READY:2,HEARTBEAT:3,SESSION_DESCRIPTION:4,SPEAKING:5},t.Events={READY:"ready",GUILD_CREATE:"guildCreate",GUILD_DELETE:"guildDelete",GUILD_UPDATE:"guildUpdate",GUILD_UNAVAILABLE:"guildUnavailable",GUILD_AVAILABLE:"guildAvailable",GUILD_MEMBER_ADD:"guildMemberAdd",GUILD_MEMBER_REMOVE:"guildMemberRemove",GUILD_MEMBER_UPDATE:"guildMemberUpdate",GUILD_MEMBER_AVAILABLE:"guildMemberAvailable",GUILD_MEMBER_SPEAKING:"guildMemberSpeaking",GUILD_MEMBERS_CHUNK:"guildMembersChunk",GUILD_ROLE_CREATE:"roleCreate",GUILD_ROLE_DELETE:"roleDelete",GUILD_ROLE_UPDATE:"roleUpdate",GUILD_EMOJI_CREATE:"guildEmojiCreate",GUILD_EMOJI_DELETE:"guildEmojiDelete",GUILD_EMOJI_UPDATE:"guildEmojiUpdate",GUILD_BAN_ADD:"guildBanAdd",GUILD_BAN_REMOVE:"guildBanRemove",CHANNEL_CREATE:"channelCreate",CHANNEL_DELETE:"channelDelete",CHANNEL_UPDATE:"channelUpdate",CHANNEL_PINS_UPDATE:"channelPinsUpdate",MESSAGE_CREATE:"message",MESSAGE_DELETE:"messageDelete",MESSAGE_UPDATE:"messageUpdate",MESSAGE_BULK_DELETE:"messageDeleteBulk",MESSAGE_REACTION_ADD:"messageReactionAdd",MESSAGE_REACTION_REMOVE:"messageReactionRemove",MESSAGE_REACTION_REMOVE_ALL:"messageReactionRemoveAll",USER_UPDATE:"userUpdate",USER_NOTE_UPDATE:"userNoteUpdate",PRESENCE_UPDATE:"presenceUpdate",VOICE_STATE_UPDATE:"voiceStateUpdate",TYPING_START:"typingStart",TYPING_STOP:"typingStop",DISCONNECT:"disconnect",RECONNECTING:"reconnecting",ERROR:"error",WARN:"warn",DEBUG:"debug"},t.WSEvents={READY:"READY",GUILD_SYNC:"GUILD_SYNC",GUILD_CREATE:"GUILD_CREATE",GUILD_DELETE:"GUILD_DELETE",GUILD_UPDATE:"GUILD_UPDATE",GUILD_MEMBER_ADD:"GUILD_MEMBER_ADD",GUILD_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",GUILD_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",GUILD_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",GUILD_ROLE_CREATE:"GUILD_ROLE_CREATE",GUILD_ROLE_DELETE:"GUILD_ROLE_DELETE",GUILD_ROLE_UPDATE:"GUILD_ROLE_UPDATE",GUILD_BAN_ADD:"GUILD_BAN_ADD",GUILD_BAN_REMOVE:"GUILD_BAN_REMOVE",CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",CHANNEL_PINS_UPDATE:"CHANNEL_PINS_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",MESSAGE_DELETE_BULK:"MESSAGE_DELETE_BULK",MESSAGE_REACTION_ADD:"MESSAGE_REACTION_ADD",MESSAGE_REACTION_REMOVE:"MESSAGE_REACTION_REMOVE",MESSAGE_REACTION_REMOVE_ALL:"MESSAGE_REACTION_REMOVE_ALL",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",TYPING_START:"TYPING_START",FRIEND_ADD:"RELATIONSHIP_ADD",FRIEND_REMOVE:"RELATIONSHIP_REMOVE",VOICE_SERVER_UPDATE:"VOICE_SERVER_UPDATE",RELATIONSHIP_ADD:"RELATIONSHIP_ADD",RELATIONSHIP_REMOVE:"RELATIONSHIP_REMOVE"},t.MessageTypes={0:"DEFAULT",1:"RECIPIENT_ADD",2:"RECIPIENT_REMOVE",3:"CALL",4:"CHANNEL_NAME_CHANGE",5:"CHANNEL_ICON_CHANGE",6:"PINS_ADD"};const o=t.PermissionFlags={CREATE_INSTANT_INVITE:1,KICK_MEMBERS:2,BAN_MEMBERS:4,ADMINISTRATOR:8,MANAGE_CHANNELS:16,MANAGE_GUILD:32,ADD_REACTIONS:64,READ_MESSAGES:1024,SEND_MESSAGES:2048,SEND_TTS_MESSAGES:4096,MANAGE_MESSAGES:8192,EMBED_LINKS:16384,ATTACH_FILES:32768,READ_MESSAGE_HISTORY:65536,MENTION_EVERYONE:1<<17,EXTERNAL_EMOJIS:1<<18,CONNECT:1<<20,SPEAK:1<<21,MUTE_MEMBERS:1<<22,DEAFEN_MEMBERS:1<<23,MOVE_MEMBERS:1<<24,USE_VAD:1<<25,CHANGE_NICKNAME:1<<26,MANAGE_NICKNAMES:1<<27,MANAGE_ROLES_OR_PERMISSIONS:1<<28,MANAGE_WEBHOOKS:1<<29,MANAGE_EMOJIS:1<<30};let a=0;for(const h in o)a|=o[h];t.ALL_PERMISSIONS=a,t.DEFAULT_PERMISSIONS=104324097}).call(t,n(6))},function(e,t){class n{constructor(e){this.packetManager=e}handle(e){return e}}e.exports=n},function(e,t){class n{constructor(e){this.client=e}handle(e){return e}}e.exports=n},function(e,t){class n extends Map{constructor(e){super(e),this._array=null,this._keyArray=null}set(e,t){super.set(e,t),this._array=null,this._keyArray=null}delete(e){super.delete(e),this._array=null,this._keyArray=null}array(){return this._array&&this._array.length===this.size||(this._array=Array.from(this.values())),this._array}keyArray(){return this._keyArray&&this._keyArray.length===this.size||(this._keyArray=Array.from(this.keys())),this._keyArray}first(){return this.values().next().value}firstKey(){return this.keys().next().value}last(){const e=this.array();return e[e.length-1]}lastKey(){const e=this.keyArray();return e[e.length-1]}random(){const e=this.array();return e[Math.floor(Math.random()*e.length)]}randomKey(){const e=this.keyArray();return e[Math.floor(Math.random()*e.length)]}findAll(e,t){if("string"!=typeof e)throw new TypeError("Key must be a string.");if("undefined"==typeof t)throw new Error("Value must be specified.");const n=[];for(const i of this.values())i[e]===t&&n.push(i);return n}find(e,t){if("string"==typeof e){if("undefined"==typeof t)throw new Error("Value must be specified.");if("id"===e)throw new RangeError("Don't use .find() with IDs. Instead, use .get(id).");for(const n of this.values())if(n[e]===t)return n;return null}if("function"==typeof e){for(const[t,n]of this)if(e(n,t,this))return n;return null}throw new Error("First argument must be a property string or a function.")}findKey(e,t){if("string"==typeof e){if("undefined"==typeof t)throw new Error("Value must be specified.");for(const[n,i]of this)if(i[e]===t)return n;return null}if("function"==typeof e){for(const[t,n]of this)if(e(n,t,this))return t;return null}throw new Error("First argument must be a property string or a function.")}exists(e,t){if("id"===e)throw new RangeError("Don't use .exists() with IDs. Instead, use .has(id).");return Boolean(this.find(e,t))}filter(e,t){t&&(e=e.bind(t));const i=new n;for(const[r,s]of this)e(s,r,this)&&i.set(r,s);return i}filterArray(e,t){t&&(e=e.bind(t));const n=[];for(const[i,r]of this)e(r,i,this)&&n.push(r);return n}map(e,t){t&&(e=e.bind(t));const n=new Array(this.size);let i=0;for(const[r,s]of this)n[i++]=e(s,r,this);return n}some(e,t){t&&(e=e.bind(t));for(const[n,i]of this)if(e(i,n,this))return!0;return!1}every(e,t){t&&(e=e.bind(t));for(const[n,i]of this)if(!e(i,n,this))return!1;return!0}reduce(e,t){let n=t;for(const[i,r]of this)n=e(n,r,i,this);return n}concat(...e){const t=new this.constructor;for(const[n,i]of this)t.set(n,i);for(const r of e)for(const[n,i]of r)t.set(n,i);return t}deleteAll(){const e=[];for(const t of this.values())t.delete&&e.push(t.delete());return e}}e.exports=n},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function r(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!r(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,r,a,h,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(n=this._events[e],o(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(s(n))for(a=Array.prototype.slice.call(arguments,1),u=n.slice(),r=u.length,h=0;h0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,r,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";(function(e,i){function r(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}function s(){return e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,n){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function m(t){return+t!=t&&(t=0),e.alloc(+t)}function _(t,n){if(e.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var r=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return V(t).length;default:if(r)return H(t).length;n=(""+n).toLowerCase(),r=!0}}function w(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,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return L(this,t,n);case"utf8":case"utf-8":return D(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return U(this,t,n);case"base64":return M(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function v(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function y(t,n,i,r,s){if(0===t.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(s)return-1;i=t.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof n&&(n=e.from(n,r)),e.isBuffer(n))return 0===n.length?-1:b(t,n,i,r,s);if("number"==typeof n)return n&=255,e.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,n,i):Uint8Array.prototype.lastIndexOf.call(t,n,i):b(t,[n],i,r,s);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,i,r){function s(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,h=t.length;if(void 0!==i&&(i=String(i).toLowerCase(),"ucs2"===i||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,h/=2,n/=2}var u;if(r){var c=-1;for(u=n;ua&&(n=a-h),u=n;u>=0;u--){for(var l=!0,f=0;fr&&(i=r)):i=r;var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o239?4:s>223?3:s>191?2:1;if(r+a<=n){var h,u,c,l;switch(a){case 1:s<128&&(o=s);break;case 2:h=e[r+1],128===(192&h)&&(l=(31&s)<<6|63&h,l>127&&(o=l));break;case 3:h=e[r+1],u=e[r+2],128===(192&h)&&128===(192&u)&&(l=(15&s)<<12|(63&h)<<6|63&u,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:h=e[r+1],u=e[r+2],c=e[r+3],128===(192&h)&&128===(192&u)&&128===(192&c)&&(l=(15&s)<<18|(63&h)<<12|(63&u)<<6|63&c,l>65535&&l<1114112&&(o=l))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),r+=a}return x(i)}function x(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var n="",i=0;ii)&&(n=i);for(var r="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function O(t,n,i,r,s,o){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>s||nt.length)throw new RangeError("Index out of range")}function N(e,t,n,i){t<0&&(t=65535+t+1);for(var r=0,s=Math.min(e.length-n,2);r>>8*(i?r:1-r)}function B(e,t,n,i){t<0&&(t=4294967295+t+1);for(var r=0,s=Math.min(e.length-n,4);r>>8*(i?r:3-r)&255}function G(e,t,n,i,r,s){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(e,t,n,i,r){return r||G(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(e,t,n,i,23,4),n+4}function z(e,t,n,i,r){return r||G(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(e,t,n,i,52,8),n+8}function q(e){if(e=F(e).replace(te,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function F(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function W(e){return e<16?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var n,i=e.length,r=null,s=[],o=0;o55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),r=n;continue}n=(r-55296<<10|n-56320)+65536}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function Z(e){for(var t=[],n=0;n>8,r=n%256,s.push(r),s.push(i);return s}function V(e){return J.toByteArray(q(e))}function K(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function X(e){return e!==e}var J=n(81),$=n(85),Q=n(58);t.Buffer=e,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,e.TYPED_ARRAY_SUPPORT=void 0!==i.TYPED_ARRAY_SUPPORT?i.TYPED_ARRAY_SUPPORT:r(),t.kMaxLength=s(),e.poolSize=8192,e._augment=function(t){return t.__proto__=e.prototype,t},e.from=function(e,t,n){return a(null,e,t,n)},e.TYPED_ARRAY_SUPPORT&&(e.prototype.__proto__=Uint8Array.prototype,e.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&e[Symbol.species]===e&&Object.defineProperty(e,Symbol.species,{value:null,configurable:!0})),e.alloc=function(e,t,n){return u(null,e,t,n)},e.allocUnsafe=function(e){return c(null,e)},e.allocUnsafeSlow=function(e){return c(null,e)},e.isBuffer=function(e){return!(null==e||!e._isBuffer)},e.compare=function(t,n){if(!e.isBuffer(t)||!e.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var i=t.length,r=n.length,s=0,o=Math.min(i,r);s0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},e.prototype.compare=function(t,n,i,r,s){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===i&&(i=t?t.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),n<0||i>t.length||r<0||s>this.length)throw new RangeError("out of range index");if(r>=s&&n>=i)return 0;if(r>=s)return-1;if(n>=i)return 1;if(n>>>=0,i>>>=0,r>>>=0,s>>>=0,this===t)return 0;for(var o=s-r,a=i-n,h=Math.min(o,a),u=this.slice(r,s),c=t.slice(n,i),l=0;lr)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return A(this,e,t,n);case"ascii":return k(this,e,t,n);case"latin1":case"binary":return S(this,e,t,n);case"base64":return T(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;e.prototype.slice=function(t,n){var i=this.length;t=~~t,n=void 0===n?i:~~n,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),n<0?(n+=i,n<0&&(n=0)):n>i&&(n=i),n0&&(r*=256);)i+=this[e+--t]*r;return i},e.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},e.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},e.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},e.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var i=this[e],r=1,s=0;++s=r&&(i-=Math.pow(2,8*t)),i},e.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var i=t,r=1,s=this[e+--i];i>0&&(r*=256);)s+=this[e+--i]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},e.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},e.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},e.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},e.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},e.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},e.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),$.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),$.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),$.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),$.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t|=0,n|=0,!i){var r=Math.pow(2,8*n)-1;O(this,e,t,n,r,0)}var s=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+s]=e/o&255;return t+n},e.prototype.writeUInt8=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,1,255,0),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=255&t,n+1},e.prototype.writeUInt16LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):N(this,t,n,!0),n+2},e.prototype.writeUInt16BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):N(this,t,n,!1),n+2},e.prototype.writeUInt32LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,4294967295,0),e.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):B(this,t,n,!0),n+4},e.prototype.writeUInt32BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,4294967295,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):B(this,t,n,!1),n+4},e.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);O(this,e,t,n,r-1,-r)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t|=0,!i){var r=Math.pow(2,8*n-1);O(this,e,t,n,r-1,-r)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},e.prototype.writeInt8=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,1,127,-128),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=255&t,n+1},e.prototype.writeInt16LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):N(this,t,n,!0),n+2},e.prototype.writeInt16BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):N(this,t,n,!1),n+2},e.prototype.writeInt32LE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,2147483647,-2147483648),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):B(this,t,n,!0),n+4},e.prototype.writeInt32BE=function(t,n,i){return t=+t,n|=0,i||O(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):B(this,t,n,!1),n+4},e.prototype.writeFloatLE=function(e,t,n){ +return j(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return j(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return z(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return z(this,e,t,!1,n)},e.prototype.copy=function(t,n,i,r){if(i||(i=0),r||0===r||(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n=0;--s)t[s+n]=this[s+i];else if(o<1e3||!e.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,i=void 0===i?this.length:i>>>0,t||(t=0);var o;if("number"==typeof t)for(o=n;o1)for(var n=1;n`}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}}i.applyToClass(o),e.exports=o},function(e,t){class n{constructor(e={}){this.status=e.status||"offline",this.game=e.game?new i(e.game):null}update(e){this.status=e.status||this.status,this.game=e.game?new i(e.game):null}equals(e){return e&&this.status===e.status&&this.game?this.game.equals(e.game):!e.game}}class i{constructor(e){this.name=e.name,this.type=e.type,this.url=e.url||null}get streaming(){return 1===this.type}equals(e){return e&&this.name===e.name&&this.type===e.type&&this.url===e.url}}t.Presence=n,t.Game=i},function(e,t,n){"use strict";function i(e){return this instanceof i?(u.call(this,e),c.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",r)):new i(e)}function r(){this.allowHalfOpen||this._writableState.ended||a(s,this)}function s(e){e.end()}var o=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=i;var a=n(32),h=n(16);h.inherits=n(12);var u=n(63),c=n(34);h.inherits(i,u);for(var l=o(c.prototype),f=0;fe.roles.has(this.id))}serialize(){const e={};for(const t in i.PermissionFlags)e[t]=this.hasPermission(t);return e}hasPermission(e,t=false){return e=this.client.resolver.resolvePermission(e),!t&&(this.permissions&i.PermissionFlags.ADMINISTRATOR)>0||(this.permissions&e)>0}hasPermissions(e,t=false){return e.every(e=>this.hasPermission(e,t))}comparePositionTo(e){return this.constructor.comparePositions(this,e)}edit(e){return this.client.rest.methods.updateGuildRole(this,e)}setName(e){return this.edit({name:e})}setColor(e){return this.edit({color:e})}setHoist(e){return this.edit({hoist:e})}setPosition(e){return this.guild.setRolePosition(this,e)}setPermissions(e){return this.edit({permissions:e})}setMentionable(e){return this.edit({mentionable:e})}delete(){return this.client.rest.methods.deleteGuildRole(this)}get editable(){if(this.managed)return!1;const e=this.guild.member(this.client.user);return!!e.hasPermission(i.PermissionFlags.MANAGE_ROLES_OR_PERMISSIONS)&&e.highestRole.comparePositionTo(this)>0}equals(e){return e&&this.id===e.id&&this.name===e.name&&this.color===e.color&&this.hoist===e.hoist&&this.position===e.position&&this.permissions===e.permissions&&this.managed===e.managed}toString(){return`<@&${this.id}>`}static comparePositions(e,t){return e.position===t.position?t.id-e.id:e.position-t.position}}e.exports=r},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){},function(e,t){class n{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.type=null,t&&this.setup(t)}setup(e){this.id=e.id}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}delete(){return this.client.rest.methods.deleteChannel(this)}}e.exports=n},function(e,t,n){const i=n(0),r=n(3);class s{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.guild=e,this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.requiresColons=e.require_colons,this.managed=e.managed,this._roles=e.roles}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}get roles(){const e=new r;for(const t of this._roles)this.guild.roles.has(t)&&e.set(t,this.guild.roles.get(t));return e}get url(){return`${i.Endpoints.CDN}/emojis/${this.id}.png`}toString(){return this.requiresColons?`<:${this.name}:${this.id}>`:this.name}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}}e.exports=s},function(e,t,n){(function(e){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===m(e)}function i(e){return"boolean"==typeof e}function r(e){return null===e}function s(e){return null==e}function o(e){return"number"==typeof e}function a(e){return"string"==typeof e}function h(e){return"symbol"==typeof e}function u(e){return void 0===e}function c(e){return"[object RegExp]"===m(e)}function l(e){return"object"==typeof e&&null!==e}function f(e){return"[object Date]"===m(e)}function d(e){return"[object Error]"===m(e)||e instanceof Error}function p(e){return"function"==typeof e}function g(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function m(e){return Object.prototype.toString.call(e)}t.isArray=n,t.isBoolean=i,t.isNull=r,t.isNullOrUndefined=s,t.isNumber=o,t.isString=a,t.isSymbol=h,t.isUndefined=u,t.isRegExp=c,t.isObject=l,t.isDate=f,t.isError=d,t.isFunction=p,t.isPrimitive=g,t.isBuffer=e.isBuffer}).call(t,n(5).Buffer)},function(e,t,n){(function(e){function n(e,t){for(var n=0,i=e.length-1;i>=0;i--){var r=e[i];"."===r?e.splice(i,1):".."===r?(e.splice(i,1),n++):n&&(e.splice(i,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function i(e,t){if(e.filter)return e.filter(t);for(var n=[],i=0;i=-1&&!r;s--){var o=s>=0?arguments[s]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,r="/"===o.charAt(0))}return t=n(i(t.split("/"),function(e){return!!e}),!r).join("/"),(r?"/":"")+t||"."},t.normalize=function(e){var r=t.isAbsolute(e),s="/"===o(e,-1);return e=n(i(e.split("/"),function(e){return!!e}),!r).join("/"),e||r||(e="."),e&&s&&(e+="/"),(r?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(i(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function i(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var r=i(e.split("/")),s=i(n.split("/")),o=Math.min(r.length,s.length),a=o,h=0;hthis.client.rest.methods.sendMessage(this,n,i,{file:e,name:t}))}sendCode(e,t,n={}){return n.split&&("object"!=typeof n.split&&(n.split={}),n.split.prepend||(n.split.prepend=`\`\`\`${e||""} +`),n.split.append||(n.split.append="\n```")),t=h(this.client.resolver.resolveString(t),!0),this.sendMessage(`\`\`\`${e||""} ${t} -\`\`\``,n)}fetchMessage(e){return this.client.rest.methods.getChannelMessage(this,e).then(e=>{const t=e instanceof s?e:new s(this,e,this.client);return this._cacheMessage(t),t})}fetchMessages(e={}){return this.client.rest.methods.getChannelMessages(this,e).then(e=>{const t=new a;for(const n of e){const e=new s(this,n,this.client);t.set(n.id,e),this._cacheMessage(e)}return t})}fetchPinnedMessages(){return this.client.rest.methods.getChannelPinnedMessages(this).then(e=>{const t=new a;for(const n of e){const e=new s(this,n,this.client);t.set(n.id,e),this._cacheMessage(e)}return t})}startTyping(e){if("undefined"!=typeof e&&e<1)throw new RangeError("Count must be at least 1.");if(this.client.user._typing.has(this.id)){const t=this.client.user._typing.get(this.id);t.count=e||t.count+1}else this.client.user._typing.set(this.id,{count:e||1,interval:this.client.setInterval(()=>{this.client.rest.methods.sendTyping(this.id)},4e3)}),this.client.rest.methods.sendTyping(this.id)}stopTyping(e=false){if(this.client.user._typing.has(this.id)){const t=this.client.user._typing.get(this.id);t.count--,(t.count<=0||e)&&(this.client.clearInterval(t.interval),this.client.user._typing.delete(this.id))}}get typing(){return this.client.user._typing.has(this.id)}get typingCount(){return this.client.user._typing.has(this.id)?this.client.user._typing.get(this.id).count:0}createCollector(e,t={}){return new o(this,e,t)}awaitMessages(e,t={}){return new Promise((n,i)=>{const r=this.createCollector(e,t);r.on("end",(e,r)=>{t.errors&&t.errors.includes(r)?i(e):n(e)})})}bulkDelete(e){if(!isNaN(e))return this.fetchMessages({limit:e}).then(e=>this.bulkDelete(e));if(e instanceof Array||e instanceof a){const t=e instanceof a?e.keyArray():e.map(e=>e.id);return this.client.rest.methods.bulkDeleteMessages(this,t)}throw new TypeError("The messages must be an Array, Collection, or number.")}_cacheMessage(e){const t=this.client.options.messageCacheMaxSize;return 0===t?null:(this.messages.size>=t&&t>0&&this.messages.delete(this.messages.firstKey()),this.messages.set(e.id,e),e)}}t.applyToClass=((e,t=false)=>{const n=["sendMessage","sendTTSMessage","sendFile","sendCode"];t&&(n.push("_cacheMessage"),n.push("fetchMessages"),n.push("fetchMessage"),n.push("bulkDelete"),n.push("startTyping"),n.push("stopTyping"),n.push("typing"),n.push("typingCount"),n.push("fetchPinnedMessages"),n.push("createCollector"),n.push("awaitMessages"));for(const r of n)i(e,r)})},function(e,t,n){const i=n(24),r=n(19),s=n(79),o=n(46),a=n(1),c=n(6),h=n(63);class f extends i{constructor(e,t){super(e.client,t),this.guild=e}setup(e){if(super.setup(e),this.name=e.name,this.position=e.position,this.permissionOverwrites=new c,e.permission_overwrites)for(const t of e.permission_overwrites)this.permissionOverwrites.set(t.id,new s(this,t))}permissionsFor(e){if(e=this.client.resolver.resolveGuildMember(this.guild,e),!e)return null;if(e.id===this.guild.ownerID)return new o(e,a.ALL_PERMISSIONS);let t=0;const n=e.roles;for(const i of n.values())t|=i.permissions;const r=this.overwritesFor(e,!0,n);for(const s of r.role.concat(r.member))t&=~s.denyData,t|=s.allowData;const c=Boolean(t&a.PermissionFlags.ADMINISTRATOR);return c&&(t=a.ALL_PERMISSIONS),new o(e,t)}overwritesFor(e,t=false,n=null){if(t||(e=this.client.resolver.resolveGuildMember(this.guild,e)),!e)return[];n=n||e.roles;const i=[],r=[];for(const s of this.permissionOverwrites.values())s.id===e.id?r.push(s):n.has(s.id)&&i.push(s);return{role:i,member:r}}overwritePermissions(e,t){const n={allow:0,deny:0};if(e instanceof r)n.type="role";else if(this.guild.roles.has(e))e=this.guild.roles.get(e),n.type="role";else if(e=this.client.resolver.resolveUser(e),n.type="member",!e)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));n.id=e.id;const i=this.permissionOverwrites.get(e.id);i&&(n.allow=i.allowData,n.deny=i.denyData);for(const s in t)t[s]===!0?(n.allow|=a.PermissionFlags[s]||0,n.deny&=~(a.PermissionFlags[s]||0)):t[s]===!1?(n.allow&=~(a.PermissionFlags[s]||0),n.deny|=a.PermissionFlags[s]||0):null===t[s]&&(n.allow&=~(a.PermissionFlags[s]||0),n.deny&=~(a.PermissionFlags[s]||0));return this.client.rest.methods.setChannelOverwrite(this,n)}edit(e){return this.client.rest.methods.updateChannel(this,e)}setName(e){return this.edit({name:e})}setPosition(e){return this.client.rest.methods.updateChannel(this,{position:e})}setTopic(e){return this.client.rest.methods.updateChannel(this,{topic:e})}createInvite(e={}){return this.client.rest.methods.createChannelInvite(this,e)}equals(e){let t=e&&this.id===e.id&&this.type===e.type&&this.topic===e.topic&&this.position===e.position&&this.name===e.name;if(t)if(this.permissionOverwrites&&e.permissionOverwrites){const n=this.permissionOverwrites.keyArray(),i=e.permissionOverwrites.keyArray();t=h(n,i)}else t=!this.permissionOverwrites&&!e.permissionOverwrites;return t}toString(){return`<#${this.id}>`}}e.exports=f},function(e,t,n){const i=n(31),r=n(19),s=n(46),o=n(1),a=n(6),c=n(15).Presence;class h{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.guild=e,this.user={},this._roles=[],t&&this.setup(t)}setup(e){this.serverDeaf=e.deaf,this.serverMute=e.mute,this.selfMute=e.self_mute,this.selfDeaf=e.self_deaf,this.voiceSessionID=e.session_id,this.voiceChannelID=e.channel_id,this.speaking=!1,this.nickname=e.nick||null,this.joinedTimestamp=new Date(e.joined_at).getTime(),this.user=e.user,this._roles=e.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new c}get roles(){const e=new a,t=this.guild.roles.get(this.guild.id);t&&e.set(t.id,t);for(const n of this._roles){const t=this.guild.roles.get(n);t&&e.set(t.id,t)}return e}get highestRole(){return this.roles.reduce((e,t)=>!e||t.comparePositionTo(e)>0?t:e)}get mute(){return this.selfMute||this.serverMute}get deaf(){return this.selfDeaf||this.serverDeaf}get voiceChannel(){return this.guild.channels.get(this.voiceChannelID)}get id(){return this.user.id}get permissions(){if(this.user.id===this.guild.ownerID)return new s(this,o.ALL_PERMISSIONS);let e=0;const t=this.roles;for(const n of t.values())e|=n.permissions;const i=Boolean(e&o.PermissionFlags.ADMINISTRATOR);return i&&(e=o.ALL_PERMISSIONS),new s(this,e)}get kickable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const e=this.guild.member(this.client.user);return!!e.hasPermission(o.PermissionFlags.KICK_MEMBERS)&&e.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const e=this.guild.member(this.client.user);return!!e.hasPermission(o.PermissionFlags.BAN_MEMBERS)&&e.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(e){if(e=this.client.resolver.resolveChannel(e),!e||!e.guild)throw new Error("Could not resolve channel to a guild channel.");return e.permissionsFor(this)}hasPermission(e,t=false){return!t&&this.user.id===this.guild.ownerID||this.roles.some(n=>n.hasPermission(e,t))}hasPermissions(e,t=false){return!t&&this.user.id===this.guild.ownerID||e.every(e=>this.hasPermission(e,t))}missingPermissions(e,t=false){return e.filter(e=>!this.hasPermission(e,t))}edit(e){return this.client.rest.methods.updateGuildMember(this,e)}setMute(e){return this.edit({mute:e})}setDeaf(e){return this.edit({deaf:e})}setVoiceChannel(e){return this.edit({channel:e})}setRoles(e){return this.edit({roles:e})}addRole(e){return this.addRoles([e])}addRoles(e){let t;if(e instanceof a){t=this._roles.slice();for(const n of e.values())t.push(n.id)}else t=this._roles.concat(e);return this.edit({roles:t})}removeRole(e){return this.removeRoles([e])}removeRoles(e){const t=this._roles.slice();if(e instanceof a)for(const n of e.values()){const e=t.indexOf(n.id);e>=0&&t.splice(e,1)}else for(const n of e){const e=t.indexOf(n instanceof r?n.id:n);e>=0&&t.splice(e,1)}return this.edit({roles:t})}setNickname(e){return this.edit({nick:e})}deleteDM(){return this.client.rest.methods.deleteChannel(this)}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(e=0){return this.client.rest.methods.banGuildMember(this.guild,this,e)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}}i.applyToClass(h),e.exports=h},function(e,t,n){const i=n(72),r=n(74),s=n(6),o=n(1),a=n(35),c=n(75);class h{constructor(e,t,n){this.client=n,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.channel=e,t&&this.setup(t)}setup(e){this.id=e.id,this.type=o.MessageTypes[e.type],this.content=e.content,this.author=this.client.dataManager.newUser(e.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=e.pinned,this.tts=e.tts,this.nonce=e.nonce,this.system=6===e.type,this.embeds=e.embeds.map(e=>new r(this,e)),this.attachments=new s;for(const t of e.attachments)this.attachments.set(t.id,new i(this,t));this.createdTimestamp=new Date(e.timestamp).getTime(),this.editedTimestamp=e.edited_timestamp?new Date(e.edited_timestamp).getTime():null,this.mentions={users:new s,roles:new s,channels:new s,everyone:e.mention_everyone};for(const n of e.mentions){let e=this.client.users.get(n.id);e?this.mentions.users.set(e.id,e):(e=this.client.dataManager.newUser(n),this.mentions.users.set(e.id,e))}if(e.mention_roles)for(const n of e.mention_roles){const e=this.channel.guild.roles.get(n);e&&this.mentions.roles.set(e.id,e)}if(this.channel.guild){const t=e.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of t){const e=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);e&&this.mentions.channels.set(e.id,e)}}if(this._edits=[],this.reactions=new s,e.reactions&&e.reactions.length>0)for(const a of e.reactions){const e=a.emoji.id?`${a.emoji.name}:${a.emoji.id}`:a.emoji.name;this.reactions.set(e,new c(this,a.emoji,a.count,a.me))}}patch(e){if(e.author&&(this.author=this.client.users.get(e.author.id),this.guild&&(this.member=this.guild.member(this.author))),e.content&&(this.content=e.content),e.timestamp&&(this.createdTimestamp=new Date(e.timestamp).getTime()),e.edited_timestamp&&(this.editedTimestamp=e.edited_timestamp?new Date(e.edited_timestamp).getTime():null),"tts"in e&&(this.tts=e.tts),"mention_everyone"in e&&(this.mentions.everyone=e.mention_everyone),e.nonce&&(this.nonce=e.nonce),e.embeds&&(this.embeds=e.embeds.map(e=>new r(this,e))),e.type>-1&&(this.system=!1,6===e.type&&(this.system=!0)),e.attachments){this.attachments=new s;for(const t of e.attachments)this.attachments.set(t.id,new i(this,t))}if(e.mentions)for(const t of e.mentions){let e=this.client.users.get(t.id);e?this.mentions.users.set(e.id,e):(e=this.client.dataManager.newUser(t),this.mentions.users.set(e.id,e))}if(e.mention_roles)for(const t of e.mention_roles){const e=this.channel.guild.roles.get(t);e&&this.mentions.roles.set(e.id,e)}if(e.id&&(this.id=e.id),this.channel.guild&&e.content){const t=e.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of t){const e=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);e&&this.mentions.channels.set(e.id,e)}}if(e.reactions&&(this.reactions=new s,e.reactions.length>0))for(const n of e.reactions){const t=n.emoji.id?`${n.emoji.name}:${n.emoji.id}`:n.emoji.name;this.reactions.set(t,new c(this,e.emoji,e.count,e.me))}}get createdAt(){return new Date(this.createdTimestamp)}get editedAt(){return this.editedTimestamp?new Date(this.editedTimestamp):null}get guild(){return this.channel.guild||null}get cleanContent(){return this.content.replace(/@(everyone|here)/g,"@​$1").replace(/<@!?[0-9]+>/g,e=>{const t=e.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(t)?`@${this.client.users.get(t).username}`:e;const n=this.channel.guild.members.get(t);if(n)return n.nickname?`@${n.nickname}`:`@${n.user.username}`;{const n=this.client.users.get(t);return n?`@${n.username}`:e}}).replace(/<#[0-9]+>/g,e=>{const t=this.client.channels.get(e.replace(/<|#|>/g,""));return t?`#${t.name}`:e}).replace(/<@&[0-9]+>/g,e=>{if("dm"===this.channel.type||"group"===this.channel.type)return e;const t=this.guild.roles.get(e.replace(/<|@|>|&/g,""));return t?`@${t.name}`:e})}get edits(){return this._edits.slice().unshift(this)}get editable(){return this.author.id===this.client.user.id}get deletable(){return this.author.id===this.client.user.id||this.guild&&this.channel.permissionsFor(this.client.user).hasPermission(o.PermissionFlags.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).hasPermission(o.PermissionFlags.MANAGE_MESSAGES)}isMentioned(e){return e=e&&e.id?e.id:e,this.mentions.users.has(e)||this.mentions.channels.has(e)||this.mentions.roles.has(e)}edit(e,t={}){return this.client.rest.methods.updateMessage(this,e,t)}editCode(e,t){return t=a(this.client.resolver.resolveString(t),!0),this.edit(`\`\`\`${e||""} +\`\`\``,n)}fetchMessage(e){return this.client.rest.methods.getChannelMessage(this,e).then(e=>{const t=e instanceof s?e:new s(this,e,this.client);return this._cacheMessage(t),t})}fetchMessages(e={}){return this.client.rest.methods.getChannelMessages(this,e).then(e=>{const t=new a;for(const n of e){const e=new s(this,n,this.client);t.set(n.id,e),this._cacheMessage(e)}return t})}fetchPinnedMessages(){return this.client.rest.methods.getChannelPinnedMessages(this).then(e=>{const t=new a;for(const n of e){const e=new s(this,n,this.client);t.set(n.id,e),this._cacheMessage(e)}return t})}startTyping(e){if("undefined"!=typeof e&&e<1)throw new RangeError("Count must be at least 1.");if(this.client.user._typing.has(this.id)){const t=this.client.user._typing.get(this.id);t.count=e||t.count+1}else this.client.user._typing.set(this.id,{count:e||1,interval:this.client.setInterval(()=>{this.client.rest.methods.sendTyping(this.id)},4e3)}),this.client.rest.methods.sendTyping(this.id)}stopTyping(e=false){if(this.client.user._typing.has(this.id)){const t=this.client.user._typing.get(this.id);t.count--,(t.count<=0||e)&&(this.client.clearInterval(t.interval),this.client.user._typing.delete(this.id))}}get typing(){return this.client.user._typing.has(this.id)}get typingCount(){return this.client.user._typing.has(this.id)?this.client.user._typing.get(this.id).count:0}createCollector(e,t={}){return new o(this,e,t)}awaitMessages(e,t={}){return new Promise((n,i)=>{const r=this.createCollector(e,t);r.on("end",(e,r)=>{t.errors&&t.errors.includes(r)?i(e):n(e)})})}bulkDelete(e){if(!isNaN(e))return this.fetchMessages({limit:e}).then(e=>this.bulkDelete(e));if(e instanceof Array||e instanceof a){const t=e instanceof a?e.keyArray():e.map(e=>e.id);return this.client.rest.methods.bulkDeleteMessages(this,t)}throw new TypeError("The messages must be an Array, Collection, or number.")}_cacheMessage(e){const t=this.client.options.messageCacheMaxSize;return 0===t?null:(this.messages.size>=t&&t>0&&this.messages.delete(this.messages.firstKey()),this.messages.set(e.id,e),e)}}t.applyToClass=((e,t=false)=>{const n=["sendMessage","sendTTSMessage","sendFile","sendCode"];t&&(n.push("_cacheMessage"),n.push("fetchMessages"),n.push("fetchMessage"),n.push("bulkDelete"),n.push("startTyping"),n.push("stopTyping"),n.push("typing"),n.push("typingCount"),n.push("fetchPinnedMessages"),n.push("createCollector"),n.push("awaitMessages"));for(const r of n)i(e,r)})},function(e,t,n){const i=n(14),r=n(11),s=n(53),o=n(27),a=n(0),h=n(3),u=n(37);class c extends i{constructor(e,t){super(e.client,t),this.guild=e}setup(e){if(super.setup(e),this.name=e.name,this.position=e.position,this.permissionOverwrites=new h,e.permission_overwrites)for(const t of e.permission_overwrites)this.permissionOverwrites.set(t.id,new s(this,t))}permissionsFor(e){if(e=this.client.resolver.resolveGuildMember(this.guild,e),!e)return null;if(e.id===this.guild.ownerID)return new o(e,a.ALL_PERMISSIONS);let t=0;const n=e.roles;for(const i of n.values())t|=i.permissions;const r=this.overwritesFor(e,!0,n);for(const s of r.role.concat(r.member))t&=~s.denyData,t|=s.allowData;const h=Boolean(t&a.PermissionFlags.ADMINISTRATOR);return h&&(t=a.ALL_PERMISSIONS),new o(e,t)}overwritesFor(e,t=false,n=null){if(t||(e=this.client.resolver.resolveGuildMember(this.guild,e)),!e)return[];n=n||e.roles;const i=[],r=[];for(const s of this.permissionOverwrites.values())s.id===e.id?r.push(s):n.has(s.id)&&i.push(s);return{role:i,member:r}}overwritePermissions(e,t){const n={allow:0,deny:0};if(e instanceof r)n.type="role";else if(this.guild.roles.has(e))e=this.guild.roles.get(e),n.type="role";else if(e=this.client.resolver.resolveUser(e),n.type="member",!e)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));n.id=e.id;const i=this.permissionOverwrites.get(e.id);i&&(n.allow=i.allowData,n.deny=i.denyData);for(const s in t)t[s]===!0?(n.allow|=a.PermissionFlags[s]||0,n.deny&=~(a.PermissionFlags[s]||0)):t[s]===!1?(n.allow&=~(a.PermissionFlags[s]||0),n.deny|=a.PermissionFlags[s]||0):null===t[s]&&(n.allow&=~(a.PermissionFlags[s]||0),n.deny&=~(a.PermissionFlags[s]||0));return this.client.rest.methods.setChannelOverwrite(this,n)}edit(e){return this.client.rest.methods.updateChannel(this,e)}setName(e){return this.edit({name:e})}setPosition(e){return this.client.rest.methods.updateChannel(this,{position:e})}setTopic(e){return this.client.rest.methods.updateChannel(this,{topic:e})}createInvite(e={}){return this.client.rest.methods.createChannelInvite(this,e)}equals(e){let t=e&&this.id===e.id&&this.type===e.type&&this.topic===e.topic&&this.position===e.position&&this.name===e.name;if(t)if(this.permissionOverwrites&&e.permissionOverwrites){const n=this.permissionOverwrites.keyArray(),i=e.permissionOverwrites.keyArray();t=u(n,i)}else t=!this.permissionOverwrites&&!e.permissionOverwrites;return t}toString(){return`<#${this.id}>`}}e.exports=c},function(e,t,n){const i=n(19),r=n(11),s=n(27),o=n(0),a=n(3),h=n(9).Presence;class u{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.guild=e,this.user={},this._roles=[],t&&this.setup(t)}setup(e){this.serverDeaf=e.deaf,this.serverMute=e.mute,this.selfMute=e.self_mute,this.selfDeaf=e.self_deaf,this.voiceSessionID=e.session_id,this.voiceChannelID=e.channel_id,this.speaking=!1,this.nickname=e.nick||null,this.joinedTimestamp=new Date(e.joined_at).getTime(),this.user=e.user,this._roles=e.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new h}get roles(){const e=new a,t=this.guild.roles.get(this.guild.id);t&&e.set(t.id,t);for(const n of this._roles){const t=this.guild.roles.get(n);t&&e.set(t.id,t)}return e}get highestRole(){return this.roles.reduce((e,t)=>!e||t.comparePositionTo(e)>0?t:e)}get mute(){return this.selfMute||this.serverMute}get deaf(){return this.selfDeaf||this.serverDeaf}get voiceChannel(){return this.guild.channels.get(this.voiceChannelID)}get id(){return this.user.id}get permissions(){if(this.user.id===this.guild.ownerID)return new s(this,o.ALL_PERMISSIONS);let e=0;const t=this.roles;for(const n of t.values())e|=n.permissions;const i=Boolean(e&o.PermissionFlags.ADMINISTRATOR);return i&&(e=o.ALL_PERMISSIONS),new s(this,e)}get kickable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const e=this.guild.member(this.client.user);return!!e.hasPermission(o.PermissionFlags.KICK_MEMBERS)&&e.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const e=this.guild.member(this.client.user);return!!e.hasPermission(o.PermissionFlags.BAN_MEMBERS)&&e.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(e){if(e=this.client.resolver.resolveChannel(e),!e||!e.guild)throw new Error("Could not resolve channel to a guild channel.");return e.permissionsFor(this)}hasPermission(e,t=false){return!t&&this.user.id===this.guild.ownerID||this.roles.some(n=>n.hasPermission(e,t))}hasPermissions(e,t=false){return!t&&this.user.id===this.guild.ownerID||e.every(e=>this.hasPermission(e,t))}missingPermissions(e,t=false){return e.filter(e=>!this.hasPermission(e,t))}edit(e){return this.client.rest.methods.updateGuildMember(this,e)}setMute(e){return this.edit({mute:e})}setDeaf(e){return this.edit({deaf:e})}setVoiceChannel(e){return this.edit({channel:e})}setRoles(e){return this.edit({roles:e})}addRole(e){return this.addRoles([e])}addRoles(e){let t;if(e instanceof a){t=this._roles.slice();for(const n of e.values())t.push(n.id)}else t=this._roles.concat(e);return this.edit({roles:t})}removeRole(e){return this.removeRoles([e])}removeRoles(e){const t=this._roles.slice();if(e instanceof a)for(const n of e.values()){const e=t.indexOf(n.id);e>=0&&t.splice(e,1)}else for(const n of e){const e=t.indexOf(n instanceof r?n.id:n);e>=0&&t.splice(e,1)}return this.edit({roles:t})}setNickname(e){return this.edit({nick:e})}deleteDM(){return this.client.rest.methods.deleteChannel(this)}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(e=0){return this.client.rest.methods.banGuildMember(this.guild,this,e)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}}i.applyToClass(u),e.exports=u},function(e,t,n){const i=n(46),r=n(48),s=n(3),o=n(0),a=n(23),h=n(49);class u{constructor(e,t,n){this.client=n,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.channel=e,t&&this.setup(t)}setup(e){this.id=e.id,this.type=o.MessageTypes[e.type],this.content=e.content,this.author=this.client.dataManager.newUser(e.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=e.pinned,this.tts=e.tts,this.nonce=e.nonce,this.system=6===e.type,this.embeds=e.embeds.map(e=>new r(this,e)),this.attachments=new s;for(const t of e.attachments)this.attachments.set(t.id,new i(this,t));this.createdTimestamp=new Date(e.timestamp).getTime(),this.editedTimestamp=e.edited_timestamp?new Date(e.edited_timestamp).getTime():null,this.mentions={users:new s,roles:new s,channels:new s,everyone:e.mention_everyone};for(const n of e.mentions){let e=this.client.users.get(n.id);e?this.mentions.users.set(e.id,e):(e=this.client.dataManager.newUser(n),this.mentions.users.set(e.id,e))}if(e.mention_roles)for(const n of e.mention_roles){const e=this.channel.guild.roles.get(n);e&&this.mentions.roles.set(e.id,e)}if(this.channel.guild){const t=e.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of t){const e=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);e&&this.mentions.channels.set(e.id,e)}}if(this._edits=[],this.reactions=new s,e.reactions&&e.reactions.length>0)for(const a of e.reactions){const e=a.emoji.id?`${a.emoji.name}:${a.emoji.id}`:a.emoji.name;this.reactions.set(e,new h(this,a.emoji,a.count,a.me))}}patch(e){if(e.author&&(this.author=this.client.users.get(e.author.id),this.guild&&(this.member=this.guild.member(this.author))),e.content&&(this.content=e.content),e.timestamp&&(this.createdTimestamp=new Date(e.timestamp).getTime()),e.edited_timestamp&&(this.editedTimestamp=e.edited_timestamp?new Date(e.edited_timestamp).getTime():null),"tts"in e&&(this.tts=e.tts),"mention_everyone"in e&&(this.mentions.everyone=e.mention_everyone),e.nonce&&(this.nonce=e.nonce),e.embeds&&(this.embeds=e.embeds.map(e=>new r(this,e))),e.type>-1&&(this.system=!1,6===e.type&&(this.system=!0)),e.attachments){this.attachments=new s;for(const t of e.attachments)this.attachments.set(t.id,new i(this,t))}if(e.mentions)for(const t of e.mentions){let e=this.client.users.get(t.id);e?this.mentions.users.set(e.id,e):(e=this.client.dataManager.newUser(t),this.mentions.users.set(e.id,e))}if(e.mention_roles)for(const t of e.mention_roles){const e=this.channel.guild.roles.get(t);e&&this.mentions.roles.set(e.id,e)}if(e.id&&(this.id=e.id),this.channel.guild&&e.content){const t=e.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of t){const e=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);e&&this.mentions.channels.set(e.id,e)}}if(e.reactions&&(this.reactions=new s,e.reactions.length>0))for(const n of e.reactions){const t=n.emoji.id?`${n.emoji.name}:${n.emoji.id}`:n.emoji.name;this.reactions.set(t,new h(this,e.emoji,e.count,e.me))}}get createdAt(){return new Date(this.createdTimestamp)}get editedAt(){return this.editedTimestamp?new Date(this.editedTimestamp):null}get guild(){return this.channel.guild||null}get cleanContent(){return this.content.replace(/@(everyone|here)/g,"@​$1").replace(/<@!?[0-9]+>/g,e=>{const t=e.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(t)?`@${this.client.users.get(t).username}`:e;const n=this.channel.guild.members.get(t);if(n)return n.nickname?`@${n.nickname}`:`@${n.user.username}`;{const n=this.client.users.get(t);return n?`@${n.username}`:e}}).replace(/<#[0-9]+>/g,e=>{const t=this.client.channels.get(e.replace(/<|#|>/g,""));return t?`#${t.name}`:e}).replace(/<@&[0-9]+>/g,e=>{if("dm"===this.channel.type||"group"===this.channel.type)return e;const t=this.guild.roles.get(e.replace(/<|@|>|&/g,""));return t?`@${t.name}`:e})}get edits(){return this._edits.slice().unshift(this)}get editable(){return this.author.id===this.client.user.id}get deletable(){return this.author.id===this.client.user.id||this.guild&&this.channel.permissionsFor(this.client.user).hasPermission(o.PermissionFlags.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).hasPermission(o.PermissionFlags.MANAGE_MESSAGES)}isMentioned(e){return e=e&&e.id?e.id:e,this.mentions.users.has(e)||this.mentions.channels.has(e)||this.mentions.roles.has(e)}edit(e,t={}){return this.client.rest.methods.updateMessage(this,e,t)}editCode(e,t){return t=a(this.client.resolver.resolveString(t),!0),this.edit(`\`\`\`${e||""} ${t} -\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(e){if(e=this.client.resolver.resolveEmojiIdentifier(e),!e)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,e)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(e=0){return e<=0?this.client.rest.methods.deleteMessage(this):new Promise(t=>{this.client.setTimeout(()=>{t(this.delete())},e)})}reply(e,t={}){e=this.client.resolver.resolveString(e);const n=this.guild?`${this.author}, `:"";return e=`${n}${e}`,t.split&&("object"!=typeof t.split&&(t.split={}),t.split.prepend||(t.split.prepend=n)),this.client.rest.methods.sendMessage(this.channel,e,t)}equals(e,t){if(!e)return!1;const n=!e.author&&!e.attachments;if(n)return this.id===e.id&&this.embeds.length===e.embeds.length;let i=this.id===e.id&&this.author.id===e.author.id&&this.content===e.content&&this.tts===e.tts&&this.nonce===e.nonce&&this.embeds.length===e.embeds.length&&this.attachments.length===e.attachments.length;return i&&t&&(i=this.mentions.everyone===e.mentions.everyone&&this.createdTimestamp===new Date(t.timestamp).getTime()&&this.editedTimestamp===new Date(t.edited_timestamp).getTime()),i}toString(){return this.content}_addReaction(e,t){const n=e.id?`${e.name}:${e.id}`:e.name;let i;return this.reactions.has(n)?(i=this.reactions.get(n),i.me||(i.me=t.id===this.client.user.id)):(i=new c(this,e,0,t.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(t.id)?null:(i.users.set(t.id,t),i.count++,i)}_removeReaction(e,t){const n=e.id||e;if(this.reactions.has(n)){const e=this.reactions.get(n);if(e.users.has(t.id))return e.users.delete(t.id),e.count--,t.id===this.client.user.id&&(e.me=!1),e}return null}_clearReactions(){this.reactions.clear()}}e.exports=h},function(e,t){e.exports=function(e,t=false,n=false){return t?e.replace(/```/g,"`​``"):n?e.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):e.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}},function(e,t,n){var i=t;i.bignum=n(7),i.define=n(141).define,i.base=n(26),i.constants=n(85),i.decoders=n(145),i.encoders=n(147)},function(e,t,n){(function(e){function n(e){var t,n;return t=e>a||e<0?(n=Math.abs(e)%a,e<0?a-n:n):e}function i(e){for(var t=0;t>>8^255&n^99,this.SBOX[r]=n,this.INV_SBOX[n]=r,s=e[r],o=e[s],a=e[o],i=257*e[n]^16843008*n,this.SUB_MIX[0][r]=i<<24|i>>>8,this.SUB_MIX[1][r]=i<<16|i>>>16,this.SUB_MIX[2][r]=i<<8|i>>>24,this.SUB_MIX[3][r]=i,i=16843009*a^65537*o^257*s^16843008*r,this.INV_SUB_MIX[0][n]=i<<24|i>>>8,this.INV_SUB_MIX[1][n]=i<<16|i>>>16,this.INV_SUB_MIX[2][n]=i<<8|i>>>24,this.INV_SUB_MIX[3][n]=i,0===r?r=c=1:(r=s^e[e[e[a^s]]],c^=e[e[c]]);return!0};var c=new r;o.blockSize=16,o.prototype.blockSize=o.blockSize,o.keySize=32,o.prototype.keySize=o.keySize,o.prototype._doReset=function(){var e,t,n,i,r,s;for(n=this._key,t=n.length,this._nRounds=t+6,r=4*(this._nRounds+1),this._keySchedule=[],i=0;i>>24,s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s],s^=c.RCON[i/t|0]<<24):t>6&&i%t===4?s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s]:void 0,this._keySchedule[i-t]^s);for(this._invKeySchedule=[],e=0;e>>24]]^c.INV_SUB_MIX[1][c.SBOX[s>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[s>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&s]];return!0},o.prototype.encryptBlock=function(t){t=s(new e(t));var n=this._doCryptBlock(t,this._keySchedule,c.SUB_MIX,c.SBOX),i=new e(16);return i.writeUInt32BE(n[0],0),i.writeUInt32BE(n[1],4),i.writeUInt32BE(n[2],8),i.writeUInt32BE(n[3],12),i},o.prototype.decryptBlock=function(t){t=s(new e(t));var n=[t[3],t[1]];t[1]=n[0],t[3]=n[1];var i=this._doCryptBlock(t,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX),r=new e(16);return r.writeUInt32BE(i[0],0),r.writeUInt32BE(i[3],4),r.writeUInt32BE(i[2],8),r.writeUInt32BE(i[1],12),r},o.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},o.prototype._doCryptBlock=function(e,t,i,r){var s,o,a,c,h,f,u,d,l;o=e[0]^t[0],a=e[1]^t[1],c=e[2]^t[2],h=e[3]^t[3],s=4;for(var p=1;p>>24]^i[1][a>>>16&255]^i[2][c>>>8&255]^i[3][255&h]^t[s++],u=i[0][a>>>24]^i[1][c>>>16&255]^i[2][h>>>8&255]^i[3][255&o]^t[s++],d=i[0][c>>>24]^i[1][h>>>16&255]^i[2][o>>>8&255]^i[3][255&a]^t[s++],l=i[0][h>>>24]^i[1][o>>>16&255]^i[2][a>>>8&255]^i[3][255&c]^t[s++],o=f,a=u,c=d,h=l;return f=(r[o>>>24]<<24|r[a>>>16&255]<<16|r[c>>>8&255]<<8|r[255&h])^t[s++],u=(r[a>>>24]<<24|r[c>>>16&255]<<16|r[h>>>8&255]<<8|r[255&o])^t[s++],d=(r[c>>>24]<<24|r[h>>>16&255]<<16|r[o>>>8&255]<<8|r[255&a])^t[s++],l=(r[h>>>24]<<24|r[o>>>16&255]<<16|r[a>>>8&255]<<8|r[255&c])^t[s++],[n(f),n(u),n(d),n(l)]},t.AES=o}).call(t,n(0).Buffer)},function(e,t){t["aes-128-ecb"]={cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},t["aes-192-ecb"]={cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},t["aes-256-ecb"]={cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},t["aes-128-cbc"]={cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},t["aes-192-cbc"]={cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},t["aes-256-cbc"]={cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},t.aes128=t["aes-128-cbc"],t.aes192=t["aes-192-cbc"],t.aes256=t["aes-256-cbc"],t["aes-128-cfb"]={cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},t["aes-192-cfb"]={cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},t["aes-256-cfb"]={cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},t["aes-128-cfb8"]={cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},t["aes-192-cfb8"]={cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},t["aes-256-cfb8"]={cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},t["aes-128-cfb1"]={cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},t["aes-192-cfb1"]={cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},t["aes-256-cfb1"]={cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},t["aes-128-ofb"]={cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},t["aes-192-ofb"]={cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},t["aes-256-ofb"]={cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},t["aes-128-ctr"]={cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},t["aes-192-ctr"]={cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},t["aes-256-ctr"]={cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},t["aes-128-gcm"]={cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},t["aes-192-gcm"]={cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},t["aes-256-gcm"]={cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}},function(e,t,n){(function(e){function i(e){for(var t,n=e.length;n--;){if(t=e.readUInt8(n),255!==t){t++,e.writeUInt8(t,n);break}e.writeUInt8(0,n)}}function r(e){var t=e._cipher.encryptBlock(e._prev);return i(e._prev),t}var s=n(27);t.encrypt=function(t,n){for(;t._cache.length0&&l.push(o),l.push(e),n&&l.push(n),o=r(t.concat(l)),l=[],a=0,i>0)for(;;){if(0===i)break;if(a===o.length)break;f[c++]=o[a],i--,a++}if(s>0&&a!==o.length)for(;;){if(0===s)break;if(a===o.length)break;u[h++]=o[a],s--,a++}if(0===i&&0===s)break}for(a=0;ae.server_max_window_bits)&&("number"!=typeof this._options.clientMaxWindowBits||e.client_max_window_bits))return(this._options.serverNoContextTakeover||e.server_no_context_takeover)&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.clientNoContextTakeover!==!1&&e.client_no_context_takeover&&(t.client_no_context_takeover=!0),"number"==typeof this._options.serverMaxWindowBits?t.server_max_window_bits=this._options.serverMaxWindowBits:"number"==typeof e.server_max_window_bits&&(t.server_max_window_bits=e.server_max_window_bits),"number"==typeof this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits!==!1&&"number"==typeof e.client_max_window_bits&&(t.client_max_window_bits=e.client_max_window_bits),!0},this);if(!n)throw new Error("Doesn't support the offered configuration");return t},i.prototype.acceptAsClient=function(e){var t=e[0];if(null!=this._options.clientNoContextTakeover&&this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Invalid value for "client_no_context_takeover"');if(null!=this._options.clientMaxWindowBits){if(this._options.clientMaxWindowBits===!1&&t.client_max_window_bits)throw new Error('Invalid value for "client_max_window_bits"');if("number"==typeof this._options.clientMaxWindowBits&&(!t.client_max_window_bits||t.client_max_window_bits>this._options.clientMaxWindowBits))throw new Error('Invalid value for "client_max_window_bits"')}return t},i.prototype.normalizeParams=function(e){return e.map(function(e){return Object.keys(e).forEach(function(t){var n=e[t];if(n.length>1)throw new Error("Multiple extension parameters for "+t);switch(n=n[0],t){case"server_no_context_takeover":case"client_no_context_takeover":if(n!==!0)throw new Error("invalid extension parameter value for "+t+" ("+n+")");e[t]=!0;break;case"server_max_window_bits":case"client_max_window_bits":if("string"==typeof n&&(n=parseInt(n,10),!~s.indexOf(n)))throw new Error("invalid extension parameter value for "+t+" ("+n+")");if(!this._isServer&&n===!0)throw new Error("Missing extension parameter value for "+t);e[t]=n;break;default:throw new Error("Not defined extension parameter ("+t+")")}},this),e},this)},i.prototype.decompress=function(e,n,i){function s(e){c(),i(e)}function a(e){if(void 0!==u._maxPayload&&null!==u._maxPayload&&u._maxPayload>0&&(l+=e.length,l>u._maxPayload)){d=[],c();var t={type:1009};return void i(t)}d.push(e)}function c(){u._inflate&&(u._inflate.removeListener("error",s),u._inflate.removeListener("data",a),u._inflate.writeInProgress=!1,(n&&u.params[h+"_no_context_takeover"]||u._inflate.pendingClose)&&(u._inflate.close&&u._inflate.close(),u._inflate=null))}var h=this._isServer?"client":"server";if(!this._inflate){var f=this.params[h+"_max_window_bits"];this._inflate=r.createInflateRaw({windowBits:"number"==typeof f?f:o})}this._inflate.writeInProgress=!0;var u=this,d=[],l=0;this._inflate.on("error",s).on("data",a),this._inflate.write(e),n&&this._inflate.write(new t([0,0,255,255])),this._inflate.flush(function(){c(),i(null,t.concat(d))})},i.prototype.compress=function(e,n,i){function s(e){h(),i(e)}function c(e){l.push(e)}function h(){d._deflate&&(d._deflate.removeListener("error",s),d._deflate.removeListener("data",c),d._deflate.writeInProgress=!1,(n&&d.params[f+"_no_context_takeover"]||d._deflate.pendingClose)&&(d._deflate.close&&d._deflate.close(),d._deflate=null))}var f=this._isServer?"server":"client";if(!this._deflate){var u=this.params[f+"_max_window_bits"];this._deflate=r.createDeflateRaw({flush:r.Z_SYNC_FLUSH,windowBits:"number"==typeof u?u:o,memLevel:this._options.memLevel||a})}this._deflate.writeInProgress=!0;var d=this,l=[];this._deflate.on("error",s).on("data",c),this._deflate.write(e),this._deflate.flush(function(){h();var e=t.concat(l);n&&(e=e.slice(0,e.length-4)),i(null,e)})},e.exports=i}).call(t,n(0).Buffer)},function(e,t){e.exports=function e(t,n){if(!n)return t;for(const i in t)({}).hasOwnProperty.call(n,i)?n[i]===Object(n[i])&&(n[i]=e(t[i],n[i])):n[i]=t[i];return n}},function(e,t,n){const i=n(1);class r{constructor(e,t){this.member=e,this.raw=t}serialize(){const e={};for(const t in i.PermissionFlags)e[t]=this.hasPermission(t);return e}hasPermission(e,t=false){return e=this.member.client.resolver.resolvePermission(e),!t&&(this.raw&i.PermissionFlags.ADMINISTRATOR)>0||(this.raw&e)>0}hasPermissions(e,t=false){return e.every(e=>this.hasPermission(e,t))}missingPermissions(e,t=false){return e.filter(e=>!this.hasPermission(e,t))}}e.exports=r},function(e,t,n){const i=n(14),r=n(19),s=n(25),o=n(15).Presence,a=n(33),c=n(1),h=n(6),f=n(12),u=n(63);class d{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.members=new h,this.channels=new h,this.roles=new h,t&&(t.unavailable?(this.available=!1,this.id=t.id):(this.available=!0,this.setup(t)))}setup(e){this.name=e.name,this.icon=e.icon,this.splash=e.splash,this.region=e.region,this.memberCount=e.member_count||this.memberCount,this.large=e.large||this.large,this.presences=new h,this.features=e.features,this.emojis=new h;for(const t of e.emojis)this.emojis.set(t.id,new s(this,t));if(this.afkTimeout=e.afk_timeout,this.afkChannelID=e.afk_channel_id,this.embedEnabled=e.embed_enabled,this.verificationLevel=e.verification_level,this.joinedTimestamp=e.joined_at?new Date(e.joined_at).getTime():this.joinedTimestamp,this.id=e.id,this.available=!e.unavailable,this.features=e.features||this.features||[],e.members){this.members.clear();for(const t of e.members)this._addMember(t,!1)}if(e.owner_id&&(this.ownerID=e.owner_id),e.channels){this.channels.clear();for(const t of e.channels)this.client.dataManager.newChannel(t,this)}if(e.roles){this.roles.clear();for(const t of e.roles){const e=new r(this,t);this.roles.set(e.id,e)}}if(e.presences)for(const n of e.presences)this._setPresence(n.user.id,n);if(this._rawVoiceStates=new h,e.voice_states)for(const i of e.voice_states){this._rawVoiceStates.set(i.user_id,i);const e=this.members.get(i.user_id);e&&(e.serverMute=i.mute,e.serverDeaf=i.deaf,e.selfMute=i.self_mute,e.selfDeaf=i.self_deaf,e.voiceSessionID=i.session_id,e.voiceChannelID=i.channel_id,this.channels.get(i.channel_id).members.set(e.user.id,e))}}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}get iconURL(){return this.icon?c.Endpoints.guildIcon(this.id,this.icon):null}get owner(){return this.members.get(this.ownerID)}get voiceConnection(){return this.client.voice.connections.get(this.id)||null}get defaultChannel(){return this.channels.get(this.id)}member(e){return this.client.resolver.resolveGuildMember(this,e)}fetchBans(){return this.client.rest.methods.getGuildBans(this)}fetchInvites(){return this.client.rest.methods.getGuildInvites(this)}fetchWebhooks(){return this.client.rest.methods.getGuildWebhooks(this)}fetchMember(e){return this._fetchWaiter?Promise.reject(new Error("Already fetching guild members.")):(e=this.client.resolver.resolveUser(e),e?this.members.has(e.id)?Promise.resolve(this.members.get(e.id)):this.client.rest.methods.getGuildMember(this,e):Promise.reject(new Error("User is not cached. Use Client.fetchUser first.")))}fetchMembers(e=""){return new Promise((t,n)=>{if(this._fetchWaiter)throw new Error("Already fetching guild members in ${this.id}.");return this.memberCount===this.members.size?void t(this):(this._fetchWaiter=t,this.client.ws.send({op:c.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:e,limit:0}}),this._checkChunks(),void this.client.setTimeout(()=>n(new Error("Members didn't arrive in time.")),12e4))})}edit(e){return this.client.rest.methods.updateGuild(this,e)}setName(e){return this.edit({name:e})}setRegion(e){return this.edit({region:e})}setVerificationLevel(e){return this.edit({verificationLevel:e})}setAFKChannel(e){return this.edit({afkChannel:e})}setAFKTimeout(e){return this.edit({afkTimeout:e})}setIcon(e){return this.edit({icon:e})}setOwner(e){return this.edit({owner:e})}setSplash(e){return this.edit({splash:e})}ban(e,t=0){return this.client.rest.methods.banGuildMember(this,e,t)}unban(e){return this.client.rest.methods.unbanGuildMember(this,e)}pruneMembers(e,t=false){if("number"!=typeof e)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,e,t)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(e,t){return this.client.rest.methods.createChannel(this,e,t)}createRole(e){const t=this.client.rest.methods.createGuildRole(this);return e?t.then(t=>t.edit(e)):t}createEmoji(e,t){return new Promise(n=>{e.startsWith("data:")?n(this.client.rest.methods.createEmoji(this,e,t)):this.client.resolver.resolveBuffer(e).then(e=>n(this.client.rest.methods.createEmoji(this,e,t)))})}deleteEmoji(e){return e instanceof s||(e=this.emojis.get(e)),this.client.rest.methods.deleteEmoji(e)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}setRolePosition(e,t){if(e instanceof r)e=e.id;else if("string"!=typeof e)return Promise.reject(new Error("Supplied role is not a role or string"));if(t=Number(t),isNaN(t))return Promise.reject(new Error("Supplied position is not a number"));const n=this.roles.array().map(n=>({id:n.id,position:n.id===e?t:n.position`:this.name}}e.exports=n},function(e,t,n){const i=n(23),r=n(35);class s{constructor(e,t,n){e?(this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),t&&this.setup(t)):(this.id=t,this.token=n,this.client=this)}setup(e){this.name=e.name,this.token=e.token,this.avatar=e.avatar,this.id=e.id,this.guildID=e.guild_id,this.channelID=e.channel_id,e.user&&(this.owner=e.user)}sendMessage(e,t={}){return this.client.rest.methods.sendWebhookMessage(this,e,t)}sendSlackMessage(e){return this.client.rest.methods.sendSlackWebhookMessage(this,e)}sendTTSMessage(e,t={}){return Object.assign(t,{tts:!0}),this.client.rest.methods.sendWebhookMessage(this,e,t)}sendFile(e,t,n,r={}){return t||(t="string"==typeof e?i.basename(e):e&&e.path?i.basename(e.path):"file.jpg"),this.client.resolver.resolveBuffer(e).then(e=>this.client.rest.methods.sendWebhookMessage(this,n,r,{file:e,name:t}))}sendCode(e,t,n={}){return n.split&&("object"!=typeof n.split&&(n.split={}),n.split.prepend||(n.split.prepend=`\`\`\`${e||""} +\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(e){if(e=this.client.resolver.resolveEmojiIdentifier(e),!e)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,e)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(e=0){return e<=0?this.client.rest.methods.deleteMessage(this):new Promise(t=>{this.client.setTimeout(()=>{t(this.delete())},e)})}reply(e,t={}){e=this.client.resolver.resolveString(e);const n=this.guild?`${this.author}, `:"";return e=`${n}${e}`,t.split&&("object"!=typeof t.split&&(t.split={}),t.split.prepend||(t.split.prepend=n)),this.client.rest.methods.sendMessage(this.channel,e,t)}equals(e,t){if(!e)return!1;const n=!e.author&&!e.attachments;if(n)return this.id===e.id&&this.embeds.length===e.embeds.length;let i=this.id===e.id&&this.author.id===e.author.id&&this.content===e.content&&this.tts===e.tts&&this.nonce===e.nonce&&this.embeds.length===e.embeds.length&&this.attachments.length===e.attachments.length;return i&&t&&(i=this.mentions.everyone===e.mentions.everyone&&this.createdTimestamp===new Date(t.timestamp).getTime()&&this.editedTimestamp===new Date(t.edited_timestamp).getTime()),i}toString(){return this.content}_addReaction(e,t){const n=e.id?`${e.name}:${e.id}`:e.name;let i;return this.reactions.has(n)?(i=this.reactions.get(n),i.me||(i.me=t.id===this.client.user.id)):(i=new h(this,e,0,t.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(t.id)?null:(i.users.set(t.id,t),i.count++,i)}_removeReaction(e,t){const n=e.id||e;if(this.reactions.has(n)){const e=this.reactions.get(n);if(e.users.has(t.id))return e.users.delete(t.id),e.count--,t.id===this.client.user.id&&(e.me=!1),e}return null}_clearReactions(){this.reactions.clear()}}e.exports=u},function(e,t){e.exports=function(e,t=false,n=false){return t?e.replace(/```/g,"`​``"):n?e.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):e.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}},function(e,t){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,n,i,r){if(t.subarray&&e.subarray)return void e.set(t.subarray(n,n+i),r);for(var s=0;s0||(this.raw&e)>0}hasPermissions(e,t=false){return e.every(e=>this.hasPermission(e,t))}missingPermissions(e,t=false){return e.filter(e=>!this.hasPermission(e,t))}}e.exports=r},function(e,t,n){const i=n(8),r=n(11),s=n(15),o=n(9).Presence,a=n(21),h=n(0),u=n(3),c=n(7),l=n(37);class f{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.members=new u,this.channels=new u,this.roles=new u,t&&(t.unavailable?(this.available=!1,this.id=t.id):(this.available=!0,this.setup(t)))}setup(e){this.name=e.name,this.icon=e.icon,this.splash=e.splash,this.region=e.region,this.memberCount=e.member_count||this.memberCount,this.large=e.large||this.large,this.presences=new u,this.features=e.features,this.emojis=new u;for(const t of e.emojis)this.emojis.set(t.id,new s(this,t));if(this.afkTimeout=e.afk_timeout,this.afkChannelID=e.afk_channel_id,this.embedEnabled=e.embed_enabled,this.verificationLevel=e.verification_level,this.joinedTimestamp=e.joined_at?new Date(e.joined_at).getTime():this.joinedTimestamp,this.id=e.id,this.available=!e.unavailable,this.features=e.features||this.features||[],e.members){this.members.clear();for(const t of e.members)this._addMember(t,!1)}if(e.owner_id&&(this.ownerID=e.owner_id),e.channels){this.channels.clear();for(const t of e.channels)this.client.dataManager.newChannel(t,this)}if(e.roles){this.roles.clear();for(const t of e.roles){const e=new r(this,t);this.roles.set(e.id,e)}}if(e.presences)for(const n of e.presences)this._setPresence(n.user.id,n);if(this._rawVoiceStates=new u,e.voice_states)for(const i of e.voice_states){this._rawVoiceStates.set(i.user_id,i);const e=this.members.get(i.user_id);e&&(e.serverMute=i.mute,e.serverDeaf=i.deaf,e.selfMute=i.self_mute,e.selfDeaf=i.self_deaf,e.voiceSessionID=i.session_id,e.voiceChannelID=i.channel_id,this.channels.get(i.channel_id).members.set(e.user.id,e))}}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}get iconURL(){return this.icon?h.Endpoints.guildIcon(this.id,this.icon):null}get owner(){return this.members.get(this.ownerID)}get voiceConnection(){return this.client.voice.connections.get(this.id)||null}get defaultChannel(){return this.channels.get(this.id)}member(e){return this.client.resolver.resolveGuildMember(this,e)}fetchBans(){return this.client.rest.methods.getGuildBans(this)}fetchInvites(){return this.client.rest.methods.getGuildInvites(this)}fetchWebhooks(){return this.client.rest.methods.getGuildWebhooks(this)}fetchMember(e){return this._fetchWaiter?Promise.reject(new Error("Already fetching guild members.")):(e=this.client.resolver.resolveUser(e),e?this.members.has(e.id)?Promise.resolve(this.members.get(e.id)):this.client.rest.methods.getGuildMember(this,e):Promise.reject(new Error("User is not cached. Use Client.fetchUser first.")))}fetchMembers(e=""){return new Promise((t,n)=>{if(this._fetchWaiter)throw new Error("Already fetching guild members in ${this.id}.");return this.memberCount===this.members.size?void t(this):(this._fetchWaiter=t,this.client.ws.send({op:h.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:e,limit:0}}),this._checkChunks(),void this.client.setTimeout(()=>n(new Error("Members didn't arrive in time.")),12e4))})}edit(e){return this.client.rest.methods.updateGuild(this,e)}setName(e){return this.edit({name:e})}setRegion(e){return this.edit({region:e})}setVerificationLevel(e){return this.edit({verificationLevel:e})}setAFKChannel(e){return this.edit({afkChannel:e})}setAFKTimeout(e){return this.edit({afkTimeout:e})}setIcon(e){return this.edit({icon:e})}setOwner(e){return this.edit({owner:e})}setSplash(e){return this.edit({splash:e})}ban(e,t=0){return this.client.rest.methods.banGuildMember(this,e,t)}unban(e){return this.client.rest.methods.unbanGuildMember(this,e)}pruneMembers(e,t=false){if("number"!=typeof e)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,e,t)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(e,t){return this.client.rest.methods.createChannel(this,e,t)}createRole(e){const t=this.client.rest.methods.createGuildRole(this);return e?t.then(t=>t.edit(e)):t}createEmoji(e,t){return new Promise(n=>{e.startsWith("data:")?n(this.client.rest.methods.createEmoji(this,e,t)):this.client.resolver.resolveBuffer(e).then(e=>n(this.client.rest.methods.createEmoji(this,e,t)))})}deleteEmoji(e){return e instanceof s||(e=this.emojis.get(e)),this.client.rest.methods.deleteEmoji(e)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}setRolePosition(e,t){if(e instanceof r)e=e.id;else if("string"!=typeof e)return Promise.reject(new Error("Supplied role is not a role or string"));if(t=Number(t),isNaN(t))return Promise.reject(new Error("Supplied position is not a number"));const n=this.roles.array().map(n=>({id:n.id,position:n.id===e?t:n.position`:this.name}}e.exports=n},function(e,t,n){const i=n(17),r=n(23);class s{constructor(e,t,n){e?(this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),t&&this.setup(t)):(this.id=t,this.token=n,this.client=this)}setup(e){this.name=e.name,this.token=e.token,this.avatar=e.avatar,this.id=e.id,this.guildID=e.guild_id,this.channelID=e.channel_id,e.user&&(this.owner=e.user)}sendMessage(e,t={}){return this.client.rest.methods.sendWebhookMessage(this,e,t)}sendSlackMessage(e){return this.client.rest.methods.sendSlackWebhookMessage(this,e)}sendTTSMessage(e,t={}){return Object.assign(t,{tts:!0}),this.client.rest.methods.sendWebhookMessage(this,e,t)}sendFile(e,t,n,r={}){return t||(t="string"==typeof e?i.basename(e):e&&e.path?i.basename(e.path):"file.jpg"),this.client.resolver.resolveBuffer(e).then(e=>this.client.rest.methods.sendWebhookMessage(this,n,r,{file:e,name:t}))}sendCode(e,t,n={}){return n.split&&("object"!=typeof n.split&&(n.split={}),n.split.prepend||(n.split.prepend=`\`\`\`${e||""} `),n.split.append||(n.split.append="\n```")),t=r(this.client.resolver.resolveString(t),!0),this.sendMessage(`\`\`\`${e||""} ${t} -\`\`\``,n)}edit(e=this.name,t){return t?this.client.resolver.resolveBuffer(t).then(t=>{const n=this.client.resolver.resolveBase64(t);return this.client.rest.methods.editWebhook(this,e,n)}):this.client.rest.methods.editWebhook(this,e).then(e=>{return this.setup(e),this})}delete(){return this.client.rest.methods.deleteWebhook(this)}}e.exports=s},function(e,t,n){function i(){return Object.keys(o)}var r=n(152);t.createCipher=t.Cipher=r.createCipher,t.createCipheriv=t.Cipheriv=r.createCipheriv;var s=n(151);t.createDecipher=t.Decipher=s.createDecipher,t.createDecipheriv=t.Decipheriv=s.createDecipheriv;var o=n(38);t.listCiphers=t.getCiphers=i},function(e,t,n){(function(t){function i(e){var t=s(e),n=t.toRed(o.mont(e.modulus)).redPow(new o(e.publicExponent)).fromRed();return{blinder:n,unblinder:t.invm(e.modulus)}}function r(e,n){var r=i(n),s=n.modulus.byteLength(),a=(o.mont(n.modulus),new o(e).mul(r.blinder).umod(n.modulus)),c=a.toRed(o.mont(n.prime1)),h=a.toRed(o.mont(n.prime2)),f=n.coefficient,u=n.prime1,d=n.prime2,l=c.redPow(n.exponent1),p=h.redPow(n.exponent2);l=l.fromRed(),p=p.fromRed();var b=l.isub(p).imul(f).umod(u);return b.imul(d),p.iadd(b),new t(p.imul(r.unblinder).umod(n.modulus).toArray(!1,s))}function s(e){for(var t=e.modulus.byteLength(),n=new o(a(t));n.cmp(e.modulus)>=0||!n.umod(e.prime1)||!n.umod(e.prime2);)n=new o(a(t));return n}var o=n(7),a=n(30);e.exports=r,r.getr=s}).call(t,n(0).Buffer)},function(e,t,n){"use strict";(function(e){var i=n(0),r=i.Buffer,s=i.SlowBuffer,o=i.kMaxLength||2147483647;t.alloc=function(e,t,n){if("function"==typeof r.alloc)return r.alloc(e,t,n);if("number"==typeof n)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>o)throw new RangeError("size is too large");var i=n,s=t;void 0===s&&(i=void 0,s=0);var a=new r(e);if("string"==typeof s)for(var c=new r(s,i),h=c.length,f=-1;++fo)throw new RangeError("size is too large");return new r(e)},t.from=function(t,n,i){if("function"==typeof r.from&&(!e.Uint8Array||Uint8Array.from!==r.from))return r.from(t,n,i);if("number"==typeof t)throw new TypeError('"value" argument must not be a number');if("string"==typeof t)return new r(t,n);if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer){var s=n;if(1===arguments.length)return new r(t);"undefined"==typeof s&&(s=0);var o=i;if("undefined"==typeof o&&(o=t.byteLength-s),s>=t.byteLength)throw new RangeError("'offset' is out of bounds");if(o>t.byteLength-s)throw new RangeError("'length' is out of bounds");return new r(t.slice(s,s+o))}if(r.isBuffer(t)){var a=new r(t.length);return t.copy(a,0,0,t.length),a}if(t){if(Array.isArray(t)||"undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return new r(t);if("Buffer"===t.type&&Array.isArray(t.data))return new r(t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},t.allocUnsafeSlow=function(e){if("function"==typeof r.allocUnsafeSlow)return r.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=o)throw new RangeError("size is too large");return new s(e)}}).call(t,n(18))},function(e,t,n){"use strict";(function(t){function i(e,n){o.call(this),e=e.toLowerCase(),"string"==typeof n&&(n=new t(n));var i="sha512"===e||"sha384"===e?128:64;this._alg=e,this._key=n,n.length>i?n=r(e).update(n).digest():n.length-1?i:k;a.WritableState=o;var M=n(28);M.inherits=n(2);var x,R={deprecate:n(232)};!function(){try{x=n(11)}catch(e){}finally{x||(x=n(5).EventEmitter)}}();var I=n(0).Buffer,T=n(52);M.inherits(a,x);var C;o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:R.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var C;a.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},a.prototype.write=function(e,t,n){var i=this._writableState,s=!1;return"function"==typeof t&&(n=t,t=null),I.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=r),i.ended?c(this,n):h(this,i,e,n)&&(i.pendingcb++,s=u(this,i,e,t,n)),s},a.prototype.cork=function(){var e=this._writableState;e.corked++},a.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||v(this,e))},a.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},a.prototype._write=function(e,t,n){n(new Error("not implemented"))},a.prototype._writev=null,a.prototype.end=function(e,t,n){var i=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||E(this,i,n)}}).call(t,n(8),n(61).setImmediate)},function(e,t,n){function i(e){if(e&&!c(e))throw new Error("Unknown encoding: "+e)}function r(e){return e.toString(this.encoding)}function s(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function o(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=n(0).Buffer,c=a.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},h=t.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),i(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=o;break;default:return void(this.write=r)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};h.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived),t+=e.toString(this.encoding,0,r);var r=t.length-1,i=t.charCodeAt(r);if(i>=55296&&i<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),e.copy(this.charBuffer,0,0,s),t.substring(0,r)}return t},h.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},h.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,i=this.charBuffer,r=this.encoding;t+=i.slice(0,n).toString(r)}return t}},function(e,t,n){function i(){}function r(e){if(!g(e))return e;var t=[];for(var n in e)s(t,n,e[n]);return t.join("&")}function s(e,t,n){if(null!=n)if(Array.isArray(n))n.forEach(function(n){s(e,t,n)});else if(g(n))for(var i in n)s(e,t+"["+i+"]",n[i]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(n));else null===n&&e.push(encodeURIComponent(t))}function o(e){for(var t,n,i={},r=e.split("&"),s=0,o=r.length;s=300)&&(i=new Error(t.statusText||"Unsuccessful HTTP response"),i.original=e,i.response=t,i.status=t.status)}catch(e){i=e}i?n.callback(i,t):n.callback(null,t)})}function l(e,t){var n=v("DELETE",e);return t&&n.end(t),n}var p;"undefined"!=typeof window?p=window:"undefined"!=typeof self?p=self:(console.warn("Using browser-only version of superagent in non-browser environment"),p=this);var b=n(163),m=n(227),g=n(119),v=e.exports=n(228).bind(null,d);v.getXHR=function(){if(!(!p.XMLHttpRequest||p.location&&"file:"==p.location.protocol&&p.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw Error("Browser-only verison of superagent could not find XHR")};var y="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};v.serializeObject=r,v.parseString=o,v.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},v.serialize={"application/x-www-form-urlencoded":r,"application/json":JSON.stringify},v.parse={"application/x-www-form-urlencoded":o,"application/json":JSON.parse},u.prototype.get=function(e){return this.header[e.toLowerCase()]},u.prototype._setHeaderProperties=function(e){var t=this.header["content-type"]||"";this.type=h(t);var n=f(t);for(var i in n)this[i]=n[i]},u.prototype._parseBody=function(e){var t=v.parse[this.type];return!t&&c(this.type)&&(t=v.parse["application/json"]),t&&e&&(e.length||e instanceof Object)?t(e):null},u.prototype._setStatusProperties=function(e){1223===e&&(e=204);var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.notFound=404==e,this.forbidden=403==e},u.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,i="cannot "+t+" "+n+" ("+this.status+")",r=new Error(i);return r.status=this.status,r.method=t,r.url=n,r},v.Response=u,b(d.prototype),m(d.prototype),d.prototype.type=function(e){return this.set("Content-Type",v.types[e]||e),this},d.prototype.responseType=function(e){return this._responseType=e,this},d.prototype.accept=function(e){return this.set("Accept",v.types[e]||e),this},d.prototype.auth=function(e,t,n){switch(n||(n={type:"basic"}),n.type){case"basic":var i=btoa(e+":"+t);this.set("Authorization","Basic "+i);break;case"auto":this.username=e,this.password=t}return this},d.prototype.query=function(e){return"string"!=typeof e&&(e=r(e)),e&&this._query.push(e),this},d.prototype.attach=function(e,t,n){if(this._data)throw Error("superagent can't mix .send() and .attach()");return this._getFormData().append(e,t,n||t.name),this},d.prototype._getFormData=function(){return this._formData||(this._formData=new p.FormData),this._formData},d.prototype.callback=function(e,t){var n=this._callback;this.clearTimeout(),e&&this.emit("error",e),n(e,t)},d.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},d.prototype.buffer=d.prototype.ca=d.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},d.prototype.pipe=d.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},d.prototype._timeoutError=function(){var e=this._timeout,t=new Error("timeout of "+e+"ms exceeded");t.timeout=e,this.callback(t)},d.prototype._appendQueryString=function(){var e=this._query.join("&");e&&(this.url+=~this.url.indexOf("?")?"&"+e:"?"+e)},d.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},d.prototype.end=function(e){var t=this,n=this.xhr=v.getXHR(),r=this._timeout,s=this._formData||this._data;this._callback=e||i,n.onreadystatechange=function(){if(4==n.readyState){var e;try{e=n.status}catch(t){e=0}if(0==e){if(t.timedout)return t._timeoutError();if(t._aborted)return;return t.crossDomainError()}t.emit("end")}};var o=function(e,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=e,t.emit("progress",n)};if(this.hasListeners("progress"))try{n.onprogress=o.bind(null,"download"),n.upload&&(n.upload.onprogress=o.bind(null,"upload"))}catch(e){}if(r&&!this._timer&&(this._timer=setTimeout(function(){t.timedout=!0,t.abort()},r)),this._appendQueryString(),this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0),this._withCredentials&&(n.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!this._isHost(s)){var a=this._header["content-type"],h=this._serializer||v.serialize[a?a.split(";")[0]:""];!h&&c(a)&&(h=v.serialize["application/json"]),h&&(s=h(s))}for(var f in this.header)null!=this.header[f]&&n.setRequestHeader(f,this.header[f]);return this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send("undefined"!=typeof s?s:null),this},v.Request=d,v.get=function(e,t,n){var i=v("GET",e);return"function"==typeof t&&(n=t,t=null),t&&i.query(t),n&&i.end(n),i},v.head=function(e,t,n){var i=v("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},v.options=function(e,t,n){var i=v("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},v.del=l,v.delete=l,v.patch=function(e,t,n){var i=v("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},v.post=function(e,t,n){var i=v("POST",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},v.put=function(e,t,n){var i=v("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i}},function(e,t,n){(function(e,i){function r(e,t){this._id=e,this._clearFn=t}var s=n(8).nextTick,o=Function.prototype.apply,a=Array.prototype.slice,c={},h=0;t.setTimeout=function(){return new r(o.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new r(o.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},t.setImmediate="function"==typeof e?e:function(e){var n=h++,i=!(arguments.length<2)&&a.call(arguments,1);return c[n]=!0,s(function(){c[n]&&(i?e.apply(null,i):e.call(null),t.clearImmediate(n))}),n},t.clearImmediate="function"==typeof i?i:function(e){delete c[e]}}).call(t,n(61).setImmediate,n(61).clearImmediate)},function(e,t,n){"use strict";function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function r(e,t,n){if(e&&h.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function s(e){return h.isString(e)&&(e=r(e)),e instanceof i?e.format():i.prototype.format.call(e)}function o(e,t){return r(e,!1,!0).resolve(t)}function a(e,t){return e?r(e,!1,!0).resolveObject(t):t}var c=n(218),h=n(239);t.parse=r,t.resolve=o,t.resolveObject=a,t.format=s,t.Url=i;var f=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,d=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["<",">",'"',"`"," ","\r","\n","\t"],p=["{","}","|","\\","^","`"].concat(l),b=["'"].concat(p),m=["%","/","?",";","#"].concat(b),g=["/","?","#"],v=255,y=/^[+a-z0-9A-Z_-]{0,63}$/,_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},S={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},k=n(221);i.prototype.parse=function(e,t,n){if(!h.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),r=i!==-1&&i127?"x":B[O];if(!L.match(y)){var N=D.slice(0,x),j=D.slice(x+1),q=B.match(_);q&&(N.push(q[1]),j.unshift(q[2])),j.length&&(a="/"+j.join(".")+a),this.hostname=N.join(".");break}}}this.hostname.length>v?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=c.toASCII(this.hostname));var z=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+z,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[p])for(var x=0,P=b.length;x0)&&n.host.split("@");A&&(n.auth=A.shift(),n.host=n.hostname=A.shift())}return n.search=e.search,n.query=e.query,h.isNull(n.pathname)&&h.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!w.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var M=w.slice(-1)[0],x=(n.host||e.host||w.length>1)&&("."===M||".."===M)||""===M,R=0,I=w.length;I>=0;I--)M=w[I],"."===M?w.splice(I,1):".."===M?(w.splice(I,1),R++):R&&(w.splice(I,1),R--);if(!y&&!_)for(;R--;R)w.unshift("..");!y||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),x&&"/"!==w.join("/").substr(-1)&&w.push("");var T=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(k){n.hostname=n.host=T?"":w.length?w.shift():"";var A=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");A&&(n.auth=A.shift(),n.host=n.hostname=A.shift())}return y=y||n.host&&w.length,y&&!T&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),h.isNull(n.pathname)&&h.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},i.prototype.parseHost=function(){var e=this.host,t=u.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t){e.exports=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(const n in e){const i=e[n],r=t.indexOf(i);r&&t.splice(r,1)}return 0===t.length}},function(e,t){e.exports={name:"discord.js",version:"10.0.1",description:"A powerful library for interacting with the Discord API",main:"./src/index",scripts:{test:"eslint src && node docs/generator test",docs:"node docs/generator","test-docs":"node docs/generator test",lint:"eslint src","web-dist":"node ./node_modules/parallel-webpack/bin/run.js"},repository:{type:"git",url:"git+https://github.com/hydrabolt/discord.js.git"},keywords:["discord","api","bot","client","node","discordapp"],author:"Amish Shah ",license:"Apache-2.0",bugs:{url:"https://github.com/hydrabolt/discord.js/issues"},homepage:"https://github.com/hydrabolt/discord.js#readme",dependencies:{superagent:"^3.0.0",tweetnacl:"^0.14.3",ws:"^1.1.1"},peerDependencies:{"node-opus":"^0.2.0",opusscript:"^0.0.1"},devDependencies:{bufferutil:"^1.2.1",eslint:"^3.10.0","jsdoc-to-markdown":"^2.0.0","json-loader":"^0.5.4","parallel-webpack":"^1.5.0","uglify-js":"github:mishoo/UglifyJS2#harmony","utf-8-validate":"^1.2.1",webpack:"2.1.0-beta.27",zlibjs:"github:imaya/zlib.js"},engines:{node:">=6.0.0"}}},function(e,t,n){(function(t){const i=n(13),r=n(23),s=n(135),o=n(136);class a{constructor(e,n,s=[]){this.manager=e,this.id=n,this.env=Object.assign({},t.env,{SHARD_ID:this.id,SHARD_COUNT:this.manager.totalShards,CLIENT_TOKEN:this.manager.token}),this.process=i.fork(r.resolve(this.manager.file),s,{env:this.env}),this.process.on("message",this._handleMessage.bind(this)),this.process.once("exit",()=>{this.manager.respawn&&this.manager.createShard(this.id)}),this._evals=new Map,this._fetches=new Map}send(e){return new Promise((t,n)=>{const i=this.process.send(e,e=>{e?n(e):t(this)});if(!i)throw new Error("Failed to send message to shard's process.")})}fetchClientValue(e){if(this._fetches.has(e))return this._fetches.get(e);const t=new Promise((t,n)=>{const i=n=>{n&&n._fetchProp===e&&(this.process.removeListener("message",i),this._fetches.delete(e),t(n._result))};this.process.on("message",i),this.send({_fetchProp:e}).catch(t=>{this.process.removeListener("message",i),this._fetches.delete(e),n(t)})});return this._fetches.set(e,t),t}eval(e){if(this._evals.has(e))return this._evals.get(e);const t=new Promise((t,n)=>{const i=r=>{r&&r._eval===e&&(this.process.removeListener("message",i),this._evals.delete(e),r._error?n(s(r._error)):t(r._result))};this.process.on("message",i),this.send({_eval:e}).catch(t=>{this.process.removeListener("message",i),this._evals.delete(e),n(t)})});return this._evals.set(e,t),t}_handleMessage(e){if(e){if(e._sFetchProp)return void this.manager.fetchClientValues(e._sFetchProp).then(t=>this.send({_sFetchProp:e._sFetchProp,_result:t}),t=>this.send({_sFetchProp:e._sFetchProp,_error:o(t)}));if(e._sEval)return void this.manager.broadcastEval(e._sEval).then(t=>this.send({_sEval:e._sEval,_result:t}),t=>this.send({_sEval:e._sEval,_error:o(t)}))}this.manager.emit("message",this,e)}}e.exports=a}).call(t,n(8))},function(e,t,n){(function(t){const i=n(135),r=n(136);class s{constructor(e){this.client=e,t.on("message",this._handleMessage.bind(this))}get id(){return this.client.options.shardId}get count(){return this.client.options.shardCount}send(e){return new Promise((n,i)=>{const r=t.send(e,e=>{e?i(e):n()});if(!r)throw new Error("Failed to send message to master process.")})}fetchClientValues(e){return new Promise((n,r)=>{const s=o=>{o&&o._sFetchProp===e&&(t.removeListener("message",s),o._error?r(i(o._error)):n(o._result))};t.on("message",s),this.send({_sFetchProp:e}).catch(e=>{t.removeListener("message",s),r(e)})})}broadcastEval(e){return new Promise((n,r)=>{const s=o=>{o&&o._sEval===e&&(t.removeListener("message",s),o._error?r(i(o._error)):n(o._result))};t.on("message",s),this.send({_sEval:e}).catch(e=>{t.removeListener("message",s),r(e)})})}_handleMessage(e){if(e)if(e._fetchProp){const t=e._fetchProp.split(".");let n=this.client;for(const i of t)n=n[i];this._respond("fetchProp",{_fetchProp:e._fetchProp,_result:n})}else if(e._eval)try{this._respond("eval",{_eval:e._eval,_result:this.client._eval(e._eval)})}catch(t){this._respond("eval",{_eval:e._eval,_error:r(t)})}}_respond(e,t){this.send(t).catch(t=>this.client.emit("error",`Error when sending ${e} response to master process: ${t}`))}static singleton(e){return this._singleton?e.emit("error","Multiple clients created in child process; only the first will handle sharding helpers."):this._singleton=new this(e),this._singleton}}e.exports=s}).call(t,n(8))},function(e,t,n){const i=n(14),r=n(76);class s extends r{setup(e){super.setup(e),this.flags=e.flags,this.owner=new i(this.client,e.owner)}}e.exports=s},function(e,t,n){const i=n(14),r=n(6);class s extends i{setup(e){super.setup(e),this.verified=e.verified,this.email=e.email,this.localPresence={},this._typing=new Map,this.friends=new r,this.blocked=new r,this.notes=new r}edit(e){return this.client.rest.methods.updateCurrentUser(e)}setUsername(e){return this.client.rest.methods.updateCurrentUser({username:e})}setEmail(e){return this.client.rest.methods.updateCurrentUser({email:e})}setPassword(e){return this.client.rest.methods.updateCurrentUser({password:e})}setAvatar(e){return e.startsWith("data:")?this.client.rest.methods.updateCurrentUser({avatar:e}):this.client.resolver.resolveBuffer(e).then(e=>this.client.rest.methods.updateCurrentUser({avatar:e}))}setStatus(e){return this.setPresence({status:e})}setGame(e,t){return this.setPresence({game:{name:e,url:t}})}setAFK(e){return this.setPresence({afk:e})}addFriend(e){return e=this.client.resolver.resolveUser(e),this.client.rest.methods.addFriend(e)}removeFriend(e){return e=this.client.resolver.resolveUser(e),this.client.rest.methods.removeFriend(e)}createGuild(e,t,n=null){return n?n.startsWith("data:")?this.client.rest.methods.createGuild({name:e,icon:n,region:t}):this.client.resolver.resolveBuffer(n).then(n=>this.client.rest.methods.createGuild({name:e,icon:n,region:t})):this.client.rest.methods.createGuild({name:e,icon:n,region:t})}setPresence(e){return new Promise(t=>{let n=this.localPresence.status||this.presence.status,i=this.localPresence.game,r=this.localPresence.afk||this.presence.afk;if(!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url}),e.status){if("string"!=typeof e.status)throw new TypeError("Status must be a string");n=e.status}e.game&&(i=e.game,i.url&&(i.type=1)),"undefined"!=typeof e.afk&&(r=e.afk),r=Boolean(r),this.localPresence={status:n,game:i,afk:r},this.localPresence.since=0,this.localPresence.game=this.localPresence.game||null,this.client.ws.send({op:3,d:this.localPresence}),this.client._setPresence(this.id,this.localPresence),t(this)})}}e.exports=s},function(e,t,n){const i=n(24),r=n(31),s=n(6);class o extends i{constructor(e,t){super(e,t),this.type="dm",this.messages=new s,this._typing=new Map}setup(e){super.setup(e),this.recipient=this.client.dataManager.newUser(e.recipients[0]),this.lastMessageID=e.last_message_id}toString(){return this.recipient.toString()}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}r.applyToClass(o,!0),e.exports=o},function(e,t,n){const i=n(24),r=n(31),s=n(6),o=n(63);class a extends i{constructor(e,t){super(e,t),this.type="group",this.messages=new s,this._typing=new Map}setup(e){if(super.setup(e),this.name=e.name,this.icon=e.icon,this.ownerID=e.owner_id,this.recipients||(this.recipients=new s),e.recipients)for(const t of e.recipients){const e=this.client.dataManager.newUser(t);this.recipients.set(e.id,e)}this.lastMessageID=e.last_message_id}get owner(){return this.client.users.get(this.ownerID)}equals(e){const t=e&&this.id===e.id&&this.name===e.name&&this.icon===e.icon&&this.ownerID===e.ownerID;if(t){const t=this.recipients.keyArray(),n=e.recipients.keyArray();return o(t,n)}return t}toString(){return this.name}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}r.applyToClass(a,!0),e.exports=a},function(e,t,n){const i=n(77),r=n(78),s=n(1);class o{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.guild=this.client.guilds.get(e.guild.id)||new i(this.client,e.guild),this.code=e.code,this.temporary=e.temporary,this.maxAge=e.max_age,this.uses=e.uses,this.maxUses=e.max_uses,e.inviter&&(this.inviter=this.client.dataManager.newUser(e.inviter)),this.channel=this.client.channels.get(e.channel.id)||new r(this.client,e.channel),this.createdTimestamp=new Date(e.created_at).getTime()}get createdAt(){return new Date(this.createdTimestamp)}get expiresTimestamp(){return this.createdTimestamp+1e3*this.maxAge}get expiresAt(){return new Date(this.expiresTimestamp)}get url(){return s.Endpoints.inviteLink(this.code)}delete(){return this.client.rest.methods.deleteInvite(this)}toString(){return this.url}}e.exports=o},function(e,t){class n{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.message=e,this.setup(t)}setup(e){this.id=e.id,this.filename=e.filename,this.filesize=e.size,this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}e.exports=n},function(e,t,n){const i=n(5).EventEmitter,r=n(6);class s extends i{constructor(e,t,n={}){super(),this.channel=e,this.filter=t,this.options=n,this.ended=!1,this.collected=new r,this.listener=(e=>this.verify(e)),this.channel.client.on("message",this.listener),n.time&&this.channel.client.setTimeout(()=>this.stop("time"),n.time)}verify(e){return(!this.channel||this.channel.id===e.channel.id)&&(!!this.filter(e,this)&&(this.collected.set(e.id,e),this.emit("message",e,this),this.collected.size>=this.options.maxMatches?this.stop("matchesLimit"):this.options.max&&this.collected.size===this.options.max&&this.stop("limit"),!0))}get next(){return new Promise((e,t)=>{if(this.ended)return void t(this.collected);const n=()=>{this.removeListener("message",i),this.removeListener("end",r)},i=(...t)=>{n(),e(...t)},r=(...e)=>{n(),t(...e)};this.once("message",i),this.once("end",r)})}stop(e="user"){this.ended||(this.ended=!0,this.channel.client.removeListener("message",this.listener),this.emit("end",this.collected,e))}}e.exports=s},function(e,t){class n{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.message=e,this.setup(t)}setup(e){if(this.title=e.title,this.type=e.type,this.description=e.description,this.url=e.url,this.fields=[],e.fields)for(const t of e.fields)this.fields.push(new o(this,t));this.createdTimestamp=e.timestamp,this.thumbnail=e.thumbnail?new i(this,e.thumbnail):null,this.author=e.author?new s(this,e.author):null,this.provider=e.provider?new r(this,e.provider):null,this.footer=e.footer?new a(this,e.footer):null}get createdAt(){return new Date(this.createdTimestamp)}}class i{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}class r{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.url=e.url}}class s{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.url=e.url}}class o{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.value=e.value,this.inline=e.inline}}class a{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.text=e.text,this.iconUrl=e.icon_url,this.proxyIconUrl=e.proxy_icon_url}}n.Thumbnail=i,n.Provider=r,n.Author=s,n.Field=o,n.Footer=a,e.exports=n},function(e,t,n){const i=n(6),r=n(25),s=n(48);class o{constructor(e,t,n,r){this.message=e,this.me=r,this.count=n||0,this.users=new i,this._emoji=new s(this,t.name,t.id)}get emoji(){if(this._emoji instanceof r)return this._emoji;if(this._emoji.id){const e=this.message.client.emojis;if(e.has(this._emoji.id)){const t=e.get(this._emoji.id);return this._emoji=t,t}}return this._emoji}remove(e=this.message.client.user){const t=this.message;return e=this.message.client.resolver.resolveUserID(e),e?t.client.rest.methods.removeMessageReaction(t,this.emoji.identifier,e):Promise.reject("Couldn't resolve the user ID to remove from the reaction.")}fetchUsers(e=100){const t=this.message;return t.client.rest.methods.getMessageReactionUsers(t,this.emoji.identifier,e).then(e=>{this.users=new i;for(const t of e){const e=this.message.client.dataManager.newUser(t);this.users.set(e.id,e)}return this.count=this.users.size,e})}}e.exports=o},function(e,t){class n{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.description=e.description,this.icon=e.icon,this.iconURL=`https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`,this.rpcOrigins=e.rpc_origins}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}toString(){return this.name}}e.exports=n},function(e,t){class n{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.icon=e.icon,this.splash=e.splash}}e.exports=n},function(e,t,n){const i=n(1);class r{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.type=i.ChannelTypes.text===e.type?"text":"voice"}}e.exports=r},function(e,t){class n{constructor(e,t){this.channel=e,t&&this.setup(t)}setup(e){this.id=e.id,this.type=e.type,this.denyData=e.deny,this.allowData=e.allow}delete(){return this.channel.client.rest.methods.deletePermissionOverwrites(this)}}e.exports=n},function(e,t,n){const i=n(32),r=n(31),s=n(6);class o extends i{constructor(e,t){super(e,t),this.type="text",this.messages=new s,this._typing=new Map}setup(e){super.setup(e),this.topic=e.topic,this.lastMessageID=e.last_message_id}get members(){const e=new s;for(const t of this.guild.members.values())this.permissionsFor(t).hasPermission("READ_MESSAGES")&&e.set(t.id,t);return e}fetchWebhooks(){return this.client.rest.methods.getChannelWebhooks(this)}createWebhook(e,t){return new Promise(n=>{t.startsWith("data:")?n(this.client.rest.methods.createWebhook(this,e,t)):this.client.resolver.resolveBuffer(t).then(t=>n(this.client.rest.methods.createWebhook(this,e,t)))})}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}r.applyToClass(o,!0),e.exports=o},function(e,t,n){const i=n(32),r=n(6);class s extends i{constructor(e,t){super(e,t),this.members=new r,this.type="voice"}setup(e){super.setup(e),this.bitrate=e.bitrate,this.userLimit=e.user_limit}get connection(){const e=this.guild.voiceConnection;return e&&e.channel.id===this.id?e:null}get joinable(){return this.permissionsFor(this.client.user).hasPermission("CONNECT")}get speakable(){return this.permissionsFor(this.client.user).hasPermission("SPEAK")}setBitrate(e){return this.edit({bitrate:e})}setUserLimit(e){return this.edit({userLimit:e})}join(){return this.client.voice.joinChannel(this)}leave(){const e=this.client.voice.connections.get(this.guild.id);e&&e.channel.id===this.id&&e.disconnect()}}e.exports=s},function(e,t,n){const i=n(60),r=n(1).Endpoints.botGateway;e.exports=function(e){return new Promise((t,n)=>{if(!e)throw new Error("A token must be provided.");i.get(r).set("Authorization",`Bot ${e.replace(/^Bot\s*/i,"")}`).end((e,i)=>{e&&n(e),t(i.body.shards)})})}},function(e,t){e.exports=function(e,{maxLength=1950,char="\n",prepend="",append=""}={}){if(e.length<=maxLength)return e;const t=e.split(char);if(1===t.length)throw new Error("Message exceeds the max length and contains no split characters.");const n=[""];let i=0;for(let r=0;rmaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+t[r];return n}},function(e,t,n){function i(e,t){return o.call(this,t),a.isBuffer(e)?(this.base=e,this.offset=0,void(this.length=e.length)):void this.error("Input not Buffer")}function r(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof r||(e=new r(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=a.byteLength(e);else{if(!a.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}var s=n(2),o=n(26).Reporter,a=n(0).Buffer;s(i,o),t.DecoderBuffer=i,i.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},i.prototype.restore=function(e){var t=new i(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,o.prototype.restore.call(this,e.reporter),t},i.prototype.isEmpty=function(){return this.offset===this.length},i.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},i.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var n=new i(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},i.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.EncoderBuffer=r,r.prototype.join=function(e,t){return e||(e=new a(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(n){n.join(e,t),t+=n.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):a.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},function(e,t,n){var i=t;i._reverse=function(e){var t={};return Object.keys(e).forEach(function(n){(0|n)==n&&(n|=0);var i=e[n];t[i]=n}),t},i.der=n(144)},function(e,t,n){function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new r,this.tree._init(e.body)}function r(e){h.Node.call(this,"der",e)}function s(e,t){var n=e.readUInt8(t);if(e.isError(n))return n;var i=u.tagClass[n>>6],r=0===(32&n);if(31===(31&n)){var s=n;for(n=0;128===(128&s);){if(s=e.readUInt8(t),e.isError(s))return s;n<<=7,n|=127&s}}else n&=31;var o=u.tag[n];return{cls:i,primitive:r,tag:n,tagStr:o}}function o(e,t,n){var i=e.readUInt8(n);if(e.isError(i))return i;if(!t&&128===i)return null;if(0===(128&i))return i;var r=127&i;if(r>=4)return e.error("length octect is too long");i=0;for(var s=0;s=31?i.error("Multi-octet tag encoding unsupported"):(t||(r|=32),r|=u.tagClassByName[n||"universal"]<<6)}var a=n(2),c=n(0).Buffer,h=n(36),f=h.base,u=h.constants.der;e.exports=i,i.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},a(r,f.Node),r.prototype._encodeComposite=function(e,t,n,i){var r=o(e,t,n,this.reporter);if(i.length<128){var s=new c(2);return s[0]=r,s[1]=i.length,this._createEncoderBuffer([s,i])}for(var a=1,h=i.length;h>=256;h>>=8)a++;var s=new c(2+a);s[0]=r,s[1]=128|a;for(var h=1+a,f=i.length;f>0;h--,f>>=8)s[h]=255&f;return this._createEncoderBuffer([s,i])},r.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var n=new c(2*e.length),i=0;i=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}for(var r=0,i=0;i=128;s>>=7)r++}for(var o=new c(r),a=o.length-1,i=e.length-1;i>=0;i--){var s=e[i];for(o[a--]=127&s;(s>>=7)>0;)o[a--]=128|127&s}return this._createEncoderBuffer(o)},r.prototype._encodeTime=function(e,t){var n,i=new Date(e);return"gentime"===t?n=[s(i.getFullYear()),s(i.getUTCMonth()+1),s(i.getUTCDate()),s(i.getUTCHours()),s(i.getUTCMinutes()),s(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[s(i.getFullYear()%100),s(i.getUTCMonth()+1),s(i.getUTCDate()),s(i.getUTCHours()),s(i.getUTCMinutes()),s(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},r.prototype._encodeNull=function(){return this._createEncoderBuffer("")},r.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!c.isBuffer(e)){var n=e.toArray();!e.sign&&128&n[0]&&n.unshift(0),e=new c(n)}if(c.isBuffer(e)){var i=e.length;0===e.length&&i++;var r=new c(i);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);for(var i=1,s=e;s>=256;s>>=8)i++;for(var r=new Array(i),s=r.length-1;s>=0;s--)r[s]=255&e,e>>=8;return 128&r[0]&&r.unshift(0),this._createEncoderBuffer(new c(r))},r.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},r.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},r.prototype._skipDefault=function(e,t,n){var i,r=this._baseState;if(null===r.default)return!1;var s=e.join();if(void 0===r.defaultBuffer&&(r.defaultBuffer=this._encodeValue(r.default,t,n).join()),s.length!==r.defaultBuffer.length)return!1;for(i=0;i>a%8,e._prev=i(e._prev,n?s:o);return h}function i(t,n){var i=t.length,r=-1,s=new e(t.length);for(t=e.concat([t,new e([n])]);++r>7;return s}t.encrypt=function(t,i,r){for(var s=i.length,o=new e(s),a=-1;++at.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+n.chunkSize);if(n.windowBits&&(n.windowBitst.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+n.windowBits);if(n.level&&(n.levelt.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+n.level);if(n.memLevel&&(n.memLevelt.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+n.memLevel);if(n.strategy&&n.strategy!=t.Z_FILTERED&&n.strategy!=t.Z_HUFFMAN_ONLY&&n.strategy!=t.Z_RLE&&n.strategy!=t.Z_FIXED&&n.strategy!=t.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+n.strategy);if(n.dictionary&&!e.isBuffer(n.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new b.Zlib(i);var r=this;this._hadError=!1,this._binding.onerror=function(e,n){r._binding=null,r._hadError=!0;var i=new Error(e);i.errno=n,i.code=t.codes[n],r.emit("error",i)};var s=t.Z_DEFAULT_COMPRESSION;"number"==typeof n.level&&(s=n.level);var o=t.Z_DEFAULT_STRATEGY;"number"==typeof n.strategy&&(o=n.strategy),this._binding.init(n.windowBits||t.Z_DEFAULT_WINDOWBITS,s,n.memLevel||t.Z_DEFAULT_MEMLEVEL,o,n.dictionary),this._buffer=new e(this._chunkSize),this._offset=0,this._closed=!1,this._level=s,this._strategy=o,this.once("end",this.close)}var p=n(118),b=n(160),m=n(10),g=n(149).ok;b.Z_MIN_WINDOWBITS=8,b.Z_MAX_WINDOWBITS=15,b.Z_DEFAULT_WINDOWBITS=15,b.Z_MIN_CHUNK=64,b.Z_MAX_CHUNK=1/0,b.Z_DEFAULT_CHUNK=16384,b.Z_MIN_MEMLEVEL=1,b.Z_MAX_MEMLEVEL=9,b.Z_DEFAULT_MEMLEVEL=8,b.Z_MIN_LEVEL=-1,b.Z_MAX_LEVEL=9,b.Z_DEFAULT_LEVEL=b.Z_DEFAULT_COMPRESSION,Object.keys(b).forEach(function(e){e.match(/^Z/)&&(t[e]=b[e])}),t.codes={Z_OK:b.Z_OK,Z_STREAM_END:b.Z_STREAM_END,Z_NEED_DICT:b.Z_NEED_DICT,Z_ERRNO:b.Z_ERRNO,Z_STREAM_ERROR:b.Z_STREAM_ERROR,Z_DATA_ERROR:b.Z_DATA_ERROR,Z_MEM_ERROR:b.Z_MEM_ERROR,Z_BUF_ERROR:b.Z_BUF_ERROR,Z_VERSION_ERROR:b.Z_VERSION_ERROR},Object.keys(t.codes).forEach(function(e){t.codes[t.codes[e]]=e}),t.Deflate=o,t.Inflate=a,t.Gzip=c,t.Gunzip=h,t.DeflateRaw=f,t.InflateRaw=u,t.Unzip=d,t.createDeflate=function(e){return new o(e)},t.createInflate=function(e){return new a(e)},t.createDeflateRaw=function(e){return new f(e)},t.createInflateRaw=function(e){return new u(e)},t.createGzip=function(e){return new c(e)},t.createGunzip=function(e){return new h(e)},t.createUnzip=function(e){return new d(e)},t.deflate=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new o(t),e,n)},t.deflateSync=function(e,t){return s(new o(t),e)},t.gzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new c(t),e,n)},t.gzipSync=function(e,t){return s(new c(t),e)},t.deflateRaw=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new f(t),e,n)},t.deflateRawSync=function(e,t){return s(new f(t),e)},t.unzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new d(t),e,n)},t.unzipSync=function(e,t){return s(new d(t),e)},t.inflate=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new a(t),e,n)},t.inflateSync=function(e,t){return s(new a(t),e)},t.gunzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new h(t),e,n)},t.gunzipSync=function(e,t){return s(new h(t),e)},t.inflateRaw=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new u(t),e,n)},t.inflateRawSync=function(e,t){return s(new u(t),e)},m.inherits(l,p),l.prototype.params=function(e,n,r){if(et.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(n!=t.Z_FILTERED&&n!=t.Z_HUFFMAN_ONLY&&n!=t.Z_RLE&&n!=t.Z_FIXED&&n!=t.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==e||this._strategy!==n){var s=this;this.flush(b.Z_SYNC_FLUSH,function(){s._binding.params(e,n),s._hadError||(s._level=e,s._strategy=n,r&&r())})}else i.nextTick(r)},l.prototype.reset=function(){return this._binding.reset()},l.prototype._flush=function(t){this._transform(new e(0),"",t)},l.prototype.flush=function(t,n){var r=this._writableState;if(("function"==typeof t||void 0===t&&!n)&&(n=t,t=b.Z_FULL_FLUSH),r.ended)n&&i.nextTick(n);else if(r.ending)n&&this.once("end",n);else if(r.needDrain){var s=this;this.once("drain",function(){s.flush(n)})}else this._flushFlag=t,this.write(new e(0),"",n)},l.prototype.close=function(e){if(e&&i.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;i.nextTick(function(){t.emit("close")})}},l.prototype._transform=function(t,n,i){var r,s=this._writableState,o=s.ending||s.ended,a=o&&(!t||s.length===t.length);if(null===!t&&!e.isBuffer(t))return i(new Error("invalid input"));a?r=b.Z_FINISH:(r=this._flushFlag,t.length>=s.length&&(this._flushFlag=this._opts.flush||b.Z_NO_FLUSH));this._processChunk(t,r,i)},l.prototype._processChunk=function(t,n,i){function r(f,l){if(!c._hadError){var p=o-l;if(g(p>=0,"have should not go down"),p>0){var b=c._buffer.slice(c._offset,c._offset+p);c._offset+=p,h?c.push(b):(u.push(b),d+=b.length)}if((0===l||c._offset>=c._chunkSize)&&(o=c._chunkSize,c._offset=0,c._buffer=new e(c._chunkSize)),0===l){if(a+=s-f,s=f,!h)return!0;var m=c._binding.write(n,t,a,s,c._buffer,c._offset,c._chunkSize);return m.callback=r,void(m.buffer=t)}return!!h&&void i()}}var s=t&&t.length,o=this._chunkSize-this._offset,a=0,c=this,h="function"==typeof i;if(!h){var f,u=[],d=0;this.on("error",function(e){f=e});do var l=this._binding.writeSync(n,t,a,s,this._buffer,this._offset,o);while(!this._hadError&&r(l[0],l[1]));if(this._hadError)throw f;var p=e.concat(u,d);return this.close(),p}var b=this._binding.write(n,t,a,s,this._buffer,this._offset,o);b.buffer=t,b.callback=r},m.inherits(o,l),m.inherits(a,l),m.inherits(c,l),m.inherits(h,l),m.inherits(f,l),m.inherits(u,l),m.inherits(d,l)}).call(t,n(0).Buffer,n(8))},function(e,t,n){"use strict";function i(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var n=1732584193,i=-271733879,r=-1732584194,f=271733878,u=0;u>16)+(t>>16)+(n>>16);return i<<16|65535&n}function f(e,t){return e<>>32-t}var u=n(165);e.exports=function(e){return u.hash(e,i,16)}},function(e,t,n){(function(t){function i(){this.init(),this._w=l,u.call(this,64,56)}function r(e,t,n){return n^e&(t^n)}function s(e,t,n){return e&t|n&(e|t)}function o(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function a(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function c(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function h(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}var f=n(2),u=n(22),d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=new Array(64);f(i,u),i.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},i.prototype._update=function(e){for(var t=this._w,n=0|this._a,i=0|this._b,f=0|this._c,u=0|this._d,l=0|this._e,p=0|this._f,b=0|this._g,m=0|this._h,g=0;g<16;++g)t[g]=e.readInt32BE(4*g);for(;g<64;++g)t[g]=h(t[g-2])+t[g-7]+c(t[g-15])+t[g-16]|0;for(var v=0;v<64;++v){var y=m+a(l)+r(l,p,b)+d[v]+t[v]|0,_=o(n)+s(n,i,f)|0;m=b,b=p,p=l,l=u+y|0,u=f,f=i,i=n,n=y+_|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=m+this._h|0},i.prototype._hash=function(){var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(){this.init(),this._w=m,p.call(this,128,112)}function r(e,t,n){return n^e&(t^n)}function s(e,t,n){return e&t|n&(e|t)}function o(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function a(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function c(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function f(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function u(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function d(e,t){return e>>>0>>0?1:0}var l=n(2),p=n(22),b=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],m=new Array(160);l(i,p),i.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},i.prototype._update=function(e){for(var t=this._w,n=0|this._ah,i=0|this._bh,l=0|this._ch,p=0|this._dh,m=0|this._eh,g=0|this._fh,v=0|this._gh,y=0|this._hh,_=0|this._al,w=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,M=0|this._gl,x=0|this._hl,R=0;R<32;R+=2)t[R]=e.readInt32BE(4*R),t[R+1]=e.readInt32BE(4*R+4);for(;R<160;R+=2){var I=t[R-30],T=t[R-30+1],C=c(I,T),D=h(T,I);I=t[R-4],T=t[R-4+1];var P=f(I,T),B=u(T,I),L=t[R-14],O=t[R-14+1],U=t[R-32],N=t[R-32+1],j=D+O|0,q=C+L+d(j,D)|0;j=j+B|0,q=q+P+d(j,B)|0,j=j+N|0,q=q+U+d(j,N)|0,t[R]=q,t[R+1]=j}for(var z=0;z<160;z+=2){q=t[z],j=t[z+1];var F=s(n,i,l),G=s(_,w,E),H=o(n,_),W=o(_,n),V=a(m,k),K=a(k,m),Z=b[z],Y=b[z+1],X=r(m,g,v),J=r(k,A,M),$=x+K|0,Q=y+V+d($,x)|0;$=$+J|0,Q=Q+X+d($,J)|0,$=$+Y|0,Q=Q+Z+d($,Y)|0,$=$+j|0,Q=Q+q+d($,j)|0;var ee=W+G|0,te=H+F+d(ee,W)|0;y=v,x=M,v=g,M=A,g=m,A=k,k=S+$|0,m=p+Q+d(k,S)|0,p=l,S=E,l=i,E=w,i=n,w=_,_=$+ee|0,n=Q+te+d(_,$)|0}this._al=this._al+_|0,this._bl=this._bl+w|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+M|0,this._hl=this._hl+x|0,this._ah=this._ah+n+d(this._al,_)|0,this._bh=this._bh+i+d(this._bl,w)|0,this._ch=this._ch+l+d(this._cl,E)|0,this._dh=this._dh+p+d(this._dl,S)|0,this._eh=this._eh+m+d(this._el,k)|0,this._fh=this._fh+g+d(this._fl,A)|0,this._gh=this._gh+v+d(this._gl,M)|0,this._hh=this._hh+y+d(this._hl,x)|0},i.prototype._hash=function(){function e(e,t,i){n.writeInt32BE(e,i),n.writeInt32BE(t,i+4)}var n=new t(64);return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),n},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){function i(){if(null!==y)return y;var e=1048576,t=[];t[0]=2;for(var n=1,i=3;ie;)n.ishrn(1);if(n.isEven()&&n.iadd(d),n.testn(1)||n.iadd(l),t.cmp(l)){if(!t.cmp(p))for(;n.mod(b).cmp(m);)n.iadd(v)}else for(;n.mod(h).cmp(g);)n.iadd(v);if(i=n.shrn(1),r(i)&&r(n)&&s(i)&&s(n)&&u.test(i)&&u.test(n))return n}}var a=n(30);e.exports=o,o.simpleSieve=r,o.fermatTest=s;var c=n(7),h=new c(24),f=n(107),u=new f,d=new c(1),l=new c(2),p=new c(5),b=(new c(16),new c(8),new c(10)),m=new c(3),g=(new c(7),new c(11)),v=new c(4),y=(new c(12),null)},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){function i(e){this.rand=e||new s.Rand}var r=n(7),s=n(90);e.exports=i,i.create=function(e){return new i(e)},i.prototype._rand=function(e){var t=e.bitLength(),n=this.rand.generate(Math.ceil(t/8));n[0]|=3;var i=7&t;return 0!==i&&(n[n.length-1]>>=7-i),new r(n)},i.prototype.test=function(e,t,n){var i=e.bitLength(),s=r.mont(e),o=new r(1).toRed(s);t||(t=Math.max(1,i/48|0));for(var a=e.subn(1),c=a.subn(1),h=0;!a.testn(h);h++);for(var f=e.shrn(h),u=a.toRed(s),d=!0;t>0;t--){var l=this._rand(c);n&&n(l);var p=l.toRed(s).redPow(f);if(0!==p.cmp(o)&&0!==p.cmp(u)){for(var b=1;b0;t--){var u=this._rand(a),d=e.gcd(u);if(0!==d.cmpn(1))return d;var l=u.toRed(i).redPow(h);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var p=1;p0)throw i.length>1?new Error("options "+i.slice(0,i.length-1).join(", ")+" and "+i[i.length-1]+" must be defined"):new Error("option "+i[0]+" must be defined")}return Object.keys(e).forEach(function(n){n in t&&(t[n]=e[n])}),this},this.copy=function(t){var i={};return Object.keys(e).forEach(function(e){t.indexOf(e)!==-1&&(i[e]=n[e])}),i},this.read=function(e,t){if("function"==typeof t){var n=this;r.readFile(e,function(e,i){if(e)return t(e);var r=JSON.parse(i);n.merge(r),t()})}else{var i=JSON.parse(r.readFileSync(e));this.merge(i)}return this},this.isDefined=function(e){return"undefined"!=typeof n[e]},this.isDefinedAndNonNull=function(e){return"undefined"!=typeof n[e]&&null!==n[e]},Object.freeze(n),Object.freeze(this)}/*! - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -var r=n(13);e.exports=i},function(e,t){"use strict";function n(e,t,n,i){for(var r=65535&e|0,s=e>>>16&65535|0,o=0;0!==n;){o=n>2e3?2e3:n,n-=o;do r=r+t[i++]|0,s=s+r|0;while(--o);r%=65521,s%=65521}return r|s<<16|0}e.exports=n},function(e,t){"use strict";function n(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}function i(e,t,n,i){var s=r,o=i+n;e^=-1;for(var a=i;a>>8^s[255&(e^t[a])];return e^-1}var r=n();e.exports=i},function(e,t){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(e,t,n){(function(e,i){var r=n(53),s=n(214);t.pbkdf2=function(e,n,i,r,o,a){if("function"==typeof o&&(a=o,o=void 0),s(i,r),"function"!=typeof a)throw new Error("No callback provided to pbkdf2");setTimeout(function(){a(null,t.pbkdf2Sync(e,n,i,r,o))})};var o;if(e.browser)o="utf-8";else{var a=parseInt(e.version.split(".")[0].slice(1),10);o=a>=6?"utf-8":"binary"}t.pbkdf2Sync=function(e,t,n,a,c){i.isBuffer(e)||(e=new i(e,o)),i.isBuffer(t)||(t=new i(t,o)),s(n,a),c=c||"sha1";var h,f=1,u=new i(a),d=new i(t.length+4);t.copy(d,0,0,t.length);for(var l,p,b=1;b<=f;b++){d.writeUInt32BE(b,t.length);var m=r(c,e).update(d).digest();h||(h=m.length,p=new i(h),f=Math.ceil(a/h),l=a-(f-1)*h),m.copy(p,0,0,h);for(var g=1;g0)if(t.ended&&!r){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&r){var c=new Error("stream.unshift() after end event");e.emit("error",c)}else{var h;!t.decoder||r||i||(n=t.decoder.write(n),h=!t.objectMode&&0===n.length),r||(t.reading=!1),h||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&d(e))),p(e,t)}else r||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=z?e=z:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function h(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=c(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function f(e,t){var n=null;return P.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function u(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,d(e)}}function d(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(U("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?I(l,e):l(e))}function l(e){U("emit readable"),e.emit("readable"),_(e)}function p(e,t){t.readingMore||(t.readingMore=!0,I(b,e,t))}function b(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=E(e,t.buffer,t.decoder),n}function E(e,t,n){var i;return es.length?s.length:e;if(r+=o===s.length?s:s.slice(0,e),e-=o,0===e){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}function k(e,t){var n=B.allocUnsafe(e),i=t.head,r=1;for(i.data.copy(n),e-=i.data.length;i=i.next;){var s=i.data,o=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,o),e-=o,0===e){o===s.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=s.slice(o));break}++r}return t.length-=r,n}function A(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,I(M,t,e))}function M(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function x(e,t){for(var n=0,i=e.length;n=t.highWaterMark||t.ended))return U("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?A(this):d(this),null;if(e=h(e,t),0===e&&t.ended)return 0===t.length&&A(this),null;var i=t.needReadable;U("need readable",i),(0===t.length||t.length-e0?w(e,t):null,null===r?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&A(this)),null!==r&&this.emit("data",r),r},s.prototype._read=function(e){this.emit("error",new Error("not implemented"))},s.prototype.pipe=function(e,n){function r(e){U("onunpipe"),e===d&&o()}function s(){U("onend"),e.end()}function o(){U("cleanup"),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("drain",g),e.removeListener("error",c),e.removeListener("unpipe",r),d.removeListener("end",s),d.removeListener("end",o),d.removeListener("data",a),v=!0,!l.awaitDrain||e._writableState&&!e._writableState.needDrain||g()}function a(t){U("ondata"),y=!1;var n=e.write(t);!1!==n||y||((1===l.pipesCount&&l.pipes===e||l.pipesCount>1&&R(l.pipes,e)!==-1)&&!v&&(U("false write response, pause",d._readableState.awaitDrain),d._readableState.awaitDrain++,y=!0),d.pause())}function c(t){U("onerror",t),u(),e.removeListener("error",c),0===D(e,"error")&&e.emit("error",t)}function h(){e.removeListener("finish",f),u()}function f(){U("onfinish"),e.removeListener("close",h),u()}function u(){U("unpipe"),d.unpipe(e)}var d=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1,U("pipe count=%d opts=%j",l.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,b=p?s:o;l.endEmitted?I(b):d.once("end",b),e.on("unpipe",r);var g=m(d);e.on("drain",g);var v=!1,y=!1;return d.on("data",a),i(e,"error",c),e.once("close",h),e.once("finish",f),e.emit("pipe",d),l.flowing||(U("pipe resume"),d.resume()),e},s.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var r=0;r>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=i>>24&255,e[t+5]=i>>16&255,e[t+6]=i>>8&255,e[t+7]=255&i}function i(e,t,n,i,r){var s,o=0;for(s=0;s>>8)-1}function r(e,t,n,r){return i(e,t,n,r,16)}function s(e,t,n,r){return i(e,t,n,r,32)}function o(e,t,n,i){for(var r,s=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,f=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,d=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,b=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,g=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,v=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,y=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,_=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,w=s,E=o,S=a,k=c,A=h,M=f,x=u,R=d,I=l,T=p,C=b,D=m,P=g,B=v,L=y,O=_,U=0;U<20;U+=2)r=w+P|0,A^=r<<7|r>>>25,r=A+w|0,I^=r<<9|r>>>23,r=I+A|0,P^=r<<13|r>>>19,r=P+I|0,w^=r<<18|r>>>14,r=M+E|0,T^=r<<7|r>>>25,r=T+M|0,B^=r<<9|r>>>23,r=B+T|0,E^=r<<13|r>>>19,r=E+B|0,M^=r<<18|r>>>14,r=C+x|0,L^=r<<7|r>>>25,r=L+C|0,S^=r<<9|r>>>23,r=S+L|0,x^=r<<13|r>>>19,r=x+S|0,C^=r<<18|r>>>14,r=O+D|0,k^=r<<7|r>>>25,r=k+O|0,R^=r<<9|r>>>23,r=R+k|0,D^=r<<13|r>>>19,r=D+R|0,O^=r<<18|r>>>14,r=w+k|0,E^=r<<7|r>>>25,r=E+w|0,S^=r<<9|r>>>23,r=S+E|0,k^=r<<13|r>>>19,r=k+S|0,w^=r<<18|r>>>14,r=M+A|0,x^=r<<7|r>>>25,r=x+M|0,R^=r<<9|r>>>23,r=R+x|0,A^=r<<13|r>>>19,r=A+R|0,M^=r<<18|r>>>14,r=C+T|0,D^=r<<7|r>>>25,r=D+C|0,I^=r<<9|r>>>23,r=I+D|0,T^=r<<13|r>>>19,r=T+I|0,C^=r<<18|r>>>14,r=O+L|0,P^=r<<7|r>>>25,r=P+O|0,B^=r<<9|r>>>23,r=B+P|0,L^=r<<13|r>>>19,r=L+B|0,O^=r<<18|r>>>14;w=w+s|0,E=E+o|0,S=S+a|0,k=k+c|0,A=A+h|0,M=M+f|0,x=x+u|0,R=R+d|0,I=I+l|0,T=T+p|0,C=C+b|0,D=D+m|0,P=P+g|0,B=B+v|0,L=L+y|0,O=O+_|0,e[0]=w>>>0&255,e[1]=w>>>8&255,e[2]=w>>>16&255,e[3]=w>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=M>>>0&255,e[21]=M>>>8&255,e[22]=M>>>16&255,e[23]=M>>>24&255,e[24]=x>>>0&255,e[25]=x>>>8&255,e[26]=x>>>16&255,e[27]=x>>>24&255,e[28]=R>>>0&255,e[29]=R>>>8&255,e[30]=R>>>16&255,e[31]=R>>>24&255,e[32]=I>>>0&255,e[33]=I>>>8&255,e[34]=I>>>16&255,e[35]=I>>>24&255,e[36]=T>>>0&255,e[37]=T>>>8&255,e[38]=T>>>16&255,e[39]=T>>>24&255,e[40]=C>>>0&255,e[41]=C>>>8&255,e[42]=C>>>16&255,e[43]=C>>>24&255,e[44]=D>>>0&255,e[45]=D>>>8&255,e[46]=D>>>16&255,e[47]=D>>>24&255,e[48]=P>>>0&255,e[49]=P>>>8&255,e[50]=P>>>16&255,e[51]=P>>>24&255,e[52]=B>>>0&255,e[53]=B>>>8&255,e[54]=B>>>16&255,e[55]=B>>>24&255,e[56]=L>>>0&255,e[57]=L>>>8&255,e[58]=L>>>16&255,e[59]=L>>>24&255,e[60]=O>>>0&255,e[61]=O>>>8&255,e[62]=O>>>16&255,e[63]=O>>>24&255}function a(e,t,n,i){for(var r,s=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,f=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,u=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,d=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,b=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,g=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,v=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,y=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,_=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,w=s,E=o,S=a,k=c,A=h,M=f,x=u,R=d,I=l,T=p,C=b,D=m,P=g,B=v,L=y,O=_,U=0;U<20;U+=2)r=w+P|0,A^=r<<7|r>>>25,r=A+w|0,I^=r<<9|r>>>23,r=I+A|0,P^=r<<13|r>>>19,r=P+I|0,w^=r<<18|r>>>14,r=M+E|0,T^=r<<7|r>>>25,r=T+M|0,B^=r<<9|r>>>23,r=B+T|0,E^=r<<13|r>>>19,r=E+B|0,M^=r<<18|r>>>14,r=C+x|0,L^=r<<7|r>>>25,r=L+C|0,S^=r<<9|r>>>23,r=S+L|0,x^=r<<13|r>>>19,r=x+S|0,C^=r<<18|r>>>14,r=O+D|0,k^=r<<7|r>>>25,r=k+O|0,R^=r<<9|r>>>23,r=R+k|0,D^=r<<13|r>>>19,r=D+R|0,O^=r<<18|r>>>14,r=w+k|0,E^=r<<7|r>>>25,r=E+w|0,S^=r<<9|r>>>23,r=S+E|0,k^=r<<13|r>>>19,r=k+S|0,w^=r<<18|r>>>14,r=M+A|0,x^=r<<7|r>>>25,r=x+M|0,R^=r<<9|r>>>23,r=R+x|0,A^=r<<13|r>>>19,r=A+R|0,M^=r<<18|r>>>14,r=C+T|0,D^=r<<7|r>>>25,r=D+C|0,I^=r<<9|r>>>23,r=I+D|0,T^=r<<13|r>>>19,r=T+I|0,C^=r<<18|r>>>14,r=O+L|0,P^=r<<7|r>>>25,r=P+O|0,B^=r<<9|r>>>23,r=B+P|0,L^=r<<13|r>>>19,r=L+B|0,O^=r<<18|r>>>14;e[0]=w>>>0&255,e[1]=w>>>8&255,e[2]=w>>>16&255,e[3]=w>>>24&255,e[4]=M>>>0&255,e[5]=M>>>8&255,e[6]=M>>>16&255,e[7]=M>>>24&255,e[8]=C>>>0&255,e[9]=C>>>8&255,e[10]=C>>>16&255,e[11]=C>>>24&255,e[12]=O>>>0&255,e[13]=O>>>8&255,e[14]=O>>>16&255,e[15]=O>>>24&255,e[16]=x>>>0&255,e[17]=x>>>8&255,e[18]=x>>>16&255,e[19]=x>>>24&255,e[20]=R>>>0&255,e[21]=R>>>8&255,e[22]=R>>>16&255,e[23]=R>>>24&255,e[24]=I>>>0&255,e[25]=I>>>8&255,e[26]=I>>>16&255,e[27]=I>>>24&255,e[28]=T>>>0&255,e[29]=T>>>8&255,e[30]=T>>>16&255,e[31]=T>>>24&255}function c(e,t,n,i){o(e,t,n,i)}function h(e,t,n,i){a(e,t,n,i)}function f(e,t,n,i,r,s,o){var a,h,f=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)f[h]=0;for(h=0;h<8;h++)f[h]=s[h];for(;r>=64;){for(c(u,f,o,de),h=0;h<64;h++)e[t+h]=n[i+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&f[h])|0,f[h]=255&a,a>>>=8;r-=64,t+=64,i+=64}if(r>0)for(c(u,f,o,de),h=0;h=64;){for(c(h,a,r,de),o=0;o<64;o++)e[t+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,t+=64}if(n>0)for(c(h,a,r,de),o=0;o>16&1),s[n-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),r=s[15]>>16&1,s[14]&=65535,_(o,s,1-r)}for(n=0;n<16;n++)e[2*n]=255&o[n],e[2*n+1]=o[n]>>8}function E(e,t){var n=new Uint8Array(32),i=new Uint8Array(32);return w(n,e),w(i,t),s(n,0,i,0)}function S(e){var t=new Uint8Array(32);return w(t,e),1&t[0]}function k(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function A(e,t,n){for(var i=0;i<16;i++)e[i]=t[i]+n[i]}function M(e,t,n){for(var i=0;i<16;i++)e[i]=t[i]-n[i]}function x(e,t,n){var i,r,s=0,o=0,a=0,c=0,h=0,f=0,u=0,d=0,l=0,p=0,b=0,m=0,g=0,v=0,y=0,_=0,w=0,E=0,S=0,k=0,A=0,M=0,x=0,R=0,I=0,T=0,C=0,D=0,P=0,B=0,L=0,O=n[0],U=n[1],N=n[2],j=n[3],q=n[4],z=n[5],F=n[6],G=n[7],H=n[8],W=n[9],V=n[10],K=n[11],Z=n[12],Y=n[13],X=n[14],J=n[15];i=t[0],s+=i*O,o+=i*U,a+=i*N,c+=i*j,h+=i*q,f+=i*z,u+=i*F,d+=i*G,l+=i*H,p+=i*W,b+=i*V,m+=i*K,g+=i*Z,v+=i*Y,y+=i*X,_+=i*J,i=t[1],o+=i*O,a+=i*U,c+=i*N,h+=i*j,f+=i*q,u+=i*z,d+=i*F,l+=i*G,p+=i*H,b+=i*W,m+=i*V,g+=i*K,v+=i*Z,y+=i*Y,_+=i*X,w+=i*J,i=t[2],a+=i*O,c+=i*U,h+=i*N,f+=i*j,u+=i*q,d+=i*z,l+=i*F,p+=i*G,b+=i*H,m+=i*W,g+=i*V,v+=i*K,y+=i*Z,_+=i*Y,w+=i*X,E+=i*J,i=t[3],c+=i*O,h+=i*U,f+=i*N,u+=i*j,d+=i*q,l+=i*z,p+=i*F,b+=i*G,m+=i*H,g+=i*W,v+=i*V,y+=i*K,_+=i*Z,w+=i*Y,E+=i*X,S+=i*J,i=t[4],h+=i*O,f+=i*U,u+=i*N,d+=i*j,l+=i*q,p+=i*z,b+=i*F,m+=i*G,g+=i*H,v+=i*W,y+=i*V,_+=i*K,w+=i*Z,E+=i*Y,S+=i*X,k+=i*J,i=t[5],f+=i*O,u+=i*U,d+=i*N,l+=i*j,p+=i*q,b+=i*z,m+=i*F,g+=i*G,v+=i*H,y+=i*W,_+=i*V,w+=i*K,E+=i*Z,S+=i*Y,k+=i*X,A+=i*J,i=t[6],u+=i*O,d+=i*U,l+=i*N,p+=i*j,b+=i*q,m+=i*z,g+=i*F,v+=i*G,y+=i*H,_+=i*W,w+=i*V,E+=i*K,S+=i*Z,k+=i*Y,A+=i*X,M+=i*J,i=t[7],d+=i*O,l+=i*U,p+=i*N,b+=i*j,m+=i*q,g+=i*z,v+=i*F,y+=i*G,_+=i*H,w+=i*W,E+=i*V,S+=i*K,k+=i*Z,A+=i*Y,M+=i*X,x+=i*J,i=t[8],l+=i*O,p+=i*U,b+=i*N,m+=i*j,g+=i*q,v+=i*z,y+=i*F,_+=i*G,w+=i*H,E+=i*W,S+=i*V,k+=i*K,A+=i*Z,M+=i*Y,x+=i*X,R+=i*J,i=t[9],p+=i*O,b+=i*U,m+=i*N,g+=i*j,v+=i*q,y+=i*z,_+=i*F,w+=i*G,E+=i*H,S+=i*W,k+=i*V,A+=i*K,M+=i*Z,x+=i*Y,R+=i*X,I+=i*J,i=t[10],b+=i*O,m+=i*U,g+=i*N,v+=i*j,y+=i*q,_+=i*z,w+=i*F,E+=i*G,S+=i*H,k+=i*W,A+=i*V,M+=i*K,x+=i*Z,R+=i*Y,I+=i*X,T+=i*J,i=t[11],m+=i*O,g+=i*U,v+=i*N,y+=i*j,_+=i*q,w+=i*z,E+=i*F,S+=i*G,k+=i*H,A+=i*W,M+=i*V,x+=i*K;R+=i*Z;I+=i*Y,T+=i*X,C+=i*J,i=t[12],g+=i*O,v+=i*U,y+=i*N,_+=i*j,w+=i*q,E+=i*z,S+=i*F,k+=i*G,A+=i*H,M+=i*W,x+=i*V,R+=i*K,I+=i*Z,T+=i*Y,C+=i*X,D+=i*J,i=t[13],v+=i*O,y+=i*U,_+=i*N,w+=i*j,E+=i*q,S+=i*z,k+=i*F,A+=i*G,M+=i*H,x+=i*W,R+=i*V,I+=i*K,T+=i*Z,C+=i*Y,D+=i*X,P+=i*J,i=t[14],y+=i*O,_+=i*U,w+=i*N,E+=i*j,S+=i*q,k+=i*z,A+=i*F,M+=i*G,x+=i*H,R+=i*W,I+=i*V,T+=i*K,C+=i*Z,D+=i*Y,P+=i*X,B+=i*J,i=t[15],_+=i*O,w+=i*U,E+=i*N,S+=i*j,k+=i*q,A+=i*z,M+=i*F,x+=i*G,R+=i*H,I+=i*W,T+=i*V,C+=i*K,D+=i*Z,P+=i*Y,B+=i*X,L+=i*J,s+=38*w,o+=38*E,a+=38*S,c+=38*k,h+=38*A,f+=38*M,u+=38*x,d+=38*R,l+=38*I,p+=38*T,b+=38*C,m+=38*D,g+=38*P,v+=38*B,y+=38*L,r=1,i=s+r+65535,r=Math.floor(i/65536),s=i-65536*r,i=o+r+65535,r=Math.floor(i/65536),o=i-65536*r,i=a+r+65535,r=Math.floor(i/65536),a=i-65536*r,i=c+r+65535,r=Math.floor(i/65536),c=i-65536*r,i=h+r+65535,r=Math.floor(i/65536),h=i-65536*r,i=f+r+65535,r=Math.floor(i/65536),f=i-65536*r,i=u+r+65535,r=Math.floor(i/65536),u=i-65536*r,i=d+r+65535,r=Math.floor(i/65536),d=i-65536*r,i=l+r+65535,r=Math.floor(i/65536),l=i-65536*r,i=p+r+65535,r=Math.floor(i/65536),p=i-65536*r,i=b+r+65535,r=Math.floor(i/65536),b=i-65536*r,i=m+r+65535,r=Math.floor(i/65536),m=i-65536*r,i=g+r+65535,r=Math.floor(i/65536),g=i-65536*r,i=v+r+65535,r=Math.floor(i/65536),v=i-65536*r,i=y+r+65535,r=Math.floor(i/65536),y=i-65536*r,i=_+r+65535,r=Math.floor(i/65536),_=i-65536*r,s+=r-1+37*(r-1),r=1,i=s+r+65535,r=Math.floor(i/65536),s=i-65536*r,i=o+r+65535,r=Math.floor(i/65536),o=i-65536*r,i=a+r+65535,r=Math.floor(i/65536),a=i-65536*r,i=c+r+65535,r=Math.floor(i/65536),c=i-65536*r,i=h+r+65535,r=Math.floor(i/65536),h=i-65536*r,i=f+r+65535,r=Math.floor(i/65536),f=i-65536*r,i=u+r+65535,r=Math.floor(i/65536),u=i-65536*r,i=d+r+65535,r=Math.floor(i/65536),d=i-65536*r,i=l+r+65535,r=Math.floor(i/65536),l=i-65536*r,i=p+r+65535,r=Math.floor(i/65536),p=i-65536*r,i=b+r+65535,r=Math.floor(i/65536),b=i-65536*r,i=m+r+65535,r=Math.floor(i/65536),m=i-65536*r,i=g+r+65535,r=Math.floor(i/65536),g=i-65536*r,i=v+r+65535,r=Math.floor(i/65536),v=i-65536*r,i=y+r+65535,r=Math.floor(i/65536),y=i-65536*r,i=_+r+65535,r=Math.floor(i/65536),_=i-65536*r,s+=r-1+37*(r-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=h,e[5]=f,e[6]=u,e[7]=d,e[8]=l,e[9]=p,e[10]=b,e[11]=m,e[12]=g,e[13]=v;e[14]=y;e[15]=_}function R(e,t){x(e,t,t)}function I(e,t){var n,i=ee();for(n=0;n<16;n++)i[n]=t[n];for(n=253;n>=0;n--)R(i,i),2!==n&&4!==n&&x(i,i,t);for(n=0;n<16;n++)e[n]=i[n]}function T(e,t){var n,i=ee();for(n=0;n<16;n++)i[n]=t[n];for(n=250;n>=0;n--)R(i,i),1!==n&&x(i,i,t);for(n=0;n<16;n++)e[n]=i[n]}function C(e,t,n){var i,r,s=new Uint8Array(32),o=new Float64Array(80),a=ee(),c=ee(),h=ee(),f=ee(),u=ee(),d=ee();for(r=0;r<31;r++)s[r]=t[r];for(s[31]=127&t[31]|64,s[0]&=248,k(o,n),r=0;r<16;r++)c[r]=o[r],f[r]=a[r]=h[r]=0;for(a[0]=f[0]=1,r=254;r>=0;--r)i=s[r>>>3]>>>(7&r)&1,_(a,c,i),_(h,f,i),A(u,a,h),M(a,a,h),A(h,c,f),M(c,c,f),R(f,u),R(d,a),x(a,h,a),x(h,c,u),A(u,a,h),M(a,a,h),R(c,a),M(h,f,d),x(a,h,oe),A(a,a,f),x(h,h,a),x(a,f,d),x(f,c,o),R(c,u),_(a,c,i),_(h,f,i);for(r=0;r<16;r++)o[r+16]=a[r],o[r+32]=h[r],o[r+48]=c[r],o[r+64]=f[r];var l=o.subarray(32),p=o.subarray(16);return I(l,l),x(p,p,l),w(e,p),0}function D(e,t){return C(e,t,ie)}function P(e,t){return te(t,32),D(e,t)}function B(e,t,n){var i=new Uint8Array(32);return C(i,n,t),h(e,ne,i,de)}function L(e,t,n,i,r,s){var o=new Uint8Array(32);return B(o,r,s),pe(e,t,n,i,o)}function O(e,t,n,i,r,s){var o=new Uint8Array(32);return B(o,r,s),be(e,t,n,i,o)}function U(e,t,n,i){for(var r,s,o,a,c,h,f,u,d,l,p,b,m,g,v,y,_,w,E,S,k,A,M,x,R,I,T=new Int32Array(16),C=new Int32Array(16),D=e[0],P=e[1],B=e[2],L=e[3],O=e[4],U=e[5],N=e[6],j=e[7],q=t[0],z=t[1],F=t[2],G=t[3],H=t[4],W=t[5],V=t[6],K=t[7],Z=0;i>=128;){for(E=0;E<16;E++)S=8*E+Z,T[E]=n[S+0]<<24|n[S+1]<<16|n[S+2]<<8|n[S+3],C[E]=n[S+4]<<24|n[S+5]<<16|n[S+6]<<8|n[S+7];for(E=0;E<80;E++)if(r=D,s=P,o=B,a=L,c=O,h=U,f=N,u=j,d=q,l=z,p=F,b=G,m=H,g=W,v=V,y=K,k=j,A=K,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=(O>>>14|H<<18)^(O>>>18|H<<14)^(H>>>9|O<<23),A=(H>>>14|O<<18)^(H>>>18|O<<14)^(O>>>9|H<<23),M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,k=O&U^~O&N,A=H&W^~H&V,M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,k=me[2*E],A=me[2*E+1],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,k=T[E%16],A=C[E%16],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,_=65535&R|I<<16,w=65535&M|x<<16,k=_,A=w,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=(D>>>28|q<<4)^(q>>>2|D<<30)^(q>>>7|D<<25),A=(q>>>28|D<<4)^(D>>>2|q<<30)^(D>>>7|q<<25),M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,k=D&P^D&B^P&B,A=q&z^q&F^z&F,M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,u=65535&R|I<<16,y=65535&M|x<<16,k=a,A=b,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=_,A=w,M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,a=65535&R|I<<16,b=65535&M|x<<16,P=r,B=s,L=o,O=a,U=c,N=h,j=f,D=u,z=d,F=l,G=p,H=b,W=m,V=g,K=v,q=y,E%16===15)for(S=0;S<16;S++)k=T[S],A=C[S],M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=T[(S+9)%16],A=C[(S+9)%16],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,_=T[(S+1)%16],w=C[(S+1)%16],k=(_>>>1|w<<31)^(_>>>8|w<<24)^_>>>7,A=(w>>>1|_<<31)^(w>>>8|_<<24)^(w>>>7|_<<25),M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,_=T[(S+14)%16],w=C[(S+14)%16],k=(_>>>19|w<<13)^(w>>>29|_<<3)^_>>>6,A=(w>>>19|_<<13)^(_>>>29|w<<3)^(w>>>6|_<<26),M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,T[S]=65535&R|I<<16,C[S]=65535&M|x<<16;k=D,A=q,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[0],A=t[0],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[0]=D=65535&R|I<<16,t[0]=q=65535&M|x<<16,k=P,A=z,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[1],A=t[1],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[1]=P=65535&R|I<<16,t[1]=z=65535&M|x<<16,k=B,A=F,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[2],A=t[2],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[2]=B=65535&R|I<<16,t[2]=F=65535&M|x<<16,k=L,A=G,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[3],A=t[3],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[3]=L=65535&R|I<<16,t[3]=G=65535&M|x<<16,k=O,A=H,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[4],A=t[4],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[4]=O=65535&R|I<<16,t[4]=H=65535&M|x<<16,k=U,A=W,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[5],A=t[5],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[5]=U=65535&R|I<<16,t[5]=W=65535&M|x<<16,k=N,A=V,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[6],A=t[6],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[6]=N=65535&R|I<<16,t[6]=V=65535&M|x<<16,k=j,A=K,M=65535&A,x=A>>>16,R=65535&k,I=k>>>16,k=e[7],A=t[7],M+=65535&A,x+=A>>>16,R+=65535&k,I+=k>>>16,x+=M>>>16,R+=x>>>16,I+=R>>>16,e[7]=j=65535&R|I<<16,t[7]=K=65535&M|x<<16,Z+=128,i-=128}return i}function N(e,n,i){var r,s=new Int32Array(8),o=new Int32Array(8),a=new Uint8Array(256),c=i;for(s[0]=1779033703,s[1]=3144134277,s[2]=1013904242,s[3]=2773480762,s[4]=1359893119,s[5]=2600822924,s[6]=528734635,s[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,U(s,o,n,i),i%=128,r=0;r=0;--r)i=n[r/8|0]>>(7&r)&1,q(e,t,i),j(t,e),j(e,e),q(e,t,i)}function G(e,t){var n=[ee(),ee(),ee(),ee()];v(n[0],he),v(n[1],fe),v(n[2],se),x(n[3],he,fe),F(e,n,t)}function H(e,t,n){var i,r=new Uint8Array(64),s=[ee(),ee(),ee(),ee()];for(n||te(t,32),N(r,t,32),r[0]&=248,r[31]&=127,r[31]|=64,G(s,r),z(e,s),i=0;i<32;i++)t[i+32]=e[i];return 0}function W(e,t){var n,i,r,s;for(i=63;i>=32;--i){for(n=0,r=i-32,s=i-12;r>8,t[r]-=256*n;t[r]+=n,t[i]=0}for(n=0,r=0;r<32;r++)t[r]+=n-(t[31]>>4)*ge[r],n=t[r]>>8,t[r]&=255;for(r=0;r<32;r++)t[r]-=n*ge[r];for(i=0;i<32;i++)t[i+1]+=t[i]>>8,e[i]=255&t[i]}function V(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;W(e,n)}function K(e,t,n,i){var r,s,o=new Uint8Array(64),a=new Uint8Array(64),c=new Uint8Array(64),h=new Float64Array(64),f=[ee(),ee(),ee(),ee()];N(o,i,32),o[0]&=248,o[31]&=127,o[31]|=64;var u=n+64;for(r=0;r>7&&M(e[0],re,e[0]),x(e[3],e[0],e[1]),0)}function Y(e,t,n,i){var r,o,a=new Uint8Array(32),c=new Uint8Array(64),h=[ee(),ee(),ee(),ee()],f=[ee(),ee(),ee(),ee()];if(o=-1,n<64)return-1;if(Z(f,i))return-1;for(r=0;r>>13|n<<3),i=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|i<<6),r=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(i>>>7|r<<9),s=255&e[8]|(255&e[9])<<8,this.r[4]=255&(r>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};le.prototype.blocks=function(e,t,n){for(var i,r,s,o,a,c,h,f,u,d,l,p,b,m,g,v,y,_,w,E=this.fin?0:2048,S=this.h[0],k=this.h[1],A=this.h[2],M=this.h[3],x=this.h[4],R=this.h[5],I=this.h[6],T=this.h[7],C=this.h[8],D=this.h[9],P=this.r[0],B=this.r[1],L=this.r[2],O=this.r[3],U=this.r[4],N=this.r[5],j=this.r[6],q=this.r[7],z=this.r[8],F=this.r[9];n>=16;)i=255&e[t+0]|(255&e[t+1])<<8,S+=8191&i,r=255&e[t+2]|(255&e[t+3])<<8,k+=8191&(i>>>13|r<<3),s=255&e[t+4]|(255&e[t+5])<<8,A+=8191&(r>>>10|s<<6),o=255&e[t+6]|(255&e[t+7])<<8,M+=8191&(s>>>7|o<<9),a=255&e[t+8]|(255&e[t+9])<<8,x+=8191&(o>>>4|a<<12),R+=a>>>1&8191,c=255&e[t+10]|(255&e[t+11])<<8,I+=8191&(a>>>14|c<<2),h=255&e[t+12]|(255&e[t+13])<<8,T+=8191&(c>>>11|h<<5),f=255&e[t+14]|(255&e[t+15])<<8,C+=8191&(h>>>8|f<<8),D+=f>>>5|E,u=0,d=u,d+=S*P,d+=k*(5*F),d+=A*(5*z),d+=M*(5*q),d+=x*(5*j),u=d>>>13,d&=8191,d+=R*(5*N),d+=I*(5*U),d+=T*(5*O),d+=C*(5*L),d+=D*(5*B),u+=d>>>13,d&=8191,l=u,l+=S*B,l+=k*P,l+=A*(5*F),l+=M*(5*z),l+=x*(5*q),u=l>>>13,l&=8191,l+=R*(5*j),l+=I*(5*N),l+=T*(5*U),l+=C*(5*O),l+=D*(5*L),u+=l>>>13,l&=8191,p=u,p+=S*L,p+=k*B,p+=A*P,p+=M*(5*F),p+=x*(5*z),u=p>>>13,p&=8191,p+=R*(5*q),p+=I*(5*j),p+=T*(5*N),p+=C*(5*U),p+=D*(5*O),u+=p>>>13,p&=8191,b=u,b+=S*O,b+=k*L,b+=A*B,b+=M*P,b+=x*(5*F),u=b>>>13,b&=8191,b+=R*(5*z),b+=I*(5*q),b+=T*(5*j),b+=C*(5*N),b+=D*(5*U),u+=b>>>13,b&=8191,m=u,m+=S*U,m+=k*O,m+=A*L,m+=M*B,m+=x*P,u=m>>>13,m&=8191,m+=R*(5*F),m+=I*(5*z),m+=T*(5*q),m+=C*(5*j),m+=D*(5*N),u+=m>>>13,m&=8191,g=u,g+=S*N,g+=k*U,g+=A*O,g+=M*L,g+=x*B,u=g>>>13,g&=8191,g+=R*P,g+=I*(5*F),g+=T*(5*z),g+=C*(5*q),g+=D*(5*j),u+=g>>>13,g&=8191,v=u,v+=S*j,v+=k*N,v+=A*U,v+=M*O,v+=x*L,u=v>>>13,v&=8191,v+=R*B,v+=I*P,v+=T*(5*F),v+=C*(5*z),v+=D*(5*q),u+=v>>>13,v&=8191,y=u,y+=S*q,y+=k*j,y+=A*N,y+=M*U,y+=x*O,u=y>>>13,y&=8191,y+=R*L,y+=I*B,y+=T*P,y+=C*(5*F),y+=D*(5*z),u+=y>>>13,y&=8191,_=u,_+=S*z,_+=k*q,_+=A*j,_+=M*N,_+=x*U,u=_>>>13,_&=8191,_+=R*O,_+=I*L,_+=T*B,_+=C*P,_+=D*(5*F),u+=_>>>13,_&=8191,w=u,w+=S*F,w+=k*z,w+=A*q,w+=M*j,w+=x*N,u=w>>>13,w&=8191,w+=R*U,w+=I*O,w+=T*L,w+=C*B,w+=D*P,u+=w>>>13,w&=8191,u=(u<<2)+u|0,u=u+d|0,d=8191&u,u>>>=13,l+=u,S=d,k=l,A=p,M=b,x=m,R=g,I=v,T=y,C=_,D=w,t+=16,n-=16;this.h[0]=S,this.h[1]=k,this.h[2]=A,this.h[3]=M,this.h[4]=x,this.h[5]=R,this.h[6]=I,this.h[7]=T,this.h[8]=C,this.h[9]=D},le.prototype.finish=function(e,t){var n,i,r,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,i=(1^n)-1,s=0;s<10;s++)o[s]&=i;for(i=~i,s=0;s<10;s++)this.h[s]=this.h[s]&i|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),r=this.h[0]+this.pad[0],this.h[0]=65535&r,s=1;s<8;s++)r=(this.h[s]+this.pad[s]|0)+(r>>>16)|0,this.h[s]=65535&r;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},le.prototype.update=function(e,t,n){var i,r;if(this.leftover){for(r=16-this.leftover,r>n&&(r=n),i=0;i=16&&(r=n-n%16,this.blocks(e,t,r),t+=r,n-=r),n){for(i=0;i=0},e.sign.keyPair=function(){var e=new Uint8Array(Ce),t=new Uint8Array(De);return H(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if($(e),e.length!==De)throw new Error("bad secret key size");for(var t=new Uint8Array(Ce),n=0;n - * MIT Licensed - */ -var i=e.exports=n(129);i.Server=n(246),i.Sender=n(128),i.Receiver=n(127),i.createServer=function(e,t){var n=new i.Server(e);return"function"==typeof t&&n.on("connection",t),n},i.connect=i.createConnection=function(e,t){var n=new i(e);return"function"==typeof t&&n.on("open",t),n}},function(e,t,n){"use strict";/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -try{e.exports=n(162)}catch(t){e.exports=n(241)}},function(e,t){/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -e.exports={isValidErrorCode:function(e){return e>=1e3&&e<=1011&&1004!=e&&1005!=e&&1006!=e||e>=3e3&&e<=4999},1e3:"normal",1001:"going away",1002:"protocol error",1003:"unsupported data",1004:"reserved",1005:"reserved for extensions",1006:"reserved for extensions",1007:"inconsistent or invalid data",1008:"policy violation",1009:"message too big",1010:"extension handshake missing",1011:"an unexpected condition prevented the request from being fulfilled"}},function(e,t,n){function i(e){e=e||"";var t={};return e.split(",").forEach(function(e){var n=e.split(";"),i=n.shift().trim(),r=t[i]=t[i]||[],s={};n.forEach(function(e){var t=e.trim().split("="),n=t[0],i=t[1];"undefined"==typeof i?i=!0:('"'===i[0]&&(i=i.slice(1)),'"'===i[i.length-1]&&(i=i.slice(0,i.length-1))),(s[n]=s[n]||[]).push(i)}),r.push(s)}),t}function r(e){return Object.keys(e).map(function(t){var n=e[t];return s.isArray(n)||(n=[n]),n.map(function(e){return[t].concat(Object.keys(e).map(function(t){var n=e[t];return s.isArray(n)||(n=[n]),n.map(function(e){return e===!0?t:t+"="+e}).join("; ")})).join("; ")}).join(", ")}).join(", ")}var s=n(10);t.parse=i,t.format=r},function(e,t,n){(function(t){function i(e,n){if(this instanceof i==!1)throw new TypeError("Classes can't be function-called");"number"==typeof e&&(n=e,e={});var r=-1;this.fragmentedBufferPool=new f(1024,function(e,t){return e.used+t},function(e){return r=r>=0?Math.ceil((r+e.used)/2):e.used});var s=-1;this.unfragmentedBufferPool=new f(1024,function(e,t){return e.used+t},function(e){return s=s>=0?Math.ceil((s+e.used)/2):e.used}),this.extensions=e||{},this.maxPayload=n||0,this.currentPayloadLength=0,this.state={activeFragmentedOperation:null,lastFragment:!1,masked:!1,opcode:0,fragmentedOperation:!1},this.overflow=[],this.headerBuffer=new t(10),this.expectOffset=0,this.expectBuffer=null,this.expectHandler=null,this.currentMessage=[],this.currentMessageLength=0,this.messageHandlers=[],this.expectHeader(2,this.processPacket),this.dead=!1,this.processing=!1,this.onerror=function(){},this.ontext=function(){},this.onbinary=function(){},this.onclose=function(){},this.onping=function(){},this.onpong=function(){}}function r(e){return(this[e]<<8)+this[e+1]}function s(e){return(this[e]<<24)+(this[e+1]<<16)+(this[e+2]<<8)+this[e+3]}function o(e,t,n,i){switch(e){default:t.copy(n,i,0,e);break;case 16:n[i+15]=t[15];case 15:n[i+14]=t[14];case 14:n[i+13]=t[13];case 13:n[i+12]=t[12];case 12:n[i+11]=t[11];case 11:n[i+10]=t[10];case 10:n[i+9]=t[9];case 9:n[i+8]=t[8];case 8:n[i+7]=t[7];case 7:n[i+6]=t[6];case 6:n[i+5]=t[5];case 5:n[i+4]=t[4];case 4:n[i+3]=t[3];case 3:n[i+2]=t[2];case 2:n[i+1]=t[1];case 1:n[i]=t[0]}}function a(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -var c=(n(10),n(245).Validation),h=n(125),f=n(240),u=n(124).BufferUtil,d=n(44);e.exports=i,i.prototype.add=function(e){if(!this.dead){var t=e.length;if(0!=t){if(null==this.expectBuffer)return void this.overflow.push(e);var n=Math.min(t,this.expectBuffer.length-this.expectOffset);for(o(n,e,this.expectBuffer,this.expectOffset),this.expectOffset+=n,n0&&this.overflow.length>0;){var i=this.overflow.pop();n0&&this.overflow.length>0;){var i=this.overflow.pop();n=8&&t)return void this.error("control frames cannot have the Per-message Compressed bits",1002);this.state.compressed=t,this.state.opcode=n,this.state.lastFragment===!1?(this.state.fragmentedOperation=!0,this.state.activeFragmentedOperation=n):this.state.fragmentedOperation=!1}var i=l[this.state.opcode];"undefined"==typeof i?this.error("no handler for opcode "+this.state.opcode,1002):i.start.call(this,e)},i.prototype.endPacket=function(){this.dead||(this.state.fragmentedOperation?this.state.lastFragment&&this.fragmentedBufferPool.reset(!0):this.unfragmentedBufferPool.reset(!0),this.expectOffset=0,this.expectBuffer=null,this.expectHandler=null,this.state.lastFragment&&this.state.opcode===this.state.activeFragmentedOperation&&(this.state.activeFragmentedOperation=null),this.currentPayloadLength=0,this.state.lastFragment=!1,this.state.opcode=null!=this.state.activeFragmentedOperation?this.state.activeFragmentedOperation:0,this.state.masked=!1,this.expectHeader(2,this.processPacket))},i.prototype.reset=function(){this.dead||(this.state={activeFragmentedOperation:null,lastFragment:!1,masked:!1,opcode:0,fragmentedOperation:!1},this.fragmentedBufferPool.reset(!0),this.unfragmentedBufferPool.reset(!0),this.expectOffset=0,this.expectBuffer=null,this.expectHandler=null,this.overflow=[],this.currentMessage=[],this.currentMessageLength=0,this.messageHandlers=[],this.currentPayloadLength=0)},i.prototype.unmask=function(e,t,n){return null!=e&&null!=t&&u.unmask(t,e),n?t:null!=t?t.toString("utf8"):""},i.prototype.error=function(e,t){if(!this.dead)return this.reset(),"string"==typeof e?this.onerror(new Error(e),t):e.constructor==Error?this.onerror(e,t):this.onerror(new Error("An error occured"),t),this},i.prototype.flush=function(){if(!this.processing&&!this.dead){var e=this.messageHandlers.shift();if(e){this.processing=!0;var t=this;e(function(){t.processing=!1,t.flush()})}}},i.prototype.applyExtensions=function(e,t,n,i){var r=this;n?this.extensions[d.extensionName].decompress(e,t,function(e,t){if(!r.dead)return e?void i(new Error("invalid compressed data")):void i(null,t)}):i(null,e)},i.prototype.maxPayloadExceeded=function(e){if(void 0===this.maxPayload||null===this.maxPayload||this.maxPayload<1)return!1;var t=this.currentPayloadLength+e;return t0&&i.currentMessageLength+r.length0&&i.currentMessageLength+r.length1?r.call(t,0):1e3;if(!h.isValidErrorCode(e))return void n.error("invalid error code",1002);var s="";if(t&&t.length>2){var o=t.slice(2);if(!c.isValidUTF8(o))return void n.error("invalid utf8 sequence",1007);s=o.toString("utf8")}n.onclose(e,s,{masked:i.masked}),n.reset()}),this.flush()}},9:{start:function(e){var t=this;if(0==t.state.lastFragment)return void t.error("fragmented ping is not supported",1002);var n=127&e[1];n<126?l[9].getData.call(t,n):t.error("control frames cannot have more than 125 bytes of data",1002)},getData:function(e){var t=this;t.state.masked?t.expectHeader(4,function(n){var i=n;t.expectData(e,function(e){l[9].finish.call(t,i,e)})}):t.expectData(e,function(e){l[9].finish.call(t,null,e)})},finish:function(e,t){var n=this;t=this.unmask(e,t,!0);var i=a(this.state);this.messageHandlers.push(function(e){n.onping(t,{masked:i.masked,binary:!0}),e()}),this.flush(),this.endPacket()}},10:{start:function(e){var t=this;if(0==t.state.lastFragment)return void t.error("fragmented pong is not supported",1002);var n=127&e[1];n<126?l[10].getData.call(t,n):t.error("control frames cannot have more than 125 bytes of data",1002)},getData:function(e){var t=this;this.state.masked?this.expectHeader(4,function(n){var i=n;t.expectData(e,function(e){l[10].finish.call(t,i,e)})}):this.expectData(e,function(e){l[10].finish.call(t,null,e)})},finish:function(e,t){var n=this;t=n.unmask(e,t,!0);var i=a(this.state);this.messageHandlers.push(function(e){n.onpong(t,{masked:i.masked,binary:!0}),e()}),this.flush(),this.endPacket()}}}}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(e,t){if(this instanceof i==!1)throw new TypeError("Classes can't be function-called");c.EventEmitter.call(this),this._socket=e,this.extensions=t||{},this.firstFragment=!0,this.compress=!1,this.messageHandlers=[],this.processing=!1}function r(e,t){this[t]=(65280&e)>>8,this[t+1]=255&e}function s(e,t){this[t]=(4278190080&e)>>24,this[t+1]=(16711680&e)>>16,this[t+2]=(65280&e)>>8,this[t+3]=255&e}function o(e){for(var n=new Uint8Array(e.buffer||e),i=e.byteLength||e.length,r=e.byteOffset||0,s=new t(i),o=0;o - * MIT Licensed - */ -var c=n(5),h=n(10),f=(c.EventEmitter,n(125)),u=n(124).BufferUtil,d=n(44);h.inherits(i,c.EventEmitter),i.prototype.close=function(e,n,i,s){if("undefined"!=typeof e&&("number"!=typeof e||!f.isValidErrorCode(e)))throw new Error("first argument must be a valid error code number");e=e||1e3;var o=new t(2+(n?t.byteLength(n):0));r.call(o,e,0),o.length>2&&o.write(n,2);var a=this;this.messageHandlers.push(function(e){a.frameAndSend(8,o,!0,i),e(),"function"==typeof s&&s()}),this.flush()},i.prototype.ping=function(e,t){var n=t&&t.mask,i=this;this.messageHandlers.push(function(t){i.frameAndSend(9,e||"",!0,n),t()}),this.flush()},i.prototype.pong=function(e,t){var n=t&&t.mask,i=this;this.messageHandlers.push(function(t){i.frameAndSend(10,e||"",!0,n),t()}),this.flush()},i.prototype.send=function(e,t,n){var i=!t||t.fin!==!1,r=t&&t.mask,s=t&&t.compress,o=t&&t.binary?2:1;this.firstFragment===!1?(o=0,s=!1):(this.firstFragment=!1,this.compress=s),i&&(this.firstFragment=!0);var a=this.compress,c=this;this.messageHandlers.push(function(t){c.applyExtensions(e,i,a,function(e,a){return e?void("function"==typeof n?n(e):c.emit("error",e)):(c.frameAndSend(o,a,i,r,s,n),void t())})}),this.flush()},i.prototype.frameAndSend=function(e,n,i,c,h,f){var d=!1;if(n){t.isBuffer(n)||(d=!0,!n||"undefined"==typeof n.byteLength&&"undefined"==typeof n.buffer?("number"==typeof n&&(n=n.toString()),n=new t(n)):n=o(n));var l=n.length,p=c?6:2,b=l;l>=65536?(p+=8,b=127):l>125&&(p+=2,b=126);var m=l<32768||c&&!d,g=m?l+p:p,v=new t(g);switch(v[0]=i?128|e:e,h&&(v[0]|=64),b){case 126:r.call(v,l,2);break;case 127:s.call(v,0,2),s.call(v,l,6)}if(c){v[1]=128|b;var y=a();if(v[p-4]=y[0],v[p-3]=y[1],v[p-2]=y[2],v[p-1]=y[3],m){u.mask(n,y,v,p,l);try{this._socket.write(v,"binary",f)}catch(e){"function"==typeof f?f(e):this.emit("error",e)}}else{u.mask(n,y,n,0,l);try{this._socket.write(v,"binary"),this._socket.write(n,"binary",f)}catch(e){"function"==typeof f?f(e):this.emit("error",e)}}}else if(v[1]=b,m){n.copy(v,p);try{this._socket.write(v,"binary",f)}catch(e){"function"==typeof f?f(e):this.emit("error",e)}}else try{this._socket.write(v,"binary"),this._socket.write(n,"binary",f)}catch(e){"function"==typeof f?f(e):this.emit("error",e)}}else try{this._socket.write(new t([e|(i?128:0),0|(c?128:0)].concat(c?[0,0,0,0]:[])),"binary",f)}catch(e){"function"==typeof f?f(e):this.emit("error",e)}},i.prototype.flush=function(){if(!this.processing){var e=this.messageHandlers.shift();if(e){this.processing=!0;var t=this;e(function(){t.processing=!1,t.flush()})}}},i.prototype.applyExtensions=function(e,t,n,i){n&&e?((e.buffer||e)instanceof ArrayBuffer&&(e=o(e)),this.extensions[d.extensionName].compress(e,t,i)):i(null,e)},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){"use strict";(function(t,i){function r(e,t,n){return this instanceof r==!1?new r(e,t,n):(T.call(this),t&&!Array.isArray(t)&&"object"==typeof t&&(n=t,t=null),"string"==typeof t&&(t=[t]),Array.isArray(t)||(t=[]),this._socket=null,this._ultron=null,this._closeReceived=!1,this.bytesReceived=0,this.readyState=null,this.supports={},this.extensions={},this._binaryType="nodebuffer",void(Array.isArray(e)?h.apply(this,e.concat(n)):f.apply(this,[e,t,n])))}function s(e,t,n){this.type="message",this.data=e,this.target=n,this.binary=t}function o(e,t,n){this.type="close",this.wasClean="undefined"==typeof e||1e3===e,this.code=e,this.reason=t,this.target=n}function a(e){this.type="open",this.target=e}function c(e,t,n){var i=t;return t&&(e&&443!=n||!e&&80!=n)&&(i=i+":"+n),i}function h(e,t,n,i){i=new S({protocolVersion:C,protocol:null,extensions:{},maxPayload:0}).merge(i),this.protocol=i.value.protocol,this.protocolVersion=i.value.protocolVersion,this.extensions=i.value.extensions,this.supports.binary="hixie-76"!==this.protocolVersion,this.upgradeReq=e,this.readyState=r.CONNECTING,this._isServer=!0,this.maxPayload=i.value.maxPayload,"hixie-76"===i.value.protocolVersion?u.call(this,x,M,t,n):u.call(this,A,k,t,n)}function f(e,n,i){if(i=new S({origin:null,protocolVersion:C,host:null,headers:null,protocol:n.join(","),agent:null,pfx:null,key:null,passphrase:null,cert:null,ca:null,ciphers:null,rejectUnauthorized:null,perMessageDeflate:!0,localAddress:null}).merge(i),8!==i.value.protocolVersion&&13!==i.value.protocolVersion)throw new Error("unsupported protocol version");var s=m.parse(e),o="ws+unix:"===s.protocol;if(!s.host&&!o)throw new Error("invalid url");var a,h="wss:"===s.protocol||"https:"===s.protocol,f=h?y:v,d=s.port||(h?443:80),l=s.auth,p={};i.value.perMessageDeflate&&(a=new I(typeof i.value.perMessageDeflate!==!0?i.value.perMessageDeflate:{},!1),p[I.extensionName]=a.offer()),this._isServer=!1,this.url=e,this.protocolVersion=i.value.protocolVersion,this.supports.binary="hixie-76"!==this.protocolVersion;var g=new t(i.value.protocolVersion+"-"+Date.now()).toString("base64"),w=_.createHash("sha1");w.update(g+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var E=w.digest("base64"),M=i.value.agent,x=c(h,s.hostname,d),T={port:d,host:s.hostname,headers:{Connection:"Upgrade",Upgrade:"websocket",Host:x,"Sec-WebSocket-Version":i.value.protocolVersion,"Sec-WebSocket-Key":g}};if(l&&(T.headers.Authorization="Basic "+new t(l).toString("base64")),i.value.protocol&&(T.headers["Sec-WebSocket-Protocol"]=i.value.protocol),i.value.host&&(T.headers.Host=i.value.host),i.value.headers)for(var D in i.value.headers)i.value.headers.hasOwnProperty(D)&&(T.headers[D]=i.value.headers[D]);Object.keys(p).length&&(T.headers["Sec-WebSocket-Extensions"]=R.format(p)),(i.isDefinedAndNonNull("pfx")||i.isDefinedAndNonNull("key")||i.isDefinedAndNonNull("passphrase")||i.isDefinedAndNonNull("cert")||i.isDefinedAndNonNull("ca")||i.isDefinedAndNonNull("ciphers")||i.isDefinedAndNonNull("rejectUnauthorized"))&&(i.isDefinedAndNonNull("pfx")&&(T.pfx=i.value.pfx),i.isDefinedAndNonNull("key")&&(T.key=i.value.key),i.isDefinedAndNonNull("passphrase")&&(T.passphrase=i.value.passphrase),i.isDefinedAndNonNull("cert")&&(T.cert=i.value.cert),i.isDefinedAndNonNull("ca")&&(T.ca=i.value.ca),i.isDefinedAndNonNull("ciphers")&&(T.ciphers=i.value.ciphers),i.isDefinedAndNonNull("rejectUnauthorized")&&(T.rejectUnauthorized=i.value.rejectUnauthorized),M||(M=new f.Agent(T))),T.path=s.path||"/",M&&(T.agent=M),o&&(T.socketPath=s.pathname),i.value.localAddress&&(T.localAddress=i.value.localAddress),i.value.origin&&(i.value.protocolVersion<13?T.headers["Sec-WebSocket-Origin"]=i.value.origin:T.headers.Origin=i.value.origin);var P=this,B=f.request(T);B.on("error",function(e){P.emit("error",e),b.call(P,e)}),B.once("response",function(e){var t;P.emit("unexpected-response",B,e)||(t=new Error("unexpected server response ("+e.statusCode+")"),B.abort(),P.emit("error",t)),b.call(P,t)}),B.once("upgrade",function(e,t,n){if(P.readyState===r.CLOSED)return P.emit("close"),P.removeAllListeners(),void t.end();var s=e.headers["sec-websocket-accept"];if("undefined"==typeof s||s!==E)return P.emit("error","invalid server key"),P.removeAllListeners(),void t.end();var o=e.headers["sec-websocket-protocol"],c=(i.value.protocol||"").split(/, */),h=null;if(!i.value.protocol&&o?h="server sent a subprotocol even though none requested":i.value.protocol&&!o?h="server sent no subprotocol even though requested":o&&c.indexOf(o)===-1&&(h="server responded with an invalid protocol"),h)return P.emit("error",h),P.removeAllListeners(),void t.end();o&&(P.protocol=o);var f=R.parse(e.headers["sec-websocket-extensions"]);if(a&&f[I.extensionName]){try{a.accept(f[I.extensionName])}catch(e){return P.emit("error","invalid extension parameter"),P.removeAllListeners(),void t.end()}P.extensions[I.extensionName]=a}u.call(P,A,k,t,n),B.removeAllListeners(),B=null,M=null}),B.end(),this.readyState=r.CONNECTING}function u(e,t,n,s){function o(e){h||f.readyState===r.CLOSED||(h=!0,n.removeListener("data",o),c.on("data",a),s&&s.length>0&&(a(s),s=null),e&&a(e))}function a(e){f.bytesReceived+=e.length,f._receiver.add(e)}var c=this._ultron=new E(n),h=!1,f=this;n.setTimeout(0),n.setNoDelay(!0),this._receiver=new e(this.extensions,this.maxPayload),this._socket=n,c.on("end",b.bind(this)),c.on("close",b.bind(this)),c.on("error",b.bind(this)),c.on("data",o),i.nextTick(o),f._receiver.ontext=function(e,t){t=t||{},f.emit("message",e,t)},f._receiver.onbinary=function(e,t){t=t||{},t.binary=!0,f.emit("message",e,t)},f._receiver.onping=function(e,t){t=t||{},f.pong(e,{mask:!f._isServer,binary:t.binary===!0},!0),f.emit("ping",e,t)},f._receiver.onpong=function(e,t){f.emit("pong",e,t||{})},f._receiver.onclose=function(e,t,n){n=n||{},f._closeReceived=!0,f.close(e,t)},f._receiver.onerror=function(e,t){f.close("undefined"!=typeof t?t:1002,""),f.emit("error",e instanceof Error?e:new Error(e))},this._sender=new t(n,this.extensions),this._sender.on("error",function(e){f.close(1002,""),f.emit("error",e)}),this.readyState=r.OPEN,this.emit("open")}function d(e){e._queue=e._queue||[]}function l(e){var t=e._queue;if("undefined"!=typeof t){delete e._queue;for(var n=0,i=t.length;n - * MIT Licensed - */ -var m=n(62),g=n(10),v=n(55),y=n(236),_=n(122),w=n(11),E=n(229),S=n(108),k=n(128),A=n(127),M=n(243),x=n(242),R=n(126),I=n(44),T=n(5).EventEmitter,C=13,D=3e4;g.inherits(r,T),["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e,t){r.prototype[e]=r[e]=t}),r.prototype.close=function(e,t){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING)return void(this.readyState=r.CLOSED);if(this.readyState===r.CLOSING)return void(this._closeReceived&&this._isServer&&this.terminate());var n=this;try{this.readyState=r.CLOSING,this._closeCode=e,this._closeMessage=t;var i=!this._isServer;this._sender.close(e,t,i,function(e){e&&n.emit("error",e),n._closeReceived&&n._isServer?n.terminate():(clearTimeout(n._closeTimer),n._closeTimer=setTimeout(b.bind(n,!0),D))})}catch(e){this.emit("error",e)}}},r.prototype.pause=function(){if(this.readyState!==r.OPEN)throw new Error("not opened");return this._socket.pause()},r.prototype.ping=function(e,t,n){if(this.readyState!==r.OPEN){if(n===!0)return;throw new Error("not opened")}t=t||{},"undefined"==typeof t.mask&&(t.mask=!this._isServer),this._sender.ping(e,t)},r.prototype.pong=function(e,t,n){if(this.readyState!==r.OPEN){if(n===!0)return;throw new Error("not opened")}t=t||{},"undefined"==typeof t.mask&&(t.mask=!this._isServer),this._sender.pong(e,t)},r.prototype.resume=function(){if(this.readyState!==r.OPEN)throw new Error("not opened");return this._socket.resume()},r.prototype.send=function(e,n,s){if("function"==typeof n&&(s=n,n={}),this.readyState!==r.OPEN){if("function"!=typeof s)throw new Error("not opened");return void s(new Error("not opened"))}if(e||(e=""),this._queue){var o=this;return void this._queue.push(function(){o.send(e,n,s)})}n=n||{},n.fin=!0,"undefined"==typeof n.binary&&(n.binary=e instanceof ArrayBuffer||e instanceof t||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array),"undefined"==typeof n.mask&&(n.mask=!this._isServer),"undefined"==typeof n.compress&&(n.compress=!0),this.extensions[I.extensionName]||(n.compress=!1);var a="function"==typeof w.Readable?w.Readable:w.Stream;if(e instanceof a){d(this);var o=this;p(this,e,n,function(e){i.nextTick(function(){l(o)}),"function"==typeof s&&s(e)})}else this._sender.send(e,n,s)},r.prototype.stream=function(e,t){function n(o,a){try{if(s.readyState!==r.OPEN)throw new Error("not opened");e.fin=a===!0,s._sender.send(o,e),a?l(s):i.nextTick(t.bind(null,null,n))}catch(e){"function"==typeof t?t(e):(delete s._queue,s.emit("error",e))}}"function"==typeof e&&(t=e,e={});var s=this;if("function"!=typeof t)throw new Error("callback must be provided");if(this.readyState!==r.OPEN){if("function"!=typeof t)throw new Error("not opened");return void t(new Error("not opened"))}return this._queue?void this._queue.push(function(){s.stream(e,t)}):(e=e||{},"undefined"==typeof e.mask&&(e.mask=!this._isServer),"undefined"==typeof e.compress&&(e.compress=!0),this.extensions[I.extensionName]||(e.compress=!1),d(this),void i.nextTick(t.bind(null,null,n)))},r.prototype.terminate=function(){if(this.readyState!==r.CLOSED)if(this._socket){this.readyState=r.CLOSING;try{this._socket.end()}catch(e){return void b.call(this,!0)}this._closeTimer&&clearTimeout(this._closeTimer),this._closeTimer=setTimeout(b.bind(this,!0),D)}else this.readyState===r.CONNECTING&&b.call(this,!0)},Object.defineProperty(r.prototype,"bufferedAmount",{get:function(){var e=0;return this._socket&&(e=this._socket.bufferSize||0),e}}),Object.defineProperty(r.prototype,"binaryType",{get:function(){return this._binaryType},set:function(e){if("arraybuffer"!==e&&"nodebuffer"!==e)throw new SyntaxError('unsupported binaryType: must be either "nodebuffer" or "arraybuffer"');this._binaryType=e}}),["open","error","close","message"].forEach(function(e){Object.defineProperty(r.prototype,"on"+e,{get:function(){var t=this.listeners(e)[0];return t?t._listener?t._listener:t:void 0},set:function(t){this.removeAllListeners(e),this.addEventListener(e,t)}})}),r.prototype.addEventListener=function(e,t){function n(e,n){n.binary&&"arraybuffer"===this.binaryType&&(e=new Uint8Array(e).buffer),t.call(h,new s(e,!!n.binary,h))}function i(e,n){t.call(h,new o(e,n,h))}function r(e){e.type="error",e.target=h,t.call(h,e)}function c(){t.call(h,new a(h))}var h=this;"function"==typeof t&&("message"===e?(n._listener=t,this.on(e,n)):"close"===e?(i._listener=t,this.on(e,i)):"error"===e?(r._listener=t,this.on(e,r)):"open"===e?(c._listener=t,this.on(e,c)):this.on(e,t))},e.exports=r,e.exports.buildHostHeader=c}).call(t,n(0).Buffer,n(8))},function(e,t,n){(function(t){const i=n(23),r=n(13),s=n(60),o=n(1),a=n(134),c=n(14),h=n(34),f=n(47),u=n(24),d=n(33),l=n(25),p=n(48);class b{constructor(e){this.client=e}resolveUser(e){return e instanceof c?e:"string"==typeof e?this.client.users.get(e)||null:e instanceof d?e.user:e instanceof h?e.author:e instanceof f?e.owner:null}resolveUserID(e){return e instanceof c||e instanceof d?e.id:"string"==typeof e?e||null:e instanceof h?e.author.id:e instanceof f?e.ownerID:null}resolveGuild(e){return e instanceof f?e:"string"==typeof e?this.client.guilds.get(e)||null:null}resolveGuildMember(e,t){return t instanceof d?t:(e=this.resolveGuild(e),t=this.resolveUser(t),e&&t?e.members.get(t.id)||null:null)}resolveChannel(e){return e instanceof u?e:e instanceof h?e.channel:e instanceof f?e.channels.get(e.id)||null:"string"==typeof e?this.client.channels.get(e)||null:null}resolveInviteCode(e){const t=/discord(?:app)?\.(?:gg|com\/invite)\/([a-z0-9]{5})/i,n=t.exec(e);return n&&n[1]?n[1]:e}resolvePermission(e){if("string"==typeof e&&(e=o.PermissionFlags[e]),"number"!=typeof e||e<1)throw new Error(o.Errors.NOT_A_PERMISSION);return e}resolveString(e){return"string"==typeof e?e:e instanceof Array?e.join("\n"):String(e)}resolveBase64(e){return e instanceof t?`data:image/jpg;base64,${e.toString("base64")}`:e}resolveBuffer(e){return e instanceof t?Promise.resolve(e):this.client.browser&&e instanceof ArrayBuffer?Promise.resolve(a(e)):"string"==typeof e?new Promise((n,o)=>{if(/^https?:\/\//.test(e)){const i=s.get(e).set("Content-Type","blob");this.client.browser&&i.responseType("arraybuffer"),i.end((e,i)=>{return e?o(e):this.client.browser?n(a(i.xhr.response)):i.body instanceof t?n(i.body):o(new TypeError("Body is not a Buffer"))})}else{const t=i.resolve(e);r.stat(t,(e,i)=>{if(e&&o(e),!i||!i.isFile())throw new Error(`The file could not be found: ${t}`);r.readFile(t,(e,t)=>{e?o(e):n(t)})})}}):Promise.reject(new TypeError("The resource must be a string or Buffer."))}resolveEmojiIdentifier(e){return e instanceof l||e instanceof p?e.identifier:"string"!=typeof e||e.includes("%")?null:encodeURIComponent(e)}}e.exports=b}).call(t,n(0).Buffer)},function(e,t,n){const i=n(281),r=n(278),s=n(280),o=n(279),a=n(277),c=n(1);class h{constructor(e){this.client=e,this.handlers={},this.userAgentManager=new i(this),this.methods=new r(this),this.rateLimitedEndpoints={},this.globallyRateLimited=!1}push(e,t){return new Promise((n,i)=>{e.push({request:t,resolve:n,reject:i})})}getRequestHandler(){switch(this.client.options.apiRequestMethod){case"sequential":return s;case"burst":return o;default:throw new Error(c.Errors.INVALID_RATE_LIMIT_METHOD)}}makeRequest(e,t,n,i,r){const s=new a(this,e,t,n,i,r);if(!this.handlers[s.route]){const e=this.getRequestHandler();this.handlers[s.route]=new e(this,s.route)}return this.push(this.handlers[s.route],s)}}e.exports=h},function(e,t){class n{constructor(e){this.restManager=e,this.queue=[]}get globalLimit(){return this.restManager.globallyRateLimited}set globalLimit(e){this.restManager.globallyRateLimited=e}push(e){this.queue.push(e)}handle(){}}e.exports=n},function(e,t){class n{constructor(e){this.player=e}encode(e){return e}decode(e){return e}}e.exports=n},function(e,t,n){(function(t){function n(e){const n=new t(e.byteLength),i=new Uint8Array(e);for(var r=0;r0&&this.setInterval(this.sweepMessages.bind(this),1e3*this.options.messageSweepInterval)}get status(){return this.ws.status}get uptime(){return this.readyAt?Date.now()-this.readyAt:null}get voiceConnections(){return this.voice.connections}get emojis(){const e=new Collection;for(const t of this.guilds.values())for(const n of t.emojis.values())e.set(n.id,n);return e}get readyTimestamp(){return this.readyAt?this.readyAt.getTime():null}login(e,t=null){return t?this.rest.methods.loginEmailPassword(e,t):this.rest.methods.loginToken(e)}destroy(){for(const e of this._timeouts)clearTimeout(e);for(const t of this._intervals)clearInterval(t);return this._timeouts.clear(),this._intervals.clear(),this.token=null,this.email=null,this.password=null,this.manager.destroy()}syncGuilds(e=this.guilds){this.user.bot||this.ws.send({op:12,d:e instanceof Collection?e.keyArray():e.map(e=>e.id)})}fetchUser(e){return this.users.has(e)?Promise.resolve(this.users.get(e)):this.rest.methods.getUser(e)}fetchInvite(e){const t=this.resolver.resolveInviteCode(e);return this.rest.methods.getInvite(t)}fetchWebhook(e,t){return this.rest.methods.getWebhook(e,t)}sweepMessages(e=this.options.messageCacheLifetime){if("number"!=typeof e||isNaN(e))throw new TypeError("The lifetime must be a number.");if(e<=0)return this.emit("debug","Didn't sweep messages - lifetime is unlimited"),-1;const t=1e3*e,n=Date.now();let i=0,r=0;for(const s of this.channels.values())if(s.messages){i++;for(const e of s.messages.values())n-(e.editedTimestamp||e.createdTimestamp)>t&&(s.messages.delete(e.id),r++)}return this.emit("debug",`Swept ${r} messages older than ${e} seconds in ${i} text-based channels`),r}fetchApplication(){if(!this.user.bot)throw new Error(Constants.Errors.NO_BOT_ACCOUNT);return this.rest.methods.getMyApplication()}setTimeout(e,t,...n){const i=setTimeout(()=>{e(),this._timeouts.delete(i)},t,...n);return this._timeouts.add(i),i}clearTimeout(e){clearTimeout(e),this._timeouts.delete(e)}setInterval(e,t,...n){const i=setInterval(e,t,...n);return this._intervals.add(i),i}clearInterval(e){clearInterval(e),this._intervals.delete(e)}_setPresence(e,t){return this.presences.get(e)?void this.presences.get(e).update(t):void this.presences.set(e,new Presence(t))}_eval(script){return eval(script)}_validateOptions(e=this.options){if("number"!=typeof e.shardCount||isNaN(e.shardCount))throw new TypeError("The shardCount option must be a number.");if("number"!=typeof e.shardId||isNaN(e.shardId))throw new TypeError("The shardId option must be a number.");if(e.shardCount<0)throw new RangeError("The shardCount option must be at least 0.");if(e.shardId<0)throw new RangeError("The shardId option must be at least 0.");if(0!==e.shardId&&e.shardId>=e.shardCount)throw new RangeError("The shardId option must be less than shardCount.");if("number"!=typeof e.messageCacheMaxSize||isNaN(e.messageCacheMaxSize))throw new TypeError("The messageCacheMaxSize option must be a number.");if("number"!=typeof e.messageCacheLifetime||isNaN(e.messageCacheLifetime))throw new TypeError("The messageCacheLifetime option must be a number.");if("number"!=typeof e.messageSweepInterval||isNaN(e.messageSweepInterval))throw new TypeError("The messageSweepInterval option must be a number.");if("boolean"!=typeof e.fetchAllMembers)throw new TypeError("The fetchAllMembers option must be a boolean.");if("boolean"!=typeof e.disableEveryone)throw new TypeError("The disableEveryone option must be a boolean.");if("number"!=typeof e.restWsBridgeTimeout||isNaN(e.restWsBridgeTimeout))throw new TypeError("The restWsBridgeTimeout option must be a number.");if(!(e.disabledEvents instanceof Array))throw new TypeError("The disabledEvents option must be an Array.")}}module.exports=Client}).call(exports,__webpack_require__(8))},function(e,t,n){const i=n(49),r=n(131),s=n(130),o=n(45),a=n(1);class c extends i{constructor(e,t,n){super(null,e,t),this.options=o(a.DefaultOptions,n),this.rest=new r(this),this.resolver=new s(this)}}e.exports=c},function(e,t,n){(function(t){const i=n(23),r=n(13),s=n(5).EventEmitter,o=n(45),a=n(65),c=n(6),h=n(82);class f extends s{constructor(e,n={}){if(super(),n=o({totalShards:"auto",respawn:!0,shardArgs:[],token:null},n),this.file=e,!e)throw new Error("File must be specified.");i.isAbsolute(e)||(this.file=i.resolve(t.cwd(),e));const s=r.statSync(this.file);if(!s.isFile())throw new Error("File path does not point to a file.");if(this.totalShards=n.totalShards,"auto"!==this.totalShards){if("number"!=typeof this.totalShards||isNaN(this.totalShards))throw new TypeError("Amount of shards must be a number.");if(this.totalShards<1)throw new RangeError("Amount of shards must be at least 1.");if(this.totalShards!==Math.floor(this.totalShards))throw new RangeError("Amount of shards must be an integer.")}this.respawn=n.respawn,this.shardArgs=n.shardArgs,this.token=n.token?n.token.replace(/^Bot\s*/i,""):null,this.shards=new c}createShard(e=this.shards.size){const t=new a(this,e,this.shardArgs);return this.shards.set(e,t),this.emit("launch",t),Promise.resolve(t)}spawn(e=this.totalShards,t=5500){if("auto"===e)return h(this.token).then(e=>{return this.totalShards=e,this._spawn(e,t)});if("number"!=typeof e||isNaN(e))throw new TypeError("Amount of shards must be a number.");if(e<1)throw new RangeError("Amount of shards must be at least 1.");if(e!==Math.floor(e))throw new TypeError("Amount of shards must be an integer.");return this._spawn(e,t)}_spawn(e,t){return new Promise(n=>{if(this.shards.size>=e)throw new Error(`Already spawned ${this.shards.size} shards.`);if(this.totalShards=e,this.createShard(),this.shards.size>=this.totalShards)return void n(this.shards);if(t<=0){for(;this.shards.size{this.createShard(),this.shards.size>=this.totalShards&&(clearInterval(e),n(this.shards))},t)}})}broadcast(e){const t=[];for(const n of this.shards.values())t.push(n.send(e));return Promise.all(t)}broadcastEval(e){const t=[];for(const n of this.shards.values())t.push(n.eval(e));return Promise.all(t)}fetchClientValues(e){if(0===this.shards.size)return Promise.reject(new Error("No shards have been spawned."));if(this.shards.size!==this.totalShards)return Promise.reject(new Error("Still spawning shards."));const t=[];for(const n of this.shards.values())t.push(n.fetchClientValue(e));return Promise.all(t)}}e.exports=f}).call(t,n(8))},function(e,t,n){!function(){function e(e){this.message=e}var n=t,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.prototype=new Error,e.prototype.name="InvalidCharacterError",n.btoa||(n.btoa=function(t){for(var n,r,s=0,o=i,a="";t.charAt(0|s)||(o="=",s%1);a+=o.charAt(63&n>>8-s%1*8)){if(r=t.charCodeAt(s+=.75),r>255)throw new e("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|r}return a}),n.atob||(n.atob=function(t){if(t=t.replace(/=+$/,""),t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,s=0,o=0,a="";r=t.charAt(o++);~r&&(n=s%4?64*n+r:r,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)r=i.indexOf(r);return a})}()},function(e,t,n){function i(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}var r=n(36),s=n(2),o=t;o.define=function(e,t){return new i(e,t)},i.prototype._createNamed=function(e){var t;try{t=n(235).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return s(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},i.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r.decoders[e])),this.decoders[e]},i.prototype.decode=function(e,t,n){return this._getDecoder(t).decode(e,n)},i.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(r.encoders[e])),this.encoders[e]},i.prototype.encode=function(e,t,n){return this._getEncoder(t).encode(e,n)}},function(e,t,n){function i(e,t){var n={};this._baseState=n,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}var r=n(26).Reporter,s=n(26).EncoderBuffer,o=n(26).DecoderBuffer,a=n(29),c=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],h=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(c),f=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];e.exports=i;var u=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];i.prototype.clone=function(){var e=this._baseState,t={};u.forEach(function(n){t[n]=e[n]});var n=new this.constructor(t.parent);return n._baseState=t,n},i.prototype._wrap=function(){var e=this._baseState;h.forEach(function(t){this[t]=function(){var n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}},this)},i.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},i.prototype._useArgs=function(e){var t=this._baseState,n=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==n.length&&(a(null===t.children),t.children=n,n.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(n){n==(0|n)&&(n|=0);var i=e[n];t[i]=n}),t}))},f.forEach(function(e){i.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),c.forEach(function(e){i.prototype[e]=function(){var t=this._baseState,n=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(n),this}}),i.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},i.prototype.optional=function(){var e=this._baseState;return e.optional=!0,this},i.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},i.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},i.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},i.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},i.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},i.prototype.any=function(){var e=this._baseState;return e.any=!0,this},i.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},i.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},i.prototype._decode=function(e,t){var n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));var i=n.default,r=!0,s=null;if(null!==n.key&&(s=e.enterKey(n.key)),n.optional){var a=null;if(null!==n.explicit?a=n.explicit:null!==n.implicit?a=n.implicit:null!==n.tag&&(a=n.tag),null!==a||n.any){if(r=this._peekTag(e,a,n.any),e.isError(r))return r}else{var c=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),r=!0}catch(e){r=!1}e.restore(c)}}var h;if(n.obj&&r&&(h=e.enterObject()),r){if(null!==n.explicit){var f=this._decodeTag(e,n.explicit);if(e.isError(f))return f;e=f}var u=e.offset;if(null===n.use&&null===n.choice){if(n.any)var c=e.save();var d=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(d))return d;n.any?i=e.raw(c):e=d}if(t&&t.track&&null!==n.tag&&t.track(e.path(),u,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),i=n.any?i:null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach(function(n){n._decode(e,t)}),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){var l=new o(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(l,t)}}return n.obj&&r&&(i=e.leaveObject(h)),null===n.key||null===i&&r!==!0?null!==s&&e.exitKey(s):e.leaveKey(s,n.key,i),i},i.prototype._decodeGeneric=function(e,t,n){var i=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,i.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):"objid"===e&&i.args?this._decodeObjid(t,i.args[0],i.args[1],n):"objid"===e?this._decodeObjid(t,null,null,n):"gentime"===e||"utctime"===e?this._decodeTime(t,e,n):"null_"===e?this._decodeNull(t,n):"bool"===e?this._decodeBool(t,n):"objDesc"===e?this._decodeStr(t,e,n):"int"===e||"enum"===e?this._decodeInt(t,i.args&&i.args[0],n):null!==i.use?this._getUse(i.use,t._reporterState.obj)._decode(t,n):t.error("unknown tag: "+e)},i.prototype._getUse=function(e,t){var n=this._baseState;return n.useDecoder=this._use(e,t),a(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},i.prototype._decodeChoice=function(e,t){var n=this._baseState,i=null,r=!1;return Object.keys(n.choice).some(function(s){var o=e.save(),a=n.choice[s];try{var c=a._decode(e,t);if(e.isError(c))return!1;i={type:s,value:c},r=!0}catch(t){return e.restore(o),!1}return!0},this),r?i:e.error("Choice not matched")},i.prototype._createEncoderBuffer=function(e){return new s(e,this.reporter)},i.prototype._encode=function(e,t,n){var i=this._baseState;if(null===i.default||i.default!==e){var r=this._encodeValue(e,t,n);if(void 0!==r&&!this._skipDefault(r,t,n))return r}},i.prototype._encodeValue=function(e,t,n){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new r);var s=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var o=null,a=!1;if(i.any)s=this._createEncoderBuffer(e);else if(i.choice)s=this._encodeChoice(e,t);else if(i.contains)o=this._getUse(i.contains,n)._encode(e,t),a=!0;else if(i.children)o=i.children.map(function(n){if("null_"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error("Child should have a key");var i=t.enterKey(n._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var r=n._encode(e[n._baseState.key],t,e);return t.leaveKey(i),r},this).filter(function(e){return e}),o=this._createEncoderBuffer(o);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var c=this.clone();c._baseState.implicit=null,o=this._createEncoderBuffer(e.map(function(n){var i=this._baseState;return this._getUse(i.args[0],e)._encode(n,t)},c))}else null!==i.use?s=this._getUse(i.use,n)._encode(e,t):(o=this._encodePrimitive(i.tag,e),a=!0);var s;if(!i.any&&null===i.choice){var h=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===h?null===i.use&&t.error("Tag could be ommited only for .use()"):null===i.use&&(s=this._encodeComposite(h,a,f,o))}return null!==i.explicit&&(s=this._encodeComposite(i.explicit,!1,"context",s)),s},i.prototype._encodeChoice=function(e,t){var n=this._baseState,i=n.choice[e.type];return i||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),i._encode(e.value,t)},i.prototype._encodePrimitive=function(e,t){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},i.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},i.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},function(e,t,n){function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}var s=n(2);t.Reporter=i,i.prototype.isError=function(e){return e instanceof r},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,n){var i=this._reporterState;this.exitKey(e),null!==i.obj&&(i.obj[t]=n)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,n=t.obj;return t.obj=e,n},i.prototype.error=function(e){var t,n=this._reporterState,i=e instanceof r;if(t=i?e:new r(n.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!n.options.partial)throw t;return i||n.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},s(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},function(e,t,n){var i=n(85);t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=i._reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=i._reverse(t.tag)},function(e,t,n){var i=t;i.der=n(86),i.pem=n(146)},function(e,t,n){function i(e){o.call(this,e),this.enc="pem"}var r=n(2),s=n(0).Buffer,o=n(86);r(i,o),e.exports=i,i.prototype.decode=function(e,t){for(var n=e.toString().split(/[\r\n]+/g),i=t.label.toUpperCase(),r=/^-----(BEGIN|END) ([^-]+)-----$/,a=-1,c=-1,h=0;h{const n=this.client.resolver.resolveBase64(t);return this.client.rest.methods.editWebhook(this,e,n)}):this.client.rest.methods.editWebhook(this,e).then(e=>{return this.setup(e),this})}delete(){return this.client.rest.methods.deleteWebhook(this)}}e.exports=s},function(e,t,n){"use strict";(function(e){var i=n(5),r=i.Buffer,s=i.SlowBuffer,o=i.kMaxLength||2147483647;t.alloc=function(e,t,n){if("function"==typeof r.alloc)return r.alloc(e,t,n);if("number"==typeof n)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>o)throw new RangeError("size is too large");var i=n,s=t;void 0===s&&(i=void 0,s=0);var a=new r(e);if("string"==typeof s)for(var h=new r(s,i),u=h.length,c=-1;++co)throw new RangeError("size is too large");return new r(e)},t.from=function(t,n,i){if("function"==typeof r.from&&(!e.Uint8Array||Uint8Array.from!==r.from))return r.from(t,n,i);if("number"==typeof t)throw new TypeError('"value" argument must not be a number');if("string"==typeof t)return new r(t,n);if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer){var s=n;if(1===arguments.length)return new r(t);"undefined"==typeof s&&(s=0);var o=i;if("undefined"==typeof o&&(o=t.byteLength-s),s>=t.byteLength)throw new RangeError("'offset' is out of bounds");if(o>t.byteLength-s)throw new RangeError("'length' is out of bounds");return new r(t.slice(s,s+o))}if(r.isBuffer(t)){var a=new r(t.length);return t.copy(a,0,0,t.length),a}if(t){if(Array.isArray(t)||"undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return new r(t);if("Buffer"===t.type&&Array.isArray(t.data))return new r(t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},t.allocUnsafeSlow=function(e){if("function"==typeof r.allocUnsafeSlow)return r.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=o)throw new RangeError("size is too large");return new s(e)}}).call(t,n(18))},function(e,t,n){"use strict";(function(t){function n(e,n,i,r){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var s,o,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,n)});case 3:return t.nextTick(function(){e.call(null,n,i)});case 4:return t.nextTick(function(){e.call(null,n,i,r)});default:for(s=new Array(a-1),o=0;o-1?i:k;a.WritableState=o;var T=n(16);T.inherits=n(12);var R,M={deprecate:n(100)};!function(){try{R=n(25)}catch(e){}finally{R||(R=n(4).EventEmitter)}}();var D=n(5).Buffer,x=n(31);T.inherits(a,R);var I;o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:M.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var I;a.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},a.prototype.write=function(e,t,n){var i=this._writableState,s=!1;return"function"==typeof t&&(n=t,t=null),D.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=r),i.ended?h(this,n):u(this,i,e,n)&&(i.pendingcb++,s=l(this,i,e,t,n)),s},a.prototype.cork=function(){var e=this._writableState;e.corked++},a.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||w(this,e))},a.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},a.prototype._write=function(e,t,n){n(new Error("not implemented"))},a.prototype._writev=null,a.prototype.end=function(e,t,n){var i=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||E(this,i,n)}}).call(t,n(6),n(36).setImmediate)},function(e,t,n){function i(){}function r(e){if(!_(e))return e;var t=[];for(var n in e)s(t,n,e[n]);return t.join("&")}function s(e,t,n){if(null!=n)if(Array.isArray(n))n.forEach(function(n){s(e,t,n)});else if(_(n))for(var i in n)s(e,t+"["+i+"]",n[i]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(n));else null===n&&e.push(encodeURIComponent(t))}function o(e){for(var t,n,i={},r=e.split("&"),s=0,o=r.length;s=300)&&(i=new Error(t.statusText||"Unsuccessful HTTP response"),i.original=e,i.response=t,i.status=t.status)}catch(e){i=e}i?n.callback(i,t):n.callback(null,t)})}function d(e,t){var n=w("DELETE",e);return t&&n.end(t),n}var p;"undefined"!=typeof window?p=window:"undefined"!=typeof self?p=self:(console.warn("Using browser-only version of superagent in non-browser environment"),p=this);var g=n(84),m=n(98),_=n(66),w=e.exports=n(99).bind(null,f);w.getXHR=function(){if(!(!p.XMLHttpRequest||p.location&&"file:"==p.location.protocol&&p.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw Error("Browser-only verison of superagent could not find XHR")};var v="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};w.serializeObject=r,w.parseString=o,w.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},w.serialize={"application/x-www-form-urlencoded":r,"application/json":JSON.stringify},w.parse={"application/x-www-form-urlencoded":o,"application/json":JSON.parse},l.prototype.get=function(e){return this.header[e.toLowerCase()]},l.prototype._setHeaderProperties=function(e){var t=this.header["content-type"]||"";this.type=u(t);var n=c(t);for(var i in n)this[i]=n[i]},l.prototype._parseBody=function(e){var t=w.parse[this.type];return!t&&h(this.type)&&(t=w.parse["application/json"]),t&&e&&(e.length||e instanceof Object)?t(e):null},l.prototype._setStatusProperties=function(e){1223===e&&(e=204);var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.notFound=404==e,this.forbidden=403==e},l.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,i="cannot "+t+" "+n+" ("+this.status+")",r=new Error(i);return r.status=this.status,r.method=t,r.url=n,r},w.Response=l,g(f.prototype),m(f.prototype),f.prototype.type=function(e){return this.set("Content-Type",w.types[e]||e),this},f.prototype.responseType=function(e){return this._responseType=e,this},f.prototype.accept=function(e){return this.set("Accept",w.types[e]||e),this},f.prototype.auth=function(e,t,n){switch(n||(n={type:"basic"}),n.type){case"basic":var i=btoa(e+":"+t);this.set("Authorization","Basic "+i);break;case"auto":this.username=e,this.password=t}return this},f.prototype.query=function(e){return"string"!=typeof e&&(e=r(e)),e&&this._query.push(e),this},f.prototype.attach=function(e,t,n){if(this._data)throw Error("superagent can't mix .send() and .attach()");return this._getFormData().append(e,t,n||t.name),this},f.prototype._getFormData=function(){return this._formData||(this._formData=new p.FormData),this._formData},f.prototype.callback=function(e,t){var n=this._callback;this.clearTimeout(),e&&this.emit("error",e),n(e,t)},f.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},f.prototype.buffer=f.prototype.ca=f.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},f.prototype.pipe=f.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},f.prototype._timeoutError=function(){var e=this._timeout,t=new Error("timeout of "+e+"ms exceeded");t.timeout=e,this.callback(t)},f.prototype._appendQueryString=function(){var e=this._query.join("&");e&&(this.url+=~this.url.indexOf("?")?"&"+e:"?"+e)},f.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},f.prototype.end=function(e){var t=this,n=this.xhr=w.getXHR(),r=this._timeout,s=this._formData||this._data;this._callback=e||i,n.onreadystatechange=function(){if(4==n.readyState){var e;try{e=n.status}catch(t){e=0}if(0==e){if(t.timedout)return t._timeoutError();if(t._aborted)return;return t.crossDomainError()}t.emit("end")}};var o=function(e,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=e,t.emit("progress",n)};if(this.hasListeners("progress"))try{n.onprogress=o.bind(null,"download"),n.upload&&(n.upload.onprogress=o.bind(null,"upload"))}catch(e){}if(r&&!this._timer&&(this._timer=setTimeout(function(){t.timedout=!0,t.abort()},r)),this._appendQueryString(),this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0),this._withCredentials&&(n.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!this._isHost(s)){var a=this._header["content-type"],u=this._serializer||w.serialize[a?a.split(";")[0]:""];!u&&h(a)&&(u=w.serialize["application/json"]),u&&(s=u(s))}for(var c in this.header)null!=this.header[c]&&n.setRequestHeader(c,this.header[c]);return this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send("undefined"!=typeof s?s:null),this},w.Request=f,w.get=function(e,t,n){var i=w("GET",e);return"function"==typeof t&&(n=t,t=null),t&&i.query(t),n&&i.end(n),i},w.head=function(e,t,n){var i=w("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},w.options=function(e,t,n){var i=w("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},w.del=d,w.delete=d,w.patch=function(e,t,n){var i=w("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},w.post=function(e,t,n){var i=w("POST",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i},w.put=function(e,t,n){var i=w("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&i.send(t),n&&i.end(n),i}},function(e,t,n){(function(e,i){function r(e,t){this._id=e,this._clearFn=t}var s=n(6).nextTick,o=Function.prototype.apply,a=Array.prototype.slice,h={},u=0;t.setTimeout=function(){return new r(o.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new r(o.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},t.setImmediate="function"==typeof e?e:function(e){var n=u++,i=!(arguments.length<2)&&a.call(arguments,1);return h[n]=!0,s(function(){h[n]&&(i?e.apply(null,i):e.call(null),t.clearImmediate(n))}),n},t.clearImmediate="function"==typeof i?i:function(e){delete h[e]}}).call(t,n(36).setImmediate,n(36).clearImmediate)},function(e,t){e.exports=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(const n in e){const i=e[n],r=t.indexOf(i);r&&t.splice(r,1)}return 0===t.length}},function(e,t){e.exports={name:"discord.js",version:"10.0.1",description:"A powerful library for interacting with the Discord API",main:"./src/index",scripts:{test:"eslint src && node docs/generator test",docs:"node docs/generator","test-docs":"node docs/generator test",lint:"eslint src","web-dist":"node ./node_modules/parallel-webpack/bin/run.js"},repository:{type:"git",url:"git+https://github.com/hydrabolt/discord.js.git"},keywords:["discord","api","bot","client","node","discordapp"],author:"Amish Shah ",license:"Apache-2.0",bugs:{url:"https://github.com/hydrabolt/discord.js/issues"},homepage:"https://github.com/hydrabolt/discord.js#readme",dependencies:{superagent:"^3.0.0",tweetnacl:"^0.14.3",ws:"^1.1.1"},peerDependencies:{"node-opus":"^0.2.0",opusscript:"^0.0.1"},devDependencies:{bufferutil:"^1.2.1",eslint:"^3.10.0","jsdoc-to-markdown":"^2.0.0","json-loader":"^0.5.4","parallel-webpack":"^1.5.0","uglify-js":"github:mishoo/UglifyJS2#harmony","utf-8-validate":"^1.2.1",webpack:"2.1.0-beta.27",zlibjs:"github:imaya/zlib.js"},engines:{node:">=6.0.0"}}},function(e,t,n){(function(t){const i=n(13),r=n(17),s=n(74),o=n(75);class a{constructor(e,n,s=[]){this.manager=e,this.id=n,this.env=Object.assign({},t.env,{SHARD_ID:this.id,SHARD_COUNT:this.manager.totalShards,CLIENT_TOKEN:this.manager.token}),this.process=i.fork(r.resolve(this.manager.file),s,{env:this.env}),this.process.on("message",this._handleMessage.bind(this)),this.process.once("exit",()=>{this.manager.respawn&&this.manager.createShard(this.id)}),this._evals=new Map,this._fetches=new Map}send(e){return new Promise((t,n)=>{const i=this.process.send(e,e=>{e?n(e):t(this)});if(!i)throw new Error("Failed to send message to shard's process.")})}fetchClientValue(e){if(this._fetches.has(e))return this._fetches.get(e);const t=new Promise((t,n)=>{const i=n=>{n&&n._fetchProp===e&&(this.process.removeListener("message",i),this._fetches.delete(e),t(n._result))};this.process.on("message",i),this.send({_fetchProp:e}).catch(t=>{this.process.removeListener("message",i),this._fetches.delete(e),n(t)})});return this._fetches.set(e,t),t}eval(e){if(this._evals.has(e))return this._evals.get(e);const t=new Promise((t,n)=>{const i=r=>{r&&r._eval===e&&(this.process.removeListener("message",i),this._evals.delete(e),r._error?n(s(r._error)):t(r._result))};this.process.on("message",i),this.send({_eval:e}).catch(t=>{this.process.removeListener("message",i),this._evals.delete(e),n(t)})});return this._evals.set(e,t),t}_handleMessage(e){if(e){if(e._sFetchProp)return void this.manager.fetchClientValues(e._sFetchProp).then(t=>this.send({_sFetchProp:e._sFetchProp,_result:t}),t=>this.send({_sFetchProp:e._sFetchProp,_error:o(t)}));if(e._sEval)return void this.manager.broadcastEval(e._sEval).then(t=>this.send({_sEval:e._sEval,_result:t}),t=>this.send({_sEval:e._sEval,_error:o(t)}))}this.manager.emit("message",this,e)}}e.exports=a}).call(t,n(6))},function(e,t,n){(function(t){const i=n(74),r=n(75);class s{constructor(e){this.client=e,t.on("message",this._handleMessage.bind(this))}get id(){return this.client.options.shardId}get count(){return this.client.options.shardCount}send(e){return new Promise((n,i)=>{const r=t.send(e,e=>{e?i(e):n()});if(!r)throw new Error("Failed to send message to master process.")})}fetchClientValues(e){return new Promise((n,r)=>{const s=o=>{o&&o._sFetchProp===e&&(t.removeListener("message",s),o._error?r(i(o._error)):n(o._result))};t.on("message",s),this.send({_sFetchProp:e}).catch(e=>{t.removeListener("message",s),r(e)})})}broadcastEval(e){return new Promise((n,r)=>{const s=o=>{o&&o._sEval===e&&(t.removeListener("message",s),o._error?r(i(o._error)):n(o._result))};t.on("message",s),this.send({_sEval:e}).catch(e=>{t.removeListener("message",s),r(e)})})}_handleMessage(e){if(e)if(e._fetchProp){const t=e._fetchProp.split(".");let n=this.client;for(const i of t)n=n[i];this._respond("fetchProp",{_fetchProp:e._fetchProp,_result:n})}else if(e._eval)try{this._respond("eval",{_eval:e._eval,_result:this.client._eval(e._eval)})}catch(t){this._respond("eval",{_eval:e._eval,_error:r(t)})}}_respond(e,t){this.send(t).catch(t=>this.client.emit("error",`Error when sending ${e} response to master process: ${t}`))}static singleton(e){return this._singleton?e.emit("error","Multiple clients created in child process; only the first will handle sharding helpers."):this._singleton=new this(e),this._singleton}}e.exports=s}).call(t,n(6))},function(e,t,n){const i=n(8),r=n(50);class s extends r{setup(e){super.setup(e),this.flags=e.flags,this.owner=new i(this.client,e.owner)}}e.exports=s},function(e,t,n){const i=n(8),r=n(3);class s extends i{setup(e){super.setup(e),this.verified=e.verified,this.email=e.email,this.localPresence={},this._typing=new Map,this.friends=new r,this.blocked=new r,this.notes=new r}edit(e){return this.client.rest.methods.updateCurrentUser(e)}setUsername(e){return this.client.rest.methods.updateCurrentUser({username:e})}setEmail(e){return this.client.rest.methods.updateCurrentUser({email:e})}setPassword(e){return this.client.rest.methods.updateCurrentUser({password:e})}setAvatar(e){return e.startsWith("data:")?this.client.rest.methods.updateCurrentUser({avatar:e}):this.client.resolver.resolveBuffer(e).then(e=>this.client.rest.methods.updateCurrentUser({avatar:e}))}setStatus(e){return this.setPresence({status:e})}setGame(e,t){return this.setPresence({game:{name:e,url:t}})}setAFK(e){return this.setPresence({afk:e})}addFriend(e){return e=this.client.resolver.resolveUser(e),this.client.rest.methods.addFriend(e)}removeFriend(e){return e=this.client.resolver.resolveUser(e),this.client.rest.methods.removeFriend(e)}createGuild(e,t,n=null){return n?n.startsWith("data:")?this.client.rest.methods.createGuild({name:e,icon:n,region:t}):this.client.resolver.resolveBuffer(n).then(n=>this.client.rest.methods.createGuild({name:e,icon:n,region:t})):this.client.rest.methods.createGuild({name:e,icon:n,region:t})}setPresence(e){return new Promise(t=>{let n=this.localPresence.status||this.presence.status,i=this.localPresence.game,r=this.localPresence.afk||this.presence.afk;if(!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url}),e.status){if("string"!=typeof e.status)throw new TypeError("Status must be a string");n=e.status}e.game&&(i=e.game,i.url&&(i.type=1)),"undefined"!=typeof e.afk&&(r=e.afk),r=Boolean(r),this.localPresence={status:n,game:i,afk:r},this.localPresence.since=0,this.localPresence.game=this.localPresence.game||null,this.client.ws.send({op:3,d:this.localPresence}),this.client._setPresence(this.id,this.localPresence),t(this)})}}e.exports=s},function(e,t,n){const i=n(14),r=n(19),s=n(3);class o extends i{constructor(e,t){super(e,t),this.type="dm",this.messages=new s,this._typing=new Map}setup(e){super.setup(e),this.recipient=this.client.dataManager.newUser(e.recipients[0]),this.lastMessageID=e.last_message_id}toString(){return this.recipient.toString()}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}r.applyToClass(o,!0),e.exports=o},function(e,t,n){const i=n(14),r=n(19),s=n(3),o=n(37);class a extends i{constructor(e,t){super(e,t),this.type="group",this.messages=new s,this._typing=new Map}setup(e){if(super.setup(e),this.name=e.name,this.icon=e.icon,this.ownerID=e.owner_id,this.recipients||(this.recipients=new s),e.recipients)for(const t of e.recipients){const e=this.client.dataManager.newUser(t);this.recipients.set(e.id,e)}this.lastMessageID=e.last_message_id}get owner(){return this.client.users.get(this.ownerID)}equals(e){const t=e&&this.id===e.id&&this.name===e.name&&this.icon===e.icon&&this.ownerID===e.ownerID;if(t){const t=this.recipients.keyArray(),n=e.recipients.keyArray();return o(t,n)}return t}toString(){return this.name}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}r.applyToClass(a,!0),e.exports=a},function(e,t,n){const i=n(51),r=n(52),s=n(0);class o{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.guild=this.client.guilds.get(e.guild.id)||new i(this.client,e.guild),this.code=e.code,this.temporary=e.temporary,this.maxAge=e.max_age,this.uses=e.uses,this.maxUses=e.max_uses,e.inviter&&(this.inviter=this.client.dataManager.newUser(e.inviter)),this.channel=this.client.channels.get(e.channel.id)||new r(this.client,e.channel),this.createdTimestamp=new Date(e.created_at).getTime()}get createdAt(){return new Date(this.createdTimestamp)}get expiresTimestamp(){return this.createdTimestamp+1e3*this.maxAge}get expiresAt(){return new Date(this.expiresTimestamp)}get url(){return s.Endpoints.inviteLink(this.code)}delete(){return this.client.rest.methods.deleteInvite(this)}toString(){return this.url}}e.exports=o},function(e,t){class n{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.message=e,this.setup(t)}setup(e){this.id=e.id,this.filename=e.filename,this.filesize=e.size,this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}e.exports=n},function(e,t,n){const i=n(4).EventEmitter,r=n(3);class s extends i{constructor(e,t,n={}){super(),this.channel=e,this.filter=t,this.options=n,this.ended=!1,this.collected=new r,this.listener=(e=>this.verify(e)),this.channel.client.on("message",this.listener),n.time&&this.channel.client.setTimeout(()=>this.stop("time"),n.time)}verify(e){return(!this.channel||this.channel.id===e.channel.id)&&(!!this.filter(e,this)&&(this.collected.set(e.id,e),this.emit("message",e,this),this.collected.size>=this.options.maxMatches?this.stop("matchesLimit"):this.options.max&&this.collected.size===this.options.max&&this.stop("limit"),!0))}get next(){return new Promise((e,t)=>{if(this.ended)return void t(this.collected);const n=()=>{this.removeListener("message",i),this.removeListener("end",r)},i=(...t)=>{n(),e(...t)},r=(...e)=>{n(),t(...e)};this.once("message",i),this.once("end",r)})}stop(e="user"){this.ended||(this.ended=!0,this.channel.client.removeListener("message",this.listener),this.emit("end",this.collected,e))}}e.exports=s},function(e,t){class n{constructor(e,t){this.client=e.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.message=e,this.setup(t)}setup(e){if(this.title=e.title,this.type=e.type,this.description=e.description,this.url=e.url,this.fields=[],e.fields)for(const t of e.fields)this.fields.push(new o(this,t));this.createdTimestamp=e.timestamp,this.thumbnail=e.thumbnail?new i(this,e.thumbnail):null,this.author=e.author?new s(this,e.author):null,this.provider=e.provider?new r(this,e.provider):null,this.footer=e.footer?new a(this,e.footer):null}get createdAt(){return new Date(this.createdTimestamp)}}class i{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}class r{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.url=e.url}}class s{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.url=e.url}}class o{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.value=e.value,this.inline=e.inline}}class a{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.text=e.text,this.iconUrl=e.icon_url,this.proxyIconUrl=e.proxy_icon_url}}n.Thumbnail=i,n.Provider=r,n.Author=s,n.Field=o,n.Footer=a,e.exports=n},function(e,t,n){const i=n(3),r=n(15),s=n(29);class o{constructor(e,t,n,r){this.message=e,this.me=r,this.count=n||0,this.users=new i,this._emoji=new s(this,t.name,t.id)}get emoji(){if(this._emoji instanceof r)return this._emoji;if(this._emoji.id){ +const e=this.message.client.emojis;if(e.has(this._emoji.id)){const t=e.get(this._emoji.id);return this._emoji=t,t}}return this._emoji}remove(e=this.message.client.user){const t=this.message;return e=this.message.client.resolver.resolveUserID(e),e?t.client.rest.methods.removeMessageReaction(t,this.emoji.identifier,e):Promise.reject("Couldn't resolve the user ID to remove from the reaction.")}fetchUsers(e=100){const t=this.message;return t.client.rest.methods.getMessageReactionUsers(t,this.emoji.identifier,e).then(e=>{this.users=new i;for(const t of e){const e=this.message.client.dataManager.newUser(t);this.users.set(e.id,e)}return this.count=this.users.size,e})}}e.exports=o},function(e,t){class n{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.description=e.description,this.icon=e.icon,this.iconURL=`https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`,this.rpcOrigins=e.rpc_origins}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}toString(){return this.name}}e.exports=n},function(e,t){class n{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.icon=e.icon,this.splash=e.splash}}e.exports=n},function(e,t,n){const i=n(0);class r{constructor(e,t){this.client=e,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.type=i.ChannelTypes.text===e.type?"text":"voice"}}e.exports=r},function(e,t){class n{constructor(e,t){this.channel=e,t&&this.setup(t)}setup(e){this.id=e.id,this.type=e.type,this.denyData=e.deny,this.allowData=e.allow}delete(){return this.channel.client.rest.methods.deletePermissionOverwrites(this)}}e.exports=n},function(e,t,n){const i=n(20),r=n(19),s=n(3);class o extends i{constructor(e,t){super(e,t),this.type="text",this.messages=new s,this._typing=new Map}setup(e){super.setup(e),this.topic=e.topic,this.lastMessageID=e.last_message_id}get members(){const e=new s;for(const t of this.guild.members.values())this.permissionsFor(t).hasPermission("READ_MESSAGES")&&e.set(t.id,t);return e}fetchWebhooks(){return this.client.rest.methods.getChannelWebhooks(this)}createWebhook(e,t){return new Promise(n=>{t.startsWith("data:")?n(this.client.rest.methods.createWebhook(this,e,t)):this.client.resolver.resolveBuffer(t).then(t=>n(this.client.rest.methods.createWebhook(this,e,t)))})}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}r.applyToClass(o,!0),e.exports=o},function(e,t,n){const i=n(20),r=n(3);class s extends i{constructor(e,t){super(e,t),this.members=new r,this.type="voice"}setup(e){super.setup(e),this.bitrate=e.bitrate,this.userLimit=e.user_limit}get connection(){const e=this.guild.voiceConnection;return e&&e.channel.id===this.id?e:null}get joinable(){return this.permissionsFor(this.client.user).hasPermission("CONNECT")}get speakable(){return this.permissionsFor(this.client.user).hasPermission("SPEAK")}setBitrate(e){return this.edit({bitrate:e})}setUserLimit(e){return this.edit({userLimit:e})}join(){return this.client.voice.joinChannel(this)}leave(){const e=this.client.voice.connections.get(this.guild.id);e&&e.channel.id===this.id&&e.disconnect()}}e.exports=s},function(e,t,n){const i=n(35),r=n(0).Endpoints.botGateway;e.exports=function(e){return new Promise((t,n)=>{if(!e)throw new Error("A token must be provided.");i.get(r).set("Authorization",`Bot ${e.replace(/^Bot\s*/i,"")}`).end((e,i)=>{e&&n(e),t(i.body.shards)})})}},function(e,t){e.exports=function(e,{maxLength=1950,char="\n",prepend="",append=""}={}){if(e.length<=maxLength)return e;const t=e.split(char);if(1===t.length)throw new Error("Message exceeds the max length and contains no split characters.");const n=[""];let i=0;for(let r=0;rmaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+t[r];return n}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t){"use strict";function n(e,t,n,i){for(var r=65535&e|0,s=e>>>16&65535|0,o=0;0!==n;){o=n>2e3?2e3:n,n-=o;do r=r+t[i++]|0,s=s+r|0;while(--o);r%=65521,s%=65521}return r|s<<16|0}e.exports=n},function(e,t){"use strict";function n(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}function i(e,t,n,i){var s=r,o=i+n;e^=-1;for(var a=i;a>>8^s[255&(e^t[a])];return e^-1}var r=n();e.exports=i},function(e,t){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(e,t,n){"use strict";function i(e){return this instanceof i?void r.call(this,e):new i(e)}e.exports=i;var r=n(33),s=n(16);s.inherits=n(12),s.inherits(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";(function(t){function i(e,t,n){return"function"==typeof e.prependListener?e.prependListener(t,n):void(e._events&&e._events[t]?x(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n))}function r(e,t){j=j||n(10),e=e||{},this.objectMode=!!e.objectMode,t instanceof j&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new G,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(B||(B=n(65).StringDecoder),this.decoder=new B(e.encoding),this.encoding=e.encoding)}function s(e){return j=j||n(10),this instanceof s?(this._readableState=new r(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),void I.call(this)):new s(e)}function o(e,t,n,i,r){var s=c(t,n);if(s)e.emit("error",s);else if(null===n)t.reading=!1,l(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!r){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&r){var h=new Error("stream.unshift() after end event");e.emit("error",h)}else{var u;!t.decoder||r||i||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),r||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&f(e))),p(e,t)}else r||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=z?e=z:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function u(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=h(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function c(e,t){var n=null;return L.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function l(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,f(e)}}function f(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(N("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?D(d,e):d(e))}function d(e){N("emit readable"),e.emit("readable"),y(e)}function p(e,t){t.readingMore||(t.readingMore=!0,D(g,e,t))}function g(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=E(e,t.buffer,t.decoder),n}function E(e,t,n){var i;return es.length?s.length:e;if(r+=o===s.length?s:s.slice(0,e),e-=o,0===e){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}function k(e,t){var n=C.allocUnsafe(e),i=t.head,r=1;for(i.data.copy(n),e-=i.data.length;i=i.next;){var s=i.data,o=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,o),e-=o,0===e){o===s.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=s.slice(o));break}++r}return t.length-=r,n}function S(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,D(T,t,e))}function T(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var n=0,i=e.length;n=t.highWaterMark||t.ended))return N("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?S(this):f(this),null;if(e=u(e,t),0===e&&t.ended)return 0===t.length&&S(this),null;var i=t.needReadable;N("need readable",i),(0===t.length||t.length-e0?b(e,t):null,null===r?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&S(this)),null!==r&&this.emit("data",r),r},s.prototype._read=function(e){this.emit("error",new Error("not implemented"))},s.prototype.pipe=function(e,n){function r(e){N("onunpipe"),e===f&&o()}function s(){N("onend"),e.end()}function o(){N("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",_),e.removeListener("error",h),e.removeListener("unpipe",r),f.removeListener("end",s),f.removeListener("end",o),f.removeListener("data",a),w=!0,!d.awaitDrain||e._writableState&&!e._writableState.needDrain||_()}function a(t){N("ondata"),v=!1;var n=e.write(t);!1!==n||v||((1===d.pipesCount&&d.pipes===e||d.pipesCount>1&&M(d.pipes,e)!==-1)&&!w&&(N("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++,v=!0),f.pause())}function h(t){N("onerror",t),l(),e.removeListener("error",h),0===U(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),l()}function c(){N("onfinish"),e.removeListener("close",u),l()}function l(){N("unpipe"),f.unpipe(e)}var f=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=e;break;case 1:d.pipes=[d.pipes,e];break;default:d.pipes.push(e)}d.pipesCount+=1,N("pipe count=%d opts=%j",d.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,g=p?s:o;d.endEmitted?D(g):f.once("end",g),e.on("unpipe",r);var _=m(f);e.on("drain",_);var w=!1,v=!1;return f.on("data",a),i(e,"error",h),e.once("close",u),e.once("finish",c),e.emit("pipe",f),d.flowing||(N("pipe resume"),f.resume()),e},s.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var r=0;r=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,r),r-=this.charReceived),t+=e.toString(this.encoding,0,r);var r=t.length-1,i=t.charCodeAt(r);if(i>=55296&&i<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),e.copy(this.charBuffer,0,0,s),t.substring(0,r)}return t},u.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},u.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,i=this.charBuffer,r=this.encoding;t+=i.slice(0,n).toString(r)}return t}},function(e,t){function n(e){return null!==e&&"object"==typeof e}e.exports=n},function(e,t,n){!function(e){"use strict";function t(e,t,n,i){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=i>>24&255,e[t+5]=i>>16&255,e[t+6]=i>>8&255,e[t+7]=255&i}function i(e,t,n,i,r){var s,o=0;for(s=0;s>>8)-1}function r(e,t,n,r){return i(e,t,n,r,16)}function s(e,t,n,r){return i(e,t,n,r,32)}function o(e,t,n,i){for(var r,s=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,u=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,c=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,_=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,v=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,y=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,b=s,E=o,A=a,k=h,S=u,T=c,R=l,M=f,D=d,x=p,I=g,U=m,L=_,C=w,P=v,O=y,N=0;N<20;N+=2)r=b+L|0,S^=r<<7|r>>>25,r=S+b|0,D^=r<<9|r>>>23,r=D+S|0,L^=r<<13|r>>>19,r=L+D|0,b^=r<<18|r>>>14,r=T+E|0,x^=r<<7|r>>>25,r=x+T|0,C^=r<<9|r>>>23,r=C+x|0,E^=r<<13|r>>>19,r=E+C|0,T^=r<<18|r>>>14,r=I+R|0,P^=r<<7|r>>>25,r=P+I|0,A^=r<<9|r>>>23,r=A+P|0,R^=r<<13|r>>>19,r=R+A|0,I^=r<<18|r>>>14,r=O+U|0,k^=r<<7|r>>>25,r=k+O|0,M^=r<<9|r>>>23,r=M+k|0,U^=r<<13|r>>>19,r=U+M|0,O^=r<<18|r>>>14,r=b+k|0,E^=r<<7|r>>>25,r=E+b|0,A^=r<<9|r>>>23,r=A+E|0,k^=r<<13|r>>>19,r=k+A|0,b^=r<<18|r>>>14,r=T+S|0,R^=r<<7|r>>>25,r=R+T|0,M^=r<<9|r>>>23,r=M+R|0,S^=r<<13|r>>>19,r=S+M|0,T^=r<<18|r>>>14,r=I+x|0,U^=r<<7|r>>>25,r=U+I|0,D^=r<<9|r>>>23,r=D+U|0,x^=r<<13|r>>>19,r=x+D|0,I^=r<<18|r>>>14,r=O+P|0,L^=r<<7|r>>>25,r=L+O|0,C^=r<<9|r>>>23,r=C+L|0,P^=r<<13|r>>>19,r=P+C|0,O^=r<<18|r>>>14;b=b+s|0,E=E+o|0,A=A+a|0,k=k+h|0,S=S+u|0,T=T+c|0,R=R+l|0,M=M+f|0,D=D+d|0,x=x+p|0,I=I+g|0,U=U+m|0,L=L+_|0,C=C+w|0,P=P+v|0,O=O+y|0,e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=A>>>0&255,e[9]=A>>>8&255,e[10]=A>>>16&255,e[11]=A>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=S>>>0&255,e[17]=S>>>8&255,e[18]=S>>>16&255,e[19]=S>>>24&255,e[20]=T>>>0&255,e[21]=T>>>8&255,e[22]=T>>>16&255,e[23]=T>>>24&255,e[24]=R>>>0&255,e[25]=R>>>8&255,e[26]=R>>>16&255,e[27]=R>>>24&255,e[28]=M>>>0&255,e[29]=M>>>8&255,e[30]=M>>>16&255,e[31]=M>>>24&255,e[32]=D>>>0&255,e[33]=D>>>8&255,e[34]=D>>>16&255,e[35]=D>>>24&255,e[36]=x>>>0&255,e[37]=x>>>8&255,e[38]=x>>>16&255,e[39]=x>>>24&255,e[40]=I>>>0&255,e[41]=I>>>8&255,e[42]=I>>>16&255,e[43]=I>>>24&255,e[44]=U>>>0&255,e[45]=U>>>8&255,e[46]=U>>>16&255,e[47]=U>>>24&255,e[48]=L>>>0&255,e[49]=L>>>8&255,e[50]=L>>>16&255,e[51]=L>>>24&255,e[52]=C>>>0&255,e[53]=C>>>8&255,e[54]=C>>>16&255,e[55]=C>>>24&255,e[56]=P>>>0&255,e[57]=P>>>8&255,e[58]=P>>>16&255,e[59]=P>>>24&255,e[60]=O>>>0&255,e[61]=O>>>8&255,e[62]=O>>>16&255,e[63]=O>>>24&255}function a(e,t,n,i){for(var r,s=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,u=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,c=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,m=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,_=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,w=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,v=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,y=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,b=s,E=o,A=a,k=h,S=u,T=c,R=l,M=f,D=d,x=p,I=g,U=m,L=_,C=w,P=v,O=y,N=0;N<20;N+=2)r=b+L|0,S^=r<<7|r>>>25,r=S+b|0,D^=r<<9|r>>>23,r=D+S|0,L^=r<<13|r>>>19,r=L+D|0,b^=r<<18|r>>>14,r=T+E|0,x^=r<<7|r>>>25,r=x+T|0,C^=r<<9|r>>>23,r=C+x|0,E^=r<<13|r>>>19,r=E+C|0,T^=r<<18|r>>>14,r=I+R|0,P^=r<<7|r>>>25,r=P+I|0,A^=r<<9|r>>>23,r=A+P|0,R^=r<<13|r>>>19,r=R+A|0,I^=r<<18|r>>>14,r=O+U|0,k^=r<<7|r>>>25,r=k+O|0,M^=r<<9|r>>>23,r=M+k|0,U^=r<<13|r>>>19,r=U+M|0,O^=r<<18|r>>>14,r=b+k|0,E^=r<<7|r>>>25,r=E+b|0,A^=r<<9|r>>>23,r=A+E|0,k^=r<<13|r>>>19,r=k+A|0,b^=r<<18|r>>>14,r=T+S|0,R^=r<<7|r>>>25,r=R+T|0,M^=r<<9|r>>>23,r=M+R|0,S^=r<<13|r>>>19,r=S+M|0,T^=r<<18|r>>>14,r=I+x|0,U^=r<<7|r>>>25,r=U+I|0,D^=r<<9|r>>>23,r=D+U|0,x^=r<<13|r>>>19,r=x+D|0,I^=r<<18|r>>>14,r=O+P|0,L^=r<<7|r>>>25,r=L+O|0,C^=r<<9|r>>>23,r=C+L|0,P^=r<<13|r>>>19,r=P+C|0,O^=r<<18|r>>>14;e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=T>>>0&255,e[5]=T>>>8&255,e[6]=T>>>16&255,e[7]=T>>>24&255,e[8]=I>>>0&255,e[9]=I>>>8&255,e[10]=I>>>16&255,e[11]=I>>>24&255,e[12]=O>>>0&255,e[13]=O>>>8&255,e[14]=O>>>16&255,e[15]=O>>>24&255,e[16]=R>>>0&255,e[17]=R>>>8&255,e[18]=R>>>16&255,e[19]=R>>>24&255,e[20]=M>>>0&255,e[21]=M>>>8&255,e[22]=M>>>16&255,e[23]=M>>>24&255,e[24]=D>>>0&255,e[25]=D>>>8&255,e[26]=D>>>16&255,e[27]=D>>>24&255,e[28]=x>>>0&255,e[29]=x>>>8&255,e[30]=x>>>16&255,e[31]=x>>>24&255}function h(e,t,n,i){o(e,t,n,i)}function u(e,t,n,i){a(e,t,n,i)}function c(e,t,n,i,r,s,o){var a,u,c=new Uint8Array(16),l=new Uint8Array(64);for(u=0;u<16;u++)c[u]=0;for(u=0;u<8;u++)c[u]=s[u];for(;r>=64;){for(h(l,c,o,fe),u=0;u<64;u++)e[t+u]=n[i+u]^l[u];for(a=1,u=8;u<16;u++)a=a+(255&c[u])|0,c[u]=255&a,a>>>=8;r-=64,t+=64,i+=64}if(r>0)for(h(l,c,o,fe),u=0;u=64;){for(h(u,a,r,fe),o=0;o<64;o++)e[t+o]=u[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,t+=64}if(n>0)for(h(u,a,r,fe),o=0;o>16&1),s[n-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),r=s[15]>>16&1,s[14]&=65535,y(o,s,1-r)}for(n=0;n<16;n++)e[2*n]=255&o[n],e[2*n+1]=o[n]>>8}function E(e,t){var n=new Uint8Array(32),i=new Uint8Array(32);return b(n,e),b(i,t),s(n,0,i,0)}function A(e){var t=new Uint8Array(32);return b(t,e),1&t[0]}function k(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function S(e,t,n){for(var i=0;i<16;i++)e[i]=t[i]+n[i]}function T(e,t,n){for(var i=0;i<16;i++)e[i]=t[i]-n[i]}function R(e,t,n){var i,r,s=0,o=0,a=0,h=0,u=0,c=0,l=0,f=0,d=0,p=0,g=0,m=0,_=0,w=0,v=0,y=0,b=0,E=0,A=0,k=0,S=0,T=0,R=0,M=0,D=0,x=0,I=0,U=0,L=0,C=0,P=0,O=n[0],N=n[1],B=n[2],G=n[3],j=n[4],z=n[5],q=n[6],F=n[7],W=n[8],H=n[9],Z=n[10],Y=n[11],V=n[12],K=n[13],X=n[14],J=n[15];i=t[0],s+=i*O,o+=i*N,a+=i*B,h+=i*G,u+=i*j,c+=i*z,l+=i*q,f+=i*F,d+=i*W,p+=i*H,g+=i*Z,m+=i*Y,_+=i*V,w+=i*K,v+=i*X,y+=i*J,i=t[1],o+=i*O,a+=i*N,h+=i*B,u+=i*G,c+=i*j,l+=i*z,f+=i*q,d+=i*F,p+=i*W,g+=i*H,m+=i*Z,_+=i*Y,w+=i*V,v+=i*K,y+=i*X,b+=i*J,i=t[2],a+=i*O,h+=i*N,u+=i*B,c+=i*G,l+=i*j,f+=i*z,d+=i*q,p+=i*F,g+=i*W,m+=i*H,_+=i*Z,w+=i*Y,v+=i*V,y+=i*K,b+=i*X,E+=i*J,i=t[3],h+=i*O,u+=i*N,c+=i*B,l+=i*G,f+=i*j,d+=i*z,p+=i*q,g+=i*F,m+=i*W,_+=i*H,w+=i*Z,v+=i*Y,y+=i*V,b+=i*K,E+=i*X,A+=i*J,i=t[4],u+=i*O,c+=i*N,l+=i*B,f+=i*G,d+=i*j,p+=i*z,g+=i*q,m+=i*F,_+=i*W,w+=i*H,v+=i*Z,y+=i*Y,b+=i*V,E+=i*K,A+=i*X,k+=i*J,i=t[5],c+=i*O,l+=i*N,f+=i*B,d+=i*G,p+=i*j,g+=i*z,m+=i*q,_+=i*F,w+=i*W,v+=i*H,y+=i*Z,b+=i*Y,E+=i*V,A+=i*K,k+=i*X,S+=i*J,i=t[6],l+=i*O,f+=i*N,d+=i*B,p+=i*G,g+=i*j,m+=i*z,_+=i*q,w+=i*F,v+=i*W,y+=i*H,b+=i*Z,E+=i*Y,A+=i*V,k+=i*K,S+=i*X,T+=i*J,i=t[7],f+=i*O,d+=i*N,p+=i*B,g+=i*G,m+=i*j,_+=i*z,w+=i*q,v+=i*F,y+=i*W,b+=i*H,E+=i*Z,A+=i*Y,k+=i*V,S+=i*K,T+=i*X,R+=i*J,i=t[8],d+=i*O,p+=i*N,g+=i*B,m+=i*G,_+=i*j,w+=i*z,v+=i*q,y+=i*F,b+=i*W,E+=i*H,A+=i*Z,k+=i*Y,S+=i*V,T+=i*K,R+=i*X,M+=i*J,i=t[9],p+=i*O,g+=i*N,m+=i*B,_+=i*G,w+=i*j,v+=i*z,y+=i*q,b+=i*F,E+=i*W,A+=i*H,k+=i*Z,S+=i*Y,T+=i*V,R+=i*K,M+=i*X,D+=i*J,i=t[10],g+=i*O,m+=i*N,_+=i*B,w+=i*G,v+=i*j,y+=i*z,b+=i*q,E+=i*F,A+=i*W,k+=i*H,S+=i*Z,T+=i*Y,R+=i*V,M+=i*K,D+=i*X,x+=i*J,i=t[11],m+=i*O,_+=i*N,w+=i*B,v+=i*G,y+=i*j,b+=i*z,E+=i*q,A+=i*F,k+=i*W,S+=i*H,T+=i*Z,R+=i*Y;M+=i*V;D+=i*K,x+=i*X,I+=i*J,i=t[12],_+=i*O,w+=i*N,v+=i*B,y+=i*G,b+=i*j,E+=i*z,A+=i*q,k+=i*F,S+=i*W,T+=i*H,R+=i*Z,M+=i*Y,D+=i*V,x+=i*K,I+=i*X,U+=i*J,i=t[13],w+=i*O,v+=i*N,y+=i*B,b+=i*G,E+=i*j,A+=i*z,k+=i*q,S+=i*F,T+=i*W,R+=i*H,M+=i*Z,D+=i*Y,x+=i*V,I+=i*K,U+=i*X,L+=i*J,i=t[14],v+=i*O,y+=i*N,b+=i*B,E+=i*G,A+=i*j,k+=i*z,S+=i*q,T+=i*F,R+=i*W,M+=i*H,D+=i*Z,x+=i*Y,I+=i*V,U+=i*K,L+=i*X,C+=i*J,i=t[15],y+=i*O,b+=i*N,E+=i*B,A+=i*G,k+=i*j,S+=i*z,T+=i*q,R+=i*F,M+=i*W,D+=i*H,x+=i*Z,I+=i*Y,U+=i*V,L+=i*K,C+=i*X,P+=i*J,s+=38*b,o+=38*E,a+=38*A,h+=38*k,u+=38*S,c+=38*T,l+=38*R,f+=38*M,d+=38*D,p+=38*x,g+=38*I,m+=38*U,_+=38*L,w+=38*C,v+=38*P,r=1,i=s+r+65535,r=Math.floor(i/65536),s=i-65536*r,i=o+r+65535,r=Math.floor(i/65536),o=i-65536*r,i=a+r+65535,r=Math.floor(i/65536),a=i-65536*r,i=h+r+65535,r=Math.floor(i/65536),h=i-65536*r,i=u+r+65535,r=Math.floor(i/65536),u=i-65536*r,i=c+r+65535,r=Math.floor(i/65536),c=i-65536*r,i=l+r+65535,r=Math.floor(i/65536),l=i-65536*r,i=f+r+65535,r=Math.floor(i/65536),f=i-65536*r,i=d+r+65535,r=Math.floor(i/65536),d=i-65536*r,i=p+r+65535,r=Math.floor(i/65536),p=i-65536*r,i=g+r+65535,r=Math.floor(i/65536),g=i-65536*r,i=m+r+65535,r=Math.floor(i/65536),m=i-65536*r,i=_+r+65535,r=Math.floor(i/65536),_=i-65536*r,i=w+r+65535,r=Math.floor(i/65536),w=i-65536*r,i=v+r+65535,r=Math.floor(i/65536),v=i-65536*r,i=y+r+65535,r=Math.floor(i/65536),y=i-65536*r,s+=r-1+37*(r-1),r=1,i=s+r+65535,r=Math.floor(i/65536),s=i-65536*r,i=o+r+65535,r=Math.floor(i/65536),o=i-65536*r,i=a+r+65535,r=Math.floor(i/65536),a=i-65536*r,i=h+r+65535,r=Math.floor(i/65536),h=i-65536*r,i=u+r+65535,r=Math.floor(i/65536),u=i-65536*r,i=c+r+65535,r=Math.floor(i/65536),c=i-65536*r,i=l+r+65535,r=Math.floor(i/65536),l=i-65536*r,i=f+r+65535,r=Math.floor(i/65536),f=i-65536*r,i=d+r+65535,r=Math.floor(i/65536),d=i-65536*r,i=p+r+65535,r=Math.floor(i/65536),p=i-65536*r,i=g+r+65535,r=Math.floor(i/65536),g=i-65536*r,i=m+r+65535,r=Math.floor(i/65536),m=i-65536*r,i=_+r+65535,r=Math.floor(i/65536),_=i-65536*r,i=w+r+65535,r=Math.floor(i/65536),w=i-65536*r,i=v+r+65535,r=Math.floor(i/65536),v=i-65536*r,i=y+r+65535,r=Math.floor(i/65536),y=i-65536*r,s+=r-1+37*(r-1),e[0]=s,e[1]=o,e[2]=a,e[3]=h,e[4]=u,e[5]=c,e[6]=l,e[7]=f,e[8]=d,e[9]=p,e[10]=g,e[11]=m,e[12]=_,e[13]=w;e[14]=v;e[15]=y}function M(e,t){R(e,t,t)}function D(e,t){var n,i=ee();for(n=0;n<16;n++)i[n]=t[n];for(n=253;n>=0;n--)M(i,i),2!==n&&4!==n&&R(i,i,t);for(n=0;n<16;n++)e[n]=i[n]}function x(e,t){var n,i=ee();for(n=0;n<16;n++)i[n]=t[n];for(n=250;n>=0;n--)M(i,i),1!==n&&R(i,i,t);for(n=0;n<16;n++)e[n]=i[n]}function I(e,t,n){var i,r,s=new Uint8Array(32),o=new Float64Array(80),a=ee(),h=ee(),u=ee(),c=ee(),l=ee(),f=ee();for(r=0;r<31;r++)s[r]=t[r];for(s[31]=127&t[31]|64,s[0]&=248,k(o,n),r=0;r<16;r++)h[r]=o[r],c[r]=a[r]=u[r]=0;for(a[0]=c[0]=1,r=254;r>=0;--r)i=s[r>>>3]>>>(7&r)&1,y(a,h,i),y(u,c,i),S(l,a,u),T(a,a,u),S(u,h,c),T(h,h,c),M(c,l),M(f,a),R(a,u,a),R(u,h,l),S(l,a,u),T(a,a,u),M(h,a),T(u,c,f),R(a,u,oe),S(a,a,c),R(u,u,a),R(a,c,f),R(c,h,o),M(h,l),y(a,h,i),y(u,c,i);for(r=0;r<16;r++)o[r+16]=a[r],o[r+32]=u[r],o[r+48]=h[r],o[r+64]=c[r];var d=o.subarray(32),p=o.subarray(16);return D(d,d),R(p,p,d),b(e,p),0}function U(e,t){return I(e,t,ie)}function L(e,t){return te(t,32),U(e,t)}function C(e,t,n){var i=new Uint8Array(32);return I(i,n,t),u(e,ne,i,fe)}function P(e,t,n,i,r,s){var o=new Uint8Array(32);return C(o,r,s),pe(e,t,n,i,o)}function O(e,t,n,i,r,s){var o=new Uint8Array(32);return C(o,r,s),ge(e,t,n,i,o)}function N(e,t,n,i){for(var r,s,o,a,h,u,c,l,f,d,p,g,m,_,w,v,y,b,E,A,k,S,T,R,M,D,x=new Int32Array(16),I=new Int32Array(16),U=e[0],L=e[1],C=e[2],P=e[3],O=e[4],N=e[5],B=e[6],G=e[7],j=t[0],z=t[1],q=t[2],F=t[3],W=t[4],H=t[5],Z=t[6],Y=t[7],V=0;i>=128;){for(E=0;E<16;E++)A=8*E+V,x[E]=n[A+0]<<24|n[A+1]<<16|n[A+2]<<8|n[A+3],I[E]=n[A+4]<<24|n[A+5]<<16|n[A+6]<<8|n[A+7];for(E=0;E<80;E++)if(r=U,s=L,o=C,a=P,h=O,u=N,c=B,l=G,f=j,d=z,p=q,g=F,m=W,_=H,w=Z,v=Y,k=G,S=Y,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=(O>>>14|W<<18)^(O>>>18|W<<14)^(W>>>9|O<<23),S=(W>>>14|O<<18)^(W>>>18|O<<14)^(O>>>9|W<<23),T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,k=O&N^~O&B,S=W&H^~W&Z,T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,k=me[2*E],S=me[2*E+1],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,k=x[E%16],S=I[E%16],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,y=65535&M|D<<16,b=65535&T|R<<16,k=y,S=b,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=(U>>>28|j<<4)^(j>>>2|U<<30)^(j>>>7|U<<25),S=(j>>>28|U<<4)^(U>>>2|j<<30)^(U>>>7|j<<25),T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,k=U&L^U&C^L&C,S=j&z^j&q^z&q,T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,l=65535&M|D<<16,v=65535&T|R<<16,k=a,S=g,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=y,S=b,T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,a=65535&M|D<<16,g=65535&T|R<<16,L=r,C=s,P=o,O=a,N=h,B=u,G=c,U=l,z=f,q=d,F=p,W=g,H=m,Z=_,Y=w,j=v,E%16===15)for(A=0;A<16;A++)k=x[A],S=I[A],T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=x[(A+9)%16],S=I[(A+9)%16],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,y=x[(A+1)%16],b=I[(A+1)%16], +k=(y>>>1|b<<31)^(y>>>8|b<<24)^y>>>7,S=(b>>>1|y<<31)^(b>>>8|y<<24)^(b>>>7|y<<25),T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,y=x[(A+14)%16],b=I[(A+14)%16],k=(y>>>19|b<<13)^(b>>>29|y<<3)^y>>>6,S=(b>>>19|y<<13)^(y>>>29|b<<3)^(b>>>6|y<<26),T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,x[A]=65535&M|D<<16,I[A]=65535&T|R<<16;k=U,S=j,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[0],S=t[0],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[0]=U=65535&M|D<<16,t[0]=j=65535&T|R<<16,k=L,S=z,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[1],S=t[1],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[1]=L=65535&M|D<<16,t[1]=z=65535&T|R<<16,k=C,S=q,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[2],S=t[2],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[2]=C=65535&M|D<<16,t[2]=q=65535&T|R<<16,k=P,S=F,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[3],S=t[3],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[3]=P=65535&M|D<<16,t[3]=F=65535&T|R<<16,k=O,S=W,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[4],S=t[4],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[4]=O=65535&M|D<<16,t[4]=W=65535&T|R<<16,k=N,S=H,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[5],S=t[5],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[5]=N=65535&M|D<<16,t[5]=H=65535&T|R<<16,k=B,S=Z,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[6],S=t[6],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[6]=B=65535&M|D<<16,t[6]=Z=65535&T|R<<16,k=G,S=Y,T=65535&S,R=S>>>16,M=65535&k,D=k>>>16,k=e[7],S=t[7],T+=65535&S,R+=S>>>16,M+=65535&k,D+=k>>>16,R+=T>>>16,M+=R>>>16,D+=M>>>16,e[7]=G=65535&M|D<<16,t[7]=Y=65535&T|R<<16,V+=128,i-=128}return i}function B(e,n,i){var r,s=new Int32Array(8),o=new Int32Array(8),a=new Uint8Array(256),h=i;for(s[0]=1779033703,s[1]=3144134277,s[2]=1013904242,s[3]=2773480762,s[4]=1359893119,s[5]=2600822924,s[6]=528734635,s[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,N(s,o,n,i),i%=128,r=0;r=0;--r)i=n[r/8|0]>>(7&r)&1,j(e,t,i),G(t,e),G(e,e),j(e,t,i)}function F(e,t){var n=[ee(),ee(),ee(),ee()];w(n[0],ue),w(n[1],ce),w(n[2],se),R(n[3],ue,ce),q(e,n,t)}function W(e,t,n){var i,r=new Uint8Array(64),s=[ee(),ee(),ee(),ee()];for(n||te(t,32),B(r,t,32),r[0]&=248,r[31]&=127,r[31]|=64,F(s,r),z(e,s),i=0;i<32;i++)t[i+32]=e[i];return 0}function H(e,t){var n,i,r,s;for(i=63;i>=32;--i){for(n=0,r=i-32,s=i-12;r>8,t[r]-=256*n;t[r]+=n,t[i]=0}for(n=0,r=0;r<32;r++)t[r]+=n-(t[31]>>4)*_e[r],n=t[r]>>8,t[r]&=255;for(r=0;r<32;r++)t[r]-=n*_e[r];for(i=0;i<32;i++)t[i+1]+=t[i]>>8,e[i]=255&t[i]}function Z(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;H(e,n)}function Y(e,t,n,i){var r,s,o=new Uint8Array(64),a=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),c=[ee(),ee(),ee(),ee()];B(o,i,32),o[0]&=248,o[31]&=127,o[31]|=64;var l=n+64;for(r=0;r>7&&T(e[0],re,e[0]),R(e[3],e[0],e[1]),0)}function K(e,t,n,i){var r,o,a=new Uint8Array(32),h=new Uint8Array(64),u=[ee(),ee(),ee(),ee()],c=[ee(),ee(),ee(),ee()];if(o=-1,n<64)return-1;if(V(c,i))return-1;for(r=0;r>>13|n<<3),i=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|i<<6),r=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(i>>>7|r<<9),s=255&e[8]|(255&e[9])<<8,this.r[4]=255&(r>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};de.prototype.blocks=function(e,t,n){for(var i,r,s,o,a,h,u,c,l,f,d,p,g,m,_,w,v,y,b,E=this.fin?0:2048,A=this.h[0],k=this.h[1],S=this.h[2],T=this.h[3],R=this.h[4],M=this.h[5],D=this.h[6],x=this.h[7],I=this.h[8],U=this.h[9],L=this.r[0],C=this.r[1],P=this.r[2],O=this.r[3],N=this.r[4],B=this.r[5],G=this.r[6],j=this.r[7],z=this.r[8],q=this.r[9];n>=16;)i=255&e[t+0]|(255&e[t+1])<<8,A+=8191&i,r=255&e[t+2]|(255&e[t+3])<<8,k+=8191&(i>>>13|r<<3),s=255&e[t+4]|(255&e[t+5])<<8,S+=8191&(r>>>10|s<<6),o=255&e[t+6]|(255&e[t+7])<<8,T+=8191&(s>>>7|o<<9),a=255&e[t+8]|(255&e[t+9])<<8,R+=8191&(o>>>4|a<<12),M+=a>>>1&8191,h=255&e[t+10]|(255&e[t+11])<<8,D+=8191&(a>>>14|h<<2),u=255&e[t+12]|(255&e[t+13])<<8,x+=8191&(h>>>11|u<<5),c=255&e[t+14]|(255&e[t+15])<<8,I+=8191&(u>>>8|c<<8),U+=c>>>5|E,l=0,f=l,f+=A*L,f+=k*(5*q),f+=S*(5*z),f+=T*(5*j),f+=R*(5*G),l=f>>>13,f&=8191,f+=M*(5*B),f+=D*(5*N),f+=x*(5*O),f+=I*(5*P),f+=U*(5*C),l+=f>>>13,f&=8191,d=l,d+=A*C,d+=k*L,d+=S*(5*q),d+=T*(5*z),d+=R*(5*j),l=d>>>13,d&=8191,d+=M*(5*G),d+=D*(5*B),d+=x*(5*N),d+=I*(5*O),d+=U*(5*P),l+=d>>>13,d&=8191,p=l,p+=A*P,p+=k*C,p+=S*L,p+=T*(5*q),p+=R*(5*z),l=p>>>13,p&=8191,p+=M*(5*j),p+=D*(5*G),p+=x*(5*B),p+=I*(5*N),p+=U*(5*O),l+=p>>>13,p&=8191,g=l,g+=A*O,g+=k*P,g+=S*C,g+=T*L,g+=R*(5*q),l=g>>>13,g&=8191,g+=M*(5*z),g+=D*(5*j),g+=x*(5*G),g+=I*(5*B),g+=U*(5*N),l+=g>>>13,g&=8191,m=l,m+=A*N,m+=k*O,m+=S*P,m+=T*C,m+=R*L,l=m>>>13,m&=8191,m+=M*(5*q),m+=D*(5*z),m+=x*(5*j),m+=I*(5*G),m+=U*(5*B),l+=m>>>13,m&=8191,_=l,_+=A*B,_+=k*N,_+=S*O,_+=T*P,_+=R*C,l=_>>>13,_&=8191,_+=M*L,_+=D*(5*q),_+=x*(5*z),_+=I*(5*j),_+=U*(5*G),l+=_>>>13,_&=8191,w=l,w+=A*G,w+=k*B,w+=S*N,w+=T*O,w+=R*P,l=w>>>13,w&=8191,w+=M*C,w+=D*L,w+=x*(5*q),w+=I*(5*z),w+=U*(5*j),l+=w>>>13,w&=8191,v=l,v+=A*j,v+=k*G,v+=S*B,v+=T*N,v+=R*O,l=v>>>13,v&=8191,v+=M*P,v+=D*C,v+=x*L,v+=I*(5*q),v+=U*(5*z),l+=v>>>13,v&=8191,y=l,y+=A*z,y+=k*j,y+=S*G,y+=T*B,y+=R*N,l=y>>>13,y&=8191,y+=M*O,y+=D*P,y+=x*C,y+=I*L,y+=U*(5*q),l+=y>>>13,y&=8191,b=l,b+=A*q,b+=k*z,b+=S*j,b+=T*G,b+=R*B,l=b>>>13,b&=8191,b+=M*N,b+=D*O,b+=x*P,b+=I*C,b+=U*L,l+=b>>>13,b&=8191,l=(l<<2)+l|0,l=l+f|0,f=8191&l,l>>>=13,d+=l,A=f,k=d,S=p,T=g,R=m,M=_,D=w,x=v,I=y,U=b,t+=16,n-=16;this.h[0]=A,this.h[1]=k,this.h[2]=S,this.h[3]=T,this.h[4]=R,this.h[5]=M,this.h[6]=D,this.h[7]=x,this.h[8]=I,this.h[9]=U},de.prototype.finish=function(e,t){var n,i,r,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,i=(1^n)-1,s=0;s<10;s++)o[s]&=i;for(i=~i,s=0;s<10;s++)this.h[s]=this.h[s]&i|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),r=this.h[0]+this.pad[0],this.h[0]=65535&r,s=1;s<8;s++)r=(this.h[s]+this.pad[s]|0)+(r>>>16)|0,this.h[s]=65535&r;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},de.prototype.update=function(e,t,n){var i,r;if(this.leftover){for(r=16-this.leftover,r>n&&(r=n),i=0;i=16&&(r=n-n%16,this.blocks(e,t,r),t+=r,n-=r),n){for(i=0;i=0},e.sign.keyPair=function(){var e=new Uint8Array(Ie),t=new Uint8Array(Ue);return W(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if($(e),e.length!==Ue)throw new Error("bad secret key size");for(var t=new Uint8Array(Ie),n=0;n=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),g(n)?i.showHidden=n:n&&t._extend(i,n),b(i.showHidden)&&(i.showHidden=!1),b(i.depth)&&(i.depth=2),b(i.colors)&&(i.colors=!1),b(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=s),h(i,e,i.depth)}function s(e,t){var n=r.styles[t];return n?"["+r.colors[n][0]+"m"+e+"["+r.colors[n][1]+"m":e}function o(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function h(e,n,i){if(e.customInspect&&n&&T(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var r=n.inspect(i,e);return v(r)||(r=h(e,r,i)),r}var s=u(e,n);if(s)return s;var o=Object.keys(n),g=a(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(n)),S(n)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return c(n);if(0===o.length){if(T(n)){var m=n.name?": "+n.name:"";return e.stylize("[Function"+m+"]","special")}if(E(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(k(n))return e.stylize(Date.prototype.toString.call(n),"date");if(S(n))return c(n)}var _="",w=!1,y=["{","}"];if(p(n)&&(w=!0,y=["[","]"]),T(n)){var b=n.name?": "+n.name:"";_=" [Function"+b+"]"}if(E(n)&&(_=" "+RegExp.prototype.toString.call(n)),k(n)&&(_=" "+Date.prototype.toUTCString.call(n)),S(n)&&(_=" "+c(n)),0===o.length&&(!w||0==n.length))return y[0]+_+y[1];if(i<0)return E(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var A;return A=w?l(e,n,i,g,o):o.map(function(t){return f(e,n,i,g,t,w)}),e.seen.pop(),d(A,_,y)}function u(e,t){if(b(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return w(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,n,i,r){for(var s=[],o=0,a=t.length;o-1&&(a=s?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),b(o)){if(s&&r.match(/^\d+$/))return a;o=JSON.stringify(""+r),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+a}function d(e,t,n){var i=0,r=e.reduce(function(e,t){return i++,t.indexOf("\n")>=0&&i++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function _(e){return null==e}function w(e){return"number"==typeof e}function v(e){return"string"==typeof e}function y(e){return"symbol"==typeof e}function b(e){return void 0===e}function E(e){return A(e)&&"[object RegExp]"===M(e)}function A(e){return"object"==typeof e&&null!==e}function k(e){return A(e)&&"[object Date]"===M(e)}function S(e){return A(e)&&("[object Error]"===M(e)||e instanceof Error)}function T(e){return"function"==typeof e}function R(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function M(e){return Object.prototype.toString.call(e)}function D(e){return e<10?"0"+e.toString(10):e.toString(10)}function x(){var e=new Date,t=[D(e.getHours()),D(e.getMinutes()),D(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var U=/%[sdj%]/g;t.format=function(e){if(!v(e)){for(var t=[],n=0;n=s)return e;switch(e){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(e){return"[Circular]"}default:return e}}),a=i[n];n{if(/^https?:\/\//.test(e)){const i=s.get(e).set("Content-Type","blob");this.client.browser&&i.responseType("arraybuffer"),i.end((e,i)=>{return e?o(e):this.client.browser?n(a(i.xhr.response)):i.body instanceof t?n(i.body):o(new TypeError("Body is not a Buffer"))})}else{const t=i.resolve(e);r.stat(t,(e,i)=>{if(e&&o(e),!i||!i.isFile())throw new Error(`The file could not be found: ${t}`);r.readFile(t,(e,t)=>{e?o(e):n(t)})})}}):Promise.reject(new TypeError("The resource must be a string or Buffer."))}resolveEmojiIdentifier(e){return e instanceof d||e instanceof p?e.identifier:"string"!=typeof e||e.includes("%")?null:encodeURIComponent(e)}}e.exports=g}).call(t,n(5).Buffer)},function(e,t,n){const i=n(138),r=n(135),s=n(137),o=n(136),a=n(134),h=n(0);class u{constructor(e){this.client=e,this.handlers={},this.userAgentManager=new i(this),this.methods=new r(this),this.rateLimitedEndpoints={},this.globallyRateLimited=!1}push(e,t){return new Promise((n,i)=>{e.push({request:t,resolve:n,reject:i})})}getRequestHandler(){switch(this.client.options.apiRequestMethod){case"sequential":return s;case"burst":return o;default:throw new Error(h.Errors.INVALID_RATE_LIMIT_METHOD)}}makeRequest(e,t,n,i,r){const s=new a(this,e,t,n,i,r);if(!this.handlers[s.route]){const e=this.getRequestHandler();this.handlers[s.route]=new e(this,s.route)}return this.push(this.handlers[s.route],s)}}e.exports=u},function(e,t){class n{constructor(e){this.restManager=e,this.queue=[]}get globalLimit(){return this.restManager.globallyRateLimited}set globalLimit(e){this.restManager.globallyRateLimited=e}push(e){this.queue.push(e)}handle(){}}e.exports=n},function(e,t){class n{constructor(e){this.player=e}encode(e){return e}decode(e){return e}}e.exports=n},function(e,t,n){(function(t){function n(e){const n=new t(e.byteLength),i=new Uint8Array(e);for(var r=0;r0&&this.setInterval(this.sweepMessages.bind(this),1e3*this.options.messageSweepInterval)}get status(){return this.ws.status}get uptime(){return this.readyAt?Date.now()-this.readyAt:null}get voiceConnections(){return this.voice.connections}get emojis(){const e=new Collection;for(const t of this.guilds.values())for(const n of t.emojis.values())e.set(n.id,n);return e}get readyTimestamp(){return this.readyAt?this.readyAt.getTime():null}login(e,t=null){return t?this.rest.methods.loginEmailPassword(e,t):this.rest.methods.loginToken(e)}destroy(){for(const e of this._timeouts)clearTimeout(e);for(const t of this._intervals)clearInterval(t);return this._timeouts.clear(),this._intervals.clear(),this.token=null,this.email=null,this.password=null,this.manager.destroy()}syncGuilds(e=this.guilds){this.user.bot||this.ws.send({op:12,d:e instanceof Collection?e.keyArray():e.map(e=>e.id)})}fetchUser(e){return this.users.has(e)?Promise.resolve(this.users.get(e)):this.rest.methods.getUser(e)}fetchInvite(e){const t=this.resolver.resolveInviteCode(e);return this.rest.methods.getInvite(t)}fetchWebhook(e,t){return this.rest.methods.getWebhook(e,t)}sweepMessages(e=this.options.messageCacheLifetime){if("number"!=typeof e||isNaN(e))throw new TypeError("The lifetime must be a number.");if(e<=0)return this.emit("debug","Didn't sweep messages - lifetime is unlimited"),-1;const t=1e3*e,n=Date.now();let i=0,r=0;for(const s of this.channels.values())if(s.messages){i++;for(const e of s.messages.values())n-(e.editedTimestamp||e.createdTimestamp)>t&&(s.messages.delete(e.id),r++)}return this.emit("debug",`Swept ${r} messages older than ${e} seconds in ${i} text-based channels`),r}fetchApplication(){if(!this.user.bot)throw new Error(Constants.Errors.NO_BOT_ACCOUNT);return this.rest.methods.getMyApplication()}setTimeout(e,t,...n){const i=setTimeout(()=>{e(),this._timeouts.delete(i)},t,...n);return this._timeouts.add(i),i}clearTimeout(e){clearTimeout(e),this._timeouts.delete(e)}setInterval(e,t,...n){const i=setInterval(e,t,...n);return this._intervals.add(i),i}clearInterval(e){clearInterval(e),this._intervals.delete(e)}_setPresence(e,t){return this.presences.get(e)?void this.presences.get(e).update(t):void this.presences.set(e,new Presence(t))}_eval(script){return eval(script)}_validateOptions(e=this.options){if("number"!=typeof e.shardCount||isNaN(e.shardCount))throw new TypeError("The shardCount option must be a number."); +if("number"!=typeof e.shardId||isNaN(e.shardId))throw new TypeError("The shardId option must be a number.");if(e.shardCount<0)throw new RangeError("The shardCount option must be at least 0.");if(e.shardId<0)throw new RangeError("The shardId option must be at least 0.");if(0!==e.shardId&&e.shardId>=e.shardCount)throw new RangeError("The shardId option must be less than shardCount.");if("number"!=typeof e.messageCacheMaxSize||isNaN(e.messageCacheMaxSize))throw new TypeError("The messageCacheMaxSize option must be a number.");if("number"!=typeof e.messageCacheLifetime||isNaN(e.messageCacheLifetime))throw new TypeError("The messageCacheLifetime option must be a number.");if("number"!=typeof e.messageSweepInterval||isNaN(e.messageSweepInterval))throw new TypeError("The messageSweepInterval option must be a number.");if("boolean"!=typeof e.fetchAllMembers)throw new TypeError("The fetchAllMembers option must be a boolean.");if("boolean"!=typeof e.disableEveryone)throw new TypeError("The disableEveryone option must be a boolean.");if("number"!=typeof e.restWsBridgeTimeout||isNaN(e.restWsBridgeTimeout))throw new TypeError("The restWsBridgeTimeout option must be a number.");if(!(e.disabledEvents instanceof Array))throw new TypeError("The disabledEvents option must be an Array.")}}module.exports=Client}).call(exports,__webpack_require__(6))},function(e,t,n){const i=n(30),r=n(70),s=n(69),o=n(26),a=n(0);class h extends i{constructor(e,t,n){super(null,e,t),this.options=o(a.DefaultOptions,n),this.rest=new r(this),this.resolver=new s(this)}}e.exports=h},function(e,t,n){(function(t){const i=n(17),r=n(13),s=n(4).EventEmitter,o=n(26),a=n(39),h=n(3),u=n(56);class c extends s{constructor(e,n={}){if(super(),n=o({totalShards:"auto",respawn:!0,shardArgs:[],token:null},n),this.file=e,!e)throw new Error("File must be specified.");i.isAbsolute(e)||(this.file=i.resolve(t.cwd(),e));const s=r.statSync(this.file);if(!s.isFile())throw new Error("File path does not point to a file.");if(this.totalShards=n.totalShards,"auto"!==this.totalShards){if("number"!=typeof this.totalShards||isNaN(this.totalShards))throw new TypeError("Amount of shards must be a number.");if(this.totalShards<1)throw new RangeError("Amount of shards must be at least 1.");if(this.totalShards!==Math.floor(this.totalShards))throw new RangeError("Amount of shards must be an integer.")}this.respawn=n.respawn,this.shardArgs=n.shardArgs,this.token=n.token?n.token.replace(/^Bot\s*/i,""):null,this.shards=new h}createShard(e=this.shards.size){const t=new a(this,e,this.shardArgs);return this.shards.set(e,t),this.emit("launch",t),Promise.resolve(t)}spawn(e=this.totalShards,t=5500){if("auto"===e)return u(this.token).then(e=>{return this.totalShards=e,this._spawn(e,t)});if("number"!=typeof e||isNaN(e))throw new TypeError("Amount of shards must be a number.");if(e<1)throw new RangeError("Amount of shards must be at least 1.");if(e!==Math.floor(e))throw new TypeError("Amount of shards must be an integer.");return this._spawn(e,t)}_spawn(e,t){return new Promise(n=>{if(this.shards.size>=e)throw new Error(`Already spawned ${this.shards.size} shards.`);if(this.totalShards=e,this.createShard(),this.shards.size>=this.totalShards)return void n(this.shards);if(t<=0){for(;this.shards.size{this.createShard(),this.shards.size>=this.totalShards&&(clearInterval(e),n(this.shards))},t)}})}broadcast(e){const t=[];for(const n of this.shards.values())t.push(n.send(e));return Promise.all(t)}broadcastEval(e){const t=[];for(const n of this.shards.values())t.push(n.eval(e));return Promise.all(t)}fetchClientValues(e){if(0===this.shards.size)return Promise.reject(new Error("No shards have been spawned."));if(this.shards.size!==this.totalShards)return Promise.reject(new Error("Still spawning shards."));const t=[];for(const n of this.shards.values())t.push(n.fetchClientValue(e));return Promise.all(t)}}e.exports=c}).call(t,n(6))},function(e,t,n){"use strict";(function(t){/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -function i(e,t){if(e===t)return 0;for(var n=e.length,i=t.length,r=0,s=Math.min(n,i);r=0;a--)if(c[a]!==h[a])return!1;for(a=c.length-1;a>=0;a--)if(o=c[a],!l(e[o],t[o],n,i))return!1;return!0}function m(e,t,n){l(e,t,!0)&&u(e,t,n,"notDeepStrictEqual",m)}function g(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&t.call({},e)===!0}function v(e){var t;try{e()}catch(e){t=e}return t}function y(e,t,n,i){var r;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(i=n,n=null),r=v(t),i=(n&&n.name?" ("+n.name+").":".")+(i?" "+i:"."),e&&!r&&u(r,n,"Missing expected exception"+i);var s="string"==typeof i,o=!e&&_.isError(r),a=!e&&r&&!n;if((o&&s&&g(r,n)||a)&&u(r,n,"Got unwanted exception"+i),e&&r&&n&&!g(r,n)||!e&&r)throw r}var _=n(10),w=Object.prototype.hasOwnProperty,E=Array.prototype.slice,S=function(){return"foo"===function(){}.name}(),k=e.exports=d,A=/\s*function\s+([^\(\s]*)\s*/;k.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=f(this),this.generatedMessage=!0);var t=e.stackStartFunction||u;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var i=n.stack,r=a(t),s=i.indexOf("\n"+r);if(s>=0){var o=i.indexOf("\n",s+1);i=i.substring(o+1)}this.stack=i}}},_.inherits(k.AssertionError,Error),k.fail=u,k.ok=d,k.equal=function(e,t,n){e!=t&&u(e,t,n,"==",k.equal)},k.notEqual=function(e,t,n){e==t&&u(e,t,n,"!=",k.notEqual)},k.deepEqual=function(e,t,n){l(e,t,!1)||u(e,t,n,"deepEqual",k.deepEqual)},k.deepStrictEqual=function(e,t,n){l(e,t,!0)||u(e,t,n,"deepStrictEqual",k.deepStrictEqual)},k.notDeepEqual=function(e,t,n){l(e,t,!1)&&u(e,t,n,"notDeepEqual",k.notDeepEqual)},k.notDeepStrictEqual=m,k.strictEqual=function(e,t,n){e!==t&&u(e,t,n,"===",k.strictEqual)},k.notStrictEqual=function(e,t,n){e===t&&u(e,t,n,"!==",k.notStrictEqual)},k.throws=function(e,t,n){y(!0,e,t,n)},k.doesNotThrow=function(e,t,n){y(!1,e,t,n)},k.ifError=function(e){if(e)throw e};var M=Object.keys||function(e){var t=[];for(var n in e)w.call(e,n)&&t.push(n);return t}}).call(t,n(18))},function(e,t){"use strict";function n(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function r(e){var t,i,r,s,o,a,c=e.length;o=n(e),a=new f(3*c/4-o),r=o>0?c-4:c;var u=0;for(t=0,i=0;t>16&255,a[u++]=s>>8&255,a[u++]=255&s;return 2===o?(s=h[e.charCodeAt(t)]<<2|h[e.charCodeAt(t+1)]>>4,a[u++]=255&s):1===o&&(s=h[e.charCodeAt(t)]<<10|h[e.charCodeAt(t+1)]<<4|h[e.charCodeAt(t+2)]>>2,a[u++]=s>>8&255,a[u++]=255&s),a}function s(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function o(e,t,n){for(var i,r=[],o=t;of?f:h+a));return 1===i?(t=e[n-1],r+=c[t>>2],r+=c[t<<4&63],r+="=="):2===i&&(t=(e[n-2]<<8)+e[n-1],r+=c[t>>10],r+=c[t>>4&63],r+=c[t<<2&63],r+="="),s.push(r),s.join("")}t.byteLength=i,t.toByteArray=r,t.fromByteArray=a;for(var c=[],h=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,l=u.length;d16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},r.prototype.flush=function(){if(this.cache.length)return this.cache};var b={ECB:n(96),CBC:n(92),CFB:n(93),CFB8:n(95),CFB1:n(94),OFB:n(97),CTR:n(39),GCM:n(39)};t.createDecipher=a,t.createDecipheriv=o}).call(t,n(0).Buffer)},function(e,t,n){(function(e){function i(t,n,s){return this instanceof i?(c.call(this),this._cache=new r,this._cipher=new a.AES(n),this._prev=new e(s.length),s.copy(this._prev),this._mode=t,void(this._autopadding=!0)):new i(t,n,s)}function r(){return this instanceof r?void(this.cache=new e("")):new r}function s(t,n,r){var s=f[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=new e(r)),"string"==typeof n&&(n=new e(n)),n.length!==s.key/8)throw new TypeError("invalid key length "+n.length);if(r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new d(p[s.mode],n,r):"auth"===s.type?new l(p[s.mode],n,r):new i(p[s.mode],n,r)}function o(e,t){var n=f[e.toLowerCase()];if(!n)throw new TypeError("invalid suite type");var i=u(t,!1,n.key,n.iv);return s(e,i.key,i.iv)}var a=n(37),c=n(20),h=n(2),f=n(38),u=n(41),d=n(98),l=n(91);h(i,c),i.prototype._update=function(t){this._cache.add(t);for(var n,i,r=[];n=this._cache.get();)i=this._mode.encrypt(this,n),r.push(i);return e.concat(r)},i.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if("10101010101010101010101010101010"!==e.toString("hex"))throw this._cipher.scrub(),new Error("data not multiple of block length")},i.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},r.prototype.add=function(t){this.cache=e.concat([this.cache,t])},r.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},r.prototype.flush=function(){for(var t=16-this.cache.length,n=new e(t),i=-1;++ic||e<0?(n=Math.abs(e)%c,e<0?c-n:n):e}function o(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]}var a=new t(16);a.fill(0),e.exports=n,n.prototype.ghash=function(e){for(var t=-1;++t0;e--)s[e]=s[e]>>>1|(1&s[e-1])<<31;s[0]=s[0]>>>1,n&&(s[0]=s[0]^225<<24)}this.state=r(a)},n.prototype.update=function(e){this.cache=t.concat([this.cache,e]);for(var n;this.cache.length>=16;)n=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(n)},n.prototype.final=function(e,n){return this.cache.length&&this.ghash(t.concat([this.cache,a],16)),this.ghash(r([0,e,0,n])),this.state};var c=Math.pow(2,32)}).call(t,n(0).Buffer)},function(e,t,n){function i(e,t){var n,i;if(e=e.toLowerCase(),d[e])n=d[e].key,i=d[e].iv;else{if(!u[e])throw new TypeError("invalid suite type");n=8*u[e].key,i=u[e].iv}var r=c(t,!1,n,i);return s(e,r.key,r.iv)}function r(e,t){var n,i;if(e=e.toLowerCase(),d[e])n=d[e].key,i=d[e].iv;else{if(!u[e])throw new TypeError("invalid suite type");n=8*u[e].key,i=u[e].iv}var r=c(t,!1,n,i);return o(e,r.key,r.iv)}function s(e,t,n){if(e=e.toLowerCase(),d[e])return h.createCipheriv(e,t,n);if(u[e])return new f({key:t,iv:n,mode:e});throw new TypeError("invalid suite type")}function o(e,t,n){if(e=e.toLowerCase(),d[e])return h.createDecipheriv(e,t,n);if(u[e])return new f({key:t,iv:n,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}function a(){return Object.keys(u).concat(h.getCiphers())}var c=n(41),h=n(50),f=n(155),u=n(156),d=n(38);t.createCipher=t.Cipher=i,t.createCipheriv=t.Cipheriv=s,t.createDecipher=t.Decipher=r,t.createDecipheriv=t.Decipheriv=o,t.listCiphers=t.getCiphers=a},function(e,t,n){(function(t){function i(e){r.call(this);var n,i=e.mode.toLowerCase(),s=a[i];n=e.decrypt?"decrypt":"encrypt";var o=e.key;"des-ede"!==i&&"des-ede-cbc"!==i||(o=t.concat([o,o.slice(0,8)]));var c=e.iv;this._des=s.create({key:o,iv:c,type:n})}var r=n(20),s=n(54),o=n(2),a={"des-ede3-cbc":s.CBC.instantiate(s.EDE),"des-ede3":s.EDE,"des-ede-cbc":s.CBC.instantiate(s.EDE),"des-ede":s.EDE,"des-cbc":s.CBC.instantiate(s.DES),"des-ecb":s.DES};a.des=a["des-cbc"],a.des3=a["des-ede3-cbc"],e.exports=i,o(i,r),i.prototype._update=function(e){return new t(this._des.update(e))},i.prototype._final=function(){return new t(this._des.final())}}).call(t,n(0).Buffer)},function(e,t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}},function(e,t,n){(function(t){function i(e){u.Writable.call(this);var t=l[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=c(t.hash),this._tag=t.id,this._signType=t.sign}function r(e){u.Writable.call(this);var t=l[e];if(!t)throw new Error("Unknown message digest");this._hash=c(t.hash),this._tag=t.id,this._signType=t.sign}function s(e){return new i(e)}function o(e){return new r(e)}var a=n(99),c=n(21),h=n(2),f=n(158),u=n(11),d=n(159),l={};Object.keys(a).forEach(function(e){l[e]=l[e.toLowerCase()]=a[e]}),h(i,u.Writable),i.prototype._write=function(e,t,n){this._hash.update(e),n()},i.prototype.update=function(e,n){return"string"==typeof e&&(e=new t(e,n)),this._hash.update(e),this},i.prototype.sign=function(e,n){this.end();var i=this._hash.digest(),r=f(t.concat([this._tag,i]),e,this._hashType,this._signType);return n?r.toString(n):r},h(r,u.Writable),r.prototype._write=function(e,t,n){this._hash.update(e),n()},r.prototype.update=function(e,n){return"string"==typeof e&&(e=new t(e,n)),this._hash.update(e),this},r.prototype.verify=function(e,n,i){"string"==typeof n&&(n=new t(n,i)),this.end();var r=this._hash.digest();return d(n,t.concat([this._tag,r]),e,this._signType)},e.exports={Sign:s,Verify:o,createSign:s,createVerify:o}}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(e,t,n,i){var o=m(t);if(o.curve){if("ecdsa"!==i)throw new Error("wrong private key type");return r(e,o)}if("dsa"===o.type){if("dsa"!==i)throw new Error("wrong private key type");return s(e,o,n)}if("rsa"!==i)throw new Error("wrong private key type");for(var a=o.modulus.byteLength(),c=[0,1];e.length+c.length+10&&n.ishrn(i),n}function h(e,n){e=c(e,n),e=e.mod(n);var i=new t(e.toArray());if(i.length=t)throw new Error("invalid sig")}var a=n(100),c=n(9),h=n(43),f=n(7),u=c.ec;e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){(function(e,i){function r(e){if(et.UNZIP)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function s(e,t){for(var n=0;n - * MIT Licensed - */ -e.exports.BufferUtil={merge:function(e,t){for(var n=0,i=0,r=t.length;n>>5]|=e[n]<<24-i%32;return t}function i(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t}function r(e,t,n){for(var i=0;i<16;i++){var r=n+i,u=t[r];t[r]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var v,y,_,w,E,S,k,A,M,x;S=v=e[0],k=y=e[1],A=_=e[2],M=w=e[3],x=E=e[4];var R;for(i=0;i<80;i+=1)R=v+t[n+d[i]]|0,R+=i<16?s(y,_,w)+m[0]:i<32?o(y,_,w)+m[1]:i<48?a(y,_,w)+m[2]:i<64?c(y,_,w)+m[3]:h(y,_,w)+m[4],R|=0,R=f(R,p[i]),R=R+E|0,v=E,E=w,w=f(_,10),_=y,y=R,R=S+t[n+l[i]]|0,R+=i<16?h(k,A,M)+g[0]:i<32?c(k,A,M)+g[1]:i<48?a(k,A,M)+g[2]:i<64?o(k,A,M)+g[3]:s(k,A,M)+g[4],R|=0,R=f(R,b[i]),R=R+x|0,S=x,x=M,M=f(A,10),A=k,k=R;R=e[1]+_+M|0,e[1]=e[2]+w+x|0,e[2]=e[3]+E+S|0,e[3]=e[4]+v+k|0,e[4]=e[0]+y+A|0,e[0]=R}function s(e,t,n){return e^t^n}function o(e,t,n){return e&t|~e&n}function a(e,t,n){return(e|~t)^n}function c(e,t,n){return e&n|t&~n}function h(e,t,n){return e^(t|~n)}function f(e,t){return e<>>32-t}function u(e){var s=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof e&&(e=new t(e,"utf8"));var o=n(e),a=8*e.length,c=8*e.length;o[a>>>5]|=128<<24-a%32,o[(a+64>>>9<<4)+14]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8);for(var h=0;h>>24)|4278255360&(f<<24|f>>>8)}var u=i(s);return new t(u)}/** @preserve -(c) 2012 by Cédric Mesnil. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -var d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],l=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],p=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],b=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],m=[0,1518500249,1859775393,2400959708,2840853838],g=[1352829926,1548603684,1836072691,2053994217,0];e.exports=u}).call(t,n(0).Buffer)},function(e,t,n){var t=e.exports=function(e){e=e.toLowerCase();var n=t[e];if(!n)throw new Error(e+" is not supported (we accept pull requests)");return new n};t.sha=n(168),t.sha1=n(169),t.sha224=n(170),t.sha256=n(103),t.sha384=n(171),t.sha512=n(104)},function(e,t,n){(function(t){function i(){this.init(),this._w=f,c.call(this,64,56)}function r(e){return e<<5|e>>>27}function s(e){return e<<30|e>>>2}function o(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}var a=n(2),c=n(22),h=[1518500249,1859775393,-1894007588,-899497514],f=new Array(80);a(i,c),i.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},i.prototype._update=function(e){for(var t=this._w,n=0|this._a,i=0|this._b,a=0|this._c,c=0|this._d,f=0|this._e,u=0;u<16;++u)t[u]=e.readInt32BE(4*u);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var d=0;d<80;++d){var l=~~(d/20),p=r(n)+o(l,i,a,c)+f+t[d]+h[l]|0;f=c,c=a,a=s(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=c+this._d|0,this._e=f+this._e|0},i.prototype._hash=function(){var e=new t(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(){this.init(),this._w=u,h.call(this,64,56)}function r(e){return e<<1|e>>>31}function s(e){return e<<5|e>>>27}function o(e){return e<<30|e>>>2}function a(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}var c=n(2),h=n(22),f=[1518500249,1859775393,-1894007588,-899497514],u=new Array(80);c(i,h),i.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},i.prototype._update=function(e){for(var t=this._w,n=0|this._a,i=0|this._b,c=0|this._c,h=0|this._d,u=0|this._e,d=0;d<16;++d)t[d]=e.readInt32BE(4*d);for(;d<80;++d)t[d]=r(t[d-3]^t[d-8]^t[d-14]^t[d-16]);for(var l=0;l<80;++l){var p=~~(l/20),b=s(n)+a(p,i,c,h)+u+t[l]+f[p]|0;u=h,h=c,c=o(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=c+this._c|0,this._d=h+this._d|0,this._e=u+this._e|0},i.prototype._hash=function(){var e=new t(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(){this.init(),this._w=a,o.call(this,64,56)}var r=n(2),s=n(103),o=n(22),a=new Array(64);r(i,s),i.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},i.prototype._hash=function(){var e=new t(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(){this.init(),this._w=a,o.call(this,128,112)}var r=n(2),s=n(104),o=n(22),a=new Array(160);r(i,s),i.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},i.prototype._hash=function(){function e(e,t,i){n.writeInt32BE(e,i),n.writeInt32BE(t,i+4)}var n=new t(48);return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),n},e.exports=i}).call(t,n(0).Buffer)},function(e,t,n){"use strict";function i(e){s.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t0;i--)t+=this._buffer(e,t),n+=this._flushBuffer(r,n);return t+=this._buffer(e,t),r},i.prototype.final=function(e){var t;e&&(t=this.update(e));var n;return n="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(n):n},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];n=c.r28shl(n,o),i=c.r28shl(i,o),c.pc2(n,i,e.keys,r)}},r.prototype._update=function(e,t,n,i){var r=this._desState,s=c.readUInt32BE(e,t),o=c.readUInt32BE(e,t+4);c.ip(s,o,r.tmp,0),s=r.tmp[0],o=r.tmp[1],"encrypt"===this.type?this._encrypt(r,s,o,r.tmp,0):this._decrypt(r,s,o,r.tmp,0),s=r.tmp[0],o=r.tmp[1],c.writeUInt32BE(n,s,i),c.writeUInt32BE(n,o,i+4)},r.prototype._pad=function(e,t){for(var n=e.length-t,i=t;i>>0,s=l}c.rip(o,s,i,r)},r.prototype._decrypt=function(e,t,n,i,r){for(var s=n,o=t,a=e.keys.length-2;a>=0;a-=2){var h=e.keys[a],f=e.keys[a+1];c.expand(s,e.tmp,0),h^=e.tmp[0],f^=e.tmp[1];var u=c.substitute(h,f),d=c.permute(u),l=s;s=(o^d)>>>0,o=l}c.rip(s,o,i,r)}},function(e,t,n){"use strict";function i(e,t){s.equal(t.length,24,"Invalid key length");var n=t.slice(0,8),i=t.slice(8,16),r=t.slice(16,24);"encrypt"===e?this.ciphers=[h.create({type:"encrypt",key:n}),h.create({type:"decrypt",key:i}),h.create({type:"encrypt",key:r})]:this.ciphers=[h.create({type:"decrypt",key:r}),h.create({type:"encrypt",key:i}),h.create({type:"decrypt",key:n})]}function r(e){c.call(this,e);var t=new i(this.type,this.options.key);this._edeState=t}var s=n(29),o=n(2),a=n(54),c=a.Cipher,h=a.DES;o(r,c),e.exports=r,r.create=function(e){return new r(e)},r.prototype._update=function(e,t,n,i){var r=this._edeState;r.ciphers[0]._update(e,t,n,i),r.ciphers[1]._update(n,i,n,i),r.ciphers[2]._update(n,i,n,i)},r.prototype._pad=h.prototype._pad,r.prototype._unpad=h.prototype._unpad},function(e,t){"use strict";t.readUInt32BE=function(e,t){var n=e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t];return n>>>0},t.writeUInt32BE=function(e,t,n){e[0+n]=t>>>24,e[1+n]=t>>>16&255,e[2+n]=t>>>8&255,e[3+n]=255&t},t.ip=function(e,t,n,i){for(var r=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)r<<=1,r|=t>>>a+o&1;for(var a=0;a<=24;a+=8)r<<=1,r|=e>>>a+o&1}for(var o=6;o>=0;o-=2){for(var a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1;for(var a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1}n[i+0]=r>>>0,n[i+1]=s>>>0},t.rip=function(e,t,n,i){for(var r=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)r<<=1,r|=t>>>a+o&1,r<<=1,r|=e>>>a+o&1;for(var o=4;o<8;o++)for(var a=24;a>=0;a-=8)s<<=1,s|=t>>>a+o&1,s<<=1,s|=e>>>a+o&1;n[i+0]=r>>>0,n[i+1]=s>>>0},t.pc1=function(e,t,n,i){for(var r=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)r<<=1,r|=t>>a+o&1;for(var a=0;a<=24;a+=8)r<<=1,r|=e>>a+o&1}for(var a=0;a<=24;a+=8)r<<=1,r|=t>>a+o&1;for(var o=1;o<=3;o++){for(var a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;for(var a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1}for(var a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;n[i+0]=r>>>0,n[i+1]=s>>>0},t.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(e,t,i,r){for(var s=0,o=0,a=n.length>>>1,c=0;c>>n[c]&1;for(var c=a;c>>n[c]&1;i[r+0]=s>>>0,i[r+1]=o>>>0},t.expand=function(e,t,n){var i=0,r=0;i=(1&e)<<5|e>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=e>>>s&63;for(var s=11;s>=3;s-=4)r|=e>>>s&63,r<<=6;r|=(31&e)<<1|e>>>31,t[n+0]=i>>>0,t[n+1]=r>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(e,t){for(var n=0,r=0;r<4;r++){var s=e>>>18-6*r&63,o=i[64*r+s];n<<=4,n|=o}for(var r=0;r<4;r++){var s=t>>>18-6*r&63,o=i[256+64*r+s];n<<=4,n|=o}return n>>>0};var r=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(e){for(var t=0,n=0;n>>r[n]&1;return t>>>0},t.padSplit=function(e,t,n){for(var i=e.toString(2);i.length0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function r(e,t){this.curve=e,this.type=t,this.precomputed=null}var s=n(7),o=n(9),a=o.utils,c=a.getNAF,h=a.getJSF,f=a.assert;e.exports=i,i.prototype.point=function(){throw new Error("Not implemented")},i.prototype.validate=function(){throw new Error("Not implemented")},i.prototype._fixedNafMul=function(e,t){f(e.precomputed);var n=e._getDoubles(),i=c(t,1),r=(1<=o;t--)a=(a<<1)+i[t];s.push(a)}for(var h=this.jpoint(null,null,null),u=this.jpoint(null,null,null),d=r;d>0;d--){for(var o=0;o=0;a--){for(var t=0;a>=0&&0===s[a];a--)t++;if(a>=0&&t++,o=o.dblp(t),a<0)break;var h=s[a];f(0!==h),o="affine"===e.type?h>0?o.mixedAdd(r[h-1>>1]):o.mixedAdd(r[-h-1>>1].neg()):h>0?o.add(r[h-1>>1]):o.add(r[-h-1>>1].neg())}return"affine"===e.type?o.toP():o},i.prototype._wnafMulAdd=function(e,t,n,i,r){for(var s=this._wnafT1,o=this._wnafT2,a=this._wnafT3,f=0,u=0;u=1;u-=2){var p=u-1,b=u;if(1===s[p]&&1===s[b]){var m=[t[p],null,null,t[b]];0===t[p].y.cmp(t[b].y)?(m[1]=t[p].add(t[b]),m[2]=t[p].toJ().mixedAdd(t[b].neg())):0===t[p].y.cmp(t[b].y.redNeg())?(m[1]=t[p].toJ().mixedAdd(t[b]),m[2]=t[p].add(t[b].neg())):(m[1]=t[p].toJ().mixedAdd(t[b]),m[2]=t[p].toJ().mixedAdd(t[b].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=h(n[p],n[b]);f=Math.max(v[0].length,f),a[p]=new Array(f),a[b]=new Array(f);for(var y=0;y=0;u--){for(var k=0;u>=0;){for(var A=!0,y=0;y=0&&k++,E=E.dblp(k),u<0)break;for(var y=0;y0?d=o[y][M-1>>1]:M<0&&(d=o[y][-M-1>>1].neg()),E="affine"===d.type?E.mixedAdd(d):E.add(d))}}for(var u=0;u=Math.ceil((e.bitLength()+1)/t.step)},r.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,r=0;r":""},r.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},r.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(e),r=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),s=i.redAdd(t),o=s.redSub(n),a=i.redSub(t),c=r.redMul(o),h=s.redMul(a),f=r.redMul(a),u=o.redMul(s);return this.curve.point(c,h,u,f)},r.prototype._projDbl=function(){var e,t,n,i=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=this.curve._mulA(r),a=o.redAdd(s);if(this.zOne)e=i.redSub(r).redSub(s).redMul(a.redSub(this.curve.two)),t=a.redMul(o.redSub(s)),n=a.redSqr().redSub(a).redSub(a);else{var c=this.z.redSqr(),h=a.redSub(c).redISub(c);e=i.redSub(r).redISub(s).redMul(h),t=a.redMul(o.redSub(s)),n=a.redMul(h)}}else{var o=r.redAdd(s),c=this.curve._mulC(this.c.redMul(this.z)).redSqr(),h=o.redSub(c).redSub(c);e=this.curve._mulC(i.redISub(o)).redMul(h),t=this.curve._mulC(o).redMul(r.redISub(s)),n=o.redMul(h)}return this.curve.point(e,t,n)},r.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},r.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),r=this.z.redMul(e.z.redAdd(e.z)),s=n.redSub(t),o=r.redSub(i),a=r.redAdd(i),c=n.redAdd(t),h=s.redMul(o),f=a.redMul(c),u=s.redMul(c),d=o.redMul(a);return this.curve.point(h,f,d,u)},r.prototype._projAdd=function(e){var t,n,i=this.z.redMul(e.z),r=i.redSqr(),s=this.x.redMul(e.x),o=this.y.redMul(e.y),a=this.curve.d.redMul(s).redMul(o),c=r.redSub(a),h=r.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(s).redISub(o),u=i.redMul(c).redMul(f);return this.curve.twisted?(t=i.redMul(h).redMul(o.redSub(this.curve._mulA(s))),n=c.redMul(h)):(t=i.redMul(h).redMul(o.redSub(s)),n=this.curve._mulC(c).redMul(h)),this.curve.point(u,t,n)},r.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},r.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},r.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},r.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},r.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},r.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},r.prototype.getX=function(){return this.normalize(),this.x.fromRed()},r.prototype.getY=function(){return this.normalize(),this.y.fromRed()},r.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},r.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}return!1},r.prototype.toP=r.prototype.normalize,r.prototype.mixedAdd=r.prototype.add},function(e,t,n){"use strict";function i(e){c.call(this,"mont",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.i4=new o(4).toRed(this.red).redInvm(),this.two=new o(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function r(e,t,n){c.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new o(t,16),this.z=new o(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}var s=n(40),o=n(7),a=n(2),c=s.base,h=n(9),f=h.utils;a(i,c),e.exports=i,i.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),i=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t),r=i.redSqrt();return 0===r.redSqr().cmp(i)},a(r,c.BasePoint),i.prototype.decodePoint=function(e,t){return this.point(f.toArray(e,t),1)},i.prototype.point=function(e,t){return new r(this,e,t)},i.prototype.pointFromJSON=function(e){return r.fromJSON(this,e)},r.prototype.precompute=function(){},r.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},r.fromJSON=function(e,t){return new r(e,t[0],t[1]||e.one)},r.prototype.inspect=function(){return this.isInfinity()?"":""},r.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},r.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),n=this.x.redSub(this.z),i=n.redSqr(),r=t.redSub(i),s=t.redMul(i),o=r.redMul(i.redAdd(this.curve.a24.redMul(r)));return this.curve.point(s,o)},r.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},r.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),i=this.x.redSub(this.z),r=e.x.redAdd(e.z),s=e.x.redSub(e.z),o=s.redMul(n),a=r.redMul(i),c=t.z.redMul(o.redAdd(a).redSqr()),h=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(c,h)},r.prototype.mul=function(e){for(var t=e.clone(),n=this,i=this.curve.point(null,null),r=this,s=[];0!==t.cmpn(0);t.iushrn(1))s.push(t.andln(1));for(var o=s.length-1;o>=0;o--)0===s[o]?(n=n.diffAdd(i,r),i=i.dbl()):(i=n.diffAdd(i,r),n=n.dbl());return i},r.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},r.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},r.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},r.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},r.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,n){"use strict";function i(e){f.call(this,"short",e),this.a=new c(e.a,16).toRed(this.red),this.b=new c(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function r(e,t,n,i){f.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new c(t,16),this.y=new c(n,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function s(e,t,n,i){f.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new c(0)):(this.x=new c(t,16),this.y=new c(n,16),this.z=new c(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}var o=n(40),a=n(9),c=n(7),h=n(2),f=o.base,u=a.utils.assert;h(i,f),e.exports=i,i.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new c(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=i[0].cmp(i[1])<0?i[0]:i[1],t=t.toRed(this.red)}if(e.lambda)n=new c(e.lambda,16);else{var r=this._getEndoRoots(this.n);0===this.g.mul(r[0]).x.cmp(this.g.x.redMul(t))?n=r[0]:(n=r[1],u(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}var s;return s=e.basis?e.basis.map(function(e){return{a:new c(e.a,16),b:new c(e.b,16)}}):this._getEndoBasis(n),{beta:t,lambda:n,basis:s}}},i.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:c.mont(e),n=new c(2).toRed(t).redInvm(),i=n.redNeg(),r=new c(3).toRed(t).redNeg().redSqrt().redMul(n),s=i.redAdd(r).fromRed(),o=i.redSub(r).fromRed();return[s,o]},i.prototype._getEndoBasis=function(e){for(var t,n,i,r,s,o,a,h,f,u=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=e,l=this.n.clone(),p=new c(1),b=new c(0),m=new c(0),g=new c(1),v=0;0!==d.cmpn(0);){var y=l.div(d);h=l.sub(y.mul(d)),f=m.sub(y.mul(p));var _=g.sub(y.mul(b));if(!i&&h.cmp(u)<0)t=a.neg(),n=p,i=h.neg(),r=f;else if(i&&2===++v)break;a=h,l=d,d=h,m=p,p=f,g=b,b=_}s=h.neg(),o=f;var w=i.sqr().add(r.sqr()),E=s.sqr().add(o.sqr());return E.cmp(w)>=0&&(s=t,o=n),i.negative&&(i=i.neg(),r=r.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:r},{a:s,b:o}]},i.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],i=t[1],r=i.b.mul(e).divRound(this.n),s=n.b.neg().mul(e).divRound(this.n),o=r.mul(n.a),a=s.mul(i.a),c=r.mul(n.b),h=s.mul(i.b),f=e.sub(o).sub(a),u=c.add(h).neg();return{k1:f,k2:u}},i.prototype.pointFromX=function(e,t){e=new c(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(0!==i.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var r=i.fromRed().isOdd(); -return(t&&!r||!t&&r)&&(i=i.redNeg()),this.point(e,i)},i.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,i=this.a.redMul(t),r=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===n.redSqr().redISub(r).cmpn(0)},i.prototype._endoWnafMulAdd=function(e,t,n){for(var i=this._endoWnafT1,r=this._endoWnafT2,s=0;s":""},r.prototype.isInfinity=function(){return this.inf},r.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},r.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),r=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(i),s=r.redSqr().redISub(this.x.redAdd(this.x)),o=r.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},r.prototype.getX=function(){return this.x.fromRed()},r.prototype.getY=function(){return this.y.fromRed()},r.prototype.mul=function(e){return e=new c(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},r.prototype.mulAdd=function(e,t,n){var i=[this,t],r=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,r):this.curve._wnafMulAdd(1,i,r,2)},r.prototype.jmulAdd=function(e,t,n){var i=[this,t],r=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,r,!0):this.curve._wnafMulAdd(1,i,r,2,!0)},r.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},r.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return t},r.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},h(s,f.BasePoint),i.prototype.jpoint=function(e,t,n){return new s(this,e,t,n)},s.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(n,i)},s.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},s.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(t),r=e.x.redMul(n),s=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(n.redMul(this.z)),a=i.redSub(r),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),f=h.redMul(a),u=i.redMul(h),d=c.redSqr().redIAdd(f).redISub(u).redISub(u),l=c.redMul(u.redISub(d)).redISub(s.redMul(f)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(d,l,p)},s.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,i=e.x.redMul(t),r=this.y,s=e.y.redMul(t).redMul(this.z),o=n.redSub(i),a=r.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),h=c.redMul(o),f=n.redMul(c),u=a.redSqr().redIAdd(h).redISub(f).redISub(f),d=a.redMul(f.redISub(u)).redISub(r.redMul(h)),l=this.z.redMul(o);return this.curve.jpoint(u,d,l)},s.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,n=0;n=0)return!1;if(n.redIAdd(r),0===this.x.cmp(n))return!0}return!1},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,n){"use strict";function i(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,c(this.g.validate(),"Invalid curve"),c(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function r(e,t){Object.defineProperty(s,e,{configurable:!0,enumerable:!0,get:function(){var n=new i(t);return Object.defineProperty(s,e,{configurable:!0,enumerable:!0,value:n}),n}})}var s=t,o=n(16),a=n(9),c=a.utils.assert;s.PresetCurve=i,r("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),r("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),r("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),r("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),r("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),r("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),r("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var h;try{h=n(191)}catch(e){h=void 0}r("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",h]})},function(e,t,n){"use strict";function i(e){return this instanceof i?("string"==typeof e&&(a(s.curves.hasOwnProperty(e),"Unknown curve "+e),e=s.curves[e]),e instanceof s.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),void(this.hash=e.hash||e.curve.hash)):new i(e)}var r=n(7),s=n(9),o=s.utils,a=o.assert,c=n(185),h=n(186);e.exports=i,i.prototype.keyPair=function(e){return new c(this,e)},i.prototype.keyFromPrivate=function(e,t){return c.fromPrivate(this,e,t)},i.prototype.keyFromPublic=function(e,t){return c.fromPublic(this,e,t)},i.prototype.genKeyPair=function(e){e||(e={});for(var t=new s.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||s.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new r(2));;){var o=new r(t.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}},i.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},i.prototype.sign=function(e,t,n,i){"object"==typeof n&&(i=n,n=null),i||(i={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new r(e,16));for(var o=this.n.byteLength(),a=t.getPrivate().toArray("be",o),c=e.toArray("be",o),f=new s.hmacDRBG({hash:this.hash,entropy:a,nonce:c,pers:i.pers,persEnc:i.persEnc}),u=this.n.sub(new r(1)),d=0;!0;d++){var l=i.k?i.k(d):new r(f.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),!(l.cmpn(1)<=0||l.cmp(u)>=0)){var p=this.g.mul(l);if(!p.isInfinity()){var b=p.getX(),m=b.umod(this.n);if(0!==m.cmpn(0)){var g=l.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e));if(g=g.umod(this.n),0!==g.cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(m)?2:0);return i.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),v^=1),new h({r:m,s:g,recoveryParam:v})}}}}}},i.prototype.verify=function(e,t,n,i){e=this._truncateToN(new r(e,16)),n=this.keyFromPublic(n,i),t=new h(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),c=a.mul(e).umod(this.n),f=a.mul(s).umod(this.n);if(!this.curve._maxwellTrick){var u=this.g.mulAdd(c,n.getPublic(),f);return!u.isInfinity()&&0===u.getX().umod(this.n).cmp(s)}var u=this.g.jmulAdd(c,n.getPublic(),f);return!u.isInfinity()&&u.eqXToP(s)},i.prototype.recoverPubKey=function(e,t,n,i){a((3&n)===n,"The recovery param is more than two bits"),t=new h(t,i);var s=this.n,o=new r(e),c=t.r,f=t.s,u=1&n,d=n>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");c=d?this.curve.pointFromX(c.add(this.curve.n),u):this.curve.pointFromX(c,u);var l=t.r.invm(s),p=s.sub(o).mul(l).umod(s),b=f.mul(l).umod(s);return this.g.mulAdd(p,c,b)},i.prototype.getKeyRecoveryParam=function(e,t,n,i){if(t=new h(t,i),null!==t.recoveryParam)return t.recoveryParam;for(var r=0;r<4;r++){var s;try{s=this.recoverPubKey(e,t,r)}catch(e){continue}if(s.eq(n))return r}throw new Error("Unable to find valid recovery factor")}},function(e,t,n){"use strict";function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var r=n(7);e.exports=i,i.fromPublic=function(e,t,n){return t instanceof i?t:new i(e,{pub:t,pubEnc:n})},i.fromPrivate=function(e,t,n){return t instanceof i?t:new i(e,{priv:t,privEnc:n})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new r(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){return e.x||e.y?void(this.pub=this.ec.curve.point(e.x,e.y)):void(this.pub=this.ec.curve.decodePoint(e,t))},i.prototype.derive=function(e){return e.mul(this.priv).getX()},i.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return""}},function(e,t,n){"use strict";function i(e,t){return e instanceof i?e:void(this._importDER(e,t)||(u(e.r&&e.s,"Signature without r or s"),this.r=new c(e.r,16),this.s=new c(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam))}function r(){this.place=0}function s(e,t){var n=e[t.place++];if(!(128&n))return n;for(var i=15&n,r=0,s=0,o=t.place;s>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}var c=n(7),h=n(9),f=h.utils,u=f.assert;e.exports=i,i.prototype._importDER=function(e,t){e=f.toArray(e,t);var n=new r;if(48!==e[n.place++])return!1;var i=s(e,n);if(i+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var o=s(e,n),a=e.slice(n.place,o+n.place);if(n.place+=o,2!==e[n.place++])return!1;var h=s(e,n);if(e.length!==h+n.place)return!1;var u=e.slice(n.place,h+n.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===u[0]&&128&u[1]&&(u=u.slice(1)),this.r=new c(a),this.s=new c(u),this.recoveryParam=null,!0},i.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=o(t),n=o(n);!(n[0]||128&n[1]);)n=n.slice(1);var i=[2];a(i,t.length),i=i.concat(t),i.push(2),a(i,n.length);var r=i.concat(n),s=[48];return a(s,r.length),s=s.concat(r),f.encode(s,e)}},function(e,t,n){"use strict";function i(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof i))return new i(e);var e=s.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}var r=n(16),s=n(9),o=s.utils,a=o.assert,c=o.parseBytes,h=n(188),f=n(189);e.exports=i,i.prototype.sign=function(e,t){e=c(e);var n=this.keyFromSecret(t),i=this.hashInt(n.messagePrefix(),e),r=this.g.mul(i),s=this.encodePoint(r),o=this.hashInt(s,n.pubBytes(),e).mul(n.priv()),a=i.add(o).umod(this.curve.n);return this.makeSignature({R:r,S:a,Rencoded:s})},i.prototype.verify=function(e,t,n){e=c(e),t=this.makeSignature(t);var i=this.keyFromPublic(n),r=this.hashInt(t.Rencoded(),i.pubBytes(),e),s=this.g.mul(t.S()),o=t.R().add(i.pub().mul(r));return o.eq(s)},i.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}var r=n(16),s=n(9),o=s.utils,a=o.assert;e.exports=i,i.prototype._init=function(e,t,n){var i=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var r=0;r=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this.reseed=1},i.prototype.generate=function(e,t,n,i){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=n,n=t,t=null),n&&(n=o.toArray(n,i),this._update(n));for(var r=[];r.length>8,o=255&r;s?n.push(s,o):n.push(o)}return n}function r(e){return 1===e.length?"0"+e:e}function s(e){for(var t="",n=0;n=0;){var s;if(r.isOdd()){var o=r.andln(i-1);s=o>(i>>1)-1?(i>>1)-o:o,r.isubn(s)}else s=0;n.push(s);for(var a=0!==r.cmpn(0)&&0===r.andln(i-1)?t+1:1,c=1;c0||t.cmpn(-r)>0;){var s=e.andln(3)+i&3,o=t.andln(3)+r&3;3===s&&(s=-1),3===o&&(o=-1);var a;if(0===(1&s))a=0;else{var c=e.andln(7)+i&7;a=3!==c&&5!==c||2!==o?s:-s}n[0].push(a);var h;if(0===(1&o))h=0;else{var c=t.andln(7)+r&7;h=3!==c&&5!==c||2!==s?o:-o}n[1].push(h),2*i===a+1&&(i=1-i),2*r===h+1&&(r=1-r),e.iushrn(1),t.iushrn(1)}return n}function c(e,t,n){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=n.call(this)}}function h(e){return"string"==typeof e?u.toArray(e,"hex"):e}function f(e){return new d(e,"hex","le")}var u=t,d=n(7);u.assert=function(e,t){if(!e)throw new Error(t||"Assertion failed")},u.toArray=i,u.zero2=r,u.toHex=s,u.encode=function(e,t){return"hex"===t?s(e):e},u.getNAF=o,u.getJSF=a,u.cachedProperty=c,u.parseBytes=h,u.intFromLE=f},function(e,t,n){function i(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var r=n(16),s=r.utils,o=s.assert;t.BlockHash=i,i.prototype.update=function(e,t){if(e=s.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=s.join32(e,0,e.length-n,this.endian);for(var i=0;i>>24&255,i[r++]=e>>>16&255,i[r++]=e>>>8&255,i[r++]=255&e}else{i[r++]=255&e,i[r++]=e>>>8&255,i[r++]=e>>>16&255,i[r++]=e>>>24&255,i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=0;for(var s=8;sthis.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t>>3}function p(e){return C(e,17)^C(e,19)^e>>>10}function b(e,t,n,i){return 0===e?c(t,n,i):1===e||3===e?f(t,n,i):2===e?h(t,n,i):void 0}function m(e,t,n,i,r,s){var o=e&n^~e&r;return o<0&&(o+=4294967296),o}function g(e,t,n,i,r,s){var o=t&i^~t&s;return o<0&&(o+=4294967296),o}function v(e,t,n,i,r,s){var o=e&n^e&r^n&r;return o<0&&(o+=4294967296),o}function y(e,t,n,i,r,s){var o=t&i^t&s^i&s;return o<0&&(o+=4294967296),o}function _(e,t){var n=O(e,t,28),i=O(t,e,2),r=O(t,e,7),s=n^i^r;return s<0&&(s+=4294967296),s}function w(e,t){var n=U(e,t,28),i=U(t,e,2),r=U(t,e,7),s=n^i^r;return s<0&&(s+=4294967296),s}function E(e,t){var n=O(e,t,14),i=O(e,t,18),r=O(t,e,9),s=n^i^r;return s<0&&(s+=4294967296),s}function S(e,t){var n=U(e,t,14),i=U(e,t,18),r=U(t,e,9),s=n^i^r;return s<0&&(s+=4294967296),s}function k(e,t){var n=O(e,t,1),i=O(e,t,8),r=N(e,t,7),s=n^i^r;return s<0&&(s+=4294967296),s}function A(e,t){var n=U(e,t,1),i=U(e,t,8),r=j(e,t,7),s=n^i^r;return s<0&&(s+=4294967296),s}function M(e,t){var n=O(e,t,19),i=O(t,e,29),r=N(e,t,6),s=n^i^r;return s<0&&(s+=4294967296),s}function x(e,t){var n=U(e,t,19),i=U(t,e,29),r=j(e,t,6),s=n^i^r;return s<0&&(s+=4294967296),s}var R=n(16),I=R.utils,T=I.assert,C=I.rotr32,D=I.rotl32,P=I.sum32,B=I.sum32_4,L=I.sum32_5,O=I.rotr64_hi,U=I.rotr64_lo,N=I.shr64_hi,j=I.shr64_lo,q=I.sum64,z=I.sum64_hi,F=I.sum64_lo,G=I.sum64_4_hi,H=I.sum64_4_lo,W=I.sum64_5_hi,V=I.sum64_5_lo,K=R.common.BlockHash,Z=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],X=[1518500249,1859775393,2400959708,3395469782];I.inherits(i,K),t.sha256=i,i.blockSize=512,i.outSize=256,i.hmacStrength=192,i.padLength=64,i.prototype._update=function(e,t){for(var n=this.W,i=0;i<16;i++)n[i]=e[t+i];for(;i>8,o=255&r;s?n.push(s,o):n.push(o)}else for(var i=0;i>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24;return t>>>0}function o(e,t){for(var n="",i=0;i>>0}return s}function f(e,t){for(var n=new Array(4*e.length),i=0,r=0;i>>24,n[r+1]=s>>>16&255,n[r+2]=s>>>8&255,n[r+3]=255&s):(n[r+3]=s>>>24,n[r+2]=s>>>16&255,n[r+1]=s>>>8&255,n[r]=255&s)}return n}function u(e,t){return e>>>t|e<<32-t}function d(e,t){return e<>>32-t}function l(e,t){return e+t>>>0}function p(e,t,n){return e+t+n>>>0}function b(e,t,n,i){return e+t+n+i>>>0}function m(e,t,n,i,r){return e+t+n+i+r>>>0}function g(e,t){if(!e)throw new Error(t||"Assertion failed")}function v(e,t,n,i){var r=e[t],s=e[t+1],o=i+s>>>0,a=(o>>0,e[t+1]=o}function y(e,t,n,i){var r=t+i>>>0,s=(r>>0}function _(e,t,n,i){var r=t+i;return r>>>0}function w(e,t,n,i,r,s,o,a){var c=0,h=t;h=h+i>>>0,c+=h>>0,c+=h>>0,c+=h>>0}function E(e,t,n,i,r,s,o,a){var c=t+i+s+a;return c>>>0}function S(e,t,n,i,r,s,o,a,c,h){var f=0,u=t;u=u+i>>>0,f+=u>>0,f+=u>>0,f+=u>>0,f+=u>>0}function k(e,t,n,i,r,s,o,a,c,h){var f=t+i+s+a+h;return f>>>0}function A(e,t,n){var i=t<<32-n|e>>>n;return i>>>0}function M(e,t,n){var i=e<<32-n|t>>>n;return i>>>0}function x(e,t,n){return e>>>n}function R(e,t,n){var i=e<<32-n|t>>>n;return i>>>0}var I=t,T=n(2);I.toArray=i,I.toHex=r,I.htonl=s,I.toHex32=o,I.zero2=a,I.zero8=c,I.join32=h,I.split32=f,I.rotr32=u,I.rotl32=d,I.sum32=l,I.sum32_3=p,I.sum32_4=b,I.sum32_5=m,I.assert=g,I.inherits=T,t.sum64=v,t.sum64_hi=y,t.sum64_lo=_,t.sum64_4_hi=w,t.sum64_4_lo=E,t.sum64_5_hi=S,t.sum64_5_lo=k,t.rotr64_hi=A,t.rotr64_lo=M,t.shr64_hi=x,t.shr64_lo=R},function(e,t,n){var i=n(11),r=n(199),s=n(140),o=n(2),a=e.exports=function(e,t){var n=this;n.writable=!0,n.xhr=e,n.body=[],n.uri=(t.protocol||"http:")+"//"+t.host+(t.port?":"+t.port:"")+(t.path||"/"),"undefined"==typeof t.withCredentials&&(t.withCredentials=!0);try{e.withCredentials=t.withCredentials}catch(e){}if(t.responseType)try{e.responseType=t.responseType}catch(e){}if(e.open(t.method||"GET",n.uri,!0),e.onerror=function(e){n.emit("error",new Error("Network error"))},n._headers={},t.headers)for(var i=c(t.headers),o=0;othis.offset&&(this.emit("data",t.slice(this.offset)),this.offset=t.length))};var c=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t){t.read=function(e,t,n,i,r){var s,o,a=8*r-i-1,c=(1<>1,f=-7,u=n?r-1:0,d=n?-1:1,l=e[t+u];for(u+=d,s=l&(1<<-f)-1,l>>=-f,f+=a;f>0;s=256*s+e[t+u],u+=d,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=i;f>0;o=256*o+e[t+u],u+=d,f-=8);if(0===s)s=1-h;else{if(s===c)return o?NaN:(l?-1:1)*(1/0);o+=Math.pow(2,i),s-=h}return(l?-1:1)*o*Math.pow(2,s-i)},t.write=function(e,t,n,i,r,s){var o,a,c,h=8*s-r-1,f=(1<>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,l=i?0:s-1,p=i?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),t+=o+u>=1?d/c:d*Math.pow(2,1-u),t*c>=2&&(o++,c/=2),o+u>=f?(a=0,o=f):o+u>=1?(a=(t*c-1)*Math.pow(2,r),o+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;e[n+l]=255&a,l+=p,a/=256,r-=8);for(o=o<0;e[n+l]=255&o,l+=p,o/=256,h-=8);e[n+l-p]|=128*b}},function(e,t){var n=[].indexOf;e.exports=function(e,t){if(n)return e.indexOf(t);for(var i=0;i=6.0.0 <7.0.0",type:"range"},"/home/travis/build/hydrabolt/discord.js/node_modules/browserify-sign"]],_from:"elliptic@>=6.0.0 <7.0.0",_id:"elliptic@6.3.2",_inCache:!0,_location:"/elliptic",_nodeVersion:"6.3.0",_npmOperationalInternal:{host:"packages-16-east.internal.npmjs.com",tmp:"tmp/elliptic-6.3.2.tgz_1473938837205_0.3108903462998569"},_npmUser:{name:"indutny",email:"fedor@indutny.com"},_npmVersion:"3.10.3",_phantomChildren:{},_requested:{raw:"elliptic@^6.0.0",scope:null,escapedName:"elliptic",name:"elliptic",rawSpec:"^6.0.0",spec:">=6.0.0 <7.0.0",type:"range"},_requiredBy:["/browserify-sign","/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz",_shasum:"e4c81e0829cf0a65ab70e998b8232723b5c1bc48",_shrinkwrap:null,_spec:"elliptic@^6.0.0",_where:"/home/travis/build/hydrabolt/discord.js/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},directories:{},dist:{shasum:"e4c81e0829cf0a65ab70e998b8232723b5c1bc48",tarball:"https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz"},files:["lib"],gitHead:"cbace4683a4a548dc0306ef36756151a20299cd5",homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",maintainers:[{name:"indutny",email:"fedor@indutny.com"}],name:"elliptic",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.3.2"}},function(e,t){e.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},function(e,t){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(e,t,n){"use strict";function i(e,t){return e.msg=B[t],t}function r(e){return(e<<1)-(e>4?9:0)}function s(e){for(var t=e.length;--t>=0;)e[t]=0}function o(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(T.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function a(e,t){C._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function c(e,t){e.pending_buf[e.pending++]=t}function h(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function f(e,t,n,i){var r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,T.arraySet(t,e.input,e.next_in,r,n),1===e.state.wrap?e.adler=D(e.adler,t,r,n):2===e.state.wrap&&(e.adler=P(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)}function u(e,t){var n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-ue?e.strstart-(e.w_size-ue):0,h=e.window,f=e.w_mask,u=e.prev,d=e.strstart+fe,l=h[s+o-1],p=h[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do if(n=t,h[n+o]===p&&h[n+o-1]===l&&h[n]===h[s]&&h[++n]===h[s+1]){s+=2,n++;do;while(h[++s]===h[++n]&&h[++s]===h[++n]&&h[++s]===h[++n]&&h[++s]===h[++n]&&h[++s]===h[++n]&&h[++s]===h[++n]&&h[++s]===h[++n]&&h[++s]===h[++n]&&so){if(e.match_start=t,o=i,i>=a)break;l=h[s+o-1],p=h[s+o]}}while((t=u[t&f])>c&&0!==--r);return o<=e.lookahead?o:e.lookahead}function d(e){var t,n,i,r,s,o=e.w_size;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=o+(o-ue)){T.arraySet(e.window,e.window,o,o,0),e.match_start-=o,e.strstart-=o,e.block_start-=o,n=e.hash_size,t=n;do i=e.head[--t],e.head[t]=i>=o?i-o:0;while(--n);n=o,t=n;do i=e.prev[--t],e.prev[t]=i>=o?i-o:0;while(--n);r+=o}if(0===e.strm.avail_in)break;if(n=f(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=he)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(d(e),0===e.lookahead&&t===L)return _e;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,a(e,!1),0===e.strm.avail_out))return _e;if(e.strstart-e.block_start>=e.w_size-ue&&(a(e,!1),0===e.strm.avail_out))return _e}return e.insert=0,t===N?(a(e,!0),0===e.strm.avail_out?Ee:Se):e.strstart>e.block_start&&(a(e,!1),0===e.strm.avail_out)?_e:_e}function p(e,t){for(var n,i;;){if(e.lookahead=he&&(e.ins_h=(e.ins_h<=he)if(i=C._tr_tally(e,e.strstart-e.match_start,e.match_length-he),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=he){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=he&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=he-1)),e.prev_length>=he&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-he,i=C._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-he),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<=he&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+fe;do;while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=he?(n=C._tr_tally(e,1,e.match_length-he),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=C._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(a(e,!1),0===e.strm.avail_out))return _e}return e.insert=0,t===N?(a(e,!0),0===e.strm.avail_out?Ee:Se):e.last_lit&&(a(e,!1),0===e.strm.avail_out)?_e:we}function g(e,t){for(var n;;){if(0===e.lookahead&&(d(e),0===e.lookahead)){if(t===L)return _e;break}if(e.match_length=0,n=C._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(a(e,!1),0===e.strm.avail_out))return _e}return e.insert=0,t===N?(a(e,!0),0===e.strm.avail_out?Ee:Se):e.last_lit&&(a(e,!1),0===e.strm.avail_out)?_e:we}function v(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}function y(e){e.window_size=2*e.w_size,s(e.head),e.max_lazy_match=I[e.level].max_lazy,e.good_match=I[e.level].good_length,e.nice_match=I[e.level].nice_length,e.max_chain_length=I[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=he-1,e.match_available=0,e.ins_h=0}function _(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new T.Buf16(2*ae),this.dyn_dtree=new T.Buf16(2*(2*se+1)),this.bl_tree=new T.Buf16(2*(2*oe+1)),s(this.dyn_ltree),s(this.dyn_dtree),s(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new T.Buf16(ce+1),this.heap=new T.Buf16(2*re+1),s(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new T.Buf16(2*re+1),s(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function w(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=J,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?le:ve,e.adler=2===t.wrap?0:1,t.last_flush=L,C._tr_init(t),q):i(e,F)}function E(e){var t=w(e);return t===q&&y(e.state),t}function S(e,t){return e&&e.state?2!==e.state.wrap?F:(e.state.gzhead=t,q):F}function k(e,t,n,r,s,o){if(!e)return F;var a=1;if(t===W&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),s<1||s>Q||n!==$||r<8||r>15||t<0||t>9||o<0||o>Y)return i(e,F);8===r&&(r=9);var c=new _;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=r,c.w_size=1<j||t<0)return e?i(e,F):F;if(a=e.state,!e.output||!e.input&&0!==e.avail_in||a.status===ye&&t!==N)return i(e,0===e.avail_out?H:F);if(a.strm=e,n=a.last_flush,a.last_flush=t,a.status===le)if(2===a.wrap)e.adler=0,c(a,31),c(a,139),c(a,8),a.gzhead?(c(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),c(a,255&a.gzhead.time),c(a,a.gzhead.time>>8&255),c(a,a.gzhead.time>>16&255),c(a,a.gzhead.time>>24&255),c(a,9===a.level?2:a.strategy>=K||a.level<2?4:0),c(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(c(a,255&a.gzhead.extra.length),c(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=P(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=pe):(c(a,0),c(a,0),c(a,0),c(a,0),c(a,0),c(a,9===a.level?2:a.strategy>=K||a.level<2?4:0),c(a,ke),a.status=ve);else{var d=$+(a.w_bits-8<<4)<<8,l=-1;l=a.strategy>=K||a.level<2?0:a.level<6?1:6===a.level?2:3,d|=l<<6,0!==a.strstart&&(d|=de),d+=31-d%31,a.status=ve,h(a,d),0!==a.strstart&&(h(a,e.adler>>>16),h(a,65535&e.adler)),e.adler=1}if(a.status===pe)if(a.gzhead.extra){for(f=a.pending;a.gzindex<(65535&a.gzhead.extra.length)&&(a.pending!==a.pending_buf_size||(a.gzhead.hcrc&&a.pending>f&&(e.adler=P(e.adler,a.pending_buf,a.pending-f,f)),o(e),f=a.pending,a.pending!==a.pending_buf_size));)c(a,255&a.gzhead.extra[a.gzindex]),a.gzindex++;a.gzhead.hcrc&&a.pending>f&&(e.adler=P(e.adler,a.pending_buf,a.pending-f,f)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=be)}else a.status=be;if(a.status===be)if(a.gzhead.name){f=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>f&&(e.adler=P(e.adler,a.pending_buf,a.pending-f,f)),o(e),f=a.pending,a.pending===a.pending_buf_size)){u=1;break}u=a.gzindexf&&(e.adler=P(e.adler,a.pending_buf,a.pending-f,f)),0===u&&(a.gzindex=0,a.status=me)}else a.status=me;if(a.status===me)if(a.gzhead.comment){f=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>f&&(e.adler=P(e.adler,a.pending_buf,a.pending-f,f)),o(e),f=a.pending,a.pending===a.pending_buf_size)){u=1;break}u=a.gzindexf&&(e.adler=P(e.adler,a.pending_buf,a.pending-f,f)),0===u&&(a.status=ge)}else a.status=ge;if(a.status===ge&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&o(e),a.pending+2<=a.pending_buf_size&&(c(a,255&e.adler),c(a,e.adler>>8&255),e.adler=0,a.status=ve)):a.status=ve),0!==a.pending){if(o(e),0===e.avail_out)return a.last_flush=-1,q}else if(0===e.avail_in&&r(t)<=r(n)&&t!==N)return i(e,H);if(a.status===ye&&0!==e.avail_in)return i(e,H);if(0!==e.avail_in||0!==a.lookahead||t!==L&&a.status!==ye){var p=a.strategy===K?g(a,t):a.strategy===Z?m(a,t):I[a.level].func(a,t);if(p!==Ee&&p!==Se||(a.status=ye),p===_e||p===Ee)return 0===e.avail_out&&(a.last_flush=-1),q;if(p===we&&(t===O?C._tr_align(a):t!==j&&(C._tr_stored_block(a,0,0,!1),t===U&&(s(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),o(e),0===e.avail_out))return a.last_flush=-1,q}return t!==N?q:a.wrap<=0?z:(2===a.wrap?(c(a,255&e.adler),c(a,e.adler>>8&255),c(a,e.adler>>16&255),c(a,e.adler>>24&255),c(a,255&e.total_in),c(a,e.total_in>>8&255),c(a,e.total_in>>16&255),c(a,e.total_in>>24&255)):(h(a,e.adler>>>16),h(a,65535&e.adler)),o(e),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?q:z)}function x(e){var t;return e&&e.state?(t=e.state.status,t!==le&&t!==pe&&t!==be&&t!==me&&t!==ge&&t!==ve&&t!==ye?i(e,F):(e.state=null,t===ve?i(e,G):q)):F}function R(e,t){var n,i,r,o,a,c,h,f,u=t.length;if(!e||!e.state)return F;if(n=e.state,o=n.wrap,2===o||1===o&&n.status!==le||n.lookahead)return F;for(1===o&&(e.adler=D(e.adler,t,u,0)),n.wrap=0,u>=n.w_size&&(0===o&&(s(n.head),n.strstart=0,n.block_start=0,n.insert=0),f=new T.Buf8(n.w_size),T.arraySet(f,t,u-n.w_size,n.w_size,0),t=f,u=n.w_size),a=e.avail_in,c=e.next_in,h=e.input,e.avail_in=u,e.next_in=0,e.input=t,d(n);n.lookahead>=he;){i=n.strstart,r=n.lookahead-(he-1);do n.ins_h=(n.ins_h<>>24,b>>>=E,m-=E,E=w>>>16&255,0===E)R[a++]=65535&w;else{if(!(16&E)){if(0===(64&E)){w=g[(65535&w)+(b&(1<>>=E,m-=E),m<15&&(b+=x[s++]<>>24,b>>>=E,m-=E,E=w>>>16&255,!(16&E)){if(0===(64&E)){w=v[(65535&w)+(b&(1<f){e.msg="invalid distance too far back",r.mode=n;break e}if(b>>>=E,m-=E,E=a-c,k>E){if(E=k-E,E>d&&r.sane){e.msg="invalid distance too far back",r.mode=n;break e}if(A=0,M=p,0===l){if(A+=u-E,E2;)R[a++]=M[A++],R[a++]=M[A++],R[a++]=M[A++],S-=3;S&&(R[a++]=M[A++],S>1&&(R[a++]=M[A++]))}else{A=a-k;do R[a++]=R[A++],R[a++]=R[A++],R[a++]=R[A++],S-=3;while(S>2);S&&(R[a++]=R[A++],S>1&&(R[a++]=R[A++]))}break}}break}}while(s>3,s-=S,m-=S<<3,b&=(1<>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function r(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new v.Buf16(320),this.work=new v.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function s(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=U,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new v.Buf32(be),t.distcode=t.distdyn=new v.Buf32(me),t.sane=1,t.back=-1,I):D}function o(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,s(e)):D}function a(e,t){var n,i;return e&&e.state?(i=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?D:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,o(e))):D}function c(e,t){var n,i;return e?(i=new r,e.state=i,i.window=null,n=a(e,t),n!==I&&(e.state=null),n):D}function h(e){return c(e,ve)}function f(e){if(ye){var t;for(m=new v.Buf32(512),g=new v.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(E(k,e.lens,0,288,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;E(A,e.lens,0,32,g,0,e.work,{bits:5}),ye=!1}e.lencode=m,e.lenbits=9,e.distcode=g,e.distbits=5}function u(e,t,n,i){var r,s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(v.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),v.arraySet(s.window,t,n-i,r,s.wnext),i-=r,i?(v.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=_(n.check,xe,2,0),d=0,l=0,n.mode=N;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",n.mode=de;break}if((15&d)!==O){e.msg="unknown compression method",n.mode=de;break}if(d>>>=4,l-=4,Ee=(15&d)+8,0===n.wbits)n.wbits=Ee;else if(Ee>n.wbits){e.msg="invalid window size",n.mode=de;break}n.dmax=1<>8&1),512&n.flags&&(xe[0]=255&d,xe[1]=d>>>8&255,n.check=_(n.check,xe,2,0)),d=0,l=0,n.mode=j;case j:for(;l<32;){if(0===c)break e;c--,d+=r[o++]<>>8&255,xe[2]=d>>>16&255,xe[3]=d>>>24&255,n.check=_(n.check,xe,4,0)),d=0,l=0,n.mode=q;case q:for(;l<16;){if(0===c)break e;c--,d+=r[o++]<>8),512&n.flags&&(xe[0]=255&d,xe[1]=d>>>8&255,n.check=_(n.check,xe,2,0)),d=0,l=0,n.mode=z;case z:if(1024&n.flags){for(;l<16;){if(0===c)break e;c--,d+=r[o++]<>>8&255,n.check=_(n.check,xe,2,0)),d=0,l=0}else n.head&&(n.head.extra=null);n.mode=F;case F:if(1024&n.flags&&(m=n.length,m>c&&(m=c),m&&(n.head&&(Ee=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),v.arraySet(n.head.extra,r,o,m,Ee)),512&n.flags&&(n.check=_(n.check,r,m,o)),c-=m,o+=m,n.length-=m),n.length))break e;n.length=0,n.mode=G;case G:if(2048&n.flags){if(0===c)break e;m=0;do Ee=r[o+m++],n.head&&Ee&&n.length<65536&&(n.head.name+=String.fromCharCode(Ee));while(Ee&&m>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Z;break;case V:for(;l<32;){if(0===c)break e;c--,d+=r[o++]<>>=7&l,l-=7&l,n.mode=he;break}for(;l<3;){if(0===c)break e;c--,d+=r[o++]<>>=1,l-=1,3&d){case 0:n.mode=X;break;case 1:if(f(n),n.mode=ne,t===R){d>>>=2,l-=2;break e}break;case 2:n.mode=Q;break;case 3:e.msg="invalid block type",n.mode=de}d>>>=2,l-=2;break;case X:for(d>>>=7&l,l-=7&l;l<32;){if(0===c)break e;c--,d+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=de;break}if(n.length=65535&d,d=0,l=0,n.mode=J,t===R)break e;case J:n.mode=$;case $:if(m=n.length){if(m>c&&(m=c),m>h&&(m=h),0===m)break e;v.arraySet(s,r,o,m,a),c-=m,o+=m,h-=m,a+=m,n.length-=m;break}n.mode=Z;break;case Q:for(;l<14;){if(0===c)break e;c--,d+=r[o++]<>>=5,l-=5,n.ndist=(31&d)+1,d>>>=5,l-=5,n.ncode=(15&d)+4,d>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=de;break}n.have=0,n.mode=ee;case ee:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[Re[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,ke={bits:n.lenbits},Se=E(S,n.lens,0,19,n.lencode,0,n.work,ke),n.lenbits=ke.bits,Se){e.msg="invalid code lengths set",n.mode=de;break}n.have=0,n.mode=te;case te:for(;n.have>>24,ge=Me>>>16&255,ve=65535&Me,!(me<=l);){if(0===c)break e;c--,d+=r[o++]<>>=me,l-=me,n.lens[n.have++]=ve;else{if(16===ve){for(Ae=me+2;l>>=me,l-=me,0===n.have){e.msg="invalid bit length repeat",n.mode=de;break}Ee=n.lens[n.have-1],m=3+(3&d),d>>>=2,l-=2}else if(17===ve){for(Ae=me+3;l>>=me,l-=me,Ee=0,m=3+(7&d),d>>>=3,l-=3}else{for(Ae=me+7;l>>=me,l-=me,Ee=0,m=11+(127&d),d>>>=7,l-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=de;break}for(;m--;)n.lens[n.have++]=Ee}}if(n.mode===de)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=de;break}if(n.lenbits=9,ke={bits:n.lenbits},Se=E(k,n.lens,0,n.nlen,n.lencode,0,n.work,ke),n.lenbits=ke.bits,Se){e.msg="invalid literal/lengths set",n.mode=de;break}if(n.distbits=6,n.distcode=n.distdyn,ke={bits:n.distbits},Se=E(A,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,ke),n.distbits=ke.bits,Se){e.msg="invalid distances set",n.mode=de;break}if(n.mode=ne,t===R)break e;case ne:n.mode=ie;case ie:if(c>=6&&h>=258){e.next_out=a,e.avail_out=h,e.next_in=o,e.avail_in=c,n.hold=d,n.bits=l,w(e,b),a=e.next_out,s=e.output,h=e.avail_out,o=e.next_in,r=e.input,c=e.avail_in,d=n.hold,l=n.bits,n.mode===Z&&(n.back=-1);break}for(n.back=0;Me=n.lencode[d&(1<>>24,ge=Me>>>16&255,ve=65535&Me,!(me<=l);){if(0===c)break e;c--,d+=r[o++]<>ye)],me=Me>>>24,ge=Me>>>16&255,ve=65535&Me,!(ye+me<=l);){if(0===c)break e;c--,d+=r[o++]<>>=ye,l-=ye,n.back+=ye}if(d>>>=me,l-=me,n.back+=me,n.length=ve,0===ge){n.mode=ce;break}if(32&ge){n.back=-1,n.mode=Z;break}if(64&ge){e.msg="invalid literal/length code",n.mode=de;break}n.extra=15&ge,n.mode=re;case re:if(n.extra){for(Ae=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=se;case se:for(;Me=n.distcode[d&(1<>>24,ge=Me>>>16&255,ve=65535&Me,!(me<=l);){if(0===c)break e;c--,d+=r[o++]<>ye)],me=Me>>>24,ge=Me>>>16&255,ve=65535&Me,!(ye+me<=l);){if(0===c)break e;c--,d+=r[o++]<>>=ye,l-=ye,n.back+=ye}if(d>>>=me,l-=me,n.back+=me,64&ge){e.msg="invalid distance code",n.mode=de;break}n.offset=ve,n.extra=15&ge,n.mode=oe;case oe:if(n.extra){for(Ae=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=de;break}n.mode=ae;case ae:if(0===h)break e;if(m=b-h,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=de;break}m>n.wnext?(m-=n.wnext,g=n.wsize-m):g=n.wnext-m,m>n.length&&(m=n.length),be=n.window}else be=s,g=a-n.offset,m=n.length;m>h&&(m=h),h-=m,n.length-=m;do s[a++]=be[g++];while(--m);0===n.length&&(n.mode=ie);break;case ce:if(0===h)break e;s[a++]=n.length,h--,n.mode=ie;break;case he:if(n.wrap){for(;l<32;){if(0===c)break e;c--,d|=r[o++]<=1&&0===z[D];D--);if(P>D&&(P=D),0===D)return b[m++]=20971520,b[m++]=20971520,v.bits=1,0;for(C=1;C0&&(e===a||1!==D))return-1;for(F[1]=0,I=1;Is||e===h&&U>o)return 1;for(var W=0;;){W++,A=I-L,g[T]k?(M=G[H+g[T]],x=j[q+g[T]]):(M=96,x=0),y=1<>L)+_]=A<<24|M<<16|x|0;while(0!==_);for(y=1<>=1;if(0!==y?(N&=y-1,N+=y):N=0,T++,0===--z[I]){if(I===D)break;I=t[n+g[T]]}if(I>P&&(N&E)!==w){for(0===L&&(L=P),S+=C,B=I-L,O=1<s||e===h&&U>o)return 1;w=N&E,b[w]=P<<24|B<<16|S-m|0}}return 0!==N&&(b[S+N]=I-L<<24|64<<16|0),v.bits=P,0}},function(e,t,n){"use strict";function i(e){for(var t=e.length;--t>=0;)e[t]=0}function r(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function s(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function o(e){return e<256?ce[e]:ce[256+(e>>>7)]}function a(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function c(e,t,n){e.bi_valid>Y-n?(e.bi_buf|=t<>Y-e.bi_valid,e.bi_valid+=n-Y):(e.bi_buf|=t<>>=1,n<<=1;while(--t>0);return n>>>1}function u(e){16===e.bi_valid?(a(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function d(e,t){var n,i,r,s,o,a,c=t.dyn_tree,h=t.max_code,f=t.stat_desc.static_tree,u=t.stat_desc.has_stree,d=t.stat_desc.extra_bits,l=t.stat_desc.extra_base,p=t.stat_desc.max_length,b=0;for(s=0;s<=Z;s++)e.bl_count[s]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;np&&(s=p,b++),c[2*i+1]=s,i>h||(e.bl_count[s]++,o=0,i>=l&&(o=d[i-l]),a=c[2*i],e.opt_len+=a*(s+o),u&&(e.static_len+=a*(f[2*i+1]+o)));if(0!==b){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,b-=2}while(b>0);for(s=p;0!==s;s--)for(i=e.bl_count[s];0!==i;)r=e.heap[--n],r>h||(c[2*r+1]!==s&&(e.opt_len+=(s-c[2*r+1])*c[2*r],c[2*r+1]=s),i--)}}function l(e,t,n){var i,r,s=new Array(Z+1),o=0;for(i=1;i<=Z;i++)s[i]=o=o+n[i-1]<<1;for(r=0;r<=t;r++){var a=e[2*r+1];0!==a&&(e[2*r]=f(s[a]++,a))}}function p(){var e,t,n,i,s,o=new Array(Z+1);for(n=0,i=0;i>=7;i8?a(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function g(e,t,n,i){m(e),i&&(a(e,n),a(e,~n)),D.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function v(e,t,n,i){var r=2*t,s=2*n;return e[r]>1;n>=1;n--)y(e,s,n);r=c;do n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],y(e,s,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,s[2*r]=s[2*n]+s[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,s[2*n+1]=s[2*i+1]=r,e.heap[1]=r++,y(e,s,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],d(e,t),l(s,h,e.bl_count)}function E(e,t,n){var i,r,s=-1,o=t[1],a=0,c=7,h=4;for(0===o&&(c=138,h=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a=3&&0===e.bl_tree[2*re[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function A(e,t,n,i){var r;for(c(e,t-257,5),c(e,n-1,5),c(e,i-4,4),r=0;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return B;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return L;for(t=32;t0?(e.strm.data_type===O&&(e.strm.data_type=M(e)),w(e,e.l_desc),w(e,e.d_desc),o=k(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&t!==-1?R(e,t,n,i):e.strategy===P||s===r?(c(e,(N<<1)+(i?1:0),3),_(e,oe,ae)):(c(e,(j<<1)+(i?1:0),3),A(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),_(e,e.dyn_ltree,e.dyn_dtree)),b(e),i&&m(e)}function C(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(he[n]+G+1)]++,e.dyn_dtree[2*o(t)]++),e.last_lit===e.lit_bufsize-1}var D=n(42),P=4,B=0,L=1,O=2,U=0,N=1,j=2,q=3,z=258,F=29,G=256,H=G+1+F,W=30,V=19,K=2*H+1,Z=15,Y=16,X=7,J=256,$=16,Q=17,ee=18,te=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ne=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],ie=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],se=512,oe=new Array(2*(H+2));i(oe);var ae=new Array(2*W);i(ae);var ce=new Array(se);i(ce);var he=new Array(z-q+1);i(he);var fe=new Array(F);i(fe);var ue=new Array(W);i(ue);var de,le,pe,be=!1;t._tr_init=x,t._tr_stored_block=R,t._tr_flush_block=T,t._tr_tally=C,t._tr_align=I},function(e,t){"use strict";function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}e.exports=n},function(e,t,n){var i=n(36),r=i.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});t.RSAPrivateKey=r;var s=i.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});t.RSAPublicKey=s;var o=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())});t.PublicKey=o;var a=i.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),c=i.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(a),this.key("subjectPrivateKey").octstr())});t.PrivateKey=c;var h=i.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});t.EncryptedPrivateKey=h;var f=i.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});t.DSAPrivateKey=f,t.DSAparam=i.define("DSAparam",function(){this.int()});var u=i.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(d),this.key("publicKey").optional().explicit(1).bitstr())});t.ECPrivateKey=u;var d=i.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});t.signature=i.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},function(e,t,n){(function(t){var i=/Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\r?\n\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n/m,r=/^-----BEGIN (.*) KEY-----\r?\n/m,s=/^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m,o=n(41),a=n(50);e.exports=function(e,n){var c,h=e.toString(),f=h.match(i);if(f){var u="aes"+f[1],d=new t(f[2],"hex"),l=new t(f[3].replace(/\r?\n/g,""),"base64"),p=o(n,d.slice(0,8),parseInt(f[1],10)).key,b=[],m=a.createDecipheriv(u,p,d);b.push(m.update(l)),b.push(m.final()),c=t.concat(b)}else{var g=h.match(s);c=new t(g[2].replace(/\r?\n/g,""),"base64")}var v=h.match(r)[1]+" KEY";return{tag:v,data:c}}}).call(t,n(0).Buffer)},function(e,t){var n=Math.pow(2,30)-1;e.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>n||t!==t)throw new TypeError("Bad key length")}},function(e,t,n){t.publicEncrypt=n(217),t.privateDecrypt=n(216),t.privateEncrypt=function(e,n){return t.publicEncrypt(e,n,!0)},t.publicDecrypt=function(e,n){return t.privateDecrypt(e,n,!0)}},function(e,t,n){(function(t){function i(e,n){var i=(e.modulus,e.modulus.byteLength()),r=(n.length,u("sha1").update(new t("")).digest()),o=r.length;if(0!==n[0])throw new Error("decryption error");var h=n.slice(1,o+1),f=n.slice(o+1),d=c(h,a(f,o)),l=c(f,a(d,i-o-1));if(s(r,l.slice(0,o)))throw new Error("decryption error");for(var p=o;0===l[p];)p++;if(1!==l[p++])throw new Error("decryption error");return l.slice(p)}function r(e,t,n){for(var i=t.slice(0,2),r=2,s=0;0!==t[r++];)if(r>=t.length){s++;break}var o=t.slice(2,r-1);t.slice(r-1,r);if(("0002"!==i.toString("hex")&&!n||"0001"!==i.toString("hex")&&n)&&s++,o.length<8&&s++,s)throw new Error("decryption error");return t.slice(r)}function s(e,n){e=new t(e),n=new t(n);var i=0,r=e.length;e.length!==n.length&&(i++,r=Math.min(e.length,n.length));for(var s=-1;++su||new h(n).cmp(c.modulus)>=0)throw new Error("decryption error");var l;l=s?d(new h(n),c):f(n,c);var p=new t(u-l.length);if(p.fill(0),l=t.concat([p,l],u),4===a)return i(c,l);if(1===a)return r(c,l,s);if(3===a)return l;throw new Error("unknown padding")}}).call(t,n(0).Buffer)},function(e,t,n){(function(t){function i(e,n){var i=e.modulus.byteLength(),r=n.length,s=c("sha1").update(new t("")).digest(),o=s.length,d=2*o;if(r>i-d-2)throw new Error("message too long");var l=new t(i-r-d-2);l.fill(0);var p=i-o-1,b=a(o),m=f(t.concat([s,l,new t([1]),n],p),h(b,p)),g=f(b,h(m,o));return new u(t.concat([new t([0]),g,m],i))}function r(e,n,i){var r=n.length,o=e.modulus.byteLength();if(r>o-11)throw new Error("message too long");var a;return i?(a=new t(o-r-3),a.fill(255)):a=s(o-r-3),new u(t.concat([new t([0,i?1:2]),a,new t([0]),n],o))}function s(e,n){for(var i,r=new t(e),s=0,o=a(2*e),c=0;s=0)throw new Error("data too long for modulus")}return n?l(a,c):d(a,c)}}).call(t,n(0).Buffer)},function(e,t,n){(function(e,i){var r;!function(s){function o(e){throw new RangeError(D[e])}function a(e,t){for(var n=e.length,i=[];n--;)i[n]=t(e[n]);return i}function c(e,t){var n=e.split("@"),i="";n.length>1&&(i=n[0]+"@",e=n[1]),e=e.replace(C,".");var r=e.split("."),s=a(r,t).join(".");return i+s}function h(e){for(var t,n,i=[],r=0,s=e.length;r=55296&&t<=56319&&r65535&&(e-=65536,t+=L(e>>>10&1023|55296),e=56320|1023&e),t+=L(e)}).join("")}function u(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:w}function d(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function l(e,t,n){var i=0;for(e=n?B(e/A):e>>1,e+=B(e/t);e>P*S>>1;i+=w)e=B(e/P);return B(i+(P+1)*e/(e+k))}function p(e){var t,n,i,r,s,a,c,h,d,p,b=[],m=e.length,g=0,v=x,y=M;for(n=e.lastIndexOf(R),n<0&&(n=0),i=0;i=128&&o("not-basic"),b.push(e.charCodeAt(i));for(r=n>0?n+1:0;r=m&&o("invalid-input"),h=u(e.charCodeAt(r++)),(h>=w||h>B((_-g)/a))&&o("overflow"),g+=h*a,d=c<=y?E:c>=y+S?S:c-y,!(hB(_/p)&&o("overflow"),a*=p;t=b.length+1,y=l(g-s,t,0==s),B(g/t)>_-v&&o("overflow"),v+=B(g/t),g%=t,b.splice(g++,0,v)}return f(b)}function b(e){var t,n,i,r,s,a,c,f,u,p,b,m,g,v,y,k=[];for(e=h(e),m=e.length,t=x,n=0,s=M,a=0;a=t&&bB((_-n)/g)&&o("overflow"),n+=(c-t)*g,t=c,a=0;a_&&o("overflow"),b==t){for(f=n,u=w;p=u<=s?E:u>=s+S?S:u-s,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},P=w-E,B=Math.floor,L=String.fromCharCode;y={version:"1.4.1",ucs2:{decode:h,encode:f},decode:p,encode:b,toASCII:g,toUnicode:m},r=function(){return y}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(this)}).call(t,n(121)(e),n(18))},function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,s){t=t||"&",r=r||"=";var o={};if("string"!=typeof e||0===e.length)return o;var a=/\+/g;e=e.split(t);var c=1e3;s&&"number"==typeof s.maxKeys&&(c=s.maxKeys);var h=e.length;c>0&&h>c&&(h=c);for(var f=0;f=0?(u=b.substr(0,m),d=b.substr(m+1)):(u=b,d=""),l=decodeURIComponent(u),p=decodeURIComponent(d),n(o,l)?i(o[l])?o[l].push(p):o[l]=[o[l],p]:o[l]=p}return o};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t){"use strict";function n(e,t){if(e.map)return e.map(t);for(var n=[],i=0;i0?this.tail.next=t:this.head=t,this.tail=t,++this.length},i.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},i.prototype.shift=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}},i.prototype.clear=function(){this.head=this.tail=null,this.length=0},i.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},i.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t=r.allocUnsafe(e>>>0),n=this.head,i=0;n;)n.data.copy(t,i),i+=n.data.length,n=n.next;return t}},function(e,t,n){e.exports=n(116)},function(e,t,n){(function(i){var r=function(){try{return n(11)}catch(e){}}();t=e.exports=n(117),t.Stream=r||t,t.Readable=t,t.Writable=n(58),t.Duplex=n(17),t.Transform=n(57),t.PassThrough=n(116),!i.browser&&"disable"===i.env.READABLE_STREAM&&r&&(e.exports=r)}).call(t,n(8))},function(e,t,n){e.exports=n(58)},function(e,t,n){function i(e){if(e)return r(e)}function r(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}var s=n(119);e.exports=i,i.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},i.prototype.parse=function(e){return this._parser=e,this},i.prototype.serialize=function(e){return this._serializer=e,this},i.prototype.timeout=function(e){return this._timeout=e,this},i.prototype.then=function(e,t){if(!this._fullfilledPromise){var n=this;this._fullfilledPromise=new Promise(function(e,t){n.end(function(n,i){n?t(n):e(i)})})}return this._fullfilledPromise.then(e,t)},i.prototype.catch=function(e){return this.then(void 0,e)},i.prototype.use=function(e){return e(this),this},i.prototype.get=function(e){return this._header[e.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(e,t){if(s(e)){for(var n in e)this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},i.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},i.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(s(e)){for(var n in e)this.field(n,e[n]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return this._getFormData().append(e,t),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype.withCredentials=function(){return this._withCredentials=!0,this},i.prototype.redirects=function(e){return this._maxRedirects=e,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(e){var t=s(e),n=this._header["content-type"];if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&s(this._data))for(var i in e)this._data[i]=e[i];else"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],"application/x-www-form-urlencoded"==n?this._data=this._data?this._data+"&"+e:e:this._data=(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(n||this.type("json"),this)}},function(e,t){function n(e,t,n){return"function"==typeof n?new e("GET",t).end(n):2==arguments.length?new e("GET",t):new e(t,n)}e.exports=n},function(e,t){"use strict";function n(e){return this instanceof n?(this.id=r++,void(this.ee=e)):new n(e)}var i=Object.prototype.hasOwnProperty,r=0;n.prototype.on=function(e,t,n){return t.__ultron=this.id,this.ee.on(e,t,n),this},n.prototype.once=function(e,t,n){return t.__ultron=this.id,this.ee.once(e,t,n),this},n.prototype.remove=function(){var e,t=arguments;if(1===t.length&&"string"==typeof t[0])t=t[0].split(/[, ]+/);else if(!t.length){t=[];for(e in this.ee._events)i.call(this.ee._events,e)&&t.push(e)}for(var n=0;n - * MIT Licensed - */ -e.exports.Validation={isValidUTF8:function(e){return!0}}},function(e,t,n){"use strict";try{e.exports=n(89)("validation")}catch(t){e.exports=n(230)}},function(e,t,n){(function(t){function n(e,t){function n(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}if(i("noDeprecation"))return e;var r=!1;return n}function i(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=n}).call(t,n(18))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(module,exports,__webpack_require__){function Context(){}var indexOf=__webpack_require__(201),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n - * MIT Licensed - */ -n(10);i.prototype.get=function(e){if(null==this._buffer||this._offset+e>this._buffer.length){var n=new t(this._growStrategy(e));this._buffer=n,this._offset=0}this._used+=e;var i=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,i},i.prototype.reset=function(e){var n=this._shrinkStrategy();n - * MIT Licensed - */ -t.BufferUtil={merge:function(e,t){for(var n=0,i=0,r=t.length;i - * MIT Licensed - */ -var s=(n(10),0),o=1,a=2,c=3;e.exports=i,i.prototype.add=function(e){function t(){if(n.state===s){if(2==e.length&&255==e[0]&&0==e[1])return n.reset(),void n.onclose();if(128===e[0])n.messageEnd=0,n.state=a,e=e.slice(1);else{if(0!==e[0])return void n.error("payload must start with 0x00 byte",!0);e=e.slice(1),n.state=o}}if(n.state===a){for(var t=0;t0&&(e=e.slice(t))}if(n.state===c){var i=n.messageEnd-n.spanLength;return e.length>=i?(n.buffers.push(e),n.spanLength+=i,n.messageEnd=i,n.parse()):(n.buffers.push(e),void(n.spanLength+=e.length))}return n.buffers.push(e),(n.messageEnd=r(e,255))!=-1?(n.spanLength+=n.messageEnd,n.parse()):void(n.spanLength+=e.length)}if(!this.dead)for(var n=this;e;)e=t()},i.prototype.cleanup=function(){this.dead=!0,this.state=s,this.buffers=[]},i.prototype.parse=function(){for(var e=new t(this.spanLength),n=0,i=0,r=this.buffers.length;i0&&a.copy(e,n,0,this.messageEnd),this.state!==o&&--this.messageEnd;var c=null;return this.messageEnd - * MIT Licensed - */ -var r=n(5),s=n(10);r.EventEmitter;e.exports=i,s.inherits(i,r.EventEmitter),i.prototype.send=function(e,n,i){if(!this.isClosed){var r="string"==typeof e,s=r?t.byteLength(e):e.length,o=s>127?2:1,a=0==this.continuationFrame,c=!n||!("undefined"!=typeof n.fin&&!n.fin),h=new t((a?n&&n.binary?1+o:1:0)+s+(!c||n&&n.binary?0:1)),f=a?1:0;a&&(n&&n.binary?(h.write("€","binary"),o>1&&h.write(String.fromCharCode(128+s/128),f++,"binary"),h.write(String.fromCharCode(127&s),f++,"binary")):h.write("\0","binary")),r?h.write(e,f,"utf8"):e.copy(h,f,0),c?(n&&n.binary||h.write("ÿ",f+s,"binary"),this.continuationFrame=!1):this.continuationFrame=!0;try{this.socket.write(h,"binary",i)}catch(e){this.error(e.toString())}}},i.prototype.close=function(e,n,i,r){if(!this.isClosed){this.isClosed=!0;try{this.continuationFrame&&this.socket.write(new t([255],"binary")),this.socket.write(new t([255,0]),"binary",r)}catch(e){this.error(e.toString())}}},i.prototype.ping=function(e,t){},i.prototype.pong=function(e,t){},i.prototype.error=function(e){return this.emit("error",e),this}}).call(t,n(0).Buffer)},function(e,t){/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -t.Validation={isValidUTF8:function(e){return!0}}},function(e,t,n){"use strict";/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ -try{e.exports=n(231)}catch(t){e.exports=n(244)}},function(e,t,n){(function(t){function i(e,n){if(this instanceof i==!1)return new i(e,n);if(h.EventEmitter.call(this),e=new d({host:"0.0.0.0",port:null,server:null,verifyClient:null,handleProtocols:null,path:null,noServer:!1,disableHixie:!1,clientTracking:!0,perMessageDeflate:!0,maxPayload:104857600}).merge(e),!e.isDefinedAndNonNull("port")&&!e.isDefinedAndNonNull("server")&&!e.value.noServer)throw new TypeError("`port` or a `server` must be provided");var r=this;if(e.isDefinedAndNonNull("port"))this._server=f.createServer(function(e,t){var n=f.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),t.end(n)}),this._server.allowHalfOpen=!1,this._server.listen(e.value.port,e.value.host,n),this._closeServer=function(){r._server&&r._server.close()};else if(e.value.server&&(this._server=e.value.server,e.value.path)){if(this._server._webSocketPaths&&e.value.server._webSocketPaths[e.value.path])throw new Error("two instances of WebSocketServer cannot listen on the same http server path");"object"!=typeof this._server._webSocketPaths&&(this._server._webSocketPaths={}),this._server._webSocketPaths[e.value.path]=1}this._server&&(this._onceServerListening=function(){r.emit("listening")},this._server.once("listening",this._onceServerListening)),"undefined"!=typeof this._server&&(this._onServerError=function(e){r.emit("error",e)},this._server.on("error",this._onServerError),this._onServerUpgrade=function(e,n,i){var s=new t(i.length);i.copy(s),r.handleUpgrade(e,n,s,function(t){r.emit("connection"+e.url,t),r.emit("connection",t)})},this._server.on("upgrade",this._onServerUpgrade)),this.options=e.value,this.path=e.value.path,this.clients=[]}function r(e,t,n,i){var r=function(){try{t.destroy()}catch(e){}};if(t.on("error",r),!e.headers["sec-websocket-key"])return void a(t,400,"Bad Request");var s=parseInt(e.headers["sec-websocket-version"]);if([8,13].indexOf(s)===-1)return void a(t,400,"Bad Request");var c=e.headers["sec-websocket-protocol"],h=s<13?e.headers["sec-websocket-origin"]:e.headers.origin,d=p.parse(e.headers["sec-websocket-extensions"]),b=this,m=function(c){var h=e.headers["sec-websocket-key"],f=u.createHash("sha1");f.update(h+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"),h=f.digest("base64");var m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade","Sec-WebSocket-Accept: "+h];"undefined"!=typeof c&&m.push("Sec-WebSocket-Protocol: "+c);var g={};try{g=o.call(b,d)}catch(e){return void a(t,400,"Bad Request")}if(Object.keys(g).length){var v={};Object.keys(g).forEach(function(e){v[e]=[g[e].params]}),m.push("Sec-WebSocket-Extensions: "+p.format(v))}b.emit("headers",m),t.setTimeout(0),t.setNoDelay(!0);try{t.write(m.concat("","").join("\r\n"))}catch(e){try{t.destroy()}catch(e){}return}var y=new l([e,t,n],{protocolVersion:s,protocol:c,extensions:g,maxPayload:b.options.maxPayload});b.options.clientTracking&&(b.clients.push(y),y.on("close",function(){var e=b.clients.indexOf(y);e!=-1&&b.clients.splice(e,1)})),t.removeListener("error",r),i(y)},g=function(){if("function"==typeof b.options.handleProtocols){var e=(c||"").split(/, */),n=!1;b.options.handleProtocols(e,function(e,i){n=!0,e?m(i):a(t,401,"Unauthorized")});return void(n||a(t,501,"Could not process protocols"))}"undefined"!=typeof c?m(c.split(/, */)[0]):m()};if("function"==typeof this.options.verifyClient){var v={origin:h,secure:"undefined"!=typeof e.connection.authorized||"undefined"!=typeof e.connection.encrypted,req:e};if(2==this.options.verifyClient.length)return void this.options.verifyClient(v,function(e,n,i){"undefined"==typeof n&&(n=401),"undefined"==typeof i&&(i=f.STATUS_CODES[n]),e?g():a(t,n,i)});if(!this.options.verifyClient(v))return void a(t,401,"Unauthorized")}g()}function s(e,n,i,r){var s=function(){try{n.destroy()}catch(e){}};if(n.on("error",s),this.options.disableHixie)return void a(n,401,"Hixie support disabled");if(!e.headers["sec-websocket-key2"])return void a(n,400,"Bad Request");var o=e.headers.origin,c=this,h=function(){var h;h=e.headers["x-forwarded-host"]?e.headers["x-forwarded-host"]:e.headers.host;var f=("https"===e.headers["x-forwarded-proto"]||n.encrypted?"wss":"ws")+"://"+h+e.url,d=e.headers["sec-websocket-protocol"],p=function(){var e=["HTTP/1.1 101 Switching Protocols","Upgrade: WebSocket","Connection: Upgrade","Sec-WebSocket-Location: "+f];return"undefined"!=typeof d&&e.push("Sec-WebSocket-Protocol: "+d),"undefined"!=typeof o&&e.push("Sec-WebSocket-Origin: "+o),new t(e.concat("","").join("\r\n"))},b=function(){n.setTimeout(0),n.setNoDelay(!0);var e=p();try{n.write(e,"binary",function(e){e&&n.removeListener("data",w)})}catch(e){try{n.destroy()}catch(e){}return}},m=function(i,o,h){var f=e.headers["sec-websocket-key1"],p=e.headers["sec-websocket-key2"],b=u.createHash("md5");[f,p].forEach(function(e){var t=parseInt(e.replace(/[^\d]/g,"")),i=e.replace(/[^ ]/g,"").length;return 0===i||t%i!==0?void a(n,400,"Bad Request"):(t/=i,void b.update(String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)))}),b.update(i.toString("binary")),n.setTimeout(0),n.setNoDelay(!0);try{var m=new t(b.digest("binary"),"binary"),g=new t(h.length+m.length);h.copy(g,0),m.copy(g,h.length),n.write(g,"binary",function(t){if(!t){var i=new l([e,n,o],{protocolVersion:"hixie-76",protocol:d});c.options.clientTracking&&(c.clients.push(i),i.on("close",function(){var e=c.clients.indexOf(i);e!=-1&&c.clients.splice(e,1)})),n.removeListener("error",s),r(i)}})}catch(e){try{n.destroy()}catch(e){}return}},g=8;if(i&&i.length>=g){var v=i.slice(0,g),y=i.length>g?i.slice(g):null;m.call(c,v,y,p())}else{var v=new t(g);i.copy(v,0);var _=i.length,y=null,w=function(e){var i=Math.min(e.length,g-_);0!==i&&(e.copy(v,_,0,i),_+=i,_==g&&(n.removeListener("data",w),i - * MIT Licensed - */ -var c=n(10),h=n(5),f=n(55),u=n(122),d=n(108),l=n(129),p=n(126),b=n(44),m=(n(238),n(62));c.inherits(i,h.EventEmitter),i.prototype.close=function(e){var t=null;try{for(var n=0,i=this.clients.length;n>>8^H[255&(i^e[t])];for(r=s>>3;r--;t+=8)i=i>>>8^H[255&(i^e[t])],i=i>>>8^H[255&(i^e[t+1])],i=i>>>8^H[255&(i^e[t+2])],i=i>>>8^H[255&(i^e[t+3])],i=i>>>8^H[255&(i^e[t+4])],i=i>>>8^H[255&(i^e[t+5])],i=i>>>8^H[255&(i^e[t+6])],i=i>>>8^H[255&(i^e[t+7])];return(4294967295^i)>>>0}function o(){}function a(e){this.buffer=new(O?Uint16Array:Array)(2*e),this.length=0}function c(e){var t,n,i,r,s,o,a,c,h,f,u=e.length,d=0,l=Number.POSITIVE_INFINITY;for(c=0;cd&&(d=e[c]),e[c]>=1;for(f=i<<16|c,h=o;h>16&255,s[o++]=n>>24;var a;switch(L){case 1===r:a=[0,r-1,0];break;case 2===r:a=[1,r-2,0];break;case 3===r:a=[2,r-3,0];break;case 4===r:a=[3,r-4,0];break;case 6>=r:a=[4,r-5,1];break;case 8>=r:a=[5,r-7,1];break;case 12>=r:a=[6,r-9,2];break;case 16>=r:a=[7,r-13,2];break;case 24>=r:a=[8,r-17,3];break;case 32>=r:a=[9,r-25,3];break;case 48>=r:a=[10,r-33,4];break;case 64>=r:a=[11,r-49,4];break;case 96>=r:a=[12,r-65,5];break;case 128>=r:a=[13,r-97,5];break;case 192>=r:a=[14,r-129,6];break;case 256>=r:a=[15,r-193,6];break;case 384>=r:a=[16,r-257,7];break;case 512>=r:a=[17,r-385,7];break;case 768>=r:a=[18,r-513,8];break;case 1024>=r:a=[19,r-769,8];break;case 1536>=r:a=[20,r-1025,9];break;case 2048>=r:a=[21,r-1537,9];break;case 3072>=r:a=[22,r-2049,10];break;case 4096>=r:a=[23,r-3073,10];break;case 6144>=r:a=[24,r-4097,11];break;case 8192>=r:a=[25,r-6145,11];break;case 12288>=r:a=[26,r-8193,12];break;case 16384>=r:a=[27,r-12289,12];break;case 24576>=r:a=[28,r-16385,13];break;case 32768>=r:a=[29,r-24577,13];break;default:i("invalid distance")}n=a,s[o++]=n[0],s[o++]=n[1],s[o++]=n[2];var c,h;for(c=0,h=s.length;c=o;)v[o++]=0;for(o=0;29>=o;)y[o++]=0}for(v[256]=1,r=0,s=t.length;r=s){for(u&&n(u,-1),o=0,a=s-r;os&&t+sh&&(r=i,h=s),258===s)break}return new f(h,t-r)}function l(e,t){var n,i,r,s,o,c=e.length,h=new a(572),f=new(O?Uint8Array:Array)(c);if(!O)for(s=0;s2*h[s-1]+f[s]&&(h[s]=2*h[s-1]+f[s]),d[s]=Array(h[s]),l[s]=Array(h[s]);for(r=0;re[r]?(d[s][o]=a,l[s][o]=t,c+=2):(d[s][o]=e[r],l[s][o]=r,++r);p[s]=0,1===f[s]&&i(s)}return u}function b(e){var t,n,i,r,s=new(O?Uint16Array:Array)(e.length),o=[],a=[],c=0;for(t=0,n=e.length;t>>=1;return s}function m(e,t){this.input=e,this.b=this.c=0,this.g={},t&&(t.flags&&(this.g=t.flags),"string"==typeof t.filename&&(this.filename=t.filename),"string"==typeof t.comment&&(this.w=t.comment),t.deflateOptions&&(this.l=t.deflateOptions)),this.l||(this.l={})}function g(e,t){switch(this.o=[],this.p=32768,this.e=this.j=this.c=this.s=0,this.input=O?new Uint8Array(e):e,this.u=!1,this.q=ne,this.L=!1,!t&&(t={})||(t.index&&(this.c=t.index),t.bufferSize&&(this.p=t.bufferSize),t.bufferType&&(this.q=t.bufferType),t.resize&&(this.L=t.resize)),this.q){case te:this.b=32768,this.a=new(O?Uint8Array:Array)(32768+this.p+258);break;case ne:this.b=0,this.a=new(O?Uint8Array:Array)(this.p),this.f=this.T,this.z=this.P,this.r=this.R;break;default:i(Error("invalid inflate mode"))}}function v(e,t){for(var n,r=e.j,s=e.e,o=e.input,a=e.c,c=o.length;s=c&&i(Error("input buffer is broken")),r|=o[a++]<>>t,e.e=s-t,e.c=a,n}function y(e,t){for(var n,i,r=e.j,s=e.e,o=e.input,a=e.c,c=o.length,h=t[0],f=t[1];s=c);)r|=o[a++]<>>16,e.j=r>>i,e.e=s-i,e.c=a,65535&n}function _(e){function t(e,t,n){var i,r,s,o=this.I;for(s=0;s>>0;e=i}for(var r,s=1,o=0,a=e.length,c=0;0>>0}function S(e,t){var n,r;switch(this.input=e,this.c=0,!t&&(t={})||(t.index&&(this.c=t.index),t.verify&&(this.W=t.verify)),n=e[this.c++],r=e[this.c++],15&n){case we:this.method=we;break;default:i(Error("unsupported compression method"))}0!==((n<<8)+r)%31&&i(Error("invalid fcheck flag:"+((n<<8)+r)%31)),32&r&&i(Error("fdict flag is not supported")),this.K=new g(e,{index:this.c,bufferSize:t.bufferSize,bufferType:t.bufferType,resize:t.resize})}function k(e,t){this.input=e,this.a=new(O?Uint8Array:Array)(32768),this.k=Ee.t;var n,i={};!t&&(t={})||"number"!=typeof t.compressionType||(this.k=t.compressionType);for(n in t)i[n]=t[n];i.outputBuffer=this.a,this.J=new h(this.input,i)}function A(t,n,i){e.nextTick(function(){var e,r;try{r=M(t,i)}catch(t){e=t}n(e,r)})}function M(e,t){var n;return n=new k(e).h(),t||(t={}),t.H?n:P(n)}function x(t,n,i){e.nextTick(function(){var e,r;try{r=R(t,i)}catch(t){e=t}n(e,r)})}function R(e,t){var n;return e.subarray=e.slice,n=new S(e).i(),t||(t={}),t.noBuffer?n:P(n)}function I(t,n,i){e.nextTick(function(){var e,r;try{r=T(t,i)}catch(t){e=t}n(e,r)})}function T(e,t){var n;return e.subarray=e.slice,n=new m(e).h(),t||(t={}),t.H?n:P(n)}function C(t,n,i){e.nextTick(function(){var e,r;try{r=D(t,i)}catch(t){e=t}n(e,r)})}function D(e,t){var n;return e.subarray=e.slice,n=new w(e).i(),t||(t={}),t.H?n:P(n)}function P(e){var t,i,r=new n(e.length);for(t=0,i=e.length;t>>8&255]<<16|F[e>>>16&255]<<8|F[e>>>24&255])>>32-t:F[e]>>8-t),8>t+o)a=a<>t-i-1&1,8===++o&&(o=0,r[s++]=F[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.m=o,this.index=s},r.prototype.finish=function(){var e,t=this.buffer,n=this.index;return 0U;++U){for(var j=U,q=j,z=7,j=j>>>1;j;j>>>=1)q<<=1,q|=1&j,--z;N[U]=(q<>>0}var F=N,G=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],H=O?new Uint32Array(G):G;a.prototype.getParent=function(e){return 2*((e-2)/4|0)},a.prototype.push=function(e,t){var n,i,r,s=this.buffer;for(n=this.length,s[this.length++]=t,s[this.length++]=e;0s[i]);)r=s[n],s[n]=s[i],s[i]=r,r=s[n+1],s[n+1]=s[i+1],s[i+1]=r,n=i;return this.length},a.prototype.pop=function(){var e,t,n,i,r,s=this.buffer;for(t=s[0],e=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;(i=2*r+2,!(i>=this.length))&&(i+2s[i]&&(i+=2),s[i]>s[r]);)n=s[r],s[r]=s[i],s[i]=n,n=s[r+1],s[r+1]=s[i+1],s[i+1]=n,r=i;return{index:e,value:t,length:this.length}};var W,V=2,K={NONE:0,M:1,t:V,Y:3},Z=[];for(W=0;288>W;W++)switch(L){case 143>=W:Z.push([W+48,8]);break;case 255>=W:Z.push([W-144+400,9]);break;case 279>=W:Z.push([W-256+0,7]);break;case 287>=W:Z.push([W-280+192,8]);break;default:i("invalid literal: "+W)}h.prototype.h=function(){var e,t,n,s,o=this.input;switch(this.k){case 0:for(n=0,s=o.length;n>>8&255,g[v++]=255&d,g[v++]=d>>>8&255,O)g.set(a,v),v+=a.length,g=g.subarray(0,v);else{for(p=0,m=a.length;pY)for(;0Y?Y:138,$>Y-3&&$=$?(ne[J++]=17,ne[J++]=$-3,ie[17]++):(ne[J++]=18,ne[J++]=$-11,ie[18]++),Y-=$;else if(ne[J++]=te[W],ie[te[W]]++,Y--,3>Y)for(;0Y?Y:6,$>Y-3&&$q;q++)H[q]=P[G[q]];for(R=19;4=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:i("invalid length: "+e)}}var t,n,r=[];for(t=3;258>=t;t++)n=e(t),r[t]=n[2]<<24|n[1]<<16|n[0];return r}(),X=O?new Uint32Array(Y):Y;m.prototype.h=function(){var e,t,n,i,r,o,a,c,f=new(O?Uint8Array:Array)(32768),u=0,d=this.input,l=this.c,p=this.filename,b=this.w;if(f[u++]=31,f[u++]=139,f[u++]=8,e=0,this.g.fname&&(e|=Q),this.g.fcomment&&(e|=ee),this.g.fhcrc&&(e|=$),f[u++]=e,t=(Date.now?Date.now():+new Date)/1e3|0,f[u++]=255&t,f[u++]=t>>>8&255,f[u++]=t>>>16&255,f[u++]=t>>>24&255,f[u++]=0,f[u++]=J,this.g.fname!==B){for(a=0,c=p.length;a>>8&255),f[u++]=255&o;f[u++]=0}if(this.g.comment){for(a=0,c=b.length;a>>8&255),f[u++]=255&o;f[u++]=0}return this.g.fhcrc&&(n=65535&s(f,0,u),f[u++]=255&n,f[u++]=n>>>8&255),this.l.outputBuffer=f,this.l.outputIndex=u,r=new h(d,this.l),f=r.h(),u=r.b,O&&(u+8>f.buffer.byteLength?(this.a=new Uint8Array(u+8),this.a.set(new Uint8Array(f.buffer)),f=this.a):f=new Uint8Array(f.buffer)),i=s(d,B,B),f[u++]=255&i,f[u++]=i>>>8&255,f[u++]=i>>>16&255,f[u++]=i>>>24&255,c=d.length,f[u++]=255&c,f[u++]=c>>>8&255,f[u++]=c>>>16&255,f[u++]=c>>>24&255,this.c=l,O&&u>>=1){case 0:var t=this.input,n=this.c,r=this.a,s=this.b,o=t.length,a=B,c=B,h=r.length,f=B;switch(this.e=this.j=0,n+1>=o&&i(Error("invalid uncompressed block header: LEN")),a=t[n++]|t[n++]<<8,n+1>=o&&i(Error("invalid uncompressed block header: NLEN")),c=t[n++]|t[n++]<<8,a===~c&&i(Error("invalid uncompressed block header: length verify")),n+a>t.length&&i(Error("input buffer is broken")),this.q){case te:for(;s+a>r.length;){if(f=h-s,a-=f,O)r.set(t.subarray(n,n+f),s),s+=f,n+=f;else for(;f--;)r[s++]=t[n++];this.b=s,r=this.f(),s=this.b}break;case ne:for(;s+a>r.length;)r=this.f({B:2});break;default:i(Error("invalid inflate mode"))}if(O)r.set(t.subarray(n,n+a),s),s+=a,n+=a;else for(;a--;)r[s++]=t[n++];this.c=n,this.b=s,this.a=r;break;case 1:this.r(ve,_e);break;case 2:_(this);break;default:i(Error("unknown BTYPE: "+e))}}return this.z()};var ie,re,se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],oe=O?new Uint16Array(se):se,ae=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],ce=O?new Uint16Array(ae):ae,he=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],fe=O?new Uint8Array(he):he,ue=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],de=O?new Uint16Array(ue):ue,le=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],pe=O?new Uint8Array(le):le,be=new(O?Uint8Array:Array)(288);for(ie=0,re=be.length;ie=ie?8:255>=ie?9:279>=ie?7:8;var me,ge,ve=c(be),ye=new(O?Uint8Array:Array)(30);for(me=0,ge=ye.length;mer)i>=c&&(this.b=i,n=this.f(),i=this.b),n[i++]=r;else for(s=r-257,a=ce[s],0=c&&(this.b=i,n=this.f(),i=this.b);a--;)n[i]=n[i++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},g.prototype.R=function(e,t){var n=this.a,i=this.b;this.A=e;for(var r,s,o,a,c=n.length;256!==(r=y(this,e));)if(256>r)i>=c&&(n=this.f(),c=n.length),n[i++]=r;else for(s=r-257,a=ce[s],0c&&(n=this.f(),c=n.length);a--;)n[i]=n[i++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},g.prototype.f=function(){var e,t,n=new(O?Uint8Array:Array)(this.b-32768),i=this.b-32768,r=this.a;if(O)n.set(r.subarray(32768,n.length));else for(e=0,t=n.length;ee;++e)r[e]=r[i+e];return this.b=32768,r},g.prototype.T=function(e){var t,n,i,r,s=this.input.length/this.c+1|0,o=this.input,a=this.a;return e&&("number"==typeof e.B&&(s=e.B),"number"==typeof e.N&&(s+=e.N)),2>s?(n=(o.length-this.c)/this.A[2],r=258*(n/2)|0,i=rt&&(this.a.length=t),e=this.a),this.buffer=e},w.prototype.i=function(){for(var e=this.input.length;this.c>>0,s(a,B,B)!==l&&i(Error("invalid CRC-32 checksum: 0x"+s(a,B,B).toString(16)+" / 0x"+l.toString(16))),t.$=n=(p[b++]|p[b++]<<8|p[b++]<<16|p[b++]<<24)>>>0,(4294967295&a.length)!==n&&i(Error("invalid input size: "+(4294967295&a.length)+" / "+n)),this.G.push(t),this.c=b}this.S=L;var m,v,y,_=this.G,w=0,E=0;for(m=0,v=_.length;m>>0,t!==E(e)&&i(Error("invalid adler-32 checksum"))),e};var we=8,Ee=K;k.prototype.h=function(){var e,t,n,r,s,o,a,c=0;switch(a=this.a,e=we){case we:t=Math.LOG2E*Math.log(32768)-8;break;default:i(Error("invalid compression method"))}switch(n=t<<4|e,a[c++]=n,e){case we:switch(this.k){case Ee.NONE:s=0;break;case Ee.M:s=1;break;case Ee.t:s=2;break;default:i(Error("unsupported compression type"))}break;default:i(Error("invalid compression method"))}return r=s<<6|0,a[c++]=r|31-(256*n+r)%31,o=E(this.input),this.J.b=c,a=this.J.h(),c=a.length,O&&(a=new Uint8Array(a.buffer),a.length<=c+4&&(this.a=new Uint8Array(a.length+4),this.a.set(a),a=this.a),a=a.subarray(0,c+4)),a[c++]=o>>24&255,a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o,a},t.deflate=A,t.deflateSync=M,t.inflate=x,t.inflateSync=R,t.gzip=I,t.gzipSync=T,t.gunzip=C,t.gunzipSync=D}).call(this)}).call(t,n(8),n(0).Buffer)},function(e,t,n){const i=n(1),r=n(12),s=n(47),o=n(14),a=n(69),c=n(25),h=n(80),f=n(81),u=n(32),d=n(70);class l{constructor(e){this.client=e}get pastReady(){return this.client.ws.status===i.Status.READY}newGuild(e){const t=this.client.guilds.has(e.id),n=new s(this.client,e);return this.client.guilds.set(n.id,n),this.pastReady&&!t&&(this.client.options.fetchAllMembers?n.fetchMembers().then(()=>{this.client.emit(i.Events.GUILD_CREATE,n)}):this.client.emit(i.Events.GUILD_CREATE,n)),n}newUser(e){if(this.client.users.has(e.id))return this.client.users.get(e.id);const t=new o(this.client,e);return this.client.users.set(t.id,t),t}newChannel(e,t){const n=this.client.channels.has(e.id);let r;return e.type===i.ChannelTypes.DM?r=new a(this.client,e):e.type===i.ChannelTypes.groupDM?r=new d(this.client,e):(t=t||this.client.guilds.get(e.guild_id),t&&(e.type===i.ChannelTypes.text?(r=new h(t,e),t.channels.set(r.id,r)):e.type===i.ChannelTypes.voice&&(r=new f(t,e),t.channels.set(r.id,r)))),r?(this.pastReady&&!n&&this.client.emit(i.Events.CHANNEL_CREATE,r),this.client.channels.set(r.id,r),r):null}newEmoji(e,t){const n=t.emojis.has(e.id);if(e&&!n){let n=new c(t,e);return this.client.emit(i.Events.EMOJI_CREATE,n),t.emojis.set(n.id,n),n}return n?t.emojis.get(e.id):null}killEmoji(e){e instanceof c&&e.guild&&(this.client.emit(i.Events.EMOJI_DELETE,e),e.guild.emojis.delete(e.id))}killGuild(e){const t=this.client.guilds.has(e.id);this.client.guilds.delete(e.id),t&&this.pastReady&&this.client.emit(i.Events.GUILD_DELETE,e)}killUser(e){this.client.users.delete(e.id)}killChannel(e){this.client.channels.delete(e.id),e instanceof u&&e.guild.channels.delete(e.id)}updateGuild(e,t){const n=r(e);e.setup(t),this.pastReady&&this.client.emit(i.Events.GUILD_UPDATE,n,e)}updateChannel(e,t){e.setup(t)}updateEmoji(e,t){const n=r(e);e.setup(t),this.client.emit(i.Events.GUILD_EMOJI_UPDATE,n,e)}}e.exports=l},function(e,t,n){const i=n(1);class r{constructor(e){this.client=e,this.heartbeatInterval=null}connectToWebSocket(e,t,n){this.client.emit(i.Events.DEBUG,`Authenticated using token ${e}`),this.client.token=e;const r=this.client.setTimeout(()=>n(new Error(i.Errors.TOOK_TOO_LONG)),3e5);this.client.rest.methods.getGateway().then(s=>{this.client.emit(i.Events.DEBUG,`Using gateway ${s}`),this.client.ws.connect(s),this.client.ws.once("close",e=>{4004===e.code&&n(new Error(i.Errors.BAD_LOGIN)),4010===e.code&&n(new Error(i.Errors.INVALID_SHARD))}),this.client.once(i.Events.READY,()=>{t(e),this.client.clearTimeout(r)})},n)}setupKeepAlive(e){this.heartbeatInterval=this.client.setInterval(()=>{this.client.emit("debug","Sending heartbeat"),this.client.ws.send({op:i.OPCodes.HEARTBEAT,d:this.client.ws.sequence},!0)},e)}destroy(){return new Promise(e=>{this.client.ws.destroy(),this.client.user.bot?e():e(this.client.rest.methods.logout())})}}e.exports=r},function(e,t,n){class i{constructor(e){this.client=e,this.register(n(267)),this.register(n(268)),this.register(n(269)),this.register(n(273)),this.register(n(270)),this.register(n(271)),this.register(n(272)),this.register(n(251)),this.register(n(252)),this.register(n(253)),this.register(n(255)),this.register(n(266)),this.register(n(259)),this.register(n(260)),this.register(n(254)),this.register(n(261)),this.register(n(262)),this.register(n(263)),this.register(n(274)),this.register(n(276)),this.register(n(275)),this.register(n(265)),this.register(n(256)),this.register(n(257)),this.register(n(258)),this.register(n(264))}register(e){this[e.name.replace(/Action$/,"")]=new e(this.client)}}e.exports=i},function(e,t,n){const i=n(4);class r extends i{handle(e){const t=this.client,n=t.dataManager.newChannel(e);return{channel:n}}}e.exports=r},function(e,t,n){const i=n(4);class r extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client;let n=t.channels.get(e.id);return n?(t.dataManager.killChannel(n),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)):n=this.deleted.get(e.id)||null,{channel:n}}scheduleForDeletion(e){this.client.setTimeout(()=>this.deleted.delete(e),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(4),r=n(1),s=n(12);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.id);if(n){const i=s(n);return n.setup(e),t.emit(r.Events.CHANNEL_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(4),r=n(1);class s extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id),i=t.dataManager.newUser(e.user);n&&i&&t.emit(r.Events.GUILD_BAN_REMOVE,n,i)}}e.exports=s},function(e,t,n){const i=n(4),r=n(1);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client;let n=t.guilds.get(e.id);if(n){if(n.available&&e.unavailable)return n.available=!1,t.emit(r.Events.GUILD_UNAVAILABLE,n),{guild:null};t.guilds.delete(n.id),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)}else n=this.deleted.get(e.id)||null;return{guild:n}}scheduleForDeletion(e){this.client.setTimeout(()=>this.deleted.delete(e),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(4);class r extends i{handle(e,t){const n=this.client,i=n.dataManager.newEmoji(e,t);return{emoji:i}}}e.exports=r},function(e,t,n){const i=n(4);class r extends i{handle(e){const t=this.client;return t.dataManager.killEmoji(e),{data:e}}}e.exports=r},function(e,t,n){const i=n(4);class r extends i{handle(e,t){const n=this.client;for(let i of e.emojis){const e=t.emojis.has(i.id);e?n.dataManager.updateEmoji(t.emojis.get(i.id),i):i=n.dataManager.newEmoji(i,t)}for(let i of t.emojis)e.emoijs.has(i.id)||n.dataManager.killEmoji(i);return{emojis:e.emojis}}}e.exports=r},function(e,t,n){const i=n(4);class r extends i{handle(e,t){const n=e._addMember(t,!1);return{member:n}}}e.exports=r},function(e,t,n){const i=n(4),r=n(1);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){let i=n.members.get(e.user.id);return i?(n.memberCount--,n._removeMember(i),this.deleted.set(n.id+e.user.id,i),t.status===r.Status.READY&&t.emit(r.Events.GUILD_MEMBER_REMOVE,i),this.scheduleForDeletion(n.id,e.user.id)):i=this.deleted.get(n.id+e.user.id)||null,{guild:n,member:i}}return{guild:n,member:null}}scheduleForDeletion(e,t){this.client.setTimeout(()=>this.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(4),r=n(1),s=n(19);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){const i=n.roles.has(e.role.id),o=new s(n,e.role);return n.roles.set(o.id,o),i||t.emit(r.Events.GUILD_ROLE_CREATE,o),{role:o}}return{role:null}}}e.exports=o},function(e,t,n){const i=n(4),r=n(1);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){let i=n.roles.get(e.role_id);return i?(n.roles.delete(e.role_id),this.deleted.set(n.id+e.role_id,i),this.scheduleForDeletion(n.id,e.role_id),t.emit(r.Events.GUILD_ROLE_DELETE,i)):i=this.deleted.get(n.id+e.role_id)||null, -{role:i}}return{role:null}}scheduleForDeletion(e,t){this.client.setTimeout(()=>this.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(4),r=n(1),s=n(12);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){const i=e.role;let o=null;const a=n.roles.get(i.id);return a&&(o=s(a),a.setup(e.role),t.emit(r.Events.GUILD_ROLE_UPDATE,o,a)),{old:o,updated:a}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(4);class r extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n)for(const i of e.roles){const e=n.roles.get(i.id);e&&(e.position=i.position)}return{guild:n}}}e.exports=r},function(e,t,n){const i=n(4);class r extends i{handle(e){const t=this.client,n=t.guilds.get(e.id);if(n){e.presences=e.presences||[];for(const t of e.presences)n._setPresence(t.user.id,t);e.members=e.members||[];for(const i of e.members){const e=n.members.get(i.user.id);e?n._updateMember(e,i):n._addMember(i)}}}}e.exports=r},function(e,t,n){const i=n(4),r=n(1),s=n(12);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.id);if(n){const i=s(n);return n.setup(e),t.emit(r.Events.GUILD_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(4),r=n(34);class s extends i{handle(e){const t=this.client,n=t.channels.get((e instanceof Array?e[0]:e).channel_id);if(n){if(e instanceof Array){const i=new Array(e.length);for(let s=0;sthis.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(4),r=n(6),s=n(1);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.channel_id),i=e.ids,o=new r;for(const a of i){const e=n.messages.get(a);e&&o.set(e.id,e)}return o.size>0&&t.emit(s.Events.MESSAGE_BULK_DELETE,o),{messages:o}}}e.exports=o},function(e,t,n){const i=n(4),r=n(1);class s extends i{handle(e){const t=this.client.users.get(e.user_id);if(!t)return!1;const n=this.client.channels.get(e.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(e.message_id);if(!i)return!1;if(!e.emoji)return!1;const s=i._addReaction(e.emoji,t);return s&&this.client.emit(r.Events.MESSAGE_REACTION_ADD,s,t),{message:i,reaction:s,user:t}}}e.exports=s},function(e,t,n){const i=n(4),r=n(1);class s extends i{handle(e){const t=this.client.users.get(e.user_id);if(!t)return!1;const n=this.client.channels.get(e.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(e.message_id);if(!i)return!1;if(!e.emoji)return!1;const s=i._removeReaction(e.emoji,t);return s&&this.client.emit(r.Events.MESSAGE_REACTION_REMOVE,s,t),{message:i,reaction:s,user:t}}}e.exports=s},function(e,t,n){const i=n(4),r=n(1);class s extends i{handle(e){const t=this.client.channels.get(e.channel_id);if(!t||"voice"===t.type)return!1;const n=t.messages.get(e.message_id);return!!n&&(n._clearReactions(),this.client.emit(r.Events.MESSAGE_REACTION_REMOVE_ALL,n),{message:n})}}e.exports=s},function(e,t,n){const i=n(4),r=n(1),s=n(12);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.channel_id);if(n){const i=n.messages.get(e.id);if(i){const n=s(i);return i.patch(e),i._edits.unshift(n),t.emit(r.Events.MESSAGE_UPDATE,n,i),{old:n,updated:i}}return{old:i,updated:i}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(4);class r extends i{handle(e){const t=this.client,n=t.dataManager.newUser(e);return{user:n}}}e.exports=r},function(e,t,n){const i=n(4),r=n(1);class s extends i{handle(e){const t=this.client,n=t.user.notes.get(e.id),i=e.note.length?e.note:null;return t.user.notes.set(e.id,i),t.emit(r.Events.USER_NOTE_UPDATE,e.id,n,i),{old:n,updated:i}}}e.exports=s},function(e,t,n){const i=n(4),r=n(1),s=n(12);class o extends i{handle(e){const t=this.client;if(t.user){if(t.user.equals(e))return{old:t.user,updated:t.user};const n=s(t.user);return t.user.patch(e),t.emit(r.Events.USER_UPDATE,n,t.user),{old:n,updated:t.user}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){function i(e){let t=e.split("?")[0];if(t.includes("/channels/")||t.includes("/guilds/")){const e=~t.indexOf("/channels/")?t.indexOf("/channels/"):t.indexOf("/guilds/"),n=t.substring(e).split("/")[2];t=t.replace(/(\d{8,})/g,":id").replace(":id",n)}return t}const r=n(60),s=n(1);class o{constructor(e,t,n,r,s,o){this.rest=e,this.method=t,this.url=n,this.auth=r,this.data=s,this.file=o,this.route=i(this.url)}getAuth(){if(this.rest.client.token&&this.rest.client.user&&this.rest.client.user.bot)return`Bot ${this.rest.client.token}`;if(this.rest.client.token)return this.rest.client.token;throw new Error(s.Errors.NO_TOKEN)}gen(){const e=r[this.method](this.url);if(this.auth&&e.set("authorization",this.getAuth()),this.file&&this.file.file){e.attach("file",this.file.file,this.file.name),this.data=this.data||{};for(const t in this.data)this.data[t]&&e.field(t,this.data[t])}else this.data&&e.send(this.data);return e.set("User-Agent",this.rest.userAgentManager.userAgent),e}}e.exports=o},function(e,t,n){const i=n(1),r=n(6),s=n(83),o=n(334),a=n(14),c=n(33),h=n(19),f=n(71),u=n(49),d=n(333),l=n(67);class p{constructor(e){this.rest=e}loginToken(e=this.rest.client.token){return new Promise((t,n)=>{e=e.replace(/^Bot\s*/i,""),this.rest.client.manager.connectToWebSocket(e,t,n)})}loginEmailPassword(e,t){return this.rest.client.emit("warn","Client launched using email and password - should use token instead"),this.rest.client.email=e,this.rest.client.password=t,this.rest.makeRequest("post",i.Endpoints.login,!1,{email:e,password:t}).then(e=>this.loginToken(e.token))}logout(){return this.rest.makeRequest("post",i.Endpoints.logout,!0,{})}getGateway(){return this.rest.makeRequest("get",i.Endpoints.gateway,!0).then(e=>{return this.rest.client.ws.gateway=`${e.url}/?encoding=json&v=${i.PROTOCOL_VERSION}`,this.rest.client.ws.gateway})}getBotGateway(){return this.rest.makeRequest("get",i.Endpoints.botGateway,!0)}sendMessage(e,t,{tts,nonce,embed,disableEveryone,split}={},n=null){return new Promise((i,r)=>{"undefined"!=typeof t&&(t=this.rest.client.resolver.resolveString(t)),t&&((disableEveryone||"undefined"==typeof disableEveryone&&this.rest.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),split&&(t=s(t,"object"==typeof split?split:{}))),e instanceof a||e instanceof c?this.createDM(e).then(e=>{this._sendMessageRequest(e,t,n,tts,nonce,embed,i,r)},r):this._sendMessageRequest(e,t,n,tts,nonce,embed,i,r)})}_sendMessageRequest(e,t,n,r,s,o,a,c){if(t instanceof Array){const h=[];let f=this.rest.makeRequest("post",i.Endpoints.channelMessages(e.id),!0,{content:t[0],tts:r,nonce:s},n).catch(c);for(let u=1;u<=t.length;u++)if(u{return h.push(c),this.rest.makeRequest("post",i.Endpoints.channelMessages(e.id),!0,{content:t[a],tts:r,nonce:s,embed:o},n)},c)}else f.then(e=>{h.push(e),a(this.rest.client.actions.MessageCreate.handle(h).messages)},c)}else this.rest.makeRequest("post",i.Endpoints.channelMessages(e.id),!0,{content:t,tts:r,nonce:s,embed:o},n).then(e=>a(this.rest.client.actions.MessageCreate.handle(e).message),c)}deleteMessage(e){return this.rest.makeRequest("del",i.Endpoints.channelMessage(e.channel.id,e.id),!0).then(()=>this.rest.client.actions.MessageDelete.handle({id:e.id,channel_id:e.channel.id}).message)}bulkDeleteMessages(e,t){return this.rest.makeRequest("post",`${i.Endpoints.channelMessages(e.id)}/bulk_delete`,!0,{messages:t}).then(()=>this.rest.client.actions.MessageDeleteBulk.handle({channel_id:e.id,ids:t}).messages)}updateMessage(e,t,{embed}={}){return t=this.rest.client.resolver.resolveString(t),this.rest.makeRequest("patch",i.Endpoints.channelMessage(e.channel.id,e.id),!0,{content:t,embed:embed}).then(e=>this.rest.client.actions.MessageUpdate.handle(e).updated)}createChannel(e,t,n){return this.rest.makeRequest("post",i.Endpoints.guildChannels(e.id),!0,{name:t,type:n}).then(e=>this.rest.client.actions.ChannelCreate.handle(e).channel)}createDM(e){const t=this.getExistingDM(e);return t?Promise.resolve(t):this.rest.makeRequest("post",i.Endpoints.userChannels(this.rest.client.user.id),!0,{recipient_id:e.id}).then(e=>this.rest.client.actions.ChannelCreate.handle(e).channel)}getExistingDM(e){return this.rest.client.channels.find(t=>t.recipient&&t.recipient.id===e.id)}deleteChannel(e){return(e instanceof a||e instanceof c)&&(e=this.getExistingDM(e)),e?this.rest.makeRequest("del",i.Endpoints.channel(e.id),!0).then(t=>{return t.id=e.id,this.rest.client.actions.ChannelDelete.handle(t).channel}):Promise.reject(new Error("No channel to delete."))}updateChannel(e,t){const n={};return n.name=(t.name||e.name).trim(),n.topic=t.topic||e.topic,n.position=t.position||e.position,n.bitrate=t.bitrate||e.bitrate,n.user_limit=t.userLimit||e.userLimit,this.rest.makeRequest("patch",i.Endpoints.channel(e.id),!0,n).then(e=>this.rest.client.actions.ChannelUpdate.handle(e).updated)}leaveGuild(e){return e.ownerID===this.rest.client.user.id?Promise.reject(new Error("Guild is owned by the client.")):this.rest.makeRequest("del",i.Endpoints.meGuild(e.id),!0).then(()=>this.rest.client.actions.GuildDelete.handle({id:e.id}).guild)}createGuild(e){return e.icon=this.rest.client.resolver.resolveBase64(e.icon)||null,e.region=e.region||"us-central",new Promise((t,n)=>{this.rest.makeRequest("post",i.Endpoints.guilds,!0,e).then(e=>{if(this.rest.client.guilds.has(e.id))return void t(this.rest.client.guilds.get(e.id));const i=n=>{n.id===e.id&&(this.rest.client.removeListener("guildCreate",i),this.rest.client.clearTimeout(r),t(n))};this.rest.client.on("guildCreate",i);const r=this.rest.client.setTimeout(()=>{this.rest.client.removeListener("guildCreate",i),n(new Error("Took too long to receive guild data."))},1e4)},n)})}deleteGuild(e){return this.rest.makeRequest("del",i.Endpoints.guild(e.id),!0).then(()=>this.rest.client.actions.GuildDelete.handle({id:e.id}).guild)}getUser(e){return this.rest.makeRequest("get",i.Endpoints.user(e),!0).then(e=>this.rest.client.actions.UserGet.handle(e).user)}updateCurrentUser(e){const t=this.rest.client.user,n={};return n.username=e.username||t.username,n.avatar=this.rest.client.resolver.resolveBase64(e.avatar)||t.avatar,t.bot||(n.email=e.email||t.email,n.password=this.rest.client.password,e.new_password&&(n.new_password=e.newPassword)),this.rest.makeRequest("patch",i.Endpoints.me,!0,n).then(e=>this.rest.client.actions.UserUpdate.handle(e).updated)}updateGuild(e,t){const n={};return t.name&&(n.name=t.name),t.region&&(n.region=t.region),t.verificationLevel&&(n.verification_level=Number(t.verificationLevel)),t.afkChannel&&(n.afk_channel_id=this.rest.client.resolver.resolveChannel(t.afkChannel).id),t.afkTimeout&&(n.afk_timeout=Number(t.afkTimeout)),t.icon&&(n.icon=this.rest.client.resolver.resolveBase64(t.icon)),t.owner&&(n.owner_id=this.rest.client.resolver.resolveUser(t.owner).id),t.splash&&(n.splash=this.rest.client.resolver.resolveBase64(t.splash)),this.rest.makeRequest("patch",i.Endpoints.guild(e.id),!0,n).then(e=>this.rest.client.actions.GuildUpdate.handle(e).updated)}kickGuildMember(e,t){return this.rest.makeRequest("del",i.Endpoints.guildMember(e.id,t.id),!0).then(()=>this.rest.client.actions.GuildMemberRemove.handle({guild_id:e.id,user:t.user}).member)}createGuildRole(e){return this.rest.makeRequest("post",i.Endpoints.guildRoles(e.id),!0).then(t=>this.rest.client.actions.GuildRoleCreate.handle({guild_id:e.id,role:t}).role)}deleteGuildRole(e){return this.rest.makeRequest("del",i.Endpoints.guildRole(e.guild.id,e.id),!0).then(()=>this.rest.client.actions.GuildRoleDelete.handle({guild_id:e.guild.id,role_id:e.id}).role)}setChannelOverwrite(e,t){return this.rest.makeRequest("put",`${i.Endpoints.channelPermissions(e.id)}/${t.id}`,!0,t)}deletePermissionOverwrites(e){return this.rest.makeRequest("del",`${i.Endpoints.channelPermissions(e.channel.id)}/${e.id}`,!0).then(()=>e)}getChannelMessages(e,t={}){const n=[];t.limit&&n.push(`limit=${t.limit}`),t.around?n.push(`around=${t.around}`):t.before?n.push(`before=${t.before}`):t.after&&n.push(`after=${t.after}`);let r=i.Endpoints.channelMessages(e.id);return n.length>0&&(r+=`?${n.join("&")}`),this.rest.makeRequest("get",r,!0)}getChannelMessage(e,t){const n=e.messages.get(t);return n?Promise.resolve(n):this.rest.makeRequest("get",i.Endpoints.channelMessage(e.id,t),!0)}getGuildMember(e,t){return this.rest.makeRequest("get",i.Endpoints.guildMember(e.id,t.id),!0).then(t=>this.rest.client.actions.GuildMemberGet.handle(e,t).member)}updateGuildMember(e,t){t.channel&&(t.channel_id=this.rest.client.resolver.resolveChannel(t.channel).id),t.roles&&(t.roles=t.roles.map(e=>e instanceof h?e.id:e));let n=i.Endpoints.guildMember(e.guild.id,e.id);if(e.id===this.rest.client.user.id){const r=Object.keys(t);1===r.length&&"nick"===r[0]&&(n=i.Endpoints.stupidInconsistentGuildEndpoint(e.guild.id))}return this.rest.makeRequest("patch",n,!0,t).then(t=>e.guild._updateMember(e,t).mem)}sendTyping(e){return this.rest.makeRequest("post",`${i.Endpoints.channel(e)}/typing`,!0)}banGuildMember(e,t,n=0){const r=this.rest.client.resolver.resolveUserID(t);return r?this.rest.makeRequest("put",`${i.Endpoints.guildBans(e.id)}/${r}?delete-message-days=${n}`,!0,{"delete-message-days":n}).then(()=>{if(t instanceof c)return t;const n=this.rest.client.resolver.resolveUser(r);return n?(t=this.rest.client.resolver.resolveGuildMember(e,n),t||n):r}):Promise.reject(new Error("Couldn't resolve the user ID to ban."))}unbanGuildMember(e,t){return new Promise((n,r)=>{const s=this.rest.client.resolver.resolveUserID(t);if(!s)throw new Error("Couldn't resolve the user ID to unban.");const o=(t,r)=>{t.id===e.id&&r.id===s&&(this.rest.client.removeListener(i.Events.GUILD_BAN_REMOVE,o),this.rest.client.clearTimeout(a),n(r))};this.rest.client.on(i.Events.GUILD_BAN_REMOVE,o);const a=this.rest.client.setTimeout(()=>{this.rest.client.removeListener(i.Events.GUILD_BAN_REMOVE,o),r(new Error("Took too long to receive the ban remove event."))},1e4);this.rest.makeRequest("del",`${i.Endpoints.guildBans(e.id)}/${s}`,!0).catch(e=>{this.rest.client.removeListener(i.Events.GUILD_BAN_REMOVE,o),this.rest.client.clearTimeout(a),r(e)})})}getGuildBans(e){return this.rest.makeRequest("get",i.Endpoints.guildBans(e.id),!0).then(e=>{const t=new r;for(const n of e){const e=this.rest.client.dataManager.newUser(n.user);t.set(e.id,e)}return t})}updateGuildRole(e,t){const n={};if(n.name=t.name||e.name,n.position="undefined"!=typeof t.position?t.position:e.position,n.color=t.color||e.color,"string"==typeof n.color&&n.color.startsWith("#")&&(n.color=parseInt(n.color.replace("#",""),16)),n.hoist="undefined"!=typeof t.hoist?t.hoist:e.hoist,n.mentionable="undefined"!=typeof t.mentionable?t.mentionable:e.mentionable,t.permissions){let e=0;for(let r of t.permissions)"string"==typeof r&&(r=i.PermissionFlags[r]),e|=r;n.permissions=e}else n.permissions=e.permissions;return this.rest.makeRequest("patch",i.Endpoints.guildRole(e.guild.id,e.id),!0,n).then(t=>this.rest.client.actions.GuildRoleUpdate.handle({role:t,guild_id:e.guild.id}).updated)}pinMessage(e){return this.rest.makeRequest("put",`${i.Endpoints.channel(e.channel.id)}/pins/${e.id}`,!0).then(()=>e)}unpinMessage(e){return this.rest.makeRequest("del",`${i.Endpoints.channel(e.channel.id)}/pins/${e.id}`,!0).then(()=>e)}getChannelPinnedMessages(e){return this.rest.makeRequest("get",`${i.Endpoints.channel(e.id)}/pins`,!0)}createChannelInvite(e,t){const n={};return n.temporary=t.temporary,n.max_age=t.maxAge,n.max_uses=t.maxUses,this.rest.makeRequest("post",`${i.Endpoints.channelInvites(e.id)}`,!0,n).then(e=>new f(this.rest.client,e))}deleteInvite(e){return this.rest.makeRequest("del",i.Endpoints.invite(e.code),!0).then(()=>e)}getInvite(e){return this.rest.makeRequest("get",i.Endpoints.invite(e),!0).then(e=>new f(this.rest.client,e))}getGuildInvites(e){return this.rest.makeRequest("get",i.Endpoints.guildInvites(e.id),!0).then(e=>{const t=new r;for(const n of e){const e=new f(this.rest.client,n);t.set(e.code,e)}return t})}pruneGuildMembers(e,t,n){return this.rest.makeRequest(n?"get":"post",`${i.Endpoints.guildPrune(e.id)}?days=${t}`,!0).then(e=>e.pruned)}createEmoji(e,t,n){return this.rest.makeRequest("post",`${i.Endpoints.guildEmojis(e.id)}`,!0,{name:n,image:t}).then(t=>this.rest.client.actions.EmojiCreate.handle(t,e).emoji)}deleteEmoji(e){return this.rest.makeRequest("delete",`${i.Endpoints.guildEmojis(e.guild.id)}/${e.id}`,!0).then(()=>this.rest.client.actions.EmojiDelete.handle(e).data)}getWebhook(e,t){return this.rest.makeRequest("get",i.Endpoints.webhook(e,t),!t).then(e=>new u(this.rest.client,e))}getGuildWebhooks(e){return this.rest.makeRequest("get",i.Endpoints.guildWebhooks(e.id),!0).then(e=>{const t=new r;for(const n of e)t.set(n.id,new u(this.rest.client,n));return t})}getChannelWebhooks(e){return this.rest.makeRequest("get",i.Endpoints.channelWebhooks(e.id),!0).then(e=>{const t=new r;for(const n of e)t.set(n.id,new u(this.rest.client,n));return t})}createWebhook(e,t,n){return this.rest.makeRequest("post",i.Endpoints.channelWebhooks(e.id),!0,{name:t,avatar:n}).then(e=>new u(this.rest.client,e))}editWebhook(e,t,n){return this.rest.makeRequest("patch",i.Endpoints.webhook(e.id,e.token),!1,{name:t,avatar:n}).then(t=>{return e.name=t.name,e.avatar=t.avatar,e})}deleteWebhook(e){return this.rest.makeRequest("delete",i.Endpoints.webhook(e.id,e.token),!1)}sendWebhookMessage(e,t,{avatarURL,tts,disableEveryone,embeds}={},n=null){return"undefined"!=typeof t&&(t=this.rest.client.resolver.resolveString(t)),t&&(disableEveryone||"undefined"==typeof disableEveryone&&this.rest.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),this.rest.makeRequest("post",`${i.Endpoints.webhook(e.id,e.token)}?wait=true`,!1,{username:e.name,avatar_url:avatarURL,content:t,tts:tts,file:n,embeds:embeds})}sendSlackWebhookMessage(e,t){return this.rest.makeRequest("post",`${i.Endpoints.webhook(e.id,e.token)}/slack?wait=true`,!1,t)}fetchUserProfile(e){return this.rest.makeRequest("get",i.Endpoints.userProfile(e.id),!0).then(t=>new d(e,t))}addFriend(e){return this.rest.makeRequest("post",i.Endpoints.relationships("@me"),!0,{username:e.username,discriminator:e.discriminator}).then(()=>e)}removeFriend(e){return this.rest.makeRequest("delete",`${i.Endpoints.relationships("@me")}/${e.id}`,!0).then(()=>e)}blockUser(e){return this.rest.makeRequest("put",`${i.Endpoints.relationships("@me")}/${e.id}`,!0,{type:2}).then(()=>e)}unblockUser(e){return this.rest.makeRequest("delete",`${i.Endpoints.relationships("@me")}/${e.id}`,!0).then(()=>e)}setRolePositions(e,t){return this.rest.makeRequest("patch",i.Endpoints.guildRoles(e),!0,t).then(()=>this.rest.client.actions.GuildRolesPositionUpdate.handle({guild_id:e,roles:t}).guild)}addMessageReaction(e,t){return this.rest.makeRequest("put",i.Endpoints.selfMessageReaction(e.channel.id,e.id,t),!0).then(()=>this.rest.client.actions.MessageReactionAdd.handle({user_id:this.rest.client.user.id,message_id:e.id,emoji:o(t),channel_id:e.channel.id}).reaction)}removeMessageReaction(e,t,n){let r=i.Endpoints.selfMessageReaction(e.channel.id,e.id,t);return n.id!==this.rest.client.user.id&&(r=i.Endpoints.userMessageReaction(e.channel.id,e.id,t,null,n.id)),this.rest.makeRequest("delete",r,!0).then(()=>this.rest.client.actions.MessageReactionRemove.handle({user_id:n.id,message_id:e.id,emoji:o(t),channel_id:e.channel.id}).reaction)}removeMessageReactions(e){this.rest.makeRequest("delete",i.Endpoints.messageReactions(e.channel.id,e.id),!0).then(()=>e)}getMessageReactionUsers(e,t,n=100){return this.rest.makeRequest("get",i.Endpoints.messageReaction(e.channel.id,e.id,t,n),!0)}getMyApplication(){return this.rest.makeRequest("get",i.Endpoints.myApplication,!0).then(e=>new l(this.rest.client,e))}setNote(e,t){return this.rest.makeRequest("put",i.Endpoints.note(e.id),!0,{note:t}).then(()=>e)}}e.exports=p},function(e,t,n){const i=n(132);class r extends i{constructor(e,t){super(e,t),this.requestRemaining=1,this.first=!0}push(e){super.push(e),this.handle()}handleNext(e){this.waiting||(this.waiting=!0,this.restManager.client.setTimeout(()=>{this.requestRemaining=this.requestLimit,this.waiting=!1,this.handle()},e))}execute(e){e.request.gen().end((t,n)=>{if(n&&n.headers&&(this.requestLimit=n.headers["x-ratelimit-limit"],this.requestResetTime=1e3*Number(n.headers["x-ratelimit-reset"]),this.requestRemaining=Number(n.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(n.headers.date).getTime(),this.handleNext(this.requestResetTime-Date.now()+this.timeDifference+1e3)),t)429===t.status?(this.requestRemaining=0,this.queue.unshift(e),this.restManager.client.setTimeout(()=>{this.globalLimit=!1,this.handle()},Number(n.headers["retry-after"])+500),n.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):e.reject(t);else{this.globalLimit=!1;const t=n&&n.body?n.body:{};e.resolve(t),this.first&&(this.first=!1,this.handle())}})}handle(){if(super.handle(),!(this.requestRemaining<1||0===this.queue.length||this.globalLimit))for(;this.queue.length>0&&this.requestRemaining>0;)this.execute(this.queue.shift()),this.requestRemaining--}}e.exports=r},function(e,t,n){const i=n(132);class r extends i{constructor(e,t){super(e,t),this.waiting=!1,this.endpoint=t,this.timeDifference=0}push(e){super.push(e),this.handle()}execute(e){return new Promise(t=>{e.request.gen().end((n,i)=>{if(i&&i.headers&&(this.requestLimit=i.headers["x-ratelimit-limit"],this.requestResetTime=1e3*Number(i.headers["x-ratelimit-reset"]),this.requestRemaining=Number(i.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(i.headers.date).getTime()),n)429===n.status?(this.restManager.client.setTimeout(()=>{this.waiting=!1,this.globalLimit=!1,t()},Number(i.headers["retry-after"])+500),i.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):(this.queue.shift(),this.waiting=!1,e.reject(n),t(n));else{this.queue.shift(),this.globalLimit=!1;const n=i&&i.body?i.body:{};e.resolve(n),0===this.requestRemaining?this.restManager.client.setTimeout(()=>{this.waiting=!1,t(n)},this.requestResetTime-Date.now()+this.timeDifference+1e3):(this.waiting=!1,t(n))}})})}handle(){if(super.handle(),!this.waiting&&0!==this.queue.length&&!this.globalLimit){this.waiting=!0;const e=this.queue[0];this.execute(e).then(()=>this.handle())}}}e.exports=r},function(e,t,n){const i=n(1);class r{constructor(e){this.restManager=e,this._userAgent={url:"https://github.com/hydrabolt/discord.js",version:i.Package.version}}set(e){this._userAgent.url=e.url||"https://github.com/hydrabolt/discord.js",this._userAgent.version=e.version||i.Package.version}get userAgent(){return`DiscordBot (${this._userAgent.url}, ${this._userAgent.version})`}}e.exports=r},function(e,t,n){const i=n(6),r=n(45),s=n(1),o=n(283),a=n(5).EventEmitter;class c{constructor(e){this.client=e,this.connections=new i,this.pending=new i,this.client.on("self.voiceServer",this.onVoiceServer.bind(this)),this.client.on("self.voiceStateUpdate",this.onVoiceStateUpdate.bind(this))}onVoiceServer(e){this.pending.has(e.guild_id)&&this.pending.get(e.guild_id).setTokenAndEndpoint(e.token,e.endpoint)}onVoiceStateUpdate(e){this.pending.has(e.guild_id)&&this.pending.get(e.guild_id).setSessionID(e.session_id)}sendVoiceStateUpdate(e,t={}){if(!this.client.user)throw new Error("Unable to join because there is no client user.");if(!e.permissionsFor)throw new Error("Channel does not support permissionsFor; is it really a voice channel?");const n=e.permissionsFor(this.client.user);if(!n)throw new Error("There is no permission set for the client user in this channel - are they part of the guild?");if(!n.hasPermission("CONNECT"))throw new Error("You do not have permission to join this voice channel.");t=r({guild_id:e.guild.id,channel_id:e.id,self_mute:!1,self_deaf:!1},t),this.client.ws.send({op:s.OPCodes.VOICE_STATE_UPDATE,d:t})}joinChannel(e){return new Promise((t,n)=>{if(this.client.browser)throw new Error("Voice connections are not available in browsers.");if(this.pending.get(e.guild.id))throw new Error("Already connecting to this guild's voice server.");if(!e.joinable)throw new Error("You do not have permission to join this voice channel.");const i=this.connections.get(e.guild.id);if(i)return i.channel.id!==e.id&&(this.sendVoiceStateUpdate(e),this.connections.get(e.guild.id).channel=e),void t(i);const r=new h(this,e);this.pending.set(e.guild.id,r),r.on("fail",t=>{this.pending.delete(e.guild.id),n(t)}),r.on("pass",i=>{this.pending.delete(e.guild.id),this.connections.set(e.guild.id,i),i.once("ready",()=>t(i)),i.once("error",n),i.once("disconnect",()=>this.connections.delete(e.guild.id))})})}}class h extends a{constructor(e,t){super(),this.voiceManager=e,this.channel=t,this.deathTimer=this.voiceManager.client.setTimeout(()=>this.fail(new Error("Connection not established within 15 seconds.")),15e3),this.data={},this.sendVoiceStateUpdate()}checkReady(){return!!(this.data.token&&this.data.endpoint&&this.data.session_id)&&(this.pass(),!0)}setTokenAndEndpoint(e,t){return e?t?this.data.token?void this.fail(new Error("There is already a registered token for this connection.")):this.data.endpoint?void this.fail(new Error("There is already a registered endpoint for this connection.")):(t=t.match(/([^:]*)/)[0])?(this.data.token=e,this.data.endpoint=t,void this.checkReady()):void this.fail(new Error("Failed to find an endpoint.")):void this.fail(new Error("Endpoint not provided from voice server packet.")):void this.fail(new Error("Token not provided from voice server packet."))}setSessionID(e){return e?this.data.session_id?void this.fail(new Error("There is already a registered session ID for this connection.")):(this.data.session_id=e,void this.checkReady()):void this.fail(new Error("Session ID not supplied."))}clean(){clearInterval(this.deathTimer),this.emit("fail",new Error("Clean-up triggered :fourTriggered:"))}pass(){clearInterval(this.deathTimer),this.emit("pass",this.upgrade())}fail(e){this.emit("fail",e),this.clean()}sendVoiceStateUpdate(){try{this.voiceManager.sendVoiceStateUpdate(this.channel)}catch(e){this.fail(e)}}upgrade(){return new o(this)}}e.exports=c},function(e,t,n){const i=n(285),r=n(284),s=n(1),o=n(293),a=n(295),c=n(5).EventEmitter,h=n(13);class f extends c{constructor(e){super(),this.voiceManager=e.voiceManager,this.channel=e.channel,this.speaking=!1,this.receivers=[],this.authentication=e.data,this.player=new o(this),this.player.on("debug",e=>{this.emit("debug",`audio player - ${e}`)}),this.player.on("error",e=>{this.emit("warn",e),this.player.cleanup()}),this.ssrcMap=new Map,this.ready=!1,this.sockets={},this.connect()}setSpeaking(e){this.speaking!==e&&(this.speaking=e,this.sockets.ws.sendPacket({op:s.VoiceOPCodes.SPEAKING,d:{speaking:!0,delay:0}}).catch(e=>{this.emit("debug",e)}))}disconnect(){this.emit("closing"),this.voiceManager.client.ws.send({op:s.OPCodes.VOICE_STATE_UPDATE,d:{guild_id:this.channel.guild.id,channel_id:null,self_mute:!1,self_deaf:!1}}),this.emit("disconnect")}connect(){if(this.sockets.ws)throw new Error("There is already an existing WebSocket connection.");if(this.sockets.udp)throw new Error("There is already an existing UDP connection.");this.sockets.ws=new i(this),this.sockets.udp=new r(this),this.sockets.ws.on("error",e=>this.emit("error",e)),this.sockets.udp.on("error",e=>this.emit("error",e)),this.sockets.ws.once("ready",e=>{this.authentication.port=e.port,this.authentication.ssrc=e.ssrc,this.sockets.udp.findEndpointAddress().then(e=>{this.sockets.udp.createUDPSocket(e)},e=>this.emit("error",e))}),this.sockets.ws.once("sessionDescription",(e,t)=>{this.authentication.encryptionMode=e,this.authentication.secretKey=t,this.emit("ready"),this.ready=!0}),this.sockets.ws.on("speaking",e=>{const t=this.channel.guild,n=this.voiceManager.client.users.get(e.user_id);if(this.ssrcMap.set(+e.ssrc,n),!e.speaking)for(const i of this.receivers){const e=i.opusStreams.get(n.id),t=i.pcmStreams.get(n.id);e&&(e.push(null),e.open=!1,i.opusStreams.delete(n.id)),t&&(t.push(null),t.open=!1,i.pcmStreams.delete(n.id))}this.ready&&this.emit("speaking",n,e.speaking),t._memberSpeakUpdate(e.user_id,e.speaking)})}playFile(e,t){return this.playStream(h.createReadStream(e),t)}playStream(e,{seek=0,volume=1,passes=1}={}){const t={seek:seek,volume:volume,passes:passes};return this.player.playUnknownStream(e,t)}playConvertedStream(e,{seek=0,volume=1,passes=1}={}){const t={seek:seek,volume:volume,passes:passes};return this.player.playPCMStream(e,t)}createReceiver(){const e=new a(this);return this.receivers.push(e),e}}e.exports=f},function(e,t,n){(function(t){function i(e){try{const n=new t(e);let i="";for(let r=4;r{s.lookup(this.voiceConnection.authentication.endpoint,(n,i)=>{return n?void t(n):(this.discordAddress=i,void e(i))})})}send(e){return new Promise((t,n)=>{if(!this.socket)throw new Error("Tried to send a UDP packet, but there is no socket available.");if(!this.discordAddress||!this.discordPort)throw new Error("Malformed UDP address or port.");this.socket.send(e,0,e.length,this.discordPort,this.discordAddress,i=>{i?n(i):t(e)})})}createUDPSocket(e){this.discordAddress=e;const n=this.socket=r.createSocket("udp4");n.once("message",e=>{const t=i(e);return t.error?void this.emit("error",t.error):(this.localAddress=t.address,this.localPort=t.port,void this.voiceConnection.sockets.ws.sendPacket({op:o.VoiceOPCodes.SELECT_PROTOCOL,d:{protocol:"udp",data:{address:t.address,port:t.port,mode:"xsalsa20_poly1305"}}}))});const s=new t(70);s.writeUIntBE(this.voiceConnection.authentication.ssrc,0,4),this.send(s)}}e.exports=c}).call(t,n(0).Buffer)},function(e,t,n){const i=n(123),r=n(1),s=n(296),o=n(5).EventEmitter;class a extends o{constructor(e){super(),this.voiceConnection=e,this.attempts=0,this.connect(),this.dead=!1,this.voiceConnection.on("closing",this.shutdown.bind(this))}shutdown(){this.dead=!0,this.reset()}get client(){return this.voiceConnection.voiceManager.client}reset(){this.ws&&(this.ws.readyState!==i.CLOSED&&this.ws.close(),this.ws=null),this.clearHeartbeat()}connect(){if(!this.dead){if(this.ws&&this.reset(),this.attempts>5)return void this.emit("error",new Error(`Too many connection attempts (${this.attempts}).`));this.attempts++,this.ws=new i(`wss://${this.voiceConnection.authentication.endpoint}`),this.ws.onopen=this.onOpen.bind(this),this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this),this.ws.onerror=this.onError.bind(this)}}send(e){return new Promise((t,n)=>{if(!this.ws||this.ws.readyState!==i.OPEN)throw new Error(`Voice websocket not open to send ${e}.`);this.ws.send(e,null,i=>{i?n(i):t(e)})})}sendPacket(e){try{e=JSON.stringify(e)}catch(e){return Promise.reject(e)}return this.send(e)}onOpen(){this.sendPacket({op:r.OPCodes.DISPATCH,d:{server_id:this.voiceConnection.channel.guild.id,user_id:this.client.user.id,token:this.voiceConnection.authentication.token, -session_id:this.voiceConnection.authentication.session_id}}).catch(()=>{this.emit("error",new Error("Tried to send join packet, but the WebSocket is not open."))})}onMessage(e){try{return this.onPacket(JSON.parse(e.data))}catch(e){return this.onError(e)}}onClose(){this.dead||this.client.setTimeout(this.connect.bind(this),1e3*this.attempts)}onError(e){this.emit("error",e)}onPacket(e){switch(e.op){case r.VoiceOPCodes.READY:this.setHeartbeat(e.d.heartbeat_interval),this.emit("ready",e.d);break;case r.VoiceOPCodes.SESSION_DESCRIPTION:this.emit("sessionDescription",e.d.mode,new s(e.d.secret_key));break;case r.VoiceOPCodes.SPEAKING:this.emit("speaking",e.d);break;default:this.emit("unknownPacket",e)}}setHeartbeat(e){return!e||isNaN(e)?void this.onError(new Error("Tried to set voice heartbeat but no valid interval was specified.")):(this.heartbeatInterval&&(this.emit("warn","A voice heartbeat interval is being overwritten"),clearInterval(this.heartbeatInterval)),void(this.heartbeatInterval=this.client.setInterval(this.sendHeartbeat.bind(this),e)))}clearHeartbeat(){return this.heartbeatInterval?(clearInterval(this.heartbeatInterval),void(this.heartbeatInterval=null)):void this.emit("warn","Tried to clear a heartbeat interval that does not exist")}sendHeartbeat(){this.sendPacket({op:r.VoiceOPCodes.HEARTBEAT,d:null}).catch(()=>{this.emit("warn","Tried to send heartbeat, but connection is not open"),this.clearHeartbeat()})}}e.exports=a},function(e,t,n){(function(t){const i=n(5).EventEmitter,r=n(120),s=new t(24);s.fill(0);class o extends i{constructor(e,t,n,i){super(),this.player=e,this.stream=t,this.streamingData={channels:2,count:0,sequence:n.sequence,timestamp:n.timestamp,pausedTime:0},this._startStreaming(),this._triggered=!1,this._volume=i.volume,this.passes=i.passes||1,this.paused=!1,this.setVolume(i.volume||1)}get time(){return this.streamingData.count*(this.streamingData.length||0)}get totalStreamTime(){return this.time+this.streamingData.pausedTime}get volume(){return this._volume}setVolume(e){this._volume=e}setVolumeDecibels(e){this._volume=Math.pow(10,e/20)}setVolumeLogarithmic(e){this._volume=Math.pow(e,1.660964)}pause(){this._setPaused(!0)}resume(){this._setPaused(!1)}end(){this._triggerTerminalState("end","user requested")}_setSpeaking(e){this.speaking=e,this.emit("speaking",e)}_sendBuffer(e,t,n){let i=this.passes;const r=this._createPacket(t,n,this.player.opusEncoder.encode(e));for(;i--;)this.player.voiceConnection.sockets.udp.send(r).catch(e=>this.emit("debug",`Failed to send a packet ${e}`))}_createPacket(e,n,i){const o=new t(i.length+28);o.fill(0),o[0]=128,o[1]=120,o.writeUIntBE(e,2,2),o.writeUIntBE(n,4,4),o.writeUIntBE(this.player.voiceConnection.authentication.ssrc,8,4),o.copy(s,0,0,12),i=r.secretbox(i,s,this.player.voiceConnection.authentication.secretKey.key);for(let a=0;a=e.length-1);i+=2){const t=Math.min(32767,Math.max(-32767,Math.floor(this._volume*e.readInt16LE(i))));n.writeInt16LE(t,i)}return n}_send(){try{if(this._triggered)return void this._setSpeaking(!1);const e=this.streamingData;if(e.missed>=5)return void this._triggerTerminalState("end","Stream is not generating quickly enough.");if(this.paused)return e.pausedTime+=10*e.length,void this.player.voiceConnection.voiceManager.client.setTimeout(()=>this._send(),10*e.length);this._setSpeaking(!0),e.startTime||(this.emit("start"),e.startTime=Date.now());const n=1920*e.channels;let i=this.stream.read(n);if(!i)return e.missed++,e.pausedTime+=10*e.length,void this.player.voiceConnection.voiceManager.client.setTimeout(()=>this._send(),10*e.length);if(e.missed=0,i.length!==n){const e=new t(n).fill(0);i.copy(e),i=e}i=this._applyVolume(i),e.count++,e.sequence=e.sequence+1<65536?e.sequence+1:0,e.timestamp=e.timestamp+4294967295?e.timestamp+960:0,this._sendBuffer(i,e.sequence,e.timestamp);const r=e.length+(e.startTime+e.pausedTime+e.count*e.length-Date.now());this.player.voiceConnection.voiceManager.client.setTimeout(()=>this._send(),r)}catch(e){this._triggerTerminalState("error",e)}}_triggerEnd(){this.emit("end")}_triggerError(e){this.emit("end"),this.emit("error",e)}_triggerTerminalState(e,t){if(!this._triggered)switch(this.emit("debug",`Triggered terminal state ${e} - stream is now dead`),this._triggered=!0,this._setSpeaking(!1),e){case"end":this._triggerEnd(t);break;case"error":this._triggerError(t);break;default:this.emit("error","Unknown trigger state")}}_startStreaming(){if(!this.stream)return void this.emit("error","No stream");this.stream.on("end",e=>this._triggerTerminalState("end",e)),this.stream.on("error",e=>this._triggerTerminalState("error",e));const e=this.streamingData;e.length=20,e.missed=0,this.stream.once("readable",()=>this._send())}_setPaused(e){e?(this.paused=!0,this._setSpeaking(!1)):(this.paused=!1,this._setSpeaking(!0))}}e.exports=o}).call(t,n(0).Buffer)},function(e,t,n){const i=n(133);let r;class s extends i{constructor(e){super(e);try{r=n(335)}catch(e){throw e}this.encoder=new r.OpusEncoder(48e3,2)}encode(e){return super.encode(e),this.encoder.encode(e,1920)}decode(e){return super.decode(e),this.encoder.decode(e,1920)}}e.exports=s},function(e,t,n){function i(e){try{return new e}catch(e){return null}}const r=[n(287),n(289)];t.add=(e=>{r.push(e)}),t.fetch=(()=>{for(const e of r){const t=i(e);if(t)return t}throw new Error("Couldn't find an Opus engine.")})},function(e,t,n){const i=n(133);let r;class s extends i{constructor(e){super(e);try{r=n(336)}catch(e){throw e}this.encoder=new r(48e3,2)}encode(e){return super.encode(e),this.encoder.encode(e,960)}decode(e){return super.decode(e),this.encoder.decode(e)}}e.exports=s},function(e,t,n){const i=n(5).EventEmitter;class r extends i{constructor(e){super(),this.player=e}createConvertStream(){}}e.exports=r},function(e,t,n){t.fetch=(()=>n(292))},function(e,t,n){function i(){for(const e of["ffmpeg","avconv","./ffmpeg","./avconv"])if(!s.spawnSync(e,["-h"]).error)return e;throw new Error("FFMPEG was not found on your system, so audio cannot be played. Please make sure FFMPEG is installed and in your PATH.")}const r=n(290),s=n(13),o=n(5).EventEmitter;class a extends o{constructor(e){super(),this.process=e,this.input=null,this.process.on("error",e=>this.emit("error",e))}setInput(e){this.input=e,e.pipe(this.process.stdin,{end:!1}),this.input.on("error",e=>this.emit("error",e)),this.process.stdin.on("error",e=>this.emit("error",e))}destroy(){this.emit("debug","destroying a ffmpeg process:"),this.input&&this.input.unpipe&&this.process.stdin&&(this.input.unpipe(this.process.stdin),this.emit("unpiped the user input stream from the process input stream")),this.process.stdin&&(this.process.stdin.end(),this.emit("ended the process stdin")),this.process.stdin.destroy&&(this.process.stdin.destroy(),this.emit("destroyed the process stdin")),this.process.kill&&(this.process.kill(),this.emit("killed the process"))}}class c extends r{constructor(e){super(e),this.command=i()}handleError(e,t){e.destroy&&e.destroy(),this.emit("error",t)}createConvertStream(e=0){super.createConvertStream();const t=s.spawn(this.command,["-analyzeduration","0","-loglevel","0","-i","-","-f","s16le","-ar","48000","-ac","2","-ss",String(e),"pipe:1"],{stdio:["pipe","pipe","ignore"]});return new a(t)}}e.exports=c},function(e,t,n){const i=n(291),r=n(288),s=n(5).EventEmitter,o=n(286);class a extends s{constructor(e){super(),this.voiceConnection=e,this.audioToPCM=new(i.fetch()),this.opusEncoder=r.fetch(),this.currentConverter=null,this.dispatcher=null,this.audioToPCM.on("error",e=>this.emit("error",e)),this.streamingData={channels:2,count:0,sequence:0,timestamp:0,pausedTime:0},this.voiceConnection.on("closing",()=>this.cleanup(null,"voice connection closing"))}playUnknownStream(e,{seek=0,volume=1,passes=1}={}){const t={seek:seek,volume:volume,passes:passes};e.on("end",()=>{this.emit("debug","Input stream to converter has ended")}),e.on("error",e=>this.emit("error",e));const n=this.audioToPCM.createConvertStream(t.seek);return n.on("error",e=>this.emit("error",e)),n.setInput(e),this.playPCMStream(n.process.stdout,n,t)}cleanup(e,t){this.emit("debug",`Clean up triggered due to ${t}`);const n=e&&this.dispatcher&&this.dispatcher.stream===e;!this.currentConverter||e&&!n||(this.currentConverter.destroy(),this.currentConverter=null)}playPCMStream(e,t,{seek=0,volume=1,passes=1}={}){const n={seek:seek,volume:volume,passes:passes};e.on("end",()=>this.emit("debug","PCM input stream ended")),this.cleanup(null,"outstanding play stream"),this.currentConverter=t,this.dispatcher&&(this.streamingData=this.dispatcher.streamingData),e.on("error",e=>this.emit("error",e));const i=new o(this,e,this.streamingData,n);return i.on("error",e=>this.emit("error",e)),i.on("end",()=>this.cleanup(i.stream,"dispatcher ended")),i.on("speaking",e=>this.voiceConnection.setSpeaking(e)),this.dispatcher=i,i.on("debug",e=>this.emit("debug",`Stream dispatch - ${e}`)),i}}e.exports=a},function(e,t,n){const i=n(11).Readable;class r extends i{constructor(){super(),this._packets=[],this.open=!0}_read(){}_push(e){this.open&&this.push(e)}}e.exports=r},function(e,t,n){(function(t){const i=n(5).EventEmitter,r=n(120),s=n(294),o=new t(24);o.fill(0);class a extends i{constructor(e){super(),this.queues=new Map,this.pcmStreams=new Map,this.opusStreams=new Map,this.destroyed=!1,this.voiceConnection=e,this._listener=(e=>{const t=+e.readUInt32BE(8).toString(10),n=this.voiceConnection.ssrcMap.get(t);if(n){if(this.queues.get(t))return this.queues.get(t).push(e),this.queues.get(t).map(e=>this.handlePacket(e,n)),void this.queues.delete(t);this.handlePacket(e,n)}else this.queues.has(t)||this.queues.set(t,[]),this.queues.get(t).push(e)}),this.voiceConnection.sockets.udp.socket.on("message",this._listener)}recreate(){this.destroyed&&(this.voiceConnection.sockets.udp.socket.on("message",this._listener),this.destroyed=!1)}destroy(){this.voiceConnection.sockets.udp.socket.removeListener("message",this._listener);for(const e of this.pcmStreams)e[1]._push(null),this.pcmStreams.delete(e[0]);for(const e of this.opusStreams)e[1]._push(null),this.opusStreams.delete(e[0]);this.destroyed=!0}createOpusStream(e){if(e=this.voiceConnection.voiceManager.client.resolver.resolveUser(e),!e)throw new Error("Couldn't resolve the user to create Opus stream.");if(this.opusStreams.get(e.id))throw new Error("There is already an existing stream for that user.");const t=new s;return this.opusStreams.set(e.id,t),t}createPCMStream(e){if(e=this.voiceConnection.voiceManager.client.resolver.resolveUser(e),!e)throw new Error("Couldn't resolve the user to create PCM stream.");if(this.pcmStreams.get(e.id))throw new Error("There is already an existing stream for that user.");const t=new s;return this.pcmStreams.set(e.id,t),t}handlePacket(e,n){e.copy(o,0,0,12);let i=r.secretbox.open(e.slice(12),o,this.voiceConnection.authentication.secretKey.key);if(!i)return void this.emit("warn","Failed to decrypt voice packet");if(i=new t(i),this.opusStreams.get(n.id)&&this.opusStreams.get(n.id)._push(i),this.emit("opus",n,i),this.listenerCount("pcm")>0||this.pcmStreams.size>0){const e=this.voiceConnection.player.opusEncoder.decode(i);this.pcmStreams.get(n.id)&&this.pcmStreams.get(n.id)._push(e),this.emit("pcm",n,e)}}}e.exports=a}).call(t,n(0).Buffer)},function(e,t){class n{constructor(e){this.key=new Uint8Array(new ArrayBuffer(e.length));for(const t in e)this.key[t]=e[t]}}e.exports=n},function(e,t,n){const i="undefined"!=typeof window,r=i?window.WebSocket:n(123),s=n(5).EventEmitter,o=n(1),a=i?n(247).inflateSync:n(101).inflateSync,c=n(298),h=n(134);class f extends s{constructor(e){super(),this.client=e,this.packetManager=new c(this),this.status=o.Status.IDLE,this.sessionID=null,this.sequence=-1,this.gateway=null,this.normalReady=!1,this.ws=null,this.disabledEvents={};for(const t in e.options.disabledEvents)this.disabledEvents[t]=!0;this.first=!0}_connect(e){this.client.emit("debug",`Connecting to gateway ${e}`),this.normalReady=!1,this.status!==o.Status.RECONNECTING&&(this.status=o.Status.CONNECTING),this.ws=new r(e),i&&(this.ws.binaryType="arraybuffer"),this.ws.onopen=(()=>this.eventOpen()),this.ws.onclose=(e=>this.eventClose(e)),this.ws.onmessage=(e=>this.eventMessage(e)),this.ws.onerror=(e=>this.eventError(e)),this._queue=[],this._remaining=3}connect(e){this.first?(this._connect(e),this.first=!1):this.client.setTimeout(()=>this._connect(e),5500)}send(e,t=false){return t?void this._send(JSON.stringify(e)):(this._queue.push(JSON.stringify(e)),void this.doQueue())}destroy(){this.ws.close(1e3),this._queue=[],this.status=o.Status.IDLE}_send(e){this.ws.readyState===r.OPEN&&(this.emit("send",e),this.ws.send(e))}doQueue(){const e=this._queue[0];if(this.ws.readyState===r.OPEN&&e){if(0===this._remaining)return void this.client.setTimeout(()=>{this.doQueue()},1e3);this._remaining--,this._send(e),this._queue.shift(),this.doQueue(),this.client.setTimeout(()=>this._remaining++,1e3)}}eventOpen(){this.client.emit("debug","Connection to gateway opened"),this.status===o.Status.RECONNECTING?this._sendResume():this._sendNewIdentify()}_sendResume(){if(!this.sessionID)return void this._sendNewIdentify();this.client.emit("debug","Identifying as resumed session");const e={token:this.client.token,session_id:this.sessionID,seq:this.sequence};this.send({op:o.OPCodes.RESUME,d:e})}_sendNewIdentify(){this.reconnecting=!1;const e=this.client.options.ws;e.token=this.client.token,this.client.options.shardCount>0&&(e.shard=[Number(this.client.options.shardId),Number(this.client.options.shardCount)]),this.client.emit("debug","Identifying as new session"),this.send({op:o.OPCodes.IDENTIFY,d:e}),this.sequence=-1}eventClose(e){this.emit("close",e),this.client.clearInterval(this.client.manager.heartbeatInterval),this.reconnecting||this.client.emit(o.Events.DISCONNECT),4004!==e.code&&4010!==e.code&&(this.reconnecting||1e3===e.code||this.tryReconnect())}eventMessage(e){let t=e.data;try{"string"!=typeof t&&(t instanceof ArrayBuffer&&(t=h(t)),t=a(t).toString()),t=JSON.parse(t)}catch(e){return this.eventError(new Error(o.Errors.BAD_WS_MESSAGE))}return this.client.emit("raw",t),t.op===o.OPCodes.HELLO&&this.client.manager.setupKeepAlive(t.d.heartbeat_interval),this.packetManager.handle(t)}eventError(e){this.client.listenerCount("error")>0&&this.client.emit("error",e),this.ws.close()}_emitReady(e=true){this.status=o.Status.READY,this.client.emit(o.Events.READY),this.packetManager.handleQueue(),this.normalReady=e}checkIfReady(){if(this.status!==o.Status.READY&&this.status!==o.Status.NEARLY){let e=0;for(const t of this.client.guilds.keys())e+=this.client.guilds.get(t).available?0:1;if(0===e){if(this.status=o.Status.NEARLY,this.client.options.fetchAllMembers){const e=this.client.guilds.map(e=>e.fetchMembers());return void Promise.all(e).then(()=>this._emitReady(),e=>{this.client.emit(o.Events.WARN,"Error in pre-ready guild member fetching"),this.client.emit(o.Events.ERROR,e),this._emitReady()})}this._emitReady()}}}tryReconnect(){this.status=o.Status.RECONNECTING,this.ws.close(),this.packetManager.handleQueue(),this.client.emit(o.Events.RECONNECTING),this.connect(this.client.ws.gateway)}}e.exports=f},function(e,t,n){const i=n(1),r=[i.WSEvents.READY,i.WSEvents.GUILD_CREATE,i.WSEvents.GUILD_DELETE,i.WSEvents.GUILD_MEMBERS_CHUNK,i.WSEvents.GUILD_MEMBER_ADD,i.WSEvents.GUILD_MEMBER_REMOVE];class s{constructor(e){this.ws=e,this.handlers={},this.queue=[],this.register(i.WSEvents.READY,n(324)),this.register(i.WSEvents.GUILD_CREATE,n(305)),this.register(i.WSEvents.GUILD_DELETE,n(306)),this.register(i.WSEvents.GUILD_UPDATE,n(315)),this.register(i.WSEvents.GUILD_BAN_ADD,n(303)),this.register(i.WSEvents.GUILD_BAN_REMOVE,n(304)),this.register(i.WSEvents.GUILD_MEMBER_ADD,n(307)),this.register(i.WSEvents.GUILD_MEMBER_REMOVE,n(308)),this.register(i.WSEvents.GUILD_MEMBER_UPDATE,n(309)),this.register(i.WSEvents.GUILD_ROLE_CREATE,n(311)),this.register(i.WSEvents.GUILD_ROLE_DELETE,n(312)),this.register(i.WSEvents.GUILD_ROLE_UPDATE,n(313)),this.register(i.WSEvents.GUILD_MEMBERS_CHUNK,n(310)),this.register(i.WSEvents.CHANNEL_CREATE,n(299)),this.register(i.WSEvents.CHANNEL_DELETE,n(300)),this.register(i.WSEvents.CHANNEL_UPDATE,n(302)),this.register(i.WSEvents.CHANNEL_PINS_UPDATE,n(301)),this.register(i.WSEvents.PRESENCE_UPDATE,n(323)),this.register(i.WSEvents.USER_UPDATE,n(329)),this.register(i.WSEvents.USER_NOTE_UPDATE,n(328)),this.register(i.WSEvents.VOICE_STATE_UPDATE,n(331)),this.register(i.WSEvents.TYPING_START,n(327)),this.register(i.WSEvents.MESSAGE_CREATE,n(316)),this.register(i.WSEvents.MESSAGE_DELETE,n(317)),this.register(i.WSEvents.MESSAGE_UPDATE,n(322)),this.register(i.WSEvents.MESSAGE_DELETE_BULK,n(318)),this.register(i.WSEvents.VOICE_SERVER_UPDATE,n(330)),this.register(i.WSEvents.GUILD_SYNC,n(314)),this.register(i.WSEvents.RELATIONSHIP_ADD,n(325)),this.register(i.WSEvents.RELATIONSHIP_REMOVE,n(326)),this.register(i.WSEvents.MESSAGE_REACTION_ADD,n(319)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE,n(320)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE_ALL,n(321))}get client(){return this.ws.client}register(e,t){this.handlers[e]=new t(this)}handleQueue(){this.queue.forEach((e,t)=>{this.handle(this.queue[t]),this.queue.splice(t,1)})}setSequence(e){e&&e>this.ws.sequence&&(this.ws.sequence=e)}handle(e){return e.op===i.OPCodes.RECONNECT?(this.setSequence(e.s),this.ws.tryReconnect(),!1):e.op===i.OPCodes.INVALID_SESSION?(this.ws.sessionID=null,this.ws._sendNewIdentify(),!1):(e.op===i.OPCodes.HEARTBEAT_ACK&&this.ws.client.emit("debug","Heartbeat acknowledged"),this.ws.status===i.Status.RECONNECTING&&(this.ws.reconnecting=!1,this.ws.checkIfReady()),this.setSequence(e.s),void 0===this.ws.disabledEvents[e.t]&&(this.ws.status!==i.Status.READY&&r.indexOf(e.t)===-1?(this.queue.push(e),!1):!!this.handlers[e.t]&&this.handlers[e.t].handle(e)))}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.ChannelCreate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.ChannelDelete.handle(n);i.channel&&t.emit(r.Events.CHANNEL_DELETE,i.channel)}}e.exports=s},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.channels.get(n.channel_id),s=new Date(n.last_pin_timestamp);i&&s&&t.emit(r.Events.CHANNEL_PINS_UPDATE,i,s)}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.ChannelUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id),s=t.users.get(n.user.id);i&&s&&t.emit(r.Events.GUILD_BAN_ADD,i,s)}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildBanRemove.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.id);i?i.available||n.unavailable||(i.setup(n),this.packetManager.ws.checkIfReady()):t.dataManager.newGuild(n)}}e.exports=r},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.GuildDelete.handle(n);i.guild&&t.emit(r.Events.GUILD_DELETE,i.guild)}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);i&&(i.memberCount++,i._addMember(n))}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildMemberRemove.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=i.members.get(n.user.id);e&&i._updateMember(e,n)}}}e.exports=r},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id),s=[];if(i)for(const o of n.members)s.push(i._addMember(o,!1));i._checkChunks(),t.emit(r.Events.GUILD_MEMBERS_CHUNK,s)}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleCreate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleDelete.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildSync.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.MessageCreate.handle(n);i.message&&t.emit(r.Events.MESSAGE_CREATE,i.message)}}e.exports=s},function(e,t,n){const i=n(3),r=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.MessageDelete.handle(n);i.message&&t.emit(r.Events.MESSAGE_DELETE,i.message)}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageDeleteBulk.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionAdd.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionRemove.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionRemoveAll.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3),r=n(1),s=n(12);class o extends i{handle(e){const t=this.packetManager.client,n=e.d;let i=t.users.get(n.user.id);const o=t.guilds.get(n.guild_id);if(!i){if(!n.user.username)return;i=t.dataManager.newUser(n.user)}const a=s(i);if(i.patch(n.user),i.equals(a)||t.emit(r.Events.USER_UPDATE,a,i),o){let e=o.members.get(i.id);if(e||"offline"===n.status||(e=o._addMember({user:i,roles:n.roles,deaf:!1,mute:!1},!1),t.emit(r.Events.GUILD_MEMBER_AVAILABLE,e)),e){const a=s(e);e.presence&&(a.frozenPresence=s(e.presence)),o._setPresence(i.id,n),t.emit(r.Events.PRESENCE_UPDATE,a,e)}else o._setPresence(i.id,n)}}}e.exports=o},function(e,t,n){const i=n(3),r=n(68);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=new r(t,n.user);t.user=i,t.readyAt=new Date,t.users.set(i.id,i);for(const s of n.guilds)t.dataManager.newGuild(s);for(const o of n.private_channels)t.dataManager.newChannel(o);for(const a of n.relationships){const e=t.dataManager.newUser(a.user);1===a.type?t.user.friends.set(e.id,e):2===a.type&&t.user.blocked.set(e.id,e)}n.presences=n.presences||[];for(const c of n.presences)t.dataManager.newUser(c.user),t._setPresence(c.user.id,c);if(n.notes)for(const h in n.notes){let e=n.notes[h];e.length||(e=null),t.user.notes.set(h,e)}!t.user.bot&&t.options.sync&&t.setInterval(t.syncGuilds.bind(t),3e4),t.once("ready",t.syncGuilds.bind(t)),t.users.has("1")||t.dataManager.newUser({id:"1",username:"Clyde",discriminator:"0000",avatar:"https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png",bot:!0,status:"online",game:null,verified:!0}),t.setTimeout(()=>{t.ws.normalReady||t.ws._emitReady(!1)},1200*n.guilds.length),this.packetManager.ws.sessionID=n.session_id,this.packetManager.ws.checkIfReady()}}e.exports=s},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;1===n.type?t.fetchUser(n.id).then(e=>{t.user.friends.set(e.id,e)}):2===n.type&&t.fetchUser(n.id).then(e=>{t.user.blocked.set(e.id,e)})}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;2===n.type?t.user.blocked.has(n.id)&&t.user.blocked.delete(n.id):1===n.type&&t.user.friends.has(n.id)&&t.user.friends.delete(n.id)}}e.exports=r},function(e,t,n){function i(e,t){return e.client.setTimeout(()=>{e.client.emit(s.Events.TYPING_STOP,e,t,e._typing.get(t.id)),e._typing.delete(t.id)},6e3)}const r=n(3),s=n(1);class o extends r{handle(e){const t=this.packetManager.client,n=e.d,r=t.channels.get(n.channel_id),o=t.users.get(n.user_id),c=new Date(1e3*n.timestamp);if(r&&o){if("voice"===r.type)return void t.emit(s.Events.WARN,`Discord sent a typing packet to voice channel ${r.id}`);if(r._typing.has(o.id)){const e=r._typing.get(o.id);e.lastTimestamp=c,e.resetTimeout(i(r,o))}else r._typing.set(o.id,new a(t,c,c,i(r,o))),t.emit(s.Events.TYPING_START,r,o)}}}class a{constructor(e,t,n,i){this.client=e,this.since=t,this.lastTimestamp=n,this._timeout=i}resetTimeout(e){this.client.clearTimeout(this._timeout),this._timeout=e}get elapsedTime(){return Date.now()-this.since}}e.exports=o},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.UserNoteUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.UserUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(3);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.emit("self.voiceServer",n)}}e.exports=r},function(e,t,n){const i=n(3),r=n(1),s=n(12);class o extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=i.members.get(n.user_id);if(e){const i=s(e);e.voiceChannel&&e.voiceChannel.id!==n.channel_id&&e.voiceChannel.members.delete(i.id),n.channel_id||(e.speaking=null),e.user.id===t.user.id&&n.channel_id&&t.emit("self.voiceStateUpdate",n);const o=t.channels.get(n.channel_id);o&&o.members.set(e.user.id,e),e.serverMute=n.mute,e.serverDeaf=n.deaf,e.selfMute=n.self_mute,e.selfDeaf=n.self_deaf,e.voiceSessionID=n.session_id,e.voiceChannelID=n.channel_id,t.emit(r.Events.VOICE_STATE_UPDATE,i,e)}}}}e.exports=o},function(e,t){class n{constructor(e,t){this.user=e,this.setup(t)}setup(e){this.type=e.type,this.name=e.name,this.id=e.id,this.revoked=e.revoked,this.integrations=e.integrations}}e.exports=n},function(e,t,n){const i=n(6),r=n(332);class s{constructor(e,t){this.user=e,this.client=this.user.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.mutualGuilds=new i,this.connections=new i,this.setup(t)}setup(e){for(const t of e.mutual_guilds)this.client.guilds.has(t.id)&&this.mutualGuilds.set(t.id,this.client.guilds.get(t.id));for(const n of e.connected_accounts)this.connections.set(n.id,new r(this.user,n))}}e.exports=s},function(e,t){e.exports=function(e){if(e.includes("%")&&(e=decodeURIComponent(e)),e.includes(":")){const[t,n]=e.split(":");return{name:t,id:n}}return{name:e,id:null}}},function(e,t){var n=new Error('Cannot find module "undefined"');throw n.code="MODULE_NOT_FOUND",n},function(e,t){var n=new Error('Cannot find module "undefined"');throw n.code="MODULE_NOT_FOUND",n},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){e.exports={Client:n(137),WebhookClient:n(138),Shard:n(65),ShardClientUtil:n(66),ShardingManager:n(139),Collection:n(6),splitMessage:n(83),escapeMarkdown:n(35),fetchRecommendedShards:n(82),Channel:n(24),ClientOAuth2Application:n(67),ClientUser:n(68),DMChannel:n(69),Emoji:n(25),EvaluatedPermissions:n(46),Game:n(15).Game,GroupDMChannel:n(70),Guild:n(47),GuildChannel:n(32),GuildMember:n(33),Invite:n(71),Message:n(34),MessageAttachment:n(72),MessageCollector:n(73),MessageEmbed:n(74),MessageReaction:n(75),OAuth2Application:n(76),PartialGuild:n(77),PartialGuildChannel:n(78),PermissionOverwrites:n(79),Presence:n(15).Presence,ReactionEmoji:n(48),Role:n(19),TextChannel:n(80),User:n(14),VoiceChannel:n(81),Webhook:n(49),version:n(64).version},"undefined"!=typeof window&&(window.Discord=e.exports)}]); \ No newline at end of file +function i(e,t){if(e===t)return 0;for(var n=e.length,i=t.length,r=0,s=Math.min(n,i);r=0;a--)if(h[a]!==u[a])return!1;for(a=h.length-1;a>=0;a--)if(o=h[a],!d(e[o],t[o],n,i))return!1;return!0}function m(e,t,n){d(e,t,!0)&&l(e,t,n,"notDeepStrictEqual",m)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&t.call({},e)===!0}function w(e){var t;try{e()}catch(e){t=e}return t}function v(e,t,n,i){var r;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(i=n,n=null),r=w(t),i=(n&&n.name?" ("+n.name+").":".")+(i?" "+i:"."),e&&!r&&l(r,n,"Missing expected exception"+i);var s="string"==typeof i,o=!e&&y.isError(r),a=!e&&r&&!n;if((o&&s&&_(r,n)||a)&&l(r,n,"Got unwanted exception"+i),e&&r&&n&&!_(r,n)||!e&&r)throw r}var y=n(68),b=Object.prototype.hasOwnProperty,E=Array.prototype.slice,A=function(){return"foo"===function(){}.name}(),k=e.exports=f,S=/\s*function\s+([^\(\s]*)\s*/;k.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=c(this),this.generatedMessage=!0);var t=e.stackStartFunction||l;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var i=n.stack,r=a(t),s=i.indexOf("\n"+r);if(s>=0){var o=i.indexOf("\n",s+1);i=i.substring(o+1)}this.stack=i}}},y.inherits(k.AssertionError,Error),k.fail=l,k.ok=f,k.equal=function(e,t,n){e!=t&&l(e,t,n,"==",k.equal)},k.notEqual=function(e,t,n){e==t&&l(e,t,n,"!=",k.notEqual)},k.deepEqual=function(e,t,n){d(e,t,!1)||l(e,t,n,"deepEqual",k.deepEqual)},k.deepStrictEqual=function(e,t,n){d(e,t,!0)||l(e,t,n,"deepStrictEqual",k.deepStrictEqual)},k.notDeepEqual=function(e,t,n){d(e,t,!1)&&l(e,t,n,"notDeepEqual",k.notDeepEqual)},k.notDeepStrictEqual=m,k.strictEqual=function(e,t,n){e!==t&&l(e,t,n,"===",k.strictEqual)},k.notStrictEqual=function(e,t,n){e===t&&l(e,t,n,"!==",k.notStrictEqual)},k.throws=function(e,t,n){v(!0,e,t,n)},k.doesNotThrow=function(e,t,n){v(!1,e,t,n)},k.ifError=function(e){if(e)throw e};var T=Object.keys||function(e){var t=[];for(var n in e)b.call(e,n)&&t.push(n);return t}}).call(t,n(18))},function(e,t){"use strict";function n(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function r(e){var t,i,r,s,o,a,h=e.length;o=n(e),a=new c(3*h/4-o),r=o>0?h-4:h;var l=0;for(t=0,i=0;t>16&255,a[l++]=s>>8&255,a[l++]=255&s;return 2===o?(s=u[e.charCodeAt(t)]<<2|u[e.charCodeAt(t+1)]>>4,a[l++]=255&s):1===o&&(s=u[e.charCodeAt(t)]<<10|u[e.charCodeAt(t+1)]<<4|u[e.charCodeAt(t+2)]>>2,a[l++]=s>>8&255,a[l++]=255&s),a}function s(e){return h[e>>18&63]+h[e>>12&63]+h[e>>6&63]+h[63&e]}function o(e,t,n){for(var i,r=[],o=t;oc?c:u+a));return 1===i?(t=e[n-1],r+=h[t>>2],r+=h[t<<4&63],r+="=="):2===i&&(t=(e[n-2]<<8)+e[n-1],r+=h[t>>10],r+=h[t>>4&63],r+=h[t<<2&63],r+="="),s.push(r),s.join("")}t.byteLength=i,t.toByteArray=r,t.fromByteArray=a;for(var h=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,d=l.length;ft.UNZIP)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function s(e,t){for(var n=0;nt.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+n.chunkSize);if(n.windowBits&&(n.windowBitst.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+n.windowBits);if(n.level&&(n.levelt.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+n.level);if(n.memLevel&&(n.memLevelt.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+n.memLevel);if(n.strategy&&n.strategy!=t.Z_FILTERED&&n.strategy!=t.Z_HUFFMAN_ONLY&&n.strategy!=t.Z_RLE&&n.strategy!=t.Z_FIXED&&n.strategy!=t.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+n.strategy);if(n.dictionary&&!e.isBuffer(n.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new g.Zlib(i);var r=this;this._hadError=!1,this._binding.onerror=function(e,n){r._binding=null,r._hadError=!0;var i=new Error(e);i.errno=n,i.code=t.codes[n],r.emit("error",i)};var s=t.Z_DEFAULT_COMPRESSION;"number"==typeof n.level&&(s=n.level);var o=t.Z_DEFAULT_STRATEGY;"number"==typeof n.strategy&&(o=n.strategy),this._binding.init(n.windowBits||t.Z_DEFAULT_WINDOWBITS,s,n.memLevel||t.Z_DEFAULT_MEMLEVEL,o,n.dictionary),this._buffer=new e(this._chunkSize),this._offset=0,this._closed=!1,this._level=s,this._strategy=o,this.once("end",this.close)}var p=n(64),g=n(82),m=n(68),_=n(80).ok;g.Z_MIN_WINDOWBITS=8,g.Z_MAX_WINDOWBITS=15,g.Z_DEFAULT_WINDOWBITS=15,g.Z_MIN_CHUNK=64,g.Z_MAX_CHUNK=1/0,g.Z_DEFAULT_CHUNK=16384,g.Z_MIN_MEMLEVEL=1,g.Z_MAX_MEMLEVEL=9,g.Z_DEFAULT_MEMLEVEL=8,g.Z_MIN_LEVEL=-1,g.Z_MAX_LEVEL=9,g.Z_DEFAULT_LEVEL=g.Z_DEFAULT_COMPRESSION,Object.keys(g).forEach(function(e){e.match(/^Z/)&&(t[e]=g[e])}),t.codes={Z_OK:g.Z_OK,Z_STREAM_END:g.Z_STREAM_END,Z_NEED_DICT:g.Z_NEED_DICT,Z_ERRNO:g.Z_ERRNO,Z_STREAM_ERROR:g.Z_STREAM_ERROR,Z_DATA_ERROR:g.Z_DATA_ERROR,Z_MEM_ERROR:g.Z_MEM_ERROR,Z_BUF_ERROR:g.Z_BUF_ERROR,Z_VERSION_ERROR:g.Z_VERSION_ERROR},Object.keys(t.codes).forEach(function(e){t.codes[t.codes[e]]=e}),t.Deflate=o,t.Inflate=a,t.Gzip=h,t.Gunzip=u,t.DeflateRaw=c,t.InflateRaw=l,t.Unzip=f,t.createDeflate=function(e){return new o(e)},t.createInflate=function(e){return new a(e)},t.createDeflateRaw=function(e){return new c(e)},t.createInflateRaw=function(e){return new l(e)},t.createGzip=function(e){return new h(e)},t.createGunzip=function(e){return new u(e)},t.createUnzip=function(e){return new f(e)},t.deflate=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new o(t),e,n)},t.deflateSync=function(e,t){return s(new o(t),e)},t.gzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new h(t),e,n)},t.gzipSync=function(e,t){return s(new h(t),e)},t.deflateRaw=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new c(t),e,n)},t.deflateRawSync=function(e,t){return s(new c(t),e)},t.unzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new f(t),e,n)},t.unzipSync=function(e,t){return s(new f(t),e)},t.inflate=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new a(t),e,n)},t.inflateSync=function(e,t){return s(new a(t),e)},t.gunzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new u(t),e,n)},t.gunzipSync=function(e,t){return s(new u(t),e)},t.inflateRaw=function(e,t,n){return"function"==typeof t&&(n=t,t={}),r(new l(t),e,n)},t.inflateRawSync=function(e,t){return s(new l(t),e)},m.inherits(d,p),d.prototype.params=function(e,n,r){if(et.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(n!=t.Z_FILTERED&&n!=t.Z_HUFFMAN_ONLY&&n!=t.Z_RLE&&n!=t.Z_FIXED&&n!=t.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==e||this._strategy!==n){var s=this;this.flush(g.Z_SYNC_FLUSH,function(){s._binding.params(e,n),s._hadError||(s._level=e,s._strategy=n,r&&r())})}else i.nextTick(r)},d.prototype.reset=function(){return this._binding.reset()},d.prototype._flush=function(t){this._transform(new e(0),"",t)},d.prototype.flush=function(t,n){var r=this._writableState;if(("function"==typeof t||void 0===t&&!n)&&(n=t,t=g.Z_FULL_FLUSH),r.ended)n&&i.nextTick(n);else if(r.ending)n&&this.once("end",n);else if(r.needDrain){var s=this;this.once("drain",function(){s.flush(n)})}else this._flushFlag=t,this.write(new e(0),"",n)},d.prototype.close=function(e){if(e&&i.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;i.nextTick(function(){t.emit("close")})}},d.prototype._transform=function(t,n,i){var r,s=this._writableState,o=s.ending||s.ended,a=o&&(!t||s.length===t.length);if(null===!t&&!e.isBuffer(t))return i(new Error("invalid input"));a?r=g.Z_FINISH:(r=this._flushFlag,t.length>=s.length&&(this._flushFlag=this._opts.flush||g.Z_NO_FLUSH));this._processChunk(t,r,i)},d.prototype._processChunk=function(t,n,i){function r(c,d){if(!h._hadError){var p=o-d;if(_(p>=0,"have should not go down"),p>0){var g=h._buffer.slice(h._offset,h._offset+p);h._offset+=p,u?h.push(g):(l.push(g),f+=g.length)}if((0===d||h._offset>=h._chunkSize)&&(o=h._chunkSize,h._offset=0,h._buffer=new e(h._chunkSize)),0===d){if(a+=s-c,s=c,!u)return!0;var m=h._binding.write(n,t,a,s,h._buffer,h._offset,h._chunkSize);return m.callback=r,void(m.buffer=t)}return!!u&&void i()}}var s=t&&t.length,o=this._chunkSize-this._offset,a=0,h=this,u="function"==typeof i;if(!u){var c,l=[],f=0;this.on("error",function(e){c=e});do var d=this._binding.writeSync(n,t,a,s,this._buffer,this._offset,o);while(!this._hadError&&r(d[0],d[1]));if(this._hadError)throw c;var p=e.concat(l,f);return this.close(),p}var g=this._binding.write(n,t,a,s,this._buffer,this._offset,o);g.buffer=t,g.callback=r},m.inherits(o,d),m.inherits(a,d),m.inherits(h,d),m.inherits(u,d),m.inherits(c,d),m.inherits(l,d),m.inherits(f,d)}).call(t,n(5).Buffer,n(6))},function(e,t,n){function i(e){if(e)return r(e)}function r(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}e.exports=i,i.prototype.on=i.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},i.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i,r=0;r>1,c=-7,l=n?r-1:0,f=n?-1:1,d=e[t+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+e[t+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=i;c>0;o=256*o+e[t+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,i),s-=u}return(d?-1:1)*o*Math.pow(2,s-i)},t.write=function(e,t,n,i,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),t+=o+l>=1?f/h:f*Math.pow(2,1-l),t*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(t*h-1)*Math.pow(2,r),o+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;e[n+d]=255&a,d+=p,a/=256,r-=8);for(o=o<0;e[n+d]=255&o,d+=p,o/=256,u-=8);e[n+d-p]|=128*g}},function(e,t){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(e,t,n){"use strict";function i(e,t){return e.msg=C[t],t}function r(e){return(e<<1)-(e>4?9:0)}function s(e){for(var t=e.length;--t>=0;)e[t]=0}function o(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(x.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function a(e,t){I._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function h(e,t){e.pending_buf[e.pending++]=t}function u(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function c(e,t,n,i){var r=e.avail_in;return r>i&&(r=i),0===r?0:(e.avail_in-=r,x.arraySet(t,e.input,e.next_in,r,n),1===e.state.wrap?e.adler=U(e.adler,t,r,n):2===e.state.wrap&&(e.adler=L(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)}function l(e,t){var n,i,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,h=e.strstart>e.w_size-le?e.strstart-(e.w_size-le):0,u=e.window,c=e.w_mask,l=e.prev,f=e.strstart+ce,d=u[s+o-1],p=u[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do if(n=t,u[n+o]===p&&u[n+o-1]===d&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do;while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&so){if(e.match_start=t,o=i,i>=a)break;d=u[s+o-1],p=u[s+o]}}while((t=l[t&c])>h&&0!==--r);return o<=e.lookahead?o:e.lookahead}function f(e){var t,n,i,r,s,o=e.w_size;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=o+(o-le)){x.arraySet(e.window,e.window,o,o,0),e.match_start-=o,e.strstart-=o,e.block_start-=o,n=e.hash_size,t=n;do i=e.head[--t],e.head[t]=i>=o?i-o:0;while(--n);n=o,t=n;do i=e.prev[--t],e.prev[t]=i>=o?i-o:0;while(--n);r+=o}if(0===e.strm.avail_in)break;if(n=c(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=ue)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(f(e),0===e.lookahead&&t===P)return ye;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,a(e,!1),0===e.strm.avail_out))return ye;if(e.strstart-e.block_start>=e.w_size-le&&(a(e,!1),0===e.strm.avail_out))return ye}return e.insert=0,t===B?(a(e,!0),0===e.strm.avail_out?Ee:Ae):e.strstart>e.block_start&&(a(e,!1),0===e.strm.avail_out)?ye:ye}function p(e,t){for(var n,i;;){if(e.lookahead=ue&&(e.ins_h=(e.ins_h<=ue)if(i=I._tr_tally(e,e.strstart-e.match_start,e.match_length-ue),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=ue){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=ue&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=ue-1)),e.prev_length>=ue&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-ue,i=I._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-ue),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<=ue&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=e.strstart+ce;do;while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=ue?(n=I._tr_tally(e,1,e.match_length-ue),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=I._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(a(e,!1),0===e.strm.avail_out))return ye}return e.insert=0,t===B?(a(e,!0),0===e.strm.avail_out?Ee:Ae):e.last_lit&&(a(e,!1),0===e.strm.avail_out)?ye:be}function _(e,t){for(var n;;){if(0===e.lookahead&&(f(e),0===e.lookahead)){if(t===P)return ye;break}if(e.match_length=0,n=I._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(a(e,!1),0===e.strm.avail_out))return ye}return e.insert=0,t===B?(a(e,!0),0===e.strm.avail_out?Ee:Ae):e.last_lit&&(a(e,!1),0===e.strm.avail_out)?ye:be}function w(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}function v(e){e.window_size=2*e.w_size,s(e.head),e.max_lazy_match=D[e.level].max_lazy,e.good_match=D[e.level].good_length,e.nice_match=D[e.level].nice_length,e.max_chain_length=D[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=ue-1,e.match_available=0,e.ins_h=0}function y(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new x.Buf16(2*ae),this.dyn_dtree=new x.Buf16(2*(2*se+1)),this.bl_tree=new x.Buf16(2*(2*oe+1)),s(this.dyn_ltree),s(this.dyn_dtree),s(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new x.Buf16(he+1),this.heap=new x.Buf16(2*re+1),s(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new x.Buf16(2*re+1),s(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function b(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=J,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?de:we,e.adler=2===t.wrap?0:1,t.last_flush=P,I._tr_init(t),j):i(e,q)}function E(e){var t=b(e);return t===j&&v(e.state),t}function A(e,t){return e&&e.state?2!==e.state.wrap?q:(e.state.gzhead=t,j):q}function k(e,t,n,r,s,o){if(!e)return q;var a=1;if(t===H&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),s<1||s>Q||n!==$||r<8||r>15||t<0||t>9||o<0||o>K)return i(e,q);8===r&&(r=9);var h=new y;return e.state=h,h.strm=e,h.wrap=a,h.gzhead=null,h.w_bits=r,h.w_size=1<G||t<0)return e?i(e,q):q;if(a=e.state,!e.output||!e.input&&0!==e.avail_in||a.status===ve&&t!==B)return i(e,0===e.avail_out?W:q);if(a.strm=e,n=a.last_flush,a.last_flush=t,a.status===de)if(2===a.wrap)e.adler=0,h(a,31),h(a,139),h(a,8),a.gzhead?(h(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),h(a,255&a.gzhead.time),h(a,a.gzhead.time>>8&255),h(a,a.gzhead.time>>16&255),h(a,a.gzhead.time>>24&255),h(a,9===a.level?2:a.strategy>=Y||a.level<2?4:0),h(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(h(a,255&a.gzhead.extra.length),h(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=L(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=pe):(h(a,0),h(a,0),h(a,0),h(a,0),h(a,0),h(a,9===a.level?2:a.strategy>=Y||a.level<2?4:0),h(a,ke),a.status=we);else{var f=$+(a.w_bits-8<<4)<<8,d=-1;d=a.strategy>=Y||a.level<2?0:a.level<6?1:6===a.level?2:3,f|=d<<6,0!==a.strstart&&(f|=fe),f+=31-f%31,a.status=we,u(a,f),0!==a.strstart&&(u(a,e.adler>>>16),u(a,65535&e.adler)),e.adler=1}if(a.status===pe)if(a.gzhead.extra){for(c=a.pending;a.gzindex<(65535&a.gzhead.extra.length)&&(a.pending!==a.pending_buf_size||(a.gzhead.hcrc&&a.pending>c&&(e.adler=L(e.adler,a.pending_buf,a.pending-c,c)),o(e),c=a.pending,a.pending!==a.pending_buf_size));)h(a,255&a.gzhead.extra[a.gzindex]),a.gzindex++;a.gzhead.hcrc&&a.pending>c&&(e.adler=L(e.adler,a.pending_buf,a.pending-c,c)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=ge)}else a.status=ge;if(a.status===ge)if(a.gzhead.name){c=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>c&&(e.adler=L(e.adler,a.pending_buf,a.pending-c,c)),o(e),c=a.pending,a.pending===a.pending_buf_size)){l=1;break}l=a.gzindexc&&(e.adler=L(e.adler,a.pending_buf,a.pending-c,c)),0===l&&(a.gzindex=0,a.status=me)}else a.status=me;if(a.status===me)if(a.gzhead.comment){c=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>c&&(e.adler=L(e.adler,a.pending_buf,a.pending-c,c)),o(e),c=a.pending,a.pending===a.pending_buf_size)){l=1;break}l=a.gzindexc&&(e.adler=L(e.adler,a.pending_buf,a.pending-c,c)),0===l&&(a.status=_e)}else a.status=_e;if(a.status===_e&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&o(e),a.pending+2<=a.pending_buf_size&&(h(a,255&e.adler),h(a,e.adler>>8&255),e.adler=0,a.status=we)):a.status=we),0!==a.pending){if(o(e),0===e.avail_out)return a.last_flush=-1,j}else if(0===e.avail_in&&r(t)<=r(n)&&t!==B)return i(e,W);if(a.status===ve&&0!==e.avail_in)return i(e,W);if(0!==e.avail_in||0!==a.lookahead||t!==P&&a.status!==ve){var p=a.strategy===Y?_(a,t):a.strategy===V?m(a,t):D[a.level].func(a,t);if(p!==Ee&&p!==Ae||(a.status=ve),p===ye||p===Ee)return 0===e.avail_out&&(a.last_flush=-1),j;if(p===be&&(t===O?I._tr_align(a):t!==G&&(I._tr_stored_block(a,0,0,!1),t===N&&(s(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),o(e),0===e.avail_out))return a.last_flush=-1,j}return t!==B?j:a.wrap<=0?z:(2===a.wrap?(h(a,255&e.adler),h(a,e.adler>>8&255),h(a,e.adler>>16&255),h(a,e.adler>>24&255),h(a,255&e.total_in),h(a,e.total_in>>8&255),h(a,e.total_in>>16&255),h(a,e.total_in>>24&255)):(u(a,e.adler>>>16),u(a,65535&e.adler)),o(e),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?j:z)}function R(e){var t;return e&&e.state?(t=e.state.status,t!==de&&t!==pe&&t!==ge&&t!==me&&t!==_e&&t!==we&&t!==ve?i(e,q):(e.state=null,t===we?i(e,F):j)):q}function M(e,t){var n,i,r,o,a,h,u,c,l=t.length;if(!e||!e.state)return q;if(n=e.state,o=n.wrap,2===o||1===o&&n.status!==de||n.lookahead)return q;for(1===o&&(e.adler=U(e.adler,t,l,0)),n.wrap=0,l>=n.w_size&&(0===o&&(s(n.head),n.strstart=0,n.block_start=0,n.insert=0),c=new x.Buf8(n.w_size),x.arraySet(c,t,l-n.w_size,n.w_size,0),t=c,l=n.w_size),a=e.avail_in,h=e.next_in,u=e.input,e.avail_in=l,e.next_in=0,e.input=t,f(n);n.lookahead>=ue;){i=n.strstart,r=n.lookahead-(ue-1);do n.ins_h=(n.ins_h<>>24,g>>>=E,m-=E,E=b>>>16&255,0===E)M[a++]=65535&b;else{if(!(16&E)){if(0===(64&E)){b=_[(65535&b)+(g&(1<>>=E,m-=E),m<15&&(g+=R[s++]<>>24,g>>>=E,m-=E,E=b>>>16&255,!(16&E)){if(0===(64&E)){b=w[(65535&b)+(g&(1<c){e.msg="invalid distance too far back",r.mode=n;break e}if(g>>>=E,m-=E,E=a-h,k>E){if(E=k-E,E>f&&r.sane){e.msg="invalid distance too far back",r.mode=n;break e}if(S=0,T=p,0===d){if(S+=l-E,E2;)M[a++]=T[S++],M[a++]=T[S++],M[a++]=T[S++],A-=3;A&&(M[a++]=T[S++],A>1&&(M[a++]=T[S++]))}else{S=a-k;do M[a++]=M[S++],M[a++]=M[S++],M[a++]=M[S++],A-=3;while(A>2);A&&(M[a++]=M[S++],A>1&&(M[a++]=M[S++]))}break}}break}}while(s>3,s-=A,m-=A<<3,g&=(1<>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function r(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new w.Buf16(320),this.work=new w.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function s(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=N,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new w.Buf32(ge),t.distcode=t.distdyn=new w.Buf32(me),t.sane=1,t.back=-1,D):U}function o(e){var t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,s(e)):U}function a(e,t){var n,i;return e&&e.state?(i=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?U:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,o(e))):U}function h(e,t){var n,i;return e?(i=new r,e.state=i,i.window=null,n=a(e,t),n!==D&&(e.state=null),n):U}function u(e){return h(e,we)}function c(e){if(ve){var t;for(m=new w.Buf32(512),_=new w.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(E(k,e.lens,0,288,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;E(S,e.lens,0,32,_,0,e.work,{bits:5}),ve=!1}e.lencode=m,e.lenbits=9,e.distcode=_,e.distbits=5}function l(e,t,n,i){var r,s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(w.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),w.arraySet(s.window,t,n-i,r,s.wnext),i-=r,i?(w.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=y(n.check,Re,2,0),f=0,d=0,n.mode=B;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&f)<<8)+(f>>8))%31){e.msg="incorrect header check",n.mode=fe;break}if((15&f)!==O){e.msg="unknown compression method",n.mode=fe;break}if(f>>>=4,d-=4,Ee=(15&f)+8,0===n.wbits)n.wbits=Ee;else if(Ee>n.wbits){e.msg="invalid window size",n.mode=fe;break}n.dmax=1<>8&1),512&n.flags&&(Re[0]=255&f,Re[1]=f>>>8&255,n.check=y(n.check,Re,2,0)),f=0,d=0,n.mode=G;case G:for(;d<32;){if(0===h)break e;h--,f+=r[o++]<>>8&255,Re[2]=f>>>16&255,Re[3]=f>>>24&255,n.check=y(n.check,Re,4,0)),f=0,d=0,n.mode=j;case j:for(;d<16;){if(0===h)break e;h--,f+=r[o++]<>8),512&n.flags&&(Re[0]=255&f,Re[1]=f>>>8&255,n.check=y(n.check,Re,2,0)),f=0,d=0,n.mode=z;case z:if(1024&n.flags){for(;d<16;){if(0===h)break e;h--,f+=r[o++]<>>8&255,n.check=y(n.check,Re,2,0)),f=0,d=0}else n.head&&(n.head.extra=null);n.mode=q;case q:if(1024&n.flags&&(m=n.length,m>h&&(m=h),m&&(n.head&&(Ee=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),w.arraySet(n.head.extra,r,o,m,Ee)),512&n.flags&&(n.check=y(n.check,r,m,o)),h-=m,o+=m,n.length-=m),n.length))break e;n.length=0,n.mode=F;case F:if(2048&n.flags){if(0===h)break e;m=0;do Ee=r[o+m++],n.head&&Ee&&n.length<65536&&(n.head.name+=String.fromCharCode(Ee));while(Ee&&m>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=V;break;case Z:for(;d<32;){if(0===h)break e;h--,f+=r[o++]<>>=7&d,d-=7&d,n.mode=ue;break}for(;d<3;){if(0===h)break e;h--,f+=r[o++]<>>=1,d-=1,3&f){case 0:n.mode=X;break;case 1:if(c(n),n.mode=ne,t===M){f>>>=2,d-=2;break e}break;case 2:n.mode=Q;break;case 3:e.msg="invalid block type",n.mode=fe}f>>>=2,d-=2;break;case X:for(f>>>=7&d,d-=7&d;d<32;){if(0===h)break e;h--,f+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=fe;break}if(n.length=65535&f,f=0,d=0,n.mode=J,t===M)break e;case J:n.mode=$;case $:if(m=n.length){if(m>h&&(m=h),m>u&&(m=u),0===m)break e;w.arraySet(s,r,o,m,a),h-=m,o+=m,u-=m,a+=m,n.length-=m;break}n.mode=V;break;case Q:for(;d<14;){if(0===h)break e;h--,f+=r[o++]<>>=5,d-=5,n.ndist=(31&f)+1,f>>>=5,d-=5,n.ncode=(15&f)+4,f>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=fe;break}n.have=0,n.mode=ee;case ee:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[Me[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,ke={bits:n.lenbits},Ae=E(A,n.lens,0,19,n.lencode,0,n.work,ke),n.lenbits=ke.bits,Ae){e.msg="invalid code lengths set",n.mode=fe;break}n.have=0,n.mode=te;case te:for(;n.have>>24,_e=Te>>>16&255,we=65535&Te,!(me<=d);){if(0===h)break e;h--,f+=r[o++]<>>=me,d-=me,n.lens[n.have++]=we;else{if(16===we){for(Se=me+2;d>>=me,d-=me,0===n.have){e.msg="invalid bit length repeat",n.mode=fe;break}Ee=n.lens[n.have-1],m=3+(3&f),f>>>=2,d-=2}else if(17===we){for(Se=me+3;d>>=me,d-=me,Ee=0,m=3+(7&f),f>>>=3,d-=3}else{for(Se=me+7;d>>=me,d-=me,Ee=0,m=11+(127&f),f>>>=7,d-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=fe;break}for(;m--;)n.lens[n.have++]=Ee}}if(n.mode===fe)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=fe;break}if(n.lenbits=9,ke={bits:n.lenbits},Ae=E(k,n.lens,0,n.nlen,n.lencode,0,n.work,ke),n.lenbits=ke.bits,Ae){e.msg="invalid literal/lengths set",n.mode=fe;break}if(n.distbits=6,n.distcode=n.distdyn,ke={bits:n.distbits},Ae=E(S,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,ke),n.distbits=ke.bits,Ae){e.msg="invalid distances set",n.mode=fe;break}if(n.mode=ne,t===M)break e;case ne:n.mode=ie;case ie:if(h>=6&&u>=258){e.next_out=a,e.avail_out=u,e.next_in=o,e.avail_in=h,n.hold=f,n.bits=d,b(e,g),a=e.next_out,s=e.output,u=e.avail_out,o=e.next_in,r=e.input,h=e.avail_in,f=n.hold,d=n.bits,n.mode===V&&(n.back=-1);break}for(n.back=0;Te=n.lencode[f&(1<>>24,_e=Te>>>16&255,we=65535&Te,!(me<=d);){if(0===h)break e;h--,f+=r[o++]<>ve)],me=Te>>>24,_e=Te>>>16&255,we=65535&Te,!(ve+me<=d);){if(0===h)break e;h--,f+=r[o++]<>>=ve,d-=ve,n.back+=ve}if(f>>>=me,d-=me,n.back+=me,n.length=we,0===_e){n.mode=he;break}if(32&_e){n.back=-1,n.mode=V;break}if(64&_e){e.msg="invalid literal/length code",n.mode=fe;break}n.extra=15&_e,n.mode=re;case re:if(n.extra){for(Se=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=se;case se:for(;Te=n.distcode[f&(1<>>24,_e=Te>>>16&255,we=65535&Te,!(me<=d);){if(0===h)break e;h--,f+=r[o++]<>ve)],me=Te>>>24,_e=Te>>>16&255,we=65535&Te,!(ve+me<=d);){if(0===h)break e;h--,f+=r[o++]<>>=ve,d-=ve,n.back+=ve}if(f>>>=me,d-=me,n.back+=me,64&_e){e.msg="invalid distance code",n.mode=fe;break}n.offset=we,n.extra=15&_e,n.mode=oe;case oe:if(n.extra){for(Se=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=fe;break}n.mode=ae;case ae:if(0===u)break e;if(m=g-u,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=fe;break}m>n.wnext?(m-=n.wnext,_=n.wsize-m):_=n.wnext-m,m>n.length&&(m=n.length),ge=n.window}else ge=s,_=a-n.offset,m=n.length;m>u&&(m=u),u-=m,n.length-=m;do s[a++]=ge[_++];while(--m);0===n.length&&(n.mode=ie);break;case he:if(0===u)break e;s[a++]=n.length,u--,n.mode=ie;break;case ue:if(n.wrap){for(;d<32;){if(0===h)break e;h--,f|=r[o++]<=1&&0===z[U];U--);if(L>U&&(L=U),0===U)return g[m++]=20971520,g[m++]=20971520,w.bits=1,0;for(I=1;I0&&(e===a||1!==U))return-1;for(q[1]=0,D=1;Ds||e===u&&N>o)return 1;for(var H=0;;){H++,S=D-P,_[x]k?(T=F[W+_[x]],R=G[j+_[x]]):(T=96,R=0),v=1<>P)+y]=S<<24|T<<16|R|0;while(0!==y);for(v=1<>=1;if(0!==v?(B&=v-1,B+=v):B=0,x++,0===--z[D]){if(D===U)break;D=t[n+_[x]]}if(D>L&&(B&E)!==b){for(0===P&&(P=L),A+=I,C=D-P,O=1<s||e===u&&N>o)return 1;b=B&E,g[b]=L<<24|C<<16|A-m|0}}return 0!==B&&(g[A+B]=D-P<<24|64<<16|0),w.bits=L,0}},function(e,t,n){"use strict";function i(e){for(var t=e.length;--t>=0;)e[t]=0}function r(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}function s(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function o(e){return e<256?he[e]:he[256+(e>>>7)]}function a(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function h(e,t,n){e.bi_valid>K-n?(e.bi_buf|=t<>K-e.bi_valid,e.bi_valid+=n-K):(e.bi_buf|=t<>>=1,n<<=1;while(--t>0);return n>>>1}function l(e){16===e.bi_valid?(a(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function f(e,t){var n,i,r,s,o,a,h=t.dyn_tree,u=t.max_code,c=t.stat_desc.static_tree,l=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(s=0;s<=V;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;np&&(s=p,g++),h[2*i+1]=s,i>u||(e.bl_count[s]++,o=0,i>=d&&(o=f[i-d]),a=h[2*i],e.opt_len+=a*(s+o),l&&(e.static_len+=a*(c[2*i+1]+o)));if(0!==g){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(s=p;0!==s;s--)for(i=e.bl_count[s];0!==i;)r=e.heap[--n],r>u||(h[2*r+1]!==s&&(e.opt_len+=(s-h[2*r+1])*h[2*r],h[2*r+1]=s),i--)}}function d(e,t,n){var i,r,s=new Array(V+1),o=0;for(i=1;i<=V;i++)s[i]=o=o+n[i-1]<<1;for(r=0;r<=t;r++){var a=e[2*r+1];0!==a&&(e[2*r]=c(s[a]++,a))}}function p(){var e,t,n,i,s,o=new Array(V+1);for(n=0,i=0;i>=7;i8?a(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function _(e,t,n,i){m(e),i&&(a(e,n),a(e,~n)),U.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function w(e,t,n,i){var r=2*t,s=2*n;return e[r]>1;n>=1;n--)v(e,s,n);r=h;do n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],v(e,s,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,s[2*r]=s[2*n]+s[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,s[2*n+1]=s[2*i+1]=r,e.heap[1]=r++,v(e,s,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],f(e,t),d(s,u,e.bl_count)}function E(e,t,n){var i,r,s=-1,o=t[1],a=0,h=7,u=4;for(0===o&&(h=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=t[2*(i+1)+1],++a=3&&0===e.bl_tree[2*re[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function S(e,t,n,i){var r;for(h(e,t-257,5),h(e,n-1,5),h(e,i-4,4),r=0;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return C;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return P;for(t=32;t0?(e.strm.data_type===O&&(e.strm.data_type=T(e)),b(e,e.l_desc),b(e,e.d_desc),o=k(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&t!==-1?M(e,t,n,i):e.strategy===L||s===r?(h(e,(B<<1)+(i?1:0),3),y(e,oe,ae)):(h(e,(G<<1)+(i?1:0),3),S(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),y(e,e.dyn_ltree,e.dyn_dtree)),g(e),i&&m(e)}function I(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(ue[n]+F+1)]++,e.dyn_dtree[2*o(t)]++),e.last_lit===e.lit_bufsize-1}var U=n(24),L=4,C=0,P=1,O=2,N=0,B=1,G=2,j=3,z=258,q=29,F=256,W=F+1+q,H=30,Z=19,Y=2*W+1,V=15,K=16,X=7,J=256,$=16,Q=17,ee=18,te=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ne=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],ie=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],se=512,oe=new Array(2*(W+2));i(oe);var ae=new Array(2*H);i(ae);var he=new Array(se);i(he);var ue=new Array(z-j+1);i(ue);var ce=new Array(q);i(ce);var le=new Array(H);i(le);var fe,de,pe,ge=!1;t._tr_init=R,t._tr_stored_block=M,t._tr_flush_block=x,t._tr_tally=I,t._tr_align=D},function(e,t){"use strict";function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}e.exports=n},function(e,t,n){e.exports=n(10)},function(e,t,n){"use strict";function i(){this.head=null,this.tail=null,this.length=0}var r=(n(5).Buffer,n(31));e.exports=i,i.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},i.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},i.prototype.shift=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}},i.prototype.clear=function(){this.head=this.tail=null,this.length=0},i.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},i.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t=r.allocUnsafe(e>>>0),n=this.head,i=0;n;)n.data.copy(t,i),i+=n.data.length,n=n.next;return t}},function(e,t,n){e.exports=n(62)},function(e,t,n){(function(i){var r=function(){try{return n(25)}catch(e){}}();t=e.exports=n(63),t.Stream=r||t,t.Readable=t,t.Writable=n(34),t.Duplex=n(10),t.Transform=n(33),t.PassThrough=n(62),!i.browser&&"disable"===i.env.READABLE_STREAM&&r&&(e.exports=r)}).call(t,n(6))},function(e,t,n){e.exports=n(34)},function(e,t,n){function i(e){if(e)return r(e)}function r(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}var s=n(66);e.exports=i,i.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},i.prototype.parse=function(e){return this._parser=e,this},i.prototype.serialize=function(e){return this._serializer=e,this},i.prototype.timeout=function(e){return this._timeout=e,this},i.prototype.then=function(e,t){if(!this._fullfilledPromise){var n=this;this._fullfilledPromise=new Promise(function(e,t){n.end(function(n,i){n?t(n):e(i)})})}return this._fullfilledPromise.then(e,t)},i.prototype.catch=function(e){return this.then(void 0,e)},i.prototype.use=function(e){return e(this),this},i.prototype.get=function(e){return this._header[e.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(e,t){if(s(e)){for(var n in e)this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},i.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},i.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(s(e)){for(var n in e)this.field(n,e[n]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return this._getFormData().append(e,t),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype.withCredentials=function(){return this._withCredentials=!0,this},i.prototype.redirects=function(e){return this._maxRedirects=e,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(e){var t=s(e),n=this._header["content-type"];if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&s(this._data))for(var i in e)this._data[i]=e[i];else"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],"application/x-www-form-urlencoded"==n?this._data=this._data?this._data+"&"+e:e:this._data=(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(n||this.type("json"),this)}},function(e,t){function n(e,t,n){return"function"==typeof n?new e("GET",t).end(n):2==arguments.length?new e("GET",t):new e(t,n)}e.exports=n},function(e,t,n){(function(t){function n(e,t){function n(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}if(i("noDeprecation"))return e;var r=!1;return n}function i(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=n}).call(t,n(18))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){t.lookup=t.resolve4=t.resolve6=t.resolveCname=t.resolveMx=t.resolveNs=t.resolveTxt=t.resolveSrv=t.resolveNaptr=t.reverse=t.resolve=function(){if(arguments.length){var e=arguments[arguments.length-1];e&&"function"==typeof e&&e(null,"0.0.0.0")}}},function(e,t,n){(function(e,n){/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function(){"use strict";function i(e){throw e}function r(e,t){this.index="number"==typeof t?t:0,this.m=0,this.buffer=e instanceof(O?Uint8Array:Array)?e:new(O?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&i(Error("invalid index")),this.buffer.length<=this.index&&this.f()}function s(e,t,n){var i,r="number"==typeof t?t:t=0,s="number"==typeof n?n:e.length;for(i=-1,r=7&s;r--;++t)i=i>>>8^W[255&(i^e[t])];for(r=s>>3;r--;t+=8)i=i>>>8^W[255&(i^e[t])],i=i>>>8^W[255&(i^e[t+1])],i=i>>>8^W[255&(i^e[t+2])],i=i>>>8^W[255&(i^e[t+3])],i=i>>>8^W[255&(i^e[t+4])],i=i>>>8^W[255&(i^e[t+5])],i=i>>>8^W[255&(i^e[t+6])],i=i>>>8^W[255&(i^e[t+7])];return(4294967295^i)>>>0}function o(){}function a(e){this.buffer=new(O?Uint16Array:Array)(2*e),this.length=0}function h(e){var t,n,i,r,s,o,a,h,u,c,l=e.length,f=0,d=Number.POSITIVE_INFINITY;for(h=0;hf&&(f=e[h]),e[h]>=1;for(c=i<<16|h,u=o;u>16&255,s[o++]=n>>24;var a;switch(P){case 1===r:a=[0,r-1,0];break;case 2===r:a=[1,r-2,0];break;case 3===r:a=[2,r-3,0];break;case 4===r:a=[3,r-4,0];break;case 6>=r:a=[4,r-5,1];break;case 8>=r:a=[5,r-7,1];break;case 12>=r:a=[6,r-9,2];break;case 16>=r:a=[7,r-13,2];break;case 24>=r:a=[8,r-17,3];break;case 32>=r:a=[9,r-25,3];break;case 48>=r:a=[10,r-33,4];break;case 64>=r:a=[11,r-49,4];break;case 96>=r:a=[12,r-65,5];break;case 128>=r:a=[13,r-97,5];break;case 192>=r:a=[14,r-129,6];break;case 256>=r:a=[15,r-193,6];break;case 384>=r:a=[16,r-257,7];break;case 512>=r:a=[17,r-385,7];break;case 768>=r:a=[18,r-513,8];break;case 1024>=r:a=[19,r-769,8];break;case 1536>=r:a=[20,r-1025,9];break;case 2048>=r:a=[21,r-1537,9];break;case 3072>=r:a=[22,r-2049,10];break;case 4096>=r:a=[23,r-3073,10];break;case 6144>=r:a=[24,r-4097,11];break;case 8192>=r:a=[25,r-6145,11];break;case 12288>=r:a=[26,r-8193,12];break;case 16384>=r:a=[27,r-12289,12];break;case 24576>=r:a=[28,r-16385,13];break;case 32768>=r:a=[29,r-24577,13];break;default:i("invalid distance")}n=a,s[o++]=n[0],s[o++]=n[1],s[o++]=n[2];var h,u;for(h=0,u=s.length;h=o;)w[o++]=0;for(o=0;29>=o;)v[o++]=0}for(w[256]=1,r=0,s=t.length;r=s){for(l&&n(l,-1),o=0,a=s-r;os&&t+su&&(r=i,u=s),258===s)break}return new c(u,t-r)}function d(e,t){var n,i,r,s,o,h=e.length,u=new a(572),c=new(O?Uint8Array:Array)(h);if(!O)for(s=0;s2*u[s-1]+c[s]&&(u[s]=2*u[s-1]+c[s]),f[s]=Array(u[s]),d[s]=Array(u[s]);for(r=0;re[r]?(f[s][o]=a,d[s][o]=t,h+=2):(f[s][o]=e[r],d[s][o]=r,++r);p[s]=0,1===c[s]&&i(s)}return l}function g(e){var t,n,i,r,s=new(O?Uint16Array:Array)(e.length),o=[],a=[],h=0;for(t=0,n=e.length;t>>=1;return s}function m(e,t){this.input=e,this.b=this.c=0,this.g={},t&&(t.flags&&(this.g=t.flags),"string"==typeof t.filename&&(this.filename=t.filename),"string"==typeof t.comment&&(this.w=t.comment),t.deflateOptions&&(this.l=t.deflateOptions)),this.l||(this.l={})}function _(e,t){switch(this.o=[],this.p=32768,this.e=this.j=this.c=this.s=0,this.input=O?new Uint8Array(e):e,this.u=!1,this.q=ne,this.L=!1,!t&&(t={})||(t.index&&(this.c=t.index),t.bufferSize&&(this.p=t.bufferSize),t.bufferType&&(this.q=t.bufferType),t.resize&&(this.L=t.resize)),this.q){case te:this.b=32768,this.a=new(O?Uint8Array:Array)(32768+this.p+258);break;case ne:this.b=0,this.a=new(O?Uint8Array:Array)(this.p),this.f=this.T,this.z=this.P,this.r=this.R;break;default:i(Error("invalid inflate mode"))}}function w(e,t){for(var n,r=e.j,s=e.e,o=e.input,a=e.c,h=o.length;s=h&&i(Error("input buffer is broken")),r|=o[a++]<>>t,e.e=s-t,e.c=a,n}function v(e,t){for(var n,i,r=e.j,s=e.e,o=e.input,a=e.c,h=o.length,u=t[0],c=t[1];s=h);)r|=o[a++]<>>16,e.j=r>>i,e.e=s-i,e.c=a,65535&n}function y(e){function t(e,t,n){var i,r,s,o=this.I;for(s=0;s>>0;e=i}for(var r,s=1,o=0,a=e.length,h=0;0>>0}function A(e,t){var n,r;switch(this.input=e,this.c=0,!t&&(t={})||(t.index&&(this.c=t.index),t.verify&&(this.W=t.verify)),n=e[this.c++],r=e[this.c++],15&n){case be:this.method=be;break;default:i(Error("unsupported compression method"))}0!==((n<<8)+r)%31&&i(Error("invalid fcheck flag:"+((n<<8)+r)%31)),32&r&&i(Error("fdict flag is not supported")),this.K=new _(e,{index:this.c,bufferSize:t.bufferSize,bufferType:t.bufferType,resize:t.resize})}function k(e,t){this.input=e,this.a=new(O?Uint8Array:Array)(32768),this.k=Ee.t;var n,i={};!t&&(t={})||"number"!=typeof t.compressionType||(this.k=t.compressionType);for(n in t)i[n]=t[n];i.outputBuffer=this.a,this.J=new u(this.input,i)}function S(t,n,i){e.nextTick(function(){var e,r;try{r=T(t,i)}catch(t){e=t}n(e,r)})}function T(e,t){var n;return n=new k(e).h(),t||(t={}),t.H?n:L(n)}function R(t,n,i){e.nextTick(function(){var e,r;try{r=M(t,i)}catch(t){e=t}n(e,r)})}function M(e,t){var n;return e.subarray=e.slice,n=new A(e).i(),t||(t={}),t.noBuffer?n:L(n)}function D(t,n,i){e.nextTick(function(){var e,r;try{r=x(t,i)}catch(t){e=t}n(e,r)})}function x(e,t){var n;return e.subarray=e.slice,n=new m(e).h(),t||(t={}),t.H?n:L(n)}function I(t,n,i){e.nextTick(function(){var e,r;try{r=U(t,i)}catch(t){e=t}n(e,r)})}function U(e,t){var n;return e.subarray=e.slice,n=new b(e).i(),t||(t={}),t.H?n:L(n)}function L(e){var t,i,r=new n(e.length);for(t=0,i=e.length;t>>8&255]<<16|q[e>>>16&255]<<8|q[e>>>24&255])>>32-t:q[e]>>8-t),8>t+o)a=a<>t-i-1&1,8===++o&&(o=0,r[s++]=q[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.m=o,this.index=s},r.prototype.finish=function(){var e,t=this.buffer,n=this.index;return 0N;++N){for(var G=N,j=G,z=7,G=G>>>1;G;G>>>=1)j<<=1,j|=1&G,--z;B[N]=(j<>>0}var q=B,F=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],W=O?new Uint32Array(F):F;a.prototype.getParent=function(e){return 2*((e-2)/4|0)},a.prototype.push=function(e,t){var n,i,r,s=this.buffer;for(n=this.length,s[this.length++]=t,s[this.length++]=e;0s[i]);)r=s[n],s[n]=s[i],s[i]=r,r=s[n+1],s[n+1]=s[i+1],s[i+1]=r,n=i;return this.length},a.prototype.pop=function(){var e,t,n,i,r,s=this.buffer;for(t=s[0],e=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;(i=2*r+2,!(i>=this.length))&&(i+2s[i]&&(i+=2),s[i]>s[r]);)n=s[r],s[r]=s[i],s[i]=n,n=s[r+1],s[r+1]=s[i+1],s[i+1]=n,r=i;return{index:e,value:t,length:this.length}};var H,Z=2,Y={NONE:0,M:1,t:Z,Y:3},V=[];for(H=0;288>H;H++)switch(P){case 143>=H:V.push([H+48,8]);break;case 255>=H:V.push([H-144+400,9]);break;case 279>=H:V.push([H-256+0,7]);break;case 287>=H:V.push([H-280+192,8]);break;default:i("invalid literal: "+H)}u.prototype.h=function(){var e,t,n,s,o=this.input;switch(this.k){case 0:for(n=0,s=o.length;n>>8&255,_[w++]=255&f,_[w++]=f>>>8&255,O)_.set(a,w),w+=a.length,_=_.subarray(0,w);else{for(p=0,m=a.length;pK)for(;0K?K:138,$>K-3&&$=$?(ne[J++]=17,ne[J++]=$-3,ie[17]++):(ne[J++]=18,ne[J++]=$-11,ie[18]++),K-=$;else if(ne[J++]=te[H],ie[te[H]]++,K--,3>K)for(;0K?K:6,$>K-3&&$j;j++)W[j]=L[F[j]];for(M=19;4=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:i("invalid length: "+e)}}var t,n,r=[];for(t=3;258>=t;t++)n=e(t),r[t]=n[2]<<24|n[1]<<16|n[0];return r}(),X=O?new Uint32Array(K):K;m.prototype.h=function(){var e,t,n,i,r,o,a,h,c=new(O?Uint8Array:Array)(32768),l=0,f=this.input,d=this.c,p=this.filename,g=this.w;if(c[l++]=31,c[l++]=139,c[l++]=8,e=0,this.g.fname&&(e|=Q),this.g.fcomment&&(e|=ee),this.g.fhcrc&&(e|=$),c[l++]=e,t=(Date.now?Date.now():+new Date)/1e3|0,c[l++]=255&t,c[l++]=t>>>8&255,c[l++]=t>>>16&255,c[l++]=t>>>24&255,c[l++]=0,c[l++]=J,this.g.fname!==C){for(a=0,h=p.length;a>>8&255),c[l++]=255&o;c[l++]=0}if(this.g.comment){for(a=0,h=g.length;a>>8&255),c[l++]=255&o;c[l++]=0}return this.g.fhcrc&&(n=65535&s(c,0,l),c[l++]=255&n,c[l++]=n>>>8&255),this.l.outputBuffer=c,this.l.outputIndex=l,r=new u(f,this.l),c=r.h(),l=r.b,O&&(l+8>c.buffer.byteLength?(this.a=new Uint8Array(l+8),this.a.set(new Uint8Array(c.buffer)),c=this.a):c=new Uint8Array(c.buffer)),i=s(f,C,C),c[l++]=255&i,c[l++]=i>>>8&255,c[l++]=i>>>16&255,c[l++]=i>>>24&255,h=f.length,c[l++]=255&h,c[l++]=h>>>8&255,c[l++]=h>>>16&255,c[l++]=h>>>24&255,this.c=d,O&&l>>=1){case 0:var t=this.input,n=this.c,r=this.a,s=this.b,o=t.length,a=C,h=C,u=r.length,c=C;switch(this.e=this.j=0,n+1>=o&&i(Error("invalid uncompressed block header: LEN")),a=t[n++]|t[n++]<<8,n+1>=o&&i(Error("invalid uncompressed block header: NLEN")),h=t[n++]|t[n++]<<8,a===~h&&i(Error("invalid uncompressed block header: length verify")),n+a>t.length&&i(Error("input buffer is broken")),this.q){case te:for(;s+a>r.length;){if(c=u-s,a-=c,O)r.set(t.subarray(n,n+c),s),s+=c,n+=c;else for(;c--;)r[s++]=t[n++];this.b=s,r=this.f(),s=this.b}break;case ne:for(;s+a>r.length;)r=this.f({B:2});break;default:i(Error("invalid inflate mode"))}if(O)r.set(t.subarray(n,n+a),s),s+=a,n+=a;else for(;a--;)r[s++]=t[n++];this.c=n,this.b=s,this.a=r;break;case 1:this.r(we,ye);break;case 2:y(this);break;default:i(Error("unknown BTYPE: "+e))}}return this.z()};var ie,re,se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],oe=O?new Uint16Array(se):se,ae=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],he=O?new Uint16Array(ae):ae,ue=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],ce=O?new Uint8Array(ue):ue,le=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],fe=O?new Uint16Array(le):le,de=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],pe=O?new Uint8Array(de):de,ge=new(O?Uint8Array:Array)(288);for(ie=0,re=ge.length;ie=ie?8:255>=ie?9:279>=ie?7:8;var me,_e,we=h(ge),ve=new(O?Uint8Array:Array)(30);for(me=0,_e=ve.length;me<_e;++me)ve[me]=5;var ye=h(ve);_.prototype.r=function(e,t){var n=this.a,i=this.b;this.A=e;for(var r,s,o,a,h=n.length-258;256!==(r=v(this,e));)if(256>r)i>=h&&(this.b=i,n=this.f(),i=this.b),n[i++]=r;else for(s=r-257,a=he[s],0=h&&(this.b=i,n=this.f(),i=this.b);a--;)n[i]=n[i++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},_.prototype.R=function(e,t){var n=this.a,i=this.b;this.A=e;for(var r,s,o,a,h=n.length;256!==(r=v(this,e));)if(256>r)i>=h&&(n=this.f(),h=n.length),n[i++]=r;else for(s=r-257,a=he[s],0h&&(n=this.f(),h=n.length);a--;)n[i]=n[i++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},_.prototype.f=function(){var e,t,n=new(O?Uint8Array:Array)(this.b-32768),i=this.b-32768,r=this.a;if(O)n.set(r.subarray(32768,n.length));else for(e=0,t=n.length;ee;++e)r[e]=r[i+e];return this.b=32768,r},_.prototype.T=function(e){var t,n,i,r,s=this.input.length/this.c+1|0,o=this.input,a=this.a;return e&&("number"==typeof e.B&&(s=e.B),"number"==typeof e.N&&(s+=e.N)),2>s?(n=(o.length-this.c)/this.A[2],r=258*(n/2)|0,i=rt&&(this.a.length=t),e=this.a),this.buffer=e},b.prototype.i=function(){for(var e=this.input.length;this.c>>0,s(a,C,C)!==d&&i(Error("invalid CRC-32 checksum: 0x"+s(a,C,C).toString(16)+" / 0x"+d.toString(16))),t.$=n=(p[g++]|p[g++]<<8|p[g++]<<16|p[g++]<<24)>>>0,(4294967295&a.length)!==n&&i(Error("invalid input size: "+(4294967295&a.length)+" / "+n)),this.G.push(t),this.c=g}this.S=P;var m,w,v,y=this.G,b=0,E=0;for(m=0,w=y.length;m>>0,t!==E(e)&&i(Error("invalid adler-32 checksum"))),e};var be=8,Ee=Y;k.prototype.h=function(){var e,t,n,r,s,o,a,h=0;switch(a=this.a,e=be){case be:t=Math.LOG2E*Math.log(32768)-8;break;default:i(Error("invalid compression method"))}switch(n=t<<4|e,a[h++]=n,e){case be:switch(this.k){case Ee.NONE:s=0;break;case Ee.M:s=1;break;case Ee.t:s=2;break;default:i(Error("unsupported compression type"))}break;default:i(Error("invalid compression method"))}return r=s<<6|0,a[h++]=r|31-(256*n+r)%31,o=E(this.input),this.J.b=h,a=this.J.h(),h=a.length,O&&(a=new Uint8Array(a.buffer),a.length<=h+4&&(this.a=new Uint8Array(a.length+4),this.a.set(a),a=this.a),a=a.subarray(0,h+4)),a[h++]=o>>24&255,a[h++]=o>>16&255,a[h++]=o>>8&255,a[h++]=255&o,a},t.deflate=S,t.deflateSync=T,t.inflate=R,t.inflateSync=M,t.gzip=D,t.gzipSync=x,t.gunzip=I,t.gunzipSync=U}).call(this)}).call(t,n(6),n(5).Buffer)},function(e,t,n){const i=n(0),r=n(7),s=n(28),o=n(8),a=n(43),h=n(15),u=n(54),c=n(55),l=n(20),f=n(44);class d{constructor(e){this.client=e}get pastReady(){return this.client.ws.status===i.Status.READY}newGuild(e){const t=this.client.guilds.has(e.id),n=new s(this.client,e);return this.client.guilds.set(n.id,n),this.pastReady&&!t&&(this.client.options.fetchAllMembers?n.fetchMembers().then(()=>{this.client.emit(i.Events.GUILD_CREATE,n)}):this.client.emit(i.Events.GUILD_CREATE,n)),n}newUser(e){if(this.client.users.has(e.id))return this.client.users.get(e.id);const t=new o(this.client,e);return this.client.users.set(t.id,t),t}newChannel(e,t){const n=this.client.channels.has(e.id);let r;return e.type===i.ChannelTypes.DM?r=new a(this.client,e):e.type===i.ChannelTypes.groupDM?r=new f(this.client,e):(t=t||this.client.guilds.get(e.guild_id),t&&(e.type===i.ChannelTypes.text?(r=new u(t,e),t.channels.set(r.id,r)):e.type===i.ChannelTypes.voice&&(r=new c(t,e),t.channels.set(r.id,r)))),r?(this.pastReady&&!n&&this.client.emit(i.Events.CHANNEL_CREATE,r),this.client.channels.set(r.id,r),r):null}newEmoji(e,t){const n=t.emojis.has(e.id);if(e&&!n){let n=new h(t,e);return this.client.emit(i.Events.EMOJI_CREATE,n),t.emojis.set(n.id,n),n}return n?t.emojis.get(e.id):null}killEmoji(e){e instanceof h&&e.guild&&(this.client.emit(i.Events.EMOJI_DELETE,e),e.guild.emojis.delete(e.id))}killGuild(e){const t=this.client.guilds.has(e.id);this.client.guilds.delete(e.id),t&&this.pastReady&&this.client.emit(i.Events.GUILD_DELETE,e)}killUser(e){this.client.users.delete(e.id)}killChannel(e){this.client.channels.delete(e.id),e instanceof l&&e.guild.channels.delete(e.id)}updateGuild(e,t){const n=r(e);e.setup(t),this.pastReady&&this.client.emit(i.Events.GUILD_UPDATE,n,e)}updateChannel(e,t){e.setup(t)}updateEmoji(e,t){const n=r(e);e.setup(t),this.client.emit(i.Events.GUILD_EMOJI_UPDATE,n,e)}}e.exports=d},function(e,t,n){const i=n(0);class r{constructor(e){this.client=e,this.heartbeatInterval=null}connectToWebSocket(e,t,n){this.client.emit(i.Events.DEBUG,`Authenticated using token ${e}`),this.client.token=e;const r=this.client.setTimeout(()=>n(new Error(i.Errors.TOOK_TOO_LONG)),3e5);this.client.rest.methods.getGateway().then(s=>{this.client.emit(i.Events.DEBUG,`Using gateway ${s}`),this.client.ws.connect(s),this.client.ws.once("close",e=>{4004===e.code&&n(new Error(i.Errors.BAD_LOGIN)),4010===e.code&&n(new Error(i.Errors.INVALID_SHARD))}),this.client.once(i.Events.READY,()=>{t(e),this.client.clearTimeout(r)})},n)}setupKeepAlive(e){this.heartbeatInterval=this.client.setInterval(()=>{this.client.emit("debug","Sending heartbeat"),this.client.ws.send({op:i.OPCodes.HEARTBEAT,d:this.client.ws.sequence},!0)},e)}destroy(){return new Promise(e=>{this.client.ws.destroy(),this.client.user.bot?e():e(this.client.rest.methods.logout())})}}e.exports=r},function(e,t,n){class i{constructor(e){this.client=e,this.register(n(124)),this.register(n(125)),this.register(n(126)),this.register(n(130)),this.register(n(127)),this.register(n(128)),this.register(n(129)),this.register(n(108)),this.register(n(109)),this.register(n(110)),this.register(n(112)),this.register(n(123)),this.register(n(116)),this.register(n(117)),this.register(n(111)),this.register(n(118)),this.register(n(119)),this.register(n(120)),this.register(n(131)),this.register(n(133)),this.register(n(132)),this.register(n(122)),this.register(n(113)),this.register(n(114)),this.register(n(115)),this.register(n(121))}register(e){this[e.name.replace(/Action$/,"")]=new e(this.client)}}e.exports=i},function(e,t,n){const i=n(2);class r extends i{handle(e){const t=this.client,n=t.dataManager.newChannel(e);return{channel:n}}}e.exports=r},function(e,t,n){const i=n(2);class r extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client;let n=t.channels.get(e.id);return n?(t.dataManager.killChannel(n),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)):n=this.deleted.get(e.id)||null,{channel:n}}scheduleForDeletion(e){this.client.setTimeout(()=>this.deleted.delete(e),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(2),r=n(0),s=n(7);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.id);if(n){const i=s(n);return n.setup(e),t.emit(r.Events.CHANNEL_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2),r=n(0);class s extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id),i=t.dataManager.newUser(e.user);n&&i&&t.emit(r.Events.GUILD_BAN_REMOVE,n,i)}}e.exports=s},function(e,t,n){const i=n(2),r=n(0);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client;let n=t.guilds.get(e.id);if(n){if(n.available&&e.unavailable)return n.available=!1,t.emit(r.Events.GUILD_UNAVAILABLE,n),{guild:null};t.guilds.delete(n.id),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)}else n=this.deleted.get(e.id)||null;return{guild:n}}scheduleForDeletion(e){this.client.setTimeout(()=>this.deleted.delete(e),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(2);class r extends i{handle(e,t){const n=this.client,i=n.dataManager.newEmoji(e,t);return{emoji:i}}}e.exports=r},function(e,t,n){const i=n(2);class r extends i{handle(e){const t=this.client;return t.dataManager.killEmoji(e),{data:e}}}e.exports=r},function(e,t,n){const i=n(2);class r extends i{handle(e,t){const n=this.client;for(let i of e.emojis){const e=t.emojis.has(i.id);e?n.dataManager.updateEmoji(t.emojis.get(i.id),i):i=n.dataManager.newEmoji(i,t)}for(let i of t.emojis)e.emoijs.has(i.id)||n.dataManager.killEmoji(i);return{emojis:e.emojis}}}e.exports=r},function(e,t,n){const i=n(2);class r extends i{handle(e,t){const n=e._addMember(t,!1);return{member:n}}}e.exports=r},function(e,t,n){const i=n(2),r=n(0);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){let i=n.members.get(e.user.id);return i?(n.memberCount--,n._removeMember(i),this.deleted.set(n.id+e.user.id,i),t.status===r.Status.READY&&t.emit(r.Events.GUILD_MEMBER_REMOVE,i),this.scheduleForDeletion(n.id,e.user.id)):i=this.deleted.get(n.id+e.user.id)||null,{guild:n,member:i}}return{guild:n,member:null}}scheduleForDeletion(e,t){this.client.setTimeout(()=>this.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(2),r=n(0),s=n(11);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){const i=n.roles.has(e.role.id),o=new s(n,e.role);return n.roles.set(o.id,o),i||t.emit(r.Events.GUILD_ROLE_CREATE,o),{role:o}}return{role:null}}}e.exports=o},function(e,t,n){const i=n(2),r=n(0);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){let i=n.roles.get(e.role_id);return i?(n.roles.delete(e.role_id),this.deleted.set(n.id+e.role_id,i),this.scheduleForDeletion(n.id,e.role_id),t.emit(r.Events.GUILD_ROLE_DELETE,i)):i=this.deleted.get(n.id+e.role_id)||null,{role:i}}return{role:null}}scheduleForDeletion(e,t){this.client.setTimeout(()=>this.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(2),r=n(0),s=n(7);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){const i=e.role;let o=null;const a=n.roles.get(i.id);return a&&(o=s(a),a.setup(e.role),t.emit(r.Events.GUILD_ROLE_UPDATE,o,a)),{old:o,updated:a}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2);class r extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n)for(const i of e.roles){const e=n.roles.get(i.id);e&&(e.position=i.position)}return{guild:n}}}e.exports=r},function(e,t,n){const i=n(2);class r extends i{handle(e){const t=this.client,n=t.guilds.get(e.id);if(n){e.presences=e.presences||[];for(const t of e.presences)n._setPresence(t.user.id,t);e.members=e.members||[];for(const i of e.members){const e=n.members.get(i.user.id);e?n._updateMember(e,i):n._addMember(i)}}}}e.exports=r},function(e,t,n){const i=n(2),r=n(0),s=n(7);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.id);if(n){const i=s(n);return n.setup(e),t.emit(r.Events.GUILD_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2),r=n(22);class s extends i{handle(e){const t=this.client,n=t.channels.get((e instanceof Array?e[0]:e).channel_id);if(n){if(e instanceof Array){const i=new Array(e.length);for(let s=0;sthis.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(2),r=n(3),s=n(0);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.channel_id),i=e.ids,o=new r;for(const a of i){const e=n.messages.get(a);e&&o.set(e.id,e)}return o.size>0&&t.emit(s.Events.MESSAGE_BULK_DELETE,o),{messages:o}}}e.exports=o},function(e,t,n){const i=n(2),r=n(0);class s extends i{handle(e){const t=this.client.users.get(e.user_id);if(!t)return!1;const n=this.client.channels.get(e.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(e.message_id);if(!i)return!1;if(!e.emoji)return!1;const s=i._addReaction(e.emoji,t);return s&&this.client.emit(r.Events.MESSAGE_REACTION_ADD,s,t),{message:i,reaction:s,user:t}}}e.exports=s},function(e,t,n){const i=n(2),r=n(0);class s extends i{handle(e){const t=this.client.users.get(e.user_id);if(!t)return!1;const n=this.client.channels.get(e.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(e.message_id);if(!i)return!1;if(!e.emoji)return!1;const s=i._removeReaction(e.emoji,t);return s&&this.client.emit(r.Events.MESSAGE_REACTION_REMOVE,s,t),{message:i,reaction:s,user:t}}}e.exports=s},function(e,t,n){const i=n(2),r=n(0);class s extends i{handle(e){const t=this.client.channels.get(e.channel_id);if(!t||"voice"===t.type)return!1;const n=t.messages.get(e.message_id);return!!n&&(n._clearReactions(),this.client.emit(r.Events.MESSAGE_REACTION_REMOVE_ALL,n),{message:n})}}e.exports=s},function(e,t,n){const i=n(2),r=n(0),s=n(7);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.channel_id);if(n){const i=n.messages.get(e.id);if(i){const n=s(i);return i.patch(e),i._edits.unshift(n),t.emit(r.Events.MESSAGE_UPDATE,n,i),{old:n,updated:i}}return{old:i,updated:i}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2);class r extends i{handle(e){const t=this.client,n=t.dataManager.newUser(e);return{user:n}}}e.exports=r},function(e,t,n){const i=n(2),r=n(0);class s extends i{handle(e){const t=this.client,n=t.user.notes.get(e.id),i=e.note.length?e.note:null;return t.user.notes.set(e.id,i),t.emit(r.Events.USER_NOTE_UPDATE,e.id,n,i),{old:n,updated:i}}}e.exports=s},function(e,t,n){const i=n(2),r=n(0),s=n(7);class o extends i{handle(e){const t=this.client;if(t.user){if(t.user.equals(e))return{old:t.user,updated:t.user};const n=s(t.user);return t.user.patch(e),t.emit(r.Events.USER_UPDATE,n,t.user),{old:n,updated:t.user}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){function i(e){let t=e.split("?")[0];if(t.includes("/channels/")||t.includes("/guilds/")){const e=~t.indexOf("/channels/")?t.indexOf("/channels/"):t.indexOf("/guilds/"),n=t.substring(e).split("/")[2];t=t.replace(/(\d{8,})/g,":id").replace(":id",n)}return t}const r=n(35),s=n(0);class o{constructor(e,t,n,r,s,o){this.rest=e,this.method=t,this.url=n,this.auth=r,this.data=s,this.file=o,this.route=i(this.url)}getAuth(){if(this.rest.client.token&&this.rest.client.user&&this.rest.client.user.bot)return`Bot ${this.rest.client.token}`;if(this.rest.client.token)return this.rest.client.token;throw new Error(s.Errors.NO_TOKEN); +}gen(){const e=r[this.method](this.url);if(this.auth&&e.set("authorization",this.getAuth()),this.file&&this.file.file){e.attach("file",this.file.file,this.file.name),this.data=this.data||{};for(const t in this.data)this.data[t]&&e.field(t,this.data[t])}else this.data&&e.send(this.data);return e.set("User-Agent",this.rest.userAgentManager.userAgent),e}}e.exports=o},function(e,t,n){const i=n(0),r=n(3),s=n(57),o=n(191),a=n(8),h=n(21),u=n(11),c=n(45),l=n(30),f=n(190),d=n(41);class p{constructor(e){this.rest=e}loginToken(e=this.rest.client.token){return new Promise((t,n)=>{e=e.replace(/^Bot\s*/i,""),this.rest.client.manager.connectToWebSocket(e,t,n)})}loginEmailPassword(e,t){return this.rest.client.emit("warn","Client launched using email and password - should use token instead"),this.rest.client.email=e,this.rest.client.password=t,this.rest.makeRequest("post",i.Endpoints.login,!1,{email:e,password:t}).then(e=>this.loginToken(e.token))}logout(){return this.rest.makeRequest("post",i.Endpoints.logout,!0,{})}getGateway(){return this.rest.makeRequest("get",i.Endpoints.gateway,!0).then(e=>{return this.rest.client.ws.gateway=`${e.url}/?encoding=json&v=${i.PROTOCOL_VERSION}`,this.rest.client.ws.gateway})}getBotGateway(){return this.rest.makeRequest("get",i.Endpoints.botGateway,!0)}sendMessage(e,t,{tts,nonce,embed,disableEveryone,split}={},n=null){return new Promise((i,r)=>{"undefined"!=typeof t&&(t=this.rest.client.resolver.resolveString(t)),t&&((disableEveryone||"undefined"==typeof disableEveryone&&this.rest.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),split&&(t=s(t,"object"==typeof split?split:{}))),e instanceof a||e instanceof h?this.createDM(e).then(e=>{this._sendMessageRequest(e,t,n,tts,nonce,embed,i,r)},r):this._sendMessageRequest(e,t,n,tts,nonce,embed,i,r)})}_sendMessageRequest(e,t,n,r,s,o,a,h){if(t instanceof Array){const u=[];let c=this.rest.makeRequest("post",i.Endpoints.channelMessages(e.id),!0,{content:t[0],tts:r,nonce:s},n).catch(h);for(let l=1;l<=t.length;l++)if(l{return u.push(h),this.rest.makeRequest("post",i.Endpoints.channelMessages(e.id),!0,{content:t[a],tts:r,nonce:s,embed:o},n)},h)}else c.then(e=>{u.push(e),a(this.rest.client.actions.MessageCreate.handle(u).messages)},h)}else this.rest.makeRequest("post",i.Endpoints.channelMessages(e.id),!0,{content:t,tts:r,nonce:s,embed:o},n).then(e=>a(this.rest.client.actions.MessageCreate.handle(e).message),h)}deleteMessage(e){return this.rest.makeRequest("del",i.Endpoints.channelMessage(e.channel.id,e.id),!0).then(()=>this.rest.client.actions.MessageDelete.handle({id:e.id,channel_id:e.channel.id}).message)}bulkDeleteMessages(e,t){return this.rest.makeRequest("post",`${i.Endpoints.channelMessages(e.id)}/bulk_delete`,!0,{messages:t}).then(()=>this.rest.client.actions.MessageDeleteBulk.handle({channel_id:e.id,ids:t}).messages)}updateMessage(e,t,{embed}={}){return t=this.rest.client.resolver.resolveString(t),this.rest.makeRequest("patch",i.Endpoints.channelMessage(e.channel.id,e.id),!0,{content:t,embed:embed}).then(e=>this.rest.client.actions.MessageUpdate.handle(e).updated)}createChannel(e,t,n){return this.rest.makeRequest("post",i.Endpoints.guildChannels(e.id),!0,{name:t,type:n}).then(e=>this.rest.client.actions.ChannelCreate.handle(e).channel)}createDM(e){const t=this.getExistingDM(e);return t?Promise.resolve(t):this.rest.makeRequest("post",i.Endpoints.userChannels(this.rest.client.user.id),!0,{recipient_id:e.id}).then(e=>this.rest.client.actions.ChannelCreate.handle(e).channel)}getExistingDM(e){return this.rest.client.channels.find(t=>t.recipient&&t.recipient.id===e.id)}deleteChannel(e){return(e instanceof a||e instanceof h)&&(e=this.getExistingDM(e)),e?this.rest.makeRequest("del",i.Endpoints.channel(e.id),!0).then(t=>{return t.id=e.id,this.rest.client.actions.ChannelDelete.handle(t).channel}):Promise.reject(new Error("No channel to delete."))}updateChannel(e,t){const n={};return n.name=(t.name||e.name).trim(),n.topic=t.topic||e.topic,n.position=t.position||e.position,n.bitrate=t.bitrate||e.bitrate,n.user_limit=t.userLimit||e.userLimit,this.rest.makeRequest("patch",i.Endpoints.channel(e.id),!0,n).then(e=>this.rest.client.actions.ChannelUpdate.handle(e).updated)}leaveGuild(e){return e.ownerID===this.rest.client.user.id?Promise.reject(new Error("Guild is owned by the client.")):this.rest.makeRequest("del",i.Endpoints.meGuild(e.id),!0).then(()=>this.rest.client.actions.GuildDelete.handle({id:e.id}).guild)}createGuild(e){return e.icon=this.rest.client.resolver.resolveBase64(e.icon)||null,e.region=e.region||"us-central",new Promise((t,n)=>{this.rest.makeRequest("post",i.Endpoints.guilds,!0,e).then(e=>{if(this.rest.client.guilds.has(e.id))return void t(this.rest.client.guilds.get(e.id));const i=n=>{n.id===e.id&&(this.rest.client.removeListener("guildCreate",i),this.rest.client.clearTimeout(r),t(n))};this.rest.client.on("guildCreate",i);const r=this.rest.client.setTimeout(()=>{this.rest.client.removeListener("guildCreate",i),n(new Error("Took too long to receive guild data."))},1e4)},n)})}deleteGuild(e){return this.rest.makeRequest("del",i.Endpoints.guild(e.id),!0).then(()=>this.rest.client.actions.GuildDelete.handle({id:e.id}).guild)}getUser(e){return this.rest.makeRequest("get",i.Endpoints.user(e),!0).then(e=>this.rest.client.actions.UserGet.handle(e).user)}updateCurrentUser(e){const t=this.rest.client.user,n={};return n.username=e.username||t.username,n.avatar=this.rest.client.resolver.resolveBase64(e.avatar)||t.avatar,t.bot||(n.email=e.email||t.email,n.password=this.rest.client.password,e.new_password&&(n.new_password=e.newPassword)),this.rest.makeRequest("patch",i.Endpoints.me,!0,n).then(e=>this.rest.client.actions.UserUpdate.handle(e).updated)}updateGuild(e,t){const n={};return t.name&&(n.name=t.name),t.region&&(n.region=t.region),t.verificationLevel&&(n.verification_level=Number(t.verificationLevel)),t.afkChannel&&(n.afk_channel_id=this.rest.client.resolver.resolveChannel(t.afkChannel).id),t.afkTimeout&&(n.afk_timeout=Number(t.afkTimeout)),t.icon&&(n.icon=this.rest.client.resolver.resolveBase64(t.icon)),t.owner&&(n.owner_id=this.rest.client.resolver.resolveUser(t.owner).id),t.splash&&(n.splash=this.rest.client.resolver.resolveBase64(t.splash)),this.rest.makeRequest("patch",i.Endpoints.guild(e.id),!0,n).then(e=>this.rest.client.actions.GuildUpdate.handle(e).updated)}kickGuildMember(e,t){return this.rest.makeRequest("del",i.Endpoints.guildMember(e.id,t.id),!0).then(()=>this.rest.client.actions.GuildMemberRemove.handle({guild_id:e.id,user:t.user}).member)}createGuildRole(e){return this.rest.makeRequest("post",i.Endpoints.guildRoles(e.id),!0).then(t=>this.rest.client.actions.GuildRoleCreate.handle({guild_id:e.id,role:t}).role)}deleteGuildRole(e){return this.rest.makeRequest("del",i.Endpoints.guildRole(e.guild.id,e.id),!0).then(()=>this.rest.client.actions.GuildRoleDelete.handle({guild_id:e.guild.id,role_id:e.id}).role)}setChannelOverwrite(e,t){return this.rest.makeRequest("put",`${i.Endpoints.channelPermissions(e.id)}/${t.id}`,!0,t)}deletePermissionOverwrites(e){return this.rest.makeRequest("del",`${i.Endpoints.channelPermissions(e.channel.id)}/${e.id}`,!0).then(()=>e)}getChannelMessages(e,t={}){const n=[];t.limit&&n.push(`limit=${t.limit}`),t.around?n.push(`around=${t.around}`):t.before?n.push(`before=${t.before}`):t.after&&n.push(`after=${t.after}`);let r=i.Endpoints.channelMessages(e.id);return n.length>0&&(r+=`?${n.join("&")}`),this.rest.makeRequest("get",r,!0)}getChannelMessage(e,t){const n=e.messages.get(t);return n?Promise.resolve(n):this.rest.makeRequest("get",i.Endpoints.channelMessage(e.id,t),!0)}getGuildMember(e,t){return this.rest.makeRequest("get",i.Endpoints.guildMember(e.id,t.id),!0).then(t=>this.rest.client.actions.GuildMemberGet.handle(e,t).member)}updateGuildMember(e,t){t.channel&&(t.channel_id=this.rest.client.resolver.resolveChannel(t.channel).id),t.roles&&(t.roles=t.roles.map(e=>e instanceof u?e.id:e));let n=i.Endpoints.guildMember(e.guild.id,e.id);if(e.id===this.rest.client.user.id){const r=Object.keys(t);1===r.length&&"nick"===r[0]&&(n=i.Endpoints.stupidInconsistentGuildEndpoint(e.guild.id))}return this.rest.makeRequest("patch",n,!0,t).then(t=>e.guild._updateMember(e,t).mem)}sendTyping(e){return this.rest.makeRequest("post",`${i.Endpoints.channel(e)}/typing`,!0)}banGuildMember(e,t,n=0){const r=this.rest.client.resolver.resolveUserID(t);return r?this.rest.makeRequest("put",`${i.Endpoints.guildBans(e.id)}/${r}?delete-message-days=${n}`,!0,{"delete-message-days":n}).then(()=>{if(t instanceof h)return t;const n=this.rest.client.resolver.resolveUser(r);return n?(t=this.rest.client.resolver.resolveGuildMember(e,n),t||n):r}):Promise.reject(new Error("Couldn't resolve the user ID to ban."))}unbanGuildMember(e,t){return new Promise((n,r)=>{const s=this.rest.client.resolver.resolveUserID(t);if(!s)throw new Error("Couldn't resolve the user ID to unban.");const o=(t,r)=>{t.id===e.id&&r.id===s&&(this.rest.client.removeListener(i.Events.GUILD_BAN_REMOVE,o),this.rest.client.clearTimeout(a),n(r))};this.rest.client.on(i.Events.GUILD_BAN_REMOVE,o);const a=this.rest.client.setTimeout(()=>{this.rest.client.removeListener(i.Events.GUILD_BAN_REMOVE,o),r(new Error("Took too long to receive the ban remove event."))},1e4);this.rest.makeRequest("del",`${i.Endpoints.guildBans(e.id)}/${s}`,!0).catch(e=>{this.rest.client.removeListener(i.Events.GUILD_BAN_REMOVE,o),this.rest.client.clearTimeout(a),r(e)})})}getGuildBans(e){return this.rest.makeRequest("get",i.Endpoints.guildBans(e.id),!0).then(e=>{const t=new r;for(const n of e){const e=this.rest.client.dataManager.newUser(n.user);t.set(e.id,e)}return t})}updateGuildRole(e,t){const n={};if(n.name=t.name||e.name,n.position="undefined"!=typeof t.position?t.position:e.position,n.color=t.color||e.color,"string"==typeof n.color&&n.color.startsWith("#")&&(n.color=parseInt(n.color.replace("#",""),16)),n.hoist="undefined"!=typeof t.hoist?t.hoist:e.hoist,n.mentionable="undefined"!=typeof t.mentionable?t.mentionable:e.mentionable,t.permissions){let e=0;for(let r of t.permissions)"string"==typeof r&&(r=i.PermissionFlags[r]),e|=r;n.permissions=e}else n.permissions=e.permissions;return this.rest.makeRequest("patch",i.Endpoints.guildRole(e.guild.id,e.id),!0,n).then(t=>this.rest.client.actions.GuildRoleUpdate.handle({role:t,guild_id:e.guild.id}).updated)}pinMessage(e){return this.rest.makeRequest("put",`${i.Endpoints.channel(e.channel.id)}/pins/${e.id}`,!0).then(()=>e)}unpinMessage(e){return this.rest.makeRequest("del",`${i.Endpoints.channel(e.channel.id)}/pins/${e.id}`,!0).then(()=>e)}getChannelPinnedMessages(e){return this.rest.makeRequest("get",`${i.Endpoints.channel(e.id)}/pins`,!0)}createChannelInvite(e,t){const n={};return n.temporary=t.temporary,n.max_age=t.maxAge,n.max_uses=t.maxUses,this.rest.makeRequest("post",`${i.Endpoints.channelInvites(e.id)}`,!0,n).then(e=>new c(this.rest.client,e))}deleteInvite(e){return this.rest.makeRequest("del",i.Endpoints.invite(e.code),!0).then(()=>e)}getInvite(e){return this.rest.makeRequest("get",i.Endpoints.invite(e),!0).then(e=>new c(this.rest.client,e))}getGuildInvites(e){return this.rest.makeRequest("get",i.Endpoints.guildInvites(e.id),!0).then(e=>{const t=new r;for(const n of e){const e=new c(this.rest.client,n);t.set(e.code,e)}return t})}pruneGuildMembers(e,t,n){return this.rest.makeRequest(n?"get":"post",`${i.Endpoints.guildPrune(e.id)}?days=${t}`,!0).then(e=>e.pruned)}createEmoji(e,t,n){return this.rest.makeRequest("post",`${i.Endpoints.guildEmojis(e.id)}`,!0,{name:n,image:t}).then(t=>this.rest.client.actions.EmojiCreate.handle(t,e).emoji)}deleteEmoji(e){return this.rest.makeRequest("delete",`${i.Endpoints.guildEmojis(e.guild.id)}/${e.id}`,!0).then(()=>this.rest.client.actions.EmojiDelete.handle(e).data)}getWebhook(e,t){return this.rest.makeRequest("get",i.Endpoints.webhook(e,t),!t).then(e=>new l(this.rest.client,e))}getGuildWebhooks(e){return this.rest.makeRequest("get",i.Endpoints.guildWebhooks(e.id),!0).then(e=>{const t=new r;for(const n of e)t.set(n.id,new l(this.rest.client,n));return t})}getChannelWebhooks(e){return this.rest.makeRequest("get",i.Endpoints.channelWebhooks(e.id),!0).then(e=>{const t=new r;for(const n of e)t.set(n.id,new l(this.rest.client,n));return t})}createWebhook(e,t,n){return this.rest.makeRequest("post",i.Endpoints.channelWebhooks(e.id),!0,{name:t,avatar:n}).then(e=>new l(this.rest.client,e))}editWebhook(e,t,n){return this.rest.makeRequest("patch",i.Endpoints.webhook(e.id,e.token),!1,{name:t,avatar:n}).then(t=>{return e.name=t.name,e.avatar=t.avatar,e})}deleteWebhook(e){return this.rest.makeRequest("delete",i.Endpoints.webhook(e.id,e.token),!1)}sendWebhookMessage(e,t,{avatarURL,tts,disableEveryone,embeds}={},n=null){return"undefined"!=typeof t&&(t=this.rest.client.resolver.resolveString(t)),t&&(disableEveryone||"undefined"==typeof disableEveryone&&this.rest.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),this.rest.makeRequest("post",`${i.Endpoints.webhook(e.id,e.token)}?wait=true`,!1,{username:e.name,avatar_url:avatarURL,content:t,tts:tts,file:n,embeds:embeds})}sendSlackWebhookMessage(e,t){return this.rest.makeRequest("post",`${i.Endpoints.webhook(e.id,e.token)}/slack?wait=true`,!1,t)}fetchUserProfile(e){return this.rest.makeRequest("get",i.Endpoints.userProfile(e.id),!0).then(t=>new f(e,t))}addFriend(e){return this.rest.makeRequest("post",i.Endpoints.relationships("@me"),!0,{username:e.username,discriminator:e.discriminator}).then(()=>e)}removeFriend(e){return this.rest.makeRequest("delete",`${i.Endpoints.relationships("@me")}/${e.id}`,!0).then(()=>e)}blockUser(e){return this.rest.makeRequest("put",`${i.Endpoints.relationships("@me")}/${e.id}`,!0,{type:2}).then(()=>e)}unblockUser(e){return this.rest.makeRequest("delete",`${i.Endpoints.relationships("@me")}/${e.id}`,!0).then(()=>e)}setRolePositions(e,t){return this.rest.makeRequest("patch",i.Endpoints.guildRoles(e),!0,t).then(()=>this.rest.client.actions.GuildRolesPositionUpdate.handle({guild_id:e,roles:t}).guild)}addMessageReaction(e,t){return this.rest.makeRequest("put",i.Endpoints.selfMessageReaction(e.channel.id,e.id,t),!0).then(()=>this.rest.client.actions.MessageReactionAdd.handle({user_id:this.rest.client.user.id,message_id:e.id,emoji:o(t),channel_id:e.channel.id}).reaction)}removeMessageReaction(e,t,n){let r=i.Endpoints.selfMessageReaction(e.channel.id,e.id,t);return n.id!==this.rest.client.user.id&&(r=i.Endpoints.userMessageReaction(e.channel.id,e.id,t,null,n.id)),this.rest.makeRequest("delete",r,!0).then(()=>this.rest.client.actions.MessageReactionRemove.handle({user_id:n.id,message_id:e.id,emoji:o(t),channel_id:e.channel.id}).reaction)}removeMessageReactions(e){this.rest.makeRequest("delete",i.Endpoints.messageReactions(e.channel.id,e.id),!0).then(()=>e)}getMessageReactionUsers(e,t,n=100){return this.rest.makeRequest("get",i.Endpoints.messageReaction(e.channel.id,e.id,t,n),!0)}getMyApplication(){return this.rest.makeRequest("get",i.Endpoints.myApplication,!0).then(e=>new d(this.rest.client,e))}setNote(e,t){return this.rest.makeRequest("put",i.Endpoints.note(e.id),!0,{note:t}).then(()=>e)}}e.exports=p},function(e,t,n){const i=n(71);class r extends i{constructor(e,t){super(e,t),this.requestRemaining=1,this.first=!0}push(e){super.push(e),this.handle()}handleNext(e){this.waiting||(this.waiting=!0,this.restManager.client.setTimeout(()=>{this.requestRemaining=this.requestLimit,this.waiting=!1,this.handle()},e))}execute(e){e.request.gen().end((t,n)=>{if(n&&n.headers&&(this.requestLimit=n.headers["x-ratelimit-limit"],this.requestResetTime=1e3*Number(n.headers["x-ratelimit-reset"]),this.requestRemaining=Number(n.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(n.headers.date).getTime(),this.handleNext(this.requestResetTime-Date.now()+this.timeDifference+1e3)),t)429===t.status?(this.requestRemaining=0,this.queue.unshift(e),this.restManager.client.setTimeout(()=>{this.globalLimit=!1,this.handle()},Number(n.headers["retry-after"])+500),n.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):e.reject(t);else{this.globalLimit=!1;const t=n&&n.body?n.body:{};e.resolve(t),this.first&&(this.first=!1,this.handle())}})}handle(){if(super.handle(),!(this.requestRemaining<1||0===this.queue.length||this.globalLimit))for(;this.queue.length>0&&this.requestRemaining>0;)this.execute(this.queue.shift()),this.requestRemaining--}}e.exports=r},function(e,t,n){const i=n(71);class r extends i{constructor(e,t){super(e,t),this.waiting=!1,this.endpoint=t,this.timeDifference=0}push(e){super.push(e),this.handle()}execute(e){return new Promise(t=>{e.request.gen().end((n,i)=>{if(i&&i.headers&&(this.requestLimit=i.headers["x-ratelimit-limit"],this.requestResetTime=1e3*Number(i.headers["x-ratelimit-reset"]),this.requestRemaining=Number(i.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(i.headers.date).getTime()),n)429===n.status?(this.restManager.client.setTimeout(()=>{this.waiting=!1,this.globalLimit=!1,t()},Number(i.headers["retry-after"])+500),i.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):(this.queue.shift(),this.waiting=!1,e.reject(n),t(n));else{this.queue.shift(),this.globalLimit=!1;const n=i&&i.body?i.body:{};e.resolve(n),0===this.requestRemaining?this.restManager.client.setTimeout(()=>{this.waiting=!1,t(n)},this.requestResetTime-Date.now()+this.timeDifference+1e3):(this.waiting=!1,t(n))}})})}handle(){if(super.handle(),!this.waiting&&0!==this.queue.length&&!this.globalLimit){this.waiting=!0;const e=this.queue[0];this.execute(e).then(()=>this.handle())}}}e.exports=r},function(e,t,n){const i=n(0);class r{constructor(e){this.restManager=e,this._userAgent={url:"https://github.com/hydrabolt/discord.js",version:i.Package.version}}set(e){this._userAgent.url=e.url||"https://github.com/hydrabolt/discord.js",this._userAgent.version=e.version||i.Package.version}get userAgent(){return`DiscordBot (${this._userAgent.url}, ${this._userAgent.version})`}}e.exports=r},function(e,t,n){const i=n(3),r=n(26),s=n(0),o=n(140),a=n(4).EventEmitter;class h{constructor(e){this.client=e,this.connections=new i,this.pending=new i,this.client.on("self.voiceServer",this.onVoiceServer.bind(this)),this.client.on("self.voiceStateUpdate",this.onVoiceStateUpdate.bind(this))}onVoiceServer(e){this.pending.has(e.guild_id)&&this.pending.get(e.guild_id).setTokenAndEndpoint(e.token,e.endpoint)}onVoiceStateUpdate(e){this.pending.has(e.guild_id)&&this.pending.get(e.guild_id).setSessionID(e.session_id)}sendVoiceStateUpdate(e,t={}){if(!this.client.user)throw new Error("Unable to join because there is no client user.");if(!e.permissionsFor)throw new Error("Channel does not support permissionsFor; is it really a voice channel?");const n=e.permissionsFor(this.client.user);if(!n)throw new Error("There is no permission set for the client user in this channel - are they part of the guild?");if(!n.hasPermission("CONNECT"))throw new Error("You do not have permission to join this voice channel.");t=r({guild_id:e.guild.id,channel_id:e.id,self_mute:!1,self_deaf:!1},t),this.client.ws.send({op:s.OPCodes.VOICE_STATE_UPDATE,d:t})}joinChannel(e){return new Promise((t,n)=>{if(this.client.browser)throw new Error("Voice connections are not available in browsers.");if(this.pending.get(e.guild.id))throw new Error("Already connecting to this guild's voice server.");if(!e.joinable)throw new Error("You do not have permission to join this voice channel.");const i=this.connections.get(e.guild.id);if(i)return i.channel.id!==e.id&&(this.sendVoiceStateUpdate(e),this.connections.get(e.guild.id).channel=e),void t(i);const r=new u(this,e);this.pending.set(e.guild.id,r),r.on("fail",t=>{this.pending.delete(e.guild.id),n(t)}),r.on("pass",i=>{this.pending.delete(e.guild.id),this.connections.set(e.guild.id,i),i.once("ready",()=>t(i)),i.once("error",n),i.once("disconnect",()=>this.connections.delete(e.guild.id))})})}}class u extends a{constructor(e,t){super(),this.voiceManager=e,this.channel=t,this.deathTimer=this.voiceManager.client.setTimeout(()=>this.fail(new Error("Connection not established within 15 seconds.")),15e3),this.data={},this.sendVoiceStateUpdate()}checkReady(){return!!(this.data.token&&this.data.endpoint&&this.data.session_id)&&(this.pass(),!0)}setTokenAndEndpoint(e,t){return e?t?this.data.token?void this.fail(new Error("There is already a registered token for this connection.")):this.data.endpoint?void this.fail(new Error("There is already a registered endpoint for this connection.")):(t=t.match(/([^:]*)/)[0])?(this.data.token=e,this.data.endpoint=t,void this.checkReady()):void this.fail(new Error("Failed to find an endpoint.")):void this.fail(new Error("Endpoint not provided from voice server packet.")):void this.fail(new Error("Token not provided from voice server packet."))}setSessionID(e){return e?this.data.session_id?void this.fail(new Error("There is already a registered session ID for this connection.")):(this.data.session_id=e,void this.checkReady()):void this.fail(new Error("Session ID not supplied."))}clean(){clearInterval(this.deathTimer),this.emit("fail",new Error("Clean-up triggered :fourTriggered:"))}pass(){clearInterval(this.deathTimer),this.emit("pass",this.upgrade())}fail(e){this.emit("fail",e),this.clean()}sendVoiceStateUpdate(){try{this.voiceManager.sendVoiceStateUpdate(this.channel)}catch(e){this.fail(e)}}upgrade(){return new o(this)}}e.exports=h},function(e,t,n){const i=n(142),r=n(141),s=n(0),o=n(150),a=n(152),h=n(4).EventEmitter,u=n(13);class c extends h{constructor(e){super(),this.voiceManager=e.voiceManager,this.channel=e.channel,this.speaking=!1,this.receivers=[],this.authentication=e.data,this.player=new o(this),this.player.on("debug",e=>{this.emit("debug",`audio player - ${e}`)}),this.player.on("error",e=>{this.emit("warn",e),this.player.cleanup()}),this.ssrcMap=new Map,this.ready=!1,this.sockets={},this.connect()}setSpeaking(e){this.speaking!==e&&(this.speaking=e,this.sockets.ws.sendPacket({op:s.VoiceOPCodes.SPEAKING,d:{speaking:!0,delay:0}}).catch(e=>{this.emit("debug",e)}))}disconnect(){this.emit("closing"),this.voiceManager.client.ws.send({op:s.OPCodes.VOICE_STATE_UPDATE,d:{guild_id:this.channel.guild.id,channel_id:null,self_mute:!1,self_deaf:!1}}),this.emit("disconnect")}connect(){if(this.sockets.ws)throw new Error("There is already an existing WebSocket connection.");if(this.sockets.udp)throw new Error("There is already an existing UDP connection.");this.sockets.ws=new i(this),this.sockets.udp=new r(this),this.sockets.ws.on("error",e=>this.emit("error",e)),this.sockets.udp.on("error",e=>this.emit("error",e)),this.sockets.ws.once("ready",e=>{this.authentication.port=e.port,this.authentication.ssrc=e.ssrc,this.sockets.udp.findEndpointAddress().then(e=>{this.sockets.udp.createUDPSocket(e)},e=>this.emit("error",e))}),this.sockets.ws.once("sessionDescription",(e,t)=>{this.authentication.encryptionMode=e,this.authentication.secretKey=t,this.emit("ready"),this.ready=!0}),this.sockets.ws.on("speaking",e=>{const t=this.channel.guild,n=this.voiceManager.client.users.get(e.user_id);if(this.ssrcMap.set(+e.ssrc,n),!e.speaking)for(const i of this.receivers){const e=i.opusStreams.get(n.id),t=i.pcmStreams.get(n.id);e&&(e.push(null),e.open=!1,i.opusStreams.delete(n.id)),t&&(t.push(null),t.open=!1,i.pcmStreams.delete(n.id))}this.ready&&this.emit("speaking",n,e.speaking),t._memberSpeakUpdate(e.user_id,e.speaking)})}playFile(e,t){return this.playStream(u.createReadStream(e),t)}playStream(e,{seek=0,volume=1,passes=1}={}){const t={seek:seek,volume:volume,passes:passes};return this.player.playUnknownStream(e,t)}playConvertedStream(e,{seek=0,volume=1,passes=1}={}){const t={seek:seek,volume:volume,passes:passes};return this.player.playPCMStream(e,t)}createReceiver(){const e=new a(this);return this.receivers.push(e),e}}e.exports=c},function(e,t,n){(function(t){function i(e){try{const n=new t(e);let i="";for(let r=4;r{s.lookup(this.voiceConnection.authentication.endpoint,(n,i)=>{return n?void t(n):(this.discordAddress=i,void e(i))})})}send(e){return new Promise((t,n)=>{if(!this.socket)throw new Error("Tried to send a UDP packet, but there is no socket available.");if(!this.discordAddress||!this.discordPort)throw new Error("Malformed UDP address or port.");this.socket.send(e,0,e.length,this.discordPort,this.discordAddress,i=>{i?n(i):t(e)})})}createUDPSocket(e){this.discordAddress=e;const n=this.socket=r.createSocket("udp4");n.once("message",e=>{const t=i(e);return t.error?void this.emit("error",t.error):(this.localAddress=t.address,this.localPort=t.port,void this.voiceConnection.sockets.ws.sendPacket({op:o.VoiceOPCodes.SELECT_PROTOCOL,d:{protocol:"udp",data:{address:t.address,port:t.port,mode:"xsalsa20_poly1305"}}}))});const s=new t(70);s.writeUIntBE(this.voiceConnection.authentication.ssrc,0,4),this.send(s)}}e.exports=h}).call(t,n(5).Buffer)},function(e,t,n){const i=n(76),r=n(0),s=n(153),o=n(4).EventEmitter;class a extends o{constructor(e){super(),this.voiceConnection=e,this.attempts=0,this.connect(),this.dead=!1,this.voiceConnection.on("closing",this.shutdown.bind(this))}shutdown(){this.dead=!0,this.reset()}get client(){return this.voiceConnection.voiceManager.client}reset(){this.ws&&(this.ws.readyState!==i.CLOSED&&this.ws.close(),this.ws=null),this.clearHeartbeat()}connect(){if(!this.dead){if(this.ws&&this.reset(),this.attempts>5)return void this.emit("error",new Error(`Too many connection attempts (${this.attempts}).`));this.attempts++,this.ws=new i(`wss://${this.voiceConnection.authentication.endpoint}`),this.ws.onopen=this.onOpen.bind(this),this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this),this.ws.onerror=this.onError.bind(this)}}send(e){return new Promise((t,n)=>{if(!this.ws||this.ws.readyState!==i.OPEN)throw new Error(`Voice websocket not open to send ${e}.`);this.ws.send(e,null,i=>{i?n(i):t(e)})})}sendPacket(e){try{e=JSON.stringify(e)}catch(e){return Promise.reject(e)}return this.send(e)}onOpen(){this.sendPacket({op:r.OPCodes.DISPATCH,d:{server_id:this.voiceConnection.channel.guild.id,user_id:this.client.user.id,token:this.voiceConnection.authentication.token,session_id:this.voiceConnection.authentication.session_id}}).catch(()=>{this.emit("error",new Error("Tried to send join packet, but the WebSocket is not open."))})}onMessage(e){try{return this.onPacket(JSON.parse(e.data))}catch(e){return this.onError(e)}}onClose(){this.dead||this.client.setTimeout(this.connect.bind(this),1e3*this.attempts)}onError(e){this.emit("error",e)}onPacket(e){switch(e.op){case r.VoiceOPCodes.READY:this.setHeartbeat(e.d.heartbeat_interval),this.emit("ready",e.d);break;case r.VoiceOPCodes.SESSION_DESCRIPTION:this.emit("sessionDescription",e.d.mode,new s(e.d.secret_key));break;case r.VoiceOPCodes.SPEAKING:this.emit("speaking",e.d);break;default:this.emit("unknownPacket",e)}}setHeartbeat(e){return!e||isNaN(e)?void this.onError(new Error("Tried to set voice heartbeat but no valid interval was specified.")):(this.heartbeatInterval&&(this.emit("warn","A voice heartbeat interval is being overwritten"),clearInterval(this.heartbeatInterval)),void(this.heartbeatInterval=this.client.setInterval(this.sendHeartbeat.bind(this),e)))}clearHeartbeat(){return this.heartbeatInterval?(clearInterval(this.heartbeatInterval),void(this.heartbeatInterval=null)):void this.emit("warn","Tried to clear a heartbeat interval that does not exist")}sendHeartbeat(){this.sendPacket({op:r.VoiceOPCodes.HEARTBEAT,d:null}).catch(()=>{this.emit("warn","Tried to send heartbeat, but connection is not open"),this.clearHeartbeat()})}}e.exports=a},function(e,t,n){(function(t){const i=n(4).EventEmitter,r=n(67),s=new t(24);s.fill(0);class o extends i{constructor(e,t,n,i){super(),this.player=e,this.stream=t,this.streamingData={channels:2,count:0,sequence:n.sequence,timestamp:n.timestamp,pausedTime:0},this._startStreaming(),this._triggered=!1,this._volume=i.volume,this.passes=i.passes||1,this.paused=!1,this.setVolume(i.volume||1)}get time(){return this.streamingData.count*(this.streamingData.length||0)}get totalStreamTime(){return this.time+this.streamingData.pausedTime}get volume(){return this._volume}setVolume(e){this._volume=e}setVolumeDecibels(e){this._volume=Math.pow(10,e/20)}setVolumeLogarithmic(e){this._volume=Math.pow(e,1.660964)}pause(){this._setPaused(!0)}resume(){this._setPaused(!1)}end(){this._triggerTerminalState("end","user requested")}_setSpeaking(e){this.speaking=e,this.emit("speaking",e)}_sendBuffer(e,t,n){let i=this.passes;const r=this._createPacket(t,n,this.player.opusEncoder.encode(e));for(;i--;)this.player.voiceConnection.sockets.udp.send(r).catch(e=>this.emit("debug",`Failed to send a packet ${e}`))}_createPacket(e,n,i){const o=new t(i.length+28);o.fill(0),o[0]=128,o[1]=120,o.writeUIntBE(e,2,2),o.writeUIntBE(n,4,4),o.writeUIntBE(this.player.voiceConnection.authentication.ssrc,8,4),o.copy(s,0,0,12),i=r.secretbox(i,s,this.player.voiceConnection.authentication.secretKey.key);for(let a=0;a=e.length-1);i+=2){const t=Math.min(32767,Math.max(-32767,Math.floor(this._volume*e.readInt16LE(i))));n.writeInt16LE(t,i)}return n}_send(){try{if(this._triggered)return void this._setSpeaking(!1);const e=this.streamingData;if(e.missed>=5)return void this._triggerTerminalState("end","Stream is not generating quickly enough.");if(this.paused)return e.pausedTime+=10*e.length,void this.player.voiceConnection.voiceManager.client.setTimeout(()=>this._send(),10*e.length);this._setSpeaking(!0),e.startTime||(this.emit("start"),e.startTime=Date.now());const n=1920*e.channels;let i=this.stream.read(n);if(!i)return e.missed++,e.pausedTime+=10*e.length,void this.player.voiceConnection.voiceManager.client.setTimeout(()=>this._send(),10*e.length);if(e.missed=0,i.length!==n){const e=new t(n).fill(0);i.copy(e),i=e}i=this._applyVolume(i),e.count++,e.sequence=e.sequence+1<65536?e.sequence+1:0,e.timestamp=e.timestamp+4294967295?e.timestamp+960:0,this._sendBuffer(i,e.sequence,e.timestamp);const r=e.length+(e.startTime+e.pausedTime+e.count*e.length-Date.now());this.player.voiceConnection.voiceManager.client.setTimeout(()=>this._send(),r)}catch(e){this._triggerTerminalState("error",e)}}_triggerEnd(){this.emit("end")}_triggerError(e){this.emit("end"),this.emit("error",e)}_triggerTerminalState(e,t){if(!this._triggered)switch(this.emit("debug",`Triggered terminal state ${e} - stream is now dead`),this._triggered=!0,this._setSpeaking(!1),e){case"end":this._triggerEnd(t);break;case"error":this._triggerError(t);break;default:this.emit("error","Unknown trigger state")}}_startStreaming(){if(!this.stream)return void this.emit("error","No stream");this.stream.on("end",e=>this._triggerTerminalState("end",e)),this.stream.on("error",e=>this._triggerTerminalState("error",e));const e=this.streamingData;e.length=20,e.missed=0,this.stream.once("readable",()=>this._send())}_setPaused(e){e?(this.paused=!0,this._setSpeaking(!1)):(this.paused=!1,this._setSpeaking(!0))}}e.exports=o}).call(t,n(5).Buffer)},function(e,t,n){const i=n(72);let r;class s extends i{constructor(e){super(e);try{r=n(192)}catch(e){throw e}this.encoder=new r.OpusEncoder(48e3,2)}encode(e){return super.encode(e),this.encoder.encode(e,1920)}decode(e){return super.decode(e),this.encoder.decode(e,1920); +}}e.exports=s},function(e,t,n){function i(e){try{return new e}catch(e){return null}}const r=[n(144),n(146)];t.add=(e=>{r.push(e)}),t.fetch=(()=>{for(const e of r){const t=i(e);if(t)return t}throw new Error("Couldn't find an Opus engine.")})},function(e,t,n){const i=n(72);let r;class s extends i{constructor(e){super(e);try{r=n(193)}catch(e){throw e}this.encoder=new r(48e3,2)}encode(e){return super.encode(e),this.encoder.encode(e,960)}decode(e){return super.decode(e),this.encoder.decode(e)}}e.exports=s},function(e,t,n){const i=n(4).EventEmitter;class r extends i{constructor(e){super(),this.player=e}createConvertStream(){}}e.exports=r},function(e,t,n){t.fetch=(()=>n(149))},function(e,t,n){function i(){for(const e of["ffmpeg","avconv","./ffmpeg","./avconv"])if(!s.spawnSync(e,["-h"]).error)return e;throw new Error("FFMPEG was not found on your system, so audio cannot be played. Please make sure FFMPEG is installed and in your PATH.")}const r=n(147),s=n(13),o=n(4).EventEmitter;class a extends o{constructor(e){super(),this.process=e,this.input=null,this.process.on("error",e=>this.emit("error",e))}setInput(e){this.input=e,e.pipe(this.process.stdin,{end:!1}),this.input.on("error",e=>this.emit("error",e)),this.process.stdin.on("error",e=>this.emit("error",e))}destroy(){this.emit("debug","destroying a ffmpeg process:"),this.input&&this.input.unpipe&&this.process.stdin&&(this.input.unpipe(this.process.stdin),this.emit("unpiped the user input stream from the process input stream")),this.process.stdin&&(this.process.stdin.end(),this.emit("ended the process stdin")),this.process.stdin.destroy&&(this.process.stdin.destroy(),this.emit("destroyed the process stdin")),this.process.kill&&(this.process.kill(),this.emit("killed the process"))}}class h extends r{constructor(e){super(e),this.command=i()}handleError(e,t){e.destroy&&e.destroy(),this.emit("error",t)}createConvertStream(e=0){super.createConvertStream();const t=s.spawn(this.command,["-analyzeduration","0","-loglevel","0","-i","-","-f","s16le","-ar","48000","-ac","2","-ss",String(e),"pipe:1"],{stdio:["pipe","pipe","ignore"]});return new a(t)}}e.exports=h},function(e,t,n){const i=n(148),r=n(145),s=n(4).EventEmitter,o=n(143);class a extends s{constructor(e){super(),this.voiceConnection=e,this.audioToPCM=new(i.fetch()),this.opusEncoder=r.fetch(),this.currentConverter=null,this.dispatcher=null,this.audioToPCM.on("error",e=>this.emit("error",e)),this.streamingData={channels:2,count:0,sequence:0,timestamp:0,pausedTime:0},this.voiceConnection.on("closing",()=>this.cleanup(null,"voice connection closing"))}playUnknownStream(e,{seek=0,volume=1,passes=1}={}){const t={seek:seek,volume:volume,passes:passes};e.on("end",()=>{this.emit("debug","Input stream to converter has ended")}),e.on("error",e=>this.emit("error",e));const n=this.audioToPCM.createConvertStream(t.seek);return n.on("error",e=>this.emit("error",e)),n.setInput(e),this.playPCMStream(n.process.stdout,n,t)}cleanup(e,t){this.emit("debug",`Clean up triggered due to ${t}`);const n=e&&this.dispatcher&&this.dispatcher.stream===e;!this.currentConverter||e&&!n||(this.currentConverter.destroy(),this.currentConverter=null)}playPCMStream(e,t,{seek=0,volume=1,passes=1}={}){const n={seek:seek,volume:volume,passes:passes};e.on("end",()=>this.emit("debug","PCM input stream ended")),this.cleanup(null,"outstanding play stream"),this.currentConverter=t,this.dispatcher&&(this.streamingData=this.dispatcher.streamingData),e.on("error",e=>this.emit("error",e));const i=new o(this,e,this.streamingData,n);return i.on("error",e=>this.emit("error",e)),i.on("end",()=>this.cleanup(i.stream,"dispatcher ended")),i.on("speaking",e=>this.voiceConnection.setSpeaking(e)),this.dispatcher=i,i.on("debug",e=>this.emit("debug",`Stream dispatch - ${e}`)),i}}e.exports=a},function(e,t,n){const i=n(25).Readable;class r extends i{constructor(){super(),this._packets=[],this.open=!0}_read(){}_push(e){this.open&&this.push(e)}}e.exports=r},function(e,t,n){(function(t){const i=n(4).EventEmitter,r=n(67),s=n(151),o=new t(24);o.fill(0);class a extends i{constructor(e){super(),this.queues=new Map,this.pcmStreams=new Map,this.opusStreams=new Map,this.destroyed=!1,this.voiceConnection=e,this._listener=(e=>{const t=+e.readUInt32BE(8).toString(10),n=this.voiceConnection.ssrcMap.get(t);if(n){if(this.queues.get(t))return this.queues.get(t).push(e),this.queues.get(t).map(e=>this.handlePacket(e,n)),void this.queues.delete(t);this.handlePacket(e,n)}else this.queues.has(t)||this.queues.set(t,[]),this.queues.get(t).push(e)}),this.voiceConnection.sockets.udp.socket.on("message",this._listener)}recreate(){this.destroyed&&(this.voiceConnection.sockets.udp.socket.on("message",this._listener),this.destroyed=!1)}destroy(){this.voiceConnection.sockets.udp.socket.removeListener("message",this._listener);for(const e of this.pcmStreams)e[1]._push(null),this.pcmStreams.delete(e[0]);for(const e of this.opusStreams)e[1]._push(null),this.opusStreams.delete(e[0]);this.destroyed=!0}createOpusStream(e){if(e=this.voiceConnection.voiceManager.client.resolver.resolveUser(e),!e)throw new Error("Couldn't resolve the user to create Opus stream.");if(this.opusStreams.get(e.id))throw new Error("There is already an existing stream for that user.");const t=new s;return this.opusStreams.set(e.id,t),t}createPCMStream(e){if(e=this.voiceConnection.voiceManager.client.resolver.resolveUser(e),!e)throw new Error("Couldn't resolve the user to create PCM stream.");if(this.pcmStreams.get(e.id))throw new Error("There is already an existing stream for that user.");const t=new s;return this.pcmStreams.set(e.id,t),t}handlePacket(e,n){e.copy(o,0,0,12);let i=r.secretbox.open(e.slice(12),o,this.voiceConnection.authentication.secretKey.key);if(!i)return void this.emit("warn","Failed to decrypt voice packet");if(i=new t(i),this.opusStreams.get(n.id)&&this.opusStreams.get(n.id)._push(i),this.emit("opus",n,i),this.listenerCount("pcm")>0||this.pcmStreams.size>0){const e=this.voiceConnection.player.opusEncoder.decode(i);this.pcmStreams.get(n.id)&&this.pcmStreams.get(n.id)._push(e),this.emit("pcm",n,e)}}}e.exports=a}).call(t,n(5).Buffer)},function(e,t){class n{constructor(e){this.key=new Uint8Array(new ArrayBuffer(e.length));for(const t in e)this.key[t]=e[t]}}e.exports=n},function(e,t,n){const i="undefined"!=typeof window,r=i?window.WebSocket:n(76),s=n(4).EventEmitter,o=n(0),a=i?n(104).inflateSync:n(83).inflateSync,h=n(155),u=n(73);class c extends s{constructor(e){super(),this.client=e,this.packetManager=new h(this),this.status=o.Status.IDLE,this.sessionID=null,this.sequence=-1,this.gateway=null,this.normalReady=!1,this.ws=null,this.disabledEvents={};for(const t in e.options.disabledEvents)this.disabledEvents[t]=!0;this.first=!0}_connect(e){this.client.emit("debug",`Connecting to gateway ${e}`),this.normalReady=!1,this.status!==o.Status.RECONNECTING&&(this.status=o.Status.CONNECTING),this.ws=new r(e),i&&(this.ws.binaryType="arraybuffer"),this.ws.onopen=(()=>this.eventOpen()),this.ws.onclose=(e=>this.eventClose(e)),this.ws.onmessage=(e=>this.eventMessage(e)),this.ws.onerror=(e=>this.eventError(e)),this._queue=[],this._remaining=3}connect(e){this.first?(this._connect(e),this.first=!1):this.client.setTimeout(()=>this._connect(e),5500)}send(e,t=false){return t?void this._send(JSON.stringify(e)):(this._queue.push(JSON.stringify(e)),void this.doQueue())}destroy(){this.ws.close(1e3),this._queue=[],this.status=o.Status.IDLE}_send(e){this.ws.readyState===r.OPEN&&(this.emit("send",e),this.ws.send(e))}doQueue(){const e=this._queue[0];if(this.ws.readyState===r.OPEN&&e){if(0===this._remaining)return void this.client.setTimeout(()=>{this.doQueue()},1e3);this._remaining--,this._send(e),this._queue.shift(),this.doQueue(),this.client.setTimeout(()=>this._remaining++,1e3)}}eventOpen(){this.client.emit("debug","Connection to gateway opened"),this.status===o.Status.RECONNECTING?this._sendResume():this._sendNewIdentify()}_sendResume(){if(!this.sessionID)return void this._sendNewIdentify();this.client.emit("debug","Identifying as resumed session");const e={token:this.client.token,session_id:this.sessionID,seq:this.sequence};this.send({op:o.OPCodes.RESUME,d:e})}_sendNewIdentify(){this.reconnecting=!1;const e=this.client.options.ws;e.token=this.client.token,this.client.options.shardCount>0&&(e.shard=[Number(this.client.options.shardId),Number(this.client.options.shardCount)]),this.client.emit("debug","Identifying as new session"),this.send({op:o.OPCodes.IDENTIFY,d:e}),this.sequence=-1}eventClose(e){this.emit("close",e),this.client.clearInterval(this.client.manager.heartbeatInterval),this.reconnecting||this.client.emit(o.Events.DISCONNECT),4004!==e.code&&4010!==e.code&&(this.reconnecting||1e3===e.code||this.tryReconnect())}eventMessage(e){let t=e.data;try{"string"!=typeof t&&(t instanceof ArrayBuffer&&(t=u(t)),t=a(t).toString()),t=JSON.parse(t)}catch(e){return this.eventError(new Error(o.Errors.BAD_WS_MESSAGE))}return this.client.emit("raw",t),t.op===o.OPCodes.HELLO&&this.client.manager.setupKeepAlive(t.d.heartbeat_interval),this.packetManager.handle(t)}eventError(e){this.client.listenerCount("error")>0&&this.client.emit("error",e),this.ws.close()}_emitReady(e=true){this.status=o.Status.READY,this.client.emit(o.Events.READY),this.packetManager.handleQueue(),this.normalReady=e}checkIfReady(){if(this.status!==o.Status.READY&&this.status!==o.Status.NEARLY){let e=0;for(const t of this.client.guilds.keys())e+=this.client.guilds.get(t).available?0:1;if(0===e){if(this.status=o.Status.NEARLY,this.client.options.fetchAllMembers){const e=this.client.guilds.map(e=>e.fetchMembers());return void Promise.all(e).then(()=>this._emitReady(),e=>{this.client.emit(o.Events.WARN,"Error in pre-ready guild member fetching"),this.client.emit(o.Events.ERROR,e),this._emitReady()})}this._emitReady()}}}tryReconnect(){this.status=o.Status.RECONNECTING,this.ws.close(),this.packetManager.handleQueue(),this.client.emit(o.Events.RECONNECTING),this.connect(this.client.ws.gateway)}}e.exports=c},function(e,t,n){const i=n(0),r=[i.WSEvents.READY,i.WSEvents.GUILD_CREATE,i.WSEvents.GUILD_DELETE,i.WSEvents.GUILD_MEMBERS_CHUNK,i.WSEvents.GUILD_MEMBER_ADD,i.WSEvents.GUILD_MEMBER_REMOVE];class s{constructor(e){this.ws=e,this.handlers={},this.queue=[],this.register(i.WSEvents.READY,n(181)),this.register(i.WSEvents.GUILD_CREATE,n(162)),this.register(i.WSEvents.GUILD_DELETE,n(163)),this.register(i.WSEvents.GUILD_UPDATE,n(172)),this.register(i.WSEvents.GUILD_BAN_ADD,n(160)),this.register(i.WSEvents.GUILD_BAN_REMOVE,n(161)),this.register(i.WSEvents.GUILD_MEMBER_ADD,n(164)),this.register(i.WSEvents.GUILD_MEMBER_REMOVE,n(165)),this.register(i.WSEvents.GUILD_MEMBER_UPDATE,n(166)),this.register(i.WSEvents.GUILD_ROLE_CREATE,n(168)),this.register(i.WSEvents.GUILD_ROLE_DELETE,n(169)),this.register(i.WSEvents.GUILD_ROLE_UPDATE,n(170)),this.register(i.WSEvents.GUILD_MEMBERS_CHUNK,n(167)),this.register(i.WSEvents.CHANNEL_CREATE,n(156)),this.register(i.WSEvents.CHANNEL_DELETE,n(157)),this.register(i.WSEvents.CHANNEL_UPDATE,n(159)),this.register(i.WSEvents.CHANNEL_PINS_UPDATE,n(158)),this.register(i.WSEvents.PRESENCE_UPDATE,n(180)),this.register(i.WSEvents.USER_UPDATE,n(186)),this.register(i.WSEvents.USER_NOTE_UPDATE,n(185)),this.register(i.WSEvents.VOICE_STATE_UPDATE,n(188)),this.register(i.WSEvents.TYPING_START,n(184)),this.register(i.WSEvents.MESSAGE_CREATE,n(173)),this.register(i.WSEvents.MESSAGE_DELETE,n(174)),this.register(i.WSEvents.MESSAGE_UPDATE,n(179)),this.register(i.WSEvents.MESSAGE_DELETE_BULK,n(175)),this.register(i.WSEvents.VOICE_SERVER_UPDATE,n(187)),this.register(i.WSEvents.GUILD_SYNC,n(171)),this.register(i.WSEvents.RELATIONSHIP_ADD,n(182)),this.register(i.WSEvents.RELATIONSHIP_REMOVE,n(183)),this.register(i.WSEvents.MESSAGE_REACTION_ADD,n(176)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE,n(177)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE_ALL,n(178))}get client(){return this.ws.client}register(e,t){this.handlers[e]=new t(this)}handleQueue(){this.queue.forEach((e,t)=>{this.handle(this.queue[t]),this.queue.splice(t,1)})}setSequence(e){e&&e>this.ws.sequence&&(this.ws.sequence=e)}handle(e){return e.op===i.OPCodes.RECONNECT?(this.setSequence(e.s),this.ws.tryReconnect(),!1):e.op===i.OPCodes.INVALID_SESSION?(this.ws.sessionID=null,this.ws._sendNewIdentify(),!1):(e.op===i.OPCodes.HEARTBEAT_ACK&&this.ws.client.emit("debug","Heartbeat acknowledged"),this.ws.status===i.Status.RECONNECTING&&(this.ws.reconnecting=!1,this.ws.checkIfReady()),this.setSequence(e.s),void 0===this.ws.disabledEvents[e.t]&&(this.ws.status!==i.Status.READY&&r.indexOf(e.t)===-1?(this.queue.push(e),!1):!!this.handlers[e.t]&&this.handlers[e.t].handle(e)))}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.ChannelCreate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.ChannelDelete.handle(n);i.channel&&t.emit(r.Events.CHANNEL_DELETE,i.channel)}}e.exports=s},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.channels.get(n.channel_id),s=new Date(n.last_pin_timestamp);i&&s&&t.emit(r.Events.CHANNEL_PINS_UPDATE,i,s)}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.ChannelUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id),s=t.users.get(n.user.id);i&&s&&t.emit(r.Events.GUILD_BAN_ADD,i,s)}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildBanRemove.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.id);i?i.available||n.unavailable||(i.setup(n),this.packetManager.ws.checkIfReady()):t.dataManager.newGuild(n)}}e.exports=r},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.GuildDelete.handle(n);i.guild&&t.emit(r.Events.GUILD_DELETE,i.guild)}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);i&&(i.memberCount++,i._addMember(n))}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildMemberRemove.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=i.members.get(n.user.id);e&&i._updateMember(e,n)}}}e.exports=r},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id),s=[];if(i)for(const o of n.members)s.push(i._addMember(o,!1));i._checkChunks(),t.emit(r.Events.GUILD_MEMBERS_CHUNK,s)}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleCreate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleDelete.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildSync.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.MessageCreate.handle(n);i.message&&t.emit(r.Events.MESSAGE_CREATE,i.message)}}e.exports=s},function(e,t,n){const i=n(1),r=n(0);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.MessageDelete.handle(n);i.message&&t.emit(r.Events.MESSAGE_DELETE,i.message)}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageDeleteBulk.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionAdd.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionRemove.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionRemoveAll.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1),r=n(0),s=n(7);class o extends i{handle(e){const t=this.packetManager.client,n=e.d;let i=t.users.get(n.user.id);const o=t.guilds.get(n.guild_id);if(!i){if(!n.user.username)return;i=t.dataManager.newUser(n.user)}const a=s(i);if(i.patch(n.user),i.equals(a)||t.emit(r.Events.USER_UPDATE,a,i),o){let e=o.members.get(i.id);if(e||"offline"===n.status||(e=o._addMember({user:i,roles:n.roles,deaf:!1,mute:!1},!1),t.emit(r.Events.GUILD_MEMBER_AVAILABLE,e)),e){const a=s(e);e.presence&&(a.frozenPresence=s(e.presence)),o._setPresence(i.id,n),t.emit(r.Events.PRESENCE_UPDATE,a,e)}else o._setPresence(i.id,n)}}}e.exports=o},function(e,t,n){const i=n(1),r=n(42);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=new r(t,n.user);t.user=i,t.readyAt=new Date,t.users.set(i.id,i);for(const s of n.guilds)t.dataManager.newGuild(s);for(const o of n.private_channels)t.dataManager.newChannel(o);for(const a of n.relationships){const e=t.dataManager.newUser(a.user);1===a.type?t.user.friends.set(e.id,e):2===a.type&&t.user.blocked.set(e.id,e)}n.presences=n.presences||[];for(const h of n.presences)t.dataManager.newUser(h.user),t._setPresence(h.user.id,h);if(n.notes)for(const u in n.notes){let e=n.notes[u];e.length||(e=null),t.user.notes.set(u,e)}!t.user.bot&&t.options.sync&&t.setInterval(t.syncGuilds.bind(t),3e4),t.once("ready",t.syncGuilds.bind(t)),t.users.has("1")||t.dataManager.newUser({id:"1",username:"Clyde",discriminator:"0000",avatar:"https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png",bot:!0,status:"online",game:null,verified:!0}),t.setTimeout(()=>{t.ws.normalReady||t.ws._emitReady(!1)},1200*n.guilds.length),this.packetManager.ws.sessionID=n.session_id,this.packetManager.ws.checkIfReady()}}e.exports=s},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;1===n.type?t.fetchUser(n.id).then(e=>{t.user.friends.set(e.id,e)}):2===n.type&&t.fetchUser(n.id).then(e=>{t.user.blocked.set(e.id,e)})}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;2===n.type?t.user.blocked.has(n.id)&&t.user.blocked.delete(n.id):1===n.type&&t.user.friends.has(n.id)&&t.user.friends.delete(n.id)}}e.exports=r},function(e,t,n){function i(e,t){return e.client.setTimeout(()=>{e.client.emit(s.Events.TYPING_STOP,e,t,e._typing.get(t.id)),e._typing.delete(t.id)},6e3)}const r=n(1),s=n(0);class o extends r{handle(e){const t=this.packetManager.client,n=e.d,r=t.channels.get(n.channel_id),o=t.users.get(n.user_id),h=new Date(1e3*n.timestamp);if(r&&o){if("voice"===r.type)return void t.emit(s.Events.WARN,`Discord sent a typing packet to voice channel ${r.id}`);if(r._typing.has(o.id)){const e=r._typing.get(o.id);e.lastTimestamp=h,e.resetTimeout(i(r,o))}else r._typing.set(o.id,new a(t,h,h,i(r,o))),t.emit(s.Events.TYPING_START,r,o)}}}class a{constructor(e,t,n,i){this.client=e,this.since=t,this.lastTimestamp=n,this._timeout=i}resetTimeout(e){this.client.clearTimeout(this._timeout),this._timeout=e}get elapsedTime(){return Date.now()-this.since}}e.exports=o},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.UserNoteUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.UserUpdate.handle(n)}}e.exports=r},function(e,t,n){const i=n(1);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.emit("self.voiceServer",n)}}e.exports=r},function(e,t,n){const i=n(1),r=n(0),s=n(7);class o extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=i.members.get(n.user_id);if(e){const i=s(e);e.voiceChannel&&e.voiceChannel.id!==n.channel_id&&e.voiceChannel.members.delete(i.id),n.channel_id||(e.speaking=null),e.user.id===t.user.id&&n.channel_id&&t.emit("self.voiceStateUpdate",n);const o=t.channels.get(n.channel_id);o&&o.members.set(e.user.id,e),e.serverMute=n.mute,e.serverDeaf=n.deaf,e.selfMute=n.self_mute,e.selfDeaf=n.self_deaf,e.voiceSessionID=n.session_id,e.voiceChannelID=n.channel_id,t.emit(r.Events.VOICE_STATE_UPDATE,i,e)}}}}e.exports=o},function(e,t){class n{constructor(e,t){this.user=e,this.setup(t)}setup(e){this.type=e.type,this.name=e.name,this.id=e.id,this.revoked=e.revoked,this.integrations=e.integrations}}e.exports=n},function(e,t,n){const i=n(3),r=n(189);class s{constructor(e,t){this.user=e,this.client=this.user.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.mutualGuilds=new i,this.connections=new i,this.setup(t)}setup(e){for(const t of e.mutual_guilds)this.client.guilds.has(t.id)&&this.mutualGuilds.set(t.id,this.client.guilds.get(t.id));for(const n of e.connected_accounts)this.connections.set(n.id,new r(this.user,n))}}e.exports=s},function(e,t){e.exports=function(e){if(e.includes("%")&&(e=decodeURIComponent(e)),e.includes(":")){const[t,n]=e.split(":");return{name:t,id:n}}return{name:e,id:null}}},function(e,t){var n=new Error('Cannot find module "undefined"');throw n.code="MODULE_NOT_FOUND",n},function(e,t){var n=new Error('Cannot find module "undefined"');throw n.code="MODULE_NOT_FOUND",n},function(e,t){},function(e,t){},function(e,t,n){e.exports={Client:n(77),WebhookClient:n(78),Shard:n(39),ShardClientUtil:n(40),ShardingManager:n(79),Collection:n(3),splitMessage:n(57),escapeMarkdown:n(23),fetchRecommendedShards:n(56),Channel:n(14),ClientOAuth2Application:n(41),ClientUser:n(42),DMChannel:n(43),Emoji:n(15),EvaluatedPermissions:n(27),Game:n(9).Game,GroupDMChannel:n(44),Guild:n(28),GuildChannel:n(20),GuildMember:n(21),Invite:n(45),Message:n(22),MessageAttachment:n(46),MessageCollector:n(47),MessageEmbed:n(48),MessageReaction:n(49),OAuth2Application:n(50),PartialGuild:n(51),PartialGuildChannel:n(52),PermissionOverwrites:n(53),Presence:n(9).Presence,ReactionEmoji:n(29),Role:n(11),TextChannel:n(54),User:n(8),VoiceChannel:n(55),Webhook:n(30),version:n(38).version},"undefined"!=typeof window&&(window.Discord=e.exports)}]); \ No newline at end of file