!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Scorocode=e()}}(function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return i(r?r:e)},l,l.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;st;++t)u[t]=e[t],c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(e){var t,r,n,i,o,s,a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new l(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;n>t;t+=4,r+=3)i=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}function o(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function s(e,t,r){for(var n,i=[],s=t;r>s;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(o(n));return i.join("")}function a(e){for(var t,r=e.length,n=r%3,i="",o=[],a=16383,c=0,l=r-n;l>c;c+=a)o.push(s(e,c,c+a>l?l:c+a));return 1===n?(t=e[r-1],i+=u[t>>2],i+=u[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=u[t>>10],i+=u[t>>4&63],i+=u[t<<2&63],i+="="),o.push(i),o.join("")}r.toByteArray=i,r.fromByteArray=a;var u=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],2:[function(e,t,r){(function(n,i){function o(t){"string"==typeof t?t={bindings:t}:t||(t={}),t.__proto__=f,t.module_root||(t.module_root=r.getRoot(r.getFileName())),".node"!=a.extname(t.bindings)&&(t.bindings+=".node");for(var n,i,o,s=[],c=0,l=t["try"].length;l>c;c++){n=u.apply(null,t["try"][c].map(function(e){return t[e]||e})),s.push(n);try{return i=t.path?e.resolve(n):e(n),t.path||(i.path=n),i}catch(h){if(!/not find/i.test(h.message))throw h}}throw o=new Error("Could not locate the bindings file. Tried:\n"+s.map(function(e){return t.arrow+e}).join("\n")),o.tries=s,o}var s=e("fs"),a=e("path"),u=a.join,c=a.dirname,l=s.existsSync||a.existsSync,f={arrow:n.env.NODE_BINDINGS_ARROW||" → ",compiled:n.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:n.platform,arch:n.arch,version:n.versions.node,bindings:"bindings.node","try":[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"]]};t.exports=r=o,r.getFileName=function(e){var t,r=Error.prepareStackTrace,n=Error.stackTraceLimit,o={};return Error.stackTraceLimit=10,Error.prepareStackTrace=function(r,n){for(var o=0,s=n.length;s>o;o++)if(t=n[o].getFileName(),t!==i){if(!e)return;if(t!==e)return}},Error.captureStackTrace(o),o.stack,Error.prepareStackTrace=r,Error.stackTraceLimit=n,t},r.getRoot=function(e){for(var t,r=c(e);;){if("."===r&&(r=n.cwd()),l(u(r,"package.json"))||l(u(r,"node_modules")))return r;if(t===r)throw new Error('Could not find module root given file: "'+e+'". Do you have a `package.json` file? ');t=r,r=u(r,"..")}}}).call(this,e("_process"),"/node_modules/bindings/bindings.js")},{_process:3,fs:void 0,path:void 0}],3:[function(e,t,r){},{}],4:[function(e,t,r){(function(t){"use strict";function n(){try{var e=new Uint8Array(1);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}function i(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(i()=t?o(e,t):void 0!==r?"string"==typeof n?o(e,t).fill(r,n):o(e,t).fill(r):o(e,t)}function l(e,t){if(u(t),e=o(e,0>t?0:0|v(t)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;t>r;r++)e[r]=0;return e}function f(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!s.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|g(t,r);return e=o(e,n),e.write(t,r),e}function h(e,t){var r=0|v(t.length);e=o(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function p(e,t,r,n){if(t.byteLength,0>r||t.byteLength=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),s.alloc(+e)}function g(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(n)return K(e).length;t=(""+t).toLowerCase(),n=!0}}function _(e,t,r){var n=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,t>>>=0,t>=r)return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return T(this,t,r);case"binary":return L(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,s=e.length,a=t.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}for(var u=-1,c=0;s>r+c;c++)if(i(e,r+c)===i(t,-1===u?0:c-u)){if(-1===u&&(u=c),c-u+1===a)return(r+u)*o}else-1!==u&&(c-=c-u),u=-1;return-1}function b(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function E(e,t,r,n){return Y(K(t,e.length-r),e,r,n)}function S(e,t,r,n){return Y(J(t),e,r,n)}function x(e,t,r,n){return S(e,t,r,n)}function O(e,t,r,n){return Y($(t),e,r,n)}function P(e,t,r,n){return Y(V(t,e.length-r),e,r,n)}function k(e,t,r){return 0===t&&r===e.length?z.fromByteArray(e):z.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;r>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(r>=i+a){var u,c,l,f;switch(a){case 1:128>o&&(s=o);break;case 2:u=e[i+1],128===(192&u)&&(f=(31&o)<<6|63&u,f>127&&(s=f));break;case 3:u=e[i+1],c=e[i+2],128===(192&u)&&128===(192&c)&&(f=(15&o)<<12|(63&u)<<6|63&c,f>2047&&(55296>f||f>57343)&&(s=f));break;case 4:u=e[i+1],c=e[i+2],l=e[i+3],128===(192&u)&&128===(192&c)&&128===(192&l)&&(f=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&l,f>65535&&1114112>f&&(s=f))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return R(n)}function R(e){var t=e.length;if(Q>=t)return String.fromCharCode.apply(String,e);for(var r="",n=0;t>n;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Q));return r}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(127&e[i]);return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function U(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=t;r>o;o++)i+=W(e[o]);return i}function N(e,t,r){for(var n=e.slice(t,r),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||o>t)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function I(e,t,r,n){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);o>i;i++)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(e,t,r,n){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);o>i;i++)e[r+i]=t>>>8*(n?i:3-i)&255}function M(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function j(e,t,r,n,i){return i||M(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(e,t,r,n,23,4),r+4}function q(e,t,r,n,i){return i||M(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(e,t,r,n,52,8),r+8}function F(e){if(e=H(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function H(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function W(e){return 16>e?"0"+e.toString(16):e.toString(16)}function K(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],s=0;n>s;s++){if(r=e.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>r){if((t-=1)<0)break;o.push(r)}else if(2048>r){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function J(e){for(var t=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function $(e){return z.toByteArray(F(e))}function Y(e,t,r,n){for(var i=0;n>i&&!(i+r>=t.length||i>=e.length);i++)t[i+r]=e[i];return i}function G(e){return e!==e}var z=e("base64-js"),Z=e("ieee754"),X=e("isarray");r.Buffer=s,r.SlowBuffer=y,r.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=i(),s.poolSize=8192,s._augment=function(e){return e.__proto__=s.prototype,e},s.from=function(e,t,r){return a(null,e,t,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(e,t,r){return c(null,e,t,r)},s.allocUnsafe=function(e){return l(null,e)},s.allocUnsafeSlow=function(e){return l(null,e)},s.isBuffer=function(e){return!(null==e||!e._isBuffer)},s.compare=function(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);o>i;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return n>r?-1:r>n?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!X(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var r;if(void 0===t)for(t=0,r=0;rt;t+=2)m(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;e>t;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},s.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):_.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),0>t||r>e.length||0>n||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,a=r-t,u=Math.min(o,a),c=this.slice(n,i),l=e.slice(t,r),f=0;u>f;++f)if(c[f]!==l[f]){o=c[f],a=l[f];break}return a>o?-1:o>a?1:0},s.prototype.indexOf=function(e,t,r){if("string"==typeof t?(r=t,t=0):t>2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:w(this,e,t,r);if("number"==typeof e)return s.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):w(this,[e],t,r);throw new TypeError("val must be string, number or Buffer")},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t=0|t,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(0>r||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":return S(this,e,t,r);case"binary":return x(this,e,t,r);case"base64":return O(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;s.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var n;if(s.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=s.prototype;else{var i=t-e;n=new s(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+e]}return n},s.prototype.readUIntLE=function(e,t,r){e=0|e,t=0|t,r||A(e,t,this.length);for(var n=this[e],i=1,o=0;++o0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return t||A(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||A(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||A(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||A(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||A(e,t,this.length);for(var n=this[e],i=1,o=0;++o=i&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||A(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||A(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){t||A(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||A(e,4,this.length),Z.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||A(e,4,this.length),Z.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||A(e,8,this.length),Z.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||A(e,8,this.length),Z.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=0|t,r=0|r,!n){var i=Math.pow(2,8*r)-1;D(this,e,t,r,i,0)}var o=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+o]=e/s&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=0|t,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++oe&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=0|t,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)0>e&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):I(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):I(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||D(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return q(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return q(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-tr&&n>t)for(i=o-1;i>=0;i--)e[i+t]=this[i+r];else if(1e3>o||!s.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);256>i&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e=255&e);if(0>t||this.length=r)return this;t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;r>o;o++)this[o]=e;else{var a=s.isBuffer(e)?e:K(new s(e,n).toString()),u=a.length;for(o=0;r-t>o;o++)this[o+t]=a[o%u]}return this};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":1,ieee754:8,isarray:5}],5:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],6:[function(e,t,r){"use strict";t.exports.BufferUtil={merge:function(e,t){for(var r=0,n=0,i=t.length;i>r;++r){var o=t[r];o.copy(e,n),n+=o.length}},mask:function(e,t,r,n,i){for(var o,s=t.readUInt32LE(0,!0),a=0;i-3>a;a+=4)o=s^e.readUInt32LE(a,!0),0>o&&(o=4294967296+o),r.writeUInt32LE(o,n+a,!0);switch(i%4){case 3:r[n+a+2]=e[a+2]^t[2];case 2:r[n+a+1]=e[a+1]^t[1];case 1:r[n+a]=e[a]^t[0]}},unmask:function(e,t){for(var r,n=t.readUInt32LE(0,!0),i=e.length,o=0;i-3>o;o+=4)r=n^e.readUInt32LE(o,!0),0>r&&(r=4294967296+r),e.writeUInt32LE(r,o,!0);switch(i%4){case 3:e[o+2]=e[o+2]^t[2];case 2:e[o+1]=e[o+1]^t[1];case 1:e[o]=e[o]^t[0]}}}},{}],7:[function(e,t,r){"use strict";try{t.exports=e("bindings")("bufferutil")}catch(n){t.exports=e("./fallback")}},{"./fallback":6,bindings:2}],8:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,h=r?-1:1,p=e[t+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,v=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+f>=1?h/u:h*Math.pow(2,1-f),t*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*v}},{}],9:[function(e,t,r){function n(e){var t={},r=this.value={};Object.keys(e).forEach(function(n){t[n]=e[n],Object.defineProperty(r,n,{get:function(){return t[n]},configurable:!1,enumerable:!0})}),this.reset=function(){return Object.keys(e).forEach(function(r){t[r]=e[r]}),this},this.merge=function(e,r){if(e=e||{},"[object Array]"===Object.prototype.toString.call(r)){for(var n=[],i=0,o=r.length;o>i;++i){var s=r[i];s in e||n.push(s)}if(n.length>0)throw n.length>1?new Error("options "+n.slice(0,n.length-1).join(", ")+" and "+n[n.length-1]+" must be defined"):new Error("option "+n[0]+" must be defined")}return Object.keys(e).forEach(function(r){r in t&&(t[r]=e[r])}),this},this.copy=function(t){var n={};return Object.keys(e).forEach(function(e){-1!==t.indexOf(e)&&(n[e]=r[e])}),n},this.read=function(e,t){if("function"==typeof t){var r=this;i.readFile(e,function(e,n){if(e)return t(e);var i=JSON.parse(n);r.merge(i),t()})}else{var n=JSON.parse(i.readFileSync(e));this.merge(n)}return this},this.isDefined=function(e){return"undefined"!=typeof r[e]},this.isDefinedAndNonNull=function(e){return"undefined"!=typeof r[e]&&null!==r[e]},Object.freeze(r),Object.freeze(this)}var i=e("fs");t.exports=n},{fs:void 0}],10:[function(e,t,r){"use strict";function n(e){return this instanceof n?(this.id=o++,void(this.ee=e)):new n(e)}var i=Object.prototype.hasOwnProperty,o=0;n.prototype.on=function(e,t,r){return t.__ultron=this.id,this.ee.on(e,t,r),this},n.prototype.once=function(e,t,r){return t.__ultron=this.id,this.ee.once(e,t,r),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 r=0;rthis._buffer.length){var t=new r(this._growStrategy(e));this._buffer=t,this._offset=0}this._used+=e;var n=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,n},n.prototype.reset=function(e){var t=this._shrinkStrategy();tn;++n){var o=t[n];o.copy(e,r),r+=o.length}},mask:function(e,t,r,n,i){for(var o=t.readUInt32LE(0,!0),s=0;i-3>s;s+=4){var a=o^e.readUInt32LE(s,!0);0>a&&(a=4294967296+a),r.writeUInt32LE(a,n+s,!0)}switch(i%4){case 3:r[n+s+2]=e[s+2]^t[2];case 2:r[n+s+1]=e[s+1]^t[1];case 1:r[n+s]=e[s]^t[0];case 0:}},unmask:function(e,t){for(var r=t.readUInt32LE(0,!0),n=e.length,i=0;n-3>i;i+=4){var o=r^e.readUInt32LE(i,!0);0>o&&(o=4294967296+o),e.writeUInt32LE(o,i,!0)}switch(n%4){case 3:e[i+2]=e[i+2]^t[2];case 2:e[i+1]=e[i+1]^t[1];case 1:e[i]=e[i]^t[0];case 0:}}}},{}],16:[function(e,t,r){"use strict";try{t.exports=e("bufferutil")}catch(n){t.exports=e("./BufferUtil.fallback")}},{"./BufferUtil.fallback":15,bufferutil:7}],17:[function(e,t,r){t.exports={isValidErrorCode:function(e){return e>=1e3&&1011>=e&&1004!=e&&1005!=e&&1006!=e||e>=3e3&&4999>=e},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"}},{}],18:[function(e,t,r){function n(e){e=e||"";var t={};return e.split(",").forEach(function(e){var r=e.split(";"),n=r.shift().trim(),i=t[n]=t[n]||[],o={};r.forEach(function(e){var t=e.trim().split("="),r=t[0],n=t[1];"undefined"==typeof n?n=!0:('"'===n[0]&&(n=n.slice(1)),'"'===n[n.length-1]&&(n=n.slice(0,n.length-1))),(o[r]=o[r]||[]).push(n)}),i.push(o)}),t}function i(e){return Object.keys(e).map(function(t){var r=e[t];return o.isArray(r)||(r=[r]),r.map(function(e){return[t].concat(Object.keys(e).map(function(t){var r=e[t];return o.isArray(r)||(r=[r]),r.map(function(e){return e===!0?t:t+"="+e}).join("; ")})).join("; ")}).join(", ")}).join(", ")}var o=e("util");r.parse=n,r.format=i},{util:void 0}],19:[function(e,t,r){(function(r){function n(e,t,r){if(this instanceof n==!1)throw new TypeError("Classes can't be function-called");this._options=e||{},this._isServer=!!t,this._inflate=null,this._deflate=null,this.params=null,this._maxPayload=r||0}var i=e("zlib"),o=[8,9,10,11,12,13,14,15],s=15,a=8;n.extensionName="permessage-deflate",n.prototype.offer=function(){var e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e},n.prototype.accept=function(e){e=this.normalizeParams(e);var t;return t=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params=t,t},n.prototype.cleanup=function(){this._inflate&&(this._inflate.writeInProgress?this._inflate.pendingClose=!0:(this._inflate.close&&this._inflate.close(), this._inflate=null)),this._deflate&&(this._deflate.writeInProgress?this._deflate.pendingClose=!0:(this._deflate.close&&this._deflate.close(),this._deflate=null))},n.prototype.acceptAsServer=function(e){var t={},r=e.some(function(e){return t={},this._options.serverNoContextTakeover===!1&&e.server_no_context_takeover||this._options.serverMaxWindowBits===!1&&e.server_max_window_bits||"number"==typeof this._options.serverMaxWindowBits&&"number"==typeof e.server_max_window_bits&&this._options.serverMaxWindowBits>e.server_max_window_bits||"number"==typeof this._options.clientMaxWindowBits&&!e.client_max_window_bits?void 0:((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(!r)throw new Error("Doesn't support the offered configuration");return t},n.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},n.prototype.normalizeParams=function(e){return e.map(function(e){return Object.keys(e).forEach(function(t){var r=e[t];if(r.length>1)throw new Error("Multiple extension parameters for "+t);switch(r=r[0],t){case"server_no_context_takeover":case"client_no_context_takeover":if(r!==!0)throw new Error("invalid extension parameter value for "+t+" ("+r+")");e[t]=!0;break;case"server_max_window_bits":case"client_max_window_bits":if("string"==typeof r&&(r=parseInt(r,10),!~o.indexOf(r)))throw new Error("invalid extension parameter value for "+t+" ("+r+")");if(!this._isServer&&r===!0)throw new Error("Missing extension parameter value for "+t);e[t]=r;break;default:throw new Error("Not defined extension parameter ("+t+")")}},this),e},this)},n.prototype.decompress=function(e,t,n){function o(e){u(),n(e)}function a(e){if(void 0!==f._maxPayload&&null!==f._maxPayload&&f._maxPayload>0&&(p+=e.length,p>f._maxPayload)){h=[],u();var t={type:1009};return void n(t)}h.push(e)}function u(){f._inflate&&(f._inflate.removeListener("error",o),f._inflate.removeListener("data",a),f._inflate.writeInProgress=!1,(t&&f.params[c+"_no_context_takeover"]||f._inflate.pendingClose)&&(f._inflate.close&&f._inflate.close(),f._inflate=null))}var c=this._isServer?"client":"server";if(!this._inflate){var l=this.params[c+"_max_window_bits"];this._inflate=i.createInflateRaw({windowBits:"number"==typeof l?l:s})}this._inflate.writeInProgress=!0;var f=this,h=[],p=0;this._inflate.on("error",o).on("data",a),this._inflate.write(e),t&&this._inflate.write(new r([0,0,255,255])),this._inflate.flush(function(){u(),n(null,r.concat(h))})},n.prototype.compress=function(e,t,n){function o(e){c(),n(e)}function u(e){p.push(e)}function c(){h._deflate&&(h._deflate.removeListener("error",o),h._deflate.removeListener("data",u),h._deflate.writeInProgress=!1,(t&&h.params[l+"_no_context_takeover"]||h._deflate.pendingClose)&&(h._deflate.close&&h._deflate.close(),h._deflate=null))}var l=this._isServer?"server":"client";if(!this._deflate){var f=this.params[l+"_max_window_bits"];this._deflate=i.createDeflateRaw({flush:i.Z_SYNC_FLUSH,windowBits:"number"==typeof f?f:s,memLevel:this._options.memLevel||a})}this._deflate.writeInProgress=!0;var h=this,p=[];this._deflate.on("error",o).on("data",u),this._deflate.write(e),this._deflate.flush(function(){c();var e=r.concat(p);t&&(e=e.slice(0,e.length-4)),n(null,e)})},t.exports=n}).call(this,e("buffer").Buffer)},{buffer:4,zlib:void 0}],20:[function(e,t,r){(function(r){function n(){if(this instanceof n==!1)throw new TypeError("Classes can't be function-called");this.state=o,this.buffers=[],this.messageEnd=-1,this.spanLength=0,this.dead=!1,this.onerror=function(){},this.ontext=function(){},this.onbinary=function(){},this.onclose=function(){},this.onping=function(){},this.onpong=function(){}}function i(e,t){for(var r=0,n=e.length;n>r;++r)if(e[r]===t)return r;return-1}var o=(e("util"),0),s=1,a=2,u=3;t.exports=n,n.prototype.add=function(e){function t(){if(r.state===o){if(2==e.length&&255==e[0]&&0==e[1])return r.reset(),void r.onclose();if(128===e[0])r.messageEnd=0,r.state=a,e=e.slice(1);else{if(0!==e[0])return void r.error("payload must start with 0x00 byte",!0);e=e.slice(1),r.state=s}}if(r.state===a){for(var t=0;t0&&(e=e.slice(t))}if(r.state===u){var n=r.messageEnd-r.spanLength;return e.length>=n?(r.buffers.push(e),r.spanLength+=n,r.messageEnd=n,r.parse()):(r.buffers.push(e),void(r.spanLength+=e.length))}return r.buffers.push(e),-1!=(r.messageEnd=i(e,255))?(r.spanLength+=r.messageEnd,r.parse()):void(r.spanLength+=e.length)}if(!this.dead)for(var r=this;e;)e=t()},n.prototype.cleanup=function(){this.dead=!0,this.state=o,this.buffers=[]},n.prototype.parse=function(){for(var e=new r(this.spanLength),t=0,n=0,i=this.buffers.length;i-1>n;++n){var o=this.buffers[n];o.copy(e,t),t+=o.length}var a=this.buffers[this.buffers.length-1];this.messageEnd>0&&a.copy(e,t,0,this.messageEnd),this.state!==s&&--this.messageEnd;var u=null;return this.messageEnd=0?Math.ceil((i+e.used)/2):e.used});var o=-1;this.unfragmentedBufferPool=new l(1024,function(e,t){return e.used+t},function(e){return o=o>=0?Math.ceil((o+e.used)/2):e.used}),this.extensions=e||{},this.maxPayload=t||0,this.currentPayloadLength=0,this.state={activeFragmentedOperation:null,lastFragment:!1,masked:!1,opcode:0,fragmentedOperation:!1},this.overflow=[],this.headerBuffer=new r(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 i(e){return(this[e]<<8)+this[e+1]}function o(e){return(this[e]<<24)+(this[e+1]<<16)+(this[e+2]<<8)+this[e+3]}function s(e,t,r,n){switch(e){default:t.copy(r,n,0,e);break;case 16:r[n+15]=t[15];case 15:r[n+14]=t[14];case 14:r[n+13]=t[13];case 13:r[n+12]=t[12];case 12:r[n+11]=t[11];case 11:r[n+10]=t[10];case 10:r[n+9]=t[9];case 9:r[n+8]=t[8];case 8:r[n+7]=t[7];case 7:r[n+6]=t[6];case 6:r[n+5]=t[5];case 5:r[n+4]=t[4];case 4:r[n+3]=t[3];case 3:r[n+2]=t[2];case 2:r[n+1]=t[1];case 1:r[n]=t[0]}}function a(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}var u=(e("util"),e("./Validation").Validation),c=e("./ErrorCodes"),l=e("./BufferPool"),f=e("./BufferUtil").BufferUtil,h=e("./PerMessageDeflate");t.exports=n,n.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 r=Math.min(t,this.expectBuffer.length-this.expectOffset);for(s(r,e,this.expectBuffer,this.expectOffset),this.expectOffset+=r,t>r&&this.overflow.push(e.slice(r));this.expectBuffer&&this.expectOffset==this.expectBuffer.length;){var n=this.expectBuffer;this.expectBuffer=null,this.expectOffset=0,this.expectHandler.call(this,n)}}}},n.prototype.cleanup=function(){this.dead=!0,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},n.prototype.expectHeader=function(e,t){if(0==e)return void t(null);this.expectBuffer=this.headerBuffer.slice(this.expectOffset,this.expectOffset+e),this.expectHandler=t;for(var r=e;r>0&&this.overflow.length>0;){var n=this.overflow.pop();r0&&this.overflow.length>0;){var n=this.overflow.pop();rr&&null!=this.state.activeFragmentedOperation)return void this.error("data frames after the initial data frame must have opcode 0",1002);if(r>=8&&t)return void this.error("control frames cannot have the Per-message Compressed bits",1002);this.state.compressed=t,this.state.opcode=r,this.state.lastFragment===!1?(this.state.fragmentedOperation=!0,this.state.activeFragmentedOperation=r):this.state.fragmentedOperation=!1}var n=p[this.state.opcode];"undefined"==typeof n?this.error("no handler for opcode "+this.state.opcode,1002):n.start.call(this,e)},n.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))},n.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)},n.prototype.unmask=function(e,t,r){return null!=e&&null!=t&&f.unmask(t,e),r?t:null!=t?t.toString("utf8"):""},n.prototype.error=function(e,t){return this.dead?void 0:(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)},n.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()})}}},n.prototype.applyExtensions=function(e,t,r,n){var i=this;r?this.extensions[h.extensionName].decompress(e,t,function(e,t){return i.dead?void 0:e?void n(new Error("invalid compressed data")):void n(null,t)}):n(null,e)},n.prototype.maxPayloadExceeded=function(e){if(void 0===this.maxPayload||null===this.maxPayload||this.maxPayload<1)return!1;var t=this.currentPayloadLength+e;return tr){if(t.maxPayloadExceeded(r))return void t.error("Maximumpayload exceeded in compressed text message. Aborting...",1009);p[1].getData.call(t,r)}else 126==r?t.expectHeader(2,function(e){var r=i.call(e,0);return t.maxPayloadExceeded(r)?void t.error("Maximumpayload exceeded in compressed text message. Aborting...",1009):void p[1].getData.call(t,r)}):127==r&&t.expectHeader(8,function(e){if(0!=o.call(e,0))return void t.error("packets with length spanning more than 32 bit is currently not supported",1008);var r=o.call(e,4);return t.maxPayloadExceeded(r)?void t.error("Maximumpayload exceeded in compressed text message. Aborting...",1009):void p[1].getData.call(t,o.call(e,4))})},getData:function(e){var t=this;t.state.masked?t.expectHeader(4,function(r){var n=r;t.expectData(e,function(e){p[1].finish.call(t,n,e)})}):t.expectData(e,function(e){p[1].finish.call(t,null,e)})},finish:function(e,t){var n=this,i=this.unmask(e,t,!0)||new r(0),o=a(this.state);this.messageHandlers.push(function(e){n.applyExtensions(i,o.lastFragment,o.compressed,function(t,i){if(t)return 1009===t.type?n.error("Maximumpayload exceeded in compressed text message. Aborting...",1009):n.error(t.message,1007);if(null!=i){if(!(0==n.maxPayload||n.maxPayload>0&&n.currentMessageLength+i.lengthr){if(t.maxPayloadExceeded(r))return void t.error("Max payload exceeded in compressed text message. Aborting...",1009);p[2].getData.call(t,r)}else 126==r?t.expectHeader(2,function(e){var r=i.call(e,0);return t.maxPayloadExceeded(r)?void t.error("Max payload exceeded in compressed text message. Aborting...",1009):void p[2].getData.call(t,r)}):127==r&&t.expectHeader(8,function(e){if(0!=o.call(e,0))return void t.error("packets with length spanning more than 32 bit is currently not supported",1008);var r=o.call(e,4,!0);return t.maxPayloadExceeded(r)?void t.error("Max payload exceeded in compressed text message. Aborting...",1009):void p[2].getData.call(t,r)})},getData:function(e){var t=this;t.state.masked?t.expectHeader(4,function(r){var n=r;t.expectData(e,function(e){p[2].finish.call(t,n,e)})}):t.expectData(e,function(e){p[2].finish.call(t,null,e)})},finish:function(e,t){var n=this,i=this.unmask(e,t,!0)||new r(0),o=a(this.state);this.messageHandlers.push(function(e){n.applyExtensions(i,o.lastFragment,o.compressed,function(t,i){if(t)return 1009===t.type?n.error("Max payload exceeded in compressed binary message. Aborting...",1009):n.error(t.message,1007);if(null!=i){if(!(0==n.maxPayload||n.maxPayload>0&&n.currentMessageLength+i.lengthr?p[8].getData.call(t,r):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(r){var n=r;t.expectData(e,function(e){p[8].finish.call(t,n,e)})}):t.expectData(e,function(e){p[8].finish.call(t,null,e)})},finish:function(e,t){var r=this;t=r.unmask(e,t,!0);var n=a(this.state);this.messageHandlers.push(function(){if(t&&1==t.length)return void r.error("close packets with data must be at least two bytes long",1002);var e=t&&t.length>1?i.call(t,0):1e3;if(!c.isValidErrorCode(e))return void r.error("invalid error code",1002);var o="";if(t&&t.length>2){var s=t.slice(2);if(!u.isValidUTF8(s))return void r.error("invalid utf8 sequence",1007);o=s.toString("utf8")}r.onclose(e,o,{masked:n.masked}),r.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 r=127&e[1];126>r?p[9].getData.call(t,r):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(r){var n=r;t.expectData(e,function(e){p[9].finish.call(t,n,e)})}):t.expectData(e,function(e){p[9].finish.call(t,null,e)})},finish:function(e,t){var r=this;t=this.unmask(e,t,!0);var n=a(this.state);this.messageHandlers.push(function(e){r.onping(t,{masked:n.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 r=127&e[1];126>r?p[10].getData.call(t,r):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(r){var n=r;t.expectData(e,function(e){p[10].finish.call(t,n,e)})}):this.expectData(e,function(e){p[10].finish.call(t,null,e)})},finish:function(e,t){var r=this;t=r.unmask(e,t,!0);var n=a(this.state);this.messageHandlers.push(function(e){r.onpong(t,{masked:n.masked,binary:!0}),e()}),this.flush(),this.endPacket()}}}}).call(this,e("buffer").Buffer)},{"./BufferPool":14,"./BufferUtil":16,"./ErrorCodes":17,"./PerMessageDeflate":19,"./Validation":25,buffer:4,util:void 0}],22:[function(e,t,r){(function(r){function n(e){if(this instanceof n==!1)throw new TypeError("Classes can't be function-called");i.EventEmitter.call(this),this.socket=e,this.continuationFrame=!1,this.isClosed=!1}var i=e("events"),o=e("util");i.EventEmitter;t.exports=n,o.inherits(n,i.EventEmitter),n.prototype.send=function(e,t,n){if(!this.isClosed){var i="string"==typeof e,o=i?r.byteLength(e):e.length,s=o>127?2:1,a=0==this.continuationFrame,u=!t||!("undefined"!=typeof t.fin&&!t.fin),c=new r((a?t&&t.binary?1+s:1:0)+o+(!u||t&&t.binary?0:1)),l=a?1:0;a&&(t&&t.binary?(c.write("€","binary"),s>1&&c.write(String.fromCharCode(128+o/128),l++,"binary"),c.write(String.fromCharCode(127&o),l++,"binary")):c.write("\x00","binary")),i?c.write(e,l,"utf8"):e.copy(c,l,0),u?(t&&t.binary||c.write("ÿ",l+o,"binary"),this.continuationFrame=!1):this.continuationFrame=!0;try{this.socket.write(c,"binary",n)}catch(f){this.error(f.toString())}}},n.prototype.close=function(e,t,n,i){if(!this.isClosed){this.isClosed=!0;try{this.continuationFrame&&this.socket.write(new r([255],"binary")),this.socket.write(new r([255,0]),"binary",i)}catch(o){this.error(o.toString())}}},n.prototype.ping=function(e,t){},n.prototype.pong=function(e,t){},n.prototype.error=function(e){return this.emit("error",e),this}}).call(this,e("buffer").Buffer)},{buffer:4,events:void 0,util:void 0}],23:[function(e,t,r){(function(r){function n(e,t){if(this instanceof n==!1)throw new TypeError("Classes can't be function-called");u.EventEmitter.call(this),this._socket=e,this.extensions=t||{},this.firstFragment=!0,this.compress=!1,this.messageHandlers=[],this.processing=!1}function i(e,t){this[t]=(65280&e)>>8,this[t+1]=255&e}function o(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 s(e){for(var t=new Uint8Array(e.buffer||e),n=e.byteLength||e.length,i=e.byteOffset||0,o=new r(n),s=0;n>s;++s)o[s]=t[i+s];return o}function a(){return new r([~~(255*Math.random()),~~(255*Math.random()),~~(255*Math.random()),~~(255*Math.random())])}var u=e("events"),c=e("util"),l=(u.EventEmitter,e("./ErrorCodes")),f=e("./BufferUtil").BufferUtil,h=e("./PerMessageDeflate");c.inherits(n,u.EventEmitter),n.prototype.close=function(e,t,n,o){if("undefined"!=typeof e&&("number"!=typeof e||!l.isValidErrorCode(e)))throw new Error("first argument must be a valid error code number");e=e||1e3;var s=new r(2+(t?r.byteLength(t):0));i.call(s,e,0),s.length>2&&s.write(t,2);var a=this;this.messageHandlers.push(function(e){a.frameAndSend(8,s,!0,n),e(),"function"==typeof o&&o()}),this.flush()},n.prototype.ping=function(e,t){var r=t&&t.mask,n=this;this.messageHandlers.push(function(t){n.frameAndSend(9,e||"",!0,r),t()}),this.flush()},n.prototype.pong=function(e,t){var r=t&&t.mask,n=this;this.messageHandlers.push(function(t){n.frameAndSend(10,e||"",!0,r),t()}),this.flush()},n.prototype.send=function(e,t,r){var n=!t||t.fin!==!1,i=t&&t.mask,o=t&&t.compress,s=t&&t.binary?2:1;this.firstFragment===!1?(s=0,o=!1):(this.firstFragment=!1,this.compress=o),n&&(this.firstFragment=!0);var a=this.compress,u=this;this.messageHandlers.push(function(t){u.applyExtensions(e,n,a,function(e,a){return e?void("function"==typeof r?r(e):u.emit("error",e)):(u.frameAndSend(s,a,n,i,o,r),void t())})}),this.flush()},n.prototype.frameAndSend=function(e,t,n,u,c,l){var h=!1;if(t){r.isBuffer(t)||(h=!0,!t||"undefined"==typeof t.byteLength&&"undefined"==typeof t.buffer?("number"==typeof t&&(t=t.toString()),t=new r(t)):t=s(t));var p=t.length,d=u?6:2,v=p;p>=65536?(d+=8,v=127):p>125&&(d+=2,v=126);var y=32768>p||u&&!h,g=y?p+d:d,_=new r(g);switch(_[0]=n?128|e:e,c&&(_[0]|=64),v){case 126:i.call(_,p,2);break;case 127:o.call(_,0,2),o.call(_,p,6)}if(u){_[1]=128|v;var m=a();if(_[d-4]=m[0],_[d-3]=m[1],_[d-2]=m[2],_[d-1]=m[3],y){f.mask(t,m,_,d,p);try{this._socket.write(_,"binary",l)}catch(w){"function"==typeof l?l(w):this.emit("error",w)}}else{f.mask(t,m,t,0,p);try{this._socket.write(_,"binary"),this._socket.write(t,"binary",l)}catch(w){"function"==typeof l?l(w):this.emit("error",w)}}}else if(_[1]=v,y){t.copy(_,d);try{this._socket.write(_,"binary",l)}catch(w){"function"==typeof l?l(w):this.emit("error",w)}}else try{this._socket.write(_,"binary"),this._socket.write(t,"binary",l)}catch(w){"function"==typeof l?l(w):this.emit("error",w)}}else try{this._socket.write(new r([e|(n?128:0),0|(u?128:0)].concat(u?[0,0,0,0]:[])),"binary",l)}catch(w){"function"==typeof l?l(w):this.emit("error",w)}},n.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()})}}},n.prototype.applyExtensions=function(e,t,r,n){r&&e?((e.buffer||e)instanceof ArrayBuffer&&(e=s(e)),this.extensions[h.extensionName].compress(e,t,n)):n(null,e)},t.exports=n}).call(this,e("buffer").Buffer)},{"./BufferUtil":16,"./ErrorCodes":17,"./PerMessageDeflate":19,buffer:4,events:void 0,util:void 0}],24:[function(e,t,r){r.Validation={isValidUTF8:function(e){return!0}}},{}],25:[function(e,t,r){"use strict";try{t.exports=e("utf-8-validate")}catch(n){t.exports=e("./Validation.fallback")}},{"./Validation.fallback":24,"utf-8-validate":12}],26:[function(e,t,r){(function(r,n){"use strict";function i(e,t,r){return this instanceof i==!1?new i(e,t,r):(T.call(this),t&&!Array.isArray(t)&&"object"==typeof t&&(r=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)?c.apply(this,e.concat(r)):l.apply(this,[e,t,r])))}function o(e,t,r){this.type="message",this.data=e,this.target=r,this.binary=t}function s(e,t,r){this.type="close",this.wasClean="undefined"==typeof e||1e3===e,this.code=e,this.reason=t,this.target=r}function a(e){this.type="open",this.target=e}function u(e,t,r){var n=t;return t&&(e&&443!=r||!e&&80!=r)&&(n=n+":"+r),n}function c(e,t,r,n){n=new S({protocolVersion:L,protocol:null,extensions:{},maxPayload:0}).merge(n),this.protocol=n.value.protocol,this.protocolVersion=n.value.protocolVersion,this.extensions=n.value.extensions,this.supports.binary="hixie-76"!==this.protocolVersion,this.upgradeReq=e,this.readyState=i.CONNECTING,this._isServer=!0,this.maxPayload=n.value.maxPayload,"hixie-76"===n.value.protocolVersion?f.call(this,k,P,t,r):f.call(this,O,x,t,r)}function l(e,t,r){if(r=new S({origin:null,protocolVersion:L,host:null,headers:null,protocol:t.join(","),agent:null,pfx:null,key:null,passphrase:null,cert:null,ca:null,ciphers:null,rejectUnauthorized:null,perMessageDeflate:!0,localAddress:null}).merge(r),8!==r.value.protocolVersion&&13!==r.value.protocolVersion)throw new Error("unsupported protocol version");var o=y.parse(e),s="ws+unix:"===o.protocol;if(!o.host&&!s)throw new Error("invalid url");var a,c="wss:"===o.protocol||"https:"===o.protocol,l=c?m:_,h=o.port||(c?443:80),p=o.auth,d={};r.value.perMessageDeflate&&(a=new R(typeof r.value.perMessageDeflate!==!0?r.value.perMessageDeflate:{},!1),d[R.extensionName]=a.offer()),this._isServer=!1,this.url=e,this.protocolVersion=r.value.protocolVersion,this.supports.binary="hixie-76"!==this.protocolVersion;var g=new n(r.value.protocolVersion+"-"+Date.now()).toString("base64"),b=w.createHash("sha1");b.update(g+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var E=b.digest("base64"),P=r.value.agent,k=u(c,o.hostname,h),T={port:h,host:o.hostname,headers:{Connection:"Upgrade",Upgrade:"websocket",Host:k,"Sec-WebSocket-Version":r.value.protocolVersion,"Sec-WebSocket-Key":g}};if(p&&(T.headers.Authorization="Basic "+new n(p).toString("base64")),r.value.protocol&&(T.headers["Sec-WebSocket-Protocol"]=r.value.protocol),r.value.host&&(T.headers.Host=r.value.host),r.value.headers)for(var U in r.value.headers)r.value.headers.hasOwnProperty(U)&&(T.headers[U]=r.value.headers[U]);Object.keys(d).length&&(T.headers["Sec-WebSocket-Extensions"]=C.format(d)),(r.isDefinedAndNonNull("pfx")||r.isDefinedAndNonNull("key")||r.isDefinedAndNonNull("passphrase")||r.isDefinedAndNonNull("cert")||r.isDefinedAndNonNull("ca")||r.isDefinedAndNonNull("ciphers")||r.isDefinedAndNonNull("rejectUnauthorized"))&&(r.isDefinedAndNonNull("pfx")&&(T.pfx=r.value.pfx),r.isDefinedAndNonNull("key")&&(T.key=r.value.key),r.isDefinedAndNonNull("passphrase")&&(T.passphrase=r.value.passphrase),r.isDefinedAndNonNull("cert")&&(T.cert=r.value.cert),r.isDefinedAndNonNull("ca")&&(T.ca=r.value.ca),r.isDefinedAndNonNull("ciphers")&&(T.ciphers=r.value.ciphers),r.isDefinedAndNonNull("rejectUnauthorized")&&(T.rejectUnauthorized=r.value.rejectUnauthorized),P||(P=new l.Agent(T))),T.path=o.path||"/",P&&(T.agent=P),s&&(T.socketPath=o.pathname),r.value.localAddress&&(T.localAddress=r.value.localAddress),r.value.origin&&(r.value.protocolVersion<13?T.headers["Sec-WebSocket-Origin"]=r.value.origin:T.headers.Origin=r.value.origin);var N=this,A=l.request(T);A.on("error",function(e){N.emit("error",e),v.call(N,e)}),A.once("response",function(e){var t;N.emit("unexpected-response",A,e)||(t=new Error("unexpected server response ("+e.statusCode+")"),A.abort(),N.emit("error",t)),v.call(N,t)}),A.once("upgrade",function(e,t,n){if(N.readyState===i.CLOSED)return N.emit("close"),N.removeAllListeners(),void t.end();var o=e.headers["sec-websocket-accept"];if("undefined"==typeof o||o!==E)return N.emit("error","invalid server key"),N.removeAllListeners(),void t.end();var s=e.headers["sec-websocket-protocol"],u=(r.value.protocol||"").split(/, */),c=null;if(!r.value.protocol&&s?c="server sent a subprotocol even though none requested":r.value.protocol&&!s?c="server sent no subprotocol even though requested":s&&-1===u.indexOf(s)&&(c="server responded with an invalid protocol"),c)return N.emit("error",c),N.removeAllListeners(),void t.end();s&&(N.protocol=s);var l=C.parse(e.headers["sec-websocket-extensions"]);if(a&&l[R.extensionName]){try{a.accept(l[R.extensionName])}catch(h){return N.emit("error","invalid extension parameter"),N.removeAllListeners(),void t.end()}N.extensions[R.extensionName]=a}f.call(N,O,x,t,n),A.removeAllListeners(),A=null,P=null}),A.end(),this.readyState=i.CONNECTING}function f(e,t,n,o){function s(e){c||l.readyState===i.CLOSED||(c=!0,n.removeListener("data",s),u.on("data",a),o&&o.length>0&&(a(o),o=null),e&&a(e))}function a(e){l.bytesReceived+=e.length,l._receiver.add(e)}var u=this._ultron=new E(n),c=!1,l=this;n.setTimeout(0),n.setNoDelay(!0),this._receiver=new e(this.extensions,this.maxPayload),this._socket=n,u.on("end",v.bind(this)),u.on("close",v.bind(this)),u.on("error",v.bind(this)),u.on("data",s),r.nextTick(s),l._receiver.ontext=function(e,t){t=t||{},l.emit("message",e,t)},l._receiver.onbinary=function(e,t){t=t||{},t.binary=!0,l.emit("message",e,t)},l._receiver.onping=function(e,t){t=t||{},l.pong(e,{mask:!l._isServer,binary:t.binary===!0},!0),l.emit("ping",e,t)},l._receiver.onpong=function(e,t){l.emit("pong",e,t||{})},l._receiver.onclose=function(e,t,r){r=r||{},l._closeReceived=!0,l.close(e,t)},l._receiver.onerror=function(e,t){l.close("undefined"!=typeof t?t:1002,""),l.emit("error",e instanceof Error?e:new Error(e))},this._sender=new t(n,this.extensions),this._sender.on("error",function(e){l.close(1002,""),l.emit("error",e)}),this.readyState=i.OPEN,this.emit("open")}function h(e){e._queue=e._queue||[]}function p(e){var t=e._queue;if("undefined"!=typeof t){delete e._queue;for(var r=0,n=t.length;n>r;++r)t[r]()}}function d(e,t,r,n){t.on("data",function(t){return e.readyState!==i.OPEN?void("function"==typeof n?n(new Error("not opened")):(delete e._queue,e.emit("error",new Error("not opened")))):(r.fin=!1,void e._sender.send(t,r))}),t.on("end",function(){return e.readyState!==i.OPEN?void("function"==typeof n?n(new Error("not opened")):(delete e._queue,e.emit("error",new Error("not opened")))):(r.fin=!0,e._sender.send(null,r),void("function"==typeof n&&n(null)))})}function v(e){if(this.readyState!==i.CLOSED){if(this.readyState=i.CLOSED,clearTimeout(this._closeTimer),this._closeTimer=null,!e&&this._closeReceived||(this._closeCode=1006),this.emit("close",this._closeCode||1e3,this._closeMessage||""),this._socket){this._ultron&&this._ultron.destroy(),this._socket.on("error",function(){try{this.destroy()}catch(e){}});try{e?this._socket.destroy():this._socket.end()}catch(t){}this._socket=null,this._ultron=null}this._sender&&(this._sender.removeAllListeners(),this._sender=null),this._receiver&&(this._receiver.cleanup(),this._receiver=null),this.extensions[R.extensionName]&&this.extensions[R.extensionName].cleanup(),this.extensions=null,this.removeAllListeners(),this.on("error",function(){}),delete this._queue}}var y=e("url"),g=e("util"),_=e("http"),m=e("https"),w=e("crypto"),b=e("stream"),E=e("ultron"),S=e("options"),x=e("./Sender"),O=e("./Receiver"),P=e("./Sender.hixie"),k=e("./Receiver.hixie"),C=e("./Extensions"),R=e("./PerMessageDeflate"),T=e("events").EventEmitter,L=13,U=3e4; g.inherits(i,T),["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(e,t){i.prototype[e]=i[e]=t}),i.prototype.close=function(e,t){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return void(this.readyState=i.CLOSED);if(this.readyState===i.CLOSING)return void(this._closeReceived&&this._isServer&&this.terminate());var r=this;try{this.readyState=i.CLOSING,this._closeCode=e,this._closeMessage=t;var n=!this._isServer;this._sender.close(e,t,n,function(e){e&&r.emit("error",e),r._closeReceived&&r._isServer?r.terminate():(clearTimeout(r._closeTimer),r._closeTimer=setTimeout(v.bind(r,!0),U))})}catch(o){this.emit("error",o)}}},i.prototype.pause=function(){if(this.readyState!==i.OPEN)throw new Error("not opened");return this._socket.pause()},i.prototype.ping=function(e,t,r){if(this.readyState!==i.OPEN){if(r===!0)return;throw new Error("not opened")}t=t||{},"undefined"==typeof t.mask&&(t.mask=!this._isServer),this._sender.ping(e,t)},i.prototype.pong=function(e,t,r){if(this.readyState!==i.OPEN){if(r===!0)return;throw new Error("not opened")}t=t||{},"undefined"==typeof t.mask&&(t.mask=!this._isServer),this._sender.pong(e,t)},i.prototype.resume=function(){if(this.readyState!==i.OPEN)throw new Error("not opened");return this._socket.resume()},i.prototype.send=function(e,t,o){if("function"==typeof t&&(o=t,t={}),this.readyState!==i.OPEN){if("function"!=typeof o)throw new Error("not opened");return void o(new Error("not opened"))}if(e||(e=""),this._queue){var s=this;return void this._queue.push(function(){s.send(e,t,o)})}t=t||{},t.fin=!0,"undefined"==typeof t.binary&&(t.binary=e instanceof ArrayBuffer||e instanceof n||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 t.mask&&(t.mask=!this._isServer),"undefined"==typeof t.compress&&(t.compress=!0),this.extensions[R.extensionName]||(t.compress=!1);var a="function"==typeof b.Readable?b.Readable:b.Stream;if(e instanceof a){h(this);var s=this;d(this,e,t,function(e){r.nextTick(function(){p(s)}),"function"==typeof o&&o(e)})}else this._sender.send(e,t,o)},i.prototype.stream=function(e,t){function n(s,a){try{if(o.readyState!==i.OPEN)throw new Error("not opened");e.fin=a===!0,o._sender.send(s,e),a?p(o):r.nextTick(t.bind(null,null,n))}catch(u){"function"==typeof t?t(u):(delete o._queue,o.emit("error",u))}}"function"==typeof e&&(t=e,e={});var o=this;if("function"!=typeof t)throw new Error("callback must be provided");if(this.readyState!==i.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(){o.stream(e,t)}):(e=e||{},"undefined"==typeof e.mask&&(e.mask=!this._isServer),"undefined"==typeof e.compress&&(e.compress=!0),this.extensions[R.extensionName]||(e.compress=!1),h(this),void r.nextTick(t.bind(null,null,n)))},i.prototype.terminate=function(){if(this.readyState!==i.CLOSED)if(this._socket){this.readyState=i.CLOSING;try{this._socket.end()}catch(e){return void v.call(this,!0)}this._closeTimer&&clearTimeout(this._closeTimer),this._closeTimer=setTimeout(v.bind(this,!0),U)}else this.readyState===i.CONNECTING&&v.call(this,!0)},Object.defineProperty(i.prototype,"bufferedAmount",{get:function(){var e=0;return this._socket&&(e=this._socket.bufferSize||0),e}}),Object.defineProperty(i.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(i.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)}})}),i.prototype.addEventListener=function(e,t){function r(e,r){r.binary&&"arraybuffer"===this.binaryType&&(e=new Uint8Array(e).buffer),t.call(c,new o(e,!!r.binary,c))}function n(e,r){t.call(c,new s(e,r,c))}function i(e){e.type="error",e.target=c,t.call(c,e)}function u(){t.call(c,new a(c))}var c=this;"function"==typeof t&&("message"===e?(r._listener=t,this.on(e,r)):"close"===e?(n._listener=t,this.on(e,n)):"error"===e?(i._listener=t,this.on(e,i)):"open"===e?(u._listener=t,this.on(e,u)):this.on(e,t))},t.exports=i,t.exports.buildHostHeader=u}).call(this,e("_process"),e("buffer").Buffer)},{"./Extensions":18,"./PerMessageDeflate":19,"./Receiver":21,"./Receiver.hixie":20,"./Sender":23,"./Sender.hixie":22,_process:3,buffer:4,crypto:void 0,events:void 0,http:void 0,https:void 0,options:9,stream:void 0,ultron:10,url:void 0,util:void 0}],27:[function(e,t,r){(function(r){function n(e,t){if(this instanceof n==!1)return new n(e,t);if(c.EventEmitter.call(this),e=new h({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 i=this;if(e.isDefinedAndNonNull("port"))this._server=l.createServer(function(e,t){var r=l.STATUS_CODES[426];t.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),t.end(r)}),this._server.allowHalfOpen=!1,this._server.listen(e.value.port,e.value.host,t),this._closeServer=function(){i._server&&i._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(){i.emit("listening")},this._server.once("listening",this._onceServerListening)),"undefined"!=typeof this._server&&(this._onServerError=function(e){i.emit("error",e)},this._server.on("error",this._onServerError),this._onServerUpgrade=function(e,t,n){var o=new r(n.length);n.copy(o),i.handleUpgrade(e,t,o,function(t){i.emit("connection"+e.url,t),i.emit("connection",t)})},this._server.on("upgrade",this._onServerUpgrade)),this.options=e.value,this.path=e.value.path,this.clients=[]}function i(e,t,r,n){var i=function(){try{t.destroy()}catch(e){}};if(t.on("error",i),!e.headers["sec-websocket-key"])return void a(t,400,"Bad Request");var o=parseInt(e.headers["sec-websocket-version"]);if(-1===[8,13].indexOf(o))return void a(t,400,"Bad Request");var u=e.headers["sec-websocket-protocol"],c=13>o?e.headers["sec-websocket-origin"]:e.headers.origin,h=d.parse(e.headers["sec-websocket-extensions"]),v=this,y=function(u){var c=e.headers["sec-websocket-key"],l=f.createHash("sha1");l.update(c+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"),c=l.digest("base64");var y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade","Sec-WebSocket-Accept: "+c];"undefined"!=typeof u&&y.push("Sec-WebSocket-Protocol: "+u);var g={};try{g=s.call(v,h)}catch(_){return void a(t,400,"Bad Request")}if(Object.keys(g).length){var m={};Object.keys(g).forEach(function(e){m[e]=[g[e].params]}),y.push("Sec-WebSocket-Extensions: "+d.format(m))}v.emit("headers",y),t.setTimeout(0),t.setNoDelay(!0);try{t.write(y.concat("","").join("\r\n"))}catch(w){try{t.destroy()}catch(w){}return}var b=new p([e,t,r],{protocolVersion:o,protocol:u,extensions:g,maxPayload:v.options.maxPayload});v.options.clientTracking&&(v.clients.push(b),b.on("close",function(){var e=v.clients.indexOf(b);-1!=e&&v.clients.splice(e,1)})),t.removeListener("error",i),n(b)},g=function(){if("function"==typeof v.options.handleProtocols){var e=(u||"").split(/, */),r=!1;v.options.handleProtocols(e,function(e,n){r=!0,e?y(n):a(t,401,"Unauthorized")});return void(r||a(t,501,"Could not process protocols"))}"undefined"!=typeof u?y(u.split(/, */)[0]):y()};if("function"==typeof this.options.verifyClient){var _={origin:c,secure:"undefined"!=typeof e.connection.authorized||"undefined"!=typeof e.connection.encrypted,req:e};if(2==this.options.verifyClient.length)return void this.options.verifyClient(_,function(e,r,n){"undefined"==typeof r&&(r=401),"undefined"==typeof n&&(n=l.STATUS_CODES[r]),e?g():a(t,r,n)});if(!this.options.verifyClient(_))return void a(t,401,"Unauthorized")}g()}function o(e,t,n,i){var o=function(){try{t.destroy()}catch(e){}};if(t.on("error",o),this.options.disableHixie)return void a(t,401,"Hixie support disabled");if(!e.headers["sec-websocket-key2"])return void a(t,400,"Bad Request");var s=e.headers.origin,u=this,c=function(){var c;c=e.headers["x-forwarded-host"]?e.headers["x-forwarded-host"]:e.headers.host;var l=("https"===e.headers["x-forwarded-proto"]||t.encrypted?"wss":"ws")+"://"+c+e.url,h=e.headers["sec-websocket-protocol"],d=function(){var e=["HTTP/1.1 101 Switching Protocols","Upgrade: WebSocket","Connection: Upgrade","Sec-WebSocket-Location: "+l];return"undefined"!=typeof h&&e.push("Sec-WebSocket-Protocol: "+h),"undefined"!=typeof s&&e.push("Sec-WebSocket-Origin: "+s),new r(e.concat("","").join("\r\n"))},v=function(){t.setTimeout(0),t.setNoDelay(!0);var e=d();try{t.write(e,"binary",function(e){e&&t.removeListener("data",b)})}catch(r){try{t.destroy()}catch(r){}return}},y=function(n,s,c){var l=e.headers["sec-websocket-key1"],d=e.headers["sec-websocket-key2"],v=f.createHash("md5");[l,d].forEach(function(e){var r=parseInt(e.replace(/[^\d]/g,"")),n=e.replace(/[^ ]/g,"").length;return 0===n||r%n!==0?void a(t,400,"Bad Request"):(r/=n,void v.update(String.fromCharCode(r>>24&255,r>>16&255,r>>8&255,255&r)))}),v.update(n.toString("binary")),t.setTimeout(0),t.setNoDelay(!0);try{var y=new r(v.digest("binary"),"binary"),g=new r(c.length+y.length);c.copy(g,0),y.copy(g,c.length),t.write(g,"binary",function(r){if(!r){var n=new p([e,t,s],{protocolVersion:"hixie-76",protocol:h});u.options.clientTracking&&(u.clients.push(n),n.on("close",function(){var e=u.clients.indexOf(n);-1!=e&&u.clients.splice(e,1)})),t.removeListener("error",o),i(n)}})}catch(_){try{t.destroy()}catch(_){}return}},g=8;if(n&&n.length>=g){var _=n.slice(0,g),m=n.length>g?n.slice(g):null;y.call(u,_,m,d())}else{var _=new r(g);n.copy(_,0);var w=n.length,m=null,b=function(e){var n=Math.min(e.length,g-w);0!==n&&(e.copy(_,w,0,n),w+=n,w==g&&(t.removeListener("data",b),nr;++r)this.clients[r].terminate()}catch(i){t=i}this.path&&this._server._webSocketPaths&&(delete this._server._webSocketPaths[this.path],0==Object.keys(this._server._webSocketPaths).length&&delete this._server._webSocketPaths);try{"undefined"!=typeof this._closeServer&&this._closeServer()}finally{this._server&&(this._server.removeListener("listening",this._onceServerListening),this._server.removeListener("error",this._onServerError),this._server.removeListener("upgrade",this._onServerUpgrade)),delete this._server}if(e)e(t);else if(t)throw t},n.prototype.handleUpgrade=function(e,t,r,n){if(this.options.path){var s=y.parse(e.url);if(s&&s.pathname!==this.options.path)return}return"undefined"==typeof e.headers.upgrade||"websocket"!==e.headers.upgrade.toLowerCase()?void a(t,400,"Bad Request"):void(e.headers["sec-websocket-key1"]?o.apply(this,arguments):i.apply(this,arguments))},t.exports=n}).call(this,e("buffer").Buffer)},{"./Extensions":18,"./PerMessageDeflate":19,"./WebSocket":26,buffer:4,crypto:void 0,events:void 0,http:void 0,options:9,tls:void 0,url:void 0,util:void 0}],28:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0}),r.SCBot=void 0;var i=function(){function e(e,t){for(var r=0;r_||_>e.length)return new Error("Corrupt BSON message");for(;;){if(h=e[r++],0===h)break;for(y=r;0!==e[y];)y++;if(y>=e.length)return new Error("Corrupt BSON document: illegal CString");switch(p=e.toString("utf8",r,y),r=y+1,h){case 7:var m=new t(12);e.copy(m,0,r,r+=12),g[p]=new l(m);break;case 2:_=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,g[p]=e.toString("utf8",r,r+=_-1),r++;break;case 16:g[p]=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24;break;case 1:g[p]=e.readDoubleLE(r),r+=8;break;case 8:g[p]=1==e[r++];break;case 6:case 10:g[p]=null;break;case 4:_=e[r]|e[r+1]<<8|e[r+2]<<16|e[r+3]<<24,g[p]=s(e,r,!0),r+=_;break;case 3:_=e[r]|e[r+1]<<8|e[r+2]<<16|e[r+3]<<24,g[p]=s(e,r,!1),r+=_;break;case 5:_=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,e[r++],g[p]=e.slice(r,r+=_);break;case 9:d=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,v=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,g[p]=new Date(4294967296*v+(0>d?d+4294967296:d));break;case 18:d=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,v=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,_=4294967296*v+(0>d?d+4294967296:d),a>_&&_>u?g[p]=_:g[p]=new c(d,v);break;case 127:g[p]=new i;break;case 255:g[p]=new o;break;case 17:d=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,v=e[r++]|e[r++]<<8|e[r++]<<16|e[r++]<<24,g[p]=new n(d,v)}}return g}Object.defineProperty(r,"__esModule",{value:!0});var a=9007199254740992,u=-9007199254740992,c=e("./long"),l=e("./objectid");n.prototype.getLowBits=function(){return this.low_},n.prototype.getHighBits=function(){return this.high_},r.deserializeFast=s}).call(this,e("buffer").Buffer)},{"./long":35,"./objectid":38,buffer:4}],30:[function(e,t,r){(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;rt||t>36)throw Error("radix out of range: "+t);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(n.MIN_VALUE)){var r=n.fromNumber(t),i=this.div(r),o=i.multiply(r).subtract(this);return i.toString(t)+o.toInt().toString(t)}return"-"+this.negate().toString(t)}for(var s=n.fromNumber(Math.pow(t,6)),o=this,a="";;){var u=o.div(s),c=o.subtract(u.multiply(s)).toInt(),l=c.toString(t);if(o=u,o.isZero())return l+a;for(;l.length<6;)l="0"+l;a=""+l+a}},n.prototype.getHighBits=function(){return this.high_},n.prototype.getLowBits=function(){return this.low_},n.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var e=0!=this.high_?this.high_:this.low_,t=31;t>0&&0==(e&1<0},n.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},n.prototype.compare=function(e){if(this.equals(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.subtract(e).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(e){var t=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=e.high_>>>16,a=65535&e.high_,u=e.low_>>>16,c=65535&e.low_,l=0,f=0,h=0,p=0;return p+=o+c,h+=p>>>16,p&=65535,h+=i+u,f+=h>>>16,h&=65535,f+=r+a,l+=f>>>16,f&=65535,l+=t+s,l&=65535,n.fromBits(h<<16|p,l<<16|f)},n.prototype.subtract=function(e){return this.add(e.negate())},n.prototype.multiply=function(e){if(this.isZero())return n.ZERO;if(e.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return e.isOdd()?n.MIN_VALUE:n.ZERO;if(e.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return e.isNegative()?this.negate().multiply(e.negate()):this.negate().multiply(e).negate();if(e.isNegative())return this.multiply(e.negate()).negate(); if(this.lessThan(n.TWO_PWR_24_)&&e.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*e.toNumber());var t=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=e.high_>>>16,a=65535&e.high_,u=e.low_>>>16,c=65535&e.low_,l=0,f=0,h=0,p=0;return p+=o*c,h+=p>>>16,p&=65535,h+=i*c,f+=h>>>16,h&=65535,h+=o*u,f+=h>>>16,h&=65535,f+=r*c,l+=f>>>16,f&=65535,f+=i*u,l+=f>>>16,f&=65535,f+=o*a,l+=f>>>16,f&=65535,l+=t*c+r*u+i*a+o*s,l&=65535,n.fromBits(h<<16|p,l<<16|f)},n.prototype.div=function(e){if(e.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(e.equals(n.ONE)||e.equals(n.NEG_ONE))return n.MIN_VALUE;if(e.equals(n.MIN_VALUE))return n.ONE;var t=this.shiftRight(1),r=t.div(e).shiftLeft(1);if(r.equals(n.ZERO))return e.isNegative()?n.ONE:n.NEG_ONE;var i=this.subtract(e.multiply(r)),o=r.add(i.div(e));return o}if(e.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return e.isNegative()?this.negate().div(e.negate()):this.negate().div(e).negate();if(e.isNegative())return this.div(e.negate()).negate();for(var s=n.ZERO,i=this;i.greaterThanOrEqual(e);){for(var r=Math.max(1,Math.floor(i.toNumber()/e.toNumber())),a=Math.ceil(Math.log(r)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=n.fromNumber(r),l=c.multiply(e);l.isNegative()||l.greaterThan(i);)r-=u,c=n.fromNumber(r),l=c.multiply(e);c.isZero()&&(c=n.ONE),s=s.add(c),i=i.subtract(l)}return s},n.prototype.modulo=function(e){return this.subtract(this.div(e).multiply(e))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(e){return n.fromBits(this.low_&e.low_,this.high_&e.high_)},n.prototype.or=function(e){return n.fromBits(this.low_|e.low_,this.high_|e.high_)},n.prototype.xor=function(e){return n.fromBits(this.low_^e.low_,this.high_^e.high_)},n.prototype.shiftLeft=function(e){if(e&=63,0==e)return this;var t=this.low_;if(32>e){var r=this.high_;return n.fromBits(t<>>32-e)}return n.fromBits(0,t<e){var r=this.low_;return n.fromBits(r>>>e|t<<32-e,t>>e)}return n.fromBits(t>>e-32,t>=0?0:-1)},n.prototype.shiftRightUnsigned=function(e){if(e&=63,0==e)return this;var t=this.high_;if(32>e){var r=this.low_;return n.fromBits(r>>>e|t<<32-e,t>>>e)}return 32==e?n.fromBits(t,0):n.fromBits(t>>>e-32,0)},n.fromInt=function(e){if(e>=-128&&128>e){var t=n.INT_CACHE_[e];if(t)return t}var r=new n(0|e,0>e?-1:0);return e>=-128&&128>e&&(n.INT_CACHE_[e]=r),r},n.fromNumber=function(e){return isNaN(e)||!isFinite(e)?n.ZERO:e<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:e+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:0>e?n.fromNumber(-e).negate():new n(e%n.TWO_PWR_32_DBL_|0,e/n.TWO_PWR_32_DBL_|0)},n.fromBits=function(e,t){return new n(e,t)},n.fromString=function(e,t){if(0==e.length)throw Error("number format error: empty string");var r=t||10;if(2>r||r>36)throw Error("radix out of range: "+r);if("-"==e.charAt(0))return n.fromString(e.substring(1),r).negate();if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+e);for(var i=n.fromNumber(Math.pow(r,8)),o=n.ZERO,s=0;sa){var c=n.fromNumber(Math.pow(r,a));o=o.multiply(c).add(n.fromNumber(u))}else o=o.multiply(i),o=o.add(n.fromNumber(u))}return o},n.INT_CACHE_={},n.TWO_PWR_16_DBL_=65536,n.TWO_PWR_24_DBL_=1<<24,n.TWO_PWR_32_DBL_=n.TWO_PWR_16_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_31_DBL_=n.TWO_PWR_32_DBL_/2,n.TWO_PWR_48_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_64_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_32_DBL_,n.TWO_PWR_63_DBL_=n.TWO_PWR_64_DBL_/2,n.ZERO=n.fromInt(0),n.ONE=n.fromInt(1),n.NEG_ONE=n.fromInt(-1),n.MAX_VALUE=n.fromBits(-1,2147483647),n.MIN_VALUE=n.fromBits(0,-2147483648),n.TWO_PWR_24_=n.fromInt(1<<24),t.exports=n,t.exports.Long=n},{}],36:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0}),r.SCMessenger=void 0;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;rc;c++)u[c]=(15>=c?"0":"")+c.toString(16);a.prototype.toHexString=function(){if(a.cacheHexString&&this.__id)return this.__id;var e="";if(!this.id||!this.id.length)throw new Error("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(this.id instanceof f)return e=h(this.id),a.cacheHexString&&(this.__id=e),e;for(var t=0;t>8&255,s[1]=t>>16&255,s[0]=t>>24&255,s[6]=255&n,s[5]=n>>8&255,s[4]=n>>16&255,s[8]=255&i,s[7]=i>>8&255,s[11]=255&o,s[10]=o>>8&255,s[9]=o>>16&255,s},a.prototype.toString=function(e){return this.id&&this.id.copy?this.id.toString("string"==typeof e?e:"hex"):this.toHexString()},a.prototype.inspect=a.prototype.toString,a.prototype.toJSON=function(){return this.toHexString()},a.prototype.equals=function(e){return e instanceof a?this.toString()==e.toString():"string"==typeof e&&a.isValid(e)&&12==e.length&&this.id instanceof f?e===this.id.toString("binary"):"string"==typeof e&&a.isValid(e)&&24==e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&a.isValid(e)&&12==e.length?e===this.id:null!=e&&(e instanceof a||e.toHexString)?e.toHexString()===this.toHexString():!1},a.prototype.getTimestamp=function(){var e=new Date,t=this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24;return e.setTime(1e3*Math.floor(t)),e},a.index=~~(16777215*Math.random()),a.createPk=function(){return new a},a.createFromTime=function(e){var t=new r([0,0,0,0,0,0,0,0,0,0,0,0]);return t[3]=255&e,t[2]=e>>8&255,t[1]=e>>16&255,t[0]=e>>24&255,new a(t)};for(var l=("0123456789abcdef".split(""),[]),c=0;10>c;)l[48+c]=c++;for(;16>c;)l[55+c]=l[87+c]=c++;var f=r,h=function(e){return e.toString("hex")};a.createFromHexString=function(e){if("undefined"==typeof e||null!=e&&24!=e.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(o)return new a(new r(e,"hex"));for(var t=new f(12),n=0,i=0;24>i;)t[n++]=l[e.charCodeAt(i++)]<<4|l[e.charCodeAt(i++)];return new a(t)},a.isValid=function(e){return null==e?!1:"number"==typeof e?!0:"string"==typeof e?12==e.length||24==e.length&&i.test(e):e instanceof a?!0:e instanceof f?!0:e.toHexString?12==e.id.length||24==e.id.length&&i.test(e.id):!1},Object.defineProperty(a.prototype,"generationTime",{enumerable:!0,get:function(){return this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24},set:function(e){this.id[3]=255&e,this.id[2]=e>>8&255,this.id[1]=e>>16&255,this.id[0]=e>>24&255}}),t.exports=a,t.exports.ObjectID=a,t.exports.ObjectId=a}).call(this,e("_process"),e("buffer").Buffer)},{_process:3,buffer:4}],39:[function(e,t,r){"use strict";function n(){return i?i:this&&this.constructor===n?void(i=this):new n}Object.defineProperty(r,"__esModule",{value:!0});var i;n.prototype._listeners={},n.prototype.emit=function(){for(var e=[],t=0;ti;i++)this._listeners[r][i].apply(null,e)},n.prototype.on=function(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)};var o=function(){return n}();r["default"]=o},{}],40:[function(e,t,r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0}),r.CloudFileProtocol=r.BotProtocol=r.CloudCodeProtocol=r.MessengerProtocol=r.UserProtocol=r.DataProtocol=r.Protocol=void 0;var s=function(){function e(e,t){for(var r=0;re)throw new Error("Limit must be a positive number");return this._limit=e,this}},{key:"skip",value:function(e){if(!s.Utils.isNumber(e)||0>e)throw new Error("Skip must be a positive number");return this._skip=e,this}},{key:"page",value:function(e){if(!s.Utils.isNumber(e)||0>e)throw new Error("Page must be a positive number");return this._skip=(e-1)*this._limit,this}},{key:"ascending",value:function(e){return this._sort[e]=1,this}},{key:"descending",value:function(e){return this._sort[e]=-1,this}},{key:"or",value:function(t){if(!(t instanceof e))throw new Error("Invalid type of Query");return this._filter.$or||(this._filter.$or=[]),this._filter.$or.push(t.toJson().query),this}},{key:"and",value:function(t){if(!(t instanceof e))throw new Error("Invalid type of Query");return this._filter.$and||(this._filter.$and=[]),this._filter.$and.push(t.toJson().query),this}},{key:"select",value:function(){this._fields=[];for(var e=arguments.length,t=0;e>t;t++)this._fields.push(arguments[t]);return this}},{key:"raw",value:function(e){if(!s.Utils.isObject(e))throw new Error("Filter must be a object");return this._filter=e,this}},{key:"toJson",value:function(){var e={coll:this._collection,limit:this._limit,skip:this._skip,query:this._filter,sort:this._sort,fields:this._fields};return e}}]),e}();r.SCQuery=u},{"./stores/data":43,"./utils":48}],42:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}var i=e("./query"),o=e("./user"),s=e("./object"),a=e("./client"),u=e("./updateOps"),c=e("./messenger"),l=e("./cloudCode"),f=e("./websocket"),h=e("./system"),p=e("./logger"),d=e("./bot"),v=e("./instance"),y=e("./observer"),g=n(y),_={Init:function(e){var t=a.Client.init(e);return t},getSessionId:function(){var e=a.Client.getInstance();return e.sessionId},setSessionId:function(e){var t=a.Client.getInstance();t.sessionId=e},on:function(e,t){(0,g["default"])().on(e,t)},use:function(e){var t=a.Client.getInstance();t.middleware.push(e)}};_.Query=i.SCQuery,_.Object=s.SCObject,_.User=o.SCUser,_.UpdateOps=u.SCUpdateOps,_.Messenger=c.SCMessenger,_.CloudCode=l.SCCloudCode,_.WebSocket=f.SCWebSocket,_.System=h.SCSystem,_.Logger=p.SCLogger,_.Bot=d.SCBot,_.Instance=v.SCInstance,_.Field=h.SCField,t.exports=_},{"./bot":28,"./client":30,"./cloudCode":31,"./instance":33,"./logger":34,"./messenger":36,"./object":37,"./observer":39,"./query":41,"./system":45,"./updateOps":46,"./user":47,"./websocket":49}],43:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0}),r.DataStore=void 0;var i=function(){function e(e,t){for(var r=0;ri;i++)this._handlers[r][i].apply(null,e)}},{key:"on",value:function(e,t){this._handlers[e]||(this._handlers[e]=[]),this._handlers[e].push(t)}},{key:"send",value:function(e){this.wsInstanse.send(e)}}]),t}()},{"./client":30,ws:13}]},{},[42])(42)});