From a26ba85296d69f1b3a9f9f9416cc9cfe17f9f965 Mon Sep 17 00:00:00 2001 From: Giovanni Foiani Date: Thu, 31 Mar 2016 10:31:06 +0200 Subject: [PATCH 1/4] Add discard from Api and discard mine options Add ack handling for STOMP client --- config/constants.js | 6 +- dist/spacebunny.js | 46 +++++------ docs/messages/amqpMessage.md | 5 ++ docs/messages/stompMessage.md | 5 ++ docs/spacebunny.md | 22 +++++- lib/{message.js => messages/amqpMessage.js} | 20 ++--- lib/messages/amqpMessage.js.map | 1 + lib/messages/stompMessage.js | 86 +++++++++++++++++++++ lib/messages/stompMessage.js.map | 1 + lib/protocols/amqpClient.js | 50 ++++-------- lib/protocols/amqpClient.js.map | 2 +- lib/protocols/stompClient.js | 62 +++++++++++++-- lib/protocols/stompClient.js.map | 2 +- lib/spacebunny.js | 25 +++++- lib/spacebunny.js.map | 2 +- src/{message.js => messages/amqpMessage.js} | 10 +-- src/messages/stompMessage.js | 52 +++++++++++++ src/protocols/amqpClient.js | 41 +++------- src/protocols/stompClient.js | 51 +++++++++--- src/spacebunny.js | 20 +++++ 20 files changed, 380 insertions(+), 129 deletions(-) create mode 100644 docs/messages/amqpMessage.md create mode 100644 docs/messages/stompMessage.md rename lib/{message.js => messages/amqpMessage.js} (87%) create mode 100644 lib/messages/amqpMessage.js.map create mode 100644 lib/messages/stompMessage.js create mode 100644 lib/messages/stompMessage.js.map rename src/{message.js => messages/amqpMessage.js} (83%) create mode 100644 src/messages/stompMessage.js diff --git a/config/constants.js b/config/constants.js index 3a3ea65..de0c1bb 100644 --- a/config/constants.js +++ b/config/constants.js @@ -18,13 +18,13 @@ exports.CONFIG = { ssl: { secureProtocol: 'TLSv1_method' }, - ackTypes: ['auto', 'manual'], - inputExchange: 'input', + fromApiHeader: 'x-from-sb-api', protocol: 'amqp', inboxTopic: 'inbox', liveStreamSuffix: 'live_stream', tempQueueSuffix: 'temp', amqp: { + ackTypes: ['auto', 'manual'], protocol: 'amqp', ssl: { protocol: 'amqps' @@ -51,6 +51,7 @@ exports.CONFIG = { } }, stomp: { + ackTypes: ['client'], connection: { headers: { max_hbrlck_fails: 10, @@ -65,6 +66,7 @@ exports.CONFIG = { } }, webStomp: { + ackTypes: ['client'], webSocket: { protocol: 'ws', ssl: { diff --git a/dist/spacebunny.js b/dist/spacebunny.js index 3e5156f..9f161fd 100644 --- a/dist/spacebunny.js +++ b/dist/spacebunny.js @@ -1,10 +1,10 @@ -webpackJsonp([0,1],[function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.StompStreamClient=t.MqttStreamClient=t.AmqpStreamClient=t.StreamClient=t.StompClient=t.MqttClient=t.AmqpClient=t.Client=void 0;var i=n(2),o=r(i),s=n(231),a=r(s),u=n(283),c=r(u),l=n(290),f=r(l),h=n(291),p=r(h),d=n(292),v=r(d);"undefined"!=typeof window&&(window.StompClient=c["default"],window.StompStreamClient=v["default"]),t.Client=o["default"],t.AmqpClient=o["default"],t.MqttClient=a["default"],t.StompClient=c["default"],t.StreamClient=f["default"],t.AmqpStreamClient=f["default"],t.MqttStreamClient=p["default"],t.StompStreamClient=v["default"]},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),u=r(a),c=function(){function e(e,t){for(var n=0;n * @license MIT */ -"use strict";function i(){function e(){}try{var t=new Uint8Array(1);return t.foo=function(){return 42},t.constructor=e,42===t.foo()&&t.constructor===e&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(n){return!1}}function o(){return e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function e(t){return this instanceof e?(e.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?s(this,t):"string"==typeof t?a(this,t,arguments.length>1?arguments[1]:"utf8"):u(this,t)):arguments.length>1?new e(t,arguments[1]):new e(t)}function s(t,n){if(t=v(t,0>n?0:0|g(n)),!e.TYPED_ARRAY_SUPPORT)for(var r=0;n>r;r++)t[r]=0;return t}function a(e,t,n){"string"==typeof n&&""!==n||(n="utf8");var r=0|m(t,n);return e=v(e,r),e.write(t,n),e}function u(t,n){if(e.isBuffer(n))return c(t,n);if($(n))return l(t,n);if(null==n)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(n.buffer instanceof ArrayBuffer)return f(t,n);if(n instanceof ArrayBuffer)return h(t,n)}return n.length?p(t,n):d(t,n)}function c(e,t){var n=0|g(t.length);return e=v(e,n),t.copy(e,0,0,n),e}function l(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function f(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(t,n){return e.TYPED_ARRAY_SUPPORT?(n.byteLength,t=e._augment(new Uint8Array(n))):t=f(t,new Uint8Array(n)),t}function p(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t){var n,r=0;"Buffer"===t.type&&$(t.data)&&(n=t.data,r=0|g(n.length)),e=v(e,r);for(var i=0;r>i;i+=1)e[i]=255&n[i];return e}function v(t,n){e.TYPED_ARRAY_SUPPORT?(t=e._augment(new Uint8Array(n)),t.__proto__=e.prototype):(t.length=n,t._isBuffer=!0);var r=0!==n&&n<=e.poolSize>>>1;return r&&(t.parent=X),t}function g(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function y(t,n){if(!(this instanceof y))return new y(t,n);var r=new e(t,n);return delete r.parent,r}function m(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return K(e).length;default:if(r)return H(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return U(this,t,n);case"binary":return B(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function _(e,t,n,r){return Y(H(t,e.length-n),e,n,r)}function E(e,t,n,r){return Y(Q(t),e,n,r)}function x(e,t,n,r){return E(e,t,n,r)}function I(e,t,n,r){return Y(K(t),e,n,r)}function k(e,t,n,r){return Y(W(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?V.fromByteArray(e):V.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n>=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,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return T(r)}function T(e){var t=e.length;if(J>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=J));return n}function U(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function j(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=z(e[o]);return i}function O(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(t,n,r,i,o,s){if(!e.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(n>o||s>n)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function L(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function M(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function P(e,t,n,r,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function F(e,t,n,r,i){return i||P(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,i){return i||P(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(e,t,n,r,52,8),n+8}function D(e){if(e=q(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function z(e){return 16>e?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Q(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function K(e){return V.toByteArray(D(e))}function Y(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}var V=n(4),G=n(5),$=n(6);t.Buffer=e,t.SlowBuffer=y,t.INSPECT_MAX_BYTES=50,e.poolSize=8192;var X={};e.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),e.TYPED_ARRAY_SUPPORT?(e.prototype.__proto__=Uint8Array.prototype,e.__proto__=Uint8Array):(e.prototype.length=void 0,e.prototype.parent=void 0),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 r=t.length,i=n.length,o=0,s=Math.min(r,i);s>o&&t[o]===n[o];)++o;return o!==s&&(r=t[o],i=n[o]),i>r?-1:r>i?1:0},e.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}},e.concat=function(t,n){if(!$(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new e(0);var r;if(void 0===n)for(n=0,r=0;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},e.prototype.compare=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:e.compare(this,t)},e.prototype.indexOf=function(t,n){function r(e,t,n){for(var r=-1,i=0;n+i2147483647?n=2147483647:-2147483648>n&&(n=-2147483648),n>>=0,0===this.length)return-1;if(n>=this.length)return-1;if(0>n&&(n=Math.max(this.length+n,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,n);if(e.isBuffer(t))return r(this,t,n);if("number"==typeof t)return e.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,n):r(this,[t],n);throw new TypeError("val must be string, number or Buffer")},e.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},e.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},e.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var i=r;r=t,t=0|n,n=i}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return E(this,e,t,n);case"binary":return x(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;e.prototype.slice=function(t,n){var r=this.length;t=~~t,n=void 0===n?r:~~n,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>n?(n+=r,0>n&&(n=0)):n>r&&(n=r),t>n&&(n=t);var i;if(e.TYPED_ARRAY_SUPPORT)i=e._augment(this.subarray(t,n));else{var o=n-t;i=new e(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},e.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},e.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},e.prototype.readUInt32LE=function(e,t){return t||R(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||R(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|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},e.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},e.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},e.prototype.readInt16LE=function(e,t){t||R(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||R(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||R(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||R(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||R(e,4,this.length),G.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),G.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),G.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),G.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||A(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},e.prototype.writeUInt8=function(t,n,r){return t=+t,n=0|n,r||A(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,r){return t=+t,n=0|n,r||A(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=0|n,r||A(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):M(this,t,n,!0),n+4},e.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=0|n,r||A(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):M(this,t,n,!1),n+4},e.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,s=1,a=0>e?1:0;for(this[t]=255&e;++o>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0>e?1:0;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=(e/s>>0)-a&255;return t+n},e.prototype.writeInt8=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,1,127,-128),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[n]=255&t,n+1},e.prototype.writeInt16LE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeInt16BE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeInt32LE=function(t,n,r){return t=+t,n=0|n,r||A(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):M(this,t,n,!0),n+4},e.prototype.writeInt32BE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,4,2147483647,-2147483648),0>t&&(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):M(this,t,n,!1),n+4},e.prototype.writeFloatLE=function(e,t,n){return F(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return F(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},e.prototype.copy=function(t,n,r,i){if(r||(r=0),i||0===i||(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>n)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-nr&&i>n)for(o=s-1;o>=0;o--)t[o+n]=this[o+r];else if(1e3>s||!e.TYPED_ARRAY_SUPPORT)for(o=0;s>o;o++)t[o+n]=this[o+r];else t._set(this.subarray(r,r+s),n);return s},e.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=H(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}},e.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(e.TYPED_ARRAY_SUPPORT)return new e(this).buffer;for(var t=new Uint8Array(this.length),n=0,r=t.length;r>n;n+=1)t[n]=this[n];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Z=e.prototype;e._augment=function(t){return t.constructor=e,t._isBuffer=!0,t._set=t.set,t.get=Z.get,t.set=Z.set,t.write=Z.write,t.toString=Z.toString,t.toLocaleString=Z.toString,t.toJSON=Z.toJSON,t.equals=Z.equals,t.compare=Z.compare,t.indexOf=Z.indexOf,t.copy=Z.copy,t.slice=Z.slice,t.readUIntLE=Z.readUIntLE,t.readUIntBE=Z.readUIntBE,t.readUInt8=Z.readUInt8,t.readUInt16LE=Z.readUInt16LE,t.readUInt16BE=Z.readUInt16BE,t.readUInt32LE=Z.readUInt32LE,t.readUInt32BE=Z.readUInt32BE,t.readIntLE=Z.readIntLE,t.readIntBE=Z.readIntBE,t.readInt8=Z.readInt8,t.readInt16LE=Z.readInt16LE,t.readInt16BE=Z.readInt16BE,t.readInt32LE=Z.readInt32LE,t.readInt32BE=Z.readInt32BE,t.readFloatLE=Z.readFloatLE,t.readFloatBE=Z.readFloatBE,t.readDoubleLE=Z.readDoubleLE,t.readDoubleBE=Z.readDoubleBE,t.writeUInt8=Z.writeUInt8,t.writeUIntLE=Z.writeUIntLE,t.writeUIntBE=Z.writeUIntBE,t.writeUInt16LE=Z.writeUInt16LE,t.writeUInt16BE=Z.writeUInt16BE,t.writeUInt32LE=Z.writeUInt32LE,t.writeUInt32BE=Z.writeUInt32BE,t.writeIntLE=Z.writeIntLE,t.writeIntBE=Z.writeIntBE,t.writeInt8=Z.writeInt8,t.writeInt16LE=Z.writeInt16LE,t.writeInt16BE=Z.writeInt16BE,t.writeInt32LE=Z.writeInt32LE,t.writeInt32BE=Z.writeInt32BE,t.writeFloatLE=Z.writeFloatLE,t.writeFloatBE=Z.writeFloatBE,t.writeDoubleLE=Z.writeDoubleLE,t.writeDoubleBE=Z.writeDoubleBE,t.fill=Z.fill,t.inspect=Z.inspect,t.toArrayBuffer=Z.toArrayBuffer,t};var ee=/[^+\/0-9A-Za-z-_]/g}).call(t,n(3).Buffer,function(){return this}())},function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===f?62:t===a||t===h?63:u>t?-1:u+10>t?t-u+26+26:l+26>t?t-l:c+26>t?t-c+26:void 0}function n(e){function n(e){c[f++]=e}var r,i,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=e.length;u="="===e.charAt(l-2)?2:"="===e.charAt(l-1)?1:0,c=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var f=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),c}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),l="A".charCodeAt(0),f="-".charCodeAt(0),h="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}(t)},function(e,t){t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<>1,l=-7,f=n?i-1:0,h=n?-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+=r;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,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,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=r?0:o-1,d=r?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[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*v}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){function r(e,t,n,r){e=o(e)?e:u(e),n=n&&!r?a(n):0;var l=e.length;return 0>n&&(n=c(l+n,0)),s(e)?l>=n&&e.indexOf(t,n)>-1:!!l&&i(e,t,n)>-1}var i=n(8),o=n(10),s=n(16),a=n(19),u=n(21),c=Math.max;e.exports=r},function(e,t,n){function r(e,t,n){if(t!==t)return i(e,n);for(var r=n-1,o=e.length;++r-1&&e%1==0&&r>=e}var r=9007199254740991;e.exports=n},function(e,t,n){function r(e){return"string"==typeof e||!i(e)&&o(e)&&u.call(e)==s}var i=n(17),o=n(18),s="[object String]",a=Object.prototype,u=a.toString;e.exports=r},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){function n(e){return!!e&&"object"==typeof e}e.exports=n},function(e,t,n){function r(e){if(!e)return 0===e?e:0;if(e=i(e),e===o||e===-o){var t=0>e?-1:1;return t*s}var n=e%1;return e===e?n?e-n:e:0}var i=n(20),o=1/0,s=1.7976931348623157e308;e.exports=r},function(e,t,n){function r(e){if(o(e)){var t=i(e.valueOf)?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var n=c.test(e);return n||l.test(e)?f(e.slice(2),n?2:8):u.test(e)?s:+e}var i=n(13),o=n(14),s=NaN,a=/^\s+|\s+$/g,u=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,f=parseInt;e.exports=r},function(e,t,n){function r(e){return e?i(e,o(e)):[]}var i=n(22),o=n(24);e.exports=r},function(e,t,n){function r(e,t){return i(t,function(t){return e[t]})}var i=n(23);e.exports=r},function(e,t){function n(e,t){for(var n=-1,r=e.length,i=Array(r);++n-1&&e%1==0&&t>e}var r=9007199254740991,i=/^(?:0|[1-9]\d*)$/;e.exports=n},function(e,t){function n(e){var t=e&&e.constructor,n="function"==typeof t&&t.prototype||r;return e===n}var r=Object.prototype;e.exports=n},function(e,t,n){(function(e){!function(t){function n(e,t){if("object"!==i(e))return t;for(var r in t)"object"===i(e[r])&&"object"===i(t[r])?e[r]=n(e[r],t[r]):e[r]=t[r];return e}function r(e,t,r){var s=r[0],a=r.length;(e||"object"!==i(s))&&(s={});for(var u=0;a>u;++u){var c=r[u],l=i(c);if("object"===l)for(var f in c){var h=e?o.clone(c[f]):c[f];t?s[f]=n(s[f],h):s[f]=h}}return s}function i(e){return{}.toString.call(e).slice(8,-1).toLowerCase()}var o=function(e){return r(e===!0,!1,arguments)},s="merge";o.recursive=function(e){return r(e===!0,!0,arguments)},o.clone=function(e){var t,n,r=e,s=i(e);if("array"===s)for(r=[],n=e.length,t=0;n>t;++t)r[t]=o.clone(e[t]);else if("object"===s){r={};for(t in e)r[t]=o.clone(e[t])}return r},t?e.exports=o:window[s]=o}("object"==typeof e&&e&&"object"==typeof e.exports&&e.exports)}).call(t,n(34)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}},function(e,t,n){(function(t,n,r){/* @preserve +"use strict";function i(){function e(){}try{var t=new Uint8Array(1);return t.foo=function(){return 42},t.constructor=e,42===t.foo()&&t.constructor===e&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(n){return!1}}function o(){return e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function e(t){return this instanceof e?(e.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?s(this,t):"string"==typeof t?a(this,t,arguments.length>1?arguments[1]:"utf8"):u(this,t)):arguments.length>1?new e(t,arguments[1]):new e(t)}function s(t,n){if(t=v(t,0>n?0:0|g(n)),!e.TYPED_ARRAY_SUPPORT)for(var r=0;n>r;r++)t[r]=0;return t}function a(e,t,n){"string"==typeof n&&""!==n||(n="utf8");var r=0|m(t,n);return e=v(e,r),e.write(t,n),e}function u(t,n){if(e.isBuffer(n))return c(t,n);if($(n))return l(t,n);if(null==n)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(n.buffer instanceof ArrayBuffer)return f(t,n);if(n instanceof ArrayBuffer)return h(t,n)}return n.length?p(t,n):d(t,n)}function c(e,t){var n=0|g(t.length);return e=v(e,n),t.copy(e,0,0,n),e}function l(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function f(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(t,n){return e.TYPED_ARRAY_SUPPORT?(n.byteLength,t=e._augment(new Uint8Array(n))):t=f(t,new Uint8Array(n)),t}function p(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t){var n,r=0;"Buffer"===t.type&&$(t.data)&&(n=t.data,r=0|g(n.length)),e=v(e,r);for(var i=0;r>i;i+=1)e[i]=255&n[i];return e}function v(t,n){e.TYPED_ARRAY_SUPPORT?(t=e._augment(new Uint8Array(n)),t.__proto__=e.prototype):(t.length=n,t._isBuffer=!0);var r=0!==n&&n<=e.poolSize>>>1;return r&&(t.parent=X),t}function g(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function y(t,n){if(!(this instanceof y))return new y(t,n);var r=new e(t,n);return delete r.parent,r}function m(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return K(e).length;default:if(r)return H(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return U(this,t,n);case"binary":return B(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function _(e,t,n,r){return Y(H(t,e.length-n),e,n,r)}function E(e,t,n,r){return Y(Q(t),e,n,r)}function x(e,t,n,r){return E(e,t,n,r)}function I(e,t,n,r){return Y(K(t),e,n,r)}function k(e,t,n,r){return Y(W(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?V.fromByteArray(e):V.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n>=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,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return T(r)}function T(e){var t=e.length;if(J>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=J));return n}function U(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function j(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=z(e[o]);return i}function O(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function R(t,n,r,i,o,s){if(!e.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(n>o||s>n)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function L(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function M(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function F(e,t,n,r,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function P(e,t,n,r,i){return i||F(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,i){return i||F(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(e,t,n,r,52,8),n+8}function D(e){if(e=q(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function z(e){return 16>e?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Q(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function K(e){return V.toByteArray(D(e))}function Y(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}var V=n(4),G=n(5),$=n(6);t.Buffer=e,t.SlowBuffer=y,t.INSPECT_MAX_BYTES=50,e.poolSize=8192;var X={};e.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),e.TYPED_ARRAY_SUPPORT?(e.prototype.__proto__=Uint8Array.prototype,e.__proto__=Uint8Array):(e.prototype.length=void 0,e.prototype.parent=void 0),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 r=t.length,i=n.length,o=0,s=Math.min(r,i);s>o&&t[o]===n[o];)++o;return o!==s&&(r=t[o],i=n[o]),i>r?-1:r>i?1:0},e.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}},e.concat=function(t,n){if(!$(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new e(0);var r;if(void 0===n)for(n=0,r=0;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},e.prototype.compare=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:e.compare(this,t)},e.prototype.indexOf=function(t,n){function r(e,t,n){for(var r=-1,i=0;n+i2147483647?n=2147483647:-2147483648>n&&(n=-2147483648),n>>=0,0===this.length)return-1;if(n>=this.length)return-1;if(0>n&&(n=Math.max(this.length+n,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,n);if(e.isBuffer(t))return r(this,t,n);if("number"==typeof t)return e.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,n):r(this,[t],n);throw new TypeError("val must be string, number or Buffer")},e.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},e.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},e.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var i=r;r=t,t=0|n,n=i}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return E(this,e,t,n);case"binary":return x(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;e.prototype.slice=function(t,n){var r=this.length;t=~~t,n=void 0===n?r:~~n,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>n?(n+=r,0>n&&(n=0)):n>r&&(n=r),t>n&&(n=t);var i;if(e.TYPED_ARRAY_SUPPORT)i=e._augment(this.subarray(t,n));else{var o=n-t;i=new e(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},e.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},e.prototype.readUInt8=function(e,t){return t||A(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return t||A(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return t||A(e,2,this.length),this[e]<<8|this[e+1]},e.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]},e.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])},e.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},e.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},e.prototype.readInt8=function(e,t){return t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},e.prototype.readInt16LE=function(e,t){t||A(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||A(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||A(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||A(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||A(e,4,this.length),G.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return t||A(e,4,this.length),G.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return t||A(e,8,this.length),G.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return t||A(e,8,this.length),G.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||R(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},e.prototype.writeUInt8=function(t,n,r){return t=+t,n=0|n,r||R(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,r){return t=+t,n=0|n,r||R(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=0|n,r||R(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):M(this,t,n,!0),n+4},e.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=0|n,r||R(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):M(this,t,n,!1),n+4},e.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}var o=0,s=1,a=0>e?1:0;for(this[t]=255&e;++o>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0>e?1:0;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=(e/s>>0)-a&255;return t+n},e.prototype.writeInt8=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,1,127,-128),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[n]=255&t,n+1},e.prototype.writeInt16LE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeInt16BE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeInt32LE=function(t,n,r){return t=+t,n=0|n,r||R(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):M(this,t,n,!0),n+4},e.prototype.writeInt32BE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,4,2147483647,-2147483648),0>t&&(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):M(this,t,n,!1),n+4},e.prototype.writeFloatLE=function(e,t,n){return P(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return P(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},e.prototype.copy=function(t,n,r,i){if(r||(r=0),i||0===i||(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>n)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-nr&&i>n)for(o=s-1;o>=0;o--)t[o+n]=this[o+r];else if(1e3>s||!e.TYPED_ARRAY_SUPPORT)for(o=0;s>o;o++)t[o+n]=this[o+r];else t._set(this.subarray(r,r+s),n);return s},e.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=H(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}},e.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(e.TYPED_ARRAY_SUPPORT)return new e(this).buffer;for(var t=new Uint8Array(this.length),n=0,r=t.length;r>n;n+=1)t[n]=this[n];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Z=e.prototype;e._augment=function(t){return t.constructor=e,t._isBuffer=!0,t._set=t.set,t.get=Z.get,t.set=Z.set,t.write=Z.write,t.toString=Z.toString,t.toLocaleString=Z.toString,t.toJSON=Z.toJSON,t.equals=Z.equals,t.compare=Z.compare,t.indexOf=Z.indexOf,t.copy=Z.copy,t.slice=Z.slice,t.readUIntLE=Z.readUIntLE,t.readUIntBE=Z.readUIntBE,t.readUInt8=Z.readUInt8,t.readUInt16LE=Z.readUInt16LE,t.readUInt16BE=Z.readUInt16BE,t.readUInt32LE=Z.readUInt32LE,t.readUInt32BE=Z.readUInt32BE,t.readIntLE=Z.readIntLE,t.readIntBE=Z.readIntBE,t.readInt8=Z.readInt8,t.readInt16LE=Z.readInt16LE,t.readInt16BE=Z.readInt16BE,t.readInt32LE=Z.readInt32LE,t.readInt32BE=Z.readInt32BE,t.readFloatLE=Z.readFloatLE,t.readFloatBE=Z.readFloatBE,t.readDoubleLE=Z.readDoubleLE,t.readDoubleBE=Z.readDoubleBE,t.writeUInt8=Z.writeUInt8,t.writeUIntLE=Z.writeUIntLE,t.writeUIntBE=Z.writeUIntBE,t.writeUInt16LE=Z.writeUInt16LE,t.writeUInt16BE=Z.writeUInt16BE,t.writeUInt32LE=Z.writeUInt32LE,t.writeUInt32BE=Z.writeUInt32BE,t.writeIntLE=Z.writeIntLE,t.writeIntBE=Z.writeIntBE,t.writeInt8=Z.writeInt8,t.writeInt16LE=Z.writeInt16LE,t.writeInt16BE=Z.writeInt16BE,t.writeInt32LE=Z.writeInt32LE,t.writeInt32BE=Z.writeInt32BE,t.writeFloatLE=Z.writeFloatLE,t.writeFloatBE=Z.writeFloatBE,t.writeDoubleLE=Z.writeDoubleLE,t.writeDoubleBE=Z.writeDoubleBE,t.fill=Z.fill,t.inspect=Z.inspect,t.toArrayBuffer=Z.toArrayBuffer,t};var ee=/[^+\/0-9A-Za-z-_]/g}).call(t,n(3).Buffer,function(){return this}())},function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===f?62:t===a||t===h?63:u>t?-1:u+10>t?t-u+26+26:l+26>t?t-l:c+26>t?t-c+26:void 0}function n(e){function n(e){c[f++]=e}var r,i,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=e.length;u="="===e.charAt(l-2)?2:"="===e.charAt(l-1)?1:0,c=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var f=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),c}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),l="A".charCodeAt(0),f="-".charCodeAt(0),h="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}(t)},function(e,t){t.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<>1,l=-7,f=n?i-1:0,h=n?-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+=r;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,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,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=r?0:o-1,d=r?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[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*v}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){function r(e,t,n,r){e=o(e)?e:u(e),n=n&&!r?a(n):0;var l=e.length;return 0>n&&(n=c(l+n,0)),s(e)?l>=n&&e.indexOf(t,n)>-1:!!l&&i(e,t,n)>-1}var i=n(8),o=n(10),s=n(16),a=n(19),u=n(21),c=Math.max;e.exports=r},function(e,t,n){function r(e,t,n){if(t!==t)return i(e,n);for(var r=n-1,o=e.length;++r-1&&e%1==0&&r>=e}var r=9007199254740991;e.exports=n},function(e,t,n){function r(e){return"string"==typeof e||!i(e)&&o(e)&&u.call(e)==s}var i=n(17),o=n(18),s="[object String]",a=Object.prototype,u=a.toString;e.exports=r},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){function n(e){return!!e&&"object"==typeof e}e.exports=n},function(e,t,n){function r(e){if(!e)return 0===e?e:0;if(e=i(e),e===o||e===-o){var t=0>e?-1:1;return t*s}var n=e%1;return e===e?n?e-n:e:0}var i=n(20),o=1/0,s=1.7976931348623157e308;e.exports=r},function(e,t,n){function r(e){if(o(e)){var t=i(e.valueOf)?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var n=c.test(e);return n||l.test(e)?f(e.slice(2),n?2:8):u.test(e)?s:+e}var i=n(13),o=n(14),s=NaN,a=/^\s+|\s+$/g,u=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,f=parseInt;e.exports=r},function(e,t,n){function r(e){return e?i(e,o(e)):[]}var i=n(22),o=n(24);e.exports=r},function(e,t,n){function r(e,t){return i(t,function(t){return e[t]})}var i=n(23);e.exports=r},function(e,t){function n(e,t){for(var n=-1,r=e.length,i=Array(r);++n-1&&e%1==0&&t>e}var r=9007199254740991,i=/^(?:0|[1-9]\d*)$/;e.exports=n},function(e,t){function n(e){var t=e&&e.constructor,n="function"==typeof t&&t.prototype||r;return e===n}var r=Object.prototype;e.exports=n},function(e,t,n){(function(e){!function(t){function n(e,t){if("object"!==i(e))return t;for(var r in t)"object"===i(e[r])&&"object"===i(t[r])?e[r]=n(e[r],t[r]):e[r]=t[r];return e}function r(e,t,r){var s=r[0],a=r.length;(e||"object"!==i(s))&&(s={});for(var u=0;a>u;++u){var c=r[u],l=i(c);if("object"===l)for(var f in c){var h=e?o.clone(c[f]):c[f];t?s[f]=n(s[f],h):s[f]=h}}return s}function i(e){return{}.toString.call(e).slice(8,-1).toLowerCase()}var o=function(e){return r(e===!0,!1,arguments)},s="merge";o.recursive=function(e){return r(e===!0,!0,arguments)},o.clone=function(e){var t,n,r=e,s=i(e);if("array"===s)for(r=[],n=e.length,t=0;n>t;++t)r[t]=o.clone(e[t]);else if("object"===s){r={};for(t in e)r[t]=o.clone(e[t])}return r},t?e.exports=o:window[s]=o}("object"==typeof e&&e&&"object"==typeof e.exports&&e.exports)}).call(t,n(34)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}},function(e,t,n){(function(t,n,r){/* @preserve * The MIT License (MIT) * * Copyright (c) 2013-2015 Petka Antonov @@ -28,31 +28,31 @@ webpackJsonp([0,1],[function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict" * THE SOFTWARE. * */ -!function(t){e.exports=t()}(function(){var e,i,o;return function s(e,t,n){function r(o,a){if(!t[o]){if(!e[o]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return r(n?n:t)},l,l.exports,s,e,t,n)}return t[o].exports}for(var i="function"==typeof _dereq_&&_dereq_,o=0;o0;){var t=e.shift();if("function"==typeof t){var n=e.shift(),r=e.shift();t.call(n,r)}else t._settlePromises()}},i.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},i.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},i.prototype._reset=function(){this._isTickUsed=!1},n.exports=i,n.exports.firstLineError=u},{"./queue":26,"./schedule":29,"./util":36}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){var i=!1,o=function(e,t){this._reject(t)},s=function(e,t){t.promiseRejectionQueued=!0,t.bindingPromise._then(o,o,null,this,e)},a=function(e,t){0===(50397184&this._bitField)&&this._resolveCallback(t.target)},u=function(e,t){t.promiseRejectionQueued||this._reject(e)};e.prototype.bind=function(o){i||(i=!0,e.prototype._propagateFrom=r.propagateFromFunction(),e.prototype._boundValue=r.boundValueFunction());var c=n(o),l=new e(t);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(c),c instanceof e){var h={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:c};f._then(t,s,void 0,l,h),c._then(a,u,void 0,l,h),l._setOnCancel(c)}else l._resolveCallback(f);return l},e.prototype._setBoundTo=function(e){void 0!==e?(this._bitField=2097152|this._bitField,this._boundTo=e):this._bitField=-2097153&this._bitField},e.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},e.bind=function(t,n){return e.resolve(n).bind(t)}}},{}],4:[function(e,t,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(e){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=e("./promise")();o.noConflict=r,t.exports=o},{"./promise":22}],5:[function(e,t,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}t.exports=function(t){function n(e,n){var r;if(null!=e&&(r=e[n]),"function"!=typeof r){var i="Object "+a.classString(e)+" has no method '"+a.toString(n)+"'";throw new t.TypeError(i)}return r}function r(e){var t=this.pop(),r=n(e,t);return r.apply(e,this)}function i(e){return e[this]}function o(e){var t=+this;return 0>t&&(t=Math.max(0,t+e.length)),e[t]}var s,a=e("./util"),u=a.canEvaluate;a.isIdentifier;t.prototype.call=function(e){var t=[].slice.call(arguments,1);return t.push(e),this._then(r,void 0,void 0,t,void 0)},t.prototype.get=function(e){var t,n="number"==typeof e;if(n)t=o;else if(u){var r=s(e);t=null!==r?r:i}else t=i;return this._then(t,void 0,void 0,e,void 0)}}},{"./util":36}],6:[function(e,t,n){"use strict";t.exports=function(t,n,r,i){var o=e("./util"),s=o.tryCatch,a=o.errorObj,u=t._async;t.prototype["break"]=t.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var e=this,t=e;e.isCancellable();){if(!e._cancelBy(t)){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}var n=e._cancellationParent;if(null==n||!n.isCancellable()){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}e._isFollowing()&&e._followee().cancel(),t=e,e=n}},t.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},t.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},t.prototype._cancelBy=function(e){return e===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},t.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},t.prototype._cancel=function(){this.isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},t.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},t.prototype._unsetOnCancel=function(){this._onCancelField=void 0},t.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},t.prototype._doInvokeOnCancel=function(e,t){if(o.isArray(e))for(var n=0;n=0?o[e]:void 0}var i=!1,o=[];return e.prototype._promiseCreated=function(){},e.prototype._pushContext=function(){},e.prototype._popContext=function(){return null},e._peekContext=e.prototype._peekContext=function(){},t.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},t.prototype._popContext=function(){if(void 0!==this._trace){var e=o.pop(),t=e._promiseCreated;return e._promiseCreated=null,t}return null},t.CapturedTrace=null,t.create=n,t.deactivateLongStackTraces=function(){},t.activateLongStackTraces=function(){var n=e.prototype._pushContext,o=e.prototype._popContext,s=e._peekContext,a=e.prototype._peekContext,u=e.prototype._promiseCreated;t.deactivateLongStackTraces=function(){e.prototype._pushContext=n,e.prototype._popContext=o,e._peekContext=s,e.prototype._peekContext=a,e.prototype._promiseCreated=u,i=!1},i=!0,e.prototype._pushContext=t.prototype._pushContext,e.prototype._popContext=t.prototype._popContext,e._peekContext=e.prototype._peekContext=r,e.prototype._promiseCreated=function(){var e=this._peekContext();e&&null==e._promiseCreated&&(e._promiseCreated=this)}},t}},{}],9:[function(e,n,r){"use strict";n.exports=function(n,r){function i(e,t){return{promise:t}}function o(){return!1}function s(e,t,n){var r=this;try{e(t,n,function(e){if("function"!=typeof e)throw new TypeError("onCancel must be a function, got: "+N.toString(e));r._attachCancellationCallback(e)})}catch(i){return i}}function a(e){if(!this.isCancellable())return this;var t=this._onCancel();void 0!==t?N.isArray(t)?t.push(e):this._setOnCancel([t,e]):this._setOnCancel(e)}function u(){return this._onCancelField}function c(e){this._onCancelField=e}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(e,t){if(0!==(1&t)){this._cancellationParent=e;var n=e._branchesRemainingToCancel;void 0===n&&(n=0),e._branchesRemainingToCancel=n+1}0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function h(e,t){0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function p(){var e=this._boundTo;return void 0!==e&&e instanceof n?e.isFulfilled()?e.value():void 0:e}function d(){this._trace=new O(this._peekContext())}function v(e,t){if(D(e)){var n=this._trace;if(void 0!==n&&t&&(n=n._parent),void 0!==n)n.attachExtraTrace(e);else if(!e.__stackCleaned__){var r=I(e);N.notEnumerableProp(e,"stack",r.message+"\n"+r.stack.join("\n")),N.notEnumerableProp(e,"__stackCleaned__",!0)}}}function g(e,t,n,r,i){if(void 0===e&&null!==t&&V){if(void 0!==i&&i._returnedNonUndefined())return;var o=r._bitField;if(0===(65535&o))return;n&&(n+=" ");var s="a promise was created in a "+n+"handler but was not returned from it";r._warn(s,!0,t)}}function y(e,t){var n=e+" is deprecated and will be removed in a future version.";return t&&(n+=" Use "+t+" instead."),m(n)}function m(e,t,r){if(ie.warnings){var i,o=new F(e);if(t)r._attachExtraTrace(o);else if(ie.longStackTraces&&(i=n._peekContext()))i.attachExtraTrace(o);else{var s=I(o);o.stack=s.message+"\n"+s.stack.join("\n")}Z("warning",o)||k(o,"",!0)}}function b(e,t){for(var n=0;n=0;--a)if(r[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=r[a];if(t[i]!==u)break;t.pop(),i--}t=r}}function E(e){for(var t=[],n=0;n0&&(t=t.slice(n)),t}function I(e){var t=e.stack,n=e.toString();return t="string"==typeof t&&t.length>0?x(e):[" (No stack trace)"],{message:n,stack:E(t)}}function k(e,t,n){if("undefined"!=typeof console){var r;if(N.isObject(e)){var i=e.stack;r=t+H(i,e)}else r=t+String(e);"function"==typeof L?L(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function C(e,t,n,r){var i=!1;try{"function"==typeof t&&(i=!0,"rejectionHandled"===e?t(r):t(n,r))}catch(o){P.throwLater(o)}"unhandledRejection"===e?Z(e,n,r)||i||k(n,"Unhandled rejection "):Z(e,r)}function S(e){var t;if("function"==typeof e)t="[function "+(e.name||"anonymous")+"]";else{t=e&&"function"==typeof e.toString?e.toString():N.toString(e);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(t))try{var r=JSON.stringify(e);t=r}catch(i){}0===t.length&&(t="(empty array)")}return"(<"+T(t)+">, no stack trace)"}function T(e){var t=41;return e.lengths||0>a||!n||!r||n!==r||s>=a||(te=function(e){if(q.test(e))return!0;var t=B(e);return!!(t&&t.fileName===n&&s<=t.line&&t.line<=a)})}}function O(e){this._parent=e,this._promisesCreated=0;var t=this._length=1+(void 0===e?0:e._length);re(this,O),t>32&&this.uncycle()}var R,A,L,M=n._getDomain,P=n._async,F=e("./errors").Warning,N=e("./util"),D=N.canAttachTrace,q=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,z=null,H=null,Q=!1,W=!(0==N.env("BLUEBIRD_DEBUG")),K=!(0==N.env("BLUEBIRD_WARNINGS")||!W&&!N.env("BLUEBIRD_WARNINGS")),Y=!(0==N.env("BLUEBIRD_LONG_STACK_TRACES")||!W&&!N.env("BLUEBIRD_LONG_STACK_TRACES")),V=0!=N.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(K||!!N.env("BLUEBIRD_W_FORGOTTEN_RETURN"));n.prototype.suppressUnhandledRejections=function(){var e=this._target();e._bitField=-1048577&e._bitField|524288},n.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),P.invokeLater(this._notifyUnhandledRejection,this,void 0))},n.prototype._notifyUnhandledRejectionIsHandled=function(){C("rejectionHandled",R,void 0,this)},n.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},n.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},n.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var e=this._settledValue();this._setUnhandledRejectionIsNotified(),C("unhandledRejection",A,e,this)}},n.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},n.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},n.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},n.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},n.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},n.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},n.prototype._warn=function(e,t,n){return m(e,t,n||this)},n.onPossiblyUnhandledRejection=function(e){var t=M();A="function"==typeof e?null===t?e:t.bind(e):void 0},n.onUnhandledRejectionHandled=function(e){var t=M();R="function"==typeof e?null===t?e:t.bind(e):void 0};var G=function(){};n.longStackTraces=function(){if(P.haveItemsQueued()&&!ie.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ie.longStackTraces&&U()){var e=n.prototype._captureStackTrace,t=n.prototype._attachExtraTrace;ie.longStackTraces=!0,G=function(){if(P.haveItemsQueued()&&!ie.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");n.prototype._captureStackTrace=e,n.prototype._attachExtraTrace=t,r.deactivateLongStackTraces(),P.enableTrampoline(),ie.longStackTraces=!1},n.prototype._captureStackTrace=d,n.prototype._attachExtraTrace=v,r.activateLongStackTraces(),P.disableTrampolineIfNecessary()}},n.hasLongStackTraces=function(){return ie.longStackTraces&&U()};var $=function(){try{var e=document.createEvent("CustomEvent");return e.initCustomEvent("testingtheevent",!1,!0,{}),N.global.dispatchEvent(e),function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e.toLowerCase(),!1,!0,t),!N.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),X=function(){return N.isNode?function(){return t.emit.apply(t,arguments)}:N.global?function(e){var t="on"+e.toLowerCase(),n=N.global[t];return n?(n.apply(N.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),J={promiseCreated:i,promiseFulfilled:i,promiseRejected:i,promiseResolved:i,promiseCancelled:i,promiseChained:function(e,t,n){return{promise:t,child:n}},warning:function(e,t){return{warning:t}},unhandledRejection:function(e,t,n){return{reason:t,promise:n}},rejectionHandled:i},Z=function(e){var t=!1;try{t=X.apply(null,arguments)}catch(n){P.throwLater(n),t=!0}var r=!1;try{r=$(e,J[e].apply(null,arguments))}catch(n){P.throwLater(n),r=!0}return r||t};n.config=function(e){if(e=Object(e),"longStackTraces"in e&&(e.longStackTraces?n.longStackTraces():!e.longStackTraces&&n.hasLongStackTraces()&&G()),"warnings"in e){var t=e.warnings;ie.warnings=!!t,V=ie.warnings,N.isObject(t)&&"wForgottenReturn"in t&&(V=!!t.wForgottenReturn)}if("cancellation"in e&&e.cancellation&&!ie.cancellation){if(P.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");n.prototype._clearCancellationData=l,n.prototype._propagateFrom=f,n.prototype._onCancel=u,n.prototype._setOnCancel=c,n.prototype._attachCancellationCallback=a,n.prototype._execute=s,ee=f,ie.cancellation=!0}"monitoring"in e&&(e.monitoring&&!ie.monitoring?(ie.monitoring=!0,n.prototype._fireEvent=Z):!e.monitoring&&ie.monitoring&&(ie.monitoring=!1,n.prototype._fireEvent=o))},n.prototype._fireEvent=o,n.prototype._execute=function(e,t,n){try{e(t,n)}catch(r){return r}},n.prototype._onCancel=function(){},n.prototype._setOnCancel=function(e){},n.prototype._attachCancellationCallback=function(e){},n.prototype._captureStackTrace=function(){},n.prototype._attachExtraTrace=function(){},n.prototype._clearCancellationData=function(){},n.prototype._propagateFrom=function(e,t){};var ee=h,te=function(){return!1},ne=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;N.inherits(O,Error),r.CapturedTrace=O,O.prototype.uncycle=function(){var e=this._length;if(!(2>e)){for(var t=[],n={},r=0,i=this;void 0!==i;++r)t.push(i),i=i._parent;e=this._length=r;for(var r=e-1;r>=0;--r){var o=t[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;e>r;++r){var s=t[r].stack,a=n[s];if(void 0!==a&&a!==r){a>0&&(t[a-1]._parent=void 0,t[a-1]._length=1),t[r]._parent=void 0,t[r]._length=1;var u=r>0?t[r-1]:this;e-1>a?(u._parent=t[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,l=r-2;l>=0;--l)t[l]._length=c,c++;return}}}},O.prototype.attachExtraTrace=function(e){if(!e.__stackCleaned__){this.uncycle();for(var t=I(e),n=t.message,r=[t.stack],i=this;void 0!==i;)r.push(E(i.stack.split("\n"))),i=i._parent;_(r),w(r),N.notEnumerableProp(e,"stack",b(n,r)),N.notEnumerableProp(e,"__stackCleaned__",!0)}};var re=function(){var e=/^\s*at\s*/,t=function(e,t){return"string"==typeof e?e:void 0!==t.name&&void 0!==t.message?t.toString():S(t)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,z=e,H=t;var n=Error.captureStackTrace;return te=function(e){return q.test(e)},function(e,t){Error.stackTraceLimit+=6,n(e,t),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return z=/@/,H=t,Q=!0,function(e){e.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(H=function(e,t){return"string"==typeof e?e:"object"!=typeof t&&"function"!=typeof t||void 0===t.name||void 0===t.message?S(t):t.toString()},null):(z=e,H=t,function(e){Error.stackTraceLimit+=6;try{throw new Error}catch(t){e.stack=t.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(L=function(e){console.warn(e)},N.isNode&&t.stderr.isTTY?L=function(e,t){var n=t?"":"";console.warn(n+e+"\n")}:N.isNode||"string"!=typeof(new Error).stack||(L=function(e,t){console.warn("%c"+e,t?"color: darkorange":"color: red")}));var ie={warnings:K,longStackTraces:!1,cancellation:!1,monitoring:!1};return Y&&n.longStackTraces(),{longStackTraces:function(){return ie.longStackTraces},warnings:function(){return ie.warnings},cancellation:function(){return ie.cancellation},monitoring:function(){return ie.monitoring},propagateFromFunction:function(){return ee},boundValueFunction:function(){return p},checkForgottenReturns:g,setBounds:j,warn:m,deprecated:y,CapturedTrace:O,fireDomEvent:$,fireGlobalEvent:X}}},{"./errors":12,"./util":36}],10:[function(e,t,n){"use strict";t.exports=function(e){function t(){return this.value}function n(){throw this.reason}e.prototype["return"]=e.prototype.thenReturn=function(n){return n instanceof e&&n.suppressUnhandledRejections(),this._then(t,void 0,void 0,{value:n},void 0)},e.prototype["throw"]=e.prototype.thenThrow=function(e){return this._then(n,void 0,void 0,{reason:e},void 0)},e.prototype.catchThrow=function(e){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:e},void 0);var t=arguments[1],r=function(){throw t};return this.caught(e,r)},e.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof e&&n.suppressUnhandledRejections(),this._then(void 0,t,void 0,{value:n},void 0);var r=arguments[1];r instanceof e&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(e,t,n){"use strict";t.exports=function(e,t){function n(){return o(this)}function r(e,n){return i(e,n,t,t)}var i=e.reduce,o=e.all;e.prototype.each=function(e){return this.mapSeries(e)._then(n,void 0,void 0,this,void 0)},e.prototype.mapSeries=function(e){return i(this,e,t,t)},e.each=function(e,t){return r(e,t)._then(n,void 0,void 0,e,void 0)},e.mapSeries=r}},{}],12:[function(e,t,n){"use strict";function r(e,t){function n(r){return this instanceof n?(f(this,"message","string"==typeof r?r:t),f(this,"name",e),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(e){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",e),this.cause=e,this.isOperational=!0,void(e instanceof Error?(f(this,"message",e.message),f(this,"stack",e.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(e)}var o,s,a=e("./es5"),u=a.freeze,c=e("./util"),l=c.inherits,f=c.notEnumerableProp,h=r("Warning","warning"),p=r("CancellationError","cancellation error"),d=r("TimeoutError","timeout error"),v=r("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(g){o=r("TypeError","type error"),s=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),m=0;m1?e.cancelPromise._reject(t):e.cancelPromise._cancel(),e.cancelPromise=null,!0):!1}function s(){return u.call(this,this.promise._target()._settledValue())}function a(e){return o(this,e)?void 0:(f.e=e,f)}function u(e){var r=this.promise,u=this.handler;if(!this.called){this.called=!0;var c=this.isFinallyHandler()?u.call(r._boundValue()):u.call(r._boundValue(),e);if(void 0!==c){r._setReturnedNonUndefined();var h=n(c,r);if(h instanceof t){if(null!=this.cancelPromise){if(h.isCancelled()){var p=new l("late cancellation observer");return r._attachExtraTrace(p),f.e=p,f}h.isPending()&&h._attachCancellationCallback(new i(this))}return h._then(s,a,void 0,this,void 0)}}}return r.isRejected()?(o(this),f.e=e,f):(o(this),e)}var c=e("./util"),l=t.CancellationError,f=c.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},t.prototype._passThrough=function(e,t,n,i){return"function"!=typeof e?this.then():this._then(n,i,void 0,new r(this,t,e),void 0)},t.prototype.lastly=t.prototype["finally"]=function(e){return this._passThrough(e,0,u,u)},t.prototype.tap=function(e){return this._passThrough(e,1,u)},r}},{"./util":36}],16:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e,n,r){for(var o=0;o0&&"function"==typeof arguments[t]){e=arguments[t];var r}var i=[].slice.call(arguments);e&&i.pop();var r=new n(i).promise();return void 0!==e?r.spread(e):r}}},{"./util":36}],18:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e,t,n,r){this.constructor$(e),this._promise._captureStackTrace();var i=c();this._callback=null===i?t:i.bind(t),this._preservedValues=r===o?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=n>=1?[]:p,this._init$(void 0,-2)}function u(e,t,n,i){if("function"!=typeof t)return r("expecting a function but got "+l.classString(t));var o="object"==typeof n&&null!==n?n.concurrency:0;return o="number"==typeof o&&isFinite(o)&&o>=1?o:0,new a(e,t,o,i).promise()}var c=t._getDomain,l=e("./util"),f=l.tryCatch,h=l.errorObj,p=[];l.inherits(a,n),a.prototype._init=function(){},a.prototype._promiseFulfilled=function(e,n){var r=this._values,o=this.length(),a=this._preservedValues,u=this._limit;if(0>n){if(n=-1*n-1,r[n]=e,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return r[n]=e,this._queue.push(n),!1;null!==a&&(a[n]=e);var c=this._promise,l=this._callback,p=c._boundValue(); +!function(t){e.exports=t()}(function(){var e,i,o;return function s(e,t,n){function r(o,a){if(!t[o]){if(!e[o]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return r(n?n:t)},l,l.exports,s,e,t,n)}return t[o].exports}for(var i="function"==typeof _dereq_&&_dereq_,o=0;o0;){var t=e.shift();if("function"==typeof t){var n=e.shift(),r=e.shift();t.call(n,r)}else t._settlePromises()}},i.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},i.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},i.prototype._reset=function(){this._isTickUsed=!1},n.exports=i,n.exports.firstLineError=u},{"./queue":26,"./schedule":29,"./util":36}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){var i=!1,o=function(e,t){this._reject(t)},s=function(e,t){t.promiseRejectionQueued=!0,t.bindingPromise._then(o,o,null,this,e)},a=function(e,t){0===(50397184&this._bitField)&&this._resolveCallback(t.target)},u=function(e,t){t.promiseRejectionQueued||this._reject(e)};e.prototype.bind=function(o){i||(i=!0,e.prototype._propagateFrom=r.propagateFromFunction(),e.prototype._boundValue=r.boundValueFunction());var c=n(o),l=new e(t);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(c),c instanceof e){var h={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:c};f._then(t,s,void 0,l,h),c._then(a,u,void 0,l,h),l._setOnCancel(c)}else l._resolveCallback(f);return l},e.prototype._setBoundTo=function(e){void 0!==e?(this._bitField=2097152|this._bitField,this._boundTo=e):this._bitField=-2097153&this._bitField},e.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},e.bind=function(t,n){return e.resolve(n).bind(t)}}},{}],4:[function(e,t,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(e){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=e("./promise")();o.noConflict=r,t.exports=o},{"./promise":22}],5:[function(e,t,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}t.exports=function(t){function n(e,n){var r;if(null!=e&&(r=e[n]),"function"!=typeof r){var i="Object "+a.classString(e)+" has no method '"+a.toString(n)+"'";throw new t.TypeError(i)}return r}function r(e){var t=this.pop(),r=n(e,t);return r.apply(e,this)}function i(e){return e[this]}function o(e){var t=+this;return 0>t&&(t=Math.max(0,t+e.length)),e[t]}var s,a=e("./util"),u=a.canEvaluate;a.isIdentifier;t.prototype.call=function(e){var t=[].slice.call(arguments,1);return t.push(e),this._then(r,void 0,void 0,t,void 0)},t.prototype.get=function(e){var t,n="number"==typeof e;if(n)t=o;else if(u){var r=s(e);t=null!==r?r:i}else t=i;return this._then(t,void 0,void 0,e,void 0)}}},{"./util":36}],6:[function(e,t,n){"use strict";t.exports=function(t,n,r,i){var o=e("./util"),s=o.tryCatch,a=o.errorObj,u=t._async;t.prototype["break"]=t.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var e=this,t=e;e.isCancellable();){if(!e._cancelBy(t)){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}var n=e._cancellationParent;if(null==n||!n.isCancellable()){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}e._isFollowing()&&e._followee().cancel(),t=e,e=n}},t.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},t.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},t.prototype._cancelBy=function(e){return e===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},t.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},t.prototype._cancel=function(){this.isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},t.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},t.prototype._unsetOnCancel=function(){this._onCancelField=void 0},t.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},t.prototype._doInvokeOnCancel=function(e,t){if(o.isArray(e))for(var n=0;n=0?o[e]:void 0}var i=!1,o=[];return e.prototype._promiseCreated=function(){},e.prototype._pushContext=function(){},e.prototype._popContext=function(){return null},e._peekContext=e.prototype._peekContext=function(){},t.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},t.prototype._popContext=function(){if(void 0!==this._trace){var e=o.pop(),t=e._promiseCreated;return e._promiseCreated=null,t}return null},t.CapturedTrace=null,t.create=n,t.deactivateLongStackTraces=function(){},t.activateLongStackTraces=function(){var n=e.prototype._pushContext,o=e.prototype._popContext,s=e._peekContext,a=e.prototype._peekContext,u=e.prototype._promiseCreated;t.deactivateLongStackTraces=function(){e.prototype._pushContext=n,e.prototype._popContext=o,e._peekContext=s,e.prototype._peekContext=a,e.prototype._promiseCreated=u,i=!1},i=!0,e.prototype._pushContext=t.prototype._pushContext,e.prototype._popContext=t.prototype._popContext,e._peekContext=e.prototype._peekContext=r,e.prototype._promiseCreated=function(){var e=this._peekContext();e&&null==e._promiseCreated&&(e._promiseCreated=this)}},t}},{}],9:[function(e,n,r){"use strict";n.exports=function(n,r){function i(e,t){return{promise:t}}function o(){return!1}function s(e,t,n){var r=this;try{e(t,n,function(e){if("function"!=typeof e)throw new TypeError("onCancel must be a function, got: "+N.toString(e));r._attachCancellationCallback(e)})}catch(i){return i}}function a(e){if(!this.isCancellable())return this;var t=this._onCancel();void 0!==t?N.isArray(t)?t.push(e):this._setOnCancel([t,e]):this._setOnCancel(e)}function u(){return this._onCancelField}function c(e){this._onCancelField=e}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(e,t){if(0!==(1&t)){this._cancellationParent=e;var n=e._branchesRemainingToCancel;void 0===n&&(n=0),e._branchesRemainingToCancel=n+1}0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function h(e,t){0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function p(){var e=this._boundTo;return void 0!==e&&e instanceof n?e.isFulfilled()?e.value():void 0:e}function d(){this._trace=new O(this._peekContext())}function v(e,t){if(D(e)){var n=this._trace;if(void 0!==n&&t&&(n=n._parent),void 0!==n)n.attachExtraTrace(e);else if(!e.__stackCleaned__){var r=I(e);N.notEnumerableProp(e,"stack",r.message+"\n"+r.stack.join("\n")),N.notEnumerableProp(e,"__stackCleaned__",!0)}}}function g(e,t,n,r,i){if(void 0===e&&null!==t&&V){if(void 0!==i&&i._returnedNonUndefined())return;var o=r._bitField;if(0===(65535&o))return;n&&(n+=" ");var s="a promise was created in a "+n+"handler but was not returned from it";r._warn(s,!0,t)}}function y(e,t){var n=e+" is deprecated and will be removed in a future version.";return t&&(n+=" Use "+t+" instead."),m(n)}function m(e,t,r){if(ie.warnings){var i,o=new P(e);if(t)r._attachExtraTrace(o);else if(ie.longStackTraces&&(i=n._peekContext()))i.attachExtraTrace(o);else{var s=I(o);o.stack=s.message+"\n"+s.stack.join("\n")}Z("warning",o)||k(o,"",!0)}}function b(e,t){for(var n=0;n=0;--a)if(r[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=r[a];if(t[i]!==u)break;t.pop(),i--}t=r}}function E(e){for(var t=[],n=0;n0&&(t=t.slice(n)),t}function I(e){var t=e.stack,n=e.toString();return t="string"==typeof t&&t.length>0?x(e):[" (No stack trace)"],{message:n,stack:E(t)}}function k(e,t,n){if("undefined"!=typeof console){var r;if(N.isObject(e)){var i=e.stack;r=t+H(i,e)}else r=t+String(e);"function"==typeof L?L(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function C(e,t,n,r){var i=!1;try{"function"==typeof t&&(i=!0,"rejectionHandled"===e?t(r):t(n,r))}catch(o){F.throwLater(o)}"unhandledRejection"===e?Z(e,n,r)||i||k(n,"Unhandled rejection "):Z(e,r)}function S(e){var t;if("function"==typeof e)t="[function "+(e.name||"anonymous")+"]";else{t=e&&"function"==typeof e.toString?e.toString():N.toString(e);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(t))try{var r=JSON.stringify(e);t=r}catch(i){}0===t.length&&(t="(empty array)")}return"(<"+T(t)+">, no stack trace)"}function T(e){var t=41;return e.lengths||0>a||!n||!r||n!==r||s>=a||(te=function(e){if(q.test(e))return!0;var t=B(e);return!!(t&&t.fileName===n&&s<=t.line&&t.line<=a)})}}function O(e){this._parent=e,this._promisesCreated=0;var t=this._length=1+(void 0===e?0:e._length);re(this,O),t>32&&this.uncycle()}var A,R,L,M=n._getDomain,F=n._async,P=e("./errors").Warning,N=e("./util"),D=N.canAttachTrace,q=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,z=null,H=null,Q=!1,W=!(0==N.env("BLUEBIRD_DEBUG")),K=!(0==N.env("BLUEBIRD_WARNINGS")||!W&&!N.env("BLUEBIRD_WARNINGS")),Y=!(0==N.env("BLUEBIRD_LONG_STACK_TRACES")||!W&&!N.env("BLUEBIRD_LONG_STACK_TRACES")),V=0!=N.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(K||!!N.env("BLUEBIRD_W_FORGOTTEN_RETURN"));n.prototype.suppressUnhandledRejections=function(){var e=this._target();e._bitField=-1048577&e._bitField|524288},n.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),F.invokeLater(this._notifyUnhandledRejection,this,void 0))},n.prototype._notifyUnhandledRejectionIsHandled=function(){C("rejectionHandled",A,void 0,this)},n.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},n.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},n.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var e=this._settledValue();this._setUnhandledRejectionIsNotified(),C("unhandledRejection",R,e,this)}},n.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},n.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},n.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},n.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},n.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},n.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},n.prototype._warn=function(e,t,n){return m(e,t,n||this)},n.onPossiblyUnhandledRejection=function(e){var t=M();R="function"==typeof e?null===t?e:t.bind(e):void 0},n.onUnhandledRejectionHandled=function(e){var t=M();A="function"==typeof e?null===t?e:t.bind(e):void 0};var G=function(){};n.longStackTraces=function(){if(F.haveItemsQueued()&&!ie.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ie.longStackTraces&&U()){var e=n.prototype._captureStackTrace,t=n.prototype._attachExtraTrace;ie.longStackTraces=!0,G=function(){if(F.haveItemsQueued()&&!ie.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");n.prototype._captureStackTrace=e,n.prototype._attachExtraTrace=t,r.deactivateLongStackTraces(),F.enableTrampoline(),ie.longStackTraces=!1},n.prototype._captureStackTrace=d,n.prototype._attachExtraTrace=v,r.activateLongStackTraces(),F.disableTrampolineIfNecessary()}},n.hasLongStackTraces=function(){return ie.longStackTraces&&U()};var $=function(){try{var e=document.createEvent("CustomEvent");return e.initCustomEvent("testingtheevent",!1,!0,{}),N.global.dispatchEvent(e),function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e.toLowerCase(),!1,!0,t),!N.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),X=function(){return N.isNode?function(){return t.emit.apply(t,arguments)}:N.global?function(e){var t="on"+e.toLowerCase(),n=N.global[t];return n?(n.apply(N.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),J={promiseCreated:i,promiseFulfilled:i,promiseRejected:i,promiseResolved:i,promiseCancelled:i,promiseChained:function(e,t,n){return{promise:t,child:n}},warning:function(e,t){return{warning:t}},unhandledRejection:function(e,t,n){return{reason:t,promise:n}},rejectionHandled:i},Z=function(e){var t=!1;try{t=X.apply(null,arguments)}catch(n){F.throwLater(n),t=!0}var r=!1;try{r=$(e,J[e].apply(null,arguments))}catch(n){F.throwLater(n),r=!0}return r||t};n.config=function(e){if(e=Object(e),"longStackTraces"in e&&(e.longStackTraces?n.longStackTraces():!e.longStackTraces&&n.hasLongStackTraces()&&G()),"warnings"in e){var t=e.warnings;ie.warnings=!!t,V=ie.warnings,N.isObject(t)&&"wForgottenReturn"in t&&(V=!!t.wForgottenReturn)}if("cancellation"in e&&e.cancellation&&!ie.cancellation){if(F.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");n.prototype._clearCancellationData=l,n.prototype._propagateFrom=f,n.prototype._onCancel=u,n.prototype._setOnCancel=c,n.prototype._attachCancellationCallback=a,n.prototype._execute=s,ee=f,ie.cancellation=!0}"monitoring"in e&&(e.monitoring&&!ie.monitoring?(ie.monitoring=!0,n.prototype._fireEvent=Z):!e.monitoring&&ie.monitoring&&(ie.monitoring=!1,n.prototype._fireEvent=o))},n.prototype._fireEvent=o,n.prototype._execute=function(e,t,n){try{e(t,n)}catch(r){return r}},n.prototype._onCancel=function(){},n.prototype._setOnCancel=function(e){},n.prototype._attachCancellationCallback=function(e){},n.prototype._captureStackTrace=function(){},n.prototype._attachExtraTrace=function(){},n.prototype._clearCancellationData=function(){},n.prototype._propagateFrom=function(e,t){};var ee=h,te=function(){return!1},ne=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;N.inherits(O,Error),r.CapturedTrace=O,O.prototype.uncycle=function(){var e=this._length;if(!(2>e)){for(var t=[],n={},r=0,i=this;void 0!==i;++r)t.push(i),i=i._parent;e=this._length=r;for(var r=e-1;r>=0;--r){var o=t[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;e>r;++r){var s=t[r].stack,a=n[s];if(void 0!==a&&a!==r){a>0&&(t[a-1]._parent=void 0,t[a-1]._length=1),t[r]._parent=void 0,t[r]._length=1;var u=r>0?t[r-1]:this;e-1>a?(u._parent=t[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,l=r-2;l>=0;--l)t[l]._length=c,c++;return}}}},O.prototype.attachExtraTrace=function(e){if(!e.__stackCleaned__){this.uncycle();for(var t=I(e),n=t.message,r=[t.stack],i=this;void 0!==i;)r.push(E(i.stack.split("\n"))),i=i._parent;_(r),w(r),N.notEnumerableProp(e,"stack",b(n,r)),N.notEnumerableProp(e,"__stackCleaned__",!0)}};var re=function(){var e=/^\s*at\s*/,t=function(e,t){return"string"==typeof e?e:void 0!==t.name&&void 0!==t.message?t.toString():S(t)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,z=e,H=t;var n=Error.captureStackTrace;return te=function(e){return q.test(e)},function(e,t){Error.stackTraceLimit+=6,n(e,t),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return z=/@/,H=t,Q=!0,function(e){e.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(H=function(e,t){return"string"==typeof e?e:"object"!=typeof t&&"function"!=typeof t||void 0===t.name||void 0===t.message?S(t):t.toString()},null):(z=e,H=t,function(e){Error.stackTraceLimit+=6;try{throw new Error}catch(t){e.stack=t.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(L=function(e){console.warn(e)},N.isNode&&t.stderr.isTTY?L=function(e,t){var n=t?"":"";console.warn(n+e+"\n")}:N.isNode||"string"!=typeof(new Error).stack||(L=function(e,t){console.warn("%c"+e,t?"color: darkorange":"color: red")}));var ie={warnings:K,longStackTraces:!1,cancellation:!1,monitoring:!1};return Y&&n.longStackTraces(),{longStackTraces:function(){return ie.longStackTraces},warnings:function(){return ie.warnings},cancellation:function(){return ie.cancellation},monitoring:function(){return ie.monitoring},propagateFromFunction:function(){return ee},boundValueFunction:function(){return p},checkForgottenReturns:g,setBounds:j,warn:m,deprecated:y,CapturedTrace:O,fireDomEvent:$,fireGlobalEvent:X}}},{"./errors":12,"./util":36}],10:[function(e,t,n){"use strict";t.exports=function(e){function t(){return this.value}function n(){throw this.reason}e.prototype["return"]=e.prototype.thenReturn=function(n){return n instanceof e&&n.suppressUnhandledRejections(),this._then(t,void 0,void 0,{value:n},void 0)},e.prototype["throw"]=e.prototype.thenThrow=function(e){return this._then(n,void 0,void 0,{reason:e},void 0)},e.prototype.catchThrow=function(e){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:e},void 0);var t=arguments[1],r=function(){throw t};return this.caught(e,r)},e.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof e&&n.suppressUnhandledRejections(),this._then(void 0,t,void 0,{value:n},void 0);var r=arguments[1];r instanceof e&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(e,t,n){"use strict";t.exports=function(e,t){function n(){return o(this)}function r(e,n){return i(e,n,t,t)}var i=e.reduce,o=e.all;e.prototype.each=function(e){return this.mapSeries(e)._then(n,void 0,void 0,this,void 0)},e.prototype.mapSeries=function(e){return i(this,e,t,t)},e.each=function(e,t){return r(e,t)._then(n,void 0,void 0,e,void 0)},e.mapSeries=r}},{}],12:[function(e,t,n){"use strict";function r(e,t){function n(r){return this instanceof n?(f(this,"message","string"==typeof r?r:t),f(this,"name",e),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(e){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",e),this.cause=e,this.isOperational=!0,void(e instanceof Error?(f(this,"message",e.message),f(this,"stack",e.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(e)}var o,s,a=e("./es5"),u=a.freeze,c=e("./util"),l=c.inherits,f=c.notEnumerableProp,h=r("Warning","warning"),p=r("CancellationError","cancellation error"),d=r("TimeoutError","timeout error"),v=r("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(g){o=r("TypeError","type error"),s=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),m=0;m1?e.cancelPromise._reject(t):e.cancelPromise._cancel(),e.cancelPromise=null,!0):!1}function s(){return u.call(this,this.promise._target()._settledValue())}function a(e){return o(this,e)?void 0:(f.e=e,f)}function u(e){var r=this.promise,u=this.handler;if(!this.called){this.called=!0;var c=this.isFinallyHandler()?u.call(r._boundValue()):u.call(r._boundValue(),e);if(void 0!==c){r._setReturnedNonUndefined();var h=n(c,r);if(h instanceof t){if(null!=this.cancelPromise){if(h.isCancelled()){var p=new l("late cancellation observer");return r._attachExtraTrace(p),f.e=p,f}h.isPending()&&h._attachCancellationCallback(new i(this))}return h._then(s,a,void 0,this,void 0)}}}return r.isRejected()?(o(this),f.e=e,f):(o(this),e)}var c=e("./util"),l=t.CancellationError,f=c.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},t.prototype._passThrough=function(e,t,n,i){return"function"!=typeof e?this.then():this._then(n,i,void 0,new r(this,t,e),void 0)},t.prototype.lastly=t.prototype["finally"]=function(e){return this._passThrough(e,0,u,u)},t.prototype.tap=function(e){return this._passThrough(e,1,u)},r}},{"./util":36}],16:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e,n,r){for(var o=0;o0&&"function"==typeof arguments[t]){e=arguments[t];var r}var i=[].slice.call(arguments);e&&i.pop();var r=new n(i).promise();return void 0!==e?r.spread(e):r}}},{"./util":36}],18:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e,t,n,r){this.constructor$(e),this._promise._captureStackTrace();var i=c();this._callback=null===i?t:i.bind(t),this._preservedValues=r===o?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=n>=1?[]:p,this._init$(void 0,-2)}function u(e,t,n,i){if("function"!=typeof t)return r("expecting a function but got "+l.classString(t));var o="object"==typeof n&&null!==n?n.concurrency:0;return o="number"==typeof o&&isFinite(o)&&o>=1?o:0,new a(e,t,o,i).promise()}var c=t._getDomain,l=e("./util"),f=l.tryCatch,h=l.errorObj,p=[];l.inherits(a,n),a.prototype._init=function(){},a.prototype._promiseFulfilled=function(e,n){var r=this._values,o=this.length(),a=this._preservedValues,u=this._limit;if(0>n){if(n=-1*n-1,r[n]=e,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return r[n]=e,this._queue.push(n),!1;null!==a&&(a[n]=e);var c=this._promise,l=this._callback,p=c._boundValue(); c._pushContext();var d=f(l).call(p,e,n,o),v=c._popContext();if(s.checkForgottenReturns(d,v,null!==a?"Promise.filter":"Promise.map",c),d===h)return this._reject(d.e),!0;var g=i(d,this._promise);if(g instanceof t){g=g._target();var y=g._bitField;if(0===(50397184&y))return u>=1&&this._inFlight++,r[n]=g,g._proxy(this,-1*(n+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(g._reason()),!0):(this._cancel(),!0);d=g._value()}r[n]=d}var m=++this._totalResolved;return m>=o?(null!==a?this._filter(r,a):this._resolve(r),!0):!1},a.prototype._drainQueue=function(){for(var e=this._queue,t=this._limit,n=this._values;e.length>0&&this._inFlighto;++o)e[o]&&(r[i++]=t[o]);r.length=i,this._resolve(r)},a.prototype.preservedValues=function(){return this._preservedValues},t.prototype.map=function(e,t){return u(this,e,t,null)},t.map=function(e,t,n,r){return u(e,t,n,r)}}},{"./util":36}],19:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o){var s=e("./util"),a=s.tryCatch;t.method=function(e){if("function"!=typeof e)throw new t.TypeError("expecting a function but got "+s.classString(e));return function(){var r=new t(n);r._captureStackTrace(),r._pushContext();var i=a(e).apply(this,arguments),s=r._popContext();return o.checkForgottenReturns(i,s,"Promise.method",r),r._resolveFromSyncValue(i),r}},t.attempt=t["try"]=function(e){if("function"!=typeof e)return i("expecting a function but got "+s.classString(e));var r=new t(n);r._captureStackTrace(),r._pushContext();var u;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var c=arguments[1],l=arguments[2];u=s.isArray(c)?a(e).apply(l,c):a(e).call(l,c)}else u=a(e)();var f=r._popContext();return o.checkForgottenReturns(u,f,"Promise.try",r),r._resolveFromSyncValue(u),r},t.prototype._resolveFromSyncValue=function(e){e===s.errorObj?this._rejectCallback(e.e,!1):this._resolveCallback(e,!0)}}},{"./util":36}],20:[function(e,t,n){"use strict";function r(e){return e instanceof Error&&l.getPrototypeOf(e)===Error.prototype}function i(e){var t;if(r(e)){t=new c(e),t.name=e.name,t.message=e.message,t.stack=e.stack;for(var n=l.keys(e),i=0;i1){var n,r=new Array(t-1),i=0;for(n=0;t-1>n;++n){var o=arguments[n];if(!p.isObject(o))return f("expecting an object but got "+p.classString(o));r[i++]=o}return r.length=i,e=arguments[n],this.then(void 0,U(r,e,this))}return this.then(void 0,e)},i.prototype.reflect=function(){return this._then(l,l,void 0,this,void 0)},i.prototype.then=function(e,t){if(S.warnings()&&arguments.length>0&&"function"!=typeof e&&"function"!=typeof t){var n=".then() only accepts functions but was passed: "+p.classString(e);arguments.length>1&&(n+=", "+p.classString(t)),this._warn(n)}return this._then(e,t,void 0,void 0,void 0)},i.prototype.done=function(e,t){var n=this._then(e,t,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(e){return"function"!=typeof e?f("expecting a function but got "+p.classString(e)):this.all()._then(e,void 0,void 0,_,void 0)},i.prototype.toJSON=function(){var e={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(e.fulfillmentValue=this.value(),e.isFulfilled=!0):this.isRejected()&&(e.rejectionReason=this.reason(),e.isRejected=!0),e},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new I(this).promise()},i.prototype.error=function(e){return this.caught(p.originatesFromRejection,e)},i.is=function(e){return e instanceof i},i.fromNode=i.fromCallback=function(e){var t=new i(w);t._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=O(e)(B(t,n));return r===j&&t._rejectCallback(r.e,!0),t._isFateSealed()||t._setAsyncGuaranteed(),t},i.all=function(e){return new I(e).promise()},i.cast=function(e){var t=x(e);return t instanceof i||(t=new i(w),t._captureStackTrace(),t._setFulfilled(),t._rejectionHandler0=e),t},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(e){var t=new i(w);return t._captureStackTrace(),t._rejectCallback(e,!0),t},i.setScheduler=function(e){if("function"!=typeof e)throw new m("expecting a function but got "+p.classString(e));var t=g._schedule;return g._schedule=e,t},i.prototype._then=function(e,t,n,r,o){var s=void 0!==o,a=s?o:new i(w),c=this._target(),l=c._bitField;s||(a._propagateFrom(this,3),a._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&l)?this._boundValue():c===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,a));var f=u();if(0!==(50397184&l)){var h,p,d=c._settlePromiseCtx;0!==(33554432&l)?(p=c._rejectionHandler0,h=e):0!==(16777216&l)?(p=c._fulfillmentHandler0,h=t,c._unsetRejectionIsUnhandled()):(d=c._settlePromiseLateCancellationObserver,p=new b("late cancellation observer"),c._attachExtraTrace(p),h=t),g.invoke(d,c,{handler:null===f?h:"function"==typeof h&&f.bind(h),promise:a,receiver:r,value:p})}else c._addCallbacks(e,t,a,r,f);return a},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(e){this._bitField=-65536&this._bitField|65535&e},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setAsyncGuaranteed=function(){this._bitField=134217728|this._bitField},i.prototype._receiverAt=function(e){var t=0===e?this._receiver0:this[4*e-4+3];if(t!==h)return void 0===t&&this._isBound()?this._boundValue():t},i.prototype._promiseAt=function(e){return this[4*e-4+2]},i.prototype._fulfillmentHandlerAt=function(e){return this[4*e-4+0]},i.prototype._rejectionHandlerAt=function(e){return this[4*e-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(e){var t=(e._bitField,e._fulfillmentHandler0),n=e._rejectionHandler0,r=e._promise0,i=e._receiverAt(0);void 0===i&&(i=h),this._addCallbacks(t,n,r,i,null)},i.prototype._migrateCallbackAt=function(e,t){var n=e._fulfillmentHandlerAt(t),r=e._rejectionHandlerAt(t),i=e._promiseAt(t),o=e._receiverAt(t);void 0===o&&(o=h),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(e,t,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof e&&(this._fulfillmentHandler0=null===i?e:i.bind(e)),"function"==typeof t&&(this._rejectionHandler0=null===i?t:i.bind(t));else{var s=4*o-4;this[s+2]=n,this[s+3]=r,"function"==typeof e&&(this[s+0]=null===i?e:i.bind(e)),"function"==typeof t&&(this[s+1]=null===i?t:i.bind(t))}return this._setLength(o+1),o},i.prototype._proxy=function(e,t){this._addCallbacks(void 0,void 0,t,e,null)},i.prototype._resolveCallback=function(e,t){if(0===(117506048&this._bitField)){if(e===this)return this._rejectCallback(c(),!1);var n=x(e,this);if(!(n instanceof i))return this._fulfill(e);t&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(c());var o=r._bitField;if(0===(50397184&o)){var s=this._length();s>0&&r._migrateCallback0(this);for(var a=1;s>a;++a)r._migrateCallbackAt(this,a);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var u=new b("late cancellation observer");r._attachExtraTrace(u),this._reject(u)}}},i.prototype._rejectCallback=function(e,t,n){var r=p.ensureErrorObject(e),i=r===e;if(!i&&!n&&S.warnings()){var o="a promise was rejected with a non-error: "+p.classString(e);this._warn(o,!0)}this._attachExtraTrace(r,t?i:!1),this._reject(e)},i.prototype._resolveFromExecutor=function(e){var t=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(e,function(e){t._resolveCallback(e)},function(e){t._rejectCallback(e,n)});n=!1,this._popContext(),void 0!==r&&t._rejectCallback(r,!0)},i.prototype._settlePromiseFromHandler=function(e,t,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;t===_?n&&"number"==typeof n.length?o=O(e).apply(this._boundValue(),n):(o=j,o.e=new m("cannot .spread() a non-array: "+p.classString(n))):o=O(e).call(t,n);var s=r._popContext();i=r._bitField,0===(65536&i)&&(o===E?r._reject(n):o===j?r._rejectCallback(o.e,!1):(S.checkForgottenReturns(o,s,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var e=this;e._isFollowing();)e=e._followee();return e},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(e){this._rejectionHandler0=e},i.prototype._settlePromise=function(e,t,r,o){var s=e instanceof i,a=this._bitField,u=0!==(134217728&a);0!==(65536&a)?(s&&e._invokeInternalOnCancel(),r instanceof T&&r.isFinallyHandler()?(r.cancelPromise=e,O(t).call(r,o)===j&&e._reject(j.e)):t===l?e._fulfill(l.call(r)):r instanceof n?r._promiseCancelled(e):s||e instanceof I?e._cancel():r.cancel()):"function"==typeof t?s?(u&&e._setAsyncGuaranteed(),this._settlePromiseFromHandler(t,r,o,e)):t.call(r,o,e):r instanceof n?r._isResolved()||(0!==(33554432&a)?r._promiseFulfilled(o,e):r._promiseRejected(o,e)):s&&(u&&e._setAsyncGuaranteed(),0!==(33554432&a)?e._fulfill(o):e._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(e){var t=e.handler,n=e.promise,r=e.receiver,o=e.value;"function"==typeof t?n instanceof i?this._settlePromiseFromHandler(t,r,o,n):t.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(e){this._settlePromise(e.promise,e.handler,e.receiver,e.value)},i.prototype._settlePromise0=function(e,t,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,e,i,t)},i.prototype._clearCallbackDataAtIndex=function(e){var t=4*e-4;this[t+2]=this[t+3]=this[t+0]=this[t+1]=void 0},i.prototype._fulfill=function(e){var t=this._bitField;if(!((117506048&t)>>>16)){if(e===this){var n=c();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=e,(65535&t)>0&&(0!==(134217728&t)?this._settlePromises():g.settlePromises(this))}},i.prototype._reject=function(e){var t=this._bitField;if(!((117506048&t)>>>16))return this._setRejected(),this._fulfillmentHandler0=e,this._isFinal()?g.fatalError(e,p.isNode):void((65535&t)>0?g.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(e,t){for(var n=1;e>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,t)}},i.prototype._rejectPromises=function(e,t){for(var n=1;e>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,t)}},i.prototype._settlePromises=function(){var e=this._bitField,t=65535&e;if(t>0){if(0!==(16842752&e)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,e),this._rejectPromises(t,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,e),this._fulfillPromises(t,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var e=this._bitField;return 0!==(33554432&e)?this._rejectionHandler0:0!==(16777216&e)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){S.deprecated("Promise.defer","new Promise");var e=new i(w);return{promise:e,resolve:o,reject:s}},p.notEnumerableProp(i,"_makeSelfResolutionError",c),e("./method")(i,w,x,f,S),e("./bind")(i,w,x,S),e("./cancel")(i,I,f,S),e("./direct_resolve")(i),e("./synchronous_inspection")(i),e("./join")(i,I,x,w,S),i.Promise=i,e("./map.js")(i,I,f,x,w,S),e("./using.js")(i,f,x,C,w,S),e("./timers.js")(i,w,S),e("./generators.js")(i,f,w,x,n,S),e("./nodeify.js")(i),e("./call_get.js")(i),e("./props.js")(i,I,x,f),e("./race.js")(i,w,x,f),e("./reduce.js")(i,I,f,x,w,S),e("./settle.js")(i,I,S),e("./some.js")(i,I,f),e("./promisify.js")(i,w),e("./any.js")(i),e("./each.js")(i,w),e("./filter.js")(i,w),p.toFastProperties(i),p.toFastProperties(i.prototype),a({a:1}),a({b:2}),a({c:3}),a(1),a(function(){}),a(void 0),a(!1),a(new i(w)),S.setBounds(v.firstLineError,p.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o){function s(e){switch(e){case-2:return[];case-3:return{}}}function a(e){var r=this._promise=new t(n);e instanceof t&&r._propagateFrom(e,3),r._setOnCancel(this),this._values=e,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var u=e("./util");u.isArray;return u.inherits(a,o),a.prototype.length=function(){return this._length},a.prototype.promise=function(){return this._promise},a.prototype._init=function c(e,n){var o=r(this._values,this._promise);if(o instanceof t){o=o._target();var a=o._bitField;if(this._values=o,0===(50397184&a))return this._promise._setAsyncGuaranteed(),o._then(c,this._reject,void 0,this,n);if(0===(33554432&a))return 0!==(16777216&a)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=u.asArray(o),null===o){var l=i("expecting an array or an iterable object but got "+u.classString(o)).reason();return void this._promise._rejectCallback(l,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(s(n))):void this._iterate(o)},a.prototype._iterate=function(e){var n=this.getActualLength(e.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,s=null,a=0;n>a;++a){var u=r(e[a],i);u instanceof t?(u=u._target(),s=u._bitField):s=null,o?null!==s&&u.suppressUnhandledRejections():null!==s?0===(50397184&s)?(u._proxy(this,a),this._values[a]=u):o=0!==(33554432&s)?this._promiseFulfilled(u._value(),a):0!==(16777216&s)?this._promiseRejected(u._reason(),a):this._promiseCancelled(a):o=this._promiseFulfilled(u,a)}o||i._setAsyncGuaranteed()},a.prototype._isResolved=function(){return null===this._values},a.prototype._resolve=function(e){this._values=null,this._promise._fulfill(e)},a.prototype._cancel=function(){!this._isResolved()&&this._promise.isCancellable()&&(this._values=null,this._promise._cancel())},a.prototype._reject=function(e){this._values=null,this._promise._rejectCallback(e,!1)},a.prototype._promiseFulfilled=function(e,t){this._values[t]=e;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},a.prototype._promiseCancelled=function(){return this._cancel(),!0},a.prototype._promiseRejected=function(e){return this._totalResolved++,this._reject(e),!0},a.prototype._resultCancelled=function(){if(!this._isResolved()){var e=this._values;if(this._cancel(),e instanceof t)e.cancel();else for(var n=0;nu;u+=2){var l=s[u],f=s[u+1],d=l+t;if(r===k)e[d]=k(l,h,l,f,t,i);else{var v=r(f,function(){return k(l,h,l,f,t,i)});p.notEnumerableProp(v,"__isPromisified__",!0),e[d]=v}}return p.toFastProperties(e),e}function l(e,t,n){return k(e,t,void 0,e,null,n)}var f,h={},p=e("./util"),d=e("./nodeback"),v=p.withAppended,g=p.maybeWrapAsError,y=p.canEvaluate,m=e("./errors").TypeError,b="Async",w={__isPromisified__:!0},_=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],E=new RegExp("^(?:"+_.join("|")+")$"),x=function(e){return p.isIdentifier(e)&&"_"!==e.charAt(0)&&"constructor"!==e},I=function(e){return e.replace(/([$])/,"\\$")},k=y?f:u;t.promisify=function(e,t){if("function"!=typeof e)throw new m("expecting a function but got "+p.classString(e));if(i(e))return e;t=Object(t);var n=void 0===t.context?h:t.context,o=!!t.multiArgs,s=l(e,n,o);return p.copyDescriptors(e,s,r),s},t.promisifyAll=function(e,t){if("function"!=typeof e&&"object"!=typeof e)throw new m("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");t=Object(t);var n=!!t.multiArgs,r=t.suffix;"string"!=typeof r&&(r=b);var i=t.filter;"function"!=typeof i&&(i=x);var o=t.promisifier;if("function"!=typeof o&&(o=k),!p.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var s=p.inheritedDataKeys(e),a=0;ao;++o){var s=r[o];t[o]=e[s],t[o+i]=s}}this.constructor$(t),this._isMap=n,this._init$(void 0,-3)}function s(e){var n,s=r(e);return c(s)?(n=s instanceof t?s._then(t.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof t&&n._propagateFrom(s,2),n):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var a,u=e("./util"),c=u.isObject,l=e("./es5");"function"==typeof Map&&(a=Map);var f=function(){function e(e,r){this[t]=e,this[t+n]=r,t++}var t=0,n=0;return function(r){n=r.size,t=0;var i=new Array(2*r.size);return r.forEach(e,i),i}}(),h=function(e){for(var t=new a,n=e.length/2|0,r=0;n>r;++r){var i=e[n+r],o=e[r];t.set(i,o)}return t};u.inherits(o,n),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(e,t){this._values[t]=e;var n=++this._totalResolved;if(n>=this._length){var r;if(this._isMap)r=h(this._values);else{r={};for(var i=this.length(),o=0,s=this.length();s>o;++o)r[this._values[o+i]]=this._values[o]}return this._resolve(r),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(e){return e>>1},t.prototype.props=function(){return s(this)},t.props=function(e){return s(e)}}},{"./es5":13,"./util":36}],26:[function(e,t,n){"use strict";function r(e,t,n,r,i){for(var o=0;i>o;++o)n[o+r]=e[o+t],e[o+t]=void 0}function i(e){this._capacity=e,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(e){return this._capacityh;++h){var d=e[h];(void 0!==d||h in e)&&t.cast(d)._then(l,f,void 0,c,null)}return c}var s=e("./util"),a=function(e){return e.then(function(t){return o(t,e)})};t.race=function(e){return o(e,void 0)},t.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e,n,r,i){this.constructor$(e);var s=h();this._fn=null===s?n:s.bind(n),void 0!==r&&(r=t.resolve(r),r._attachCancellationCallback(this)),this._initialValue=r,this._currentCancellable=null,this._eachValues=i===o?[]:void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function u(e,t){this.isFulfilled()?t._resolve(e):t._reject(e)}function c(e,t,n,i){if("function"!=typeof t)return r("expecting a function but got "+p.classString(t));var o=new a(e,t,n,i);return o.promise()}function l(e){this.accum=e,this.array._gotAccum(e);var n=i(this.value,this.array._promise);return n instanceof t?(this.array._currentCancellable=n,n._then(f,void 0,void 0,this,void 0)):f.call(this,n)}function f(e){var n=this.array,r=n._promise,i=d(n._fn);r._pushContext();var o;o=void 0!==n._eachValues?i.call(r._boundValue(),e,this.index,this.length):i.call(r._boundValue(),this.accum,e,this.index,this.length),o instanceof t&&(n._currentCancellable=o);var a=r._popContext();return s.checkForgottenReturns(o,a,void 0!==n._eachValues?"Promise.each":"Promise.reduce",r),o}var h=t._getDomain,p=e("./util"),d=p.tryCatch;p.inherits(a,n),a.prototype._gotAccum=function(e){void 0!==this._eachValues&&e!==o&&this._eachValues.push(e)},a.prototype._eachComplete=function(e){return this._eachValues.push(e),this._eachValues},a.prototype._init=function(){},a.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},a.prototype.shouldCopyValues=function(){return!1},a.prototype._resolve=function(e){this._promise._resolveCallback(e),this._values=null},a.prototype._resultCancelled=function(e){return e===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof t&&this._currentCancellable.cancel(),this._initialValue instanceof t&&this._initialValue.cancel()))},a.prototype._iterate=function(e){this._values=e;var n,r,i=e.length;if(void 0!==this._initialValue?(n=this._initialValue,r=0):(n=t.resolve(e[0]),r=1),this._currentCancellable=n,!n.isRejected())for(;i>r;++r){var o={accum:null,value:e[r],index:r,length:i,array:this};n=n._then(l,void 0,void 0,o,void 0)}void 0!==this._eachValues&&(n=n._then(this._eachComplete,void 0,void 0,this,void 0)),n._then(u,u,void 0,n,this)},t.prototype.reduce=function(e,t){return c(this,e,t,null)},t.reduce=function(e,t,n,r){return c(e,t,n,r)}}},{"./util":36}],29:[function(e,i,o){"use strict";var s,a=e("./util"),u=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")};if(a.isNode&&"undefined"==typeof MutationObserver){var c=n.setImmediate,l=t.nextTick;s=a.isRecentNode?function(e){c.call(n,e)}:function(e){l.call(t,e)}}else s="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?"undefined"!=typeof r?function(e){r(e)}:"undefined"!=typeof setTimeout?function(e){setTimeout(e,0)}:u:function(){var e=document.createElement("div"),t={attributes:!0},n=!1,r=document.createElement("div"),i=new MutationObserver(function(){e.classList.toggle("foo"),n=!1});i.observe(r,t);var o=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(e,t),o()}}();i.exports=s},{"./util":36}],30:[function(e,t,n){"use strict";t.exports=function(t,n,r){function i(e){this.constructor$(e)}var o=t.PromiseInspection,s=e("./util");s.inherits(i,n),i.prototype._promiseResolved=function(e,t){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(e,t){var n=new o;return n._bitField=33554432,n._settledValueField=e,this._promiseResolved(t,n)},i.prototype._promiseRejected=function(e,t){var n=new o;return n._bitField=16777216,n._settledValueField=e,this._promiseResolved(t,n)},t.settle=function(e){return r.deprecated(".settle()",".reflect()"),new i(e).promise()},t.prototype.settle=function(){return t.settle(this)}}},{"./util":36}],31:[function(e,t,n){"use strict";t.exports=function(t,n,r){function i(e){this.constructor$(e),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(e,t){if((0|t)!==t||0>t)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new i(e),o=n.promise();return n.setHowMany(t),n.init(),o}var s=e("./util"),a=e("./errors").RangeError,u=e("./errors").AggregateError,c=s.isArray,l={};s.inherits(i,n),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var e=c(this._values);!this._isResolved()&&e&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(e){this._howMany=e},i.prototype._promiseFulfilled=function(e){return this._addFulfilled(e),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(e){return this._addRejected(e),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof t||null==this._values?this._cancel():(this._addRejected(l),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var e=new u,t=this.length();t0?this._reject(e):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(e){this._values.push(e)},i.prototype._addFulfilled=function(e){this._values[this._totalResolved++]=e},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(e){var t="Input array must contain at least "+this._howMany+" items but contains only "+e+" items";return new a(t)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},t.some=function(e,t){return o(e,t)},t.prototype.some=function(e){return o(this,e)},t._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(e,t,n){"use strict";t.exports=function(e){function t(e){void 0!==e?(e=e._target(),this._bitField=e._bitField,this._settledValueField=e._isFateSealed()?e._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}t.prototype._settledValue=function(){return this._settledValueField};var n=t.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n"); -return this._settledValue()},r=t.prototype.error=t.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=t.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=t.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=t.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=t.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};t.prototype.isCancelled=e.prototype._isCancelled=function(){return 65536===(65536&this._bitField)},e.prototype.isCancelled=function(){return this._target()._isCancelled()},e.prototype.isPending=function(){return s.call(this._target())},e.prototype.isRejected=function(){return o.call(this._target())},e.prototype.isFulfilled=function(){return i.call(this._target())},e.prototype.isResolved=function(){return a.call(this._target())},e.prototype.value=function(){return n.call(this._target())},e.prototype.reason=function(){var e=this._target();return e._unsetRejectionIsUnhandled(),r.call(e)},e.prototype._value=function(){return this._settledValue()},e.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},e.PromiseInspection=t}},{}],33:[function(e,t,n){"use strict";t.exports=function(t,n){function r(e,r){if(l(e)){if(e instanceof t)return e;var i=o(e);if(i===c){r&&r._pushContext();var u=t.reject(i.e);return r&&r._popContext(),u}if("function"==typeof i){if(s(e)){var u=new t(n);return e._then(u._fulfill,u._reject,void 0,u,null),u}return a(e,i,r)}}return e}function i(e){return e.then}function o(e){try{return i(e)}catch(t){return c.e=t,c}}function s(e){return f.call(e,"_promise0")}function a(e,r,i){function o(e){a&&(a._resolveCallback(e),a=null)}function s(e){a&&(a._rejectCallback(e,f,!0),a=null)}var a=new t(n),l=a;i&&i._pushContext(),a._captureStackTrace(),i&&i._popContext();var f=!0,h=u.tryCatch(r).call(e,o,s);return f=!1,a&&h===c&&(a._rejectCallback(h.e,!0,!0),a=null),l}var u=e("./util"),c=u.errorObj,l=u.isObject,f={}.hasOwnProperty;return r}},{"./util":36}],34:[function(e,t,n){"use strict";t.exports=function(t,n,r){function i(e){this.handle=e}function o(e){return clearTimeout(this.handle),e}function s(e){throw clearTimeout(this.handle),e}var a=e("./util"),u=t.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var c=function(e){return l(+this).thenReturn(e)},l=t.delay=function(e,o){var s,a;return void 0!==o?(s=t.resolve(o)._then(c,null,null,e,void 0),r.cancellation()&&o instanceof t&&s._setOnCancel(o)):(s=new t(n),a=setTimeout(function(){s._fulfill()},+e),r.cancellation()&&s._setOnCancel(new i(a))),s._setAsyncGuaranteed(),s};t.prototype.delay=function(e){return l(e,this)};var f=function(e,t,n){var r;r="string"!=typeof t?t instanceof Error?t:new u("operation timed out"):new u(t),a.markAsOriginatingFromRejection(r),e._attachExtraTrace(r),e._reject(r),null!=n&&n.cancel()};t.prototype.timeout=function(e,t){e=+e;var n,a,u=new i(setTimeout(function(){n.isPending()&&f(n,t,a)},e));return r.cancellation()?(a=this.then(),n=a._then(o,s,void 0,u,void 0),n._setOnCancel(u)):n=this._then(o,s,void 0,u,void 0),n}}},{"./util":36}],35:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e){setTimeout(function(){throw e},0)}function u(e){var t=r(e);return t!==e&&"function"==typeof e._isDisposable&&"function"==typeof e._getDisposer&&e._isDisposable()&&t._setDisposable(e._getDisposer()),t}function c(e,n){function i(){if(s>=c)return l._fulfill();var o=u(e[s++]);if(o instanceof t&&o._isDisposable()){try{o=r(o._getDisposer().tryDispose(n),e.promise)}catch(f){return a(f)}if(o instanceof t)return o._then(i,a,null,null,null)}i()}var s=0,c=e.length,l=new t(o);return i(),l}function l(e,t,n){this._data=e,this._promise=t,this._context=n}function f(e,t,n){this.constructor$(e,t,n)}function h(e){return l.isDisposer(e)?(this.resources[this.index]._setDisposable(e),e.promise()):e}function p(e){this.length=e,this.promise=null,this[e-1]=null}var d=e("./util"),v=e("./errors").TypeError,g=e("./util").inherits,y=d.errorObj,m=d.tryCatch;l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},l.prototype.tryDispose=function(e){var t=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=null!==t?this.doDispose(t,e):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},l.isDisposer=function(e){return null!=e&&"function"==typeof e.resource&&"function"==typeof e.tryDispose},g(f,l),f.prototype.doDispose=function(e,t){var n=this.data();return n.call(e,e,t)},p.prototype._resultCancelled=function(){for(var e=this.length,n=0;e>n;++n){var r=this[n];r instanceof t&&r.cancel()}},t.using=function(){var e=arguments.length;if(2>e)return n("you must pass at least 2 arguments to Promise.using");var i=arguments[e-1];if("function"!=typeof i)return n("expecting a function but got "+d.classString(i));var o,a=!0;2===e&&Array.isArray(arguments[0])?(o=arguments[0],e=o.length,a=!1):(o=arguments,e--);for(var u=new p(e),f=0;e>f;++f){var v=o[f];if(l.isDisposer(v)){var g=v;v=v.promise(),v._setDisposable(g)}else{var b=r(v);b instanceof t&&(v=b._then(h,null,null,{resources:u,index:f},void 0))}u[f]=v}for(var w=new Array(u.length),f=0;f0},t.prototype._getDisposer=function(){return this._disposer},t.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},t.prototype.disposer=function(e){if("function"==typeof e)return new f(e,this,i());throw new v}}},{"./errors":12,"./util":36}],36:[function(e,r,i){"use strict";function o(){try{var e=U;return U=null,e.apply(this,arguments)}catch(t){return T.e=t,T}}function s(e){return U=e,o}function a(e){return null==e||e===!0||e===!1||"string"==typeof e||"number"==typeof e}function u(e){return"function"==typeof e||"object"==typeof e&&null!==e}function c(e){return a(e)?new Error(m(e)):e}function l(e,t){var n,r=e.length,i=new Array(r+1);for(n=0;r>n;++n)i[n]=e[n];return i[n]=t,i}function f(e,t,n){if(!C.isES5)return{}.hasOwnProperty.call(e,t)?e[t]:void 0;var r=Object.getOwnPropertyDescriptor(e,t);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function h(e,t,n){if(a(e))return e;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return C.defineProperty(e,t,r),e}function p(e){throw e}function d(e){try{if("function"==typeof e){var t=C.names(e.prototype),n=C.isES5&&t.length>1,r=t.length>0&&!(1===t.length&&"constructor"===t[0]),i=R.test(e+"")&&C.names(e).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function v(e){function t(){}t.prototype=e;for(var n=8;n--;)new t;return e}function g(e){return A.test(e)}function y(e,t,n){for(var r=new Array(e),i=0;e>i;++i)r[i]=t+i+n;return r}function m(e){try{return e+""}catch(t){return"[no string representation]"}}function b(e){return null!==e&&"object"==typeof e&&"string"==typeof e.message&&"string"==typeof e.name}function w(e){try{h(e,"isOperational",!0)}catch(t){}}function _(e){return null==e?!1:e instanceof Error.__BluebirdErrorTypes__.OperationalError||e.isOperational===!0}function E(e){return b(e)&&C.propertyIsWritable(e,"stack")}function x(e){return{}.toString.call(e)}function I(e,t,n){for(var r=C.names(e),i=0;i10||e[0]>0}(),N.isNode&&N.toFastProperties(t);try{throw new Error}catch(D){N.lastLineError=D}r.exports=N},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(t,n(36),function(){return this}(),n(37).setImmediate)},function(e,t){function n(){c=!1,s.length?u=s.concat(u):l=-1,u.length&&r()}function r(){if(!c){var e=setTimeout(n);c=!0;for(var t=u.length;t;){for(s=u,u=[];++l1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},t.setImmediate="function"==typeof e?e:function(e){var n=c++,r=arguments.length<2?!1:a.call(arguments,1);return u[n]=!0,o(function(){u[n]&&(r?e.apply(null,r):e.call(null),t.clearImmediate(n))}),n},t.clearImmediate="function"==typeof r?r:function(e){delete u[e]}}).call(t,n(37).setImmediate,n(37).clearImmediate)},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(e){function t(e,t,n,r){var i=I.resolve(e);return arguments.length<2?i:i.then(t,n,r)}function r(e){return new I(e)}function i(e){return function(){for(var t=0,n=arguments.length,r=new Array(n);n>t;++t)r[t]=arguments[t];return k(e,this,r)}}function o(e){for(var t=0,n=arguments.length-1,r=new Array(n);n>t;++t)r[t]=arguments[t+1];return k(e,this,r)}function s(){return new a}function a(){function e(e){r._handler.resolve(e)}function t(e){r._handler.reject(e)}function n(e){r._handler.notify(e)}var r=I._defer();this.promise=r,this.resolve=e,this.reject=t,this.notify=n,this.resolver={resolve:e,reject:t,notify:n}}function u(e){return e&&"function"==typeof e.then}function c(){return I.all(arguments)}function l(e){return t(e,I.all)}function f(e){return t(e,I.settle)}function h(e,n){return t(e,function(e){return I.map(e,n)})}function p(e,n){return t(e,function(e){return I.filter(e,n)})}var d=n(39),v=n(44),g=n(47),y=n(48),m=n(49),b=n(50),w=n(51),_=n(52),E=n(53),x=n(43),I=[v,g,y,b,w,m,_,d,E].reduce(function(e,t){return t(e)},n(55)),k=n(46)(I);return t.promise=r,t.resolve=I.resolve,t.reject=I.reject,t.lift=i,t["try"]=o,t.attempt=o,t.iterate=I.iterate,t.unfold=I.unfold,t.join=c,t.all=l,t.settle=f,t.any=i(I.any),t.some=i(I.some),t.race=i(I.race),t.map=h,t.filter=p,t.reduce=i(I.reduce),t.reduceRight=i(I.reduceRight),t.isPromiseLike=u,t.Promise=I,t.defer=s,t.TimeoutError=x,t}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[293,40,43],function(e,t,n){var r;(function(i){/** @license MIT License (c) copyright 2010-2014 original author or authors */ +return this._settledValue()},r=t.prototype.error=t.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=t.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=t.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=t.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=t.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};t.prototype.isCancelled=e.prototype._isCancelled=function(){return 65536===(65536&this._bitField)},e.prototype.isCancelled=function(){return this._target()._isCancelled()},e.prototype.isPending=function(){return s.call(this._target())},e.prototype.isRejected=function(){return o.call(this._target())},e.prototype.isFulfilled=function(){return i.call(this._target())},e.prototype.isResolved=function(){return a.call(this._target())},e.prototype.value=function(){return n.call(this._target())},e.prototype.reason=function(){var e=this._target();return e._unsetRejectionIsUnhandled(),r.call(e)},e.prototype._value=function(){return this._settledValue()},e.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},e.PromiseInspection=t}},{}],33:[function(e,t,n){"use strict";t.exports=function(t,n){function r(e,r){if(l(e)){if(e instanceof t)return e;var i=o(e);if(i===c){r&&r._pushContext();var u=t.reject(i.e);return r&&r._popContext(),u}if("function"==typeof i){if(s(e)){var u=new t(n);return e._then(u._fulfill,u._reject,void 0,u,null),u}return a(e,i,r)}}return e}function i(e){return e.then}function o(e){try{return i(e)}catch(t){return c.e=t,c}}function s(e){return f.call(e,"_promise0")}function a(e,r,i){function o(e){a&&(a._resolveCallback(e),a=null)}function s(e){a&&(a._rejectCallback(e,f,!0),a=null)}var a=new t(n),l=a;i&&i._pushContext(),a._captureStackTrace(),i&&i._popContext();var f=!0,h=u.tryCatch(r).call(e,o,s);return f=!1,a&&h===c&&(a._rejectCallback(h.e,!0,!0),a=null),l}var u=e("./util"),c=u.errorObj,l=u.isObject,f={}.hasOwnProperty;return r}},{"./util":36}],34:[function(e,t,n){"use strict";t.exports=function(t,n,r){function i(e){this.handle=e}function o(e){return clearTimeout(this.handle),e}function s(e){throw clearTimeout(this.handle),e}var a=e("./util"),u=t.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var c=function(e){return l(+this).thenReturn(e)},l=t.delay=function(e,o){var s,a;return void 0!==o?(s=t.resolve(o)._then(c,null,null,e,void 0),r.cancellation()&&o instanceof t&&s._setOnCancel(o)):(s=new t(n),a=setTimeout(function(){s._fulfill()},+e),r.cancellation()&&s._setOnCancel(new i(a))),s._setAsyncGuaranteed(),s};t.prototype.delay=function(e){return l(e,this)};var f=function(e,t,n){var r;r="string"!=typeof t?t instanceof Error?t:new u("operation timed out"):new u(t),a.markAsOriginatingFromRejection(r),e._attachExtraTrace(r),e._reject(r),null!=n&&n.cancel()};t.prototype.timeout=function(e,t){e=+e;var n,a,u=new i(setTimeout(function(){n.isPending()&&f(n,t,a)},e));return r.cancellation()?(a=this.then(),n=a._then(o,s,void 0,u,void 0),n._setOnCancel(u)):n=this._then(o,s,void 0,u,void 0),n}}},{"./util":36}],35:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,o,s){function a(e){setTimeout(function(){throw e},0)}function u(e){var t=r(e);return t!==e&&"function"==typeof e._isDisposable&&"function"==typeof e._getDisposer&&e._isDisposable()&&t._setDisposable(e._getDisposer()),t}function c(e,n){function i(){if(s>=c)return l._fulfill();var o=u(e[s++]);if(o instanceof t&&o._isDisposable()){try{o=r(o._getDisposer().tryDispose(n),e.promise)}catch(f){return a(f)}if(o instanceof t)return o._then(i,a,null,null,null)}i()}var s=0,c=e.length,l=new t(o);return i(),l}function l(e,t,n){this._data=e,this._promise=t,this._context=n}function f(e,t,n){this.constructor$(e,t,n)}function h(e){return l.isDisposer(e)?(this.resources[this.index]._setDisposable(e),e.promise()):e}function p(e){this.length=e,this.promise=null,this[e-1]=null}var d=e("./util"),v=e("./errors").TypeError,g=e("./util").inherits,y=d.errorObj,m=d.tryCatch;l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},l.prototype.tryDispose=function(e){var t=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=null!==t?this.doDispose(t,e):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},l.isDisposer=function(e){return null!=e&&"function"==typeof e.resource&&"function"==typeof e.tryDispose},g(f,l),f.prototype.doDispose=function(e,t){var n=this.data();return n.call(e,e,t)},p.prototype._resultCancelled=function(){for(var e=this.length,n=0;e>n;++n){var r=this[n];r instanceof t&&r.cancel()}},t.using=function(){var e=arguments.length;if(2>e)return n("you must pass at least 2 arguments to Promise.using");var i=arguments[e-1];if("function"!=typeof i)return n("expecting a function but got "+d.classString(i));var o,a=!0;2===e&&Array.isArray(arguments[0])?(o=arguments[0],e=o.length,a=!1):(o=arguments,e--);for(var u=new p(e),f=0;e>f;++f){var v=o[f];if(l.isDisposer(v)){var g=v;v=v.promise(),v._setDisposable(g)}else{var b=r(v);b instanceof t&&(v=b._then(h,null,null,{resources:u,index:f},void 0))}u[f]=v}for(var w=new Array(u.length),f=0;f0},t.prototype._getDisposer=function(){return this._disposer},t.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},t.prototype.disposer=function(e){if("function"==typeof e)return new f(e,this,i());throw new v}}},{"./errors":12,"./util":36}],36:[function(e,r,i){"use strict";function o(){try{var e=U;return U=null,e.apply(this,arguments)}catch(t){return T.e=t,T}}function s(e){return U=e,o}function a(e){return null==e||e===!0||e===!1||"string"==typeof e||"number"==typeof e}function u(e){return"function"==typeof e||"object"==typeof e&&null!==e}function c(e){return a(e)?new Error(m(e)):e}function l(e,t){var n,r=e.length,i=new Array(r+1);for(n=0;r>n;++n)i[n]=e[n];return i[n]=t,i}function f(e,t,n){if(!C.isES5)return{}.hasOwnProperty.call(e,t)?e[t]:void 0;var r=Object.getOwnPropertyDescriptor(e,t);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function h(e,t,n){if(a(e))return e;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return C.defineProperty(e,t,r),e}function p(e){throw e}function d(e){try{if("function"==typeof e){var t=C.names(e.prototype),n=C.isES5&&t.length>1,r=t.length>0&&!(1===t.length&&"constructor"===t[0]),i=A.test(e+"")&&C.names(e).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function v(e){function t(){}t.prototype=e;for(var n=8;n--;)new t;return e}function g(e){return R.test(e)}function y(e,t,n){for(var r=new Array(e),i=0;e>i;++i)r[i]=t+i+n;return r}function m(e){try{return e+""}catch(t){return"[no string representation]"}}function b(e){return null!==e&&"object"==typeof e&&"string"==typeof e.message&&"string"==typeof e.name}function w(e){try{h(e,"isOperational",!0)}catch(t){}}function _(e){return null==e?!1:e instanceof Error.__BluebirdErrorTypes__.OperationalError||e.isOperational===!0}function E(e){return b(e)&&C.propertyIsWritable(e,"stack")}function x(e){return{}.toString.call(e)}function I(e,t,n){for(var r=C.names(e),i=0;i10||e[0]>0}(),N.isNode&&N.toFastProperties(t);try{throw new Error}catch(D){N.lastLineError=D}r.exports=N},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(t,n(36),function(){return this}(),n(37).setImmediate)},function(e,t){function n(){c=!1,s.length?u=s.concat(u):l=-1,u.length&&r()}function r(){if(!c){var e=setTimeout(n);c=!0;for(var t=u.length;t;){for(s=u,u=[];++l1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},t.setImmediate="function"==typeof e?e:function(e){var n=c++,r=arguments.length<2?!1:a.call(arguments,1);return u[n]=!0,o(function(){u[n]&&(r?e.apply(null,r):e.call(null),t.clearImmediate(n))}),n},t.clearImmediate="function"==typeof r?r:function(e){delete u[e]}}).call(t,n(37).setImmediate,n(37).clearImmediate)},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ +!function(i){"use strict";r=function(e){function t(e,t,n,r){var i=I.resolve(e);return arguments.length<2?i:i.then(t,n,r)}function r(e){return new I(e)}function i(e){return function(){for(var t=0,n=arguments.length,r=new Array(n);n>t;++t)r[t]=arguments[t];return k(e,this,r)}}function o(e){for(var t=0,n=arguments.length-1,r=new Array(n);n>t;++t)r[t]=arguments[t+1];return k(e,this,r)}function s(){return new a}function a(){function e(e){r._handler.resolve(e)}function t(e){r._handler.reject(e)}function n(e){r._handler.notify(e)}var r=I._defer();this.promise=r,this.resolve=e,this.reject=t,this.notify=n,this.resolver={resolve:e,reject:t,notify:n}}function u(e){return e&&"function"==typeof e.then}function c(){return I.all(arguments)}function l(e){return t(e,I.all)}function f(e){return t(e,I.settle)}function h(e,n){return t(e,function(e){return I.map(e,n)})}function p(e,n){return t(e,function(e){return I.filter(e,n)})}var d=n(39),v=n(44),g=n(47),y=n(48),m=n(49),b=n(50),w=n(51),_=n(52),E=n(53),x=n(43),I=[v,g,y,b,w,m,_,d,E].reduce(function(e,t){return t(e)},n(55)),k=n(46)(I);return t.promise=r,t.resolve=I.resolve,t.reject=I.reject,t.lift=i,t["try"]=o,t.attempt=o,t.iterate=I.iterate,t.unfold=I.unfold,t.join=c,t.all=l,t.settle=f,t.any=i(I.any),t.some=i(I.some),t.race=i(I.race),t.map=h,t.filter=p,t.reduce=i(I.reduce),t.reduceRight=i(I.reduceRight),t.isPromiseLike=u,t.Promise=I,t.defer=s,t.TimeoutError=x,t}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[294,40,43],function(e,t,n){var r;(function(i){/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(o){"use strict";r=function(e){function t(){return"undefined"!=typeof i&&"[object process]"===Object.prototype.toString.call(i)}function r(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function o(e){function t(){var e=n;n=void 0,e()}var n,r=document.createTextNode(""),i=new e(t);i.observe(r,{characterData:!0});var o=0;return function(e){n=e,r.data=o^=1}}var s,a="undefined"!=typeof setTimeout&&setTimeout,u=function(e,t){return setTimeout(e,t)},c=function(e){return clearTimeout(e)},l=function(e){return a(e,0)};if(t())l=function(e){return i.nextTick(e)};else if(s=r())l=o(s);else if(!a){var f=n(41);u=function(e,t){return f.setTimer(t,e)},c=f.cancelTimer,l=f.runOnLoop||f.runOnContext}return{setTimer:u,clearTimer:c,asap:l}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))}).call(t,n(36))},function(e,t){},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){function e(t){Error.call(this),this.message=t,this.name=e.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(e){var t=n(45),r=n(46);return function(e){function n(t){function n(e){l=null,this.resolve(e)}function r(e){this.resolved||(l.push(e),0===--c&&this.reject(l))}for(var i,o,s=e._defer(),a=s._handler,u=t.length>>>0,c=u,l=[],f=0;u>f;++f)if(o=t[f],void 0!==o||f in t){if(i=e._handler(o),i.state()>0){a.become(i),e._visitRemaining(t,f,i);break}i.visit(a,n,r)}else--c;return 0===c&&a.reject(new RangeError("any(): array must not be empty")),s}function i(t,n){function r(e){this.resolved||(l.push(e),0===--p&&(f=null,this.resolve(l)))}function i(e){this.resolved||(f.push(e),0===--o&&(l=null,this.reject(f)))}var o,s,a,u=e._defer(),c=u._handler,l=[],f=[],h=t.length>>>0,p=0;for(a=0;h>a;++a)s=t[a],(void 0!==s||a in t)&&++p;for(n=Math.max(n,0),o=p-n+1,p=Math.min(n,p),n>p?c.reject(new RangeError("some(): array must contain at least "+n+" item(s), but had "+p)):0===p&&c.resolve(l),a=0;h>a;++a)s=t[a],(void 0!==s||a in t)&&e._handler(s).visit(c,r,i,c.notify);return u}function o(t,n){return e._traverse(n,t)}function s(t,n){var r=m.call(t);return e._traverse(n,r).then(function(e){return a(r,e)})}function a(t,n){for(var r=n.length,i=new Array(r),o=0,s=0;r>o;++o)n[o]&&(i[s++]=e._handler(t[o]).value);return i.length=s,i}function u(e){return v(e.map(c))}function c(n){var r=e._handler(n);return 0===r.state()?d(n).then(t.fulfilled,t.rejected):(r._unreport(),t.inspect(r))}function l(e,t){return arguments.length>2?g.call(e,h(t),arguments[2]):g.call(e,h(t))}function f(e,t){return arguments.length>2?y.call(e,h(t),arguments[2]):y.call(e,h(t))}function h(e){return function(t,n,r){return p(e,void 0,[t,n,r])}}var p=r(e),d=e.resolve,v=e.all,g=Array.prototype.reduce,y=Array.prototype.reduceRight,m=Array.prototype.slice;return e.any=n,e.some=i,e.settle=u,e.map=o,e.filter=s,e.reduce=l,e.reduceRight=f,e.prototype.spread=function(e){return this.then(v).then(function(t){return e.apply(this,t)})},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){function e(){return{state:"pending"}}function t(e){return{state:"rejected",reason:e}}function n(e){return{state:"fulfilled",value:e}}function r(r){var i=r.state();return 0===i?e():i>0?n(r.value):t(r.value)}return{pending:e,fulfilled:n,rejected:t,inspect:r}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){function e(e,n){function r(t,r,o){var s=e._defer(),a=o.length,u=new Array(a);return i({f:t,thisArg:r,args:o,params:u,i:a-1,call:n},s._handler),s}function i(t,r){if(t.i<0)return n(t.f,t.thisArg,t.params,r);var i=e._handler(t.args[t.i]);i.fold(o,t,void 0,r)}function o(e,t,n){e.params[e.i]=t,e.i-=1,i(e,n)}return arguments.length<2&&(n=t),r}function t(e,t,n,r){try{r.resolve(e.apply(t,n))}catch(i){r.reject(i)}}return e.tryCatchResolve=t,e}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){function e(){throw new TypeError("catch predicate must be a function")}function t(e,t){return n(t)?e instanceof t:t(e)}function n(e){return e===Error||null!=e&&e.prototype instanceof Error}function r(e){return("object"==typeof e||"function"==typeof e)&&null!==e}function i(e){return e}return function(n){function o(e,n){return function(r){return t(r,n)?e.call(this,r):c(r)}}function s(e,t,n,i){var o=e.call(t);return r(o)?a(o,n,i):n(i)}function a(e,t,n){return u(e).then(function(){return t(n)})}var u=n.resolve,c=n.reject,l=n.prototype["catch"];return n.prototype.done=function(e,t){this._handler.visit(this._handler.receiver,e,t)},n.prototype["catch"]=n.prototype.otherwise=function(t){return arguments.length<2?l.call(this,t):"function"!=typeof t?this.ensure(e):l.call(this,o(arguments[1],t))},n.prototype["finally"]=n.prototype.ensure=function(e){return"function"!=typeof e?this:this.then(function(t){return s(e,this,i,t)},function(t){return s(e,this,c,t)})},n.prototype["else"]=n.prototype.orElse=function(e){return this.then(void 0,function(){return e})},n.prototype["yield"]=function(e){return this.then(function(){return e})},n.prototype.tap=function(e){return this.then(e)["yield"](this)},n}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(){return function(e){return e.prototype.fold=function(t,n){var r=this._beget();return this._handler.fold(function(n,r,i){e._handler(n).fold(function(e,n,r){r.resolve(t.call(this,n,e))},r,this,i)},n,r._handler.receiver,r._handler),r},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[294,45],function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ +!function(i){"use strict";r=function(){return function(e){return e.prototype.fold=function(t,n){var r=this._beget();return this._handler.fold(function(n,r,i){e._handler(n).fold(function(e,n,r){r.resolve(t.call(this,n,e))},r,this,i)},n,r._handler.receiver,r._handler),r},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[295,45],function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){return function(e){function t(e,t,r,i){return n(function(t){return[t,e(t)]},t,r,i)}function n(e,t,i,o){function s(o,s){return r(i(o)).then(function(){return n(e,t,i,s)})}return r(o).then(function(n){return r(t(n)).then(function(t){return t?n:r(e(n)).spread(s)})})}var r=e.resolve;return e.iterate=t,e.unfold=n,e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){return function(e){return e.prototype.progress=function(e){return this.then(void 0,void 0,e)},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(){return function(e){return e.prototype["with"]=e.prototype.withThis=function(e){var t=this._beget(),n=t._handler;return n.receiver=e,this._handler.chain(n,e),t},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(e){function t(e){throw e}function r(){}var i=n(40).setTimer,o=n(54);return function(e){function n(e){e.handled||(p.push(e),l("Potentially unhandled rejection ["+e.id+"] "+o.formatError(e.value)))}function s(e){var t=p.indexOf(e);t>=0&&(p.splice(t,1),f("Handled previous rejection ["+e.id+"] "+o.formatObject(e.value)))}function a(e,t){h.push(e,t),null===d&&(d=i(u,0))}function u(){for(d=null;h.length>0;)h.shift()(h.shift())}var c,l=r,f=r;"undefined"!=typeof console&&(c=console,l="undefined"!=typeof c.error?function(e){c.error(e)}:function(e){c.log(e)},f="undefined"!=typeof c.info?function(e){c.info(e)}:function(e){c.log(e)}),e.onPotentiallyUnhandledRejection=function(e){a(n,e)},e.onPotentiallyUnhandledRejectionHandled=function(e){a(s,e)},e.onFatalRejection=function(e){a(t,e.value)};var h=[],p=[],d=null;return e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(){function e(e){var n="object"==typeof e&&null!==e&&(e.stack||e.message)?e.stack||e.message:t(e);return e instanceof Error?n:n+" (WARNING: non-Error used)"}function t(e){var t=String(e);return"[object Object]"===t&&"undefined"!=typeof JSON&&(t=n(e,t)),t}function n(e,t){try{return JSON.stringify(e)}catch(n){return t}}return{formatError:e,formatObject:t,tryStringify:n}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[295,56,57,40],function(e,t,n){var r;(function(i){/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(o){"use strict";r=function(){return function(e){function t(e,t){this._handler=e===w?t:n(e)}function n(e){function t(e){i.resolve(e)}function n(e){i.reject(e)}function r(e){i.notify(e)}var i=new E;try{e(t,n,r)}catch(o){n(o)}return i}function r(e){return L(e)?e:new t(w,new x(y(e)))}function o(e){return new t(w,new x(new C(e)))}function s(){return ee}function a(){return new t(w,new E)}function u(e,t){var n=new E(e.receiver,e.join().context);return new t(w,n)}function c(e){return f(W,null,e)}function l(e,t){return f(D,e,t)}function f(e,n,r){function i(t,i,s){s.resolved||h(r,o,t,e(n,i,t),s)}function o(e,t,n){l[e]=t,0===--c&&n.become(new k(l))}for(var s,a="function"==typeof n?i:o,u=new E,c=r.length>>>0,l=new Array(c),f=0;f0?t(n,o.value,i):(i.become(o),p(e,n+1,o))}else t(n,r,i)}function p(e,t,n){for(var r=t;rn&&e._unreport()}}function v(e){return"object"!=typeof e||null===e?o(new TypeError("non-iterable passed to race()")):0===e.length?s():1===e.length?r(e[0]):g(e)}function g(e){var n,r,i,o=new E;for(n=0;n0||"function"!=typeof t&&0>i)return new this.constructor(w,r);var o=this._beget(),s=o._handler;return r.chain(s,r.receiver,e,t,n),o},t.prototype["catch"]=function(e){return this.then(void 0,e)},t.prototype._beget=function(){return u(this._handler,this.constructor)},t.all=c,t.race=v,t._traverse=l,t._visitRemaining=p,w.prototype.when=w.prototype.become=w.prototype.notify=w.prototype.fail=w.prototype._unreport=w.prototype._report=K,w.prototype._state=0,w.prototype.state=function(){return this._state},w.prototype.join=function(){for(var e=this;void 0!==e.handler;)e=e.handler;return e},w.prototype.chain=function(e,t,n,r,i){this.when({resolver:e,receiver:t,fulfilled:n,rejected:r,progress:i})},w.prototype.visit=function(e,t,n,r){this.chain(X,e,t,n,r)},w.prototype.fold=function(e,t,n,r){this.when(new A(e,t,n,r))},Q(w,_),_.prototype.become=function(e){e.fail()};var X=new _;Q(w,E),E.prototype._state=0,E.prototype.resolve=function(e){this.become(y(e))},E.prototype.reject=function(e){this.resolved||this.become(new C(e))},E.prototype.join=function(){if(!this.resolved)return this;for(var e=this;void 0!==e.handler;)if(e=e.handler,e===this)return this.handler=U();return e},E.prototype.run=function(){var e=this.consumers,t=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var n=0;n",'"',"`"," ","\r","\n"," "],d=["{","}","|","\\","^","`"].concat(p),v=["'"].concat(d),g=["%","/","?",";","#"].concat(v),y=["/","?","#"],m=255,b=/^[+a-z0-9A-Z_-]{0,63}$/,w=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},I=n(63);r.prototype.parse=function(e,t,n){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),i=-1!==r&&rT)&&(C=T)}var U,B;B=-1===C?a.lastIndexOf("@"):a.lastIndexOf("@",C),-1!==B&&(U=a.slice(0,B),a=a.slice(B+1),this.auth=decodeURIComponent(U)),C=-1;for(var S=0;ST)&&(C=T)}-1===C&&(C=a.length),this.host=a.slice(0,C),a=a.slice(C),this.parseHost(),this.hostname=this.hostname||"";var j="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!j)for(var O=this.hostname.split(/\./),S=0,R=O.length;R>S;S++){var A=O[S];if(A&&!A.match(b)){for(var L="",M=0,P=A.length;P>M;M++)L+=A.charCodeAt(M)>127?"x":A[M];if(!L.match(b)){var F=O.slice(0,S),N=O.slice(S+1),D=A.match(w);D&&(F.push(D[1]),N.unshift(D[2])),N.length&&(a="/"+N.join(".")+a),this.hostname=F.join(".");break}}}this.hostname.length>m?this.hostname="":this.hostname=this.hostname.toLowerCase(),j||(this.hostname=u.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,j&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!_[d])for(var S=0,R=v.length;R>S;S++){var H=v[S];if(-1!==a.indexOf(H)){var Q=encodeURIComponent(H);Q===H&&(Q=escape(H)),a=a.split(H).join(Q)}}var W=a.indexOf("#");-1!==W&&(this.hash=a.substr(W),a=a.slice(0,W));var K=a.indexOf("?");if(-1!==K?(this.search=a.substr(K),this.query=a.substr(K+1),t&&(this.query=I.parse(this.query)),a=a.slice(0,K)):t&&(this.search="",this.query={}),a&&(this.pathname=a),x[d]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var q=this.pathname||"",Y=this.search||"";this.path=q+Y}return this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,o="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&c.isObject(this.query)&&Object.keys(this.query).length&&(o=I.stringify(this.query));var s=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||x[t])&&i!==!1?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),s=s.replace("#","%23"),t+i+n+s+r},r.prototype.resolve=function(e){return this.resolveObject(i(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(c.isString(e)){var t=new r;t.parse(e,!1,!0),e=t}for(var n=new r,i=Object.keys(this),o=0;o0?n.host.split("@"):!1;k&&(n.auth=k.shift(),n.host=n.hostname=k.shift())}return n.search=e.search,n.query=e.query,c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!_.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=_.slice(-1)[0],S=(n.host||e.host||_.length>1)&&("."===C||".."===C)||""===C,T=0,U=_.length;U>=0;U--)C=_[U],"."===C?_.splice(U,1):".."===C?(_.splice(U,1),T++):T&&(_.splice(U,1),T--);if(!b&&!w)for(;T--;T)_.unshift("..");!b||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),S&&"/"!==_.join("/").substr(-1)&&_.push("");var B=""===_[0]||_[0]&&"/"===_[0].charAt(0);if(I){n.hostname=n.host=B?"":_.length?_.shift():"";var k=n.host&&n.host.indexOf("@")>0?n.host.split("@"):!1;k&&(n.auth=k.shift(),n.host=n.hostname=k.shift())}return b=b||n.host&&_.length,b&&!B&&_.unshift(""),_.length?n.pathname=_.join("/"):(n.pathname=null,n.path=null),c.isNull(n.pathname)&&c.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},r.prototype.parseHost=function(){var e=this.host,t=f.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,n){var r;(function(e,i){!function(o){function s(e){throw RangeError(O[e])}function a(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function u(e,t){var n=e.split("@"),r="";n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(j,".");var i=e.split("."),o=a(i,t).join(".");return r+o}function c(e){for(var t,n,r=[],i=0,o=e.length;o>i;)t=e.charCodeAt(i++),t>=55296&&56319>=t&&o>i?(n=e.charCodeAt(i++),56320==(64512&n)?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--)):r.push(t);return r}function l(e){return a(e,function(e){var t="";return e>65535&&(e-=65536,t+=L(e>>>10&1023|55296),e=56320|1023&e),t+=L(e)}).join("")}function f(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:_}function h(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function p(e,t,n){var r=0;for(e=n?A(e/k):e>>1,e+=A(e/t);e>R*x>>1;r+=_)e=A(e/R);return A(r+(R+1)*e/(e+I))}function d(e){var t,n,r,i,o,a,u,c,h,d,v=[],g=e.length,y=0,m=S,b=C;for(n=e.lastIndexOf(T),0>n&&(n=0),r=0;n>r;++r)e.charCodeAt(r)>=128&&s("not-basic"),v.push(e.charCodeAt(r));for(i=n>0?n+1:0;g>i;){for(o=y,a=1,u=_;i>=g&&s("invalid-input"),c=f(e.charCodeAt(i++)),(c>=_||c>A((w-y)/a))&&s("overflow"),y+=c*a,h=b>=u?E:u>=b+x?x:u-b,!(h>c);u+=_)d=_-h,a>A(w/d)&&s("overflow"),a*=d;t=v.length+1,b=p(y-o,t,0==o),A(y/t)>w-m&&s("overflow"),m+=A(y/t),y%=t,v.splice(y++,0,m)}return l(v)}function v(e){var t,n,r,i,o,a,u,l,f,d,v,g,y,m,b,I=[];for(e=c(e),g=e.length,t=S,n=0,o=C,a=0;g>a;++a)v=e[a],128>v&&I.push(L(v));for(r=i=I.length,i&&I.push(T);g>r;){for(u=w,a=0;g>a;++a)v=e[a],v>=t&&u>v&&(u=v);for(y=r+1,u-t>A((w-n)/y)&&s("overflow"),n+=(u-t)*y,t=u,a=0;g>a;++a)if(v=e[a],t>v&&++n>w&&s("overflow"),v==t){for(l=n,f=_;d=o>=f?E:f>=o+x?x:f-o,!(d>l);f+=_)b=l-d,m=_-d,I.push(L(h(d+b%m,0))),l=A(b/m);I.push(L(h(l,0))),o=p(n,y,r==i),n=0,++r}++n,++t}return I.join("")}function g(e){return u(e,function(e){return U.test(e)?d(e.slice(4).toLowerCase()):e})}function y(e){return u(e,function(e){return B.test(e)?"xn--"+v(e):e})}var m=("object"==typeof t&&t&&!t.nodeType&&t,"object"==typeof e&&e&&!e.nodeType&&e,"object"==typeof i&&i);m.global!==m&&m.window!==m&&m.self!==m||(o=m);var b,w=2147483647,_=36,E=1,x=26,I=38,k=700,C=72,S=128,T="-",U=/^xn--/,B=/[^\x20-\x7E]/,j=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=_-E,A=Math.floor,L=String.fromCharCode;b={version:"1.3.2",ucs2:{decode:c,encode:l},decode:d,encode:v,toASCII:y,toUnicode:g},r=function(){return b}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(this)}).call(t,n(34)(e),function(){return this}())},function(e,t){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(64),t.encode=t.stringify=n(65)},function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,i){t=t||"&",r=r||"=";var o={};if("string"!=typeof e||0===e.length)return o;var s=/\+/g;e=e.split(t);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var u=e.length;a>0&&u>a&&(u=a);for(var c=0;u>c;++c){var l,f,h,p,d=e[c].replace(s,"%20"),v=d.indexOf(r);v>=0?(l=d.substr(0,v),f=d.substr(v+1)):(l=d,f=""),h=decodeURIComponent(l),p=decodeURIComponent(f),n(o,h)?Array.isArray(o[h])?o[h].push(p):o[h]=[o[h],p]:o[h]=p}return o}},function(e,t){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,i){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(i){var o=encodeURIComponent(n(i))+r;return Array.isArray(e[i])?e[i].map(function(e){return o+encodeURIComponent(n(e))}).join(t):o+encodeURIComponent(n(e[i]))}).join(t):i?encodeURIComponent(n(i))+r+encodeURIComponent(n(e)):""}},function(e,t,n){(function(t){"use strict";function r(e){g.call(this);var n=this.stream=u(e);this.muxer=new d(n),this.rest=new t(0),this.frameMax=f.FRAME_MIN_SIZE,this.sentSinceLastCheck=!1,this.recvSinceLastCheck=!1,this.expectSocketClose=!1,this.freeChannels=new _,this.channels=[{channel:{accept:o(this)},buffer:e}]}function i(e){var t=this.channels[e.channel];return t?t.channel.accept(e):void this.closeWithError(x("Frame on unknown channel %d",e.channel),f.CHANNEL_ERROR,new Error(x("Frame on unknown channel: %s",w(e,!1))))}function o(e){return function(t){if(t===p);else if(t.id===l.ConnectionClose){e.sendMethod(0,l.ConnectionCloseOk,{});var n=x("Connection closed: %s",b(t)),r=C(n),i=new Error(n);i.code=t.fields.replyCode,c(i)&&e.emit("error",i),e.toClosed(r,i)}else t.id===l.ConnectionBlocked?e.emit("blocked",t.fields.reason):t.id===l.ConnectionUnblocked?e.emit("unblocked"):e.closeWithError(x("Unexpected frame on channel 0"),f.UNEXPECTED_FRAME,new Error(x("Unexpected frame on channel 0: %s",w(t,!1))))}}function s(e,t){return function(){throw new k(e,t)}}function a(e,t,n){e.sendMethod=e.sendContent=e.sendMessage=s(t,n)}function u(e){if(e instanceof v)return e;var t=new v;return t.wrap(e),t._write=function(t,n,r){return e.write(t,n,r)},t}function c(e){switch(e&&e.code){case l.constants.CONNECTION_FORCED:case l.constants.REPLY_SUCCESS:return!1;default:return!0}}var l=n(67),f=l.constants,h=n(74),p=h.HEARTBEAT,d=n(82).Mux,v=n(83).Duplex||n(99),g=n(84).EventEmitter,y=n(102).Heart,m=n(103).methodName,b=n(103).closeMessage,w=n(103).inspect,_=n(104).BitSet,E=n(71).inherits,x=n(71).format,I=n(83).PassThrough||n(101),k=n(105).IllegalOperationError,C=n(105).stackCapture,S=1024,T=2048;E(r,g);var U=r.prototype;U.sendProtocolHeader=function(){this.sendBytes(h.PROTOCOL_HEADER)},U.open=function(e,t){function n(e){d.step(function(t,n){null!==t?o(t):0!==n.channel?o(new Error(x("Frame on channel != 0 during handshake: %s",w(n,!1)))):e(n)})}function r(e,t){n(function(n){n.id===e?t(n):o(new Error(x("Expected %s; got %s",m(e),w(n,!1))))})}function o(e){v(e)}function s(e){try{d.sendMethod(0,e,g)}catch(t){o(t)}}function a(e,t){return 0===e||0===t?Math.max(e,t):Math.min(e,t)}function u(t){var r=t.fields.mechanisms.toString().split(" ");return r.indexOf(e.mechanism)<0?void o(new Error(x("SASL mechanism %s is not provided by the server",e.mechanism))):(s(l.ConnectionStartOk),void n(c))}function c(t){switch(t.id){case l.ConnectionSecure:o(new Error("Wasn't expecting to have to go through secure"));break;case l.ConnectionClose:o(new Error(x("Handshake terminated by server: %s",b(t))));break;case l.ConnectionTune:var n=t.fields;g.frameMax=a(n.frameMax,e.frameMax),g.channelMax=a(n.channelMax,e.channelMax),g.heartbeat=a(n.heartbeat,e.heartbeat),s(l.ConnectionTuneOk),s(l.ConnectionOpen),r(l.ConnectionOpenOk,f);break;default:o(new Error(x("Expected connection.secure, connection.close, or connection.tune during handshake; got %s",w(t,!1))))}}function f(e){d.channelMax=g.channelMax||65535,d.frameMax=g.frameMax||4294967295,d.heartbeat=g.heartbeat,d.heartbeater=d.startHeartbeater(),d.accept=i,p(e)}function h(e){o(e||new Error("Socket closed abruptly during opening handshake"))}function p(e){d.stream.removeListener("end",h),d.stream.removeListener("error",h),d.stream.on("error",d.onSocketError.bind(d)),d.stream.on("end",d.onSocketError.bind(d,new Error("Unexpected close"))),d.on("frameError",d.onSocketError.bind(d)),d.acceptLoop(),v(null,e)}var d=this,v=t||function(){},g=Object.create(e);this.stream.on("end",h),this.stream.on("error",h),this.sendProtocolHeader(),r(l.ConnectionStart,u)},U.close=function(e){var t=e&&function(){e(null)};this.closeBecause("Cheers, thanks",f.REPLY_SUCCESS,t)},U.closeBecause=function(e,t,n){this.sendMethod(0,l.ConnectionClose,{replyText:e,replyCode:t,methodId:0,classId:0});var r=C("closeBecause called: "+e);this.toClosing(r,n)},U.closeWithError=function(e,t,n){this.emit("error",n),this.closeBecause(e,t)},U.onSocketError=function(e){if(!this.expectSocketClose){this.expectSocketClose=!0,this.emit("error",e);var t=C("Socket error");this.toClosed(t,e)}},U.toClosing=function(e,t){var n=this.sendMethod.bind(this);this.accept=function(e){if(e.id===l.ConnectionCloseOk){t&&t();var r=C("ConnectionCloseOk received");this.toClosed(r,void 0)}else e.id===l.ConnectionClose&&n(0,l.ConnectionCloseOk,{})},a(this,"Connection closing",e)},U._closeChannels=function(e){for(var t=1;tn||n>this.channelMax)throw new Error("No channels left to allocate");this.freeChannels.set(n);var r=t&&t.highWaterMark||S,i=new I({objectMode:!0,highWaterMark:r});return this.channels[n]={channel:e,buffer:i},i.on("drain",function(){e.onBufferDrain()}),this.muxer.pipeFrom(i),n},U.releaseChannel=function(e){this.freeChannels.clear(e);var t=this.channels[e].buffer;this.muxer.unpipeFrom(t),this.channels[e]=null},U.acceptLoop=function(){function e(){try{for(var e;e=t.recvFrame();)t.accept(e)}catch(n){t.emit("frameError",n)}}var t=this;t.stream.on("readable",e),e()},U.step=function(e){function t(){var r;try{r=n.recvFrame()}catch(i){return void e(i,null)}r?e(null,r):n.stream.once("readable",t)}var n=this;t()},U.checkSend=function(){var e=this.sentSinceLastCheck;return this.sentSinceLastCheck=!1,e},U.checkRecv=function(){var e=this.recvSinceLastCheck;return this.recvSinceLastCheck=!1,e},U.sendBytes=function(e){this.sentSinceLastCheck=!0,this.stream.write(e)},U.sendHeartbeat=function(){return this.sendBytes(h.HEARTBEAT_BUF)};var B=l.encodeMethod,j=l.encodeProperties;U.sendMethod=function(e,t,n){var r=B(t,e,n);this.sentSinceLastCheck=!0;var i=this.channels[e].buffer;return i.write(r)},U.sendMessage=function(e,n,r,i,o,s){if(!t.isBuffer(s))throw new TypeError("content is not a buffer");var a=B(n,e,r),u=j(i,e,s.length,o),c=this.channels[e].buffer;this.sentSinceLastCheck=!0;var l=a.length+u.length,f=s.length>0?s.length+O:0,h=l+f;if(T>h){var p=new t(h),d=a.copy(p,0);return d+=u.copy(p,d),f>0&&R(e,s).copy(p,d),c.write(p)}if(T>l){var v=new t(l),d=a.copy(v,0);u.copy(v,d),c.write(v)}else c.write(a),c.write(u);return this.sendContent(e,s)};var O=l.FRAME_OVERHEAD,R=h.makeBodyFrame;U.sendContent=function(e,n){if(!t.isBuffer(n))throw new TypeError(x("Expected buffer; got %s",n));for(var r=!0,i=this.channels[e].buffer,o=this.frameMax-O,s=0;sn.length?n.slice(s):n.slice(s,a),c=R(e,u);r=i.write(c)}return this.sentSinceLastCheck=!0,r};var A=h.parseFrame,L=h.decodeFrame;U.recvFrame=function(){var e=A(this.rest,this.frameMax);if(e)return this.rest=e.rest,L(e);var n=this.stream.read();return null===n?!1:(this.recvSinceLastCheck=!0,this.rest=t.concat([this.rest,n]),this.recvFrame())},e.exports.Connection=r,e.exports.isFatalError=c}).call(t,n(3).Buffer)},function(e,t,n){(function(t){/** @preserve This file is generated by the script +!function(i){"use strict";r=function(){function e(e){var n="object"==typeof e&&null!==e&&(e.stack||e.message)?e.stack||e.message:t(e);return e instanceof Error?n:n+" (WARNING: non-Error used)"}function t(e){var t=String(e);return"[object Object]"===t&&"undefined"!=typeof JSON&&(t=n(e,t)),t}function n(e,t){try{return JSON.stringify(e)}catch(n){return t}}return{formatError:e,formatObject:t,tryStringify:n}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[296,56,57,40],function(e,t,n){var r;(function(i){/** @license MIT License (c) copyright 2010-2014 original author or authors */ +!function(o){"use strict";r=function(){return function(e){function t(e,t){this._handler=e===w?t:n(e)}function n(e){function t(e){i.resolve(e)}function n(e){i.reject(e)}function r(e){i.notify(e)}var i=new E;try{e(t,n,r)}catch(o){n(o)}return i}function r(e){return L(e)?e:new t(w,new x(y(e)))}function o(e){return new t(w,new x(new C(e)))}function s(){return ee}function a(){return new t(w,new E)}function u(e,t){var n=new E(e.receiver,e.join().context);return new t(w,n)}function c(e){return f(W,null,e)}function l(e,t){return f(D,e,t)}function f(e,n,r){function i(t,i,s){s.resolved||h(r,o,t,e(n,i,t),s)}function o(e,t,n){l[e]=t,0===--c&&n.become(new k(l))}for(var s,a="function"==typeof n?i:o,u=new E,c=r.length>>>0,l=new Array(c),f=0;f0?t(n,o.value,i):(i.become(o),p(e,n+1,o))}else t(n,r,i)}function p(e,t,n){for(var r=t;rn&&e._unreport()}}function v(e){return"object"!=typeof e||null===e?o(new TypeError("non-iterable passed to race()")):0===e.length?s():1===e.length?r(e[0]):g(e)}function g(e){var n,r,i,o=new E;for(n=0;n0||"function"!=typeof t&&0>i)return new this.constructor(w,r);var o=this._beget(),s=o._handler;return r.chain(s,r.receiver,e,t,n),o},t.prototype["catch"]=function(e){return this.then(void 0,e)},t.prototype._beget=function(){return u(this._handler,this.constructor)},t.all=c,t.race=v,t._traverse=l,t._visitRemaining=p,w.prototype.when=w.prototype.become=w.prototype.notify=w.prototype.fail=w.prototype._unreport=w.prototype._report=K,w.prototype._state=0,w.prototype.state=function(){return this._state},w.prototype.join=function(){for(var e=this;void 0!==e.handler;)e=e.handler;return e},w.prototype.chain=function(e,t,n,r,i){this.when({resolver:e,receiver:t,fulfilled:n,rejected:r,progress:i})},w.prototype.visit=function(e,t,n,r){this.chain(X,e,t,n,r)},w.prototype.fold=function(e,t,n,r){this.when(new R(e,t,n,r))},Q(w,_),_.prototype.become=function(e){e.fail()};var X=new _;Q(w,E),E.prototype._state=0,E.prototype.resolve=function(e){this.become(y(e))},E.prototype.reject=function(e){this.resolved||this.become(new C(e))},E.prototype.join=function(){if(!this.resolved)return this;for(var e=this;void 0!==e.handler;)if(e=e.handler,e===this)return this.handler=U();return e},E.prototype.run=function(){var e=this.consumers,t=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var n=0;n",'"',"`"," ","\r","\n"," "],d=["{","}","|","\\","^","`"].concat(p),v=["'"].concat(d),g=["%","/","?",";","#"].concat(v),y=["/","?","#"],m=255,b=/^[+a-z0-9A-Z_-]{0,63}$/,w=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},I=n(63);r.prototype.parse=function(e,t,n){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),i=-1!==r&&rT)&&(C=T)}var U,B;B=-1===C?a.lastIndexOf("@"):a.lastIndexOf("@",C),-1!==B&&(U=a.slice(0,B),a=a.slice(B+1),this.auth=decodeURIComponent(U)),C=-1;for(var S=0;ST)&&(C=T)}-1===C&&(C=a.length),this.host=a.slice(0,C),a=a.slice(C),this.parseHost(),this.hostname=this.hostname||"";var j="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!j)for(var O=this.hostname.split(/\./),S=0,A=O.length;A>S;S++){var R=O[S];if(R&&!R.match(b)){for(var L="",M=0,F=R.length;F>M;M++)L+=R.charCodeAt(M)>127?"x":R[M];if(!L.match(b)){var P=O.slice(0,S),N=O.slice(S+1),D=R.match(w);D&&(P.push(D[1]),N.unshift(D[2])),N.length&&(a="/"+N.join(".")+a),this.hostname=P.join(".");break}}}this.hostname.length>m?this.hostname="":this.hostname=this.hostname.toLowerCase(),j||(this.hostname=u.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,j&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!_[d])for(var S=0,A=v.length;A>S;S++){var H=v[S];if(-1!==a.indexOf(H)){var Q=encodeURIComponent(H);Q===H&&(Q=escape(H)),a=a.split(H).join(Q)}}var W=a.indexOf("#");-1!==W&&(this.hash=a.substr(W),a=a.slice(0,W));var K=a.indexOf("?");if(-1!==K?(this.search=a.substr(K),this.query=a.substr(K+1),t&&(this.query=I.parse(this.query)),a=a.slice(0,K)):t&&(this.search="",this.query={}),a&&(this.pathname=a),x[d]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var q=this.pathname||"",Y=this.search||"";this.path=q+Y}return this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,o="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&c.isObject(this.query)&&Object.keys(this.query).length&&(o=I.stringify(this.query));var s=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||x[t])&&i!==!1?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),s=s.replace("#","%23"),t+i+n+s+r},r.prototype.resolve=function(e){return this.resolveObject(i(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(c.isString(e)){var t=new r;t.parse(e,!1,!0),e=t}for(var n=new r,i=Object.keys(this),o=0;o0?n.host.split("@"):!1;k&&(n.auth=k.shift(),n.host=n.hostname=k.shift())}return n.search=e.search,n.query=e.query,c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!_.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=_.slice(-1)[0],S=(n.host||e.host||_.length>1)&&("."===C||".."===C)||""===C,T=0,U=_.length;U>=0;U--)C=_[U],"."===C?_.splice(U,1):".."===C?(_.splice(U,1),T++):T&&(_.splice(U,1),T--);if(!b&&!w)for(;T--;T)_.unshift("..");!b||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),S&&"/"!==_.join("/").substr(-1)&&_.push("");var B=""===_[0]||_[0]&&"/"===_[0].charAt(0);if(I){n.hostname=n.host=B?"":_.length?_.shift():"";var k=n.host&&n.host.indexOf("@")>0?n.host.split("@"):!1;k&&(n.auth=k.shift(),n.host=n.hostname=k.shift())}return b=b||n.host&&_.length,b&&!B&&_.unshift(""),_.length?n.pathname=_.join("/"):(n.pathname=null,n.path=null),c.isNull(n.pathname)&&c.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},r.prototype.parseHost=function(){var e=this.host,t=f.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,n){var r;(function(e,i){!function(o){function s(e){throw RangeError(O[e])}function a(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function u(e,t){var n=e.split("@"),r="";n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(j,".");var i=e.split("."),o=a(i,t).join(".");return r+o}function c(e){for(var t,n,r=[],i=0,o=e.length;o>i;)t=e.charCodeAt(i++),t>=55296&&56319>=t&&o>i?(n=e.charCodeAt(i++),56320==(64512&n)?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--)):r.push(t);return r}function l(e){return a(e,function(e){var t="";return e>65535&&(e-=65536,t+=L(e>>>10&1023|55296),e=56320|1023&e),t+=L(e)}).join("")}function f(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:_}function h(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function p(e,t,n){var r=0;for(e=n?R(e/k):e>>1,e+=R(e/t);e>A*x>>1;r+=_)e=R(e/A);return R(r+(A+1)*e/(e+I))}function d(e){var t,n,r,i,o,a,u,c,h,d,v=[],g=e.length,y=0,m=S,b=C;for(n=e.lastIndexOf(T),0>n&&(n=0),r=0;n>r;++r)e.charCodeAt(r)>=128&&s("not-basic"),v.push(e.charCodeAt(r));for(i=n>0?n+1:0;g>i;){for(o=y,a=1,u=_;i>=g&&s("invalid-input"),c=f(e.charCodeAt(i++)),(c>=_||c>R((w-y)/a))&&s("overflow"),y+=c*a,h=b>=u?E:u>=b+x?x:u-b,!(h>c);u+=_)d=_-h,a>R(w/d)&&s("overflow"),a*=d;t=v.length+1,b=p(y-o,t,0==o),R(y/t)>w-m&&s("overflow"),m+=R(y/t),y%=t,v.splice(y++,0,m)}return l(v)}function v(e){var t,n,r,i,o,a,u,l,f,d,v,g,y,m,b,I=[];for(e=c(e),g=e.length,t=S,n=0,o=C,a=0;g>a;++a)v=e[a],128>v&&I.push(L(v));for(r=i=I.length,i&&I.push(T);g>r;){for(u=w,a=0;g>a;++a)v=e[a],v>=t&&u>v&&(u=v);for(y=r+1,u-t>R((w-n)/y)&&s("overflow"),n+=(u-t)*y,t=u,a=0;g>a;++a)if(v=e[a],t>v&&++n>w&&s("overflow"),v==t){for(l=n,f=_;d=o>=f?E:f>=o+x?x:f-o,!(d>l);f+=_)b=l-d,m=_-d,I.push(L(h(d+b%m,0))),l=R(b/m);I.push(L(h(l,0))),o=p(n,y,r==i),n=0,++r}++n,++t}return I.join("")}function g(e){return u(e,function(e){return U.test(e)?d(e.slice(4).toLowerCase()):e})}function y(e){return u(e,function(e){return B.test(e)?"xn--"+v(e):e})}var m=("object"==typeof t&&t&&!t.nodeType&&t,"object"==typeof e&&e&&!e.nodeType&&e,"object"==typeof i&&i);m.global!==m&&m.window!==m&&m.self!==m||(o=m);var b,w=2147483647,_=36,E=1,x=26,I=38,k=700,C=72,S=128,T="-",U=/^xn--/,B=/[^\x20-\x7E]/,j=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=_-E,R=Math.floor,L=String.fromCharCode;b={version:"1.3.2",ucs2:{decode:c,encode:l},decode:d,encode:v,toASCII:y,toUnicode:g},r=function(){return b}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(this)}).call(t,n(34)(e),function(){return this}())},function(e,t){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(64),t.encode=t.stringify=n(65)},function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,i){t=t||"&",r=r||"=";var o={};if("string"!=typeof e||0===e.length)return o;var s=/\+/g;e=e.split(t);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var u=e.length;a>0&&u>a&&(u=a);for(var c=0;u>c;++c){var l,f,h,p,d=e[c].replace(s,"%20"),v=d.indexOf(r);v>=0?(l=d.substr(0,v),f=d.substr(v+1)):(l=d,f=""),h=decodeURIComponent(l),p=decodeURIComponent(f),n(o,h)?Array.isArray(o[h])?o[h].push(p):o[h]=[o[h],p]:o[h]=p}return o}},function(e,t){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,i){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(i){var o=encodeURIComponent(n(i))+r;return Array.isArray(e[i])?e[i].map(function(e){return o+encodeURIComponent(n(e))}).join(t):o+encodeURIComponent(n(e[i]))}).join(t):i?encodeURIComponent(n(i))+r+encodeURIComponent(n(e)):""}},function(e,t,n){(function(t){"use strict";function r(e){g.call(this);var n=this.stream=u(e);this.muxer=new d(n),this.rest=new t(0),this.frameMax=f.FRAME_MIN_SIZE,this.sentSinceLastCheck=!1,this.recvSinceLastCheck=!1,this.expectSocketClose=!1,this.freeChannels=new _,this.channels=[{channel:{accept:o(this)},buffer:e}]}function i(e){var t=this.channels[e.channel];return t?t.channel.accept(e):void this.closeWithError(x("Frame on unknown channel %d",e.channel),f.CHANNEL_ERROR,new Error(x("Frame on unknown channel: %s",w(e,!1))))}function o(e){return function(t){if(t===p);else if(t.id===l.ConnectionClose){e.sendMethod(0,l.ConnectionCloseOk,{});var n=x("Connection closed: %s",b(t)),r=C(n),i=new Error(n);i.code=t.fields.replyCode,c(i)&&e.emit("error",i),e.toClosed(r,i)}else t.id===l.ConnectionBlocked?e.emit("blocked",t.fields.reason):t.id===l.ConnectionUnblocked?e.emit("unblocked"):e.closeWithError(x("Unexpected frame on channel 0"),f.UNEXPECTED_FRAME,new Error(x("Unexpected frame on channel 0: %s",w(t,!1))))}}function s(e,t){return function(){throw new k(e,t)}}function a(e,t,n){e.sendMethod=e.sendContent=e.sendMessage=s(t,n)}function u(e){if(e instanceof v)return e;var t=new v;return t.wrap(e),t._write=function(t,n,r){return e.write(t,n,r)},t}function c(e){switch(e&&e.code){case l.constants.CONNECTION_FORCED:case l.constants.REPLY_SUCCESS:return!1;default:return!0}}var l=n(67),f=l.constants,h=n(74),p=h.HEARTBEAT,d=n(82).Mux,v=n(83).Duplex||n(99),g=n(84).EventEmitter,y=n(102).Heart,m=n(103).methodName,b=n(103).closeMessage,w=n(103).inspect,_=n(104).BitSet,E=n(71).inherits,x=n(71).format,I=n(83).PassThrough||n(101),k=n(105).IllegalOperationError,C=n(105).stackCapture,S=1024,T=2048;E(r,g);var U=r.prototype;U.sendProtocolHeader=function(){this.sendBytes(h.PROTOCOL_HEADER)},U.open=function(e,t){function n(e){d.step(function(t,n){null!==t?o(t):0!==n.channel?o(new Error(x("Frame on channel != 0 during handshake: %s",w(n,!1)))):e(n)})}function r(e,t){n(function(n){n.id===e?t(n):o(new Error(x("Expected %s; got %s",m(e),w(n,!1))))})}function o(e){v(e)}function s(e){try{d.sendMethod(0,e,g)}catch(t){o(t)}}function a(e,t){return 0===e||0===t?Math.max(e,t):Math.min(e,t)}function u(t){var r=t.fields.mechanisms.toString().split(" ");return r.indexOf(e.mechanism)<0?void o(new Error(x("SASL mechanism %s is not provided by the server",e.mechanism))):(s(l.ConnectionStartOk),void n(c))}function c(t){switch(t.id){case l.ConnectionSecure:o(new Error("Wasn't expecting to have to go through secure"));break;case l.ConnectionClose:o(new Error(x("Handshake terminated by server: %s",b(t))));break;case l.ConnectionTune:var n=t.fields;g.frameMax=a(n.frameMax,e.frameMax),g.channelMax=a(n.channelMax,e.channelMax),g.heartbeat=a(n.heartbeat,e.heartbeat),s(l.ConnectionTuneOk),s(l.ConnectionOpen),r(l.ConnectionOpenOk,f);break;default:o(new Error(x("Expected connection.secure, connection.close, or connection.tune during handshake; got %s",w(t,!1))))}}function f(e){d.channelMax=g.channelMax||65535,d.frameMax=g.frameMax||4294967295,d.heartbeat=g.heartbeat,d.heartbeater=d.startHeartbeater(),d.accept=i,p(e)}function h(e){o(e||new Error("Socket closed abruptly during opening handshake"))}function p(e){d.stream.removeListener("end",h),d.stream.removeListener("error",h),d.stream.on("error",d.onSocketError.bind(d)),d.stream.on("end",d.onSocketError.bind(d,new Error("Unexpected close"))),d.on("frameError",d.onSocketError.bind(d)),d.acceptLoop(),v(null,e)}var d=this,v=t||function(){},g=Object.create(e);this.stream.on("end",h),this.stream.on("error",h),this.sendProtocolHeader(),r(l.ConnectionStart,u)},U.close=function(e){var t=e&&function(){e(null)};this.closeBecause("Cheers, thanks",f.REPLY_SUCCESS,t)},U.closeBecause=function(e,t,n){this.sendMethod(0,l.ConnectionClose,{replyText:e,replyCode:t,methodId:0,classId:0});var r=C("closeBecause called: "+e);this.toClosing(r,n)},U.closeWithError=function(e,t,n){this.emit("error",n),this.closeBecause(e,t)},U.onSocketError=function(e){if(!this.expectSocketClose){this.expectSocketClose=!0,this.emit("error",e);var t=C("Socket error");this.toClosed(t,e)}},U.toClosing=function(e,t){var n=this.sendMethod.bind(this);this.accept=function(e){if(e.id===l.ConnectionCloseOk){t&&t();var r=C("ConnectionCloseOk received");this.toClosed(r,void 0)}else e.id===l.ConnectionClose&&n(0,l.ConnectionCloseOk,{})},a(this,"Connection closing",e)},U._closeChannels=function(e){for(var t=1;tn||n>this.channelMax)throw new Error("No channels left to allocate");this.freeChannels.set(n);var r=t&&t.highWaterMark||S,i=new I({objectMode:!0,highWaterMark:r});return this.channels[n]={channel:e,buffer:i},i.on("drain",function(){e.onBufferDrain()}),this.muxer.pipeFrom(i),n},U.releaseChannel=function(e){this.freeChannels.clear(e);var t=this.channels[e].buffer;this.muxer.unpipeFrom(t),this.channels[e]=null},U.acceptLoop=function(){function e(){try{for(var e;e=t.recvFrame();)t.accept(e)}catch(n){t.emit("frameError",n)}}var t=this;t.stream.on("readable",e),e()},U.step=function(e){function t(){var r;try{r=n.recvFrame()}catch(i){return void e(i,null)}r?e(null,r):n.stream.once("readable",t)}var n=this;t()},U.checkSend=function(){var e=this.sentSinceLastCheck;return this.sentSinceLastCheck=!1,e},U.checkRecv=function(){var e=this.recvSinceLastCheck;return this.recvSinceLastCheck=!1,e},U.sendBytes=function(e){this.sentSinceLastCheck=!0,this.stream.write(e)},U.sendHeartbeat=function(){return this.sendBytes(h.HEARTBEAT_BUF)};var B=l.encodeMethod,j=l.encodeProperties;U.sendMethod=function(e,t,n){var r=B(t,e,n);this.sentSinceLastCheck=!0;var i=this.channels[e].buffer;return i.write(r)},U.sendMessage=function(e,n,r,i,o,s){if(!t.isBuffer(s))throw new TypeError("content is not a buffer");var a=B(n,e,r),u=j(i,e,s.length,o),c=this.channels[e].buffer;this.sentSinceLastCheck=!0;var l=a.length+u.length,f=s.length>0?s.length+O:0,h=l+f;if(T>h){var p=new t(h),d=a.copy(p,0);return d+=u.copy(p,d),f>0&&A(e,s).copy(p,d),c.write(p)}if(T>l){var v=new t(l),d=a.copy(v,0);u.copy(v,d),c.write(v)}else c.write(a),c.write(u);return this.sendContent(e,s)};var O=l.FRAME_OVERHEAD,A=h.makeBodyFrame;U.sendContent=function(e,n){if(!t.isBuffer(n))throw new TypeError(x("Expected buffer; got %s",n));for(var r=!0,i=this.channels[e].buffer,o=this.frameMax-O,s=0;sn.length?n.slice(s):n.slice(s,a),c=A(e,u);r=i.write(c)}return this.sentSinceLastCheck=!0,r};var R=h.parseFrame,L=h.decodeFrame;U.recvFrame=function(){var e=R(this.rest,this.frameMax);if(e)return this.rest=e.rest,L(e);var n=this.stream.read();return null===n?!1:(this.recvSinceLastCheck=!0,this.rest=t.concat([this.rest,n]),this.recvFrame())},e.exports.Connection=r,e.exports.isFatalError=c}).call(t,n(3).Buffer)},function(e,t,n){(function(t){/** @preserve This file is generated by the script * ../bin/generate-defs.js, which is not in general included in a * distribution, but is available in the source repository e.g. at * https://github.com/squaremo/amqp.node/ */ -"use strict";function r(e){var t,n,r=0,i={versionMajor:void 0,versionMinor:void 0,serverProperties:void 0,mechanisms:void 0,locales:void 0};return t=e[r],r++,i.versionMajor=t,t=e[r],r++,i.versionMinor=t,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.serverProperties=t,n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.mechanisms=t,n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.locales=t,i}function i(e,n){var r,i=0,o=null,s=0,a=0;if(o=n.serverProperties,void 0===o)throw new Error("Missing value for mandatory field 'serverProperties'");if("object"!=typeof o)throw new TypeError("Field 'serverProperties' is the wrong type; must be an object");r=St(Ut,o,a);var u=Ut.slice(a,a+r);if(a+=r,s+=u.length,o=n.mechanisms,void 0===o)o=new t("PLAIN");else if(!t.isBuffer(o))throw new TypeError("Field 'mechanisms' is the wrong type; must be a Buffer");if(s+=o.length,o=n.locales,void 0===o)o=new t("en_US");else if(!t.isBuffer(o))throw new TypeError("Field 'locales' is the wrong type; must be a Buffer");s+=o.length;var c=new t(22+s);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(655370,7),i=11,o=n.versionMajor,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'versionMajor' is the wrong type; must be a number (but not NaN)");if(c.writeUInt8(o,i),i++,o=n.versionMinor,void 0===o)o=9;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'versionMinor' is the wrong type; must be a number (but not NaN)");return c.writeUInt8(o,i),i++,i+=u.copy(c,i),o=n.mechanisms,void 0===o&&(o=new t("PLAIN")),r=o.length,c.writeUInt32BE(r,i),i+=4,o.copy(c,i),i+=r,o=n.locales,void 0===o&&(o=new t("en_US")),r=o.length,c.writeUInt32BE(r,i),i+=4,o.copy(c,i),i+=r,c[i]=206,c.writeUInt32BE(i-7,3),c}function o(e){var t,n,r=0,i={clientProperties:void 0,mechanism:void 0,response:void 0,locale:void 0};return n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.clientProperties=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.mechanism=t,n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.response=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.locale=t,i}function s(e,n){var r,i=0,o=null,s=0,a=0;if(o=n.clientProperties,void 0===o)throw new Error("Missing value for mandatory field 'clientProperties'");if("object"!=typeof o)throw new TypeError("Field 'clientProperties' is the wrong type; must be an object");r=St(Ut,o,a);var u=Ut.slice(a,a+r);if(a+=r,s+=u.length,o=n.mechanism,void 0===o)o="PLAIN";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'mechanism' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(s+=c,o=n.response,void 0===o)throw new Error("Missing value for mandatory field 'response'");if(!t.isBuffer(o))throw new TypeError("Field 'response' is the wrong type; must be a Buffer");if(s+=o.length,o=n.locale,void 0===o)o="en_US";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'locale' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");s+=l;var f=new t(18+s);return f[0]=1,f.writeUInt16BE(e,1),f.writeUInt32BE(655371,7),i=11,i+=u.copy(f,i),o=n.mechanism,void 0===o&&(o="PLAIN"),f[i]=c,i++,f.write(o,i,"utf8"),i+=c,o=n.response,void 0===o&&(o=new t(void 0)),r=o.length,f.writeUInt32BE(r,i),i+=4,o.copy(f,i),i+=r,o=n.locale,void 0===o&&(o="en_US"),f[i]=l,i++,f.write(o,i,"utf8"),i+=l,f[i]=206,f.writeUInt32BE(i-7,3),f}function a(e){var t,n,r=0,i={challenge:void 0};return n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.challenge=t,i}function u(e,n){var r,i=0,o=null,s=0;if(o=n.challenge,void 0===o)throw new Error("Missing value for mandatory field 'challenge'");if(!t.isBuffer(o))throw new TypeError("Field 'challenge' is the wrong type; must be a Buffer");s+=o.length;var a=new t(16+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655380,7),i=11,o=n.challenge,void 0===o&&(o=new t(void 0)),r=o.length,a.writeUInt32BE(r,i),i+=4,o.copy(a,i),i+=r,a[i]=206,a.writeUInt32BE(i-7,3),a}function c(e){var t,n,r=0,i={response:void 0};return n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.response=t,i}function l(e,n){var r,i=0,o=null,s=0;if(o=n.response,void 0===o)throw new Error("Missing value for mandatory field 'response'");if(!t.isBuffer(o))throw new TypeError("Field 'response' is the wrong type; must be a Buffer");s+=o.length;var a=new t(16+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655381,7),i=11,o=n.response,void 0===o&&(o=new t(void 0)),r=o.length,a.writeUInt32BE(r,i),i+=4,o.copy(a,i),i+=r,a[i]=206,a.writeUInt32BE(i-7,3),a}function f(e){var t,n=0,r={channelMax:void 0,frameMax:void 0,heartbeat:void 0};return t=e.readUInt16BE(n),n+=2,r.channelMax=t,t=e.readUInt32BE(n),n+=4,r.frameMax=t,t=e.readUInt16BE(n),n+=2,r.heartbeat=t,r}function h(e,n){var r=0,i=null,o=0,s=new t(20+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(655390,7),r=11,i=n.channelMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'channelMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt16BE(i,r),r+=2,i=n.frameMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'frameMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt32BE(i,r),r+=4,i=n.heartbeat,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'heartbeat' is the wrong type; must be a number (but not NaN)");return s.writeUInt16BE(i,r),r+=2,s[r]=206,s.writeUInt32BE(r-7,3),s}function p(e){var t,n=0,r={channelMax:void 0,frameMax:void 0,heartbeat:void 0};return t=e.readUInt16BE(n),n+=2,r.channelMax=t,t=e.readUInt32BE(n),n+=4,r.frameMax=t,t=e.readUInt16BE(n),n+=2,r.heartbeat=t,r}function d(e,n){var r=0,i=null,o=0,s=new t(20+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(655391,7),r=11,i=n.channelMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'channelMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt16BE(i,r),r+=2,i=n.frameMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'frameMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt32BE(i,r),r+=4,i=n.heartbeat,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'heartbeat' is the wrong type; must be a number (but not NaN)");return s.writeUInt16BE(i,r),r+=2,s[r]=206,s.writeUInt32BE(r-7,3),s}function v(e){var t,n,r=0,i={virtualHost:void 0,capabilities:void 0,insist:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.virtualHost=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.capabilities=t,t=!!(1&e[r]),i.insist=t,i}function g(e,n){var r=0,i=null,o=0,s=0;if(i=n.virtualHost,void 0===i)i="/";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'virtualHost' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.capabilities,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'capabilities' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");s+=u;var c=new t(15+s);return c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(655400,7),r=11,i=n.virtualHost,void 0===i&&(i="/"),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.capabilities,void 0===i&&(i=""),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,i=n.insist,void 0===i&&(i=!1),i&&(o+=1),c[r]=o,r++,c[r]=206,c.writeUInt32BE(r-7,3),c}function y(e){var t,n,r=0,i={knownHosts:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.knownHosts=t,i}function m(e,n){var r=0,i=null,o=0;if(i=n.knownHosts,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'knownHosts' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655401,7),r=11,i=n.knownHosts,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function b(e){var t,n,r=0,i={replyCode:void 0,replyText:void 0,classId:void 0,methodId:void 0};return t=e.readUInt16BE(r),r+=2,i.replyCode=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.replyText=t,t=e.readUInt16BE(r),r+=2,i.classId=t,t=e.readUInt16BE(r),r+=2,i.methodId=t,i}function w(e,n){var r=0,i=null,o=0;if(i=n.replyText,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(19+o);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655410,7),r=11,i=n.replyCode,void 0===i)throw new Error("Missing value for mandatory field 'replyCode'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.replyText,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,i=n.classId,void 0===i)throw new Error("Missing value for mandatory field 'classId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'classId' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.methodId,void 0===i)throw new Error("Missing value for mandatory field 'methodId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'methodId' is the wrong type; must be a number (but not NaN)");return a.writeUInt16BE(i,r),r+=2,a[r]=206,a.writeUInt32BE(r-7,3),a}function _(e){var t={};return t}function E(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(655411,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function x(e){var t,n,r=0,i={reason:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.reason=t,i}function I(e,n){var r=0,i=null,o=0;if(i=n.reason,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'reason' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655420,7),r=11,i=n.reason,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function k(e){var t={};return t}function C(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(655421,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function S(e){var t,n,r=0,i={outOfBand:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.outOfBand=t,i}function T(e,n){var r=0,i=null,o=0;if(i=n.outOfBand,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'outOfBand' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310730,7),r=11,i=n.outOfBand,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function U(e){var t,n,r=0,i={channelId:void 0};return n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.channelId=t,i}function B(e,n){var r,i=0,o=null,s=0;if(o=n.channelId,void 0===o)o=new t("");else if(!t.isBuffer(o))throw new TypeError("Field 'channelId' is the wrong type; must be a Buffer");s+=o.length;var a=new t(16+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310731,7),i=11,o=n.channelId,void 0===o&&(o=new t("")),r=o.length,a.writeUInt32BE(r,i),i+=4,o.copy(a,i),i+=r,a[i]=206,a.writeUInt32BE(i-7,3),a}function j(e){var t,n=0,r={active:void 0};return t=!!(1&e[n]),r.active=t,r}function O(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310740,7),r=11,i=n.active,void 0===i)throw new Error("Missing value for mandatory field 'active'");return i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function R(e){var t,n=0,r={active:void 0};return t=!!(1&e[n]),r.active=t,r}function A(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310741,7),r=11,i=n.active,void 0===i)throw new Error("Missing value for mandatory field 'active'");return i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function L(e){var t,n,r=0,i={replyCode:void 0,replyText:void 0,classId:void 0,methodId:void 0};return t=e.readUInt16BE(r),r+=2,i.replyCode=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.replyText=t,t=e.readUInt16BE(r),r+=2,i.classId=t,t=e.readUInt16BE(r),r+=2,i.methodId=t,i}function M(e,n){var r=0,i=null,o=0;if(i=n.replyText,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(19+o);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310760,7),r=11,i=n.replyCode,void 0===i)throw new Error("Missing value for mandatory field 'replyCode'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.replyText,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,i=n.classId,void 0===i)throw new Error("Missing value for mandatory field 'classId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'classId' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.methodId,void 0===i)throw new Error("Missing value for mandatory field 'methodId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'methodId' is the wrong type; must be a number (but not NaN)");return a.writeUInt16BE(i,r),r+=2,a[r]=206,a.writeUInt32BE(r-7,3),a}function P(e){var t={};return t}function F(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(1310761,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function N(e){var t,n,r=0,i={realm:void 0,exclusive:void 0,passive:void 0,active:void 0,write:void 0,read:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.realm=t,t=!!(1&e[r]),i.exclusive=t,t=!!(2&e[r]),i.passive=t,t=!!(4&e[r]),i.active=t,t=!!(8&e[r]),i.write=t,t=!!(16&e[r]),i.read=t,i}function D(e,n){var r=0,i=null,o=0,s=0;if(i=n.realm,void 0===i)i="/data";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'realm' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(14+s);return u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(1966090,7),r=11,i=n.realm,void 0===i&&(i="/data"),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.exclusive,void 0===i&&(i=!1),i&&(o+=1),i=n.passive,void 0===i&&(i=!0),i&&(o+=2),i=n.active,void 0===i&&(i=!0),i&&(o+=4),i=n.write,void 0===i&&(i=!0),i&&(o+=8),i=n.read,void 0===i&&(i=!0),i&&(o+=16),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function q(e){var t,n=0,r={ticket:void 0};return t=e.readUInt16BE(n),n+=2,r.ticket=t,r}function z(e,n){var r=0,i=null,o=0,s=new t(14+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(1966091,7),r=11,i=n.ticket,void 0===i)i=1;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return s.writeUInt16BE(i,r),r+=2,s[r]=206,s.writeUInt32BE(r-7,3),s}function H(e){var t,n,r=0,i={ticket:void 0,exchange:void 0,type:void 0,passive:void 0,durable:void 0,autoDelete:void 0,internal:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.type=t,t=!!(1&e[r]),i.passive=t,t=!!(2&e[r]),i.durable=t,t=!!(4&e[r]),i.autoDelete=t,t=!!(8&e[r]),i.internal=t,t=!!(16&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function Q(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.exchange,void 0===o)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.type,void 0===o)o="direct";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'type' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var f=Ut.slice(u,u+r);u+=r,a+=f.length;var h=new t(17+a);if(h[0]=1,h.writeUInt16BE(e,1),h.writeUInt32BE(2621450,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return h.writeUInt16BE(o,i),i+=2,o=n.exchange,void 0===o&&(o=void 0),h[i]=c,i++,h.write(o,i,"utf8"),i+=c,o=n.type,void 0===o&&(o="direct"),h[i]=l,i++,h.write(o,i,"utf8"),i+=l,o=n.passive,void 0===o&&(o=!1),o&&(s+=1),o=n.durable,void 0===o&&(o=!1),o&&(s+=2),o=n.autoDelete,void 0===o&&(o=!1),o&&(s+=4),o=n.internal,void 0===o&&(o=!1),o&&(s+=8),o=n.nowait,void 0===o&&(o=!1),o&&(s+=16),h[i]=s,i++,s=0,i+=f.copy(h,i),h[i]=206,h.writeUInt32BE(i-7,3),h}function W(e){var t={};return t}function K(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621451,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function Y(e){var t,n,r=0,i={ticket:void 0,exchange:void 0,ifUnused:void 0,nowait:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,t=!!(1&e[r]),i.ifUnused=t,t=!!(2&e[r]),i.nowait=t,i}function V(e,n){var r=0,i=null,o=0,s=0;if(i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(2621460,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.exchange,void 0===i&&(i=void 0),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.ifUnused,void 0===i&&(i=!1),i&&(o+=1),i=n.nowait,void 0===i&&(i=!1),i&&(o+=2),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function G(e){var t={};return t}function $(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621461,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function X(e){var t,n,r=0,i={ticket:void 0,destination:void 0,source:void 0,routingKey:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.destination=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.source=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function J(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.destination,void 0===o)throw new Error("Missing value for mandatory field 'destination'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'destination' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.source,void 0===o)throw new Error("Missing value for mandatory field 'source'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'source' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(o,"utf8");if(a+=f,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var h=Ut.slice(u,u+r);u+=r,a+=h.length;var p=new t(18+a);if(p[0]=1,p.writeUInt16BE(e,1),p.writeUInt32BE(2621470,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return p.writeUInt16BE(o,i),i+=2,o=n.destination,void 0===o&&(o=void 0),p[i]=c,i++,p.write(o,i,"utf8"),i+=c,o=n.source,void 0===o&&(o=void 0),p[i]=l,i++,p.write(o,i,"utf8"),i+=l,o=n.routingKey,void 0===o&&(o=""),p[i]=f,i++,p.write(o,i,"utf8"),i+=f,o=n.nowait,void 0===o&&(o=!1),o&&(s+=1),p[i]=s,i++,s=0,i+=h.copy(p,i),p[i]=206,p.writeUInt32BE(i-7,3),p}function Z(e){var t={};return t}function ee(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621471,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function te(e){var t,n,r=0,i={ticket:void 0,destination:void 0,source:void 0,routingKey:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.destination=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.source=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function ne(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.destination,void 0===o)throw new Error("Missing value for mandatory field 'destination'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'destination' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.source,void 0===o)throw new Error("Missing value for mandatory field 'source'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'source' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(o,"utf8");if(a+=f,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var h=Ut.slice(u,u+r);u+=r,a+=h.length;var p=new t(18+a);if(p[0]=1,p.writeUInt16BE(e,1),p.writeUInt32BE(2621480,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return p.writeUInt16BE(o,i),i+=2,o=n.destination,void 0===o&&(o=void 0),p[i]=c,i++,p.write(o,i,"utf8"),i+=c,o=n.source,void 0===o&&(o=void 0),p[i]=l,i++,p.write(o,i,"utf8"),i+=l,o=n.routingKey,void 0===o&&(o=""),p[i]=f,i++,p.write(o,i,"utf8"),i+=f,o=n.nowait,void 0===o&&(o=!1),o&&(s+=1),p[i]=s,i++,s=0,i+=h.copy(p,i),p[i]=206,p.writeUInt32BE(i-7,3),p}function re(e){var t={};return t}function ie(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621491,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function oe(e){var t,n,r=0,i={ticket:void 0,queue:void 0,passive:void 0,durable:void 0,exclusive:void 0,autoDelete:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.passive=t,t=!!(2&e[r]),i.durable=t,t=!!(4&e[r]),i.exclusive=t,t=!!(8&e[r]),i.autoDelete=t,t=!!(16&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function se(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var l=Ut.slice(u,u+r);u+=r,a+=l.length;var f=new t(16+a);if(f[0]=1,f.writeUInt16BE(e,1),f.writeUInt32BE(3276810,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return f.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),f[i]=c,i++,f.write(o,i,"utf8"),i+=c,o=n.passive,void 0===o&&(o=!1),o&&(s+=1),o=n.durable,void 0===o&&(o=!1),o&&(s+=2),o=n.exclusive,void 0===o&&(o=!1),o&&(s+=4),o=n.autoDelete,void 0===o&&(o=!1),o&&(s+=8),o=n.nowait,void 0===o&&(o=!1),o&&(s+=16),f[i]=s,i++,s=0,i+=l.copy(f,i),f[i]=206,f.writeUInt32BE(i-7,3),f}function ae(e){var t,n,r=0,i={queue:void 0,messageCount:void 0,consumerCount:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=e.readUInt32BE(r),r+=4,i.messageCount=t,t=e.readUInt32BE(r),r+=4,i.consumerCount=t,i}function ue(e,n){var r=0,i=null,o=0;if(i=n.queue,void 0===i)throw new Error("Missing value for mandatory field 'queue'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(21+o);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3276811,7),r=11,i=n.queue,void 0===i&&(i=void 0),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");if(a.writeUInt32BE(i,r),r+=4,i=n.consumerCount,void 0===i)throw new Error("Missing value for mandatory field 'consumerCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'consumerCount' is the wrong type; must be a number (but not NaN)");return a.writeUInt32BE(i,r),r+=4,a[r]=206,a.writeUInt32BE(r-7,3),a}function ce(e){var t,n,r=0,i={ticket:void 0,queue:void 0,exchange:void 0,routingKey:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function le(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.exchange,void 0===o)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(o,"utf8");if(a+=f,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var h=Ut.slice(u,u+r);u+=r,a+=h.length;var p=new t(18+a);if(p[0]=1,p.writeUInt16BE(e,1),p.writeUInt32BE(3276820,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return p.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),p[i]=c,i++,p.write(o,i,"utf8"),i+=c,o=n.exchange,void 0===o&&(o=void 0),p[i]=l,i++,p.write(o,i,"utf8"),i+=l,o=n.routingKey,void 0===o&&(o=""),p[i]=f,i++,p.write(o,i,"utf8"),i+=f,o=n.nowait,void 0===o&&(o=!1),o&&(s+=1),p[i]=s,i++,s=0,i+=h.copy(p,i),p[i]=206,p.writeUInt32BE(i-7,3),p}function fe(e){var t={};return t}function he(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3276821,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function pe(e){var t,n,r=0,i={ticket:void 0,queue:void 0,nowait:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.nowait=t,i}function de(e,n){var r=0,i=null,o=0,s=0;if(i=n.queue,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3276830,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.queue,void 0===i&&(i=""),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.nowait,void 0===i&&(i=!1),i&&(o+=1),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function ve(e){var t,n=0,r={messageCount:void 0};return t=e.readUInt32BE(n),n+=4,r.messageCount=t,r}function ge(e,n){var r=0,i=null,o=0,s=new t(16+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(3276831,7),r=11,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");return s.writeUInt32BE(i,r),r+=4,s[r]=206,s.writeUInt32BE(r-7,3),s}function ye(e){var t,n,r=0,i={ticket:void 0,queue:void 0,ifUnused:void 0,ifEmpty:void 0,nowait:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.ifUnused=t,t=!!(2&e[r]),i.ifEmpty=t,t=!!(4&e[r]),i.nowait=t,i}function me(e,n){var r=0,i=null,o=0,s=0;if(i=n.queue,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3276840,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.queue,void 0===i&&(i=""),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.ifUnused,void 0===i&&(i=!1),i&&(o+=1),i=n.ifEmpty,void 0===i&&(i=!1),i&&(o+=2),i=n.nowait,void 0===i&&(i=!1),i&&(o+=4),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function be(e){var t,n=0,r={messageCount:void 0};return t=e.readUInt32BE(n),n+=4,r.messageCount=t,r}function we(e,n){var r=0,i=null,o=0,s=new t(16+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(3276841,7),r=11,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");return s.writeUInt32BE(i,r),r+=4,s[r]=206,s.writeUInt32BE(r-7,3),s}function _e(e){var t,n,r=0,i={ticket:void 0,queue:void 0,exchange:void 0,routingKey:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function Ee(e,n){var r,i=0,o=null,s=0,a=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(o,"utf8");if(s+=u,o=n.exchange,void 0===o)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(s+=c,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(s+=l,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,a);var f=Ut.slice(a,a+r);a+=r,s+=f.length;var h=new t(17+s);if(h[0]=1,h.writeUInt16BE(e,1),h.writeUInt32BE(3276850,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)"); -return h.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),h[i]=u,i++,h.write(o,i,"utf8"),i+=u,o=n.exchange,void 0===o&&(o=void 0),h[i]=c,i++,h.write(o,i,"utf8"),i+=c,o=n.routingKey,void 0===o&&(o=""),h[i]=l,i++,h.write(o,i,"utf8"),i+=l,i+=f.copy(h,i),h[i]=206,h.writeUInt32BE(i-7,3),h}function xe(e){var t={};return t}function Ie(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3276851,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ke(e){var t,n=0,r={prefetchSize:void 0,prefetchCount:void 0,global:void 0};return t=e.readUInt32BE(n),n+=4,r.prefetchSize=t,t=e.readUInt16BE(n),n+=2,r.prefetchCount=t,t=!!(1&e[n]),r.global=t,r}function Ce(e,n){var r=0,i=null,o=0,s=0,a=new t(19+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932170,7),r=11,i=n.prefetchSize,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'prefetchSize' is the wrong type; must be a number (but not NaN)");if(a.writeUInt32BE(i,r),r+=4,i=n.prefetchCount,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'prefetchCount' is the wrong type; must be a number (but not NaN)");return a.writeUInt16BE(i,r),r+=2,i=n.global,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function Se(e){var t={};return t}function Te(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3932171,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function Ue(e){var t,n,r=0,i={ticket:void 0,queue:void 0,consumerTag:void 0,noLocal:void 0,noAck:void 0,exclusive:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,t=!!(1&e[r]),i.noLocal=t,t=!!(2&e[r]),i.noAck=t,t=!!(4&e[r]),i.exclusive=t,t=!!(8&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function Be(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.consumerTag,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var f=Ut.slice(u,u+r);u+=r,a+=f.length;var h=new t(17+a);if(h[0]=1,h.writeUInt16BE(e,1),h.writeUInt32BE(3932180,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return h.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),h[i]=c,i++,h.write(o,i,"utf8"),i+=c,o=n.consumerTag,void 0===o&&(o=""),h[i]=l,i++,h.write(o,i,"utf8"),i+=l,o=n.noLocal,void 0===o&&(o=!1),o&&(s+=1),o=n.noAck,void 0===o&&(o=!1),o&&(s+=2),o=n.exclusive,void 0===o&&(o=!1),o&&(s+=4),o=n.nowait,void 0===o&&(o=!1),o&&(s+=8),h[i]=s,i++,s=0,i+=f.copy(h,i),h[i]=206,h.writeUInt32BE(i-7,3),h}function je(e){var t,n,r=0,i={consumerTag:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,i}function Oe(e,n){var r=0,i=null,o=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932181,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function Re(e){var t,n,r=0,i={consumerTag:void 0,nowait:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,t=!!(1&e[r]),i.nowait=t,i}function Ae(e,n){var r=0,i=null,o=0,s=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(14+s);return u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3932190,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.nowait,void 0===i&&(i=!1),i&&(o+=1),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function Le(e){var t,n,r=0,i={consumerTag:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,i}function Me(e,n){var r=0,i=null,o=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932191,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function Pe(e){var t,n,r=0,i={ticket:void 0,exchange:void 0,routingKey:void 0,mandatory:void 0,immediate:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.mandatory=t,t=!!(2&e[r]),i.immediate=t,i}function Fe(e,n){var r=0,i=null,o=0,s=0;if(i=n.exchange,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.routingKey,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");s+=u;var c=new t(17+s);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(3932200,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return c.writeUInt16BE(i,r),r+=2,i=n.exchange,void 0===i&&(i=""),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.routingKey,void 0===i&&(i=""),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,i=n.mandatory,void 0===i&&(i=!1),i&&(o+=1),i=n.immediate,void 0===i&&(i=!1),i&&(o+=2),c[r]=o,r++,c[r]=206,c.writeUInt32BE(r-7,3),c}function Ne(e){var t,n,r=0,i={replyCode:void 0,replyText:void 0,exchange:void 0,routingKey:void 0};return t=e.readUInt16BE(r),r+=2,i.replyCode=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.replyText=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,i}function De(e,n){var r=0,i=null,o=0;if(i=n.replyText,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");if(o+=s,i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(o+=a,i=n.routingKey,void 0===i)throw new Error("Missing value for mandatory field 'routingKey'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");o+=u;var c=new t(17+o);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(3932210,7),r=11,i=n.replyCode,void 0===i)throw new Error("Missing value for mandatory field 'replyCode'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)");return c.writeUInt16BE(i,r),r+=2,i=n.replyText,void 0===i&&(i=""),c[r]=s,r++,c.write(i,r,"utf8"),r+=s,i=n.exchange,void 0===i&&(i=void 0),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.routingKey,void 0===i&&(i=void 0),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,c[r]=206,c.writeUInt32BE(r-7,3),c}function qe(e){var t,n,r=0,i={consumerTag:void 0,deliveryTag:void 0,redelivered:void 0,exchange:void 0,routingKey:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,t=Ct.readUInt64BE(e,r),r+=8,i.deliveryTag=t,t=!!(1&e[r]),i.redelivered=t,r++,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,i}function ze(e,n){var r=0,i=null,o=0,s=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");if(s+=u,i=n.routingKey,void 0===i)throw new Error("Missing value for mandatory field 'routingKey'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(i,"utf8");s+=c;var l=new t(24+s);if(l[0]=1,l.writeUInt16BE(e,1),l.writeUInt32BE(3932220,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),l[r]=a,r++,l.write(i,r,"utf8"),r+=a,i=n.deliveryTag,void 0===i)throw new Error("Missing value for mandatory field 'deliveryTag'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(l,i,r),r+=8,i=n.redelivered,void 0===i&&(i=!1),i&&(o+=1),l[r]=o,r++,o=0,i=n.exchange,void 0===i&&(i=void 0),l[r]=u,r++,l.write(i,r,"utf8"),r+=u,i=n.routingKey,void 0===i&&(i=void 0),l[r]=c,r++,l.write(i,r,"utf8"),r+=c,l[r]=206,l.writeUInt32BE(r-7,3),l}function He(e){var t,n,r=0,i={ticket:void 0,queue:void 0,noAck:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.noAck=t,i}function Qe(e,n){var r=0,i=null,o=0,s=0;if(i=n.queue,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3932230,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.queue,void 0===i&&(i=""),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.noAck,void 0===i&&(i=!1),i&&(o+=1),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function We(e){var t,n,r=0,i={deliveryTag:void 0,redelivered:void 0,exchange:void 0,routingKey:void 0,messageCount:void 0};return t=Ct.readUInt64BE(e,r),r+=8,i.deliveryTag=t,t=!!(1&e[r]),i.redelivered=t,r++,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=e.readUInt32BE(r),r+=4,i.messageCount=t,i}function Ke(e,n){var r=0,i=null,o=0,s=0;if(i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.routingKey,void 0===i)throw new Error("Missing value for mandatory field 'routingKey'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");s+=u;var c=new t(27+s);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(3932231,7),r=11,i=n.deliveryTag,void 0===i)throw new Error("Missing value for mandatory field 'deliveryTag'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");if(Ct.writeUInt64BE(c,i,r),r+=8,i=n.redelivered,void 0===i&&(i=!1),i&&(o+=1),c[r]=o,r++,o=0,i=n.exchange,void 0===i&&(i=void 0),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.routingKey,void 0===i&&(i=void 0),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");return c.writeUInt32BE(i,r),r+=4,c[r]=206,c.writeUInt32BE(r-7,3),c}function Ye(e){var t,n,r=0,i={clusterId:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.clusterId=t,i}function Ve(e,n){var r=0,i=null,o=0;if(i=n.clusterId,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'clusterId' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932232,7),r=11,i=n.clusterId,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function Ge(e){var t,n=0,r={deliveryTag:void 0,multiple:void 0};return t=Ct.readUInt64BE(e,n),n+=8,r.deliveryTag=t,t=!!(1&e[n]),r.multiple=t,r}function $e(e,n){var r=0,i=null,o=0,s=0,a=new t(21+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932240,7),r=11,i=n.deliveryTag,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(a,i,r),r+=8,i=n.multiple,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function Xe(e){var t,n=0,r={deliveryTag:void 0,requeue:void 0};return t=Ct.readUInt64BE(e,n),n+=8,r.deliveryTag=t,t=!!(1&e[n]),r.requeue=t,r}function Je(e,n){var r=0,i=null,o=0,s=0,a=new t(21+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932250,7),r=11,i=n.deliveryTag,void 0===i)throw new Error("Missing value for mandatory field 'deliveryTag'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(a,i,r),r+=8,i=n.requeue,void 0===i&&(i=!0),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function Ze(e){var t,n=0,r={requeue:void 0};return t=!!(1&e[n]),r.requeue=t,r}function et(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932260,7),r=11,i=n.requeue,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function tt(e){var t,n=0,r={requeue:void 0};return t=!!(1&e[n]),r.requeue=t,r}function nt(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932270,7),r=11,i=n.requeue,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function rt(e){var t={};return t}function it(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3932271,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ot(e){var t,n=0,r={deliveryTag:void 0,multiple:void 0,requeue:void 0};return t=Ct.readUInt64BE(e,n),n+=8,r.deliveryTag=t,t=!!(1&e[n]),r.multiple=t,t=!!(2&e[n]),r.requeue=t,r}function st(e,n){var r=0,i=null,o=0,s=0,a=new t(21+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932280,7),r=11,i=n.deliveryTag,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(a,i,r),r+=8,i=n.multiple,void 0===i&&(i=!1),i&&(o+=1),i=n.requeue,void 0===i&&(i=!0),i&&(o+=2),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function at(e){var t={};return t}function ut(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898250,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ct(e){var t={};return t}function lt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898251,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ft(e){var t={};return t}function ht(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898260,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function pt(e){var t={};return t}function dt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898261,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function vt(e){var t={};return t}function gt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898270,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function yt(e){var t={};return t}function mt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898271,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function bt(e){var t,n=0,r={nowait:void 0};return t=!!(1&e[n]),r.nowait=t,r}function wt(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(5570570,7),r=11,i=n.nowait,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function _t(e){var t={};return t}function Et(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5570571,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function xt(e,n,r){var i,o,s=0,a=0,u=0,c=0;if(i=r.contentType,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'contentType' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(i,"utf8");c+=1,c+=l}if(i=r.contentEncoding,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'contentEncoding' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(i,"utf8");c+=1,c+=f}if(i=r.headers,void 0!=i){if("object"!=typeof i)throw new TypeError("Field 'headers' is the wrong type; must be an object");o=St(Ut,i,u);var h=Ut.slice(u,u+o);u+=o,c+=h.length}if(i=r.deliveryMode,void 0!=i){if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryMode' is the wrong type; must be a number (but not NaN)");c+=1}if(i=r.priority,void 0!=i){if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'priority' is the wrong type; must be a number (but not NaN)");c+=1}if(i=r.correlationId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'correlationId' is the wrong type; must be a string (up to 255 chars)");var p=t.byteLength(i,"utf8");c+=1,c+=p}if(i=r.replyTo,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyTo' is the wrong type; must be a string (up to 255 chars)");var d=t.byteLength(i,"utf8");c+=1,c+=d}if(i=r.expiration,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'expiration' is the wrong type; must be a string (up to 255 chars)");var v=t.byteLength(i,"utf8");c+=1,c+=v}if(i=r.messageId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'messageId' is the wrong type; must be a string (up to 255 chars)");var g=t.byteLength(i,"utf8");c+=1,c+=g}if(i=r.timestamp,void 0!=i){if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'timestamp' is the wrong type; must be a number (but not NaN)");c+=8}if(i=r.type,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'type' is the wrong type; must be a string (up to 255 chars)");var y=t.byteLength(i,"utf8");c+=1,c+=y}if(i=r.userId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'userId' is the wrong type; must be a string (up to 255 chars)");var m=t.byteLength(i,"utf8");c+=1,c+=m}if(i=r.appId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'appId' is the wrong type; must be a string (up to 255 chars)");var b=t.byteLength(i,"utf8");c+=1,c+=b}if(i=r.clusterId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'clusterId' is the wrong type; must be a string (up to 255 chars)");var w=t.byteLength(i,"utf8");c+=1,c+=w}var _=new t(22+c);return _[0]=2,_.writeUInt16BE(e,1),_.writeUInt32BE(3932160,7),Ct.writeUInt64BE(_,n,11),a=0,s=21,i=r.contentType,void 0!=i&&(a+=32768,_[s]=l,s++,_.write(i,s,"utf8"),s+=l),i=r.contentEncoding,void 0!=i&&(a+=16384,_[s]=f,s++,_.write(i,s,"utf8"),s+=f),i=r.headers,void 0!=i&&(a+=8192,s+=h.copy(_,s)),i=r.deliveryMode,void 0!=i&&(a+=4096,_.writeUInt8(i,s),s++),i=r.priority,void 0!=i&&(a+=2048,_.writeUInt8(i,s),s++),i=r.correlationId,void 0!=i&&(a+=1024,_[s]=p,s++,_.write(i,s,"utf8"),s+=p),i=r.replyTo,void 0!=i&&(a+=512,_[s]=d,s++,_.write(i,s,"utf8"),s+=d),i=r.expiration,void 0!=i&&(a+=256,_[s]=v,s++,_.write(i,s,"utf8"),s+=v),i=r.messageId,void 0!=i&&(a+=128,_[s]=g,s++,_.write(i,s,"utf8"),s+=g),i=r.timestamp,void 0!=i&&(a+=64,Ct.writeUInt64BE(_,i,s),s+=8),i=r.type,void 0!=i&&(a+=32,_[s]=y,s++,_.write(i,s,"utf8"),s+=y),i=r.userId,void 0!=i&&(a+=16,_[s]=m,s++,_.write(i,s,"utf8"),s+=m),i=r.appId,void 0!=i&&(a+=8,_[s]=b,s++,_.write(i,s,"utf8"),s+=b),i=r.clusterId,void 0!=i&&(a+=4,_[s]=w,s++,_.write(i,s,"utf8"),s+=w),_[s]=206,_.writeUInt32BE(s-7,3),_.writeUInt16BE(a,19),_.slice(0,s+1)}function It(e){var t,n,r,i=2;if(t=e.readUInt16BE(0),0===t)return{};var o={contentType:void 0,contentEncoding:void 0,headers:void 0,deliveryMode:void 0,priority:void 0,correlationId:void 0,replyTo:void 0,expiration:void 0,messageId:void 0,timestamp:void 0,type:void 0,userId:void 0,appId:void 0,clusterId:void 0};return 32768&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.contentType=n),16384&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.contentEncoding=n),8192&t&&(r=e.readUInt32BE(i),i+=4,n=Tt(e.slice(i,i+r)),i+=r,o.headers=n),4096&t&&(n=e[i],i++,o.deliveryMode=n),2048&t&&(n=e[i],i++,o.priority=n),1024&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.correlationId=n),512&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.replyTo=n),256&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.expiration=n),128&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.messageId=n),64&t&&(n=Ct.readUInt64BE(e,i),i+=8,o.timestamp=n),32&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.type=n),16&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.userId=n),8&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.appId=n),4&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.clusterId=n),o}var kt=n(68),Ct=n(69),St=kt.encodeTable,Tt=kt.decodeFields,Ut=new t(4096);Object.freeze({});e.exports.constants={FRAME_METHOD:1,FRAME_HEADER:2,FRAME_BODY:3,FRAME_HEARTBEAT:8,FRAME_MIN_SIZE:4096,FRAME_END:206,REPLY_SUCCESS:200,CONTENT_TOO_LARGE:311,NO_ROUTE:312,NO_CONSUMERS:313,ACCESS_REFUSED:403,NOT_FOUND:404,RESOURCE_LOCKED:405,PRECONDITION_FAILED:406,CONNECTION_FORCED:320,INVALID_PATH:402,FRAME_ERROR:501,SYNTAX_ERROR:502,COMMAND_INVALID:503,CHANNEL_ERROR:504,UNEXPECTED_FRAME:505,RESOURCE_ERROR:506,NOT_ALLOWED:530,NOT_IMPLEMENTED:540,INTERNAL_ERROR:541},e.exports.constant_strs={1:"FRAME-METHOD",2:"FRAME-HEADER",3:"FRAME-BODY",8:"FRAME-HEARTBEAT",200:"REPLY-SUCCESS",206:"FRAME-END",311:"CONTENT-TOO-LARGE",312:"NO-ROUTE",313:"NO-CONSUMERS",320:"CONNECTION-FORCED",402:"INVALID-PATH",403:"ACCESS-REFUSED",404:"NOT-FOUND",405:"RESOURCE-LOCKED",406:"PRECONDITION-FAILED",501:"FRAME-ERROR",502:"SYNTAX-ERROR",503:"COMMAND-INVALID",504:"CHANNEL-ERROR",505:"UNEXPECTED-FRAME",506:"RESOURCE-ERROR",530:"NOT-ALLOWED",540:"NOT-IMPLEMENTED",541:"INTERNAL-ERROR",4096:"FRAME-MIN-SIZE"},e.exports.FRAME_OVERHEAD=8,e.exports.decode=function(e,t){switch(e){case 655370:return r(t);case 655371:return o(t);case 655380:return a(t);case 655381:return c(t);case 655390:return f(t);case 655391:return p(t);case 655400:return v(t);case 655401:return y(t);case 655410:return b(t);case 655411:return _(t);case 655420:return x(t);case 655421:return k(t);case 1310730:return S(t);case 1310731:return U(t);case 1310740:return j(t);case 1310741:return R(t);case 1310760:return L(t);case 1310761:return P(t);case 1966090:return N(t);case 1966091:return q(t);case 2621450:return H(t);case 2621451:return W(t);case 2621460:return Y(t);case 2621461:return G(t);case 2621470:return X(t);case 2621471:return Z(t);case 2621480:return te(t);case 2621491:return re(t);case 3276810:return oe(t);case 3276811:return ae(t);case 3276820:return ce(t);case 3276821:return fe(t);case 3276830:return pe(t);case 3276831:return ve(t);case 3276840:return ye(t);case 3276841:return be(t);case 3276850:return _e(t);case 3276851:return xe(t);case 3932170:return ke(t);case 3932171:return Se(t);case 3932180:return Ue(t);case 3932181:return je(t);case 3932190:return Re(t);case 3932191:return Le(t);case 3932200:return Pe(t);case 3932210:return Ne(t);case 3932220:return qe(t);case 3932230:return He(t);case 3932231:return We(t);case 3932232:return Ye(t);case 3932240:return Ge(t);case 3932250:return Xe(t);case 3932260:return Ze(t);case 3932270:return tt(t);case 3932271:return rt(t);case 3932280:return ot(t);case 5898250:return at(t);case 5898251:return ct(t);case 5898260:return ft(t);case 5898261:return pt(t);case 5898270:return vt(t);case 5898271:return yt(t);case 5570570:return bt(t);case 5570571:return _t(t);case 60:return It(t);default:throw new Error("Unknown class/method ID")}},e.exports.encodeMethod=function(e,t,n){switch(e){case 655370:return i(t,n);case 655371:return s(t,n);case 655380:return u(t,n);case 655381:return l(t,n);case 655390:return h(t,n);case 655391:return d(t,n);case 655400:return g(t,n);case 655401:return m(t,n);case 655410:return w(t,n);case 655411:return E(t,n);case 655420:return I(t,n);case 655421:return C(t,n);case 1310730:return T(t,n);case 1310731:return B(t,n);case 1310740:return O(t,n);case 1310741:return A(t,n);case 1310760:return M(t,n);case 1310761:return F(t,n);case 1966090:return D(t,n);case 1966091:return z(t,n);case 2621450:return Q(t,n);case 2621451:return K(t,n);case 2621460:return V(t,n);case 2621461:return $(t,n);case 2621470:return J(t,n);case 2621471:return ee(t,n);case 2621480:return ne(t,n);case 2621491:return ie(t,n);case 3276810:return se(t,n);case 3276811:return ue(t,n);case 3276820:return le(t,n);case 3276821:return he(t,n);case 3276830:return de(t,n);case 3276831:return ge(t,n);case 3276840:return me(t,n);case 3276841:return we(t,n);case 3276850:return Ee(t,n);case 3276851:return Ie(t,n);case 3932170:return Ce(t,n);case 3932171:return Te(t,n);case 3932180:return Be(t,n);case 3932181:return Oe(t,n);case 3932190:return Ae(t,n);case 3932191:return Me(t,n);case 3932200:return Fe(t,n);case 3932210:return De(t,n);case 3932220:return ze(t,n);case 3932230:return Qe(t,n);case 3932231:return Ke(t,n);case 3932232:return Ve(t,n);case 3932240:return $e(t,n);case 3932250:return Je(t,n);case 3932260:return et(t,n);case 3932270:return nt(t,n);case 3932271:return it(t,n);case 3932280:return st(t,n);case 5898250:return ut(t,n);case 5898251:return lt(t,n);case 5898260:return ht(t,n);case 5898261:return dt(t,n);case 5898270:return gt(t,n);case 5898271:return mt(t,n);case 5570570:return wt(t,n);case 5570571:return Et(t,n);default:throw new Error("Unknown class/method ID")}},e.exports.encodeProperties=function(e,t,n,r){switch(e){case 60:return xt(t,n,r);default:throw new Error("Unknown class/properties ID")}},e.exports.info=function(e){switch(e){case 655370:return Bt;case 655371:return jt;case 655380:return Ot;case 655381:return Rt;case 655390:return At;case 655391:return Lt;case 655400:return Mt;case 655401:return Pt;case 655410:return Ft;case 655411:return Nt;case 655420:return Dt;case 655421:return qt;case 1310730:return zt;case 1310731:return Ht;case 1310740:return Qt;case 1310741:return Wt;case 1310760:return Kt;case 1310761:return Yt;case 1966090:return Vt;case 1966091:return Gt;case 2621450:return $t;case 2621451:return Xt;case 2621460:return Jt;case 2621461:return Zt;case 2621470:return en;case 2621471:return tn;case 2621480:return nn;case 2621491:return rn;case 3276810:return on;case 3276811:return sn;case 3276820:return an;case 3276821:return un;case 3276830:return cn;case 3276831:return ln;case 3276840:return fn;case 3276841:return hn;case 3276850:return pn;case 3276851:return dn;case 3932170:return vn;case 3932171:return gn;case 3932180:return yn;case 3932181:return mn;case 3932190:return bn;case 3932191:return wn;case 3932200:return _n;case 3932210:return En;case 3932220:return xn;case 3932230:return In;case 3932231:return kn;case 3932232:return Cn;case 3932240:return Sn;case 3932250:return Tn;case 3932260:return Un;case 3932270:return Bn;case 3932271:return jn;case 3932280:return On;case 5898250:return Rn;case 5898251:return An;case 5898260:return Ln;case 5898261:return Mn;case 5898270:return Pn;case 5898271:return Fn;case 5570570:return Nn;case 5570571:return Dn;case 60:return qn;default:throw new Error("Unknown class/method ID")}},e.exports.ConnectionStart=655370;var Bt=e.exports.methodInfoConnectionStart={id:655370,name:"ConnectionStart",args:[{type:"octet",name:"versionMajor","default":0},{type:"octet",name:"versionMinor","default":9},{type:"table",name:"serverProperties"},{type:"longstr",name:"mechanisms","default":"PLAIN"},{type:"longstr",name:"locales","default":"en_US"}]};e.exports.ConnectionStartOk=655371;var jt=e.exports.methodInfoConnectionStartOk={id:655371,name:"ConnectionStartOk",args:[{type:"table",name:"clientProperties"},{type:"shortstr",name:"mechanism","default":"PLAIN"},{type:"longstr",name:"response"},{type:"shortstr",name:"locale","default":"en_US"}]};e.exports.ConnectionSecure=655380;var Ot=e.exports.methodInfoConnectionSecure={id:655380,name:"ConnectionSecure",args:[{type:"longstr",name:"challenge"}]};e.exports.ConnectionSecureOk=655381;var Rt=e.exports.methodInfoConnectionSecureOk={id:655381,name:"ConnectionSecureOk",args:[{type:"longstr",name:"response"}]};e.exports.ConnectionTune=655390;var At=e.exports.methodInfoConnectionTune={id:655390,name:"ConnectionTune",args:[{type:"short",name:"channelMax","default":0},{type:"long",name:"frameMax","default":0},{type:"short",name:"heartbeat","default":0}]};e.exports.ConnectionTuneOk=655391;var Lt=e.exports.methodInfoConnectionTuneOk={id:655391,name:"ConnectionTuneOk",args:[{type:"short",name:"channelMax","default":0},{type:"long",name:"frameMax","default":0},{type:"short",name:"heartbeat","default":0}]};e.exports.ConnectionOpen=655400;var Mt=e.exports.methodInfoConnectionOpen={id:655400,name:"ConnectionOpen",args:[{type:"shortstr",name:"virtualHost","default":"/"},{type:"shortstr",name:"capabilities","default":""},{type:"bit",name:"insist","default":!1}]};e.exports.ConnectionOpenOk=655401;var Pt=e.exports.methodInfoConnectionOpenOk={id:655401,name:"ConnectionOpenOk",args:[{type:"shortstr",name:"knownHosts","default":""}]};e.exports.ConnectionClose=655410;var Ft=e.exports.methodInfoConnectionClose={id:655410,name:"ConnectionClose",args:[{type:"short",name:"replyCode"},{type:"shortstr",name:"replyText","default":""},{type:"short",name:"classId"},{type:"short",name:"methodId"}]};e.exports.ConnectionCloseOk=655411;var Nt=e.exports.methodInfoConnectionCloseOk={id:655411,name:"ConnectionCloseOk",args:[]};e.exports.ConnectionBlocked=655420;var Dt=e.exports.methodInfoConnectionBlocked={id:655420,name:"ConnectionBlocked",args:[{type:"shortstr",name:"reason","default":""}]};e.exports.ConnectionUnblocked=655421;var qt=e.exports.methodInfoConnectionUnblocked={id:655421,name:"ConnectionUnblocked",args:[]};e.exports.ChannelOpen=1310730;var zt=e.exports.methodInfoChannelOpen={id:1310730,name:"ChannelOpen",args:[{type:"shortstr",name:"outOfBand","default":""}]};e.exports.ChannelOpenOk=1310731;var Ht=e.exports.methodInfoChannelOpenOk={id:1310731,name:"ChannelOpenOk",args:[{type:"longstr",name:"channelId","default":""}]};e.exports.ChannelFlow=1310740;var Qt=e.exports.methodInfoChannelFlow={id:1310740,name:"ChannelFlow",args:[{type:"bit",name:"active" -}]};e.exports.ChannelFlowOk=1310741;var Wt=e.exports.methodInfoChannelFlowOk={id:1310741,name:"ChannelFlowOk",args:[{type:"bit",name:"active"}]};e.exports.ChannelClose=1310760;var Kt=e.exports.methodInfoChannelClose={id:1310760,name:"ChannelClose",args:[{type:"short",name:"replyCode"},{type:"shortstr",name:"replyText","default":""},{type:"short",name:"classId"},{type:"short",name:"methodId"}]};e.exports.ChannelCloseOk=1310761;var Yt=e.exports.methodInfoChannelCloseOk={id:1310761,name:"ChannelCloseOk",args:[]};e.exports.AccessRequest=1966090;var Vt=e.exports.methodInfoAccessRequest={id:1966090,name:"AccessRequest",args:[{type:"shortstr",name:"realm","default":"/data"},{type:"bit",name:"exclusive","default":!1},{type:"bit",name:"passive","default":!0},{type:"bit",name:"active","default":!0},{type:"bit",name:"write","default":!0},{type:"bit",name:"read","default":!0}]};e.exports.AccessRequestOk=1966091;var Gt=e.exports.methodInfoAccessRequestOk={id:1966091,name:"AccessRequestOk",args:[{type:"short",name:"ticket","default":1}]};e.exports.ExchangeDeclare=2621450;var $t=e.exports.methodInfoExchangeDeclare={id:2621450,name:"ExchangeDeclare",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"type","default":"direct"},{type:"bit",name:"passive","default":!1},{type:"bit",name:"durable","default":!1},{type:"bit",name:"autoDelete","default":!1},{type:"bit",name:"internal","default":!1},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.ExchangeDeclareOk=2621451;var Xt=e.exports.methodInfoExchangeDeclareOk={id:2621451,name:"ExchangeDeclareOk",args:[]};e.exports.ExchangeDelete=2621460;var Jt=e.exports.methodInfoExchangeDelete={id:2621460,name:"ExchangeDelete",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"exchange"},{type:"bit",name:"ifUnused","default":!1},{type:"bit",name:"nowait","default":!1}]};e.exports.ExchangeDeleteOk=2621461;var Zt=e.exports.methodInfoExchangeDeleteOk={id:2621461,name:"ExchangeDeleteOk",args:[]};e.exports.ExchangeBind=2621470;var en=e.exports.methodInfoExchangeBind={id:2621470,name:"ExchangeBind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"destination"},{type:"shortstr",name:"source"},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.ExchangeBindOk=2621471;var tn=e.exports.methodInfoExchangeBindOk={id:2621471,name:"ExchangeBindOk",args:[]};e.exports.ExchangeUnbind=2621480;var nn=e.exports.methodInfoExchangeUnbind={id:2621480,name:"ExchangeUnbind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"destination"},{type:"shortstr",name:"source"},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.ExchangeUnbindOk=2621491;var rn=e.exports.methodInfoExchangeUnbindOk={id:2621491,name:"ExchangeUnbindOk",args:[]};e.exports.QueueDeclare=3276810;var on=e.exports.methodInfoQueueDeclare={id:3276810,name:"QueueDeclare",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"passive","default":!1},{type:"bit",name:"durable","default":!1},{type:"bit",name:"exclusive","default":!1},{type:"bit",name:"autoDelete","default":!1},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.QueueDeclareOk=3276811;var sn=e.exports.methodInfoQueueDeclareOk={id:3276811,name:"QueueDeclareOk",args:[{type:"shortstr",name:"queue"},{type:"long",name:"messageCount"},{type:"long",name:"consumerCount"}]};e.exports.QueueBind=3276820;var an=e.exports.methodInfoQueueBind={id:3276820,name:"QueueBind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.QueueBindOk=3276821;var un=e.exports.methodInfoQueueBindOk={id:3276821,name:"QueueBindOk",args:[]};e.exports.QueuePurge=3276830;var cn=e.exports.methodInfoQueuePurge={id:3276830,name:"QueuePurge",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"nowait","default":!1}]};e.exports.QueuePurgeOk=3276831;var ln=e.exports.methodInfoQueuePurgeOk={id:3276831,name:"QueuePurgeOk",args:[{type:"long",name:"messageCount"}]};e.exports.QueueDelete=3276840;var fn=e.exports.methodInfoQueueDelete={id:3276840,name:"QueueDelete",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"ifUnused","default":!1},{type:"bit",name:"ifEmpty","default":!1},{type:"bit",name:"nowait","default":!1}]};e.exports.QueueDeleteOk=3276841;var hn=e.exports.methodInfoQueueDeleteOk={id:3276841,name:"QueueDeleteOk",args:[{type:"long",name:"messageCount"}]};e.exports.QueueUnbind=3276850;var pn=e.exports.methodInfoQueueUnbind={id:3276850,name:"QueueUnbind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey","default":""},{type:"table",name:"arguments","default":{}}]};e.exports.QueueUnbindOk=3276851;var dn=e.exports.methodInfoQueueUnbindOk={id:3276851,name:"QueueUnbindOk",args:[]};e.exports.BasicQos=3932170;var vn=e.exports.methodInfoBasicQos={id:3932170,name:"BasicQos",args:[{type:"long",name:"prefetchSize","default":0},{type:"short",name:"prefetchCount","default":0},{type:"bit",name:"global","default":!1}]};e.exports.BasicQosOk=3932171;var gn=e.exports.methodInfoBasicQosOk={id:3932171,name:"BasicQosOk",args:[]};e.exports.BasicConsume=3932180;var yn=e.exports.methodInfoBasicConsume={id:3932180,name:"BasicConsume",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"shortstr",name:"consumerTag","default":""},{type:"bit",name:"noLocal","default":!1},{type:"bit",name:"noAck","default":!1},{type:"bit",name:"exclusive","default":!1},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.BasicConsumeOk=3932181;var mn=e.exports.methodInfoBasicConsumeOk={id:3932181,name:"BasicConsumeOk",args:[{type:"shortstr",name:"consumerTag"}]};e.exports.BasicCancel=3932190;var bn=e.exports.methodInfoBasicCancel={id:3932190,name:"BasicCancel",args:[{type:"shortstr",name:"consumerTag"},{type:"bit",name:"nowait","default":!1}]};e.exports.BasicCancelOk=3932191;var wn=e.exports.methodInfoBasicCancelOk={id:3932191,name:"BasicCancelOk",args:[{type:"shortstr",name:"consumerTag"}]};e.exports.BasicPublish=3932200;var _n=e.exports.methodInfoBasicPublish={id:3932200,name:"BasicPublish",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"exchange","default":""},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"mandatory","default":!1},{type:"bit",name:"immediate","default":!1}]};e.exports.BasicReturn=3932210;var En=e.exports.methodInfoBasicReturn={id:3932210,name:"BasicReturn",args:[{type:"short",name:"replyCode"},{type:"shortstr",name:"replyText","default":""},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey"}]};e.exports.BasicDeliver=3932220;var xn=e.exports.methodInfoBasicDeliver={id:3932220,name:"BasicDeliver",args:[{type:"shortstr",name:"consumerTag"},{type:"longlong",name:"deliveryTag"},{type:"bit",name:"redelivered","default":!1},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey"}]};e.exports.BasicGet=3932230;var In=e.exports.methodInfoBasicGet={id:3932230,name:"BasicGet",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"noAck","default":!1}]};e.exports.BasicGetOk=3932231;var kn=e.exports.methodInfoBasicGetOk={id:3932231,name:"BasicGetOk",args:[{type:"longlong",name:"deliveryTag"},{type:"bit",name:"redelivered","default":!1},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey"},{type:"long",name:"messageCount"}]};e.exports.BasicGetEmpty=3932232;var Cn=e.exports.methodInfoBasicGetEmpty={id:3932232,name:"BasicGetEmpty",args:[{type:"shortstr",name:"clusterId","default":""}]};e.exports.BasicAck=3932240;var Sn=e.exports.methodInfoBasicAck={id:3932240,name:"BasicAck",args:[{type:"longlong",name:"deliveryTag","default":0},{type:"bit",name:"multiple","default":!1}]};e.exports.BasicReject=3932250;var Tn=e.exports.methodInfoBasicReject={id:3932250,name:"BasicReject",args:[{type:"longlong",name:"deliveryTag"},{type:"bit",name:"requeue","default":!0}]};e.exports.BasicRecoverAsync=3932260;var Un=e.exports.methodInfoBasicRecoverAsync={id:3932260,name:"BasicRecoverAsync",args:[{type:"bit",name:"requeue","default":!1}]};e.exports.BasicRecover=3932270;var Bn=e.exports.methodInfoBasicRecover={id:3932270,name:"BasicRecover",args:[{type:"bit",name:"requeue","default":!1}]};e.exports.BasicRecoverOk=3932271;var jn=e.exports.methodInfoBasicRecoverOk={id:3932271,name:"BasicRecoverOk",args:[]};e.exports.BasicNack=3932280;var On=e.exports.methodInfoBasicNack={id:3932280,name:"BasicNack",args:[{type:"longlong",name:"deliveryTag","default":0},{type:"bit",name:"multiple","default":!1},{type:"bit",name:"requeue","default":!0}]};e.exports.TxSelect=5898250;var Rn=e.exports.methodInfoTxSelect={id:5898250,name:"TxSelect",args:[]};e.exports.TxSelectOk=5898251;var An=e.exports.methodInfoTxSelectOk={id:5898251,name:"TxSelectOk",args:[]};e.exports.TxCommit=5898260;var Ln=e.exports.methodInfoTxCommit={id:5898260,name:"TxCommit",args:[]};e.exports.TxCommitOk=5898261;var Mn=e.exports.methodInfoTxCommitOk={id:5898261,name:"TxCommitOk",args:[]};e.exports.TxRollback=5898270;var Pn=e.exports.methodInfoTxRollback={id:5898270,name:"TxRollback",args:[]};e.exports.TxRollbackOk=5898271;var Fn=e.exports.methodInfoTxRollbackOk={id:5898271,name:"TxRollbackOk",args:[]};e.exports.ConfirmSelect=5570570;var Nn=e.exports.methodInfoConfirmSelect={id:5570570,name:"ConfirmSelect",args:[{type:"bit",name:"nowait","default":!1}]};e.exports.ConfirmSelectOk=5570571;var Dn=e.exports.methodInfoConfirmSelectOk={id:5570571,name:"ConfirmSelectOk",args:[]};e.exports.BasicProperties=60;var qn=e.exports.propertiesInfoBasicProperties={id:60,name:"BasicProperties",args:[{type:"shortstr",name:"contentType"},{type:"shortstr",name:"contentEncoding"},{type:"table",name:"headers"},{type:"octet",name:"deliveryMode"},{type:"octet",name:"priority"},{type:"shortstr",name:"correlationId"},{type:"shortstr",name:"replyTo"},{type:"shortstr",name:"expiration"},{type:"shortstr",name:"messageId"},{type:"timestamp",name:"timestamp"},{type:"shortstr",name:"type"},{type:"shortstr",name:"userId"},{type:"shortstr",name:"appId"},{type:"shortstr",name:"clusterId"}]}}).call(t,n(3).Buffer)},function(e,t,n){(function(t){"use strict";function r(e){return e>=0x8000000000000000||Math.abs(e)<0x4000000000000&&Math.floor(e)!==e}function i(e,n,r){var i=r;r+=4;for(var o in n)if(void 0!==n[o]){var a=t.byteLength(o);e.writeUInt8(a,r),r++,e.write(o,r,"utf8"),r+=a,r+=s(e,n[o],r)}var u=r-i;return e.writeUInt32BE(u-4,i),u}function o(e,t,n){var r=n;n+=4;for(var i=0,o=t.length;o>i;i++)n+=s(e,t[i],n);var a=n-r;return e.writeUInt32BE(a-4,r),a}function s(e,n,s){function a(t){e.write(t,s),s++}var c=s,l=typeof n,f=n;switch(n&&"object"===l&&n.hasOwnProperty("!")&&(f=n.value,l=n["!"]),l){case"string":var h=t.byteLength(f,"utf8");a("S"),e.writeUInt32BE(h,s),s+=4,e.write(f,s,"utf8"),s+=h;break;case"object":null===f?a("V"):Array.isArray(f)?(a("A"),s+=o(e,f,s)):t.isBuffer(f)?(a("x"),e.writeUInt32BE(f.length,s),s+=4,f.copy(e,s),s+=f.length):(a("F"),s+=i(e,f,s));break;case"boolean":a("t"),e.writeUInt8(f?1:0,s),s++;break;case"number":r(f)?(a("d"),e.writeDoubleBE(f,s),s+=8):128>f&&f>=-128?(a("b"),e.writeInt8(f,s),s++):f>=-32768&&32768>f?(a("s"),e.writeInt16BE(f,s),s+=2):f>=-2147483648&&2147483648>f?(a("I"),e.writeInt32BE(f,s),s+=4):(a("l"),u.writeInt64BE(e,f,s),s+=8);break;case"timestamp":a("T"),u.writeUInt64BE(e,f,s),s+=8;break;case"float":a("f"),e.writeFloatBE(f,s),s+=4;break;case"decimal":if(a("D"),!(f.hasOwnProperty("places")&&f.hasOwnProperty("digits")&&f.places>=0&&f.places<256))throw new TypeError("Decimal value must be {'places': 0..255, 'digits': uint32}, got "+JSON.stringify(f));e[s]=f.places,s++,e.writeUInt32BE(f.digits,s),s+=4;break;default:throw new TypeError("Unknown type to encode: "+l)}return s-c}function a(e){function t(){var t=String.fromCharCode(e[c]);switch(c++,t){case"b":o=e.readInt8(c),c++;break;case"S":r=e.readUInt32BE(c),c+=4,o=e.toString("utf8",c,c+r),c+=r;break;case"I":o=e.readInt32BE(c),c+=4;break;case"D":var i=e[c];c++;var s=e.readUInt32BE(c);c+=4,o={"!":"decimal",value:{places:i,digits:s}};break;case"T":o=u.readUInt64BE(e,c),c+=8,o={"!":"timestamp",value:o};break;case"F":r=e.readUInt32BE(c),c+=4,o=a(e.slice(c,c+r)),c+=r;break;case"A":r=e.readUInt32BE(c),c+=4,n(c+r);break;case"d":o=e.readDoubleBE(c),c+=8;break;case"f":o=e.readFloatBE(c),c+=4;break;case"l":o=u.readInt64BE(e,c),c+=8;break;case"s":o=e.readInt16BE(c),c+=2;break;case"t":o=0!=e[c],c++;break;case"V":o=null;break;case"x":r=e.readUInt32BE(c),c+=4,o=e.slice(c,c+r),c+=r;break;default:throw new TypeError('Unexpected type tag "'+t+'"')}}function n(e){for(var n=[];e>c;)t(),n.push(o);o=n}for(var r,i,o,s={},c=0,l=e.length;l>c;)r=e.readUInt8(c),c++,i=e.toString("utf8",c,c+r),c+=r,t(),s[i]=o;return s}var u=n(69);e.exports.encodeTable=i,e.exports.decodeFields=a}).call(t,n(3).Buffer)},function(e,t,n){(function(t){"use strict";function r(e){return G>=e&&e>=-G}function i(e){K(r(e),"number cannot be represented as a contiguous integer")}function o(e,t,n){K.ok("number"==typeof e&&e>=t&&n>=e&&Math.floor(e)===e,"not a number in the required range")}function s(e,t,n){return e.readUInt8(t,n)<<16|e.readUInt16BE(t+1,n)}function a(e,t,n,r){r||(o(t,0,16777215),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeUInt8(t>>>16,n,r),e.writeUInt16BE(65535&t,n+1,r)}function u(e,t,n){return(e.readUInt8(t,n)||0)*Y+e.readUInt32BE(t+1,n)}function c(e,t,n,r){r||(o(t,0,0xffffffffff),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeUInt8(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+1,r)}function l(e,t,n){return e.readUInt16BE(t,n)*Y+e.readUInt32BE(t+2,n)}function f(e,t,n,r){r||(o(t,0,0xffffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeUInt16BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+2,r)}function h(e,t,n){return((e.readUInt8(t,n)||0)<<16|e.readUInt16BE(t+1,n))*Y+e.readUInt32BE(t+3,n)}function p(e,t,n,r){if(r||(o(t,0,72057594037927940),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),72057594037927940>t){var i=Math.floor(t*V);e.writeUInt8(i>>>16,n,r),e.writeUInt16BE(65535&i,n+1,r),e.writeInt32BE(-1&t,n+3,r)}else e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255}function d(e,t,n){return e.readUInt32BE(t,n)*Y+e.readUInt32BE(t+4,n)}function v(e,t,n,r){r||(o(t,0,0x10000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x10000000000000000>t?(e.writeUInt32BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+4,r)):(e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=255)}function g(e,t,n){return e.readUInt8(t+2,n)<<16|e.readUInt16LE(t,n)}function y(e,t,n,r){r||(o(t,0,16777215),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeUInt16LE(65535&t,n,r),e.writeUInt8(t>>>16,n+2,r)}function m(e,t,n){return(e.readUInt8(t+4,n)||0)*Y+e.readUInt32LE(t,n)}function b(e,t,n,r){r||(o(t,0,0xffffffffff),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeUInt8(Math.floor(t*V),n+4,r)}function w(e,t,n){return e.readUInt16LE(t+4,n)*Y+e.readUInt32LE(t,n)}function _(e,t,n,r){r||(o(t,0,0xffffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeUInt16LE(Math.floor(t*V),n+4,r)}function E(e,t,n){return((e.readUInt8(t+6,n)||0)<<16|e.readUInt16LE(t+4,n))*Y+e.readUInt32LE(t,n)}function x(e,t,n,r){if(r||(o(t,0,72057594037927940),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),72057594037927940>t){e.writeInt32LE(-1&t,n,r);var i=Math.floor(t*V);e.writeUInt16LE(65535&i,n+4,r),e.writeUInt8(i>>>16,n+6,r)}else e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255}function I(e,t,n){return e.readUInt32LE(t+4,n)*Y+e.readUInt32LE(t,n)}function k(e,t,n,r){r||(o(t,0,0x10000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x10000000000000000>t?(e.writeInt32LE(-1&t,n,r),e.writeUInt32LE(Math.floor(t*V),n+4,r)):(e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=255)}function C(e,t,n){return(e.readInt8(t,n)<<16)+e.readUInt16BE(t+1,n)}function S(e,t,n,r){r||(o(t,-8388608,8388607),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeInt8(t>>16,n,r),e.writeUInt16BE(65535&t,n+1,r)}function T(e,t,n){return(e.readInt8(t,n)||0)*Y+e.readUInt32BE(t+1,n)}function U(e,t,n,r){r||(o(t,-549755813888,549755813887),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeInt8(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+1,r)}function B(e,t,n){return e.readInt16BE(t,n)*Y+e.readUInt32BE(t+2,n)}function j(e,t,n,r){r||(o(t,-0x800000000000,0x7fffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeInt16BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+2,r)}function O(e,t,n){return(((e.readInt8(t,n)||0)<<16)+e.readUInt16BE(t+1,n))*Y+e.readUInt32BE(t+3,n)}function R(e,t,n,r){if(r||(o(t,-0x800000000000000,0x80000000000000),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),0x80000000000000>t){var i=Math.floor(t*V);e.writeInt8(i>>16,n,r),e.writeUInt16BE(65535&i,n+1,r),e.writeInt32BE(-1&t,n+3,r)}else e[n]=127,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255}function A(e,t,n){return e.readInt32BE(t,n)*Y+e.readUInt32BE(t+4,n)}function L(e,t,n,r){r||(o(t,-0x800000000000000000,0x8000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x8000000000000000>t?(e.writeInt32BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+4,r)):(e[n]=127,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=255)}function M(e,t,n){return(e.readInt8(t+2,n)<<16)+e.readUInt16LE(t,n)}function P(e,t,n,r){r||(o(t,-8388608,8388607),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeUInt16LE(65535&t,n,r),e.writeInt8(t>>16,n+2,r)}function F(e,t,n){return(e.readInt8(t+4,n)||0)*Y+e.readUInt32LE(t,n)}function N(e,t,n,r){r||(o(t,-549755813888,549755813887),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeInt8(Math.floor(t*V),n+4,r)}function D(e,t,n){return e.readInt16LE(t+4,n)*Y+e.readUInt32LE(t,n)}function q(e,t,n,r){r||(o(t,-0x800000000000,0x7fffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeInt16LE(Math.floor(t*V),n+4,r)}function z(e,t,n){return(((e.readInt8(t+6,n)||0)<<16)+e.readUInt16LE(t+4,n))*Y+e.readUInt32LE(t,n)}function H(e,t,n,r){if(r||(o(t,-0x80000000000000,0x80000000000000),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),0x80000000000000>t){e.writeInt32LE(-1&t,n,r);var i=Math.floor(t*V);e.writeUInt16LE(65535&i,n+4,r),e.writeInt8(i>>16,n+6,r)}else e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=127}function Q(e,t,n){return e.readInt32LE(t+4,n)*Y+e.readUInt32LE(t,n)}function W(e,t,n,r){r||(o(t,-0x8000000000000000,0x8000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x8000000000000000>t?(e.writeInt32LE(-1&t,n,r),e.writeInt32LE(Math.floor(t*V),n+4,r)):(e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=127)}var K=n(70),Y=4294967296,V=1/Y,G=9007199254740991;e.exports.isContiguousInt=r,e.exports.assertContiguousInt=i,["UInt","Int"].forEach(function(n){var r=n+"8";e.exports["read"+r]=t.prototype["read"+r].call,e.exports["write"+r]=t.prototype["write"+r].call,["16","32"].forEach(function(r){["LE","BE"].forEach(function(i){var o=n+r+i,s=t.prototype["read"+o];e.exports["read"+o]=function(e,t,n){return s.call(e,t,n)};var a=t.prototype["write"+o];e.exports["write"+o]=function(e,t,n,r){return a.call(e,t,n,r)}})})}),e.exports.readUInt24BE=s,e.exports.writeUInt24BE=a,e.exports.readUInt40BE=u,e.exports.writeUInt40BE=c,e.exports.readUInt48BE=l,e.exports.writeUInt48BE=f,e.exports.readUInt56BE=h,e.exports.writeUInt56BE=p,e.exports.readUInt64BE=d,e.exports.writeUInt64BE=v,e.exports.readUInt24LE=g,e.exports.writeUInt24LE=y,e.exports.readUInt40LE=m,e.exports.writeUInt40LE=b,e.exports.readUInt48LE=w,e.exports.writeUInt48LE=_,e.exports.readUInt56LE=E,e.exports.writeUInt56LE=x,e.exports.readUInt64LE=I,e.exports.writeUInt64LE=k,e.exports.readInt24BE=C,e.exports.writeInt24BE=S,e.exports.readInt40BE=T,e.exports.writeInt40BE=U,e.exports.readInt48BE=B,e.exports.writeInt48BE=j,e.exports.readInt56BE=O,e.exports.writeInt56BE=R,e.exports.readInt64BE=A,e.exports.writeInt64BE=L,e.exports.readInt24LE=M,e.exports.writeInt24LE=P,e.exports.readInt40LE=F,e.exports.writeInt40LE=N,e.exports.readInt48LE=D,e.exports.writeInt48LE=q,e.exports.readInt56LE=z,e.exports.writeInt56LE=H,e.exports.readInt64LE=Q,e.exports.writeInt64LE=W}).call(t,n(3).Buffer)},function(e,t,n){function r(e,t){return p.isUndefined(t)?""+t:p.isNumber(t)&&!isFinite(t)?t.toString():p.isFunction(t)||p.isRegExp(t)?t.toString():t}function i(e,t){return p.isString(e)?e.length=0;o--)if(s[o]!=a[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!u(e[i],t[i]))return!1;return!0}function f(e,t){return e&&t?"[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t?!0:t.call({},e)===!0:!1}function h(e,t,n,r){var i;p.isString(n)&&(r=n,n=null);try{t()}catch(o){i=o}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&s(i,n,"Missing expected exception"+r),!e&&f(i,n)&&s(i,n,"Got unwanted exception"+r),e&&i&&n&&!f(i,n)||!e&&i)throw i}var p=n(71),d=Array.prototype.slice,v=Object.prototype.hasOwnProperty,g=e.exports=a;g.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=o(this),this.generatedMessage=!0);var t=e.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,i=t.name,a=r.indexOf("\n"+i);if(a>=0){var u=r.indexOf("\n",a+1);r=r.substring(u+1)}this.stack=r}}},p.inherits(g.AssertionError,Error),g.fail=s,g.ok=a,g.equal=function(e,t,n){e!=t&&s(e,t,n,"==",g.equal)},g.notEqual=function(e,t,n){e==t&&s(e,t,n,"!=",g.notEqual)},g.deepEqual=function(e,t,n){u(e,t)||s(e,t,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(e,t,n){u(e,t)&&s(e,t,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(e,t,n){e!==t&&s(e,t,n,"===",g.strictEqual)},g.notStrictEqual=function(e,t,n){e===t&&s(e,t,n,"!==",g.notStrictEqual)},g["throws"]=function(e,t,n){h.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(e,t){h.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(e){if(e)throw e};var y=Object.keys||function(e){var t=[];for(var n in e)v.call(e,n)&&t.push(n);return t}},function(e,t,n){(function(e,r){function i(e,n){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(e,n,r){if(e.customInspect&&n&&C(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return b(i)||(i=u(e,i,r)),i}var o=c(e,n);if(o)return o;var s=Object.keys(n),v=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),k(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(n);if(0===s.length){if(C(n)){var g=n.name?": "+n.name:"";return e.stylize("[Function"+g+"]","special")}if(E(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(I(n))return e.stylize(Date.prototype.toString.call(n),"date");if(k(n))return l(n)}var y="",m=!1,w=["{","}"];if(d(n)&&(m=!0,w=["[","]"]),C(n)){var _=n.name?": "+n.name:"";y=" [Function"+_+"]"}if(E(n)&&(y=" "+RegExp.prototype.toString.call(n)),I(n)&&(y=" "+Date.prototype.toUTCString.call(n)),k(n)&&(y=" "+l(n)),0===s.length&&(!m||0==n.length))return w[0]+y+w[1];if(0>r)return E(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var x;return x=m?f(e,n,r,v,s):s.map(function(t){return h(e,n,r,v,t,m)}),e.seen.pop(),p(x,y,w)}function c(e,t){if(_(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):v(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)j(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}function h(e,t,n,r,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),j(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(n)?u(e,c.value,null):u(e,c.value,n-1),a.indexOf("\n")>-1&&(a=o?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")),_(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function v(e){return"boolean"==typeof e}function g(e){return null===e}function y(e){return null==e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function _(e){return void 0===e}function E(e){return x(e)&&"[object RegExp]"===T(e)}function x(e){return"object"==typeof e&&null!==e}function I(e){return x(e)&&"[object Date]"===T(e)}function k(e){return x(e)&&("[object Error]"===T(e)||e instanceof Error)}function C(e){return"function"==typeof e}function S(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function T(e){return Object.prototype.toString.call(e)}function U(e){return 10>e?"0"+e.toString(10):e.toString(10)}function B(){var e=new Date,t=[U(e.getHours()),U(e.getMinutes()),U(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function j(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=g(a)||!x(a)?" "+a:" "+i(a);return s},t.deprecate=function(n,i){function o(){if(!s){if(r.throwDeprecation)throw new Error(i);r.traceDeprecation?console.trace(i):console.error(i),s=!0}return n.apply(this,arguments)}if(_(e.process))return function(){return t.deprecate(n,i).apply(this,arguments)};if(r.noDeprecation===!0)return n;var s=!1;return o};var R,A={};t.debuglog=function(e){if(_(R)&&(R={NODE_ENV:"production"}.NODE_DEBUG||""),e=e.toUpperCase(),!A[e])if(new RegExp("\\b"+e+"\\b","i").test(R)){var n=r.pid;A[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else A[e]=function(){};return A[e]},t.inspect=i,i.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]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=v,t.isNull=g,t.isNullOrUndefined=y,t.isNumber=m,t.isString=b,t.isSymbol=w,t.isUndefined=_,t.isRegExp=E,t.isObject=x,t.isDate=I,t.isError=k,t.isFunction=C,t.isPrimitive=S,t.isBuffer=n(72);var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(){console.log("%s - %s",B(),t.format.apply(t,arguments))},t.inherits=n(73),t._extend=function(e,t){if(!t||!x(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(t,function(){return this}(),n(36))},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){"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,n){(function(t){"use strict";function r(e,t){var n=d(e);if(n){var r=n.size,i=n.rest;if(r>t)throw new Error("Frame size exceeds frame max");if(i.length>r){if(i[r]!==h)throw new Error("Invalid frame");return{type:n.type,channel:n.channel,size:r,payload:i.slice(0,r),rest:i.slice(r+1)}}}return!1}var i=n(67),o=i.constants,s=i.decode,a=n(75);e.exports.PROTOCOL_HEADER="AMQP"+String.fromCharCode(0,0,9,1);var u=o.FRAME_METHOD,c=o.FRAME_HEARTBEAT,l=o.FRAME_HEADER,f=o.FRAME_BODY,h=o.FRAME_END,p=a.builder(f,"channel:16, size:32, payload:size/binary",h);e.exports.makeBodyFrame=function(e,t){return p({channel:e,size:t.length,payload:t})};var d=a.matcher("type:8","channel:16","size:32","rest/binary");e.exports.parseFrame=r;var v=a.matcher("class:16","_weight:16","size:64","flagsAndfields/binary"),g=a.matcher("id:32, args/binary"),y={channel:0};e.exports.decodeFrame=function(e){var t=e.payload;switch(e.type){case u:var n=g(t),r=n.id,i=s(r,n.args);return{id:r,channel:e.channel, +"use strict";function r(e){var t,n,r=0,i={versionMajor:void 0,versionMinor:void 0,serverProperties:void 0,mechanisms:void 0,locales:void 0};return t=e[r],r++,i.versionMajor=t,t=e[r],r++,i.versionMinor=t,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.serverProperties=t,n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.mechanisms=t,n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.locales=t,i}function i(e,n){var r,i=0,o=null,s=0,a=0;if(o=n.serverProperties,void 0===o)throw new Error("Missing value for mandatory field 'serverProperties'");if("object"!=typeof o)throw new TypeError("Field 'serverProperties' is the wrong type; must be an object");r=St(Ut,o,a);var u=Ut.slice(a,a+r);if(a+=r,s+=u.length,o=n.mechanisms,void 0===o)o=new t("PLAIN");else if(!t.isBuffer(o))throw new TypeError("Field 'mechanisms' is the wrong type; must be a Buffer");if(s+=o.length,o=n.locales,void 0===o)o=new t("en_US");else if(!t.isBuffer(o))throw new TypeError("Field 'locales' is the wrong type; must be a Buffer");s+=o.length;var c=new t(22+s);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(655370,7),i=11,o=n.versionMajor,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'versionMajor' is the wrong type; must be a number (but not NaN)");if(c.writeUInt8(o,i),i++,o=n.versionMinor,void 0===o)o=9;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'versionMinor' is the wrong type; must be a number (but not NaN)");return c.writeUInt8(o,i),i++,i+=u.copy(c,i),o=n.mechanisms,void 0===o&&(o=new t("PLAIN")),r=o.length,c.writeUInt32BE(r,i),i+=4,o.copy(c,i),i+=r,o=n.locales,void 0===o&&(o=new t("en_US")),r=o.length,c.writeUInt32BE(r,i),i+=4,o.copy(c,i),i+=r,c[i]=206,c.writeUInt32BE(i-7,3),c}function o(e){var t,n,r=0,i={clientProperties:void 0,mechanism:void 0,response:void 0,locale:void 0};return n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.clientProperties=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.mechanism=t,n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.response=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.locale=t,i}function s(e,n){var r,i=0,o=null,s=0,a=0;if(o=n.clientProperties,void 0===o)throw new Error("Missing value for mandatory field 'clientProperties'");if("object"!=typeof o)throw new TypeError("Field 'clientProperties' is the wrong type; must be an object");r=St(Ut,o,a);var u=Ut.slice(a,a+r);if(a+=r,s+=u.length,o=n.mechanism,void 0===o)o="PLAIN";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'mechanism' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(s+=c,o=n.response,void 0===o)throw new Error("Missing value for mandatory field 'response'");if(!t.isBuffer(o))throw new TypeError("Field 'response' is the wrong type; must be a Buffer");if(s+=o.length,o=n.locale,void 0===o)o="en_US";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'locale' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");s+=l;var f=new t(18+s);return f[0]=1,f.writeUInt16BE(e,1),f.writeUInt32BE(655371,7),i=11,i+=u.copy(f,i),o=n.mechanism,void 0===o&&(o="PLAIN"),f[i]=c,i++,f.write(o,i,"utf8"),i+=c,o=n.response,void 0===o&&(o=new t(void 0)),r=o.length,f.writeUInt32BE(r,i),i+=4,o.copy(f,i),i+=r,o=n.locale,void 0===o&&(o="en_US"),f[i]=l,i++,f.write(o,i,"utf8"),i+=l,f[i]=206,f.writeUInt32BE(i-7,3),f}function a(e){var t,n,r=0,i={challenge:void 0};return n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.challenge=t,i}function u(e,n){var r,i=0,o=null,s=0;if(o=n.challenge,void 0===o)throw new Error("Missing value for mandatory field 'challenge'");if(!t.isBuffer(o))throw new TypeError("Field 'challenge' is the wrong type; must be a Buffer");s+=o.length;var a=new t(16+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655380,7),i=11,o=n.challenge,void 0===o&&(o=new t(void 0)),r=o.length,a.writeUInt32BE(r,i),i+=4,o.copy(a,i),i+=r,a[i]=206,a.writeUInt32BE(i-7,3),a}function c(e){var t,n,r=0,i={response:void 0};return n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.response=t,i}function l(e,n){var r,i=0,o=null,s=0;if(o=n.response,void 0===o)throw new Error("Missing value for mandatory field 'response'");if(!t.isBuffer(o))throw new TypeError("Field 'response' is the wrong type; must be a Buffer");s+=o.length;var a=new t(16+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655381,7),i=11,o=n.response,void 0===o&&(o=new t(void 0)),r=o.length,a.writeUInt32BE(r,i),i+=4,o.copy(a,i),i+=r,a[i]=206,a.writeUInt32BE(i-7,3),a}function f(e){var t,n=0,r={channelMax:void 0,frameMax:void 0,heartbeat:void 0};return t=e.readUInt16BE(n),n+=2,r.channelMax=t,t=e.readUInt32BE(n),n+=4,r.frameMax=t,t=e.readUInt16BE(n),n+=2,r.heartbeat=t,r}function h(e,n){var r=0,i=null,o=0,s=new t(20+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(655390,7),r=11,i=n.channelMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'channelMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt16BE(i,r),r+=2,i=n.frameMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'frameMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt32BE(i,r),r+=4,i=n.heartbeat,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'heartbeat' is the wrong type; must be a number (but not NaN)");return s.writeUInt16BE(i,r),r+=2,s[r]=206,s.writeUInt32BE(r-7,3),s}function p(e){var t,n=0,r={channelMax:void 0,frameMax:void 0,heartbeat:void 0};return t=e.readUInt16BE(n),n+=2,r.channelMax=t,t=e.readUInt32BE(n),n+=4,r.frameMax=t,t=e.readUInt16BE(n),n+=2,r.heartbeat=t,r}function d(e,n){var r=0,i=null,o=0,s=new t(20+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(655391,7),r=11,i=n.channelMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'channelMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt16BE(i,r),r+=2,i=n.frameMax,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'frameMax' is the wrong type; must be a number (but not NaN)");if(s.writeUInt32BE(i,r),r+=4,i=n.heartbeat,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'heartbeat' is the wrong type; must be a number (but not NaN)");return s.writeUInt16BE(i,r),r+=2,s[r]=206,s.writeUInt32BE(r-7,3),s}function v(e){var t,n,r=0,i={virtualHost:void 0,capabilities:void 0,insist:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.virtualHost=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.capabilities=t,t=!!(1&e[r]),i.insist=t,i}function g(e,n){var r=0,i=null,o=0,s=0;if(i=n.virtualHost,void 0===i)i="/";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'virtualHost' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.capabilities,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'capabilities' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");s+=u;var c=new t(15+s);return c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(655400,7),r=11,i=n.virtualHost,void 0===i&&(i="/"),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.capabilities,void 0===i&&(i=""),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,i=n.insist,void 0===i&&(i=!1),i&&(o+=1),c[r]=o,r++,c[r]=206,c.writeUInt32BE(r-7,3),c}function y(e){var t,n,r=0,i={knownHosts:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.knownHosts=t,i}function m(e,n){var r=0,i=null,o=0;if(i=n.knownHosts,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'knownHosts' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655401,7),r=11,i=n.knownHosts,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function b(e){var t,n,r=0,i={replyCode:void 0,replyText:void 0,classId:void 0,methodId:void 0};return t=e.readUInt16BE(r),r+=2,i.replyCode=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.replyText=t,t=e.readUInt16BE(r),r+=2,i.classId=t,t=e.readUInt16BE(r),r+=2,i.methodId=t,i}function w(e,n){var r=0,i=null,o=0;if(i=n.replyText,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(19+o);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655410,7),r=11,i=n.replyCode,void 0===i)throw new Error("Missing value for mandatory field 'replyCode'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.replyText,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,i=n.classId,void 0===i)throw new Error("Missing value for mandatory field 'classId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'classId' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.methodId,void 0===i)throw new Error("Missing value for mandatory field 'methodId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'methodId' is the wrong type; must be a number (but not NaN)");return a.writeUInt16BE(i,r),r+=2,a[r]=206,a.writeUInt32BE(r-7,3),a}function _(e){var t={};return t}function E(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(655411,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function x(e){var t,n,r=0,i={reason:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.reason=t,i}function I(e,n){var r=0,i=null,o=0;if(i=n.reason,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'reason' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(655420,7),r=11,i=n.reason,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function k(e){var t={};return t}function C(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(655421,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function S(e){var t,n,r=0,i={outOfBand:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.outOfBand=t,i}function T(e,n){var r=0,i=null,o=0;if(i=n.outOfBand,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'outOfBand' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310730,7),r=11,i=n.outOfBand,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function U(e){var t,n,r=0,i={channelId:void 0};return n=e.readUInt32BE(r),r+=4,t=e.slice(r,r+n),r+=n,i.channelId=t,i}function B(e,n){var r,i=0,o=null,s=0;if(o=n.channelId,void 0===o)o=new t("");else if(!t.isBuffer(o))throw new TypeError("Field 'channelId' is the wrong type; must be a Buffer");s+=o.length;var a=new t(16+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310731,7),i=11,o=n.channelId,void 0===o&&(o=new t("")),r=o.length,a.writeUInt32BE(r,i),i+=4,o.copy(a,i),i+=r,a[i]=206,a.writeUInt32BE(i-7,3),a}function j(e){var t,n=0,r={active:void 0};return t=!!(1&e[n]),r.active=t,r}function O(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310740,7),r=11,i=n.active,void 0===i)throw new Error("Missing value for mandatory field 'active'");return i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function A(e){var t,n=0,r={active:void 0};return t=!!(1&e[n]),r.active=t,r}function R(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310741,7),r=11,i=n.active,void 0===i)throw new Error("Missing value for mandatory field 'active'");return i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function L(e){var t,n,r=0,i={replyCode:void 0,replyText:void 0,classId:void 0,methodId:void 0};return t=e.readUInt16BE(r),r+=2,i.replyCode=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.replyText=t,t=e.readUInt16BE(r),r+=2,i.classId=t,t=e.readUInt16BE(r),r+=2,i.methodId=t,i}function M(e,n){var r=0,i=null,o=0;if(i=n.replyText,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(19+o);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(1310760,7),r=11,i=n.replyCode,void 0===i)throw new Error("Missing value for mandatory field 'replyCode'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.replyText,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,i=n.classId,void 0===i)throw new Error("Missing value for mandatory field 'classId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'classId' is the wrong type; must be a number (but not NaN)");if(a.writeUInt16BE(i,r),r+=2,i=n.methodId,void 0===i)throw new Error("Missing value for mandatory field 'methodId'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'methodId' is the wrong type; must be a number (but not NaN)");return a.writeUInt16BE(i,r),r+=2,a[r]=206,a.writeUInt32BE(r-7,3),a}function F(e){var t={};return t}function P(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(1310761,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function N(e){var t,n,r=0,i={realm:void 0,exclusive:void 0,passive:void 0,active:void 0,write:void 0,read:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.realm=t,t=!!(1&e[r]),i.exclusive=t,t=!!(2&e[r]),i.passive=t,t=!!(4&e[r]),i.active=t,t=!!(8&e[r]),i.write=t,t=!!(16&e[r]),i.read=t,i}function D(e,n){var r=0,i=null,o=0,s=0;if(i=n.realm,void 0===i)i="/data";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'realm' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(14+s);return u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(1966090,7),r=11,i=n.realm,void 0===i&&(i="/data"),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.exclusive,void 0===i&&(i=!1),i&&(o+=1),i=n.passive,void 0===i&&(i=!0),i&&(o+=2),i=n.active,void 0===i&&(i=!0),i&&(o+=4),i=n.write,void 0===i&&(i=!0),i&&(o+=8),i=n.read,void 0===i&&(i=!0),i&&(o+=16),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function q(e){var t,n=0,r={ticket:void 0};return t=e.readUInt16BE(n),n+=2,r.ticket=t,r}function z(e,n){var r=0,i=null,o=0,s=new t(14+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(1966091,7),r=11,i=n.ticket,void 0===i)i=1;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return s.writeUInt16BE(i,r),r+=2,s[r]=206,s.writeUInt32BE(r-7,3),s}function H(e){var t,n,r=0,i={ticket:void 0,exchange:void 0,type:void 0,passive:void 0,durable:void 0,autoDelete:void 0,internal:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.type=t,t=!!(1&e[r]),i.passive=t,t=!!(2&e[r]),i.durable=t,t=!!(4&e[r]),i.autoDelete=t,t=!!(8&e[r]),i.internal=t,t=!!(16&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function Q(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.exchange,void 0===o)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.type,void 0===o)o="direct";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'type' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var f=Ut.slice(u,u+r);u+=r,a+=f.length;var h=new t(17+a);if(h[0]=1,h.writeUInt16BE(e,1),h.writeUInt32BE(2621450,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return h.writeUInt16BE(o,i),i+=2,o=n.exchange,void 0===o&&(o=void 0),h[i]=c,i++,h.write(o,i,"utf8"),i+=c,o=n.type,void 0===o&&(o="direct"),h[i]=l,i++,h.write(o,i,"utf8"),i+=l,o=n.passive,void 0===o&&(o=!1),o&&(s+=1),o=n.durable,void 0===o&&(o=!1),o&&(s+=2),o=n.autoDelete,void 0===o&&(o=!1),o&&(s+=4),o=n.internal,void 0===o&&(o=!1),o&&(s+=8),o=n.nowait,void 0===o&&(o=!1),o&&(s+=16),h[i]=s,i++,s=0,i+=f.copy(h,i),h[i]=206,h.writeUInt32BE(i-7,3),h}function W(e){var t={};return t}function K(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621451,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function Y(e){var t,n,r=0,i={ticket:void 0,exchange:void 0,ifUnused:void 0,nowait:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,t=!!(1&e[r]),i.ifUnused=t,t=!!(2&e[r]),i.nowait=t,i}function V(e,n){var r=0,i=null,o=0,s=0;if(i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(2621460,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.exchange,void 0===i&&(i=void 0),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.ifUnused,void 0===i&&(i=!1),i&&(o+=1),i=n.nowait,void 0===i&&(i=!1),i&&(o+=2),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function G(e){var t={};return t}function $(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621461,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function X(e){var t,n,r=0,i={ticket:void 0,destination:void 0,source:void 0,routingKey:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.destination=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.source=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function J(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.destination,void 0===o)throw new Error("Missing value for mandatory field 'destination'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'destination' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.source,void 0===o)throw new Error("Missing value for mandatory field 'source'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'source' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(o,"utf8");if(a+=f,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var h=Ut.slice(u,u+r);u+=r,a+=h.length;var p=new t(18+a);if(p[0]=1,p.writeUInt16BE(e,1),p.writeUInt32BE(2621470,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return p.writeUInt16BE(o,i),i+=2,o=n.destination,void 0===o&&(o=void 0),p[i]=c,i++,p.write(o,i,"utf8"),i+=c,o=n.source,void 0===o&&(o=void 0),p[i]=l,i++,p.write(o,i,"utf8"),i+=l,o=n.routingKey,void 0===o&&(o=""),p[i]=f,i++,p.write(o,i,"utf8"),i+=f,o=n.nowait,void 0===o&&(o=!1),o&&(s+=1),p[i]=s,i++,s=0,i+=h.copy(p,i),p[i]=206,p.writeUInt32BE(i-7,3),p}function Z(e){var t={};return t}function ee(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621471,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function te(e){var t,n,r=0,i={ticket:void 0,destination:void 0,source:void 0,routingKey:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.destination=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.source=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function ne(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.destination,void 0===o)throw new Error("Missing value for mandatory field 'destination'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'destination' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.source,void 0===o)throw new Error("Missing value for mandatory field 'source'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'source' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(o,"utf8");if(a+=f,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var h=Ut.slice(u,u+r);u+=r,a+=h.length;var p=new t(18+a);if(p[0]=1,p.writeUInt16BE(e,1),p.writeUInt32BE(2621480,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return p.writeUInt16BE(o,i),i+=2,o=n.destination,void 0===o&&(o=void 0),p[i]=c,i++,p.write(o,i,"utf8"),i+=c,o=n.source,void 0===o&&(o=void 0),p[i]=l,i++,p.write(o,i,"utf8"),i+=l,o=n.routingKey,void 0===o&&(o=""),p[i]=f,i++,p.write(o,i,"utf8"),i+=f,o=n.nowait,void 0===o&&(o=!1),o&&(s+=1),p[i]=s,i++,s=0,i+=h.copy(p,i),p[i]=206,p.writeUInt32BE(i-7,3),p}function re(e){var t={};return t}function ie(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(2621491,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function oe(e){var t,n,r=0,i={ticket:void 0,queue:void 0,passive:void 0,durable:void 0,exclusive:void 0,autoDelete:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.passive=t,t=!!(2&e[r]),i.durable=t,t=!!(4&e[r]),i.exclusive=t,t=!!(8&e[r]),i.autoDelete=t,t=!!(16&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function se(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var l=Ut.slice(u,u+r);u+=r,a+=l.length;var f=new t(16+a);if(f[0]=1,f.writeUInt16BE(e,1),f.writeUInt32BE(3276810,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return f.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),f[i]=c,i++,f.write(o,i,"utf8"),i+=c,o=n.passive,void 0===o&&(o=!1),o&&(s+=1),o=n.durable,void 0===o&&(o=!1),o&&(s+=2),o=n.exclusive,void 0===o&&(o=!1),o&&(s+=4),o=n.autoDelete,void 0===o&&(o=!1),o&&(s+=8),o=n.nowait,void 0===o&&(o=!1),o&&(s+=16),f[i]=s,i++,s=0,i+=l.copy(f,i),f[i]=206,f.writeUInt32BE(i-7,3),f}function ae(e){var t,n,r=0,i={queue:void 0,messageCount:void 0,consumerCount:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=e.readUInt32BE(r),r+=4,i.messageCount=t,t=e.readUInt32BE(r),r+=4,i.consumerCount=t,i}function ue(e,n){var r=0,i=null,o=0;if(i=n.queue,void 0===i)throw new Error("Missing value for mandatory field 'queue'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(21+o);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3276811,7),r=11,i=n.queue,void 0===i&&(i=void 0),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");if(a.writeUInt32BE(i,r),r+=4,i=n.consumerCount,void 0===i)throw new Error("Missing value for mandatory field 'consumerCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'consumerCount' is the wrong type; must be a number (but not NaN)");return a.writeUInt32BE(i,r),r+=4,a[r]=206,a.writeUInt32BE(r-7,3),a}function ce(e){var t,n,r=0,i={ticket:void 0,queue:void 0,exchange:void 0,routingKey:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function le(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.exchange,void 0===o)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(o,"utf8");if(a+=f,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var h=Ut.slice(u,u+r);u+=r,a+=h.length;var p=new t(18+a);if(p[0]=1,p.writeUInt16BE(e,1),p.writeUInt32BE(3276820,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return p.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),p[i]=c,i++,p.write(o,i,"utf8"),i+=c,o=n.exchange,void 0===o&&(o=void 0),p[i]=l,i++,p.write(o,i,"utf8"),i+=l,o=n.routingKey,void 0===o&&(o=""),p[i]=f,i++,p.write(o,i,"utf8"),i+=f,o=n.nowait,void 0===o&&(o=!1),o&&(s+=1),p[i]=s,i++,s=0,i+=h.copy(p,i),p[i]=206,p.writeUInt32BE(i-7,3),p}function fe(e){var t={};return t}function he(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3276821,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function pe(e){var t,n,r=0,i={ticket:void 0,queue:void 0,nowait:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.nowait=t,i}function de(e,n){var r=0,i=null,o=0,s=0;if(i=n.queue,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3276830,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.queue,void 0===i&&(i=""),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.nowait,void 0===i&&(i=!1),i&&(o+=1),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function ve(e){var t,n=0,r={messageCount:void 0};return t=e.readUInt32BE(n),n+=4,r.messageCount=t,r}function ge(e,n){var r=0,i=null,o=0,s=new t(16+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(3276831,7),r=11,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");return s.writeUInt32BE(i,r),r+=4,s[r]=206,s.writeUInt32BE(r-7,3),s}function ye(e){var t,n,r=0,i={ticket:void 0,queue:void 0,ifUnused:void 0,ifEmpty:void 0,nowait:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.ifUnused=t,t=!!(2&e[r]),i.ifEmpty=t,t=!!(4&e[r]),i.nowait=t,i}function me(e,n){var r=0,i=null,o=0,s=0;if(i=n.queue,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3276840,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.queue,void 0===i&&(i=""),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.ifUnused,void 0===i&&(i=!1),i&&(o+=1),i=n.ifEmpty,void 0===i&&(i=!1),i&&(o+=2),i=n.nowait,void 0===i&&(i=!1),i&&(o+=4),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function be(e){var t,n=0,r={messageCount:void 0};return t=e.readUInt32BE(n),n+=4,r.messageCount=t,r}function we(e,n){var r=0,i=null,o=0,s=new t(16+o);if(s[0]=1,s.writeUInt16BE(e,1),s.writeUInt32BE(3276841,7),r=11,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");return s.writeUInt32BE(i,r),r+=4,s[r]=206,s.writeUInt32BE(r-7,3),s}function _e(e){var t,n,r=0,i={ticket:void 0,queue:void 0,exchange:void 0,routingKey:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function Ee(e,n){var r,i=0,o=null,s=0,a=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(o,"utf8");if(s+=u,o=n.exchange,void 0===o)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(s+=c,o=n.routingKey,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(s+=l,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,a);var f=Ut.slice(a,a+r);a+=r,s+=f.length;var h=new t(17+s);if(h[0]=1,h.writeUInt16BE(e,1),h.writeUInt32BE(3276850,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)"); +return h.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),h[i]=u,i++,h.write(o,i,"utf8"),i+=u,o=n.exchange,void 0===o&&(o=void 0),h[i]=c,i++,h.write(o,i,"utf8"),i+=c,o=n.routingKey,void 0===o&&(o=""),h[i]=l,i++,h.write(o,i,"utf8"),i+=l,i+=f.copy(h,i),h[i]=206,h.writeUInt32BE(i-7,3),h}function xe(e){var t={};return t}function Ie(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3276851,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ke(e){var t,n=0,r={prefetchSize:void 0,prefetchCount:void 0,global:void 0};return t=e.readUInt32BE(n),n+=4,r.prefetchSize=t,t=e.readUInt16BE(n),n+=2,r.prefetchCount=t,t=!!(1&e[n]),r.global=t,r}function Ce(e,n){var r=0,i=null,o=0,s=0,a=new t(19+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932170,7),r=11,i=n.prefetchSize,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'prefetchSize' is the wrong type; must be a number (but not NaN)");if(a.writeUInt32BE(i,r),r+=4,i=n.prefetchCount,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'prefetchCount' is the wrong type; must be a number (but not NaN)");return a.writeUInt16BE(i,r),r+=2,i=n.global,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function Se(e){var t={};return t}function Te(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3932171,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function Ue(e){var t,n,r=0,i={ticket:void 0,queue:void 0,consumerTag:void 0,noLocal:void 0,noAck:void 0,exclusive:void 0,nowait:void 0,arguments:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,t=!!(1&e[r]),i.noLocal=t,t=!!(2&e[r]),i.noAck=t,t=!!(4&e[r]),i.exclusive=t,t=!!(8&e[r]),i.nowait=t,r++,n=e.readUInt32BE(r),r+=4,t=Tt(e.slice(r,r+n)),r+=n,i.arguments=t,i}function Be(e,n){var r,i=0,o=null,s=0,a=0,u=0;if(o=n.queue,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(o,"utf8");if(a+=c,o=n.consumerTag,void 0===o)o="";else if(!("string"==typeof o&&t.byteLength(o)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(o,"utf8");if(a+=l,o=n.arguments,void 0===o)o={};else if("object"!=typeof o)throw new TypeError("Field 'arguments' is the wrong type; must be an object");r=St(Ut,o,u);var f=Ut.slice(u,u+r);u+=r,a+=f.length;var h=new t(17+a);if(h[0]=1,h.writeUInt16BE(e,1),h.writeUInt32BE(3932180,7),i=11,o=n.ticket,void 0===o)o=0;else if("number"!=typeof o||isNaN(o))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return h.writeUInt16BE(o,i),i+=2,o=n.queue,void 0===o&&(o=""),h[i]=c,i++,h.write(o,i,"utf8"),i+=c,o=n.consumerTag,void 0===o&&(o=""),h[i]=l,i++,h.write(o,i,"utf8"),i+=l,o=n.noLocal,void 0===o&&(o=!1),o&&(s+=1),o=n.noAck,void 0===o&&(o=!1),o&&(s+=2),o=n.exclusive,void 0===o&&(o=!1),o&&(s+=4),o=n.nowait,void 0===o&&(o=!1),o&&(s+=8),h[i]=s,i++,s=0,i+=f.copy(h,i),h[i]=206,h.writeUInt32BE(i-7,3),h}function je(e){var t,n,r=0,i={consumerTag:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,i}function Oe(e,n){var r=0,i=null,o=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932181,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function Ae(e){var t,n,r=0,i={consumerTag:void 0,nowait:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,t=!!(1&e[r]),i.nowait=t,i}function Re(e,n){var r=0,i=null,o=0,s=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(14+s);return u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3932190,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.nowait,void 0===i&&(i=!1),i&&(o+=1),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function Le(e){var t,n,r=0,i={consumerTag:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,i}function Me(e,n){var r=0,i=null,o=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932191,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function Fe(e){var t,n,r=0,i={ticket:void 0,exchange:void 0,routingKey:void 0,mandatory:void 0,immediate:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=!!(1&e[r]),i.mandatory=t,t=!!(2&e[r]),i.immediate=t,i}function Pe(e,n){var r=0,i=null,o=0,s=0;if(i=n.exchange,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.routingKey,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");s+=u;var c=new t(17+s);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(3932200,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return c.writeUInt16BE(i,r),r+=2,i=n.exchange,void 0===i&&(i=""),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.routingKey,void 0===i&&(i=""),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,i=n.mandatory,void 0===i&&(i=!1),i&&(o+=1),i=n.immediate,void 0===i&&(i=!1),i&&(o+=2),c[r]=o,r++,c[r]=206,c.writeUInt32BE(r-7,3),c}function Ne(e){var t,n,r=0,i={replyCode:void 0,replyText:void 0,exchange:void 0,routingKey:void 0};return t=e.readUInt16BE(r),r+=2,i.replyCode=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.replyText=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,i}function De(e,n){var r=0,i=null,o=0;if(i=n.replyText,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");if(o+=s,i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(o+=a,i=n.routingKey,void 0===i)throw new Error("Missing value for mandatory field 'routingKey'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");o+=u;var c=new t(17+o);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(3932210,7),r=11,i=n.replyCode,void 0===i)throw new Error("Missing value for mandatory field 'replyCode'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)");return c.writeUInt16BE(i,r),r+=2,i=n.replyText,void 0===i&&(i=""),c[r]=s,r++,c.write(i,r,"utf8"),r+=s,i=n.exchange,void 0===i&&(i=void 0),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.routingKey,void 0===i&&(i=void 0),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,c[r]=206,c.writeUInt32BE(r-7,3),c}function qe(e){var t,n,r=0,i={consumerTag:void 0,deliveryTag:void 0,redelivered:void 0,exchange:void 0,routingKey:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.consumerTag=t,t=Ct.readUInt64BE(e,r),r+=8,i.deliveryTag=t,t=!!(1&e[r]),i.redelivered=t,r++,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,i}function ze(e,n){var r=0,i=null,o=0,s=0;if(i=n.consumerTag,void 0===i)throw new Error("Missing value for mandatory field 'consumerTag'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");if(s+=u,i=n.routingKey,void 0===i)throw new Error("Missing value for mandatory field 'routingKey'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var c=t.byteLength(i,"utf8");s+=c;var l=new t(24+s);if(l[0]=1,l.writeUInt16BE(e,1),l.writeUInt32BE(3932220,7),r=11,i=n.consumerTag,void 0===i&&(i=void 0),l[r]=a,r++,l.write(i,r,"utf8"),r+=a,i=n.deliveryTag,void 0===i)throw new Error("Missing value for mandatory field 'deliveryTag'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(l,i,r),r+=8,i=n.redelivered,void 0===i&&(i=!1),i&&(o+=1),l[r]=o,r++,o=0,i=n.exchange,void 0===i&&(i=void 0),l[r]=u,r++,l.write(i,r,"utf8"),r+=u,i=n.routingKey,void 0===i&&(i=void 0),l[r]=c,r++,l.write(i,r,"utf8"),r+=c,l[r]=206,l.writeUInt32BE(r-7,3),l}function He(e){var t,n,r=0,i={ticket:void 0,queue:void 0,noAck:void 0};return t=e.readUInt16BE(r),r+=2,i.ticket=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.queue=t,t=!!(1&e[r]),i.noAck=t,i}function Qe(e,n){var r=0,i=null,o=0,s=0;if(i=n.queue,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");s+=a;var u=new t(16+s);if(u[0]=1,u.writeUInt16BE(e,1),u.writeUInt32BE(3932230,7),r=11,i=n.ticket,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)");return u.writeUInt16BE(i,r),r+=2,i=n.queue,void 0===i&&(i=""),u[r]=a,r++,u.write(i,r,"utf8"),r+=a,i=n.noAck,void 0===i&&(i=!1),i&&(o+=1),u[r]=o,r++,u[r]=206,u.writeUInt32BE(r-7,3),u}function We(e){var t,n,r=0,i={deliveryTag:void 0,redelivered:void 0,exchange:void 0,routingKey:void 0,messageCount:void 0};return t=Ct.readUInt64BE(e,r),r+=8,i.deliveryTag=t,t=!!(1&e[r]),i.redelivered=t,r++,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.exchange=t,n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.routingKey=t,t=e.readUInt32BE(r),r+=4,i.messageCount=t,i}function Ke(e,n){var r=0,i=null,o=0,s=0;if(i=n.exchange,void 0===i)throw new Error("Missing value for mandatory field 'exchange'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)");var a=t.byteLength(i,"utf8");if(s+=a,i=n.routingKey,void 0===i)throw new Error("Missing value for mandatory field 'routingKey'");if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)");var u=t.byteLength(i,"utf8");s+=u;var c=new t(27+s);if(c[0]=1,c.writeUInt16BE(e,1),c.writeUInt32BE(3932231,7),r=11,i=n.deliveryTag,void 0===i)throw new Error("Missing value for mandatory field 'deliveryTag'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");if(Ct.writeUInt64BE(c,i,r),r+=8,i=n.redelivered,void 0===i&&(i=!1),i&&(o+=1),c[r]=o,r++,o=0,i=n.exchange,void 0===i&&(i=void 0),c[r]=a,r++,c.write(i,r,"utf8"),r+=a,i=n.routingKey,void 0===i&&(i=void 0),c[r]=u,r++,c.write(i,r,"utf8"),r+=u,i=n.messageCount,void 0===i)throw new Error("Missing value for mandatory field 'messageCount'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)");return c.writeUInt32BE(i,r),r+=4,c[r]=206,c.writeUInt32BE(r-7,3),c}function Ye(e){var t,n,r=0,i={clusterId:void 0};return n=e.readUInt8(r),r++,t=e.toString("utf8",r,r+n),r+=n,i.clusterId=t,i}function Ve(e,n){var r=0,i=null,o=0;if(i=n.clusterId,void 0===i)i="";else if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'clusterId' is the wrong type; must be a string (up to 255 chars)");var s=t.byteLength(i,"utf8");o+=s;var a=new t(13+o);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932232,7),r=11,i=n.clusterId,void 0===i&&(i=""),a[r]=s,r++,a.write(i,r,"utf8"),r+=s,a[r]=206,a.writeUInt32BE(r-7,3),a}function Ge(e){var t,n=0,r={deliveryTag:void 0,multiple:void 0};return t=Ct.readUInt64BE(e,n),n+=8,r.deliveryTag=t,t=!!(1&e[n]),r.multiple=t,r}function $e(e,n){var r=0,i=null,o=0,s=0,a=new t(21+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932240,7),r=11,i=n.deliveryTag,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(a,i,r),r+=8,i=n.multiple,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function Xe(e){var t,n=0,r={deliveryTag:void 0,requeue:void 0};return t=Ct.readUInt64BE(e,n),n+=8,r.deliveryTag=t,t=!!(1&e[n]),r.requeue=t,r}function Je(e,n){var r=0,i=null,o=0,s=0,a=new t(21+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932250,7),r=11,i=n.deliveryTag,void 0===i)throw new Error("Missing value for mandatory field 'deliveryTag'");if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(a,i,r),r+=8,i=n.requeue,void 0===i&&(i=!0),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function Ze(e){var t,n=0,r={requeue:void 0};return t=!!(1&e[n]),r.requeue=t,r}function et(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932260,7),r=11,i=n.requeue,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function tt(e){var t,n=0,r={requeue:void 0};return t=!!(1&e[n]),r.requeue=t,r}function nt(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932270,7),r=11,i=n.requeue,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function rt(e){var t={};return t}function it(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(3932271,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ot(e){var t,n=0,r={deliveryTag:void 0,multiple:void 0,requeue:void 0};return t=Ct.readUInt64BE(e,n),n+=8,r.deliveryTag=t,t=!!(1&e[n]),r.multiple=t,t=!!(2&e[n]),r.requeue=t,r}function st(e,n){var r=0,i=null,o=0,s=0,a=new t(21+s);if(a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(3932280,7),r=11,i=n.deliveryTag,void 0===i)i=0;else if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)");return Ct.writeUInt64BE(a,i,r),r+=8,i=n.multiple,void 0===i&&(i=!1),i&&(o+=1),i=n.requeue,void 0===i&&(i=!0),i&&(o+=2),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function at(e){var t={};return t}function ut(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898250,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ct(e){var t={};return t}function lt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898251,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function ft(e){var t={};return t}function ht(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898260,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function pt(e){var t={};return t}function dt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898261,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function vt(e){var t={};return t}function gt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898270,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function yt(e){var t={};return t}function mt(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5898271,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function bt(e){var t,n=0,r={nowait:void 0};return t=!!(1&e[n]),r.nowait=t,r}function wt(e,n){var r=0,i=null,o=0,s=0,a=new t(13+s);return a[0]=1,a.writeUInt16BE(e,1),a.writeUInt32BE(5570570,7),r=11,i=n.nowait,void 0===i&&(i=!1),i&&(o+=1),a[r]=o,r++,a[r]=206,a.writeUInt32BE(r-7,3),a}function _t(e){var t={};return t}function Et(e,n){var r=0,i=0,o=new t(12+i);return o[0]=1,o.writeUInt16BE(e,1),o.writeUInt32BE(5570571,7),r=11,o[r]=206,o.writeUInt32BE(r-7,3),o}function xt(e,n,r){var i,o,s=0,a=0,u=0,c=0;if(i=r.contentType,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'contentType' is the wrong type; must be a string (up to 255 chars)");var l=t.byteLength(i,"utf8");c+=1,c+=l}if(i=r.contentEncoding,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'contentEncoding' is the wrong type; must be a string (up to 255 chars)");var f=t.byteLength(i,"utf8");c+=1,c+=f}if(i=r.headers,void 0!=i){if("object"!=typeof i)throw new TypeError("Field 'headers' is the wrong type; must be an object");o=St(Ut,i,u);var h=Ut.slice(u,u+o);u+=o,c+=h.length}if(i=r.deliveryMode,void 0!=i){if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'deliveryMode' is the wrong type; must be a number (but not NaN)");c+=1}if(i=r.priority,void 0!=i){if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'priority' is the wrong type; must be a number (but not NaN)");c+=1}if(i=r.correlationId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'correlationId' is the wrong type; must be a string (up to 255 chars)");var p=t.byteLength(i,"utf8");c+=1,c+=p}if(i=r.replyTo,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'replyTo' is the wrong type; must be a string (up to 255 chars)");var d=t.byteLength(i,"utf8");c+=1,c+=d}if(i=r.expiration,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'expiration' is the wrong type; must be a string (up to 255 chars)");var v=t.byteLength(i,"utf8");c+=1,c+=v}if(i=r.messageId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'messageId' is the wrong type; must be a string (up to 255 chars)");var g=t.byteLength(i,"utf8");c+=1,c+=g}if(i=r.timestamp,void 0!=i){if("number"!=typeof i||isNaN(i))throw new TypeError("Field 'timestamp' is the wrong type; must be a number (but not NaN)");c+=8}if(i=r.type,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'type' is the wrong type; must be a string (up to 255 chars)");var y=t.byteLength(i,"utf8");c+=1,c+=y}if(i=r.userId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'userId' is the wrong type; must be a string (up to 255 chars)");var m=t.byteLength(i,"utf8");c+=1,c+=m}if(i=r.appId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'appId' is the wrong type; must be a string (up to 255 chars)");var b=t.byteLength(i,"utf8");c+=1,c+=b}if(i=r.clusterId,void 0!=i){if(!("string"==typeof i&&t.byteLength(i)<256))throw new TypeError("Field 'clusterId' is the wrong type; must be a string (up to 255 chars)");var w=t.byteLength(i,"utf8");c+=1,c+=w}var _=new t(22+c);return _[0]=2,_.writeUInt16BE(e,1),_.writeUInt32BE(3932160,7),Ct.writeUInt64BE(_,n,11),a=0,s=21,i=r.contentType,void 0!=i&&(a+=32768,_[s]=l,s++,_.write(i,s,"utf8"),s+=l),i=r.contentEncoding,void 0!=i&&(a+=16384,_[s]=f,s++,_.write(i,s,"utf8"),s+=f),i=r.headers,void 0!=i&&(a+=8192,s+=h.copy(_,s)),i=r.deliveryMode,void 0!=i&&(a+=4096,_.writeUInt8(i,s),s++),i=r.priority,void 0!=i&&(a+=2048,_.writeUInt8(i,s),s++),i=r.correlationId,void 0!=i&&(a+=1024,_[s]=p,s++,_.write(i,s,"utf8"),s+=p),i=r.replyTo,void 0!=i&&(a+=512,_[s]=d,s++,_.write(i,s,"utf8"),s+=d),i=r.expiration,void 0!=i&&(a+=256,_[s]=v,s++,_.write(i,s,"utf8"),s+=v),i=r.messageId,void 0!=i&&(a+=128,_[s]=g,s++,_.write(i,s,"utf8"),s+=g),i=r.timestamp,void 0!=i&&(a+=64,Ct.writeUInt64BE(_,i,s),s+=8),i=r.type,void 0!=i&&(a+=32,_[s]=y,s++,_.write(i,s,"utf8"),s+=y),i=r.userId,void 0!=i&&(a+=16,_[s]=m,s++,_.write(i,s,"utf8"),s+=m),i=r.appId,void 0!=i&&(a+=8,_[s]=b,s++,_.write(i,s,"utf8"),s+=b),i=r.clusterId,void 0!=i&&(a+=4,_[s]=w,s++,_.write(i,s,"utf8"),s+=w),_[s]=206,_.writeUInt32BE(s-7,3),_.writeUInt16BE(a,19),_.slice(0,s+1)}function It(e){var t,n,r,i=2;if(t=e.readUInt16BE(0),0===t)return{};var o={contentType:void 0,contentEncoding:void 0,headers:void 0,deliveryMode:void 0,priority:void 0,correlationId:void 0,replyTo:void 0,expiration:void 0,messageId:void 0,timestamp:void 0,type:void 0,userId:void 0,appId:void 0,clusterId:void 0};return 32768&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.contentType=n),16384&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.contentEncoding=n),8192&t&&(r=e.readUInt32BE(i),i+=4,n=Tt(e.slice(i,i+r)),i+=r,o.headers=n),4096&t&&(n=e[i],i++,o.deliveryMode=n),2048&t&&(n=e[i],i++,o.priority=n),1024&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.correlationId=n),512&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.replyTo=n),256&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.expiration=n),128&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.messageId=n),64&t&&(n=Ct.readUInt64BE(e,i),i+=8,o.timestamp=n),32&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.type=n),16&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.userId=n),8&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.appId=n),4&t&&(r=e.readUInt8(i),i++,n=e.toString("utf8",i,i+r),i+=r,o.clusterId=n),o}var kt=n(68),Ct=n(69),St=kt.encodeTable,Tt=kt.decodeFields,Ut=new t(4096);Object.freeze({});e.exports.constants={FRAME_METHOD:1,FRAME_HEADER:2,FRAME_BODY:3,FRAME_HEARTBEAT:8,FRAME_MIN_SIZE:4096,FRAME_END:206,REPLY_SUCCESS:200,CONTENT_TOO_LARGE:311,NO_ROUTE:312,NO_CONSUMERS:313,ACCESS_REFUSED:403,NOT_FOUND:404,RESOURCE_LOCKED:405,PRECONDITION_FAILED:406,CONNECTION_FORCED:320,INVALID_PATH:402,FRAME_ERROR:501,SYNTAX_ERROR:502,COMMAND_INVALID:503,CHANNEL_ERROR:504,UNEXPECTED_FRAME:505,RESOURCE_ERROR:506,NOT_ALLOWED:530,NOT_IMPLEMENTED:540,INTERNAL_ERROR:541},e.exports.constant_strs={1:"FRAME-METHOD",2:"FRAME-HEADER",3:"FRAME-BODY",8:"FRAME-HEARTBEAT",200:"REPLY-SUCCESS",206:"FRAME-END",311:"CONTENT-TOO-LARGE",312:"NO-ROUTE",313:"NO-CONSUMERS",320:"CONNECTION-FORCED",402:"INVALID-PATH",403:"ACCESS-REFUSED",404:"NOT-FOUND",405:"RESOURCE-LOCKED",406:"PRECONDITION-FAILED",501:"FRAME-ERROR",502:"SYNTAX-ERROR",503:"COMMAND-INVALID",504:"CHANNEL-ERROR",505:"UNEXPECTED-FRAME",506:"RESOURCE-ERROR",530:"NOT-ALLOWED",540:"NOT-IMPLEMENTED",541:"INTERNAL-ERROR",4096:"FRAME-MIN-SIZE"},e.exports.FRAME_OVERHEAD=8,e.exports.decode=function(e,t){switch(e){case 655370:return r(t);case 655371:return o(t);case 655380:return a(t);case 655381:return c(t);case 655390:return f(t);case 655391:return p(t);case 655400:return v(t);case 655401:return y(t);case 655410:return b(t);case 655411:return _(t);case 655420:return x(t);case 655421:return k(t);case 1310730:return S(t);case 1310731:return U(t);case 1310740:return j(t);case 1310741:return A(t);case 1310760:return L(t);case 1310761:return F(t);case 1966090:return N(t);case 1966091:return q(t);case 2621450:return H(t);case 2621451:return W(t);case 2621460:return Y(t);case 2621461:return G(t);case 2621470:return X(t);case 2621471:return Z(t);case 2621480:return te(t);case 2621491:return re(t);case 3276810:return oe(t);case 3276811:return ae(t);case 3276820:return ce(t);case 3276821:return fe(t);case 3276830:return pe(t);case 3276831:return ve(t);case 3276840:return ye(t);case 3276841:return be(t);case 3276850:return _e(t);case 3276851:return xe(t);case 3932170:return ke(t);case 3932171:return Se(t);case 3932180:return Ue(t);case 3932181:return je(t);case 3932190:return Ae(t);case 3932191:return Le(t);case 3932200:return Fe(t);case 3932210:return Ne(t);case 3932220:return qe(t);case 3932230:return He(t);case 3932231:return We(t);case 3932232:return Ye(t);case 3932240:return Ge(t);case 3932250:return Xe(t);case 3932260:return Ze(t);case 3932270:return tt(t);case 3932271:return rt(t);case 3932280:return ot(t);case 5898250:return at(t);case 5898251:return ct(t);case 5898260:return ft(t);case 5898261:return pt(t);case 5898270:return vt(t);case 5898271:return yt(t);case 5570570:return bt(t);case 5570571:return _t(t);case 60:return It(t);default:throw new Error("Unknown class/method ID")}},e.exports.encodeMethod=function(e,t,n){switch(e){case 655370:return i(t,n);case 655371:return s(t,n);case 655380:return u(t,n);case 655381:return l(t,n);case 655390:return h(t,n);case 655391:return d(t,n);case 655400:return g(t,n);case 655401:return m(t,n);case 655410:return w(t,n);case 655411:return E(t,n);case 655420:return I(t,n);case 655421:return C(t,n);case 1310730:return T(t,n);case 1310731:return B(t,n);case 1310740:return O(t,n);case 1310741:return R(t,n);case 1310760:return M(t,n);case 1310761:return P(t,n);case 1966090:return D(t,n);case 1966091:return z(t,n);case 2621450:return Q(t,n);case 2621451:return K(t,n);case 2621460:return V(t,n);case 2621461:return $(t,n);case 2621470:return J(t,n);case 2621471:return ee(t,n);case 2621480:return ne(t,n);case 2621491:return ie(t,n);case 3276810:return se(t,n);case 3276811:return ue(t,n);case 3276820:return le(t,n);case 3276821:return he(t,n);case 3276830:return de(t,n);case 3276831:return ge(t,n);case 3276840:return me(t,n);case 3276841:return we(t,n);case 3276850:return Ee(t,n);case 3276851:return Ie(t,n);case 3932170:return Ce(t,n);case 3932171:return Te(t,n);case 3932180:return Be(t,n);case 3932181:return Oe(t,n);case 3932190:return Re(t,n);case 3932191:return Me(t,n);case 3932200:return Pe(t,n);case 3932210:return De(t,n);case 3932220:return ze(t,n);case 3932230:return Qe(t,n);case 3932231:return Ke(t,n);case 3932232:return Ve(t,n);case 3932240:return $e(t,n);case 3932250:return Je(t,n);case 3932260:return et(t,n);case 3932270:return nt(t,n);case 3932271:return it(t,n);case 3932280:return st(t,n);case 5898250:return ut(t,n);case 5898251:return lt(t,n);case 5898260:return ht(t,n);case 5898261:return dt(t,n);case 5898270:return gt(t,n);case 5898271:return mt(t,n);case 5570570:return wt(t,n);case 5570571:return Et(t,n);default:throw new Error("Unknown class/method ID")}},e.exports.encodeProperties=function(e,t,n,r){switch(e){case 60:return xt(t,n,r);default:throw new Error("Unknown class/properties ID")}},e.exports.info=function(e){switch(e){case 655370:return Bt;case 655371:return jt;case 655380:return Ot;case 655381:return At;case 655390:return Rt;case 655391:return Lt;case 655400:return Mt;case 655401:return Ft;case 655410:return Pt;case 655411:return Nt;case 655420:return Dt;case 655421:return qt;case 1310730:return zt;case 1310731:return Ht;case 1310740:return Qt;case 1310741:return Wt;case 1310760:return Kt;case 1310761:return Yt;case 1966090:return Vt;case 1966091:return Gt;case 2621450:return $t;case 2621451:return Xt;case 2621460:return Jt;case 2621461:return Zt;case 2621470:return en;case 2621471:return tn;case 2621480:return nn;case 2621491:return rn;case 3276810:return on;case 3276811:return sn;case 3276820:return an;case 3276821:return un;case 3276830:return cn;case 3276831:return ln;case 3276840:return fn;case 3276841:return hn;case 3276850:return pn;case 3276851:return dn;case 3932170:return vn;case 3932171:return gn;case 3932180:return yn;case 3932181:return mn;case 3932190:return bn;case 3932191:return wn;case 3932200:return _n;case 3932210:return En;case 3932220:return xn;case 3932230:return In;case 3932231:return kn;case 3932232:return Cn;case 3932240:return Sn;case 3932250:return Tn;case 3932260:return Un;case 3932270:return Bn;case 3932271:return jn;case 3932280:return On;case 5898250:return An;case 5898251:return Rn;case 5898260:return Ln;case 5898261:return Mn;case 5898270:return Fn;case 5898271:return Pn;case 5570570:return Nn;case 5570571:return Dn;case 60:return qn;default:throw new Error("Unknown class/method ID")}},e.exports.ConnectionStart=655370;var Bt=e.exports.methodInfoConnectionStart={id:655370,name:"ConnectionStart",args:[{type:"octet",name:"versionMajor","default":0},{type:"octet",name:"versionMinor","default":9},{type:"table",name:"serverProperties"},{type:"longstr",name:"mechanisms","default":"PLAIN"},{type:"longstr",name:"locales","default":"en_US"}]};e.exports.ConnectionStartOk=655371;var jt=e.exports.methodInfoConnectionStartOk={id:655371,name:"ConnectionStartOk",args:[{type:"table",name:"clientProperties"},{type:"shortstr",name:"mechanism","default":"PLAIN"},{type:"longstr",name:"response"},{type:"shortstr",name:"locale","default":"en_US"}]};e.exports.ConnectionSecure=655380;var Ot=e.exports.methodInfoConnectionSecure={id:655380,name:"ConnectionSecure",args:[{type:"longstr",name:"challenge"}]};e.exports.ConnectionSecureOk=655381;var At=e.exports.methodInfoConnectionSecureOk={id:655381,name:"ConnectionSecureOk",args:[{type:"longstr",name:"response"}]};e.exports.ConnectionTune=655390;var Rt=e.exports.methodInfoConnectionTune={id:655390,name:"ConnectionTune",args:[{type:"short",name:"channelMax","default":0},{type:"long",name:"frameMax","default":0},{type:"short",name:"heartbeat","default":0}]};e.exports.ConnectionTuneOk=655391;var Lt=e.exports.methodInfoConnectionTuneOk={id:655391,name:"ConnectionTuneOk",args:[{type:"short",name:"channelMax","default":0},{type:"long",name:"frameMax","default":0},{type:"short",name:"heartbeat","default":0}]};e.exports.ConnectionOpen=655400;var Mt=e.exports.methodInfoConnectionOpen={id:655400,name:"ConnectionOpen",args:[{type:"shortstr",name:"virtualHost","default":"/"},{type:"shortstr",name:"capabilities","default":""},{type:"bit",name:"insist","default":!1}]};e.exports.ConnectionOpenOk=655401;var Ft=e.exports.methodInfoConnectionOpenOk={id:655401,name:"ConnectionOpenOk",args:[{type:"shortstr",name:"knownHosts","default":""}]};e.exports.ConnectionClose=655410;var Pt=e.exports.methodInfoConnectionClose={id:655410,name:"ConnectionClose",args:[{type:"short",name:"replyCode"},{type:"shortstr",name:"replyText","default":""},{type:"short",name:"classId"},{type:"short",name:"methodId"}]};e.exports.ConnectionCloseOk=655411;var Nt=e.exports.methodInfoConnectionCloseOk={id:655411,name:"ConnectionCloseOk",args:[]};e.exports.ConnectionBlocked=655420;var Dt=e.exports.methodInfoConnectionBlocked={id:655420,name:"ConnectionBlocked",args:[{type:"shortstr",name:"reason","default":""}]};e.exports.ConnectionUnblocked=655421;var qt=e.exports.methodInfoConnectionUnblocked={id:655421,name:"ConnectionUnblocked",args:[]};e.exports.ChannelOpen=1310730;var zt=e.exports.methodInfoChannelOpen={id:1310730,name:"ChannelOpen",args:[{type:"shortstr",name:"outOfBand","default":""}]};e.exports.ChannelOpenOk=1310731;var Ht=e.exports.methodInfoChannelOpenOk={id:1310731,name:"ChannelOpenOk",args:[{type:"longstr",name:"channelId","default":""}]};e.exports.ChannelFlow=1310740;var Qt=e.exports.methodInfoChannelFlow={id:1310740,name:"ChannelFlow",args:[{type:"bit",name:"active" +}]};e.exports.ChannelFlowOk=1310741;var Wt=e.exports.methodInfoChannelFlowOk={id:1310741,name:"ChannelFlowOk",args:[{type:"bit",name:"active"}]};e.exports.ChannelClose=1310760;var Kt=e.exports.methodInfoChannelClose={id:1310760,name:"ChannelClose",args:[{type:"short",name:"replyCode"},{type:"shortstr",name:"replyText","default":""},{type:"short",name:"classId"},{type:"short",name:"methodId"}]};e.exports.ChannelCloseOk=1310761;var Yt=e.exports.methodInfoChannelCloseOk={id:1310761,name:"ChannelCloseOk",args:[]};e.exports.AccessRequest=1966090;var Vt=e.exports.methodInfoAccessRequest={id:1966090,name:"AccessRequest",args:[{type:"shortstr",name:"realm","default":"/data"},{type:"bit",name:"exclusive","default":!1},{type:"bit",name:"passive","default":!0},{type:"bit",name:"active","default":!0},{type:"bit",name:"write","default":!0},{type:"bit",name:"read","default":!0}]};e.exports.AccessRequestOk=1966091;var Gt=e.exports.methodInfoAccessRequestOk={id:1966091,name:"AccessRequestOk",args:[{type:"short",name:"ticket","default":1}]};e.exports.ExchangeDeclare=2621450;var $t=e.exports.methodInfoExchangeDeclare={id:2621450,name:"ExchangeDeclare",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"type","default":"direct"},{type:"bit",name:"passive","default":!1},{type:"bit",name:"durable","default":!1},{type:"bit",name:"autoDelete","default":!1},{type:"bit",name:"internal","default":!1},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.ExchangeDeclareOk=2621451;var Xt=e.exports.methodInfoExchangeDeclareOk={id:2621451,name:"ExchangeDeclareOk",args:[]};e.exports.ExchangeDelete=2621460;var Jt=e.exports.methodInfoExchangeDelete={id:2621460,name:"ExchangeDelete",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"exchange"},{type:"bit",name:"ifUnused","default":!1},{type:"bit",name:"nowait","default":!1}]};e.exports.ExchangeDeleteOk=2621461;var Zt=e.exports.methodInfoExchangeDeleteOk={id:2621461,name:"ExchangeDeleteOk",args:[]};e.exports.ExchangeBind=2621470;var en=e.exports.methodInfoExchangeBind={id:2621470,name:"ExchangeBind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"destination"},{type:"shortstr",name:"source"},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.ExchangeBindOk=2621471;var tn=e.exports.methodInfoExchangeBindOk={id:2621471,name:"ExchangeBindOk",args:[]};e.exports.ExchangeUnbind=2621480;var nn=e.exports.methodInfoExchangeUnbind={id:2621480,name:"ExchangeUnbind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"destination"},{type:"shortstr",name:"source"},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.ExchangeUnbindOk=2621491;var rn=e.exports.methodInfoExchangeUnbindOk={id:2621491,name:"ExchangeUnbindOk",args:[]};e.exports.QueueDeclare=3276810;var on=e.exports.methodInfoQueueDeclare={id:3276810,name:"QueueDeclare",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"passive","default":!1},{type:"bit",name:"durable","default":!1},{type:"bit",name:"exclusive","default":!1},{type:"bit",name:"autoDelete","default":!1},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.QueueDeclareOk=3276811;var sn=e.exports.methodInfoQueueDeclareOk={id:3276811,name:"QueueDeclareOk",args:[{type:"shortstr",name:"queue"},{type:"long",name:"messageCount"},{type:"long",name:"consumerCount"}]};e.exports.QueueBind=3276820;var an=e.exports.methodInfoQueueBind={id:3276820,name:"QueueBind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.QueueBindOk=3276821;var un=e.exports.methodInfoQueueBindOk={id:3276821,name:"QueueBindOk",args:[]};e.exports.QueuePurge=3276830;var cn=e.exports.methodInfoQueuePurge={id:3276830,name:"QueuePurge",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"nowait","default":!1}]};e.exports.QueuePurgeOk=3276831;var ln=e.exports.methodInfoQueuePurgeOk={id:3276831,name:"QueuePurgeOk",args:[{type:"long",name:"messageCount"}]};e.exports.QueueDelete=3276840;var fn=e.exports.methodInfoQueueDelete={id:3276840,name:"QueueDelete",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"ifUnused","default":!1},{type:"bit",name:"ifEmpty","default":!1},{type:"bit",name:"nowait","default":!1}]};e.exports.QueueDeleteOk=3276841;var hn=e.exports.methodInfoQueueDeleteOk={id:3276841,name:"QueueDeleteOk",args:[{type:"long",name:"messageCount"}]};e.exports.QueueUnbind=3276850;var pn=e.exports.methodInfoQueueUnbind={id:3276850,name:"QueueUnbind",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey","default":""},{type:"table",name:"arguments","default":{}}]};e.exports.QueueUnbindOk=3276851;var dn=e.exports.methodInfoQueueUnbindOk={id:3276851,name:"QueueUnbindOk",args:[]};e.exports.BasicQos=3932170;var vn=e.exports.methodInfoBasicQos={id:3932170,name:"BasicQos",args:[{type:"long",name:"prefetchSize","default":0},{type:"short",name:"prefetchCount","default":0},{type:"bit",name:"global","default":!1}]};e.exports.BasicQosOk=3932171;var gn=e.exports.methodInfoBasicQosOk={id:3932171,name:"BasicQosOk",args:[]};e.exports.BasicConsume=3932180;var yn=e.exports.methodInfoBasicConsume={id:3932180,name:"BasicConsume",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"shortstr",name:"consumerTag","default":""},{type:"bit",name:"noLocal","default":!1},{type:"bit",name:"noAck","default":!1},{type:"bit",name:"exclusive","default":!1},{type:"bit",name:"nowait","default":!1},{type:"table",name:"arguments","default":{}}]};e.exports.BasicConsumeOk=3932181;var mn=e.exports.methodInfoBasicConsumeOk={id:3932181,name:"BasicConsumeOk",args:[{type:"shortstr",name:"consumerTag"}]};e.exports.BasicCancel=3932190;var bn=e.exports.methodInfoBasicCancel={id:3932190,name:"BasicCancel",args:[{type:"shortstr",name:"consumerTag"},{type:"bit",name:"nowait","default":!1}]};e.exports.BasicCancelOk=3932191;var wn=e.exports.methodInfoBasicCancelOk={id:3932191,name:"BasicCancelOk",args:[{type:"shortstr",name:"consumerTag"}]};e.exports.BasicPublish=3932200;var _n=e.exports.methodInfoBasicPublish={id:3932200,name:"BasicPublish",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"exchange","default":""},{type:"shortstr",name:"routingKey","default":""},{type:"bit",name:"mandatory","default":!1},{type:"bit",name:"immediate","default":!1}]};e.exports.BasicReturn=3932210;var En=e.exports.methodInfoBasicReturn={id:3932210,name:"BasicReturn",args:[{type:"short",name:"replyCode"},{type:"shortstr",name:"replyText","default":""},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey"}]};e.exports.BasicDeliver=3932220;var xn=e.exports.methodInfoBasicDeliver={id:3932220,name:"BasicDeliver",args:[{type:"shortstr",name:"consumerTag"},{type:"longlong",name:"deliveryTag"},{type:"bit",name:"redelivered","default":!1},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey"}]};e.exports.BasicGet=3932230;var In=e.exports.methodInfoBasicGet={id:3932230,name:"BasicGet",args:[{type:"short",name:"ticket","default":0},{type:"shortstr",name:"queue","default":""},{type:"bit",name:"noAck","default":!1}]};e.exports.BasicGetOk=3932231;var kn=e.exports.methodInfoBasicGetOk={id:3932231,name:"BasicGetOk",args:[{type:"longlong",name:"deliveryTag"},{type:"bit",name:"redelivered","default":!1},{type:"shortstr",name:"exchange"},{type:"shortstr",name:"routingKey"},{type:"long",name:"messageCount"}]};e.exports.BasicGetEmpty=3932232;var Cn=e.exports.methodInfoBasicGetEmpty={id:3932232,name:"BasicGetEmpty",args:[{type:"shortstr",name:"clusterId","default":""}]};e.exports.BasicAck=3932240;var Sn=e.exports.methodInfoBasicAck={id:3932240,name:"BasicAck",args:[{type:"longlong",name:"deliveryTag","default":0},{type:"bit",name:"multiple","default":!1}]};e.exports.BasicReject=3932250;var Tn=e.exports.methodInfoBasicReject={id:3932250,name:"BasicReject",args:[{type:"longlong",name:"deliveryTag"},{type:"bit",name:"requeue","default":!0}]};e.exports.BasicRecoverAsync=3932260;var Un=e.exports.methodInfoBasicRecoverAsync={id:3932260,name:"BasicRecoverAsync",args:[{type:"bit",name:"requeue","default":!1}]};e.exports.BasicRecover=3932270;var Bn=e.exports.methodInfoBasicRecover={id:3932270,name:"BasicRecover",args:[{type:"bit",name:"requeue","default":!1}]};e.exports.BasicRecoverOk=3932271;var jn=e.exports.methodInfoBasicRecoverOk={id:3932271,name:"BasicRecoverOk",args:[]};e.exports.BasicNack=3932280;var On=e.exports.methodInfoBasicNack={id:3932280,name:"BasicNack",args:[{type:"longlong",name:"deliveryTag","default":0},{type:"bit",name:"multiple","default":!1},{type:"bit",name:"requeue","default":!0}]};e.exports.TxSelect=5898250;var An=e.exports.methodInfoTxSelect={id:5898250,name:"TxSelect",args:[]};e.exports.TxSelectOk=5898251;var Rn=e.exports.methodInfoTxSelectOk={id:5898251,name:"TxSelectOk",args:[]};e.exports.TxCommit=5898260;var Ln=e.exports.methodInfoTxCommit={id:5898260,name:"TxCommit",args:[]};e.exports.TxCommitOk=5898261;var Mn=e.exports.methodInfoTxCommitOk={id:5898261,name:"TxCommitOk",args:[]};e.exports.TxRollback=5898270;var Fn=e.exports.methodInfoTxRollback={id:5898270,name:"TxRollback",args:[]};e.exports.TxRollbackOk=5898271;var Pn=e.exports.methodInfoTxRollbackOk={id:5898271,name:"TxRollbackOk",args:[]};e.exports.ConfirmSelect=5570570;var Nn=e.exports.methodInfoConfirmSelect={id:5570570,name:"ConfirmSelect",args:[{type:"bit",name:"nowait","default":!1}]};e.exports.ConfirmSelectOk=5570571;var Dn=e.exports.methodInfoConfirmSelectOk={id:5570571,name:"ConfirmSelectOk",args:[]};e.exports.BasicProperties=60;var qn=e.exports.propertiesInfoBasicProperties={id:60,name:"BasicProperties",args:[{type:"shortstr",name:"contentType"},{type:"shortstr",name:"contentEncoding"},{type:"table",name:"headers"},{type:"octet",name:"deliveryMode"},{type:"octet",name:"priority"},{type:"shortstr",name:"correlationId"},{type:"shortstr",name:"replyTo"},{type:"shortstr",name:"expiration"},{type:"shortstr",name:"messageId"},{type:"timestamp",name:"timestamp"},{type:"shortstr",name:"type"},{type:"shortstr",name:"userId"},{type:"shortstr",name:"appId"},{type:"shortstr",name:"clusterId"}]}}).call(t,n(3).Buffer)},function(e,t,n){(function(t){"use strict";function r(e){return e>=0x8000000000000000||Math.abs(e)<0x4000000000000&&Math.floor(e)!==e}function i(e,n,r){var i=r;r+=4;for(var o in n)if(void 0!==n[o]){var a=t.byteLength(o);e.writeUInt8(a,r),r++,e.write(o,r,"utf8"),r+=a,r+=s(e,n[o],r)}var u=r-i;return e.writeUInt32BE(u-4,i),u}function o(e,t,n){var r=n;n+=4;for(var i=0,o=t.length;o>i;i++)n+=s(e,t[i],n);var a=n-r;return e.writeUInt32BE(a-4,r),a}function s(e,n,s){function a(t){e.write(t,s),s++}var c=s,l=typeof n,f=n;switch(n&&"object"===l&&n.hasOwnProperty("!")&&(f=n.value,l=n["!"]),l){case"string":var h=t.byteLength(f,"utf8");a("S"),e.writeUInt32BE(h,s),s+=4,e.write(f,s,"utf8"),s+=h;break;case"object":null===f?a("V"):Array.isArray(f)?(a("A"),s+=o(e,f,s)):t.isBuffer(f)?(a("x"),e.writeUInt32BE(f.length,s),s+=4,f.copy(e,s),s+=f.length):(a("F"),s+=i(e,f,s));break;case"boolean":a("t"),e.writeUInt8(f?1:0,s),s++;break;case"number":r(f)?(a("d"),e.writeDoubleBE(f,s),s+=8):128>f&&f>=-128?(a("b"),e.writeInt8(f,s),s++):f>=-32768&&32768>f?(a("s"),e.writeInt16BE(f,s),s+=2):f>=-2147483648&&2147483648>f?(a("I"),e.writeInt32BE(f,s),s+=4):(a("l"),u.writeInt64BE(e,f,s),s+=8);break;case"timestamp":a("T"),u.writeUInt64BE(e,f,s),s+=8;break;case"float":a("f"),e.writeFloatBE(f,s),s+=4;break;case"decimal":if(a("D"),!(f.hasOwnProperty("places")&&f.hasOwnProperty("digits")&&f.places>=0&&f.places<256))throw new TypeError("Decimal value must be {'places': 0..255, 'digits': uint32}, got "+JSON.stringify(f));e[s]=f.places,s++,e.writeUInt32BE(f.digits,s),s+=4;break;default:throw new TypeError("Unknown type to encode: "+l)}return s-c}function a(e){function t(){var t=String.fromCharCode(e[c]);switch(c++,t){case"b":o=e.readInt8(c),c++;break;case"S":r=e.readUInt32BE(c),c+=4,o=e.toString("utf8",c,c+r),c+=r;break;case"I":o=e.readInt32BE(c),c+=4;break;case"D":var i=e[c];c++;var s=e.readUInt32BE(c);c+=4,o={"!":"decimal",value:{places:i,digits:s}};break;case"T":o=u.readUInt64BE(e,c),c+=8,o={"!":"timestamp",value:o};break;case"F":r=e.readUInt32BE(c),c+=4,o=a(e.slice(c,c+r)),c+=r;break;case"A":r=e.readUInt32BE(c),c+=4,n(c+r);break;case"d":o=e.readDoubleBE(c),c+=8;break;case"f":o=e.readFloatBE(c),c+=4;break;case"l":o=u.readInt64BE(e,c),c+=8;break;case"s":o=e.readInt16BE(c),c+=2;break;case"t":o=0!=e[c],c++;break;case"V":o=null;break;case"x":r=e.readUInt32BE(c),c+=4,o=e.slice(c,c+r),c+=r;break;default:throw new TypeError('Unexpected type tag "'+t+'"')}}function n(e){for(var n=[];e>c;)t(),n.push(o);o=n}for(var r,i,o,s={},c=0,l=e.length;l>c;)r=e.readUInt8(c),c++,i=e.toString("utf8",c,c+r),c+=r,t(),s[i]=o;return s}var u=n(69);e.exports.encodeTable=i,e.exports.decodeFields=a}).call(t,n(3).Buffer)},function(e,t,n){(function(t){"use strict";function r(e){return G>=e&&e>=-G}function i(e){K(r(e),"number cannot be represented as a contiguous integer")}function o(e,t,n){K.ok("number"==typeof e&&e>=t&&n>=e&&Math.floor(e)===e,"not a number in the required range")}function s(e,t,n){return e.readUInt8(t,n)<<16|e.readUInt16BE(t+1,n)}function a(e,t,n,r){r||(o(t,0,16777215),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeUInt8(t>>>16,n,r),e.writeUInt16BE(65535&t,n+1,r)}function u(e,t,n){return(e.readUInt8(t,n)||0)*Y+e.readUInt32BE(t+1,n)}function c(e,t,n,r){r||(o(t,0,0xffffffffff),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeUInt8(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+1,r)}function l(e,t,n){return e.readUInt16BE(t,n)*Y+e.readUInt32BE(t+2,n)}function f(e,t,n,r){r||(o(t,0,0xffffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeUInt16BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+2,r)}function h(e,t,n){return((e.readUInt8(t,n)||0)<<16|e.readUInt16BE(t+1,n))*Y+e.readUInt32BE(t+3,n)}function p(e,t,n,r){if(r||(o(t,0,72057594037927940),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),72057594037927940>t){var i=Math.floor(t*V);e.writeUInt8(i>>>16,n,r),e.writeUInt16BE(65535&i,n+1,r),e.writeInt32BE(-1&t,n+3,r)}else e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255}function d(e,t,n){return e.readUInt32BE(t,n)*Y+e.readUInt32BE(t+4,n)}function v(e,t,n,r){r||(o(t,0,0x10000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x10000000000000000>t?(e.writeUInt32BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+4,r)):(e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=255)}function g(e,t,n){return e.readUInt8(t+2,n)<<16|e.readUInt16LE(t,n)}function y(e,t,n,r){r||(o(t,0,16777215),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeUInt16LE(65535&t,n,r),e.writeUInt8(t>>>16,n+2,r)}function m(e,t,n){return(e.readUInt8(t+4,n)||0)*Y+e.readUInt32LE(t,n)}function b(e,t,n,r){r||(o(t,0,0xffffffffff),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeUInt8(Math.floor(t*V),n+4,r)}function w(e,t,n){return e.readUInt16LE(t+4,n)*Y+e.readUInt32LE(t,n)}function _(e,t,n,r){r||(o(t,0,0xffffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeUInt16LE(Math.floor(t*V),n+4,r)}function E(e,t,n){return((e.readUInt8(t+6,n)||0)<<16|e.readUInt16LE(t+4,n))*Y+e.readUInt32LE(t,n)}function x(e,t,n,r){if(r||(o(t,0,72057594037927940),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),72057594037927940>t){e.writeInt32LE(-1&t,n,r);var i=Math.floor(t*V);e.writeUInt16LE(65535&i,n+4,r),e.writeUInt8(i>>>16,n+6,r)}else e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255}function I(e,t,n){return e.readUInt32LE(t+4,n)*Y+e.readUInt32LE(t,n)}function k(e,t,n,r){r||(o(t,0,0x10000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x10000000000000000>t?(e.writeInt32LE(-1&t,n,r),e.writeUInt32LE(Math.floor(t*V),n+4,r)):(e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=255)}function C(e,t,n){return(e.readInt8(t,n)<<16)+e.readUInt16BE(t+1,n)}function S(e,t,n,r){r||(o(t,-8388608,8388607),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeInt8(t>>16,n,r),e.writeUInt16BE(65535&t,n+1,r)}function T(e,t,n){return(e.readInt8(t,n)||0)*Y+e.readUInt32BE(t+1,n)}function U(e,t,n,r){r||(o(t,-549755813888,549755813887),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeInt8(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+1,r)}function B(e,t,n){return e.readInt16BE(t,n)*Y+e.readUInt32BE(t+2,n)}function j(e,t,n,r){r||(o(t,-0x800000000000,0x7fffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeInt16BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+2,r)}function O(e,t,n){return(((e.readInt8(t,n)||0)<<16)+e.readUInt16BE(t+1,n))*Y+e.readUInt32BE(t+3,n)}function A(e,t,n,r){if(r||(o(t,-0x800000000000000,0x80000000000000),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),0x80000000000000>t){var i=Math.floor(t*V);e.writeInt8(i>>16,n,r),e.writeUInt16BE(65535&i,n+1,r),e.writeInt32BE(-1&t,n+3,r)}else e[n]=127,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255}function R(e,t,n){return e.readInt32BE(t,n)*Y+e.readUInt32BE(t+4,n)}function L(e,t,n,r){r||(o(t,-0x800000000000000000,0x8000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x8000000000000000>t?(e.writeInt32BE(Math.floor(t*V),n,r),e.writeInt32BE(-1&t,n+4,r)):(e[n]=127,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=255)}function M(e,t,n){return(e.readInt8(t+2,n)<<16)+e.readUInt16LE(t,n)}function F(e,t,n,r){r||(o(t,-8388608,8388607),K.ok(n+3<=e.length,"attempt to write beyond end of buffer")),e.writeUInt16LE(65535&t,n,r),e.writeInt8(t>>16,n+2,r)}function P(e,t,n){return(e.readInt8(t+4,n)||0)*Y+e.readUInt32LE(t,n)}function N(e,t,n,r){r||(o(t,-549755813888,549755813887),K.ok(n+5<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeInt8(Math.floor(t*V),n+4,r)}function D(e,t,n){return e.readInt16LE(t+4,n)*Y+e.readUInt32LE(t,n)}function q(e,t,n,r){r||(o(t,-0x800000000000,0x7fffffffffff),K.ok(n+6<=e.length,"attempt to write beyond end of buffer")),e.writeInt32LE(-1&t,n,r),e.writeInt16LE(Math.floor(t*V),n+4,r)}function z(e,t,n){return(((e.readInt8(t+6,n)||0)<<16)+e.readUInt16LE(t+4,n))*Y+e.readUInt32LE(t,n)}function H(e,t,n,r){if(r||(o(t,-0x80000000000000,0x80000000000000),K.ok(n+7<=e.length,"attempt to write beyond end of buffer")),0x80000000000000>t){e.writeInt32LE(-1&t,n,r);var i=Math.floor(t*V);e.writeUInt16LE(65535&i,n+4,r),e.writeInt8(i>>16,n+6,r)}else e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=127}function Q(e,t,n){return e.readInt32LE(t+4,n)*Y+e.readUInt32LE(t,n)}function W(e,t,n,r){r||(o(t,-0x8000000000000000,0x8000000000000000),K.ok(n+8<=e.length,"attempt to write beyond end of buffer")),0x8000000000000000>t?(e.writeInt32LE(-1&t,n,r),e.writeInt32LE(Math.floor(t*V),n+4,r)):(e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255,e[n+4]=255,e[n+5]=255,e[n+6]=255,e[n+7]=127)}var K=n(70),Y=4294967296,V=1/Y,G=9007199254740991;e.exports.isContiguousInt=r,e.exports.assertContiguousInt=i,["UInt","Int"].forEach(function(n){var r=n+"8";e.exports["read"+r]=t.prototype["read"+r].call,e.exports["write"+r]=t.prototype["write"+r].call,["16","32"].forEach(function(r){["LE","BE"].forEach(function(i){var o=n+r+i,s=t.prototype["read"+o];e.exports["read"+o]=function(e,t,n){return s.call(e,t,n)};var a=t.prototype["write"+o];e.exports["write"+o]=function(e,t,n,r){return a.call(e,t,n,r)}})})}),e.exports.readUInt24BE=s,e.exports.writeUInt24BE=a,e.exports.readUInt40BE=u,e.exports.writeUInt40BE=c,e.exports.readUInt48BE=l,e.exports.writeUInt48BE=f,e.exports.readUInt56BE=h,e.exports.writeUInt56BE=p,e.exports.readUInt64BE=d,e.exports.writeUInt64BE=v,e.exports.readUInt24LE=g,e.exports.writeUInt24LE=y,e.exports.readUInt40LE=m,e.exports.writeUInt40LE=b,e.exports.readUInt48LE=w,e.exports.writeUInt48LE=_,e.exports.readUInt56LE=E,e.exports.writeUInt56LE=x,e.exports.readUInt64LE=I,e.exports.writeUInt64LE=k,e.exports.readInt24BE=C,e.exports.writeInt24BE=S,e.exports.readInt40BE=T,e.exports.writeInt40BE=U,e.exports.readInt48BE=B,e.exports.writeInt48BE=j,e.exports.readInt56BE=O,e.exports.writeInt56BE=A,e.exports.readInt64BE=R,e.exports.writeInt64BE=L,e.exports.readInt24LE=M,e.exports.writeInt24LE=F,e.exports.readInt40LE=P,e.exports.writeInt40LE=N,e.exports.readInt48LE=D,e.exports.writeInt48LE=q,e.exports.readInt56LE=z,e.exports.writeInt56LE=H,e.exports.readInt64LE=Q,e.exports.writeInt64LE=W}).call(t,n(3).Buffer)},function(e,t,n){function r(e,t){return p.isUndefined(t)?""+t:p.isNumber(t)&&!isFinite(t)?t.toString():p.isFunction(t)||p.isRegExp(t)?t.toString():t}function i(e,t){return p.isString(e)?e.length=0;o--)if(s[o]!=a[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!u(e[i],t[i]))return!1;return!0}function f(e,t){return e&&t?"[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t?!0:t.call({},e)===!0:!1}function h(e,t,n,r){var i;p.isString(n)&&(r=n,n=null);try{t()}catch(o){i=o}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&s(i,n,"Missing expected exception"+r),!e&&f(i,n)&&s(i,n,"Got unwanted exception"+r),e&&i&&n&&!f(i,n)||!e&&i)throw i}var p=n(71),d=Array.prototype.slice,v=Object.prototype.hasOwnProperty,g=e.exports=a;g.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=o(this),this.generatedMessage=!0);var t=e.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,i=t.name,a=r.indexOf("\n"+i);if(a>=0){var u=r.indexOf("\n",a+1);r=r.substring(u+1)}this.stack=r}}},p.inherits(g.AssertionError,Error),g.fail=s,g.ok=a,g.equal=function(e,t,n){e!=t&&s(e,t,n,"==",g.equal)},g.notEqual=function(e,t,n){e==t&&s(e,t,n,"!=",g.notEqual)},g.deepEqual=function(e,t,n){u(e,t)||s(e,t,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(e,t,n){u(e,t)&&s(e,t,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(e,t,n){e!==t&&s(e,t,n,"===",g.strictEqual)},g.notStrictEqual=function(e,t,n){e===t&&s(e,t,n,"!==",g.notStrictEqual)},g["throws"]=function(e,t,n){h.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(e,t){h.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(e){if(e)throw e};var y=Object.keys||function(e){var t=[];for(var n in e)v.call(e,n)&&t.push(n);return t}},function(e,t,n){(function(e,r){function i(e,n){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(e,n,r){if(e.customInspect&&n&&C(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return b(i)||(i=u(e,i,r)),i}var o=c(e,n);if(o)return o;var s=Object.keys(n),v=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),k(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(n);if(0===s.length){if(C(n)){var g=n.name?": "+n.name:"";return e.stylize("[Function"+g+"]","special")}if(E(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(I(n))return e.stylize(Date.prototype.toString.call(n),"date");if(k(n))return l(n)}var y="",m=!1,w=["{","}"];if(d(n)&&(m=!0,w=["[","]"]),C(n)){var _=n.name?": "+n.name:"";y=" [Function"+_+"]"}if(E(n)&&(y=" "+RegExp.prototype.toString.call(n)),I(n)&&(y=" "+Date.prototype.toUTCString.call(n)),k(n)&&(y=" "+l(n)),0===s.length&&(!m||0==n.length))return w[0]+y+w[1];if(0>r)return E(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var x;return x=m?f(e,n,r,v,s):s.map(function(t){return h(e,n,r,v,t,m)}),e.seen.pop(),p(x,y,w)}function c(e,t){if(_(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):v(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)j(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}function h(e,t,n,r,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),j(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(n)?u(e,c.value,null):u(e,c.value,n-1),a.indexOf("\n")>-1&&(a=o?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")),_(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function v(e){return"boolean"==typeof e}function g(e){return null===e}function y(e){return null==e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function _(e){return void 0===e}function E(e){return x(e)&&"[object RegExp]"===T(e)}function x(e){return"object"==typeof e&&null!==e}function I(e){return x(e)&&"[object Date]"===T(e)}function k(e){return x(e)&&("[object Error]"===T(e)||e instanceof Error)}function C(e){return"function"==typeof e}function S(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function T(e){return Object.prototype.toString.call(e)}function U(e){return 10>e?"0"+e.toString(10):e.toString(10)}function B(){var e=new Date,t=[U(e.getHours()),U(e.getMinutes()),U(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function j(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=g(a)||!x(a)?" "+a:" "+i(a);return s},t.deprecate=function(n,i){function o(){if(!s){if(r.throwDeprecation)throw new Error(i);r.traceDeprecation?console.trace(i):console.error(i),s=!0}return n.apply(this,arguments)}if(_(e.process))return function(){return t.deprecate(n,i).apply(this,arguments)};if(r.noDeprecation===!0)return n;var s=!1;return o};var A,R={};t.debuglog=function(e){if(_(A)&&(A={NODE_ENV:"production"}.NODE_DEBUG||""),e=e.toUpperCase(),!R[e])if(new RegExp("\\b"+e+"\\b","i").test(A)){var n=r.pid;R[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else R[e]=function(){};return R[e]},t.inspect=i,i.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]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=v,t.isNull=g,t.isNullOrUndefined=y,t.isNumber=m,t.isString=b,t.isSymbol=w,t.isUndefined=_,t.isRegExp=E,t.isObject=x,t.isDate=I,t.isError=k,t.isFunction=C,t.isPrimitive=S,t.isBuffer=n(72);var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(){console.log("%s - %s",B(),t.format.apply(t,arguments))},t.inherits=n(73),t._extend=function(e,t){if(!t||!x(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(t,function(){return this}(),n(36))},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){"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,n){(function(t){"use strict";function r(e,t){var n=d(e);if(n){var r=n.size,i=n.rest;if(r>t)throw new Error("Frame size exceeds frame max");if(i.length>r){if(i[r]!==h)throw new Error("Invalid frame");return{type:n.type,channel:n.channel,size:r,payload:i.slice(0,r),rest:i.slice(r+1)}}}return!1}var i=n(67),o=i.constants,s=i.decode,a=n(75);e.exports.PROTOCOL_HEADER="AMQP"+String.fromCharCode(0,0,9,1);var u=o.FRAME_METHOD,c=o.FRAME_HEARTBEAT,l=o.FRAME_HEADER,f=o.FRAME_BODY,h=o.FRAME_END,p=a.builder(f,"channel:16, size:32, payload:size/binary",h);e.exports.makeBodyFrame=function(e,t){return p({channel:e,size:t.length,payload:t})};var d=a.matcher("type:8","channel:16","size:32","rest/binary");e.exports.parseFrame=r;var v=a.matcher("class:16","_weight:16","size:64","flagsAndfields/binary"),g=a.matcher("id:32, args/binary"),y={channel:0};e.exports.decodeFrame=function(e){var t=e.payload;switch(e.type){case u:var n=g(t),r=n.id,i=s(r,n.args);return{id:r,channel:e.channel, fields:i};case l:var o=v(t),r=o["class"],i=s(r,o.flagsAndfields);return{id:r,channel:e.channel,size:o.size,fields:i};case f:return{channel:e.channel,content:e.payload};case c:return y;default:throw new Error("Unknown frame type "+e.type)}},e.exports.HEARTBEAT_BUF=new t([o.FRAME_HEARTBEAT,0,0,0,0,0,0,o.FRAME_END]),e.exports.HEARTBEAT=y}).call(t,n(3).Buffer)},function(e,t,n){"use strict";e.exports.parse=n(76).parse,e.exports.match=n(79).match,e.exports.build=n(80).build,e.exports.write=n(80).write,e.exports.matcher=e.exports.compile=n(81).compile,e.exports.builder=n(81).compile_builder},function(e,t,n){"use strict";function r(e){for(var t=o.parse(e),n=0,r=t.length;r>n;n++){var s=t[n];if(void 0!=s.string)t[n]=i.string(s.string);else if(void 0!=s.value)t[n]=i.value(s.value,s.size,s.specifiers);else{if(void 0==s.name)throw"Unknown segment "+s;t[n]=i.variable(s.name,s.size,s.specifiers)}}return t}var i=n(77),o=n(78);e.exports.parse=function(){var e=[].join.call(arguments,",");return r(e)}},function(e,t){"use strict";function n(e){var t={};for(var n in e)t[e[n]]=1;return t}function r(e,t,r){var i=n(r),o={name:e};return o.type=s(i),a(o,o.type,i),o.size=f(o,o.type,t,o.unit),o}function i(e,t,r){var i=n(r),o={value:e};return o.type=s(i),a(o,o.type,i),o.size=f(o,o.type,t,o.unit),o}function o(e){return{value:e,type:"string"}}function s(e){for(var t in e)if(h[t])return t;return"integer"}function a(e,t,n){switch(t){case"integer":e.signed=c(n);case"float":e.bigendian=u(n);default:e.unit=l(n,e.type)}return e}function u(e){return!e.little}function c(e){return e.signed}function l(e,t){for(var n in e)if("unit:"==n.substr(0,5)){var r=parseInt(n.substr(5));return r}switch(t){case"binary":return 8;case"integer":case"float":return 1}}function f(e,t,n,r){if(void 0!==n&&""!==n)return n;switch(t){case"integer":return 8;case"float":return 64;case"binary":return!0}}e.exports.variable=r,e.exports.rest=function(){return r("_",!0,["binary"])},e.exports.value=i,e.exports.string=o;var h={integer:1,binary:1,"float":1}},function(e,t){e.exports=function(){function e(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var t={parse:function(t,n){function r(e){I>E||(E>I&&(I=E,k=[]),k.push(e))}function i(){var e,t,n,r,i,a;if(i=E,a=E,e=m(),null!==e)if(t=s(),null!==t){for(n=[],r=o();null!==r;)n.push(r),r=o();null!==n?e=[e,t,n]:(e=null,E=a)}else e=null,E=a;else e=null,E=a;return null!==e&&(e=function(e,t,n){return n.unshift(t),n}(i,e[1],e[2])),null===e&&(E=i),e}function o(){var e,n,i,o,a,u;return a=E,u=E,e=m(),null!==e?(44===t.charCodeAt(E)?(n=",",E++):(n=null,0===x&&r('","')),null!==n?(i=m(),null!==i?(o=s(),null!==o?e=[e,n,i,o]:(e=null,E=u)):(e=null,E=u)):(e=null,E=u)):(e=null,E=u),null!==e&&(e=function(e,t){return t}(a,e[3])),null===e&&(E=a),e}function s(){var e,t,n,r,i;return r=E,e=a(),null!==e&&(e=function(e,t){return{string:t}}(r,e)),null===e&&(E=r),null===e&&(r=E,i=E,e=f(),null!==e?(t=p(),t=null!==t?t:"",null!==t?(n=d(),n=null!==n?n:"",null!==n?e=[e,t,n]:(e=null,E=i)):(e=null,E=i)):(e=null,E=i),null!==e&&(e=function(e,t,n,r){return{name:t,size:n,specifiers:r}}(r,e[0],e[1],e[2])),null===e&&(E=r),null===e&&(r=E,i=E,e=h(),null!==e?(t=p(),t=null!==t?t:"",null!==t?(n=d(),n=null!==n?n:"",null!==n?e=[e,t,n]:(e=null,E=i)):(e=null,E=i)):(e=null,E=i),null!==e&&(e=function(e,t,n,r){return{value:t,size:n,specifiers:r}}(r,e[0],e[1],e[2])),null===e&&(E=r))),e}function a(){var e,n,i,o,s;return o=E,s=E,34===t.charCodeAt(E)?(e='"',E++):(e=null,0===x&&r('"\\""')),null!==e?(34===t.charCodeAt(E)?(n='"',E++):(n=null,0===x&&r('"\\""')),null!==n?e=[e,n]:(e=null,E=s)):(e=null,E=s),null!==e&&(e=function(e){return""}(o)),null===e&&(E=o),null===e&&(o=E,s=E,34===t.charCodeAt(E)?(e='"',E++):(e=null,0===x&&r('"\\""')),null!==e?(n=u(),null!==n?(34===t.charCodeAt(E)?(i='"',E++):(i=null,0===x&&r('"\\""')),null!==i?e=[e,n,i]:(e=null,E=s)):(e=null,E=s)):(e=null,E=s),null!==e&&(e=function(e,t){return t}(o,e[1])),null===e&&(E=o)),e}function u(){var e,t,n;if(n=E,t=c(),null!==t)for(e=[];null!==t;)e.push(t),t=c();else e=null;return null!==e&&(e=function(e,t){return t.join("")}(n,e)),null===e&&(E=n),e}function c(){var e,n,i,o,s,a,u;return/^[^"\\\0-\x1F]/.test(t.charAt(E))?(e=t.charAt(E),E++):(e=null,0===x&&r('[^"\\\\\\0-\\x1F]')),null===e&&(a=E,'\\"'===t.substr(E,2)?(e='\\"',E+=2):(e=null,0===x&&r('"\\\\\\""')),null!==e&&(e=function(e){return'"'}(a)),null===e&&(E=a),null===e&&(a=E,"\\\\"===t.substr(E,2)?(e="\\\\",E+=2):(e=null,0===x&&r('"\\\\\\\\"')),null!==e&&(e=function(e){return"\\"}(a)),null===e&&(E=a),null===e&&(a=E,"\\/"===t.substr(E,2)?(e="\\/",E+=2):(e=null,0===x&&r('"\\\\/"')),null!==e&&(e=function(e){return"/"}(a)),null===e&&(E=a),null===e&&(a=E,"\\b"===t.substr(E,2)?(e="\\b",E+=2):(e=null,0===x&&r('"\\\\b"')),null!==e&&(e=function(e){return"\b"}(a)),null===e&&(E=a),null===e&&(a=E,"\\f"===t.substr(E,2)?(e="\\f",E+=2):(e=null,0===x&&r('"\\\\f"')),null!==e&&(e=function(e){return"\f"}(a)),null===e&&(E=a),null===e&&(a=E,"\\n"===t.substr(E,2)?(e="\\n",E+=2):(e=null,0===x&&r('"\\\\n"')),null!==e&&(e=function(e){return"\n"}(a)),null===e&&(E=a),null===e&&(a=E,"\\r"===t.substr(E,2)?(e="\\r",E+=2):(e=null,0===x&&r('"\\\\r"')),null!==e&&(e=function(e){return"\r"}(a)),null===e&&(E=a),null===e&&(a=E,"\\t"===t.substr(E,2)?(e="\\t",E+=2):(e=null,0===x&&r('"\\\\t"')),null!==e&&(e=function(e){return" "}(a)),null===e&&(E=a),null===e&&(a=E,u=E,"\\u"===t.substr(E,2)?(e="\\u",E+=2):(e=null,0===x&&r('"\\\\u"')),null!==e?(n=l(),null!==n?(i=l(),null!==i?(o=l(),null!==o?(s=l(),null!==s?e=[e,n,i,o,s]:(e=null,E=u)):(e=null,E=u)):(e=null,E=u)):(e=null,E=u)):(e=null,E=u),null!==e&&(e=function(e,t,n,r,i){return String.fromCharCode(parseInt("0x"+t+n+r+i))}(a,e[1],e[2],e[3],e[4])),null===e&&(E=a)))))))))),e}function l(){var e;return/^[0-9a-fA-F]/.test(t.charAt(E))?(e=t.charAt(E),E++):(e=null,0===x&&r("[0-9a-fA-F]")),e}function f(){var e,n,i,o,s;if(o=E,s=E,/^[_a-zA-Z]/.test(t.charAt(E))?(e=t.charAt(E),E++):(e=null,0===x&&r("[_a-zA-Z]")),null!==e){for(n=[],/^[_a-zA-Z0-9]/.test(t.charAt(E))?(i=t.charAt(E),E++):(i=null,0===x&&r("[_a-zA-Z0-9]"));null!==i;)n.push(i),/^[_a-zA-Z0-9]/.test(t.charAt(E))?(i=t.charAt(E),E++):(i=null,0===x&&r("[_a-zA-Z0-9]"));null!==n?e=[e,n]:(e=null,E=s)}else e=null,E=s;return null!==e&&(e=function(e,t,n){return t+n.join("")}(o,e[0],e[1])),null===e&&(E=o),e}function h(){var e,n,i,o,s;if(o=E,48===t.charCodeAt(E)?(e="0",E++):(e=null,0===x&&r('"0"')),null!==e&&(e=function(e){return 0}(o)),null===e&&(E=o),null===e){if(o=E,s=E,/^[1-9]/.test(t.charAt(E))?(e=t.charAt(E),E++):(e=null,0===x&&r("[1-9]")),null!==e){for(n=[],/^[0-9]/.test(t.charAt(E))?(i=t.charAt(E),E++):(i=null,0===x&&r("[0-9]"));null!==i;)n.push(i),/^[0-9]/.test(t.charAt(E))?(i=t.charAt(E),E++):(i=null,0===x&&r("[0-9]"));null!==n?e=[e,n]:(e=null,E=s)}else e=null,E=s;null!==e&&(e=function(e,t,n){return parseInt(t+n.join(""))}(o,e[0],e[1])),null===e&&(E=o)}return e}function p(){var e,n,i,o;return i=E,o=E,58===t.charCodeAt(E)?(e=":",E++):(e=null,0===x&&r('":"')),null!==e?(n=h(),null!==n?e=[e,n]:(e=null,E=o)):(e=null,E=o),null!==e&&(e=function(e,t){return t}(i,e[1])),null===e&&(E=i),null===e&&(i=E,o=E,58===t.charCodeAt(E)?(e=":",E++):(e=null,0===x&&r('":"')),null!==e?(n=f(),null!==n?e=[e,n]:(e=null,E=o)):(e=null,E=o),null!==e&&(e=function(e,t){return t}(i,e[1])),null===e&&(E=i)),e}function d(){var e,n,i,o,s,a;if(s=E,a=E,47===t.charCodeAt(E)?(e="/",E++):(e=null,0===x&&r('"/"')),null!==e)if(n=g(),null!==n){for(i=[],o=v();null!==o;)i.push(o),o=v();null!==i?e=[e,n,i]:(e=null,E=a)}else e=null,E=a;else e=null,E=a;return null!==e&&(e=function(e,t,n){return n.unshift(t),n}(s,e[1],e[2])),null===e&&(E=s),e}function v(){var e,n,i,o;return i=E,o=E,45===t.charCodeAt(E)?(e="-",E++):(e=null,0===x&&r('"-"')),null!==e?(n=g(),null!==n?e=[e,n]:(e=null,E=o)):(e=null,E=o),null!==e&&(e=function(e,t){return t}(i,e[1])),null===e&&(E=i),e}function g(){var e;return"little"===t.substr(E,6)?(e="little",E+=6):(e=null,0===x&&r('"little"')),null===e&&("big"===t.substr(E,3)?(e="big",E+=3):(e=null,0===x&&r('"big"')),null===e&&("signed"===t.substr(E,6)?(e="signed",E+=6):(e=null,0===x&&r('"signed"')),null===e&&("unsigned"===t.substr(E,8)?(e="unsigned",E+=8):(e=null,0===x&&r('"unsigned"')),null===e&&("integer"===t.substr(E,7)?(e="integer",E+=7):(e=null,0===x&&r('"integer"')),null===e&&("binary"===t.substr(E,6)?(e="binary",E+=6):(e=null,0===x&&r('"binary"')),null===e&&("float"===t.substr(E,5)?(e="float",E+=5):(e=null,0===x&&r('"float"')),null===e&&(e=y()))))))),e}function y(){var e,n,i,o;return i=E,o=E,"unit:"===t.substr(E,5)?(e="unit:",E+=5):(e=null,0===x&&r('"unit:"')),null!==e?(n=h(),null!==n?e=[e,n]:(e=null,E=o)):(e=null,E=o),null!==e&&(e=function(e,t){return"unit:"+t}(i,e[1])),null===e&&(E=i),e}function m(){var e,n;for(e=[],/^[ \t\n]/.test(t.charAt(E))?(n=t.charAt(E),E++):(n=null,0===x&&r("[ \\t\\n]"));null!==n;)e.push(n),/^[ \t\n]/.test(t.charAt(E))?(n=t.charAt(E),E++):(n=null,0===x&&r("[ \\t\\n]"));return e}function b(e){e.sort();for(var t=null,n=[],r=0;rg?!1:void(d+=n)}function c(e){l("get_integer"),l(e);var n=e.unit,i=o(e,v),s=i*n,a=d/8;return d+=s,s%8>0||d>g?!1:r(t,a,s/8,e.bigendian,e.signed)}function f(e){l("get_float"),l(e);var n=e.unit,r=o(e,v),s=r*n,a=d/8;return d+=s,d>g?!1:i(t,a,s/8,e.bigendian)}function h(e){l("get_binary"),l(e);var n=e.unit,r=o(e,v),i=d/8;if(r===!0)return d=g,t.slice(i);var s=r*n;return s%8>0||d+s>g?!1:(d+=s,t.slice(i,i+s/8))}function p(e){l("get_string"),l(e);var n=e.value.length,r=d/8;return d+=8*n,d>g?!1:t.slice(r,r+n).toString("utf8")}for(var d=0,v=s(n),g=8*t.length,y=e.length,m=0;y>m;m++){var b=e[m],w=!1;if("_"===b.name)w=u(b);else{switch(b.type){case"string":w=p(b);break;case"integer":w=c(b);break;case"float":w=f(b);break;case"binary":w=h(b)}if(w===!1)return!1;if(b.name)v[b.name]=w;else if(b.value!=w)return!1}}return d==g?a(v):!1}var c=n(69),l={NODE_ENV:"production"}.DEBUG?function(e){console.log(e)}:function(){};e.exports.match=u,e.exports.parse_int=r,e.exports.parse_float=i},function(e,t,n){(function(t){"use strict";function r(e,t,n,r){for(var i=0,o=n.length;o>i;i++){var s=n[i];switch(s.type){case"string":t+=e.write(s.value,t,"utf8");break;case"binary":t+=a(s,e,t,r);break;case"integer":t+=u(s,e,t,r);break;case"float":t+=l(s,e,t,r)}}return t}function i(e,n){var i=s(e,n),o=new t(i);return r(o,0,e,n),o}function o(e,n){if("string"==typeof e.size)return n[e.size]*e.unit/8;if("string"===e.type)return t.byteLength(e.value,"utf8");if("binary"===e.type&&e.size===!0){var r=n[e.name];return r.length}return e.size*e.unit/8}function s(e,t){for(var n=0,r=0,i=e.length;i>r;r++)n+=o(e[r],t);return n}function a(e,t,n,r){var i=r[e.name],s=o(e,r);return i.copy(t,n,0,s),s}function u(e,t,n,r){var i=e.name?r[e.name]:e.value,s=o(e,r);return c(t,i,n,s,e.bigendian)}function c(e,t,n,r,i){switch(r){case 1:e.writeUInt8(t,n);break;case 2:i?e.writeUInt16BE(t,n):e.writeUInt16LE(t,n);break;case 4:i?e.writeUInt32BE(t,n):e.writeUInt32LE(t,n);break;case 8:i?h.writeUInt64BE(e,t,n):h.writeUInt64LE(e,t,n);break;default:throw new Error("integer size * unit must be 8, 16, 32 or 64")}return r}function l(e,t,n,r){var i=e.name?r[e.name]:e.value,s=o(e,r);return f(t,i,n,s,e.bigendian)}function f(e,t,n,r,i){if(4===r)i?e.writeFloatBE(t,n):e.writeFloatLE(t,n);else{if(8!==r)throw new Error("float size * unit must be 32 or 64");i?e.writeDoubleBE(t,n):e.writeDoubleLE(t,n)}return r}var h=n(69),p=n(76).parse;e.exports.write=r,e.exports.build=i,e.exports.write_int=c,e.exports.write_float=f,e.exports.builder=function(e){e=arguments.length>1?[].join.call(arguments,","):e;var t=p(e);return function(e){return i(t,e)}}}).call(t,n(3).Buffer)},function(e,t,n){(function(t){"use strict";function r(){T=[]}function i(){T.push(w.apply(null,arguments))}function o(){return T.join("\n")}function s(e){return"string"==typeof e.size?w("%s * %d",h(e.size),e.unit):(e.size*e.unit).toString()}function a(e){i("bits = %s;\n",s(e));var t="integer"===e.type?"parse_int":"parse_float",n=e.bigendian,r=e.signed;i("byteoffset = offset / 8; offset += bits"),i("if (offset > binsize) { return false; }"),i("else { result = %s(bin, byteoffset, bits / 8, %s, %s); }",t,n,r)}function u(e){i("byteoffset = offset / 8;"),e.size===!0?(i("offset = binsize;"),i("result = bin.slice(byteoffset);")):(i("bits = %s;",s(e)),i("offset += bits;"),i("if (offset > binsize) { return false; }"),i("else { result = bin.slice(byteoffset,","byteoffset + bits / 8); }"))}function c(e){i("byteoffset = offset / 8;");var t=e.value.length,n=8*t;i("offset += %d;",n),i("if (offset > binsize) { return false; }"),i("else { result = bin.toString(byteoffset,",w("byteoffset + %d); }",t))}function l(e){if("string"==typeof e.size)i("var skipbits = %s * %d;",h(e.size),e.unit),i("if (offset + skipbits > binsize) { return false; }"),i("else { offset += skipbits; }");else if(e.size===!0)i("if (offset % 8 === 0) { offset = binsize; }"),i("else { return false; }");else{var t=e.unit*e.size;i("if (offset + %d > binsize) { return false; }",t),i("else { offset += %d; }",t)}}function f(e){if("_"===e.name)l(e);else{switch(e.type){case"integer":case"float":a(e);break;case"binary":u(e);break;case"string":c(e)}if(i("if (result === false) return false;"),e.name)i("else if (%s !== undefined) {",h(e.name)),i("if (%s != result) return false;",h(e.name)),i("}"),i("else %s = result;",h(e.name));else{var t=JSON.stringify(e.value);i("else if (result != %s) return false;",t)}}}function h(e){return"var_"+e}function p(e){for(var t={},n=0;nu;u++){var c=e[u];i("// "+JSON.stringify(c)),f(c)}i("if (offset == binsize) {"),i("return {");for(var n=0;n0)for(var a=0;an;n++){var r=e[n];i("// %s",JSON.stringify(r)),v(r)}}function b(e){return r(),i("return function(bindings) {"),i("'use strict';"),y(e),i("var buf = new Buffer(buffersize);"),i("var offset = 0;"),m(e),i("return buf;"),i("}"),new Function("write_int","write_float",o())(C,S)}n(69);var w=n(71).format,_=n(76).parse,E=n(79),x=E.parse_int,I=E.parse_float,k=n(80),C=k.write_int,S=k.write_float,T=[];e.exports.compile_pattern=d,e.exports.compile=function(){var e=[].join.call(arguments,","),t=_(e);return d(t)},e.exports.compile_builder=function(){var e=[].join.call(arguments,","),t=_(e);return b(t)}}).call(t,n(3).Buffer)},function(e,t,n){(function(t,r){"use strict";function i(e){this.newStreams=[],this.oldStreams=[],this.blocked=!1,this.scheduledRead=!1,this.out=e;var t=this;e.on("drain",function(){t.blocked=!1,t._readIncoming()})}var o=(n(71).inherits,n(70)),s="function"==typeof t?t:r.nextTick;i.prototype._readIncoming=function(){function e(e){var r;if(1===e.length){for(r=e.shift();t;){var i=r.read();if(null===i)break;t=n.write(i)}t||e.push(r)}else for(;t&&(r=e.shift());){var i=r.read();null!==i&&(t=n.write(i),e.push(r))}}if(!this.blocked){var t=!0,n=this.out;e(this.newStreams),t?(o.equal(0,this.newStreams.length),e(this.oldStreams)):(o(this.newStreams.length>0,"Expect some new streams to remain"),this.oldStreams=this.oldStreams.concat(this.newStreams),this.newStreams=[]),this.blocked=!t}},i.prototype._scheduleRead=function(){var e=this;e.scheduledRead||(s(function(){e.scheduledRead=!1,e._readIncoming()}),e.scheduledRead=!0)},i.prototype.pipeFrom=function(e){function t(){i.newStreams.push(e),i._scheduleRead()}function n(){e.removeListener("readable",t),e.removeListener("error",n),e.removeListener("end",n),e.removeListener("unpipeFrom",r)}function r(e){e===i&&n()}var i=this;e.on("unpipeFrom",r),e.on("end",n),e.on("error",n),e.on("readable",t)},i.prototype.unpipeFrom=function(e){e.emit("unpipeFrom",this)},e.exports.Mux=i}).call(t,n(37).setImmediate,n(36))},function(e,t,n){function r(){i.call(this)}e.exports=r;var i=n(84).EventEmitter,o=n(73);o(r,i),r.Readable=n(85),r.Writable=n(98),r.Duplex=n(99),r.Transform=n(100),r.PassThrough=n(101),r.Stream=r,r.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&c.pause&&c.pause()}function r(){c.readable&&c.resume&&c.resume()}function o(){l||(l=!0,e.end())}function s(){l||(l=!0,"function"==typeof e.destroy&&e.destroy())}function a(e){if(u(),0===i.listenerCount(this,"error"))throw e}function u(){c.removeListener("data",n),e.removeListener("drain",r),c.removeListener("end",o),c.removeListener("close",s),c.removeListener("error",a),e.removeListener("error",a),c.removeListener("end",u),c.removeListener("close",u),e.removeListener("close",u)}var c=this;c.on("data",n),e.on("drain",r),e._isStdio||t&&t.end===!1||(c.on("end",o),c.on("close",s));var l=!1;return c.on("error",a),e.on("error",a),c.on("end",u),c.on("close",u),e.on("close",u),e.emit("pipe",c),e}},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(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(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,a,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(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(o(n))for(a=Array.prototype.slice.call(arguments,1),c=n.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a);return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(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),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,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],r(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]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){t=e.exports=n(86),t.Stream=n(83),t.Readable=t,t.Writable=n(94),t.Duplex=n(93),t.Transform=n(96),t.PassThrough=n(97)},function(e,t,n){(function(t){function r(e,t){var r=n(93);e=e||{};var i=e.highWaterMark,o=e.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],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.objectMode=!!e.objectMode,t instanceof r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(T||(T=n(95).StringDecoder),this.decoder=new T(e.encoding),this.encoding=e.encoding)}function i(e){n(93);return this instanceof i?(this._readableState=new r(e,this),this.readable=!0,void C.call(this)):new i(e)}function o(e,t,n,r,i){var o=c(t,n);if(o)e.emit("error",o);else if(S.isNullOrUndefined(n))t.reading=!1,t.ended||l(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||r||(n=t.decoder.write(n)),i||(t.reading=!1),t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&f(e)),p(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length=B)e=B;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:isNaN(e)||S.isNull(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var n=null;return S.isBuffer(t)||S.isString(t)||S.isNullOrUndefined(t)||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function l(e,t){if(t.decoder&&!t.ended){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 n=e._readableState;n.needReadable=!1,n.emittedReadable||(U("emitReadable",n.flowing),n.emittedReadable=!0,n.sync?t.nextTick(function(){h(e)}):h(e))}function h(e){U("emit readable"),e.emit("readable"),m(e)}function p(e,n){n.readingMore||(n.readingMore=!0,t.nextTick(function(){d(e,n)}))}function d(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)n=o?r.join(""):I.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");n.endEmitted||(n.ended=!0,t.nextTick(function(){n.endEmitted||0!==n.length||(n.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function _(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function E(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=i;var x=n(87),I=n(88).Buffer;i.ReadableState=r;var k=n(84).EventEmitter;k.listenerCount||(k.listenerCount=function(e,t){return e.listeners(t).length});var C=n(83),S=n(91);S.inherits=n(73);var T,U=n(92);U=U&&U.debuglog?U.debuglog("stream"):function(){},S.inherits(i,C),i.prototype.push=function(e,t){var n=this._readableState;return S.isString(e)&&!n.objectMode&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=new I(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(e){return T||(T=n(95).StringDecoder),this._readableState.decoder=new T(e),this._readableState.encoding=e,this};var B=8388608;i.prototype.read=function(e){U("read",e);var t=this._readableState,n=e;if((!S.isNumber(e)||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return U("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?w(this):f(this),null;if(e=u(e,t),0===e&&t.ended)return 0===t.length&&w(this),null;var r=t.needReadable;U("need readable",r),(0===t.length||t.length-e0?b(e,t):null,S.isNull(i)&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&w(this),S.isNull(i)||this.emit("data",i),i},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,n){function r(e){U("onunpipe"),e===f&&o()}function i(){U("onend"),e.end()}function o(){U("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",g),e.removeListener("error",a),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),f.removeListener("data",s),!h.awaitDrain||e._writableState&&!e._writableState.needDrain||g()}function s(t){U("ondata");var n=e.write(t);!1===n&&(U("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++,f.pause())}function a(t){U("onerror",t),l(),e.removeListener("error",a),0===k.listenerCount(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),l()}function c(){U("onfinish"),e.removeListener("close",u),l()}function l(){U("unpipe"),f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,U("pipe count=%d opts=%j",h.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,d=p?i:o;h.endEmitted?t.nextTick(d):f.once("end",d),e.on("unpipe",r);var g=v(f);return e.on("drain",g),f.on("data",s),e._events&&e._events.error?x(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",f),h.flowing||(U("pipe resume"),f.resume()),e},i.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,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=E(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,n){var r=C.prototype.on.call(this,e,n);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&this.readable){var i=this._readableState;if(!i.readableListening)if(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading)i.length&&f(this,i);else{var o=this;t.nextTick(function(){U("readable nexttick read 0"),o.read(0)})}} return r},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var e=this._readableState;return e.flowing||(U("resume"),e.flowing=!0,e.reading||(U("resume read 0"),this.read(0)),g(this,e)),this},i.prototype.pause=function(){return U("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(U("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(U("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(U("wrapped data"),t.decoder&&(i=t.decoder.write(i)),i&&(t.objectMode||i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)S.isFunction(e[i])&&S.isUndefined(this[i])&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return _(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){U("wrapped _read",t),n&&(n=!1,e.resume())},r},i._fromList=b}).call(t,n(36))},function(e,t){e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},function(e,t,n){(function(e,r){/*! * The buffer module from node.js, for the browser. @@ -60,18 +60,18 @@ return r},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){v * @author Feross Aboukhadijeh * @license MIT */ -"use strict";function i(){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 o(){return e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function e(t){return this instanceof e?(e.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?s(this,t):"string"==typeof t?a(this,t,arguments.length>1?arguments[1]:"utf8"):u(this,t)):arguments.length>1?new e(t,arguments[1]):new e(t)}function s(t,n){if(t=v(t,0>n?0:0|g(n)),!e.TYPED_ARRAY_SUPPORT)for(var r=0;n>r;r++)t[r]=0;return t}function a(e,t,n){"string"==typeof n&&""!==n||(n="utf8");var r=0|m(t,n);return e=v(e,r),e.write(t,n),e}function u(t,n){if(e.isBuffer(n))return c(t,n);if($(n))return l(t,n);if(null==n)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(n.buffer instanceof ArrayBuffer)return f(t,n);if(n instanceof ArrayBuffer)return h(t,n)}return n.length?p(t,n):d(t,n)}function c(e,t){var n=0|g(t.length);return e=v(e,n),t.copy(e,0,0,n),e}function l(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function f(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(t,n){return n.byteLength,e.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(n),t.__proto__=e.prototype):t=f(t,new Uint8Array(n)),t}function p(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t){var n,r=0;"Buffer"===t.type&&$(t.data)&&(n=t.data,r=0|g(n.length)),e=v(e,r);for(var i=0;r>i;i+=1)e[i]=255&n[i];return e}function v(t,n){e.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(n),t.__proto__=e.prototype):t.length=n;var r=0!==n&&n<=e.poolSize>>>1;return r&&(t.parent=X),t}function g(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function y(t,n){if(!(this instanceof y))return new y(t,n);var r=new e(t,n);return delete r.parent,r}function m(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return K(e).length;default:if(r)return H(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return U(this,t,n);case"binary":return B(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function _(e,t,n,r){return Y(H(t,e.length-n),e,n,r)}function E(e,t,n,r){return Y(Q(t),e,n,r)}function x(e,t,n,r){return E(e,t,n,r)}function I(e,t,n,r){return Y(K(t),e,n,r)}function k(e,t,n,r){return Y(W(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?V.fromByteArray(e):V.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n>=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,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return T(r)}function T(e){var t=e.length;if(J>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=J));return n}function U(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function j(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=z(e[o]);return i}function O(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(t,n,r,i,o,s){if(!e.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(n>o||s>n)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function L(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function M(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function P(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function F(e,t,n,r,i){return i||P(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,i){return i||P(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(e,t,n,r,52,8),n+8}function D(e){if(e=q(e).replace(Z,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function z(e){return 16>e?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Q(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function K(e){return V.toByteArray(D(e))}function Y(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}var V=n(89),G=n(5),$=n(90);t.Buffer=e,t.SlowBuffer=y,t.INSPECT_MAX_BYTES=50,e.poolSize=8192;var X={};e.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),e._augment=function(t){return t.__proto__=e.prototype,t},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.prototype.length=void 0,e.prototype.parent=void 0),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 r=t.length,i=n.length,o=0,s=Math.min(r,i);s>o&&t[o]===n[o];)++o;return o!==s&&(r=t[o],i=n[o]),i>r?-1:r>i?1:0},e.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}},e.concat=function(t,n){if(!$(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new e(0);var r;if(void 0===n)for(n=0,r=0;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},e.prototype.compare=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:e.compare(this,t)},e.prototype.indexOf=function(t,n){function r(e,t,n){for(var r=-1,i=0;n+i2147483647?n=2147483647:-2147483648>n&&(n=-2147483648),n>>=0,0===this.length)return-1;if(n>=this.length)return-1;if(0>n&&(n=Math.max(this.length+n,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,n);if(e.isBuffer(t))return r(this,t,n);if("number"==typeof t)return e.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,n):r(this,[t],n);throw new TypeError("val must be string, number or Buffer")},e.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var i=r;r=t,t=0|n,n=i}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return E(this,e,t,n);case"binary":return x(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;e.prototype.slice=function(t,n){var r=this.length;t=~~t,n=void 0===n?r:~~n,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>n?(n+=r,0>n&&(n=0)):n>r&&(n=r),t>n&&(n=t);var i;if(e.TYPED_ARRAY_SUPPORT)i=this.subarray(t,n),i.__proto__=e.prototype;else{var o=n-t;i=new e(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},e.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},e.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},e.prototype.readUInt32LE=function(e,t){return t||R(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||R(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|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},e.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},e.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},e.prototype.readInt16LE=function(e,t){t||R(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||R(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||R(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||R(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||R(e,4,this.length),G.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),G.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),G.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),G.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||A(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},e.prototype.writeUInt8=function(t,n,r){return t=+t,n=0|n,r||A(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,r){return t=+t,n=0|n,r||A(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=0|n,r||A(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):M(this,t,n,!0),n+4},e.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=0|n,r||A(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):M(this,t,n,!1),n+4},e.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,s=1,a=0>e?1:0;for(this[t]=255&e;++o>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0>e?1:0;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=(e/s>>0)-a&255;return t+n},e.prototype.writeInt8=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,1,127,-128),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[n]=255&t,n+1},e.prototype.writeInt16LE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeInt16BE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeInt32LE=function(t,n,r){return t=+t,n=0|n,r||A(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):M(this,t,n,!0),n+4},e.prototype.writeInt32BE=function(t,n,r){return t=+t,n=0|n,r||A(this,t,n,4,2147483647,-2147483648),0>t&&(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):M(this,t,n,!1),n+4},e.prototype.writeFloatLE=function(e,t,n){return F(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return F(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},e.prototype.copy=function(t,n,r,i){if(r||(r=0),i||0===i||(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>n)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-nr&&i>n)for(o=s-1;o>=0;o--)t[o+n]=this[o+r];else if(1e3>s||!e.TYPED_ARRAY_SUPPORT)for(o=0;s>o;o++)t[o+n]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),n);return s},e.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=H(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}};var Z=/[^+\/0-9A-Za-z-_]/g}).call(t,n(3).Buffer,function(){return this}())},function(e,t){"use strict";function n(){var e,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=t.length;for(e=0;n>e;e++)a[e]=t[e];for(e=0;n>e;++e)u[t.charCodeAt(e)]=e;u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63}function r(e){var t,n,r,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 c(3*a/4-o),r=o>0?a-4:a;var l=0;for(t=0,n=0;r>t;t+=4,n+=3)i=u[e.charCodeAt(t)]<<18|u[e.charCodeAt(t+1)]<<12|u[e.charCodeAt(t+2)]<<6|u[e.charCodeAt(t+3)],s[l++]=(16711680&i)>>16,s[l++]=(65280&i)>>8,s[l++]=255&i;return 2===o?(i=u[e.charCodeAt(t)]<<2|u[e.charCodeAt(t+1)]>>4,s[l++]=255&i):1===o&&(i=u[e.charCodeAt(t)]<<10|u[e.charCodeAt(t+1)]<<4|u[e.charCodeAt(t+2)]>>2,s[l++]=i>>8&255,s[l++]=255&i),s}function i(e){return a[e>>18&63]+a[e>>12&63]+a[e>>6&63]+a[63&e]}function o(e,t,n){for(var r,o=[],s=t;n>s;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(i(r));return o.join("")}function s(e){for(var t,n=e.length,r=n%3,i="",s=[],u=16383,c=0,l=n-r;l>c;c+=u)s.push(o(e,c,c+u>l?l:c+u));return 1===r?(t=e[n-1],i+=a[t>>2],i+=a[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=a[t>>10],i+=a[t>>4&63],i+=a[t<<2&63],i+="="),s.push(i),s.join("")}t.toByteArray=r,t.fromByteArray=s;var a=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},6,function(e,t,n){(function(e){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===g(e)}function r(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function l(e){return"[object RegExp]"===g(e)}function f(e){return"object"==typeof e&&null!==e}function h(e){return"[object Date]"===g(e)}function p(e){return"[object Error]"===g(e)||e instanceof Error}function d(e){return"function"==typeof e}function v(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function g(e){return Object.prototype.toString.call(e)}t.isArray=n,t.isBoolean=r,t.isNull=i,t.isNullOrUndefined=o,t.isNumber=s,t.isString=a,t.isSymbol=u,t.isUndefined=c,t.isRegExp=l,t.isObject=f,t.isDate=h,t.isError=p,t.isFunction=d,t.isPrimitive=v,t.isBuffer=e.isBuffer}).call(t,n(3).Buffer)},41,[296,86,94],function(e,t,n){(function(t){function r(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function i(e,t){var r=n(93);e=e||{};var i=e.highWaterMark,o=e.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.objectMode=!!e.objectMode,t instanceof r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){p(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function o(e){var t=n(93);return this instanceof o||this instanceof t?(this._writableState=new i(e,this),this.writable=!0,void x.call(this)):new o(e)}function s(e,n,r){var i=new Error("write after end");e.emit("error",i),t.nextTick(function(){r(i)})}function a(e,n,r,i){var o=!0;if(!(E.isBuffer(r)||E.isString(r)||E.isNullOrUndefined(r)||n.objectMode)){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),t.nextTick(function(){i(s)}),o=!1}return o}function u(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&E.isString(t)&&(t=new _(t,n)),t}function c(e,t,n,i,o){n=u(t,n,i),E.isBuffer(n)&&(i="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length1){for(var n=[],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&&56319>=r)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,r=t.charCodeAt(i);if(r>=55296&&56319>=r){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},c.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(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},function(e,t,n){function r(e,t){this.afterTransform=function(e,n){return i(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,u.isNullOrUndefined(n)||e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length";if(e.id){var n=r.info(e.id);return i("<%s channel:%d%s>",n.name,e.channel,t?" "+JSON.stringify(e.fields,void 0,2):"")}return i("",e.channel,e.size)}},function(e,t){"use strict";function n(e){if(e){var t=Math.ceil(e/32);this.words=new Array(t)}else this.words=[];this.wordsInUse=0}function r(e){return Math.floor(e/32)}function i(e){if(0===e)return 32;var t,n=31;return t=e<<16,0!=t&&(n-=16,e=t),t=e<<8,0!=t&&(n-=8,e=t),t=e<<4,0!=t&&(n-=4,e=t),t=e<<2,0!=t&&(n-=2,e=t),n-(e<<1>>>31)}var o=n.prototype;o.ensureSize=function(e){var t=this.words.length;e>t&&(this.words=this.words.concat(new Array(e-t)))},o.set=function(e){var t=r(e);t>=this.wordsInUse&&(this.ensureSize(t+1),this.wordsInUse=t+1);var n=1<=this.wordsInUse)){var n=~(1<=this.wordsInUse)return!1;var n=1<=this.wordsInUse)return-1;for(var n=this.words[t]&4294967295<=this.wordsInUse)return e;for(var n=~this.words[t]&4294967295<=0.4.0 <0.5.0",_id:"amqplib@0.4.1",_inCache:!0,_installable:!0,_location:"/amqplib",_nodeVersion:"0.10.25",_npmOperationalInternal:{host:"packages-5-east.internal.npmjs.com",tmp:"tmp/amqplib-0.4.1.tgz_1454652521626_0.6085246792063117"},_npmUser:{email:"mikeb@squaremobius.net",name:"squaremo"},_npmVersion:"3.3.3",_phantomChildren:{},_requested:{name:"amqplib",raw:"amqplib@^0.4.0",rawSpec:"^0.4.0",scope:null,spec:">=0.4.0 <0.5.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/amqplib/-/amqplib-0.4.1.tgz",_shasum:"988e5c65eb992b2df8486d52ef2f6bbbc8fdbd0e",_shrinkwrap:null,_spec:"amqplib@^0.4.0",_where:"/Users/gfoiani/Dev/work/spacebunny/sdk/node",author:{email:"mikeb@squaremobius.net",name:"Michael Bridgen"},bugs:{url:"https://github.com/squaremo/amqp.node/issues"},dependencies:{bitsyntax:"~0.0.4","buffer-more-ints":"0.0.2","readable-stream":"1.x >=1.1.9",when:"~3.6.2"},description:"An AMQP 0-9-1 (e.g., RabbitMQ) library and client.",devDependencies:{claire:"0.4.1",istanbul:"0.1.x",mocha:"~1","uglify-js":"2.4.x"},directories:{},dist:{shasum:"988e5c65eb992b2df8486d52ef2f6bbbc8fdbd0e",tarball:"http://registry.npmjs.org/amqplib/-/amqplib-0.4.1.tgz"},engines:{node:">=0.8 <5 || ^5"},gitHead:"e6e52d94ef308ece88188b3a89c4a68b5d70863f",homepage:"http://squaremo.github.io/amqp.node/",keywords:["AMQP","AMQP 0-9-1","RabbitMQ"],license:"MIT",main:"./channel_api.js",maintainers:[{name:"squaremo",email:"mikeb@squaremobius.net"}],name:"amqplib",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/squaremo/amqp.node.git"}, -scripts:{prepublish:"make",test:"make test"},version:"0.4.1"}},function(e,t){},function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);l.call(this),this.connection=e;var t=this;["error","close","blocked","unblocked"].forEach(function(n){e.on(n,t.emit.bind(t,n))})}function i(e){f.call(this,e),this.on("delivery",this.handleDelivery.bind(this)),this.on("cancel",this.handleCancel.bind(this))}function o(e){i.call(this,e)}var s=n(67),a=n(110),u=a.defer,c=n(71).inherits,l=n(84).EventEmitter,f=n(129).BaseChannel,h=n(129).acceptMessage,p=n(130);c(r,l),e.exports.ChannelModel=r;var d=r.prototype;d.close=function(){var e=u();return this.connection.close(function(t){null===t?e.resolve():e.reject(t)}),e.promise},c(i,f),e.exports.Channel=i,d.createChannel=function(){var e=new i(this.connection);return e.open().then(function(t){return e})};var v=i.prototype;v.rpc=function(e,t,n){var r=u();return this._rpc(e,t,n,function(e,t){null!==e?r.reject(e):r.resolve(t.fields)}),r.promise},v.open=function(){return a["try"](this.allocate.bind(this)).then(function(e){return e.rpc(s.ChannelOpen,{outOfBand:""},s.ChannelOpenOk)})},v.close=function(){var e=u();return this.closeBecause("Goodbye",s.constants.REPLY_SUCCESS,e.resolve),e.promise},v.assertQueue=function(e,t){return this.rpc(s.QueueDeclare,p.assertQueue(e,t),s.QueueDeclareOk)},v.checkQueue=function(e){return this.rpc(s.QueueDeclare,p.checkQueue(e),s.QueueDeclareOk)},v.deleteQueue=function(e,t){return this.rpc(s.QueueDelete,p.deleteQueue(e,t),s.QueueDeleteOk)},v.purgeQueue=function(e){return this.rpc(s.QueuePurge,p.purgeQueue(e),s.QueuePurgeOk)},v.bindQueue=function(e,t,n,r){return this.rpc(s.QueueBind,p.bindQueue(e,t,n,r),s.QueueBindOk)},v.unbindQueue=function(e,t,n,r){return this.rpc(s.QueueUnbind,p.unbindQueue(e,t,n,r),s.QueueUnbindOk)},v.assertExchange=function(e,t,n){return this.rpc(s.ExchangeDeclare,p.assertExchange(e,t,n),s.ExchangeDeclareOk).then(function(t){return{exchange:e}})},v.checkExchange=function(e){return this.rpc(s.ExchangeDeclare,p.checkExchange(e),s.ExchangeDeclareOk)},v.deleteExchange=function(e,t){return this.rpc(s.ExchangeDelete,p.deleteExchange(e,t),s.ExchangeDeleteOk)},v.bindExchange=function(e,t,n,r){return this.rpc(s.ExchangeBind,p.bindExchange(e,t,n,r),s.ExchangeBindOk)},v.unbindExchange=function(e,t,n,r){return this.rpc(s.ExchangeUnbind,p.unbindExchange(e,t,n,r),s.ExchangeUnbindOk)},v.publish=function(e,t,n,r){var i=p.publish(e,t,r);return this.sendMessage(i,i,n)},v.sendToQueue=function(e,t,n){return this.publish("",e,t,n)},v.consume=function(e,t,n){var r=this,i=p.consume(e,n),o=u();return this._rpc(s.BasicConsume,i,s.BasicConsumeOk,function(e,n){null===e?(r.registerConsumer(n.fields.consumerTag,t),o.resolve(n.fields)):o.reject(e)}),o.promise},v.cancel=function(e){var t=this,n=u();return this._rpc(s.BasicCancel,p.cancel(e),s.BasicCancelOk,function(r,i){null===r?(t.unregisterConsumer(e),n.resolve(i.fields)):n.reject(r)}),n.promise},v.get=function(e,t){var n=u(),r=this,i=p.get(e,t);return this.sendOrEnqueue(s.BasicGet,i,function(e,t){if(null===e)if(t.id===s.BasicGetEmpty)n.resolve(!1);else if(t.id===s.BasicGetOk){var i=t.fields;r.handleMessage=h(function(e){e.fields=i,n.resolve(e)})}else n.reject(new Error("Unexpected response to BasicGet: "+inspect(t)));else n.reject(e)}),n.promise},v.ack=function(e,t){this.sendImmediately(s.BasicAck,p.ack(e.fields.deliveryTag,t))},v.ackAll=function(){this.sendImmediately(s.BasicAck,p.ack(0,!0))},v.nack=function(e,t,n){this.sendImmediately(s.BasicNack,p.nack(e.fields.deliveryTag,t,n))},v.nackAll=function(e){this.sendImmediately(s.BasicNack,p.nack(0,!0,e))},v.reject=function(e,t){this.sendImmediately(s.BasicReject,p.reject(e.fields.deliveryTag,t))},v.prefetch=v.qos=function(e,t){return this.rpc(s.BasicQos,p.prefetch(e,t),s.BasicQosOk)},v.recover=function(){return this.rpc(s.BasicRecover,p.recover(),s.BasicRecoverOk)},c(o,i),e.exports.ConfirmChannel=o,d.createConfirmChannel=function(){var e=new o(this.connection);return e.open().then(function(t){return e.rpc(s.ConfirmSelect,{nowait:!1},s.ConfirmSelectOk)}).then(function(){return e})};var g=o.prototype;g.publish=function(e,t,n,r,i){return this.pushConfirmCallback(i),v.publish.call(this,e,t,n,r)},g.sendToQueue=function(e,t,n,r){return this.publish("",e,t,n,r)},g.waitForConfirms=function(){var e=[],t=this.unconfirmed;return t.forEach(function(n,r){if(null===n);else{var i=u();t[r]=function(e){n&&n(e),null===e?i.resolve():i.reject(e)},e.push(i.promise)}}),a.all(e)}},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(e){function t(e,t,n,r){var i=I.resolve(e);return arguments.length<2?i:i.then(t,n,r)}function r(e){return new I(e)}function i(e){return function(){for(var t=0,n=arguments.length,r=new Array(n);n>t;++t)r[t]=arguments[t];return k(e,this,r)}}function o(e){for(var t=0,n=arguments.length-1,r=new Array(n);n>t;++t)r[t]=arguments[t+1];return k(e,this,r)}function s(){return new a}function a(){function e(e){r._handler.resolve(e)}function t(e){r._handler.reject(e)}function n(e){r._handler.notify(e)}var r=I._defer();this.promise=r,this.resolve=e,this.reject=t,this.notify=n,this.resolver={resolve:e,reject:t,notify:n}}function u(e){return e&&"function"==typeof e.then}function c(){return I.all(arguments)}function l(e){return t(e,I.all)}function f(e){return t(e,I.settle)}function h(e,n){return t(e,function(e){return I.map(e,n)})}function p(e,n){return t(e,function(e){return I.filter(e,n)})}var d=n(111),v=n(115),g=n(118),y=n(119),m=n(120),b=n(121),w=n(122),_=n(123),E=n(124),x=n(114),I=[v,g,y,b,w,m,_,d,E].reduce(function(e,t){return t(e)},n(126)),k=n(117)(I);return t.promise=r,t.resolve=I.resolve,t.reject=I.reject,t.lift=i,t["try"]=o,t.attempt=o,t.iterate=I.iterate,t.unfold=I.unfold,t.join=c,t.all=l,t.settle=f,t.any=i(I.any),t.some=i(I.some),t.race=i(I.race),t.map=h,t.filter=p,t.reduce=i(I.reduce),t.reduceRight=i(I.reduceRight),t.isPromiseLike=u,t.Promise=I,t.defer=s,t.TimeoutError=x,t}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[293,112,114],function(e,t,n){var r;(function(i){/** @license MIT License (c) copyright 2010-2014 original author or authors */ +"use strict";function i(){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 o(){return e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function e(t){return this instanceof e?(e.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?s(this,t):"string"==typeof t?a(this,t,arguments.length>1?arguments[1]:"utf8"):u(this,t)):arguments.length>1?new e(t,arguments[1]):new e(t)}function s(t,n){if(t=v(t,0>n?0:0|g(n)),!e.TYPED_ARRAY_SUPPORT)for(var r=0;n>r;r++)t[r]=0;return t}function a(e,t,n){"string"==typeof n&&""!==n||(n="utf8");var r=0|m(t,n);return e=v(e,r),e.write(t,n),e}function u(t,n){if(e.isBuffer(n))return c(t,n);if($(n))return l(t,n);if(null==n)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(n.buffer instanceof ArrayBuffer)return f(t,n);if(n instanceof ArrayBuffer)return h(t,n)}return n.length?p(t,n):d(t,n)}function c(e,t){var n=0|g(t.length);return e=v(e,n),t.copy(e,0,0,n),e}function l(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function f(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(t,n){return n.byteLength,e.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(n),t.__proto__=e.prototype):t=f(t,new Uint8Array(n)),t}function p(e,t){var n=0|g(t.length);e=v(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t){var n,r=0;"Buffer"===t.type&&$(t.data)&&(n=t.data,r=0|g(n.length)),e=v(e,r);for(var i=0;r>i;i+=1)e[i]=255&n[i];return e}function v(t,n){e.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(n),t.__proto__=e.prototype):t.length=n;var r=0!==n&&n<=e.poolSize>>>1;return r&&(t.parent=X),t}function g(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function y(t,n){if(!(this instanceof y))return new y(t,n);var r=new e(t,n);return delete r.parent,r}function m(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return K(e).length;default:if(r)return H(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return U(this,t,n);case"binary":return B(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function _(e,t,n,r){return Y(H(t,e.length-n),e,n,r)}function E(e,t,n,r){return Y(Q(t),e,n,r)}function x(e,t,n,r){return E(e,t,n,r)}function I(e,t,n,r){return Y(K(t),e,n,r)}function k(e,t,n,r){return Y(W(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?V.fromByteArray(e):V.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n>=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,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return T(r)}function T(e){var t=e.length;if(J>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=J));return n}function U(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function j(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=z(e[o]);return i}function O(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function R(t,n,r,i,o,s){if(!e.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(n>o||s>n)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function L(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function M(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function F(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function P(e,t,n,r,i){return i||F(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,i){return i||F(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(e,t,n,r,52,8),n+8}function D(e){if(e=q(e).replace(Z,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function z(e){return 16>e?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Q(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function K(e){return V.toByteArray(D(e))}function Y(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}var V=n(89),G=n(5),$=n(90);t.Buffer=e,t.SlowBuffer=y,t.INSPECT_MAX_BYTES=50,e.poolSize=8192;var X={};e.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:i(),e._augment=function(t){return t.__proto__=e.prototype,t},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.prototype.length=void 0,e.prototype.parent=void 0),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 r=t.length,i=n.length,o=0,s=Math.min(r,i);s>o;++o)if(t[o]!==n[o]){r=t[o],i=n[o];break}return i>r?-1:r>i?1:0},e.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}},e.concat=function(t,n){if(!$(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new e(0);var r;if(void 0===n)for(n=0,r=0;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},e.prototype.compare=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return e.compare(this,t)},e.prototype.indexOf=function(t,n){function r(e,t,n){for(var r=-1,i=0;n+i2147483647?n=2147483647:-2147483648>n&&(n=-2147483648),n>>=0,0===this.length)return-1;if(n>=this.length)return-1;if(0>n&&(n=Math.max(this.length+n,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,n);if(e.isBuffer(t))return r(this,t,n);if("number"==typeof t)return e.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,n):r(this,[t],n);throw new TypeError("val must be string, number or Buffer")},e.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var i=r;r=t,t=0|n,n=i}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return E(this,e,t,n);case"binary":return x(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;e.prototype.slice=function(t,n){var r=this.length;t=~~t,n=void 0===n?r:~~n,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>n?(n+=r,0>n&&(n=0)):n>r&&(n=r),t>n&&(n=t);var i;if(e.TYPED_ARRAY_SUPPORT)i=this.subarray(t,n),i.__proto__=e.prototype;else{var o=n-t;i=new e(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},e.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},e.prototype.readUInt8=function(e,t){return t||A(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return t||A(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return t||A(e,2,this.length),this[e]<<8|this[e+1]},e.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]},e.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])},e.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},e.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},e.prototype.readInt8=function(e,t){return t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},e.prototype.readInt16LE=function(e,t){t||A(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||A(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||A(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||A(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||A(e,4,this.length),G.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return t||A(e,4,this.length),G.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return t||A(e,8,this.length),G.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return t||A(e,8,this.length),G.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||R(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},e.prototype.writeUInt8=function(t,n,r){return t=+t,n=0|n,r||R(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,r){return t=+t,n=0|n,r||R(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,2,65535,0),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=0|n,r||R(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):M(this,t,n,!0),n+4},e.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=0|n,r||R(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):M(this,t,n,!1),n+4},e.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}var o=0,s=1,a=0>e?1:0;for(this[t]=255&e;++o>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);R(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0>e?1:0;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=(e/s>>0)-a&255;return t+n},e.prototype.writeInt8=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,1,127,-128),e.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[n]=255&t,n+1},e.prototype.writeInt16LE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},e.prototype.writeInt16BE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,2,32767,-32768),e.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},e.prototype.writeInt32LE=function(t,n,r){return t=+t,n=0|n,r||R(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):M(this,t,n,!0),n+4},e.prototype.writeInt32BE=function(t,n,r){return t=+t,n=0|n,r||R(this,t,n,4,2147483647,-2147483648),0>t&&(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):M(this,t,n,!1),n+4},e.prototype.writeFloatLE=function(e,t,n){return P(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return P(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},e.prototype.copy=function(t,n,r,i){if(r||(r=0),i||0===i||(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>n)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-nr&&i>n)for(o=s-1;o>=0;o--)t[o+n]=this[o+r];else if(1e3>s||!e.TYPED_ARRAY_SUPPORT)for(o=0;s>o;o++)t[o+n]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),n);return s},e.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=H(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}};var Z=/[^+\/0-9A-Za-z-_]/g}).call(t,n(3).Buffer,function(){return this}())},function(e,t){"use strict";function n(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;n>t;++t)a[t]=e[t],u[e.charCodeAt(t)]=t;u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63}function r(e){var t,n,r,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 c(3*a/4-o),r=o>0?a-4:a;var l=0;for(t=0,n=0;r>t;t+=4,n+=3)i=u[e.charCodeAt(t)]<<18|u[e.charCodeAt(t+1)]<<12|u[e.charCodeAt(t+2)]<<6|u[e.charCodeAt(t+3)],s[l++]=i>>16&255,s[l++]=i>>8&255,s[l++]=255&i;return 2===o?(i=u[e.charCodeAt(t)]<<2|u[e.charCodeAt(t+1)]>>4,s[l++]=255&i):1===o&&(i=u[e.charCodeAt(t)]<<10|u[e.charCodeAt(t+1)]<<4|u[e.charCodeAt(t+2)]>>2,s[l++]=i>>8&255,s[l++]=255&i),s}function i(e){return a[e>>18&63]+a[e>>12&63]+a[e>>6&63]+a[63&e]}function o(e,t,n){for(var r,o=[],s=t;n>s;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(i(r));return o.join("")}function s(e){for(var t,n=e.length,r=n%3,i="",s=[],u=16383,c=0,l=n-r;l>c;c+=u)s.push(o(e,c,c+u>l?l:c+u));return 1===r?(t=e[n-1],i+=a[t>>2],i+=a[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=a[t>>10],i+=a[t>>4&63],i+=a[t<<2&63],i+="="),s.push(i),s.join("")}t.toByteArray=r,t.fromByteArray=s;var a=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},6,function(e,t,n){(function(e){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===g(e)}function r(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function l(e){return"[object RegExp]"===g(e)}function f(e){return"object"==typeof e&&null!==e}function h(e){return"[object Date]"===g(e)}function p(e){return"[object Error]"===g(e)||e instanceof Error}function d(e){return"function"==typeof e}function v(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function g(e){return Object.prototype.toString.call(e)}t.isArray=n,t.isBoolean=r,t.isNull=i,t.isNullOrUndefined=o,t.isNumber=s,t.isString=a,t.isSymbol=u,t.isUndefined=c,t.isRegExp=l,t.isObject=f,t.isDate=h,t.isError=p,t.isFunction=d,t.isPrimitive=v,t.isBuffer=e.isBuffer}).call(t,n(3).Buffer)},41,[297,86,94],function(e,t,n){(function(t){function r(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function i(e,t){var r=n(93);e=e||{};var i=e.highWaterMark,o=e.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.objectMode=!!e.objectMode,t instanceof r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){p(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function o(e){var t=n(93);return this instanceof o||this instanceof t?(this._writableState=new i(e,this),this.writable=!0,void x.call(this)):new o(e)}function s(e,n,r){var i=new Error("write after end");e.emit("error",i),t.nextTick(function(){r(i)})}function a(e,n,r,i){var o=!0;if(!(E.isBuffer(r)||E.isString(r)||E.isNullOrUndefined(r)||n.objectMode)){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),t.nextTick(function(){i(s)}),o=!1}return o}function u(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&E.isString(t)&&(t=new _(t,n)),t}function c(e,t,n,i,o){n=u(t,n,i),E.isBuffer(n)&&(i="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length1){for(var n=[],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&&56319>=r)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,r=t.charCodeAt(i);if(r>=55296&&56319>=r){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},c.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(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},function(e,t,n){function r(e,t){this.afterTransform=function(e,n){return i(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,u.isNullOrUndefined(n)||e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length";if(e.id){var n=r.info(e.id);return i("<%s channel:%d%s>",n.name,e.channel,t?" "+JSON.stringify(e.fields,void 0,2):"")}return i("",e.channel,e.size)}},function(e,t){"use strict";function n(e){if(e){var t=Math.ceil(e/32);this.words=new Array(t)}else this.words=[];this.wordsInUse=0}function r(e){return Math.floor(e/32)}function i(e){if(0===e)return 32;var t,n=31;return t=e<<16,0!=t&&(n-=16,e=t),t=e<<8,0!=t&&(n-=8,e=t),t=e<<4,0!=t&&(n-=4,e=t),t=e<<2,0!=t&&(n-=2,e=t),n-(e<<1>>>31)}var o=n.prototype;o.ensureSize=function(e){var t=this.words.length;e>t&&(this.words=this.words.concat(new Array(e-t)))},o.set=function(e){var t=r(e);t>=this.wordsInUse&&(this.ensureSize(t+1),this.wordsInUse=t+1);var n=1<=this.wordsInUse)){var n=~(1<=this.wordsInUse)return!1;var n=1<=this.wordsInUse)return-1;for(var n=this.words[t]&4294967295<=this.wordsInUse)return e;for(var n=~this.words[t]&4294967295<=0.4.0 <0.5.0",_id:"amqplib@0.4.1",_inCache:!0,_installable:!0,_location:"/amqplib",_nodeVersion:"0.10.25",_npmOperationalInternal:{host:"packages-5-east.internal.npmjs.com",tmp:"tmp/amqplib-0.4.1.tgz_1454652521626_0.6085246792063117"},_npmUser:{email:"mikeb@squaremobius.net",name:"squaremo"},_npmVersion:"3.3.3",_phantomChildren:{},_requested:{name:"amqplib",raw:"amqplib@^0.4.0",rawSpec:"^0.4.0",scope:null,spec:">=0.4.0 <0.5.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/amqplib/-/amqplib-0.4.1.tgz",_shasum:"988e5c65eb992b2df8486d52ef2f6bbbc8fdbd0e",_shrinkwrap:null,_spec:"amqplib@^0.4.0",_where:"/Users/gfoiani/Dev/work/spacebunny/sdk/node",author:{email:"mikeb@squaremobius.net",name:"Michael Bridgen"},bugs:{url:"https://github.com/squaremo/amqp.node/issues"},dependencies:{bitsyntax:"~0.0.4","buffer-more-ints":"0.0.2","readable-stream":"1.x >=1.1.9",when:"~3.6.2"},description:"An AMQP 0-9-1 (e.g., RabbitMQ) library and client.",devDependencies:{claire:"0.4.1",istanbul:"0.1.x",mocha:"~1","uglify-js":"2.4.x"},directories:{},dist:{shasum:"988e5c65eb992b2df8486d52ef2f6bbbc8fdbd0e",tarball:"http://registry.npmjs.org/amqplib/-/amqplib-0.4.1.tgz"},engines:{node:">=0.8 <5 || ^5"},gitHead:"e6e52d94ef308ece88188b3a89c4a68b5d70863f",homepage:"http://squaremo.github.io/amqp.node/",keywords:["AMQP","AMQP 0-9-1","RabbitMQ"],license:"MIT",main:"./channel_api.js",maintainers:[{name:"squaremo",email:"mikeb@squaremobius.net"}],name:"amqplib",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/squaremo/amqp.node.git"},scripts:{prepublish:"make",test:"make test" +},version:"0.4.1"}},function(e,t){},function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);l.call(this),this.connection=e;var t=this;["error","close","blocked","unblocked"].forEach(function(n){e.on(n,t.emit.bind(t,n))})}function i(e){f.call(this,e),this.on("delivery",this.handleDelivery.bind(this)),this.on("cancel",this.handleCancel.bind(this))}function o(e){i.call(this,e)}var s=n(67),a=n(110),u=a.defer,c=n(71).inherits,l=n(84).EventEmitter,f=n(129).BaseChannel,h=n(129).acceptMessage,p=n(130);c(r,l),e.exports.ChannelModel=r;var d=r.prototype;d.close=function(){var e=u();return this.connection.close(function(t){null===t?e.resolve():e.reject(t)}),e.promise},c(i,f),e.exports.Channel=i,d.createChannel=function(){var e=new i(this.connection);return e.open().then(function(t){return e})};var v=i.prototype;v.rpc=function(e,t,n){var r=u();return this._rpc(e,t,n,function(e,t){null!==e?r.reject(e):r.resolve(t.fields)}),r.promise},v.open=function(){return a["try"](this.allocate.bind(this)).then(function(e){return e.rpc(s.ChannelOpen,{outOfBand:""},s.ChannelOpenOk)})},v.close=function(){var e=u();return this.closeBecause("Goodbye",s.constants.REPLY_SUCCESS,e.resolve),e.promise},v.assertQueue=function(e,t){return this.rpc(s.QueueDeclare,p.assertQueue(e,t),s.QueueDeclareOk)},v.checkQueue=function(e){return this.rpc(s.QueueDeclare,p.checkQueue(e),s.QueueDeclareOk)},v.deleteQueue=function(e,t){return this.rpc(s.QueueDelete,p.deleteQueue(e,t),s.QueueDeleteOk)},v.purgeQueue=function(e){return this.rpc(s.QueuePurge,p.purgeQueue(e),s.QueuePurgeOk)},v.bindQueue=function(e,t,n,r){return this.rpc(s.QueueBind,p.bindQueue(e,t,n,r),s.QueueBindOk)},v.unbindQueue=function(e,t,n,r){return this.rpc(s.QueueUnbind,p.unbindQueue(e,t,n,r),s.QueueUnbindOk)},v.assertExchange=function(e,t,n){return this.rpc(s.ExchangeDeclare,p.assertExchange(e,t,n),s.ExchangeDeclareOk).then(function(t){return{exchange:e}})},v.checkExchange=function(e){return this.rpc(s.ExchangeDeclare,p.checkExchange(e),s.ExchangeDeclareOk)},v.deleteExchange=function(e,t){return this.rpc(s.ExchangeDelete,p.deleteExchange(e,t),s.ExchangeDeleteOk)},v.bindExchange=function(e,t,n,r){return this.rpc(s.ExchangeBind,p.bindExchange(e,t,n,r),s.ExchangeBindOk)},v.unbindExchange=function(e,t,n,r){return this.rpc(s.ExchangeUnbind,p.unbindExchange(e,t,n,r),s.ExchangeUnbindOk)},v.publish=function(e,t,n,r){var i=p.publish(e,t,r);return this.sendMessage(i,i,n)},v.sendToQueue=function(e,t,n){return this.publish("",e,t,n)},v.consume=function(e,t,n){var r=this,i=p.consume(e,n),o=u();return this._rpc(s.BasicConsume,i,s.BasicConsumeOk,function(e,n){null===e?(r.registerConsumer(n.fields.consumerTag,t),o.resolve(n.fields)):o.reject(e)}),o.promise},v.cancel=function(e){var t=this,n=u();return this._rpc(s.BasicCancel,p.cancel(e),s.BasicCancelOk,function(r,i){null===r?(t.unregisterConsumer(e),n.resolve(i.fields)):n.reject(r)}),n.promise},v.get=function(e,t){var n=u(),r=this,i=p.get(e,t);return this.sendOrEnqueue(s.BasicGet,i,function(e,t){if(null===e)if(t.id===s.BasicGetEmpty)n.resolve(!1);else if(t.id===s.BasicGetOk){var i=t.fields;r.handleMessage=h(function(e){e.fields=i,n.resolve(e)})}else n.reject(new Error("Unexpected response to BasicGet: "+inspect(t)));else n.reject(e)}),n.promise},v.ack=function(e,t){this.sendImmediately(s.BasicAck,p.ack(e.fields.deliveryTag,t))},v.ackAll=function(){this.sendImmediately(s.BasicAck,p.ack(0,!0))},v.nack=function(e,t,n){this.sendImmediately(s.BasicNack,p.nack(e.fields.deliveryTag,t,n))},v.nackAll=function(e){this.sendImmediately(s.BasicNack,p.nack(0,!0,e))},v.reject=function(e,t){this.sendImmediately(s.BasicReject,p.reject(e.fields.deliveryTag,t))},v.prefetch=v.qos=function(e,t){return this.rpc(s.BasicQos,p.prefetch(e,t),s.BasicQosOk)},v.recover=function(){return this.rpc(s.BasicRecover,p.recover(),s.BasicRecoverOk)},c(o,i),e.exports.ConfirmChannel=o,d.createConfirmChannel=function(){var e=new o(this.connection);return e.open().then(function(t){return e.rpc(s.ConfirmSelect,{nowait:!1},s.ConfirmSelectOk)}).then(function(){return e})};var g=o.prototype;g.publish=function(e,t,n,r,i){return this.pushConfirmCallback(i),v.publish.call(this,e,t,n,r)},g.sendToQueue=function(e,t,n,r){return this.publish("",e,t,n,r)},g.waitForConfirms=function(){var e=[],t=this.unconfirmed;return t.forEach(function(n,r){if(null===n);else{var i=u();t[r]=function(e){n&&n(e),null===e?i.resolve():i.reject(e)},e.push(i.promise)}}),a.all(e)}},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ +!function(i){"use strict";r=function(e){function t(e,t,n,r){var i=I.resolve(e);return arguments.length<2?i:i.then(t,n,r)}function r(e){return new I(e)}function i(e){return function(){for(var t=0,n=arguments.length,r=new Array(n);n>t;++t)r[t]=arguments[t];return k(e,this,r)}}function o(e){for(var t=0,n=arguments.length-1,r=new Array(n);n>t;++t)r[t]=arguments[t+1];return k(e,this,r)}function s(){return new a}function a(){function e(e){r._handler.resolve(e)}function t(e){r._handler.reject(e)}function n(e){r._handler.notify(e)}var r=I._defer();this.promise=r,this.resolve=e,this.reject=t,this.notify=n,this.resolver={resolve:e,reject:t,notify:n}}function u(e){return e&&"function"==typeof e.then}function c(){return I.all(arguments)}function l(e){return t(e,I.all)}function f(e){return t(e,I.settle)}function h(e,n){return t(e,function(e){return I.map(e,n)})}function p(e,n){return t(e,function(e){return I.filter(e,n)})}var d=n(111),v=n(115),g=n(118),y=n(119),m=n(120),b=n(121),w=n(122),_=n(123),E=n(124),x=n(114),I=[v,g,y,b,w,m,_,d,E].reduce(function(e,t){return t(e)},n(126)),k=n(117)(I);return t.promise=r,t.resolve=I.resolve,t.reject=I.reject,t.lift=i,t["try"]=o,t.attempt=o,t.iterate=I.iterate,t.unfold=I.unfold,t.join=c,t.all=l,t.settle=f,t.any=i(I.any),t.some=i(I.some),t.race=i(I.race),t.map=h,t.filter=p,t.reduce=i(I.reduce),t.reduceRight=i(I.reduceRight),t.isPromiseLike=u,t.Promise=I,t.defer=s,t.TimeoutError=x,t}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[294,112,114],function(e,t,n){var r;(function(i){/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(o){"use strict";r=function(e){function t(){return"undefined"!=typeof i&&null!==i&&"function"==typeof i.nextTick}function r(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function o(e){function t(){var e=n;n=void 0,e()}var n,r=document.createTextNode(""),i=new e(t);i.observe(r,{characterData:!0});var o=0;return function(e){n=e,r.data=o^=1}}var s,a="undefined"!=typeof setTimeout&&setTimeout,u=function(e,t){return setTimeout(e,t)},c=function(e){return clearTimeout(e)},l=function(e){return a(e,0)};if(t())l=function(e){return i.nextTick(e)};else if(s=r())l=o(s);else if(!a){var f=n(113);u=function(e,t){return f.setTimer(t,e)},c=f.cancelTimer,l=f.runOnLoop||f.runOnContext}return{setTimer:u,clearTimer:c,asap:l}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))}).call(t,n(36))},41,43,function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(e){var t=n(116),r=n(117);return function(e){function n(t){function n(e){l=null,this.resolve(e)}function r(e){this.resolved||(l.push(e),0===--c&&this.reject(l))}for(var i,o,s=e._defer(),a=s._handler,u=t.length>>>0,c=u,l=[],f=0;u>f;++f)if(o=t[f],void 0!==o||f in t){if(i=e._handler(o),i.state()>0){a.become(i),e._visitRemaining(t,f,i);break}i.visit(a,n,r)}else--c;return 0===c&&a.reject(new RangeError("any(): array must not be empty")),s}function i(t,n){function r(e){this.resolved||(l.push(e),0===--p&&(f=null,this.resolve(l)))}function i(e){this.resolved||(f.push(e),0===--o&&(l=null,this.reject(f)))}var o,s,a,u=e._defer(),c=u._handler,l=[],f=[],h=t.length>>>0,p=0;for(a=0;h>a;++a)s=t[a],(void 0!==s||a in t)&&++p;for(n=Math.max(n,0),o=p-n+1,p=Math.min(n,p),n>p?c.reject(new RangeError("some(): array must contain at least "+n+" item(s), but had "+p)):0===p&&c.resolve(l),a=0;h>a;++a)s=t[a],(void 0!==s||a in t)&&e._handler(s).visit(c,r,i,c.notify);return u}function o(t,n){return e._traverse(n,t)}function s(t,n){var r=m.call(t);return e._traverse(n,r).then(function(e){return a(r,e)})}function a(t,n){for(var r=n.length,i=new Array(r),o=0,s=0;r>o;++o)n[o]&&(i[s++]=e._handler(t[o]).value);return i.length=s,i}function u(e){return v(e.map(c))}function c(n){var r=e._handler(n);return 0===r.state()?d(n).then(t.fulfilled,t.rejected):t.inspect(r)}function l(e,t){return arguments.length>2?g.call(e,h(t),arguments[2]):g.call(e,h(t))}function f(e,t){return arguments.length>2?y.call(e,h(t),arguments[2]):y.call(e,h(t))}function h(e){return function(t,n,r){return p(e,void 0,[t,n,r])}}var p=r(e),d=e.resolve,v=e.all,g=Array.prototype.reduce,y=Array.prototype.reduceRight,m=Array.prototype.slice;return e.any=n,e.some=i,e.settle=u,e.map=o,e.filter=s,e.reduce=l,e.reduceRight=f,e.prototype.spread=function(e){return this.then(v).then(function(t){return e.apply(this,t)})},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},45,46,47,48,[294,116],50,51,52,function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ +!function(i){"use strict";r=function(e){var t=n(116),r=n(117);return function(e){function n(t){function n(e){l=null,this.resolve(e)}function r(e){this.resolved||(l.push(e),0===--c&&this.reject(l))}for(var i,o,s=e._defer(),a=s._handler,u=t.length>>>0,c=u,l=[],f=0;u>f;++f)if(o=t[f],void 0!==o||f in t){if(i=e._handler(o),i.state()>0){a.become(i),e._visitRemaining(t,f,i);break}i.visit(a,n,r)}else--c;return 0===c&&a.reject(new RangeError("any(): array must not be empty")),s}function i(t,n){function r(e){this.resolved||(l.push(e),0===--p&&(f=null,this.resolve(l)))}function i(e){this.resolved||(f.push(e),0===--o&&(l=null,this.reject(f)))}var o,s,a,u=e._defer(),c=u._handler,l=[],f=[],h=t.length>>>0,p=0;for(a=0;h>a;++a)s=t[a],(void 0!==s||a in t)&&++p;for(n=Math.max(n,0),o=p-n+1,p=Math.min(n,p),n>p?c.reject(new RangeError("some(): array must contain at least "+n+" item(s), but had "+p)):0===p&&c.resolve(l),a=0;h>a;++a)s=t[a],(void 0!==s||a in t)&&e._handler(s).visit(c,r,i,c.notify);return u}function o(t,n){return e._traverse(n,t)}function s(t,n){var r=m.call(t);return e._traverse(n,r).then(function(e){return a(r,e)})}function a(t,n){for(var r=n.length,i=new Array(r),o=0,s=0;r>o;++o)n[o]&&(i[s++]=e._handler(t[o]).value);return i.length=s,i}function u(e){return v(e.map(c))}function c(n){var r=e._handler(n);return 0===r.state()?d(n).then(t.fulfilled,t.rejected):t.inspect(r)}function l(e,t){return arguments.length>2?g.call(e,h(t),arguments[2]):g.call(e,h(t))}function f(e,t){return arguments.length>2?y.call(e,h(t),arguments[2]):y.call(e,h(t))}function h(e){return function(t,n,r){return p(e,void 0,[t,n,r])}}var p=r(e),d=e.resolve,v=e.all,g=Array.prototype.reduce,y=Array.prototype.reduceRight,m=Array.prototype.slice;return e.any=n,e.some=i,e.settle=u,e.map=o,e.filter=s,e.reduce=l,e.reduceRight=f,e.prototype.spread=function(e){return this.then(v).then(function(t){return e.apply(this,t)})},e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},45,46,47,48,[295,116],50,51,52,function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ !function(i){"use strict";r=function(e){function t(e){throw e}function r(){}var i=n(112).setTimer,o=n(125);return function(e){function n(e){e.handled||(p.push(e),l("Potentially unhandled rejection ["+e.id+"] "+o.formatError(e.value)))}function s(e){var t=p.indexOf(e);t>=0&&(p.splice(t,1),f("Handled previous rejection ["+e.id+"] "+o.formatObject(e.value)))}function a(e,t){h.push(e,t),null===d&&(d=i(u,0))}function u(){for(d=null;h.length>0;)h.shift()(h.shift())}var c,l=r,f=r;"undefined"!=typeof console&&(c=console,l="undefined"!=typeof c.error?function(e){c.error(e)}:function(e){c.log(e)},f="undefined"!=typeof c.info?function(e){c.info(e)}:function(e){c.log(e)}),e.onPotentiallyUnhandledRejection=function(e){a(n,e)},e.onPotentiallyUnhandledRejectionHandled=function(e){a(s,e)},e.onFatalRejection=function(e){a(t,e.value)};var h=[],p=[],d=null;return e}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(){function e(e){var n="object"==typeof e&&null!==e&&e.stack?e.stack:t(e);return e instanceof Error?n:n+" (WARNING: non-Error used)"}function t(e){var t=String(e);return"[object Object]"===t&&"undefined"!=typeof JSON&&(t=n(e,t)),t}function n(e,t){try{return JSON.stringify(e)}catch(n){return t}}return{formatError:e,formatObject:t,tryStringify:n}}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}(n(42))},[295,127,128,112],function(e,t,n){var r;/** @license MIT License (c) copyright 2010-2014 original author or authors */ -!function(i){"use strict";r=function(){return function(e){function t(e,t){this._handler=e===b?t:n(e)}function n(e){function t(e){i.resolve(e)}function n(e){i.reject(e)}function r(e){i.notify(e)}var i=new _;try{e(t,n,r)}catch(o){n(o)}return i}function r(e){return A(e)?e:new t(b,new E(g(e)))}function i(e){return new t(b,new E(new k(e)))}function o(){return X}function s(){return new t(b,new _)}function a(e,t){var n=new _(e.receiver,e.join().context);return new t(b,n)}function u(e){return l(Q,null,e)}function c(e,t){return l(N,e,t)}function l(e,n,r){function i(t,i,s){s.resolved||f(r,o,t,e(n,i,t),s)}function o(e,t,n){l[e]=t,0===--c&&n.become(new I(l))}for(var s,a="function"==typeof n?i:o,u=new _,c=r.length>>>0,l=new Array(c),h=0;h0?t(n,o.value,i):(i.become(o),h(e,n+1,o))}else t(n,r,i)}function h(e,t,n){for(var r=t;rn&&e._unreport()}}function d(e){return"object"!=typeof e||null===e?i(new TypeError("non-iterable passed to race()")):0===e.length?o():1===e.length?r(e[0]):v(e)}function v(e){var n,r,i,o=new _;for(n=0;n0||"function"!=typeof t&&0>i)return new this.constructor(b,r);var o=this._beget(),s=o._handler;return r.chain(s,r.receiver,e,t,n),o},t.prototype["catch"]=function(e){return this.then(void 0,e)},t.prototype._beget=function(){return a(this._handler,this.constructor)},t.all=u,t.race=d,t._traverse=c,t._visitRemaining=h,b.prototype.when=b.prototype.become=b.prototype.notify=b.prototype.fail=b.prototype._unreport=b.prototype._report=W,b.prototype._state=0,b.prototype.state=function(){return this._state},b.prototype.join=function(){for(var e=this;void 0!==e.handler;)e=e.handler;return e},b.prototype.chain=function(e,t,n,r,i){this.when({resolver:e,receiver:t,fulfilled:n,rejected:r,progress:i})},b.prototype.visit=function(e,t,n,r){this.chain(V,e,t,n,r)},b.prototype.fold=function(e,t,n,r){this.when(new R(e,t,n,r))},H(b,w),w.prototype.become=function(e){e.fail()};var V=new w;H(b,_),_.prototype._state=0,_.prototype.resolve=function(e){this.become(g(e))},_.prototype.reject=function(e){this.resolved||this.become(new k(e))},_.prototype.join=function(){if(!this.resolved)return this;for(var e=this;void 0!==e.handler;)if(e=e.handler,e===this)return this.handler=T();return e},_.prototype.run=function(){var e=this.consumers,t=this.join();this.consumers=void 0;for(var n=0;no)throw g("Too much content sent! Expected %d bytes",i);return null!==a?a.push(n.content):a=[n.content],r}throw"Expected content frame after headers"}var i=0,o=0,a=null,u={fields:null,properties:null,content:null};return n}function u(e){r.call(this,e),this.consumers={}}var c=n(67),l=n(103).closeMessage,f=n(103).inspect,h=n(103).methodName,p=n(70),d=n(71).inherits,v=n(84).EventEmitter,g=n(71).format,y=n(105).IllegalOperationError,m=n(105).stackCapture;d(r,v),e.exports.Channel=r,e.exports.acceptMessage=a;var b=r.prototype;b.allocate=function(){return this.ch=this.connection.freshChannel(this),this},b.sendImmediately=function(e,t){return this.connection.sendMethod(this.ch,e,t)},b.sendOrEnqueue=function(e,t,n){this.reply?this.pending.push({method:e,fields:t,reply:n}):(p(0===this.pending.length),this.reply=n,this.sendImmediately(e,t))},b.sendMessage=function(e,t,n){return this.connection.sendMessage(this.ch,c.BasicPublish,e,c.BasicProperties,t,n)},b._rpc=function(e,t,n,r){function i(t,i){if(null===t){if(i.id===n)return r(null,i);var s=h(n),a=new Error(g("Expected %s; got %s",s,f(i,!1)));return o.closeWithError(g("Expected %s; got %s",s,h(i.id)),c.constants.UNEXPECTED_FRAME,a),r(a)}if(t instanceof Error)return r(t);var u=(t.fields.classId<<16)+t.fields.methodId,a=e===u?g("Operation failed: %s; %s",h(e),l(t)):g("Channel closed by server: %s",l(t));return r(new Error(a))}var o=this;this.sendOrEnqueue(e,t,i)},b.toClosed=function(e){this._rejectPending(),o(this,"Channel closed",e),this.accept=i("Channel closed",e),this.connection.releaseChannel(this.ch),this.emit("close")},b.toClosing=function(e,t){var n=this.sendImmediately.bind(this);o(this,"Channel closing",e),this.accept=function(e){if(e.id===c.ChannelCloseOk){t&&t();var r=m("ChannelCloseOk frame received");this.toClosed(r)}else e.id===c.ChannelClose&&n(c.ChannelCloseOk,{})}},b._rejectPending=function(){function e(e){e(new Error("Channel ended, no reply will be forthcoming"))}null!==this.reply&&e(this.reply),this.reply=null;for(var t;t=this.pending.shift();)e(t.reply);this.pending=null},b.closeBecause=function(e,t,n){this.sendImmediately(c.ChannelClose,{replyText:e,replyCode:t,methodId:0,classId:0});var r=m("closeBecause called: "+e);this.toClosing(r,n)},b.closeWithError=function(e,t,n){var r=this;this.closeBecause(e,t,function(){n.code=t,r.emit("error",n)})},b.acceptMessageFrame=function(e){try{this.handleMessage=this.handleMessage(e)}catch(t){"string"==typeof t?this.closeWithError(t,c.constants.UNEXPECTED_FRAME,new Error(t)):t instanceof Error?this.closeWithError("Error while processing message",c.constants.INTERNAL_ERROR,t):this.closeWithError("Internal error while processing message",c.constants.INTERNAL_ERROR,new Error(t.toString()))}},b.handleConfirm=function(e,t){var n=t.deliveryTag,r=t.multiple;if(r){var i=this.unconfirmed.splice(0,n-this.lwm+1);this.lwm=n+1,i.forEach(e)}else{var o;if(n===this.lwm)for(o=this.unconfirmed.shift(),this.lwm++;null===this.unconfirmed[0];)this.unconfirmed.shift(),this.lwm++;else o=this.unconfirmed[n-this.lwm],this.unconfirmed[n-this.lwm]=null;e(o)}},b.pushConfirmCallback=function(e){this.unconfirmed.push(e||!1)},b.accept=function(e){switch(e.id){case void 0:case c.BasicDeliver:case c.BasicReturn:case c.BasicProperties:return this.acceptMessageFrame(e);case c.BasicAck:return this.emit("ack",e.fields);case c.BasicNack:return this.emit("nack",e.fields);case c.BasicCancel:return this.emit("cancel",e.fields);case c.ChannelClose:if(this.reply){var t=this.reply;this.reply=null,t(e)}var n="Channel closed by server: "+l(e);this.sendImmediately(c.ChannelCloseOk,{});var r=new Error(n);r.code=e.fields.replyCode,this.emit("error",r);var i=m(n);return void this.toClosed(i);case c.BasicFlow:return this.closeWithError("Flow not implemented",c.constants.NOT_IMPLEMENTED,new Error("Flow not implemented"));default:var t=this.reply;if(this.reply=null,this.pending.length>0){var o=this.pending.shift();this.reply=o.reply,this.sendImmediately(o.method,o.fields)}return t(null,e)}},b.onBufferDrain=function(){this.emit("drain")},d(u,r),e.exports.BaseChannel=u,u.prototype.registerConsumer=function(e,t){this.consumers[e]=t},u.prototype.unregisterConsumer=function(e){delete this.consumers[e]},u.prototype.dispatchMessage=function(e,t){var n=e.consumerTag,r=this.consumers[n];if(r)return r(t);throw new Error("Unknown consumer: "+n)},u.prototype.handleDelivery=function(e){return this.dispatchMessage(e.fields,e)},u.prototype.handleCancel=function(e){return this.dispatchMessage(e,null)}}).call(t,n(3).Buffer)},function(e,t){"use strict";function n(e,t,n){void 0!=n&&(e[t]=n)}var r=Object.freeze({}),i={};i.assertQueue=function(e,t){e=e||"",t=t||r;var i=Object.create(t.arguments||null);return n(i,"x-expires",t.expires),n(i,"x-message-ttl",t.messageTtl),n(i,"x-dead-letter-exchange",t.deadLetterExchange),n(i,"x-dead-letter-routing-key",t.deadLetterRoutingKey),n(i,"x-max-length",t.maxLength),n(i,"x-max-priority",t.maxPriority),{queue:e,exclusive:!!t.exclusive,durable:void 0===t.durable?!0:t.durable,autoDelete:!!t.autoDelete,arguments:i,passive:!1,ticket:0,nowait:!1}},i.checkQueue=function(e){return{queue:e,passive:!0,nowait:!1,durable:!0,autoDelete:!1,exclusive:!1,ticket:0}},i.deleteQueue=function(e,t){return t=t||r,{queue:e,ifUnused:!!t.ifUnused,ifEmpty:!!t.ifEmpty,ticket:0,nowait:!1}},i.purgeQueue=function(e){return{queue:e,ticket:0,nowait:!1}},i.bindQueue=function(e,t,n,r){return{queue:e,exchange:t,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.unbindQueue=function(e,t,n,r){return{queue:e,exchange:t,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.assertExchange=function(e,t,i){i=i||r;var o=Object.create(i.arguments||null);return n(o,"alternate-exchange",i.alternateExchange),{exchange:e,ticket:0,type:t,passive:!1,durable:void 0===i.durable?!0:i.durable,autoDelete:!!i.autoDelete,internal:!!i.internal,nowait:!1,arguments:o}},i.checkExchange=function(e){return{exchange:e,passive:!0,nowait:!1,durable:!0,internal:!1,type:"",autoDelete:!1,ticket:0}},i.deleteExchange=function(e,t){return t=t||r,{exchange:e,ifUnused:!!t.ifUnused,ticket:0,nowait:!1}},i.bindExchange=function(e,t,n,r){return{source:t,destination:e,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.unbindExchange=function(e,t,n,r){return{source:t,destination:e,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.publish=function(e,t,i){function o(e){return void 0===e?void 0:Array.isArray(e)?e.map(String):[String(e)]}i=i||r;var s=Object.create(i.headers||null);n(s,"CC",o(i.CC)),n(s,"BCC",o(i.BCC));var a;void 0!==i.persistent?a=i.persistent?2:1:"number"==typeof i.deliveryMode?a=i.deliveryMode:i.deliveryMode&&(a=2);var u=i.expiration;return void 0!==u&&(u=u.toString()),{exchange:e,routingKey:t,mandatory:!!i.mandatory,immediate:!1,ticket:void 0,contentType:i.contentType,contentEncoding:i.contentEncoding,headers:s,deliveryMode:a,priority:i.priority,correlationId:i.correlationId,replyTo:i.replyTo,expiration:u,messageId:i.messageId,timestamp:i.timestamp,type:i.type,userId:i.userId,appId:i.appId,clusterId:void 0}},i.consume=function(e,t){t=t||r;var i=Object.create(t.arguments||null);return n(i,"x-priority",t.priority),{ticket:0,queue:e,consumerTag:t.consumerTag||"",noLocal:!!t.noLocal,noAck:!!t.noAck,exclusive:!!t.exclusive,nowait:!1,arguments:i}},i.cancel=function(e){return{consumerTag:e,nowait:!1}},i.get=function(e,t){return t=t||r,{ticket:0,queue:e,noAck:!!t.noAck}},i.ack=function(e,t){return{deliveryTag:e,multiple:!!t}},i.nack=function(e,t,n){return{deliveryTag:e,multiple:!!t,requeue:void 0===n?!0:n}},i.reject=function(e,t){return{deliveryTag:e,requeue:void 0===t?!0:t}},i.prefetch=function(e,t){return{prefetchCount:e||0,prefetchSize:0,global:!!t}},i.recover=function(){return{requeue:!0}},e.exports=Object.freeze(i)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=n(132),s=r(o),a=n(209),u=r(a),c=function(){function e(e,t){for(var n=0;nn)return!1;var r=e.length-1;return n==r?e.pop():s.call(e,n,1),!0}var i=n(147),o=Array.prototype,s=o.splice;e.exports=r},function(e,t,n){function r(e,t){for(var n=e.length;n--;)if(i(e[n][0],t))return n;return-1}var i=n(148);e.exports=r},function(e,t){function n(e,t){return e===t||e!==e&&t!==t}e.exports=n},function(e,t,n){function r(e){var t=this.__data__,n=t.array;return n?i(n,e):t.map.get(e)}var i=n(150);e.exports=r},function(e,t,n){function r(e,t){var n=i(e,t);return 0>n?void 0:e[n][1]}var i=n(147);e.exports=r},function(e,t,n){function r(e){var t=this.__data__,n=t.array;return n?i(n,e):t.map.has(e)}var i=n(152);e.exports=r},function(e,t,n){function r(e,t){return i(e,t)>-1}var i=n(147);e.exports=r},function(e,t,n){function r(e,t){var n=this.__data__,r=n.array;r&&(r.lengthr?e.push([t,n]):e[r][1]=n}var i=n(147);e.exports=r},function(e,t,n){function r(e,t,n){e[t]=i&&void 0===n?o:n}var i=n(157),o="__lodash_hash_undefined__";e.exports=r},function(e,t,n){function r(e,t,n,a,u){return e===t?!0:null==e||null==t||!o(e)&&!s(t)?e!==e&&t!==t:i(e,t,r,n,a,u)}var i=n(175),o=n(14),s=n(18);e.exports=r},function(e,t,n){function r(e,t,n,r,g,m){var b=c(e),w=c(t),_=d,E=d;b||(_=u(e),_=_==p?v:_),w||(E=u(t),E=E==p?v:E);var x=_==v&&!l(e),I=E==v&&!l(t),k=_==E;if(k&&!x)return m||(m=new i),b||f(e)?o(e,t,n,r,g,m):s(e,t,_,n,r,g,m);if(!(g&h)){var C=x&&y.call(e,"__wrapped__"),S=I&&y.call(t,"__wrapped__");if(C||S)return m||(m=new i),n(C?e.value():e,S?t.value():t,r,g,m)}return k?(m||(m=new i),a(e,t,n,r,g,m)):!1}var i=n(143),o=n(176),s=n(178),a=n(183),u=n(184),c=n(17),l=n(160),f=n(187),h=2,p="[object Arguments]",d="[object Array]",v="[object Object]",g=Object.prototype,y=g.hasOwnProperty;e.exports=r},function(e,t,n){function r(e,t,n,r,a,u){var c=-1,l=a&s,f=a&o,h=e.length,p=t.length;if(h!=p&&!(l&&p>h))return!1;var d=u.get(e);if(d)return d==t;var v=!0;for(u.set(e,t);++cn;)e=e[t[n++]];return n&&n==r?e:void 0}var i=n(195),o=n(199);e.exports=r},function(e,t,n){function r(e){return i(e)?e:o(e)}var i=n(17),o=n(196);e.exports=r},function(e,t,n){function r(e){var t=[];return i(e).replace(o,function(e,n,r,i){t.push(r?i.replace(s,"$1"):n||e)}),t}var i=n(197),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,s=/\\(\\)?/g;e.exports=r},function(e,t,n){function r(e){if("string"==typeof e)return e;if(null==e)return"";if(o(e))return u?u.call(e):"";var t=e+"";return"0"==t&&1/e==-s?"-0":t}var i=n(179),o=n(198),s=1/0,a=i?i.prototype:void 0,u=a?a.toString:void 0;e.exports=r},function(e,t,n){function r(e){return"symbol"==typeof e||i(e)&&a.call(e)==o}var i=n(18),o="[object Symbol]",s=Object.prototype,a=s.toString;e.exports=r},function(e,t,n){function r(e,t){return"number"==typeof e?!0:!i(e)&&(s.test(e)||!o.test(e)||null!=t&&e in Object(t))}var i=n(17),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=r},function(e,t,n){function r(e,t){return o(e,t,i)}var i=n(201),o=n(202);e.exports=r},function(e,t){function n(e,t){return t in Object(e)}e.exports=n},function(e,t,n){function r(e,t,n){if(null==e)return!1;var r=n(e,t);r||u(t)||(t=i(t),e=h(e,t),null!=e&&(t=f(t),r=n(e,t)));var p=e?e.length:void 0;return r||!!p&&c(p)&&a(t,p)&&(s(e)||l(e)||o(e))}var i=n(195),o=n(29),s=n(17),a=n(31),u=n(199),c=n(15),l=n(16),f=n(203),h=n(204);e.exports=r},function(e,t){function n(e){var t=e?e.length:0;return t?e[t-1]:void 0}e.exports=n},function(e,t,n){function r(e,t){return 1==t.length?e:o(e,i(t,0,-1))}var i=n(205),o=n(193);e.exports=r},function(e,t){function n(e,t,n){var r=-1,i=e.length;0>t&&(t=-t>i?0:i+t),n=n>i?i:n,0>n&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r=e?e:n),void 0!==t&&(e=e>=t?e:t)),e}e.exports=n},function(e,t,n){e.exports=n(212)},function(e,t,n){"use strict";function r(e){this.defaults=o.merge({},e),this.interceptors={request:new a,response:new a}}var i=n(213),o=n(214),s=n(215),a=n(223),u=n(224),c=n(225),l=n(226),f=n(219);r.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),e=o.merge(i,this.defaults,{method:"get"},e),e.baseURL&&!u(e.url)&&(e.url=c(e.baseURL,e.url)),e.withCredentials=e.withCredentials||this.defaults.withCredentials,e.data=f(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=[s,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n};var h=new r(i),p=e.exports=l(r.prototype.request,h);p.create=function(e){return new r(e)},p.defaults=h.defaults,p.all=function(e){return Promise.all(e)},p.spread=n(227),p.interceptors=h.interceptors,o.forEach(["delete","get","head"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))},p[e]=l(r.prototype[e],h)}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))},p[e]=l(r.prototype[e],h)})},function(e,t,n){"use strict";var r=n(214),i=/^\)\]\}',?\n/,o={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return r.isFormData(e)?e:r.isArrayBuffer(e)?e:r.isArrayBufferView(e)?e.buffer:!r.isObject(e)||r.isFile(e)||r.isBlob(e)?e:(r.isUndefined(t)||(r.forEach(t,function(e,n){"content-type"===n.toLowerCase()&&(t["Content-Type"]=e)}),r.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(i,"");try{e=JSON.parse(e)}catch(t){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(o),post:r.merge(o),put:r.merge(o)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(e,t){"use strict";function n(e){return"[object Array]"===y.call(e)}function r(e){return"[object ArrayBuffer]"===y.call(e)}function i(e){return"[object FormData]"===y.call(e)}function o(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function s(e){return"string"==typeof e}function a(e){return"number"==typeof e}function u(e){return"undefined"==typeof e}function c(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===y.call(e)}function f(e){return"[object File]"===y.call(e)}function h(e){return"[object Blob]"===y.call(e)}function p(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function d(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||n(e)||(e=[e]),n(e))for(var r=0,i=e.length;i>r;r++)t.call(null,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(null,e[o],o,e)}function g(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=g(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;r>n;n++)v(arguments[n],e);return t}var y=Object.prototype.toString;e.exports={isArray:n,isArrayBuffer:r,isFormData:i,isArrayBufferView:o,isString:s,isNumber:a,isObject:c,isUndefined:u,isDate:l,isFile:f,isBlob:h,isStandardBrowserEnv:d,forEach:v,merge:g,trim:p}},function(e,t,n){(function(t){"use strict";e.exports=function(e){return new Promise(function(r,i){try{var o;"function"==typeof e.adapter?o=e.adapter:"undefined"!=typeof XMLHttpRequest?o=n(216):"undefined"!=typeof t&&(o=n(216)),"function"==typeof o&&o(r,i,e)}catch(s){i(s)}})}}).call(t,n(36))},function(e,t,n){"use strict";var r=n(214),i=n(217),o=n(218),s=n(219),a=n(220),u=window.btoa||n(221);e.exports=function(e,t,c){var l=c.data,f=c.headers;r.isFormData(l)&&delete f["Content-Type"];var h=new XMLHttpRequest;if(!window.XDomainRequest||"withCredentials"in h||a(c.url)||(h=new window.XDomainRequest),c.auth){var p=c.auth.username||"",d=c.auth.password||"";f.Authorization="Basic "+u(p+":"+d); -}if(h.open(c.method.toUpperCase(),i(c.url,c.params,c.paramsSerializer),!0),h.timeout=c.timeout,h.onload=function(){if(h){var n="getAllResponseHeaders"in h?o(h.getAllResponseHeaders()):null,r=-1!==["text",""].indexOf(c.responseType||"")?h.responseText:h.response,i={data:s(r,n,c.transformResponse),status:1223===h.status?204:h.status,statusText:1223===h.status?"No Content":h.statusText,headers:n,config:c};(i.status>=200&&i.status<300||!("status"in h)&&i.responseText?e:t)(i),h=null}},h.onerror=function(){t(new Error("Network Error")),h=null},r.isStandardBrowserEnv()){var v=n(222),g=c.withCredentials||a(c.url)?v.read(c.xsrfCookieName):void 0;g&&(f[c.xsrfHeaderName]=g)}if("setRequestHeader"in h&&r.forEach(f,function(e,t){"undefined"==typeof l&&"content-type"===t.toLowerCase()?delete f[t]:h.setRequestHeader(t,e)}),c.withCredentials&&(h.withCredentials=!0),c.responseType)try{h.responseType=c.responseType}catch(y){if("json"!==h.responseType)throw y}r.isArrayBuffer(l)&&(l=new DataView(l)),h.send(l)}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var i=n(214);e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else{var s=[];i.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(i.isArray(e)&&(t+="[]"),i.isArray(e)||(e=[e]),i.forEach(e,function(e){i.isDate(e)?e=e.toISOString():i.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),o=s.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){"use strict";var r=n(214);e.exports=function(e){var t,n,i,o={};return e?(r.forEach(e.split("\n"),function(e){i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t&&(o[t]=o[t]?o[t]+", "+n:n)}),o):o}},function(e,t,n){"use strict";var r=n(214);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";var r=n(214);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(i.setAttribute("href",t),t=i.href),i.setAttribute("href",t),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return t=e(window.location.href),function(n){var i=r.isString(n)?e(n):n;return i.protocol===t.protocol&&i.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(e){this.message=e}function r(e){for(var t,r,o=String(e),s="",a=0,u=i;o.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&t>>8-a%1*8)){if(r=o.charCodeAt(a+=.75),r>255)throw new n("INVALID_CHARACTER_ERR: DOM Exception 5");t=t<<8|r}return s}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(214);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,i,o,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var i=n(214);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){i.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;ri;i++)r.push(s(e,t[i],n));else{r={};for(var a in t)t.hasOwnProperty(a)&&(r[e(a,n)]=s(e,t[a],n))}return r},a=function(e,t){t=t||{};var n=t.separator||"_",r=t.split||/(?=[A-Z])/;return e.split(r).join(n)},u=function(e){return y(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""}),e.substr(0,1).toLowerCase()+e.substr(1))},c=function(e){var t=u(e);return t.substr(0,1).toUpperCase()+t.substr(1)},l=function(e,t){return a(e,t).toLowerCase()},f=Object.prototype.toString,h=function(e){return e===Object(e)},p=function(e){return"[object Array]"==f.call(e)},d=function(e){return"[object Date]"==f.call(e)},v=function(e){return"[object RegExp]"==f.call(e)},g=function(e){return"[object Boolean]"==f.call(e)},y=function(e){return e-=0,e===e},m={camelize:u,decamelize:l,pascalize:c,depascalize:l,camelizeKeys:function(e){return s(u,e)},decamelizeKeys:function(e,t){return s(l,e,t)},pascalizeKeys:function(e){return s(c,e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};r=m,i="function"==typeof r?r.call(t,n,t,e):r,!(void 0!==i&&(e.exports=i))}(this)},function(e,t){"use strict";t.CONFIG={protocol:"http",secureProtocol:"https",deviceEndpoint:{url:"http://api.demo.spacebunny.io",api_version:"/v1",path:"/device_configurations"},accessKeyEndpoint:{url:"http://api.demo.spacebunny.io",api_version:"/v1",path:"/access_key_configurations"},ackTypes:["auto","manual"],inputExchange:"input"}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(u){i=!0,o=u}finally{try{!r&&a["return"]&&a["return"]()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,t){for(var n=0;n0&&this.emit("error",new Error("Connection refused: "+n[t]))},u.prototype._handlePublish=function(e,t){var n=e.topic.toString(),r=e.payload,i=e.qos,o=e.messageId,s=this;switch(i){case 2:this.incomingStore.put(e,function(){s._sendPacket({cmd:"pubrec",messageId:o},t)});break;case 1:this._sendPacket({cmd:"puback",messageId:o});case 0:this.emit("message",n,r,e),this.handleMessage(e,t)}},u.prototype.handleMessage=function(e,t){t()},u.prototype._handleAck=function(e){var t=e.messageId,n=e.cmd,r=null,i=this.outgoing[t],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[t],this.outgoingStore.del(e,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:t},this._sendPacket(r);break;case"suback":delete this.outgoing[t],this.outgoingStore.del(e,function(t,n){var r,s=n.subscriptions,a=e.granted;if(t)return o.emit("error",t);for(r=0;r0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||r||(n=t.decoder.write(n)),t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):(t.reading=!1,t.buffer.push(n)),t.needReadable&&f(e),p(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length=U)e=U;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var n=null;return I.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.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.length>0?f(e):w(e)}function f(e){var n=e._readableState;n.needReadable=!1,n.emittedReadable||(n.emittedReadable=!0,n.sync?t.nextTick(function(){h(e)}):h(e))}function h(e){e.emit("readable")}function p(e,n){n.readingMore||(n.readingMore=!0,t.nextTick(function(){d(e,n)}))}function d(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length0)return;return 0===r.pipesCount?(r.flowing=!1,void(k.listenerCount(e,"data")>0&&m(e))):void(r.ranOut=!0)}function y(){this._readableState.ranOut&&(this._readableState.ranOut=!1,g(this))}function m(e,n){var r=e._readableState;if(r.flowing)throw new Error("Cannot switch to old mode now.");var i=n||!1,o=!1;e.readable=!0,e.pipe=C.prototype.pipe,e.on=e.addListener=C.prototype.on,e.on("readable",function(){o=!0;for(var t;!i&&null!==(t=e.read());)e.emit("data",t);null===t&&(o=!1,e._readableState.needReadable=!0)}),e.pause=function(){i=!0,this.emit("pause")},e.resume=function(){i=!1,o?t.nextTick(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}function b(e,t){var n,r=t.buffer,i=t.length,o=!!t.decoder,s=!!t.objectMode;if(0===r.length)return null;if(0===i)n=null;else if(s)n=r.shift();else if(!e||e>=i)n=o?r.join(""):I.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");!n.endEmitted&&n.calledRead&&(n.ended=!0,t.nextTick(function(){n.endEmitted||0!==n.length||(n.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function _(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function E(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=i;var x=n(87),I=n(88).Buffer;i.ReadableState=r;var k=n(84).EventEmitter;k.listenerCount||(k.listenerCount=function(e,t){return e.listeners(t).length});var C=n(83),S=n(91);S.inherits=n(73);var T;S.inherits(i,C),i.prototype.push=function(e,t){var n=this._readableState;return"string"!=typeof e||n.objectMode||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new I(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(e){T||(T=n(95).StringDecoder),this._readableState.decoder=new T(e),this._readableState.encoding=e};var U=8388608;i.prototype.read=function(e){var t=this._readableState;t.calledRead=!0;var n,r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return f(this),null;if(e=u(e,t),0===e&&t.ended)return n=null,t.length>0&&t.decoder&&(n=b(e,t),t.length-=n.length),0===t.length&&w(this),n;var i=t.needReadable;return t.length-e<=t.highWaterMark&&(i=!0),(t.ended||t.reading)&&(i=!1),i&&(t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),i&&!t.reading&&(e=u(r,t)),n=e>0?b(e,t):null,null===n&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),t.ended&&!t.endEmitted&&0===t.length&&w(this),n},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,n){function r(e){e===l&&o()}function i(){e.end()}function o(){e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("drain",d),e.removeListener("error",s),e.removeListener("unpipe",r),l.removeListener("end",i),l.removeListener("end",o),e._writableState&&!e._writableState.needDrain||d()}function s(t){c(),e.removeListener("error",s),0===k.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",u),c()}function u(){e.removeListener("close",a),c()}function c(){l.unpipe(e)}var l=this,f=this._readableState;switch(f.pipesCount){case 0:f.pipes=e;break;case 1:f.pipes=[f.pipes,e];break;default:f.pipes.push(e)}f.pipesCount+=1;var h=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,p=h?i:o;f.endEmitted?t.nextTick(p):l.once("end",p),e.on("unpipe",r);var d=v(l);return e.on("drain",d),e._events&&e._events.error?x(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",a),e.once("finish",u),e.emit("pipe",l),f.flowing||(this.on("readable",y),f.flowing=!0,t.nextTick(function(){g(l)})),e},i.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,this.removeListener("readable",y),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=E(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=C.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||m(this),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&f(this,r):this.read(0))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){m(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){m(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)"function"==typeof e[i]&&"undefined"==typeof this[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return _(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){n&&(n=!1,e.resume())},r},i._fromList=b}).call(t,n(36))},[300,238],[296,236,237],function(e,t,n){function r(e,t){this.afterTransform=function(e,n){return i(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length0)&&this[this._states[this._stateCounter]]();)this._stateCounter++,this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},r.prototype._parseHeader=function(){var e=this._list.readUInt8(0);return this.packet.cmd=u.types[e>>u.CMD_SHIFT],this.packet.retain=0!==(e&u.RETAIN_MASK),this.packet.qos=e>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=0!==(e&u.DUP_MASK),this._list.consume(1),!0},r.prototype._parseLength=function(){for(var e,t=0,n=1,r=0,i=!0;5>t&&(e=this._list.readUInt8(t++),r+=n*(e&u.LENGTH_MASK),n*=128,0!==(e&u.LENGTH_FIN_MASK));)if(this._list.length<=t){i=!1;break}return i&&(this.packet.length=r,this._list.consume(t)),i},r.prototype._parsePayload=function(){var e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this.emit("error",new Error("not supported"))}e=!0}return e},r.prototype._parseConnect=function(){var e,t,n,r,i,o,s={},a=this.packet;if(e=this._parseString(),null===e)return this.emit("error",new Error("cannot parse protocol id"));if("MQTT"!=e&&"MQIsdp"!=e)return this.emit("error",new Error("invalid protocol id"));if(a.protocolId=e,this._pos>=this._list.length)return this.emit("error",new Error("packet too short"));if(a.protocolVersion=this._list.readUInt8(this._pos),3!=a.protocolVersion&&4!=a.protocolVersion)return this.emit("error",new Error("invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this.emit("error",new Error("packet too short"));if(s.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,s.will&&(a.will={},a.will.retain=0!==(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK),a.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),a.clean=0!==(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK),this._pos++,a.keepalive=this._parseNum(),-1===a.keepalive)return this.emit("error",new Error("packet too short"));if(t=this._parseString(),null===t)return this.emit("error",new Error("packet too short"));if(a.clientId=t,s.will){if(n=this._parseString(),null===n)return this.emit("error",new Error("cannot parse will topic"));if(a.will.topic=n,r=this._parseBuffer(),null===r)return this.emit("error",new Error("cannot parse will payload"));a.will.payload=r}if(s.username){if(o=this._parseString(),null===o)return this.emit("error",new Error("cannot parse username"));a.username=o}if(s.password){if(i=this._parseBuffer(),null===i)return this.emit("error",new Error("cannot parse username"));a.password=i}return a},r.prototype._parseConnack=function(){var e=this.packet;return this._list.length<2?null:(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),e.returnCode=this._list.readUInt8(this._pos),-1===e.returnCode?this.emit("error",new Error("cannot parse return code")):void 0)},r.prototype._parsePublish=function(){var e=this.packet;return e.topic=this._parseString(),null===e.topic?this.emit("error",new Error("cannot parse topic")):void(e.qos>0&&!this._parseMessageId()||(e.payload=this._list.slice(this._pos,e.length)))},r.prototype._parseSubscribe=function(){var e,t,n=this.packet;if(1!=n.qos)return this.emit("error",new Error("wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._posthis._list.length||r>this.packet.length?null:(t=this._list.toString("utf8",this._pos,r),this._pos+=n,t)},r.prototype._parseBuffer=function(){var e,t=this._parseNum(),n=t+this._pos;return-1===t||n>this._list.length||n>this.packet.length?null:(e=this._list.slice(this._pos,n),this._pos+=t,e)},r.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var e=this._list.readUInt16BE(this._pos);return this._pos+=2,e},e.exports=r},function(e,t,n){(function(t){function r(e){if(!(this instanceof r))return new r(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var n=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",function(e){e.on("error",n)}),this.on("unpipe",function(e){e.removeListener("error",n)})}else t.isBuffer(e)?this.append(e):Array.isArray(e)&&e.forEach(function(e){t.isBuffer(e)&&this.append(e)}.bind(this));i.call(this)}var i=n(247),o=n(71);o.inherits(r,i),r.prototype._offset=function(e){for(var t,n=0,r=0;re)return[r,e-n];n=t}},r.prototype.append=function(e){var n=t.isBuffer(e)||e instanceof r;return"number"==typeof e&&(e=e.toString()),this._bufs.push(n?e:new t(e)),this.length+=e.length,this},r.prototype._write=function(e,t,n){this.append(e),n&&n()},r.prototype._read=function(e){return this.length?(e=Math.min(e,this.length),this.push(this.slice(0,e)),void this.consume(e)):this.push(null)},r.prototype.end=function(e){i.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},r.prototype.get=function(e){return this.slice(e,e+1)[0]},r.prototype.slice=function(e,t){return this.copy(null,0,e,t)},r.prototype.copy=function(e,n,r,i){if(("number"!=typeof r||0>r)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return e||new t(0);if(0>=i)return e||new t(0);var o,s,a=!!e,u=this._offset(r),c=i-r,l=c,f=a&&n||0,h=u[1];if(0===r&&i==this.length){if(!a)return t.concat(this._bufs);for(s=0;so)){this._bufs[s].copy(e,f,h,h+l);break}this._bufs[s].copy(e,f,h),f+=o,l-=o,h&&(h=0)}return e},r.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},r.prototype.consume=function(e){for(;this._bufs.length;){if(!(e>this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){for(var e=0,t=new r;e255||0>r)throw new Error("Invalid protocol version");if(l+=1,"string"!=typeof a&&!t.isBuffer(a)||!a&&4!=r||!a&&!o){if(4>r)throw new Error("clientId must be supplied before 3.1.1");if(0==o)throw new Error("clientId must be given if cleanSession set to 0")}else l+=a.length+2;if("number"!=typeof s||0>s||s>65535)throw new Error("Invalid keepalive");if(l+=2,l+=1,i){if("object"!=typeof i)throw new Error("Invalid will");if(!i.topic||"string"!=typeof i.topic)throw new Error("Invalid will topic");if(l+=t.byteLength(i.topic)+2,i.payload&&i.payload){if(!(i.payload.length>=0))throw new Error("Invalid will payload");l+="string"==typeof i.payload?t.byteLength(i.payload)+2:i.payload.length+2}else l+=2}if(u){if(!u.length)throw new Error("Invalid username");l+=t.byteLength(u)+2}if(c){if(!c.length)throw new Error("Invalid password");l+=b(c)+2}var f=new t(1+h(l)+l),v=0;f.writeUInt8(w.codes.connect<0&&(l+=y(c,l,a)),t.isBuffer(s)?g(c,l,s):v(c,l,s),c}function a(e){var e=e||{},n=e.cmd||"puback",r=e.messageId,i=e.dup&&"pubrel"===n?w.DUP_MASK:0,o=0;if("pubrel"===n&&(o=1),"number"!=typeof r)throw new Error("Invalid message id");var s=new t(4),a=0;return s[a++]=w.codes[n]<=0&&128>e?1:e>=128&&16384>e?2:e>=16384&&2097152>e?3:e>=2097152&&268435456>e?4:0}function p(e,t,n){var r=0,i=t;do r=n%128|0,n=n/128|0,n>0&&(r=128|r),e.writeUInt8(r,t++,!0);while(n>0);return t-i}function d(e,n,r){var i=t.byteLength(r);return y(e,n,i),v(e,n+2,r),i+2}function v(e,t,n){e.write(n,t)}function g(e,t,n){return n.copy(e,t),n.length}function y(e,t,n){return e.writeUInt8(n>>8,t,!0),e.writeUInt8(255&n,t+1,!0),2}function m(e,t,n){var r=0;return n&&"string"==typeof n?r+=d(e,t+r,n):n?(r+=y(e,t+r,n.length),r+=g(e,t+r,n)):r+=y(e,t+r,0),r}function b(e){return t.isBuffer(e)?e.length:t.byteLength(e)}var w=n(252),_=new t(0);e.exports=r}).call(t,n(3).Buffer)},function(e,t){"use strict";function n(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){Date.now();r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0,r._callback=void 0,r._args=void 0)}}function r(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;tx)return void setTimeout(l,I,e,t,n);try{m.send(e)}catch(r){return n(r)}n()}function f(e){m.close(),e()}function h(){y.setReadable(E),y.setWritable(E),y.emit("connect")}function p(){y.end(),y.destroy()}function d(e){y.destroy(e)}function v(e){var t=e.data;t=new i(t instanceof ArrayBuffer?new Uint8Array(t):t),E.push(t)}function g(){m.close()}var y,m,b="browser"===t.title,w=!!r.WebSocket,_=b?l:c,E=s.obj(_,f);n&&!Array.isArray(n)&&"object"==typeof n&&(o=n,n=null),o||(o={});var x=o.browserBufferSize||524288,I=o.browserBufferTimeout||1e3;return"object"==typeof e?m=e:(m=w&&b?new u(e,n):new u(e,n,o),m.binaryType="arraybuffer"),1===m.readyState?y=E:(y=a.obj(),m.addEventListener("open",h)),y.socket=m,m.addEventListener("close",p),m.addEventListener("error",d),m.addEventListener("message",v),E.on("close",g),y}var s=n(262),a=n(272),u=n(282);e.exports=o}).call(t,n(36),function(){return this}(),n(3).Buffer)},function(e,t,n){(function(t){function r(e){s.call(this,e),this._destroyed=!1}function i(e,t,n){n(null,e)}function o(e){return function(t,n,r){return"function"==typeof t&&(r=n,n=t,t={}),"function"!=typeof n&&(n=i),"function"!=typeof r&&(r=null),e(t,n,r)}}var s=n(263),a=n(71).inherits,u=n(255);a(r,s),r.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var n=this;t.nextTick(function(){e&&n.emit("error",e),n.emit("close")})}},e.exports=o(function(e,t,n){var i=new r(e);return i._transform=t,n&&(i._flush=n),i}),e.exports.ctor=o(function(e,t,n){function i(t){return this instanceof i?(this.options=u(e,t),void r.call(this,this.options)):new i(t)}return a(i,r),i.prototype._transform=t,n&&(i.prototype._flush=n),i}),e.exports.obj=o(function(e,t,n){var i=new r(u({objectMode:!0,highWaterMark:16},e));return i._transform=t,n&&(i._flush=n),i})}).call(t,n(36))},[299,264],[301,265],[302,267,270],function(e,t,n){(function(t){"use strict";function n(e){for(var n=new Array(arguments.length-1),r=0;rf;f++)v=g[f],l=v.indexOf(":"),u[w(v.substring(0,l))]=w(v.substring(l+1));if(r="",b=s+2,u["content-length"])p=parseInt(u["content-length"]),r=(""+n).substring(b,b+p);else for(i=null,c=h=y=b,m=n.length;(m>=y?m>h:h>m)&&(i=n.charAt(c),i!==e.NULL);c=m>=y?++h:--h)r+=i;return new t(o,u,r)},t.unmarshall=function(t){var r,i,o,s;return i=t.split(RegExp(""+e.NULL+e.LF+"*")),s={frames:[],partial:""},s.frames=function(){var e,t,o,s;for(o=i.slice(0,-1),s=[],e=0,t=o.length;t>e;e++)r=o[e],s.push(n(r));return s}(),o=i.slice(-1)[0],o===e.LF||-1!==o.search(RegExp(""+e.NULL+e.LF+"*$"))?s.frames.push(n(o)):s.partial=o,s},t.marshall=function(n,r,i){var o;return o=new t(n,r,i), -o.toString()+e.NULL},t}(),n=function(){function t(e){this.ws=e,this.ws.binaryType="arraybuffer",this.counter=0,this.connected=!1,this.heartbeat={outgoing:1e4,incoming:1e4},this.maxWebSocketFrameSize=16384,this.subscriptions={},this.partialData=""}var n;return t.prototype.debug=function(e){var t;return"undefined"!=typeof window&&null!==window&&null!=(t=window.console)?t.log(e):void 0},n=function(){return Date.now?Date.now():(new Date).valueOf},t.prototype._transmit=function(e,t,n){var i;for(i=r.marshall(e,t,n),"function"==typeof this.debug&&this.debug(">>> "+i);;){if(!(i.length>this.maxWebSocketFrameSize))return this.ws.send(i);this.ws.send(i.substring(0,this.maxWebSocketFrameSize)),i=i.substring(this.maxWebSocketFrameSize),"function"==typeof this.debug&&this.debug("remaining = "+i.length)}},t.prototype._setupHeartbeat=function(t){var r,o,s,a,u,c;if((r=t.version)===i.VERSIONS.V1_1||r===i.VERSIONS.V1_2)return o=function(){var e,n,r,i;for(r=t["heart-beat"].split(","),i=[],e=0,n=r.length;n>e;e++)c=r[e],i.push(parseInt(c));return i}(),a=o[0],s=o[1],0!==this.heartbeat.outgoing&&0!==s&&(u=Math.max(this.heartbeat.outgoing,s),"function"==typeof this.debug&&this.debug("send PING every "+u+"ms"),this.pinger=i.setInterval(u,function(t){return function(){return t.ws.send(e.LF),"function"==typeof t.debug?t.debug(">>> PING"):void 0}}(this))),0!==this.heartbeat.incoming&&0!==a?(u=Math.max(this.heartbeat.incoming,a),"function"==typeof this.debug&&this.debug("check PONG every "+u+"ms"),this.ponger=i.setInterval(u,function(e){return function(){var t;return t=n()-e.serverActivity,t>2*u?("function"==typeof e.debug&&e.debug("did not receive server activity for the last "+t+"ms"),e.ws.close()):void 0}}(this))):void 0},t.prototype._parseConnect=function(){var e,t,n,r;switch(e=1<=arguments.length?s.call(arguments,0):[],r={},e.length){case 2:r=e[0],t=e[1];break;case 3:e[1]instanceof Function?(r=e[0],t=e[1],n=e[2]):(r.login=e[0],r.passcode=e[1],t=e[2]);break;case 4:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3];break;default:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3],r.host=e[4]}return[r,t,n]},t.prototype.connect=function(){var t,o,a,u;return t=1<=arguments.length?s.call(arguments,0):[],u=this._parseConnect.apply(this,t),a=u[0],this.connectCallback=u[1],o=u[2],"function"==typeof this.debug&&this.debug("Opening Web Socket..."),this.ws.onmessage=function(t){return function(i){var s,a,u,c,l,f,h,p,d,v,g,y,m;if(c="undefined"!=typeof ArrayBuffer&&i.data instanceof ArrayBuffer?(s=new Uint8Array(i.data),"function"==typeof t.debug?t.debug("--- got data length: "+s.length):void 0,function(){var e,t,n;for(n=[],e=0,t=s.length;t>e;e++)a=s[e],n.push(String.fromCharCode(a));return n}().join("")):i.data,t.serverActivity=n(),c===e.LF)return void("function"==typeof t.debug&&t.debug("<<< PONG"));for("function"==typeof t.debug&&t.debug("<<< "+c),m=r.unmarshall(t.partialData+c),t.partialData=m.partial,v=m.frames,g=[],f=0,h=v.length;h>f;f++)switch(l=v[f],l.command){case"CONNECTED":"function"==typeof t.debug&&t.debug("connected to server "+l.headers.server),t.connected=!0,t._setupHeartbeat(l.headers),g.push("function"==typeof t.connectCallback?t.connectCallback(l):void 0);break;case"MESSAGE":y=l.headers.subscription,d=t.subscriptions[y]||t.onreceive,d?(u=t,p=l.headers["message-id"],l.ack=function(e){return null==e&&(e={}),u.ack(p,y,e)},l.nack=function(e){return null==e&&(e={}),u.nack(p,y,e)},g.push(d(l))):g.push("function"==typeof t.debug?t.debug("Unhandled received MESSAGE: "+l):void 0);break;case"RECEIPT":g.push("function"==typeof t.onreceipt?t.onreceipt(l):void 0);break;case"ERROR":g.push("function"==typeof o?o(l):void 0);break;default:g.push("function"==typeof t.debug?t.debug("Unhandled frame: "+l):void 0)}return g}}(this),this.ws.onclose=function(e){return function(){var t;return t="Whoops! Lost connection to "+e.ws.url,"function"==typeof e.debug&&e.debug(t),e._cleanUp(),"function"==typeof o?o(t):void 0}}(this),this.ws.onopen=function(e){return function(){return"function"==typeof e.debug&&e.debug("Web Socket Opened..."),a["accept-version"]=i.VERSIONS.supportedVersions(),a["heart-beat"]=[e.heartbeat.outgoing,e.heartbeat.incoming].join(","),e._transmit("CONNECT",a)}}(this)},t.prototype.disconnect=function(e,t){return null==t&&(t={}),this._transmit("DISCONNECT",t),this.ws.onclose=null,this.ws.close(),this._cleanUp(),"function"==typeof e?e():void 0},t.prototype._cleanUp=function(){return this.connected=!1,this.pinger&&i.clearInterval(this.pinger),this.ponger?i.clearInterval(this.ponger):void 0},t.prototype.send=function(e,t,n){return null==t&&(t={}),null==n&&(n=""),t.destination=e,this._transmit("SEND",t,n)},t.prototype.subscribe=function(e,t,n){var r;return null==n&&(n={}),n.id||(n.id="sub-"+this.counter++),n.destination=e,this.subscriptions[n.id]=t,this._transmit("SUBSCRIBE",n),r=this,{id:n.id,unsubscribe:function(){return r.unsubscribe(n.id)}}},t.prototype.unsubscribe=function(e){return delete this.subscriptions[e],this._transmit("UNSUBSCRIBE",{id:e})},t.prototype.begin=function(e){var t,n;return n=e||"tx-"+this.counter++,this._transmit("BEGIN",{transaction:n}),t=this,{id:n,commit:function(){return t.commit(n)},abort:function(){return t.abort(n)}}},t.prototype.commit=function(e){return this._transmit("COMMIT",{transaction:e})},t.prototype.abort=function(e){return this._transmit("ABORT",{transaction:e})},t.prototype.ack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("ACK",n)},t.prototype.nack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("NACK",n)},t}(),i={VERSIONS:{V1_0:"1.0",V1_1:"1.1",V1_2:"1.2",supportedVersions:function(){return"1.1,1.0"}},client:function(e,t){var r,o;return null==t&&(t=["v10.stomp","v11.stomp"]),r=i.WebSocketClass||WebSocket,o=new r(e,t),new n(o)},over:function(e){return new n(e)},Frame:r},"undefined"!=typeof t&&null!==t&&(t.Stomp=i),"undefined"!=typeof window&&null!==window?(i.setInterval=function(e,t){return window.setInterval(t,e)},i.clearInterval=function(e){return window.clearInterval(e)},window.Stomp=i):t||(self.Stomp=i)}).call(this)},function(e,t,n){(function(){var e,r,i,o,s,a,u;e=n(285),r=n(108),s=n(108),e.Stomp.setInterval=function(e,t){return setInterval(t,e)},e.Stomp.clearInterval=function(e){return clearInterval(e)},a=function(e,t,n){var i,o;return i=null,o={url:"tcp://"+e+":"+t,send:function(e){return i.write(e)},close:function(){return i.end()}},i=n?s.connect(t,e,n,function(e){return i.authorized?o.onopen():(console.error("SSL is not authorized: "+i.authorizationError),"function"==typeof o.onclose?o.onclose(e):void 0)}):r.connect(t,e,function(e){return o.onopen()}),i.on("error",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),i.on("close",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),i.on("data",function(e){var t;return t={data:e.toString()},o.onmessage(t)}),o},u=function(e){var t,r,i,o;return t=n(287).client,r=null,o={url:e,send:function(e){return r.sendUTF(e)},close:function(){return r.close()}},i=new t,i.on("connect",function(e){return r=e,o.onopen(),r.on("error",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),r.on("close",function(){return"function"==typeof o.onclose?o.onclose():void 0}),r.on("message",function(e){var t;return"utf8"===e.type?(t={data:e.utf8Data},o.onmessage(t)):void 0})}),i.connect(e),o},i=function(t,n,r){var i;return i=a(t,n,r),e.Stomp.over(i)},o=function(t){var n;return n=u(t),e.Stomp.over(n)},t.overTCP=i,t.overWS=o}).call(this)},function(e,t,n){function r(e,t){var n;return n=t?new o(e,t):new o(e)}var i=function(){return this}(),o=i.WebSocket||i.MozWebSocket,s=n(288);e.exports={w3cwebsocket:o?r:null,version:s}},function(e,t,n){e.exports=n(289).version},function(e,t){e.exports={_args:[["websocket@latest","/Users/gfoiani/Dev/work/spacebunny/sdk/node/node_modules/stompjs"]],_from:"websocket@latest",_id:"websocket@1.0.22",_inCache:!0,_installable:!0,_location:"/websocket",_nodeVersion:"3.3.1",_npmUser:{email:"brian@worlize.com",name:"theturtle32"},_npmVersion:"2.14.3",_phantomChildren:{},_requested:{name:"websocket",raw:"websocket@latest",rawSpec:"latest",scope:null,spec:"latest",type:"tag"},_requiredBy:["/stompjs"],_resolved:"https://registry.npmjs.org/websocket/-/websocket-1.0.22.tgz",_shasum:"8c33e3449f879aaf518297c9744cebf812b9e3d8",_shrinkwrap:null,_spec:"websocket@latest",_where:"/Users/gfoiani/Dev/work/spacebunny/sdk/node/node_modules/stompjs",author:{email:"brian@worlize.com",name:"Brian McKelvey",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"~2.2.0",nan:"~2.0.5","typedarray-to-buffer":"~3.0.3",yaeti:"~0.0.4"},description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^0.0.1",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^1.11.2","jshint-stylish":"^1.0.2",tape:"^4.0.1"},directories:{lib:"./lib"},dist:{shasum:"8c33e3449f879aaf518297c9744cebf812b9e3d8",tarball:"http://registry.npmjs.org/websocket/-/websocket-1.0.22.tgz"},engines:{node:">=0.8.0"},gitHead:"19108bbfd7d94a5cd02dbff3495eafee9e901ca4",homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["RFC-6455","client","comet","networking","push","realtime","server","socket","websocket","websockets"],license:"Apache-2.0",main:"index",maintainers:[{name:"theturtle32",email:"brian@worlize.com"}],name:"websocket",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.22"}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n>>0,l=new Array(c),h=0;h0?t(n,o.value,i):(i.become(o),h(e,n+1,o))}else t(n,r,i)}function h(e,t,n){for(var r=t;rn&&e._unreport()}}function d(e){return"object"!=typeof e||null===e?i(new TypeError("non-iterable passed to race()")):0===e.length?o():1===e.length?r(e[0]):v(e)}function v(e){var n,r,i,o=new _;for(n=0;n0||"function"!=typeof t&&0>i)return new this.constructor(b,r);var o=this._beget(),s=o._handler;return r.chain(s,r.receiver,e,t,n),o},t.prototype["catch"]=function(e){return this.then(void 0,e)},t.prototype._beget=function(){return a(this._handler,this.constructor)},t.all=u,t.race=d,t._traverse=c,t._visitRemaining=h,b.prototype.when=b.prototype.become=b.prototype.notify=b.prototype.fail=b.prototype._unreport=b.prototype._report=W,b.prototype._state=0,b.prototype.state=function(){return this._state},b.prototype.join=function(){for(var e=this;void 0!==e.handler;)e=e.handler;return e},b.prototype.chain=function(e,t,n,r,i){this.when({resolver:e,receiver:t,fulfilled:n,rejected:r,progress:i})},b.prototype.visit=function(e,t,n,r){this.chain(V,e,t,n,r)},b.prototype.fold=function(e,t,n,r){this.when(new A(e,t,n,r))},H(b,w),w.prototype.become=function(e){e.fail()};var V=new w;H(b,_),_.prototype._state=0,_.prototype.resolve=function(e){this.become(g(e))},_.prototype.reject=function(e){this.resolved||this.become(new k(e))},_.prototype.join=function(){if(!this.resolved)return this;for(var e=this;void 0!==e.handler;)if(e=e.handler,e===this)return this.handler=T();return e},_.prototype.run=function(){var e=this.consumers,t=this.join();this.consumers=void 0;for(var n=0;no)throw g("Too much content sent! Expected %d bytes",i);return null!==a?a.push(n.content):a=[n.content],r}throw"Expected content frame after headers"}var i=0,o=0,a=null,u={fields:null,properties:null,content:null};return n}function u(e){r.call(this,e),this.consumers={}}var c=n(67),l=n(103).closeMessage,f=n(103).inspect,h=n(103).methodName,p=n(70),d=n(71).inherits,v=n(84).EventEmitter,g=n(71).format,y=n(105).IllegalOperationError,m=n(105).stackCapture;d(r,v),e.exports.Channel=r,e.exports.acceptMessage=a;var b=r.prototype;b.allocate=function(){return this.ch=this.connection.freshChannel(this),this},b.sendImmediately=function(e,t){return this.connection.sendMethod(this.ch,e,t)},b.sendOrEnqueue=function(e,t,n){this.reply?this.pending.push({method:e,fields:t,reply:n}):(p(0===this.pending.length),this.reply=n,this.sendImmediately(e,t))},b.sendMessage=function(e,t,n){return this.connection.sendMessage(this.ch,c.BasicPublish,e,c.BasicProperties,t,n)},b._rpc=function(e,t,n,r){function i(t,i){if(null===t){if(i.id===n)return r(null,i);var s=h(n),a=new Error(g("Expected %s; got %s",s,f(i,!1)));return o.closeWithError(g("Expected %s; got %s",s,h(i.id)),c.constants.UNEXPECTED_FRAME,a),r(a)}if(t instanceof Error)return r(t);var u=(t.fields.classId<<16)+t.fields.methodId,a=e===u?g("Operation failed: %s; %s",h(e),l(t)):g("Channel closed by server: %s",l(t));return r(new Error(a))}var o=this;this.sendOrEnqueue(e,t,i)},b.toClosed=function(e){this._rejectPending(),o(this,"Channel closed",e),this.accept=i("Channel closed",e),this.connection.releaseChannel(this.ch),this.emit("close")},b.toClosing=function(e,t){var n=this.sendImmediately.bind(this);o(this,"Channel closing",e),this.accept=function(e){if(e.id===c.ChannelCloseOk){t&&t();var r=m("ChannelCloseOk frame received");this.toClosed(r)}else e.id===c.ChannelClose&&n(c.ChannelCloseOk,{})}},b._rejectPending=function(){function e(e){e(new Error("Channel ended, no reply will be forthcoming"))}null!==this.reply&&e(this.reply),this.reply=null;for(var t;t=this.pending.shift();)e(t.reply);this.pending=null},b.closeBecause=function(e,t,n){this.sendImmediately(c.ChannelClose,{replyText:e,replyCode:t,methodId:0,classId:0});var r=m("closeBecause called: "+e);this.toClosing(r,n)},b.closeWithError=function(e,t,n){var r=this;this.closeBecause(e,t,function(){n.code=t,r.emit("error",n)})},b.acceptMessageFrame=function(e){try{this.handleMessage=this.handleMessage(e)}catch(t){"string"==typeof t?this.closeWithError(t,c.constants.UNEXPECTED_FRAME,new Error(t)):t instanceof Error?this.closeWithError("Error while processing message",c.constants.INTERNAL_ERROR,t):this.closeWithError("Internal error while processing message",c.constants.INTERNAL_ERROR,new Error(t.toString()))}},b.handleConfirm=function(e,t){var n=t.deliveryTag,r=t.multiple;if(r){var i=this.unconfirmed.splice(0,n-this.lwm+1);this.lwm=n+1,i.forEach(e)}else{var o;if(n===this.lwm)for(o=this.unconfirmed.shift(),this.lwm++;null===this.unconfirmed[0];)this.unconfirmed.shift(),this.lwm++;else o=this.unconfirmed[n-this.lwm],this.unconfirmed[n-this.lwm]=null;e(o)}},b.pushConfirmCallback=function(e){this.unconfirmed.push(e||!1)},b.accept=function(e){switch(e.id){case void 0:case c.BasicDeliver:case c.BasicReturn:case c.BasicProperties:return this.acceptMessageFrame(e);case c.BasicAck:return this.emit("ack",e.fields);case c.BasicNack:return this.emit("nack",e.fields);case c.BasicCancel:return this.emit("cancel",e.fields);case c.ChannelClose:if(this.reply){var t=this.reply;this.reply=null,t(e)}var n="Channel closed by server: "+l(e);this.sendImmediately(c.ChannelCloseOk,{});var r=new Error(n);r.code=e.fields.replyCode,this.emit("error",r);var i=m(n);return void this.toClosed(i);case c.BasicFlow:return this.closeWithError("Flow not implemented",c.constants.NOT_IMPLEMENTED,new Error("Flow not implemented"));default:var t=this.reply;if(this.reply=null,this.pending.length>0){var o=this.pending.shift();this.reply=o.reply,this.sendImmediately(o.method,o.fields)}return t(null,e)}},b.onBufferDrain=function(){this.emit("drain")},d(u,r),e.exports.BaseChannel=u,u.prototype.registerConsumer=function(e,t){this.consumers[e]=t},u.prototype.unregisterConsumer=function(e){delete this.consumers[e]},u.prototype.dispatchMessage=function(e,t){var n=e.consumerTag,r=this.consumers[n];if(r)return r(t);throw new Error("Unknown consumer: "+n)},u.prototype.handleDelivery=function(e){return this.dispatchMessage(e.fields,e)},u.prototype.handleCancel=function(e){return this.dispatchMessage(e,null)}}).call(t,n(3).Buffer)},function(e,t){"use strict";function n(e,t,n){void 0!=n&&(e[t]=n)}var r=Object.freeze({}),i={};i.assertQueue=function(e,t){e=e||"",t=t||r;var i=Object.create(t.arguments||null);return n(i,"x-expires",t.expires),n(i,"x-message-ttl",t.messageTtl),n(i,"x-dead-letter-exchange",t.deadLetterExchange),n(i,"x-dead-letter-routing-key",t.deadLetterRoutingKey),n(i,"x-max-length",t.maxLength),n(i,"x-max-priority",t.maxPriority),{queue:e,exclusive:!!t.exclusive,durable:void 0===t.durable?!0:t.durable,autoDelete:!!t.autoDelete,arguments:i,passive:!1,ticket:0,nowait:!1}},i.checkQueue=function(e){return{queue:e,passive:!0,nowait:!1,durable:!0,autoDelete:!1,exclusive:!1,ticket:0}},i.deleteQueue=function(e,t){return t=t||r,{queue:e,ifUnused:!!t.ifUnused,ifEmpty:!!t.ifEmpty,ticket:0,nowait:!1}},i.purgeQueue=function(e){return{queue:e,ticket:0,nowait:!1}},i.bindQueue=function(e,t,n,r){return{queue:e,exchange:t,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.unbindQueue=function(e,t,n,r){return{queue:e,exchange:t,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.assertExchange=function(e,t,i){i=i||r;var o=Object.create(i.arguments||null);return n(o,"alternate-exchange",i.alternateExchange),{exchange:e,ticket:0,type:t,passive:!1,durable:void 0===i.durable?!0:i.durable,autoDelete:!!i.autoDelete,internal:!!i.internal,nowait:!1,arguments:o}},i.checkExchange=function(e){return{exchange:e,passive:!0,nowait:!1,durable:!0,internal:!1,type:"",autoDelete:!1,ticket:0}},i.deleteExchange=function(e,t){return t=t||r,{exchange:e,ifUnused:!!t.ifUnused,ticket:0,nowait:!1}},i.bindExchange=function(e,t,n,r){return{source:t,destination:e,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.unbindExchange=function(e,t,n,r){return{source:t,destination:e,routingKey:n,arguments:r,ticket:0,nowait:!1}},i.publish=function(e,t,i){function o(e){return void 0===e?void 0:Array.isArray(e)?e.map(String):[String(e)]}i=i||r;var s=Object.create(i.headers||null);n(s,"CC",o(i.CC)),n(s,"BCC",o(i.BCC));var a;void 0!==i.persistent?a=i.persistent?2:1:"number"==typeof i.deliveryMode?a=i.deliveryMode:i.deliveryMode&&(a=2);var u=i.expiration;return void 0!==u&&(u=u.toString()),{exchange:e,routingKey:t,mandatory:!!i.mandatory,immediate:!1,ticket:void 0,contentType:i.contentType,contentEncoding:i.contentEncoding,headers:s,deliveryMode:a,priority:i.priority,correlationId:i.correlationId,replyTo:i.replyTo,expiration:u,messageId:i.messageId,timestamp:i.timestamp,type:i.type,userId:i.userId,appId:i.appId,clusterId:void 0}},i.consume=function(e,t){t=t||r;var i=Object.create(t.arguments||null);return n(i,"x-priority",t.priority),{ticket:0,queue:e,consumerTag:t.consumerTag||"",noLocal:!!t.noLocal,noAck:!!t.noAck,exclusive:!!t.exclusive,nowait:!1,arguments:i}},i.cancel=function(e){return{consumerTag:e,nowait:!1}},i.get=function(e,t){return t=t||r,{ticket:0,queue:e,noAck:!!t.noAck}},i.ack=function(e,t){return{deliveryTag:e,multiple:!!t}},i.nack=function(e,t,n){return{deliveryTag:e,multiple:!!t,requeue:void 0===n?!0:n}},i.reject=function(e,t){return{deliveryTag:e,requeue:void 0===t?!0:t}},i.prefetch=function(e,t){return{prefetchCount:e||0,prefetchSize:0,global:!!t}},i.recover=function(){return{requeue:!0}},e.exports=Object.freeze(i)},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=n(132),s=r(o),a=n(209),u=r(a),c=function(){function e(e,t){for(var n=0;n0?t[0].id||e:e}},{key:"liveStreamExists",value:function(e){var t=(0,s["default"])(this._liveStreams,function(t){return t.name===e});return t.length>0}},{key:"tempQueue",value:function(e,t,n){var r=n||(new Date).getTime();return r+"-"+this._connectionParams.client+"-"+(this.exchangeName(e,t)+".")+(""+this._tempQueueSuffix)}},{key:"exchangeName",value:function(e,t){return e&&t?this.liveStreamByName(e)+"."+t:""+t}},{key:"_encapsulateContent",value:function(e){var t=e;try{t=JSON.stringify(e)}catch(n){t=e}return t}},{key:"_checkSslOptions",value:function(){var e=this._sslOpts;return e.ca?e.cert&&e.key?!0:!!e.pfx:!1}},{key:"_generateHostname",value:function(e){var t=""+(this._endpointUrl||e.url),n=this._ssl?w.endpoint.secureProtocol:w.endpoint.protocol;return(0,u["default"])(t,n)||(t=n+"://"+t),t}},{key:"_parseContent",value:function(t){var n=t;if(e.isBuffer(n)){var r=n.toString("utf-8");try{n=JSON.parse(r)}catch(i){n=r}}return n}}]),t}();t["default"]=_}).call(t,n(3).Buffer)},function(e,t,n){function r(e,t){var n=a(e)?i:o;return n(e,s(t,3))}var i=n(133),o=n(134),s=n(140),a=n(17);e.exports=r},function(e,t){function n(e,t){for(var n=-1,r=e.length,i=0,o=[];++nn)return!1;var r=e.length-1;return n==r?e.pop():s.call(e,n,1),!0}var i=n(147),o=Array.prototype,s=o.splice;e.exports=r},function(e,t,n){function r(e,t){for(var n=e.length;n--;)if(i(e[n][0],t))return n;return-1}var i=n(148);e.exports=r},function(e,t){function n(e,t){return e===t||e!==e&&t!==t}e.exports=n},function(e,t,n){function r(e){var t=this.__data__,n=t.array;return n?i(n,e):t.map.get(e)}var i=n(150);e.exports=r},function(e,t,n){function r(e,t){var n=i(e,t);return 0>n?void 0:e[n][1]}var i=n(147);e.exports=r},function(e,t,n){function r(e){var t=this.__data__,n=t.array;return n?i(n,e):t.map.has(e)}var i=n(152);e.exports=r},function(e,t,n){function r(e,t){return i(e,t)>-1}var i=n(147);e.exports=r},function(e,t,n){function r(e,t){var n=this.__data__,r=n.array;r&&(r.lengthr?e.push([t,n]):e[r][1]=n}var i=n(147);e.exports=r},function(e,t,n){function r(e,t,n){e[t]=i&&void 0===n?o:n}var i=n(157),o="__lodash_hash_undefined__";e.exports=r},function(e,t,n){function r(e,t,n,a,u){return e===t?!0:null==e||null==t||!o(e)&&!s(t)?e!==e&&t!==t:i(e,t,r,n,a,u)}var i=n(175),o=n(14),s=n(18);e.exports=r},function(e,t,n){function r(e,t,n,r,g,m){var b=c(e),w=c(t),_=d,E=d;b||(_=u(e),_=_==p?v:_),w||(E=u(t),E=E==p?v:E);var x=_==v&&!l(e),I=E==v&&!l(t),k=_==E;if(k&&!x)return m||(m=new i),b||f(e)?o(e,t,n,r,g,m):s(e,t,_,n,r,g,m);if(!(g&h)){var C=x&&y.call(e,"__wrapped__"),S=I&&y.call(t,"__wrapped__");if(C||S)return m||(m=new i),n(C?e.value():e,S?t.value():t,r,g,m)}return k?(m||(m=new i),a(e,t,n,r,g,m)):!1}var i=n(143),o=n(176),s=n(178),a=n(183),u=n(184),c=n(17),l=n(160),f=n(187),h=2,p="[object Arguments]",d="[object Array]",v="[object Object]",g=Object.prototype,y=g.hasOwnProperty;e.exports=r},function(e,t,n){function r(e,t,n,r,a,u){var c=-1,l=a&s,f=a&o,h=e.length,p=t.length;if(h!=p&&!(l&&p>h))return!1;var d=u.get(e);if(d)return d==t;var v=!0;for(u.set(e,t);++cn;)e=e[t[n++]];return n&&n==r?e:void 0}var i=n(195),o=n(199);e.exports=r},function(e,t,n){function r(e){return i(e)?e:o(e)}var i=n(17),o=n(196);e.exports=r},function(e,t,n){function r(e){var t=[];return i(e).replace(o,function(e,n,r,i){t.push(r?i.replace(s,"$1"):n||e)}),t}var i=n(197),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,s=/\\(\\)?/g;e.exports=r},function(e,t,n){function r(e){if("string"==typeof e)return e;if(null==e)return"";if(o(e))return u?u.call(e):"";var t=e+"";return"0"==t&&1/e==-s?"-0":t}var i=n(179),o=n(198),s=1/0,a=i?i.prototype:void 0,u=a?a.toString:void 0;e.exports=r},function(e,t,n){function r(e){return"symbol"==typeof e||i(e)&&a.call(e)==o}var i=n(18),o="[object Symbol]",s=Object.prototype,a=s.toString;e.exports=r},function(e,t,n){function r(e,t){return"number"==typeof e?!0:!i(e)&&(s.test(e)||!o.test(e)||null!=t&&e in Object(t))}var i=n(17),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=r},function(e,t,n){function r(e,t){return o(e,t,i)}var i=n(201),o=n(202);e.exports=r},function(e,t){function n(e,t){return t in Object(e)}e.exports=n},function(e,t,n){function r(e,t,n){if(null==e)return!1;var r=n(e,t);r||u(t)||(t=i(t),e=h(e,t),null!=e&&(t=f(t),r=n(e,t)));var p=e?e.length:void 0;return r||!!p&&c(p)&&a(t,p)&&(s(e)||l(e)||o(e))}var i=n(195),o=n(29),s=n(17),a=n(31),u=n(199),c=n(15),l=n(16),f=n(203),h=n(204);e.exports=r},function(e,t){function n(e){var t=e?e.length:0;return t?e[t-1]:void 0}e.exports=n},function(e,t,n){function r(e,t){return 1==t.length?e:o(e,i(t,0,-1))}var i=n(205),o=n(193);e.exports=r},function(e,t){function n(e,t,n){var r=-1,i=e.length;0>t&&(t=-t>i?0:i+t),n=n>i?i:n,0>n&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r=e?e:n),void 0!==t&&(e=e>=t?e:t)),e}e.exports=n},function(e,t,n){e.exports=n(212)},function(e,t,n){"use strict";function r(e){this.defaults=o.merge({},e),this.interceptors={request:new a,response:new a}}var i=n(213),o=n(214),s=n(215),a=n(223),u=n(224),c=n(225),l=n(226),f=n(219);r.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),e=o.merge(i,this.defaults,{method:"get"},e),e.baseURL&&!u(e.url)&&(e.url=c(e.baseURL,e.url)),e.withCredentials=e.withCredentials||this.defaults.withCredentials,e.data=f(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=[s,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n};var h=new r(i),p=e.exports=l(r.prototype.request,h);p.create=function(e){return new r(e)},p.defaults=h.defaults,p.all=function(e){return Promise.all(e)},p.spread=n(227),p.interceptors=h.interceptors,o.forEach(["delete","get","head"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))},p[e]=l(r.prototype[e],h)}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))},p[e]=l(r.prototype[e],h)})},function(e,t,n){"use strict";var r=n(214),i=/^\)\]\}',?\n/,o={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return r.isFormData(e)?e:r.isArrayBuffer(e)?e:r.isArrayBufferView(e)?e.buffer:!r.isObject(e)||r.isFile(e)||r.isBlob(e)?e:(r.isUndefined(t)||(r.forEach(t,function(e,n){"content-type"===n.toLowerCase()&&(t["Content-Type"]=e)}),r.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(i,"");try{e=JSON.parse(e)}catch(t){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(o),post:r.merge(o),put:r.merge(o)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(e,t){"use strict";function n(e){return"[object Array]"===y.call(e)}function r(e){return"[object ArrayBuffer]"===y.call(e)}function i(e){return"[object FormData]"===y.call(e)}function o(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function s(e){return"string"==typeof e}function a(e){return"number"==typeof e}function u(e){return"undefined"==typeof e}function c(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===y.call(e)}function f(e){return"[object File]"===y.call(e)}function h(e){return"[object Blob]"===y.call(e)}function p(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function d(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||n(e)||(e=[e]),n(e))for(var r=0,i=e.length;i>r;r++)t.call(null,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(null,e[o],o,e)}function g(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=g(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;r>n;n++)v(arguments[n],e);return t}var y=Object.prototype.toString;e.exports={isArray:n,isArrayBuffer:r,isFormData:i,isArrayBufferView:o,isString:s,isNumber:a, +isObject:c,isUndefined:u,isDate:l,isFile:f,isBlob:h,isStandardBrowserEnv:d,forEach:v,merge:g,trim:p}},function(e,t,n){(function(t){"use strict";e.exports=function(e){return new Promise(function(r,i){try{var o;"function"==typeof e.adapter?o=e.adapter:"undefined"!=typeof XMLHttpRequest?o=n(216):"undefined"!=typeof t&&(o=n(216)),"function"==typeof o&&o(r,i,e)}catch(s){i(s)}})}}).call(t,n(36))},function(e,t,n){"use strict";var r=n(214),i=n(217),o=n(218),s=n(219),a=n(220),u=window.btoa||n(221);e.exports=function(e,t,c){var l=c.data,f=c.headers;r.isFormData(l)&&delete f["Content-Type"];var h=new XMLHttpRequest;if(!window.XDomainRequest||"withCredentials"in h||a(c.url)||(h=new window.XDomainRequest),c.auth){var p=c.auth.username||"",d=c.auth.password||"";f.Authorization="Basic "+u(p+":"+d)}if(h.open(c.method.toUpperCase(),i(c.url,c.params,c.paramsSerializer),!0),h.timeout=c.timeout,h.onload=function(){if(h){var n="getAllResponseHeaders"in h?o(h.getAllResponseHeaders()):null,r=-1!==["text",""].indexOf(c.responseType||"")?h.responseText:h.response,i={data:s(r,n,c.transformResponse),status:1223===h.status?204:h.status,statusText:1223===h.status?"No Content":h.statusText,headers:n,config:c};(i.status>=200&&i.status<300||!("status"in h)&&i.responseText?e:t)(i),h=null}},h.onerror=function(){t(new Error("Network Error")),h=null},r.isStandardBrowserEnv()){var v=n(222),g=c.withCredentials||a(c.url)?v.read(c.xsrfCookieName):void 0;g&&(f[c.xsrfHeaderName]=g)}if("setRequestHeader"in h&&r.forEach(f,function(e,t){"undefined"==typeof l&&"content-type"===t.toLowerCase()?delete f[t]:h.setRequestHeader(t,e)}),c.withCredentials&&(h.withCredentials=!0),c.responseType)try{h.responseType=c.responseType}catch(y){if("json"!==h.responseType)throw y}r.isArrayBuffer(l)&&(l=new DataView(l)),h.send(l)}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var i=n(214);e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else{var s=[];i.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(i.isArray(e)&&(t+="[]"),i.isArray(e)||(e=[e]),i.forEach(e,function(e){i.isDate(e)?e=e.toISOString():i.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),o=s.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){"use strict";var r=n(214);e.exports=function(e){var t,n,i,o={};return e?(r.forEach(e.split("\n"),function(e){i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t&&(o[t]=o[t]?o[t]+", "+n:n)}),o):o}},function(e,t,n){"use strict";var r=n(214);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";var r=n(214);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(i.setAttribute("href",t),t=i.href),i.setAttribute("href",t),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return t=e(window.location.href),function(n){var i=r.isString(n)?e(n):n;return i.protocol===t.protocol&&i.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(e){this.message=e}function r(e){for(var t,r,o=String(e),s="",a=0,u=i;o.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&t>>8-a%1*8)){if(r=o.charCodeAt(a+=.75),r>255)throw new n("INVALID_CHARACTER_ERR: DOM Exception 5");t=t<<8|r}return s}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(214);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,i,o,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var i=n(214);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){i.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;ri;i++)r.push(s(e,t[i],n));else{r={};for(var a in t)t.hasOwnProperty(a)&&(r[e(a,n)]=s(e,t[a],n))}return r},a=function(e,t){t=t||{};var n=t.separator||"_",r=t.split||/(?=[A-Z])/;return e.split(r).join(n)},u=function(e){return y(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""}),e.substr(0,1).toLowerCase()+e.substr(1))},c=function(e){var t=u(e);return t.substr(0,1).toUpperCase()+t.substr(1)},l=function(e,t){return a(e,t).toLowerCase()},f=Object.prototype.toString,h=function(e){return e===Object(e)},p=function(e){return"[object Array]"==f.call(e)},d=function(e){return"[object Date]"==f.call(e)},v=function(e){return"[object RegExp]"==f.call(e)},g=function(e){return"[object Boolean]"==f.call(e)},y=function(e){return e-=0,e===e},m={camelize:u,decamelize:l,pascalize:c,depascalize:l,camelizeKeys:function(e){return s(u,e)},decamelizeKeys:function(e,t){return s(l,e,t)},pascalizeKeys:function(e){return s(c,e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};r=m,i="function"==typeof r?r.call(t,n,t,e):r,!(void 0!==i&&(e.exports=i))}(this)},function(e,t){"use strict";t.CONFIG={endpoint:{protocol:"http",secureProtocol:"https"},deviceEndpoint:{url:"http://api.demo.spacebunny.io",api_version:"/v1",path:"/device_configurations"},accessKeyEndpoint:{url:"http://api.demo.spacebunny.io",api_version:"/v1",path:"/access_key_configurations"},ssl:{secureProtocol:"TLSv1_method"},fromApiHeader:"x-from-sb-api",protocol:"amqp",inboxTopic:"inbox",liveStreamSuffix:"live_stream",tempQueueSuffix:"temp",amqp:{ackTypes:["auto","manual"],protocol:"amqp",ssl:{protocol:"amqps"},inputQueueArgs:{},deviceExchangeArgs:{},subscribeArgs:{noAck:!0,requeue:!1,allUpTo:!1},publishArgs:{withConfirm:!1},socketOptions:{frameMax:32768,heartbeat:60},stream:{defaultStreamRoutingKey:"#",streamQueueArguments:{exclusive:!0,autoDelete:!0,durable:!1}}},mqtt:{protocol:"mqtt",ssl:{protocol:"mqtts",rejectUnauthorized:!0},connection:{opts:{qos:1},timeout:5e3}},stomp:{ackTypes:["client"],connection:{headers:{max_hbrlck_fails:10,"accept-version":"1.0,1.1,1.2","heart-beat":"10000,10000"}},existingQueuePrefix:"amq/queue",stream:{exchangePrefix:"exchange",defaultPattern:"#"}},webStomp:{ackTypes:["client"],webSocket:{protocol:"ws",ssl:{protocol:"wss"},enpoint:"ws"}}}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(u){i=!0,o=u}finally{try{!r&&a["return"]&&a["return"]()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,t){for(var n=0;n0&&this.emit("error",new Error("Connection refused: "+n[t]))},u.prototype._handlePublish=function(e,t){var n=e.topic.toString(),r=e.payload,i=e.qos,o=e.messageId,s=this;switch(i){case 2:this.incomingStore.put(e,function(){s._sendPacket({cmd:"pubrec",messageId:o},t)});break;case 1:this._sendPacket({cmd:"puback",messageId:o});case 0:this.emit("message",n,r,e),this.handleMessage(e,t)}},u.prototype.handleMessage=function(e,t){t()},u.prototype._handleAck=function(e){var t=e.messageId,n=e.cmd,r=null,i=this.outgoing[t],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[t],this.outgoingStore.del(e,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:t},this._sendPacket(r);break;case"suback":delete this.outgoing[t],this.outgoingStore.del(e,function(t,n){var r,s=n.subscriptions,a=e.granted;if(t)return o.emit("error",t);for(r=0;r0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||r||(n=t.decoder.write(n)),t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):(t.reading=!1,t.buffer.push(n)),t.needReadable&&f(e),p(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length=U)e=U;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var n=null;return I.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.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.length>0?f(e):w(e)}function f(e){var n=e._readableState;n.needReadable=!1,n.emittedReadable||(n.emittedReadable=!0,n.sync?t.nextTick(function(){h(e)}):h(e))}function h(e){e.emit("readable")}function p(e,n){n.readingMore||(n.readingMore=!0,t.nextTick(function(){d(e,n)}))}function d(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length0)return;return 0===r.pipesCount?(r.flowing=!1,void(k.listenerCount(e,"data")>0&&m(e))):void(r.ranOut=!0)}function y(){this._readableState.ranOut&&(this._readableState.ranOut=!1,g(this))}function m(e,n){var r=e._readableState;if(r.flowing)throw new Error("Cannot switch to old mode now.");var i=n||!1,o=!1;e.readable=!0,e.pipe=C.prototype.pipe,e.on=e.addListener=C.prototype.on,e.on("readable",function(){o=!0;for(var t;!i&&null!==(t=e.read());)e.emit("data",t);null===t&&(o=!1,e._readableState.needReadable=!0)}),e.pause=function(){i=!0,this.emit("pause")},e.resume=function(){i=!1,o?t.nextTick(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}function b(e,t){var n,r=t.buffer,i=t.length,o=!!t.decoder,s=!!t.objectMode;if(0===r.length)return null;if(0===i)n=null;else if(s)n=r.shift();else if(!e||e>=i)n=o?r.join(""):I.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");!n.endEmitted&&n.calledRead&&(n.ended=!0,t.nextTick(function(){n.endEmitted||0!==n.length||(n.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function _(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function E(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=i;var x=n(87),I=n(88).Buffer;i.ReadableState=r;var k=n(84).EventEmitter;k.listenerCount||(k.listenerCount=function(e,t){return e.listeners(t).length});var C=n(83),S=n(91);S.inherits=n(73);var T;S.inherits(i,C),i.prototype.push=function(e,t){var n=this._readableState;return"string"!=typeof e||n.objectMode||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new I(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(e){T||(T=n(95).StringDecoder),this._readableState.decoder=new T(e),this._readableState.encoding=e};var U=8388608;i.prototype.read=function(e){var t=this._readableState;t.calledRead=!0;var n,r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return f(this),null;if(e=u(e,t),0===e&&t.ended)return n=null,t.length>0&&t.decoder&&(n=b(e,t),t.length-=n.length),0===t.length&&w(this),n;var i=t.needReadable;return t.length-e<=t.highWaterMark&&(i=!0),(t.ended||t.reading)&&(i=!1),i&&(t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),i&&!t.reading&&(e=u(r,t)),n=e>0?b(e,t):null,null===n&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),t.ended&&!t.endEmitted&&0===t.length&&w(this),n},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,n){function r(e){e===l&&o()}function i(){e.end()}function o(){e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("drain",d),e.removeListener("error",s),e.removeListener("unpipe",r),l.removeListener("end",i),l.removeListener("end",o),e._writableState&&!e._writableState.needDrain||d()}function s(t){c(),e.removeListener("error",s),0===k.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",u),c()}function u(){e.removeListener("close",a),c()}function c(){l.unpipe(e)}var l=this,f=this._readableState;switch(f.pipesCount){case 0:f.pipes=e;break;case 1:f.pipes=[f.pipes,e];break;default:f.pipes.push(e)}f.pipesCount+=1;var h=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,p=h?i:o;f.endEmitted?t.nextTick(p):l.once("end",p),e.on("unpipe",r);var d=v(l);return e.on("drain",d),e._events&&e._events.error?x(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",a),e.once("finish",u),e.emit("pipe",l),f.flowing||(this.on("readable",y),f.flowing=!0,t.nextTick(function(){g(l)})),e},i.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,this.removeListener("readable",y),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=E(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=C.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||m(this),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&f(this,r):this.read(0))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){m(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){m(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)"function"==typeof e[i]&&"undefined"==typeof this[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return _(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){n&&(n=!1,e.resume())},r},i._fromList=b}).call(t,n(36))},[301,238],[297,236,237],function(e,t,n){function r(e,t){this.afterTransform=function(e,n){return i(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length0)&&this[this._states[this._stateCounter]]();)this._stateCounter++,this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},r.prototype._parseHeader=function(){var e=this._list.readUInt8(0);return this.packet.cmd=u.types[e>>u.CMD_SHIFT],this.packet.retain=0!==(e&u.RETAIN_MASK),this.packet.qos=e>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=0!==(e&u.DUP_MASK),this._list.consume(1),!0},r.prototype._parseLength=function(){for(var e,t=0,n=1,r=0,i=!0;5>t&&(e=this._list.readUInt8(t++),r+=n*(e&u.LENGTH_MASK),n*=128,0!==(e&u.LENGTH_FIN_MASK));)if(this._list.length<=t){i=!1;break}return i&&(this.packet.length=r,this._list.consume(t)),i},r.prototype._parsePayload=function(){var e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this.emit("error",new Error("not supported"))}e=!0}return e},r.prototype._parseConnect=function(){var e,t,n,r,i,o,s={},a=this.packet;if(e=this._parseString(),null===e)return this.emit("error",new Error("cannot parse protocol id"));if("MQTT"!=e&&"MQIsdp"!=e)return this.emit("error",new Error("invalid protocol id"));if(a.protocolId=e,this._pos>=this._list.length)return this.emit("error",new Error("packet too short"));if(a.protocolVersion=this._list.readUInt8(this._pos),3!=a.protocolVersion&&4!=a.protocolVersion)return this.emit("error",new Error("invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this.emit("error",new Error("packet too short"));if(s.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,s.will&&(a.will={},a.will.retain=0!==(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK),a.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),a.clean=0!==(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK),this._pos++,a.keepalive=this._parseNum(),-1===a.keepalive)return this.emit("error",new Error("packet too short"));if(t=this._parseString(),null===t)return this.emit("error",new Error("packet too short"));if(a.clientId=t,s.will){if(n=this._parseString(),null===n)return this.emit("error",new Error("cannot parse will topic"));if(a.will.topic=n,r=this._parseBuffer(),null===r)return this.emit("error",new Error("cannot parse will payload"));a.will.payload=r}if(s.username){if(o=this._parseString(),null===o)return this.emit("error",new Error("cannot parse username"));a.username=o}if(s.password){if(i=this._parseBuffer(),null===i)return this.emit("error",new Error("cannot parse username"));a.password=i}return a},r.prototype._parseConnack=function(){var e=this.packet;return this._list.length<2?null:(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),e.returnCode=this._list.readUInt8(this._pos),-1===e.returnCode?this.emit("error",new Error("cannot parse return code")):void 0)},r.prototype._parsePublish=function(){var e=this.packet;return e.topic=this._parseString(),null===e.topic?this.emit("error",new Error("cannot parse topic")):void(e.qos>0&&!this._parseMessageId()||(e.payload=this._list.slice(this._pos,e.length)))},r.prototype._parseSubscribe=function(){var e,t,n=this.packet;if(1!=n.qos)return this.emit("error",new Error("wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._posthis._list.length||r>this.packet.length?null:(t=this._list.toString("utf8",this._pos,r),this._pos+=n,t)},r.prototype._parseBuffer=function(){var e,t=this._parseNum(),n=t+this._pos;return-1===t||n>this._list.length||n>this.packet.length?null:(e=this._list.slice(this._pos,n),this._pos+=t,e)},r.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var e=this._list.readUInt16BE(this._pos);return this._pos+=2,e},e.exports=r},function(e,t,n){(function(t){function r(e){if(!(this instanceof r))return new r(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var n=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",function(e){e.on("error",n)}),this.on("unpipe",function(e){e.removeListener("error",n)})}else t.isBuffer(e)?this.append(e):Array.isArray(e)&&e.forEach(function(e){t.isBuffer(e)&&this.append(e)}.bind(this));i.call(this)}var i=n(247),o=n(71);o.inherits(r,i),r.prototype._offset=function(e){for(var t,n=0,r=0;re)return[r,e-n];n=t}},r.prototype.append=function(e){var n=t.isBuffer(e)||e instanceof r;return"number"==typeof e&&(e=e.toString()),this._bufs.push(n?e:new t(e)),this.length+=e.length,this},r.prototype._write=function(e,t,n){this.append(e),n&&n()},r.prototype._read=function(e){return this.length?(e=Math.min(e,this.length),this.push(this.slice(0,e)),void this.consume(e)):this.push(null)},r.prototype.end=function(e){i.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},r.prototype.get=function(e){return this.slice(e,e+1)[0]},r.prototype.slice=function(e,t){return this.copy(null,0,e,t)},r.prototype.copy=function(e,n,r,i){if(("number"!=typeof r||0>r)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return e||new t(0);if(0>=i)return e||new t(0);var o,s,a=!!e,u=this._offset(r),c=i-r,l=c,f=a&&n||0,h=u[1];if(0===r&&i==this.length){if(!a)return t.concat(this._bufs);for(s=0;so)){this._bufs[s].copy(e,f,h,h+l);break}this._bufs[s].copy(e,f,h),f+=o,l-=o,h&&(h=0)}return e},r.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},r.prototype.consume=function(e){for(;this._bufs.length;){if(!(e>this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){for(var e=0,t=new r;e255||0>r)throw new Error("Invalid protocol version");if(l+=1,"string"!=typeof a&&!t.isBuffer(a)||!a&&4!=r||!a&&!o){if(4>r)throw new Error("clientId must be supplied before 3.1.1");if(0==o)throw new Error("clientId must be given if cleanSession set to 0")}else l+=a.length+2;if("number"!=typeof s||0>s||s>65535)throw new Error("Invalid keepalive");if(l+=2,l+=1,i){if("object"!=typeof i)throw new Error("Invalid will");if(!i.topic||"string"!=typeof i.topic)throw new Error("Invalid will topic");if(l+=t.byteLength(i.topic)+2,i.payload&&i.payload){if(!(i.payload.length>=0))throw new Error("Invalid will payload");l+="string"==typeof i.payload?t.byteLength(i.payload)+2:i.payload.length+2}else l+=2}if(u){if(!u.length)throw new Error("Invalid username");l+=t.byteLength(u)+2}if(c){if(!c.length)throw new Error("Invalid password");l+=b(c)+2}var f=new t(1+h(l)+l),v=0;f.writeUInt8(w.codes.connect<0&&(l+=y(c,l,a)),t.isBuffer(s)?g(c,l,s):v(c,l,s),c}function a(e){var e=e||{},n=e.cmd||"puback",r=e.messageId,i=e.dup&&"pubrel"===n?w.DUP_MASK:0,o=0;if("pubrel"===n&&(o=1),"number"!=typeof r)throw new Error("Invalid message id");var s=new t(4),a=0;return s[a++]=w.codes[n]<=0&&128>e?1:e>=128&&16384>e?2:e>=16384&&2097152>e?3:e>=2097152&&268435456>e?4:0}function p(e,t,n){var r=0,i=t;do r=n%128|0,n=n/128|0,n>0&&(r=128|r),e.writeUInt8(r,t++,!0);while(n>0);return t-i}function d(e,n,r){var i=t.byteLength(r);return y(e,n,i),v(e,n+2,r),i+2}function v(e,t,n){e.write(n,t)}function g(e,t,n){return n.copy(e,t),n.length}function y(e,t,n){return e.writeUInt8(n>>8,t,!0),e.writeUInt8(255&n,t+1,!0),2}function m(e,t,n){var r=0;return n&&"string"==typeof n?r+=d(e,t+r,n):n?(r+=y(e,t+r,n.length),r+=g(e,t+r,n)):r+=y(e,t+r,0),r}function b(e){return t.isBuffer(e)?e.length:t.byteLength(e)}var w=n(252),_=new t(0);e.exports=r}).call(t,n(3).Buffer)},function(e,t){"use strict";function n(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){Date.now();r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0,r._callback=void 0,r._args=void 0)}}function r(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;tx)return void setTimeout(l,I,e,t,n);try{m.send(e)}catch(r){return n(r)}n()}function f(e){m.close(),e()}function h(){y.setReadable(E),y.setWritable(E),y.emit("connect")}function p(){y.end(),y.destroy()}function d(e){y.destroy(e)}function v(e){var t=e.data;t=new i(t instanceof ArrayBuffer?new Uint8Array(t):t),E.push(t)}function g(){m.close()}var y,m,b="browser"===t.title,w=!!r.WebSocket,_=b?l:c,E=s.obj(_,f);n&&!Array.isArray(n)&&"object"==typeof n&&(o=n,n=null),o||(o={});var x=o.browserBufferSize||524288,I=o.browserBufferTimeout||1e3;return"object"==typeof e?m=e:(m=w&&b?new u(e,n):new u(e,n,o),m.binaryType="arraybuffer"),1===m.readyState?y=E:(y=a.obj(),m.addEventListener("open",h)),y.socket=m,m.addEventListener("close",p),m.addEventListener("error",d),m.addEventListener("message",v),E.on("close",g),y}var s=n(262),a=n(272),u=n(282);e.exports=o}).call(t,n(36),function(){return this}(),n(3).Buffer)},function(e,t,n){(function(t){function r(e){s.call(this,e),this._destroyed=!1}function i(e,t,n){n(null,e)}function o(e){return function(t,n,r){return"function"==typeof t&&(r=n,n=t,t={}),"function"!=typeof n&&(n=i),"function"!=typeof r&&(r=null),e(t,n,r)}}var s=n(263),a=n(71).inherits,u=n(255);a(r,s),r.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var n=this;t.nextTick(function(){e&&n.emit("error",e),n.emit("close")})}},e.exports=o(function(e,t,n){var i=new r(e);return i._transform=t,n&&(i._flush=n),i}),e.exports.ctor=o(function(e,t,n){function i(t){return this instanceof i?(this.options=u(e,t),void r.call(this,this.options)):new i(t)}return a(i,r),i.prototype._transform=t,n&&(i.prototype._flush=n),i}),e.exports.obj=o(function(e,t,n){var i=new r(u({objectMode:!0,highWaterMark:16},e));return i._transform=t,n&&(i._flush=n),i})}).call(t,n(36))},[300,264],[302,265],[303,267,270],function(e,t,n){(function(t){"use strict";function n(e){for(var n=new Array(arguments.length-1),r=0;rf;f++)v=g[f],l=v.indexOf(":"),u[w(v.substring(0,l))]=w(v.substring(l+1));if(r="",b=s+2,u["content-length"])p=parseInt(u["content-length"]),r=(""+n).substring(b,b+p);else for(i=null,c=h=y=b,m=n.length;(m>=y?m>h:h>m)&&(i=n.charAt(c),i!==e.NULL);c=m>=y?++h:--h)r+=i;return new t(o,u,r)},t.unmarshall=function(t){var r,i,o,s;return i=t.split(RegExp(""+e.NULL+e.LF+"*")),s={frames:[],partial:""},s.frames=function(){var e,t,o,s;for(o=i.slice(0,-1),s=[],e=0,t=o.length;t>e;e++)r=o[e],s.push(n(r));return s}(),o=i.slice(-1)[0],o===e.LF||-1!==o.search(RegExp(""+e.NULL+e.LF+"*$"))?s.frames.push(n(o)):s.partial=o,s},t.marshall=function(n,r,i){var o;return o=new t(n,r,i),o.toString()+e.NULL},t}(),n=function(){function t(e){this.ws=e,this.ws.binaryType="arraybuffer",this.counter=0,this.connected=!1,this.heartbeat={outgoing:1e4,incoming:1e4},this.maxWebSocketFrameSize=16384,this.subscriptions={},this.partialData=""}var n;return t.prototype.debug=function(e){var t;return"undefined"!=typeof window&&null!==window&&null!=(t=window.console)?t.log(e):void 0},n=function(){return Date.now?Date.now():(new Date).valueOf},t.prototype._transmit=function(e,t,n){var i;for(i=r.marshall(e,t,n),"function"==typeof this.debug&&this.debug(">>> "+i);;){if(!(i.length>this.maxWebSocketFrameSize))return this.ws.send(i);this.ws.send(i.substring(0,this.maxWebSocketFrameSize)),i=i.substring(this.maxWebSocketFrameSize),"function"==typeof this.debug&&this.debug("remaining = "+i.length)}},t.prototype._setupHeartbeat=function(t){var r,o,s,a,u,c;if((r=t.version)===i.VERSIONS.V1_1||r===i.VERSIONS.V1_2)return o=function(){var e,n,r,i;for(r=t["heart-beat"].split(","),i=[],e=0,n=r.length;n>e;e++)c=r[e],i.push(parseInt(c));return i}(),a=o[0],s=o[1],0!==this.heartbeat.outgoing&&0!==s&&(u=Math.max(this.heartbeat.outgoing,s),"function"==typeof this.debug&&this.debug("send PING every "+u+"ms"),this.pinger=i.setInterval(u,function(t){return function(){return t.ws.send(e.LF),"function"==typeof t.debug?t.debug(">>> PING"):void 0}}(this))),0!==this.heartbeat.incoming&&0!==a?(u=Math.max(this.heartbeat.incoming,a),"function"==typeof this.debug&&this.debug("check PONG every "+u+"ms"),this.ponger=i.setInterval(u,function(e){return function(){var t;return t=n()-e.serverActivity,t>2*u?("function"==typeof e.debug&&e.debug("did not receive server activity for the last "+t+"ms"),e.ws.close()):void 0}}(this))):void 0},t.prototype._parseConnect=function(){var e,t,n,r;switch(e=1<=arguments.length?s.call(arguments,0):[],r={},e.length){case 2:r=e[0],t=e[1];break;case 3:e[1]instanceof Function?(r=e[0],t=e[1],n=e[2]):(r.login=e[0],r.passcode=e[1],t=e[2]);break;case 4:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3];break;default:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3],r.host=e[4]}return[r,t,n]},t.prototype.connect=function(){var t,o,a,u;return t=1<=arguments.length?s.call(arguments,0):[],u=this._parseConnect.apply(this,t),a=u[0],this.connectCallback=u[1],o=u[2],"function"==typeof this.debug&&this.debug("Opening Web Socket..."),this.ws.onmessage=function(t){return function(i){var s,a,u,c,l,f,h,p,d,v,g,y,m;if(c="undefined"!=typeof ArrayBuffer&&i.data instanceof ArrayBuffer?(s=new Uint8Array(i.data),"function"==typeof t.debug?t.debug("--- got data length: "+s.length):void 0,function(){var e,t,n;for(n=[],e=0,t=s.length;t>e;e++)a=s[e],n.push(String.fromCharCode(a));return n}().join("")):i.data,t.serverActivity=n(),c===e.LF)return void("function"==typeof t.debug&&t.debug("<<< PONG"));for("function"==typeof t.debug&&t.debug("<<< "+c),m=r.unmarshall(t.partialData+c),t.partialData=m.partial,v=m.frames,g=[],f=0,h=v.length;h>f;f++)switch(l=v[f],l.command){case"CONNECTED":"function"==typeof t.debug&&t.debug("connected to server "+l.headers.server),t.connected=!0,t._setupHeartbeat(l.headers),g.push("function"==typeof t.connectCallback?t.connectCallback(l):void 0);break;case"MESSAGE":y=l.headers.subscription,d=t.subscriptions[y]||t.onreceive,d?(u=t,p=l.headers["message-id"],l.ack=function(e){return null==e&&(e={}),u.ack(p,y,e)},l.nack=function(e){return null==e&&(e={}),u.nack(p,y,e)},g.push(d(l))):g.push("function"==typeof t.debug?t.debug("Unhandled received MESSAGE: "+l):void 0);break;case"RECEIPT":g.push("function"==typeof t.onreceipt?t.onreceipt(l):void 0);break;case"ERROR":g.push("function"==typeof o?o(l):void 0);break;default:g.push("function"==typeof t.debug?t.debug("Unhandled frame: "+l):void 0)}return g}}(this),this.ws.onclose=function(e){return function(){var t;return t="Whoops! Lost connection to "+e.ws.url,"function"==typeof e.debug&&e.debug(t),e._cleanUp(),"function"==typeof o?o(t):void 0}}(this),this.ws.onopen=function(e){return function(){return"function"==typeof e.debug&&e.debug("Web Socket Opened..."),a["accept-version"]=i.VERSIONS.supportedVersions(),a["heart-beat"]=[e.heartbeat.outgoing,e.heartbeat.incoming].join(","),e._transmit("CONNECT",a)}}(this)},t.prototype.disconnect=function(e,t){return null==t&&(t={}),this._transmit("DISCONNECT",t),this.ws.onclose=null,this.ws.close(),this._cleanUp(),"function"==typeof e?e():void 0},t.prototype._cleanUp=function(){return this.connected=!1,this.pinger&&i.clearInterval(this.pinger),this.ponger?i.clearInterval(this.ponger):void 0},t.prototype.send=function(e,t,n){return null==t&&(t={}),null==n&&(n=""),t.destination=e,this._transmit("SEND",t,n)},t.prototype.subscribe=function(e,t,n){var r;return null==n&&(n={}),n.id||(n.id="sub-"+this.counter++),n.destination=e,this.subscriptions[n.id]=t,this._transmit("SUBSCRIBE",n),r=this,{id:n.id,unsubscribe:function(){return r.unsubscribe(n.id)}}},t.prototype.unsubscribe=function(e){return delete this.subscriptions[e],this._transmit("UNSUBSCRIBE",{id:e})},t.prototype.begin=function(e){var t,n;return n=e||"tx-"+this.counter++,this._transmit("BEGIN",{transaction:n}),t=this,{id:n,commit:function(){return t.commit(n)},abort:function(){return t.abort(n)}}},t.prototype.commit=function(e){return this._transmit("COMMIT",{transaction:e})},t.prototype.abort=function(e){return this._transmit("ABORT",{transaction:e})},t.prototype.ack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("ACK",n)},t.prototype.nack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("NACK",n)},t}(),i={VERSIONS:{V1_0:"1.0",V1_1:"1.1",V1_2:"1.2",supportedVersions:function(){return"1.1,1.0"}},client:function(e,t){var r,o;return null==t&&(t=["v10.stomp","v11.stomp"]),r=i.WebSocketClass||WebSocket,o=new r(e,t),new n(o)},over:function(e){return new n(e)},Frame:r},"undefined"!=typeof t&&null!==t&&(t.Stomp=i),"undefined"!=typeof window&&null!==window?(i.setInterval=function(e,t){return window.setInterval(t,e)},i.clearInterval=function(e){return window.clearInterval(e)},window.Stomp=i):t||(self.Stomp=i)}).call(this)},function(e,t,n){(function(){var e,r,i,o,s,a,u;e=n(285),r=n(108),s=n(108),e.Stomp.setInterval=function(e,t){return setInterval(t,e)},e.Stomp.clearInterval=function(e){return clearInterval(e)},a=function(e,t,n){var i,o;return i=null,o={url:"tcp://"+e+":"+t,send:function(e){return i.write(e)},close:function(){return i.end()}},i=n?s.connect(t,e,n,function(e){return i.authorized?o.onopen():(console.error("SSL is not authorized: "+i.authorizationError),"function"==typeof o.onclose?o.onclose(e):void 0)}):r.connect(t,e,function(e){return o.onopen()}),i.on("error",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),i.on("close",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),i.on("data",function(e){var t;return t={data:e.toString()},o.onmessage(t)}),o},u=function(e){var t,r,i,o;return t=n(287).client,r=null,o={url:e,send:function(e){return r.sendUTF(e)},close:function(){return r.close()}},i=new t,i.on("connect",function(e){return r=e,o.onopen(),r.on("error",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),r.on("close",function(){return"function"==typeof o.onclose?o.onclose():void 0}),r.on("message",function(e){var t;return"utf8"===e.type?(t={data:e.utf8Data},o.onmessage(t)):void 0})}),i.connect(e),o},i=function(t,n,r){var i;return i=a(t,n,r),e.Stomp.over(i)},o=function(t){var n;return n=u(t),e.Stomp.over(n)},t.overTCP=i,t.overWS=o}).call(this)},function(e,t,n){function r(e,t){var n;return n=t?new o(e,t):new o(e)}var i=function(){return this}(),o=i.WebSocket||i.MozWebSocket,s=n(288);e.exports={w3cwebsocket:o?r:null,version:s}},function(e,t,n){e.exports=n(289).version},function(e,t){e.exports={_args:[["websocket@latest","/Users/gfoiani/Dev/work/spacebunny/sdk/node/node_modules/stompjs"]],_from:"websocket@latest",_id:"websocket@1.0.22",_inCache:!0,_installable:!0,_location:"/websocket",_nodeVersion:"3.3.1",_npmUser:{email:"brian@worlize.com",name:"theturtle32"},_npmVersion:"2.14.3",_phantomChildren:{},_requested:{name:"websocket",raw:"websocket@latest",rawSpec:"latest",scope:null,spec:"latest",type:"tag"},_requiredBy:["/stompjs"],_resolved:"https://registry.npmjs.org/websocket/-/websocket-1.0.22.tgz",_shasum:"8c33e3449f879aaf518297c9744cebf812b9e3d8",_shrinkwrap:null,_spec:"websocket@latest",_where:"/Users/gfoiani/Dev/work/spacebunny/sdk/node/node_modules/stompjs",author:{email:"brian@worlize.com",name:"Brian McKelvey",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"~2.2.0",nan:"~2.0.5","typedarray-to-buffer":"~3.0.3",yaeti:"~0.0.4"},description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^0.0.1",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^1.11.2","jshint-stylish":"^1.0.2",tape:"^4.0.1"},directories:{lib:"./lib"},dist:{shasum:"8c33e3449f879aaf518297c9744cebf812b9e3d8",tarball:"http://registry.npmjs.org/websocket/-/websocket-1.0.22.tgz"},engines:{node:">=0.8.0"},gitHead:"19108bbfd7d94a5cd02dbff3495eafee9e901ca4",homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["RFC-6455","client","comet","networking","push","realtime","server","socket","websocket","websockets"],license:"Apache-2.0",main:"index",maintainers:[{name:"theturtle32",email:"brian@worlize.com"}],name:"websocket",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.22"}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(u){i=!0,o=u}finally{try{!r&&a["return"]&&a["return"]()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,t){for(var n=0;n0&&(a=o[0].callback||s),a(t,r)}),r(!0))})})["catch"](function(e){i(e)})})}},{key:"_streamChannelTopicFor",value:function(e,t){return e+"/"+t}},{key:"_streamTopicFor",value:function(e){return this.liveStreamByName(e)+"/"+this._liveStreamSuffix}}]),t}(p["default"]);delete d.onReceive,delete d.publish,delete d._topicFor,t["default"]=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;nn;n++)t(e[n],n)}e.exports=o;var u=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},c=n(91);c.inherits=n(73);var l=n(r),f=n(i);c.inherits(o,l),a(u(f.prototype),function(e){o.prototype[e]||(o.prototype[e]=f.prototype[e])})}).call(t,n(36))},function(e,t,n,r){function i(e){return this instanceof i?void o.call(this,e):new i(e)}e.exports=i;var o=n(r),s=n(91);s.inherits=n(73),s.inherits(i,o),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){(function(t){function i(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function o(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function s(e){var t=n(r);return this instanceof s||this instanceof t?(this._writableState=new o(e,this),this.writable=!0,void x.call(this)):new s(e)}function a(e,n,r){var i=new Error("write after end");e.emit("error",i),t.nextTick(function(){r(i)})}function u(e,n,r,i){var o=!0;if(!_.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!n.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),t.nextTick(function(){i(s)}),o=!1}return o}function c(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new _(t,n)),t}function l(e,t,n,r,o){n=c(t,n,r),_.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var a;!t.decoder||i||r||(n=t.decoder.write(n),a=!t.objectMode&&0===n.length),i||(t.reading=!1),a||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&v(e))),y(e,t)}else i||(t.reading=!1);return l(t)}function l(e){return!e.ended&&(e.needReadable||e.length=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function h(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=f(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function p(e,t){var n=null;return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function d(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,v(e)}}function v(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(M("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U(g,e):g(e))}function g(e){M("emit readable"),e.emit("readable"),x(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U(m,e,t))}function m(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)n=o?r.join(""):1===r.length?r[0]:j.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,U(C,t,e))}function C(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function S(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function T(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=u;var U=n(266),B=n(r),j=n(88).Buffer;u.ReadableState=a;var O,R=(n(84),function(e,t){return e.listeners(t).length});!function(){try{O=n(83)}catch(e){}finally{O||(O=n(84).EventEmitter)}}();var j=n(88).Buffer,A=n(91);A.inherits=n(73);var L=n(i),M=void 0;M=L&&L.debuglog?L.debuglog("stream"):function(){};var P;A.inherits(u,O);var F,F;u.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new j(e,t),t="")),c(this,n,e,t,!1)},u.prototype.unshift=function(e){var t=this._readableState;return c(this,t,e,"",!0)},u.prototype.isPaused=function(){return this._readableState.flowing===!1},u.prototype.setEncoding=function(e){return P||(P=n(95).StringDecoder),this._readableState.decoder=new P(e),this._readableState.encoding=e,this};var N=8388608;u.prototype.read=function(e){M("read",e);var t=this._readableState,n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return M("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?k(this):v(this),null;if(e=h(e,t),0===e&&t.ended)return 0===t.length&&k(this),null;var r=t.needReadable;M("need readable",r),(0===t.length||t.length-e0?I(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&k(this),null!==i&&this.emit("data",i),i},u.prototype._read=function(e){this.emit("error",new Error("not implemented"))},u.prototype.pipe=function(e,n){function r(e){M("onunpipe"),e===f&&o()}function i(){M("onend"),e.end()}function o(){M("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",v),e.removeListener("error",a),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),f.removeListener("data",s),g=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||v()}function s(t){M("ondata");var n=e.write(t);!1===n&&(1!==h.pipesCount||h.pipes[0]!==e||1!==f.listenerCount("data")||g||(M("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++),f.pause())}function a(t){M("onerror",t),l(),e.removeListener("error",a),0===R(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),l()}function c(){M("onfinish"),e.removeListener("close",u),l()}function l(){M("unpipe"),f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,M("pipe count=%d opts=%j",h.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,d=p?i:o;h.endEmitted?U(d):f.once("end",d),e.on("unpipe",r);var v=b(f);e.on("drain",v);var g=!1;return f.on("data",s),e._events&&e._events.error?B(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",f),h.flowing||(M("pipe resume"),f.resume()),e},u.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,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var o=T(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},u.prototype.on=function(e,t){var n=O.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&!this._readableState.endEmitted){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&v(this,r):U(w,this))}return n},u.prototype.addListener=u.prototype.on,u.prototype.resume=function(){var e=this._readableState;return e.flowing||(M("resume"),e.flowing=!0,_(this,e)),this},u.prototype.pause=function(){return M("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(M("pause"),this._readableState.flowing=!1,this.emit("pause")),this},u.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(M("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(M("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return S(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){M("wrapped _read",t),n&&(n=!1,e.resume())},r},u._fromList=I}).call(t,n(36))},function(e,t,n,r,i){(function(t,o){"use strict";function s(){}function a(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function u(e,t){O=O||n(r),e=e||{},this.objectMode=!!e.objectMode,t instanceof O&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new k(this),this.corkedRequestsFree.next=new k(this)}function c(e){return O=O||n(i),this instanceof c||this instanceof O?(this._writableState=new u(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),void B.call(this)):new c(e)}function l(e,t){var n=new Error("write after end");e.emit("error",n),C(t,n)}function f(e,t,n,r){var i=!0;if(!T.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),C(r,o),i=!1}return i}function h(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new T(t,n)),t}function p(e,t,n,r,i){n=h(t,n,r),T.isBuffer(n)&&(r="buffer");var o=t.objectMode?1:n.length;t.length+=o;var s=t.length-1?o:C,T=n(88).Buffer;c.WritableState=u;var U=n(91);U.inherits=n(73);var B,j={deprecate:n(271)};!function(){try{B=n(83)}catch(e){}finally{B||(B=n(84).EventEmitter)}}();var T=n(88).Buffer;U.inherits(c,B);var O;u.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(u.prototype,"buffer",{get:j.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var O;c.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},c.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),T.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=s),r.ended?l(this,n):f(this,r,e,n)&&(r.pendingcb++,i=p(this,r,e,t,n)),i},c.prototype.cork=function(){var e=this._writableState;e.corked++},c.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||w(this,e))},c.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);this._writableState.defaultEncoding=e},c.prototype._write=function(e,t,n){n(new Error("not implemented"))},c.prototype._writev=null,c.prototype.end=function(e,t,n){var r=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),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||I(this,r,n)}}).call(t,n(36),n(37).setImmediate)}]); \ No newline at end of file +!function(a){"use strict";s=function(e){var t=n(r),s=n(i),a=n(o).asap;return t({scheduler:new s(a)})}.call(t,n,t,e),!(void 0!==s&&(e.exports=s))}(n(42))},function(e,t,n,r,i){(function(t){function o(e){return this instanceof o?(l.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",s)):new o(e)}function s(){this.allowHalfOpen||this._writableState.ended||t.nextTick(this.end.bind(this))}function a(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}e.exports=o;var u=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},c=n(91);c.inherits=n(73);var l=n(r),f=n(i);c.inherits(o,l),a(u(f.prototype),function(e){o.prototype[e]||(o.prototype[e]=f.prototype[e])})}).call(t,n(36))},function(e,t,n,r){function i(e){return this instanceof i?void o.call(this,e):new i(e)}e.exports=i;var o=n(r),s=n(91);s.inherits=n(73),s.inherits(i,o),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){(function(t){function i(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function o(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function s(e){var t=n(r);return this instanceof s||this instanceof t?(this._writableState=new o(e,this),this.writable=!0,void x.call(this)):new s(e)}function a(e,n,r){var i=new Error("write after end");e.emit("error",i),t.nextTick(function(){r(i)})}function u(e,n,r,i){var o=!0;if(!_.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!n.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),t.nextTick(function(){i(s)}),o=!1}return o}function c(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new _(t,n)),t}function l(e,t,n,r,o){n=c(t,n,r),_.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var a;!t.decoder||i||r||(n=t.decoder.write(n),a=!t.objectMode&&0===n.length),i||(t.reading=!1),a||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&v(e))),y(e,t)}else i||(t.reading=!1);return l(t)}function l(e){return!e.ended&&(e.needReadable||e.length=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function h(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=f(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function p(e,t){var n=null;return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function d(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,v(e)}}function v(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(M("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U(g,e):g(e))}function g(e){M("emit readable"),e.emit("readable"),x(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U(m,e,t))}function m(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)n=o?r.join(""):1===r.length?r[0]:j.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,U(C,t,e))}function C(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function S(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function T(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=u;var U=n(266),B=n(r),j=n(88).Buffer;u.ReadableState=a;var O,A=(n(84),function(e,t){return e.listeners(t).length});!function(){try{O=n(83)}catch(e){}finally{O||(O=n(84).EventEmitter)}}();var j=n(88).Buffer,R=n(91);R.inherits=n(73);var L=n(i),M=void 0;M=L&&L.debuglog?L.debuglog("stream"):function(){};var F;R.inherits(u,O);var P,P;u.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new j(e,t),t="")),c(this,n,e,t,!1)},u.prototype.unshift=function(e){var t=this._readableState;return c(this,t,e,"",!0)},u.prototype.isPaused=function(){return this._readableState.flowing===!1},u.prototype.setEncoding=function(e){return F||(F=n(95).StringDecoder),this._readableState.decoder=new F(e),this._readableState.encoding=e,this};var N=8388608;u.prototype.read=function(e){M("read",e);var t=this._readableState,n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return M("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?k(this):v(this),null;if(e=h(e,t),0===e&&t.ended)return 0===t.length&&k(this),null;var r=t.needReadable;M("need readable",r),(0===t.length||t.length-e0?I(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&k(this),null!==i&&this.emit("data",i),i},u.prototype._read=function(e){this.emit("error",new Error("not implemented"))},u.prototype.pipe=function(e,n){function r(e){M("onunpipe"),e===f&&o()}function i(){M("onend"),e.end()}function o(){M("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",v),e.removeListener("error",a),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),f.removeListener("data",s),g=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||v()}function s(t){M("ondata");var n=e.write(t);!1===n&&(1!==h.pipesCount||h.pipes[0]!==e||1!==f.listenerCount("data")||g||(M("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++),f.pause())}function a(t){M("onerror",t),l(),e.removeListener("error",a),0===A(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),l()}function c(){M("onfinish"),e.removeListener("close",u),l()}function l(){M("unpipe"),f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,M("pipe count=%d opts=%j",h.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,d=p?i:o;h.endEmitted?U(d):f.once("end",d),e.on("unpipe",r);var v=b(f);e.on("drain",v);var g=!1;return f.on("data",s),e._events&&e._events.error?B(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",f),h.flowing||(M("pipe resume"),f.resume()),e},u.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,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var o=T(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},u.prototype.on=function(e,t){var n=O.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&!this._readableState.endEmitted){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&v(this,r):U(w,this))}return n},u.prototype.addListener=u.prototype.on,u.prototype.resume=function(){var e=this._readableState;return e.flowing||(M("resume"),e.flowing=!0,_(this,e)),this},u.prototype.pause=function(){return M("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(M("pause"),this._readableState.flowing=!1,this.emit("pause")),this},u.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(M("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(M("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return S(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){M("wrapped _read",t),n&&(n=!1,e.resume())},r},u._fromList=I}).call(t,n(36))},function(e,t,n,r,i){(function(t,o){"use strict";function s(){}function a(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function u(e,t){O=O||n(r),e=e||{},this.objectMode=!!e.objectMode,t instanceof O&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new k(this),this.corkedRequestsFree.next=new k(this)}function c(e){return O=O||n(i),this instanceof c||this instanceof O?(this._writableState=new u(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),void B.call(this)):new c(e)}function l(e,t){var n=new Error("write after end");e.emit("error",n),C(t,n)}function f(e,t,n,r){var i=!0;if(!T.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),C(r,o),i=!1}return i}function h(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new T(t,n)),t}function p(e,t,n,r,i){n=h(t,n,r),T.isBuffer(n)&&(r="buffer");var o=t.objectMode?1:n.length;t.length+=o;var s=t.length-1?o:C,T=n(88).Buffer;c.WritableState=u;var U=n(91);U.inherits=n(73);var B,j={deprecate:n(271)};!function(){try{B=n(83)}catch(e){}finally{B||(B=n(84).EventEmitter)}}();var T=n(88).Buffer;U.inherits(c,B);var O;u.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(u.prototype,"buffer",{get:j.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var O;c.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},c.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),T.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=s),r.ended?l(this,n):f(this,r,e,n)&&(r.pendingcb++,i=p(this,r,e,t,n)),i},c.prototype.cork=function(){var e=this._writableState;e.corked++},c.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||w(this,e))},c.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);this._writableState.defaultEncoding=e},c.prototype._write=function(e,t,n){n(new Error("not implemented"))},c.prototype._writev=null,c.prototype.end=function(e,t,n){var r=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),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||I(this,r,n)}}).call(t,n(36),n(37).setImmediate)}]); \ No newline at end of file diff --git a/docs/messages/amqpMessage.md b/docs/messages/amqpMessage.md new file mode 100644 index 0000000..932ddbb --- /dev/null +++ b/docs/messages/amqpMessage.md @@ -0,0 +1,5 @@ + + +## Message +A wrapper for the message object + diff --git a/docs/messages/stompMessage.md b/docs/messages/stompMessage.md new file mode 100644 index 0000000..932ddbb --- /dev/null +++ b/docs/messages/stompMessage.md @@ -0,0 +1,5 @@ + + +## Message +A wrapper for the message object + diff --git a/docs/spacebunny.md b/docs/spacebunny.md index e48154b..b529385 100644 --- a/docs/spacebunny.md +++ b/docs/spacebunny.md @@ -7,10 +7,11 @@ A module that exports the base SpaceBunny client * [SpaceBunny](#module_SpaceBunny) * [~SpaceBunny](#module_SpaceBunny..SpaceBunny) * [new SpaceBunny(opts)](#new_module_SpaceBunny..SpaceBunny_new) - * [.getConnectionParams()](#module_SpaceBunny..SpaceBunny+getConnectionParams) ⇒ + * [.getEndpointConfigs()](#module_SpaceBunny..SpaceBunny+getEndpointConfigs) ⇒ * [.channels()](#module_SpaceBunny..SpaceBunny+channels) ⇒ * [.deviceId()](#module_SpaceBunny..SpaceBunny+deviceId) ⇒ * [.liveStreamByName(streamName)](#module_SpaceBunny..SpaceBunny+liveStreamByName) ⇒ + * [.liveStreamExists(streamName)](#module_SpaceBunny..SpaceBunny+liveStreamExists) ⇒ @@ -19,10 +20,11 @@ A module that exports the base SpaceBunny client * [~SpaceBunny](#module_SpaceBunny..SpaceBunny) * [new SpaceBunny(opts)](#new_module_SpaceBunny..SpaceBunny_new) - * [.getConnectionParams()](#module_SpaceBunny..SpaceBunny+getConnectionParams) ⇒ + * [.getEndpointConfigs()](#module_SpaceBunny..SpaceBunny+getEndpointConfigs) ⇒ * [.channels()](#module_SpaceBunny..SpaceBunny+channels) ⇒ * [.deviceId()](#module_SpaceBunny..SpaceBunny+deviceId) ⇒ * [.liveStreamByName(streamName)](#module_SpaceBunny..SpaceBunny+liveStreamByName) ⇒ + * [.liveStreamExists(streamName)](#module_SpaceBunny..SpaceBunny+liveStreamExists) ⇒ @@ -32,9 +34,9 @@ A module that exports the base SpaceBunny client | --- | --- | --- | | opts | Object | constructor options may contain api-key or connection options | - + -#### spaceBunny.getConnectionParams() ⇒ +#### spaceBunny.getEndpointConfigs() ⇒ Check if api-key or connection parameters have already been passed If at least api-key is passed ask the endpoint for the configurations else if also connection parameters are not passed raise an exception @@ -63,3 +65,15 @@ Return a Stream ID from a stream name given in input | --- | --- | --- | | streamName | String | stream name | + + +#### spaceBunny.liveStreamExists(streamName) ⇒ +Check if a stream exists + +**Kind**: instance method of [SpaceBunny](#module_SpaceBunny..SpaceBunny) +**Returns**: true if stream exists, false otherwise + +| Param | Type | Description | +| --- | --- | --- | +| streamName | String | stream name | + diff --git a/lib/message.js b/lib/messages/amqpMessage.js similarity index 87% rename from lib/message.js rename to lib/messages/amqpMessage.js index b435fc9..13625ef 100644 --- a/lib/message.js +++ b/lib/messages/amqpMessage.js @@ -15,9 +15,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * @module Message */ -var CONFIG = require('../config/constants').CONFIG; +var CONFIG = require('../../config/constants').CONFIG; -var Message = function () { +var AmqpMessage = function () { /** * @constructor @@ -26,10 +26,10 @@ var Message = function () { * @param {Object} opts - subscription options */ - function Message(message, receiverId) { + function AmqpMessage(message, receiverId) { var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - _classCallCheck(this, Message); + _classCallCheck(this, AmqpMessage); this.content = message.content; this.fields = message.fields; @@ -56,7 +56,7 @@ var Message = function () { */ - _createClass(Message, [{ + _createClass(AmqpMessage, [{ key: 'blackListed', value: function blackListed() { if (this._discardMine && this._receiverId === this.senderId && !this.fromApi()) return true; @@ -66,7 +66,7 @@ var Message = function () { /** * Check if a message comes from API - * Check if the source exchange is equals to inputExchange + * Check if it contains 'x-from-sb-api' header * * @return Boolean - true if it comes from API, false otherwise */ @@ -74,12 +74,12 @@ var Message = function () { }, { key: 'fromApi', value: function fromApi() { - return this.fields.exchange === CONFIG.inputExchange; + return this.properties.headers && this.properties.headers[CONFIG.fromApiHeader]; } }]); - return Message; + return AmqpMessage; }(); -exports.default = Message; -//# sourceMappingURL=message.js.map +exports.default = AmqpMessage; +//# sourceMappingURL=amqpMessage.js.map diff --git a/lib/messages/amqpMessage.js.map b/lib/messages/amqpMessage.js.map new file mode 100644 index 0000000..191fa46 --- /dev/null +++ b/lib/messages/amqpMessage.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["messages/amqpMessage.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,IAAM,SAAS,QAAQ,wBAAR,EAAkC,MAAlC;;IAET;;;;;;;;;AAQJ,WARI,WAQJ,CAAY,OAAZ,EAAqB,UAArB,EAA4C;QAAX,6DAAO,kBAAI;;0BARxC,aAQwC;;AAC1C,SAAK,OAAL,GAAe,QAAQ,OAAR,CAD2B;AAE1C,SAAK,MAAL,GAAc,QAAQ,MAAR,CAF4B;AAG1C,SAAK,UAAL,GAAkB,QAAQ,UAAR,CAHwB;AAI1C,QAAI;kCACkC,KAAK,MAAL,CAAY,UAAZ,CAAuB,KAAvB,CAA6B,GAA7B,EADlC;;;;AACD,WAAK,QAAL,6BADC;AACc,WAAK,WAAL,6BADd;KAAJ,CAEE,OAAO,EAAP,EAAW;AACX,cAAQ,KAAR,CAAc,0BAAd;AADW,KAAX;AAGF,SAAK,WAAL,GAAmB,UAAnB,CAT0C;AAU1C,SAAK,YAAL,GAAoB,KAAK,WAAL,IAAoB,KAApB,CAVsB;AAW1C,SAAK,eAAL,GAAuB,KAAK,cAAL,IAAuB,KAAvB,CAXmB;GAA5C;;;;;;;;;eARI;;kCA2BU;AACZ,UAAI,KAAK,YAAL,IAAqB,KAAK,WAAL,KAAqB,KAAK,QAAL,IAAiB,CAAC,KAAK,OAAL,EAAD,EAAiB,OAAO,IAAP,CAAhF;AACA,UAAI,KAAK,eAAL,IAAwB,KAAK,OAAL,EAAxB,EAAwC,OAAO,IAAP,CAA5C;AACA,aAAO,KAAP,CAHY;;;;;;;;;;;;8BAYJ;AACR,aAAQ,KAAK,UAAL,CAAgB,OAAhB,IAA2B,KAAK,UAAL,CAAgB,OAAhB,CAAwB,OAAO,aAAP,CAAnD,CADA;;;;SAvCN;;;kBA4CS","file":"messages/amqpMessage.js","sourcesContent":["/**\n * A wrapper for the message object\n * @module Message\n */\n\nconst CONFIG = require('../../config/constants').CONFIG;\n\nclass AmqpMessage {\n\n /**\n * @constructor\n * @param {Object} message - the message received from the channel\n * @param {String} receiverId - the receiver id\n * @param {Object} opts - subscription options\n */\n constructor(message, receiverId, opts = {}) {\n this.content = message.content;\n this.fields = message.fields;\n this.properties = message.properties;\n try {\n [this.senderId, this.channelName] = this.fields.routingKey.split('.');\n } catch (ex) {\n console.error('Wrong routing key format'); // eslint-disable-line no-console\n }\n this._receiverId = receiverId;\n this._discardMine = opts.discardMine || false;\n this._discardFromApi = opts.discardFromApi || false;\n }\n\n /**\n * Check if a message should be accepted of rejected\n *\n * @return Boolean - true if should be not considered, false otherwise\n */\n blackListed() {\n if (this._discardMine && this._receiverId === this.senderId && !this.fromApi()) return true;\n if (this._discardFromApi && this.fromApi()) return true;\n return false;\n }\n\n /**\n * Check if a message comes from API\n * Check if it contains 'x-from-sb-api' header\n *\n * @return Boolean - true if it comes from API, false otherwise\n */\n fromApi() {\n return (this.properties.headers && this.properties.headers[CONFIG.fromApiHeader]);\n }\n}\n\nexport default AmqpMessage;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file diff --git a/lib/messages/stompMessage.js b/lib/messages/stompMessage.js new file mode 100644 index 0000000..4b31929 --- /dev/null +++ b/lib/messages/stompMessage.js @@ -0,0 +1,86 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * A wrapper for the message object + * @module Message + */ + +var CONFIG = require('../../config/constants').CONFIG; + +var StompMessage = function () { + + /** + * @constructor + * @param {Object} message - the message received from the channel + * @param {String} receiverId - the receiver id + * @param {Object} opts - subscription options + */ + + function StompMessage(message, receiverId) { + var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + + _classCallCheck(this, StompMessage); + + this.body = message.body; + this.headers = message.headers; + try { + var destination = this.headers.destination.split('/'); + + var _destination$split = destination[destination.length - 1].split('.'); + + var _destination$split2 = _slicedToArray(_destination$split, 2); + + this.senderId = _destination$split2[0]; + this.channelName = _destination$split2[1]; + } catch (ex) { + console.error('Wrong routing key format'); // eslint-disable-line no-console + } + this._receiverId = receiverId; + this._discardMine = opts.discardMine || false; + this._discardFromApi = opts.discardFromApi || false; + } + + /** + * Check if a message should be accepted of rejected + * + * @return Boolean - true if should be not considered, false otherwise + */ + + + _createClass(StompMessage, [{ + key: 'blackListed', + value: function blackListed() { + if (this._discardMine && this._receiverId === this.senderId && !this.fromApi()) return true; + if (this._discardFromApi && this.fromApi()) return true; + return false; + } + + /** + * Check if a message comes from API + * Check if it contains 'x-from-sb-api' header + * + * @return Boolean - true if it comes from API, false otherwise + */ + + }, { + key: 'fromApi', + value: function fromApi() { + return this.headers && this.headers[CONFIG.fromApiHeader]; + } + }]); + + return StompMessage; +}(); + +exports.default = StompMessage; +//# sourceMappingURL=stompMessage.js.map diff --git a/lib/messages/stompMessage.js.map b/lib/messages/stompMessage.js.map new file mode 100644 index 0000000..4503787 --- /dev/null +++ b/lib/messages/stompMessage.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["messages/stompMessage.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,IAAM,SAAS,QAAQ,wBAAR,EAAkC,MAAlC;;IAET;;;;;;;;;AAQJ,WARI,YAQJ,CAAY,OAAZ,EAAqB,UAArB,EAA4C;QAAX,6DAAO,kBAAI;;0BARxC,cAQwC;;AAC1C,SAAK,IAAL,GAAY,QAAQ,IAAR,CAD8B;AAE1C,SAAK,OAAL,GAAe,QAAQ,OAAR,CAF2B;AAG1C,QAAI;AACF,UAAM,cAAc,KAAK,OAAL,CAAa,WAAb,CAAyB,KAAzB,CAA+B,GAA/B,CAAd,CADJ;;+BAEkC,YAAY,YAAY,MAAZ,GAAqB,CAArB,CAAZ,CAAoC,KAApC,CAA0C,GAA1C,EAFlC;;;;AAED,WAAK,QAAL,0BAFC;AAEc,WAAK,WAAL,0BAFd;KAAJ,CAGE,OAAO,EAAP,EAAW;AACX,cAAQ,KAAR,CAAc,0BAAd;AADW,KAAX;AAGF,SAAK,WAAL,GAAmB,UAAnB,CAT0C;AAU1C,SAAK,YAAL,GAAoB,KAAK,WAAL,IAAoB,KAApB,CAVsB;AAW1C,SAAK,eAAL,GAAuB,KAAK,cAAL,IAAuB,KAAvB,CAXmB;GAA5C;;;;;;;;;eARI;;kCA2BU;AACZ,UAAI,KAAK,YAAL,IAAqB,KAAK,WAAL,KAAqB,KAAK,QAAL,IAAiB,CAAC,KAAK,OAAL,EAAD,EAAiB,OAAO,IAAP,CAAhF;AACA,UAAI,KAAK,eAAL,IAAwB,KAAK,OAAL,EAAxB,EAAwC,OAAO,IAAP,CAA5C;AACA,aAAO,KAAP,CAHY;;;;;;;;;;;;8BAYJ;AACR,aAAQ,KAAK,OAAL,IAAgB,KAAK,OAAL,CAAa,OAAO,aAAP,CAA7B,CADA;;;;SAvCN;;;kBA4CS","file":"messages/stompMessage.js","sourcesContent":["/**\n * A wrapper for the message object\n * @module Message\n */\n\nconst CONFIG = require('../../config/constants').CONFIG;\n\nclass StompMessage {\n\n /**\n * @constructor\n * @param {Object} message - the message received from the channel\n * @param {String} receiverId - the receiver id\n * @param {Object} opts - subscription options\n */\n constructor(message, receiverId, opts = {}) {\n this.body = message.body;\n this.headers = message.headers;\n try {\n const destination = this.headers.destination.split('/');\n [this.senderId, this.channelName] = destination[destination.length - 1].split('.');\n } catch (ex) {\n console.error('Wrong routing key format'); // eslint-disable-line no-console\n }\n this._receiverId = receiverId;\n this._discardMine = opts.discardMine || false;\n this._discardFromApi = opts.discardFromApi || false;\n }\n\n /**\n * Check if a message should be accepted of rejected\n *\n * @return Boolean - true if should be not considered, false otherwise\n */\n blackListed() {\n if (this._discardMine && this._receiverId === this.senderId && !this.fromApi()) return true;\n if (this._discardFromApi && this.fromApi()) return true;\n return false;\n }\n\n /**\n * Check if a message comes from API\n * Check if it contains 'x-from-sb-api' header\n *\n * @return Boolean - true if it comes from API, false otherwise\n */\n fromApi() {\n return (this.headers && this.headers[CONFIG.fromApiHeader]);\n }\n}\n\nexport default StompMessage;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file diff --git a/lib/protocols/amqpClient.js b/lib/protocols/amqpClient.js index cd2d0de..15595e0 100644 --- a/lib/protocols/amqpClient.js +++ b/lib/protocols/amqpClient.js @@ -30,9 +30,9 @@ var _spacebunny = require('../spacebunny'); var _spacebunny2 = _interopRequireDefault(_spacebunny); -var _message = require('../message'); +var _amqpMessage = require('../messages/amqpMessage'); -var _message2 = _interopRequireDefault(_message); +var _amqpMessage2 = _interopRequireDefault(_amqpMessage); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -104,19 +104,22 @@ var AmqpClient = function (_SpaceBunny) { // Receive messages from imput queue return new _bluebird2.default(function (resolve, reject) { _this2._createChannel('input', opts).then(function (ch) { - return _when2.default.all([ch.checkQueue(_this2.deviceId() + '.' + _this2._inboxTopic, _this2._inputQueueArgs), ch.consume(_this2.deviceId() + '.' + _this2._inboxTopic, function (res) { + return _when2.default.all([ch.checkQueue(_this2.deviceId() + '.' + _this2._inboxTopic, _this2._inputQueueArgs), ch.consume(_this2.deviceId() + '.' + _this2._inboxTopic, function (message) { // Create message object - var message = new _message2.default(res, _this2._deviceId, opts); - // Chec if should be accepted or not - if (message.blackListed()) { - ch.nack(res, opts.allUpTo, opts.requeue); + var amqpMessage = new _amqpMessage2.default(message, _this2._deviceId, opts); + var ackNeeded = _this2._autoAck(opts.ack); + // Check if should be accepted or not + if (amqpMessage.blackListed()) { + if (ackNeeded) { + ch.nack(message, opts.allUpTo, opts.requeue); + } return; } // Call message callback - callback(_this2._parseContent(res.content), res.fields, res.properties); + callback(_this2._parseContent(amqpMessage.content), amqpMessage.fields, amqpMessage.properties); // Check if ACK is needed - if (_this2._autoAck(opts.ack)) { - ch.ack(res, opts.allUpTo); + if (ackNeeded) { + ch.ack(message, opts.allUpTo); } }, opts)]); }).then(function (res) { @@ -325,29 +328,6 @@ var AmqpClient = function (_SpaceBunny) { return this.deviceId() + '.' + channel; } - /** - * Automatically parse message content - * - * @private - * @param {Object/String} message - the received message - * @return an object containing the input message with parsed content - */ - - }, { - key: '_parseContent', - value: function _parseContent(message) { - var parsedMessage = message; - if (Buffer.isBuffer(parsedMessage)) { - var content = parsedMessage.toString('utf-8'); - try { - parsedMessage = JSON.parse(content); - } catch (ex) { - parsedMessage = content; - } - } - return parsedMessage; - } - /** * Check if the SDK have to automatically ack messages * @@ -360,7 +340,7 @@ var AmqpClient = function (_SpaceBunny) { key: '_autoAck', value: function _autoAck(ack) { if (ack) { - if (!(0, _includes3.default)(CONFIG.ackTypes, ack)) { + if (!(0, _includes3.default)(CONFIG[this._protocol].ackTypes, ack)) { console.error('Wrong acknowledge type'); // eslint-disable-line no-console } switch (ack) { @@ -370,7 +350,7 @@ var AmqpClient = function (_SpaceBunny) { return false; } } - return false; + return true; } }]); diff --git a/lib/protocols/amqpClient.js.map b/lib/protocols/amqpClient.js.map index 8ca4f99..af2ac17 100644 --- a/lib/protocols/amqpClient.js.map +++ b/lib/protocols/amqpClient.js.map @@ -1 +1 @@ -{"version":3,"sources":["protocols/amqpClient.js"],"names":[],"mappings":"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","file":"protocols/amqpClient.js","sourcesContent":["/**\n * A module that exports an AmqpClient client\n * which inherits from the SpaceBunny base client\n * @module AmqpClient\n */\n\n// Import some helpers modules\nimport merge from 'merge';\nimport Promise from 'bluebird';\nimport when from 'when';\nimport _ from 'lodash';\n\n// Import amqplib\nimport amqp from 'amqplib';\n\n// Import SpaceBunny main module from which AmqpClient inherits\nimport SpaceBunny from '../spacebunny';\nimport Message from '../message';\nconst CONFIG = require('../../config/constants').CONFIG;\n\nclass AmqpClient extends SpaceBunny {\n\n /**\n * @constructor\n * @param {Object} opts - options must contain api-key or connection options\n * (deviceId and secret) for devices.\n */\n constructor(opts) {\n super(opts);\n this._amqpConnection = undefined;\n this._amqpChannels = {};\n const amqpOptions = CONFIG.amqp;\n this._protocol = amqpOptions.protocol;\n this._sslProtocol = amqpOptions.ssl.protocol;\n this._inputQueueArgs = amqpOptions.inputQueueArgs;\n this._deviceExchangeArgs = amqpOptions.deviceExchangeArgs;\n this._subscribeArgs = amqpOptions.subscribeArgs;\n this._publishArgs = amqpOptions.publishArgs;\n this._socketOptions = amqpOptions.socketOptions;\n }\n\n /**\n * Subscribe to input channel\n *\n * @param {function} callback - function called every time a message is received\n * passing the current message as argument\n * @param {Object} options - subscription options\n * @return promise containing the result of the subscription\n */\n onReceive(callback, opts) {\n opts = merge(this._subscribeArgs, opts);\n opts.noAck = (opts.ack === null);\n // Receive messages from imput queue\n return new Promise((resolve, reject) => {\n this._createChannel('input', opts).then((ch) => {\n return when.all([\n ch.checkQueue(`${this.deviceId()}.${this._inboxTopic}`, this._inputQueueArgs),\n ch.consume(`${this.deviceId()}.${this._inboxTopic}`, (res) => {\n // Create message object\n const message = new Message(res, this._deviceId, opts);\n // Chec if should be accepted or not\n if (message.blackListed()) {\n ch.nack(res, opts.allUpTo, opts.requeue);\n return;\n }\n // Call message callback\n callback(this._parseContent(res.content), res.fields, res.properties);\n // Check if ACK is needed\n if (this._autoAck(opts.ack)) { ch.ack(res, opts.allUpTo); }\n }, opts)\n ]);\n }).then((res) => {\n resolve(res);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Publish a message on a specific channel\n *\n * @param {String} channel - channel name on which you want to publish a message\n * @param {Object} message - the message payload\n * @param {Object} opts - publication options\n * @return promise containing the result of the subscription\n */\n publish(channel, message, opts = {}) {\n opts = merge(this._publishArgs, opts);\n return new Promise((resolve, reject) => {\n this._createChannel('output', opts).then((ch) => {\n const bufferedMessage = new Buffer(this._encapsulateContent(message));\n const promises = [\n ch.checkExchange(this.deviceId()),\n ch.publish(this.deviceId(), this._routingKeyFor(channel), bufferedMessage, opts)\n ];\n if (opts.withConfirm === true) {\n promises.push(ch.waitForConfirms());\n }\n return when.all(promises);\n }).then((res) => {\n resolve(res);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Destroy the connection between the amqp client and broker\n *\n * @return a promise containing the result of the operation\n */\n disconnect() {\n return new Promise((resolve, reject) => {\n if (this._amqpConnection === undefined) {\n reject('Not Connected');\n } else {\n this._amqpConnection.close().then(() => {\n this._amqpConnection = undefined;\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n // ------------ PRIVATE METHODS -------------------\n\n /**\n * Establish an amqp connection with the broker\n * using configurations retrieved from the endpoint.\n * If the connnection already exists, returns the current connnection\n *\n * @private\n * @return a promise containing current connection\n */\n _connect() {\n let connectionOpts = merge({}, this._socketOptions);\n\n return new Promise((resolve, reject) => {\n this.getEndpointConfigs().then((endpointConfigs) => {\n const connectionParams = endpointConfigs.connection;\n if (this._amqpConnection !== undefined) {\n resolve(this._amqpConnection);\n } else {\n // TODO if ssl change connections string and connection parameters\n let connectionString = '';\n if (this._ssl) {\n if (this._checkSslOptions()) {\n connectionString = `${this._sslProtocol}://${connectionParams.deviceId || connectionParams.client}:` +\n `${connectionParams.secret}@${connectionParams.host}:` +\n `${connectionParams.protocols.amqp.sslPort}/${connectionParams.vhost.replace('/', '%2f')}`;\n connectionOpts = merge(connectionOpts, this._sslOpts);\n } else {\n reject('Missing required SSL connection parameters');\n }\n } else {\n connectionString = `${this._protocol}://${connectionParams.deviceId || connectionParams.client}:` +\n `${connectionParams.secret}@${connectionParams.host}:` +\n `${connectionParams.protocols.amqp.port}/${connectionParams.vhost.replace('/', '%2f')}`;\n }\n amqp.connect(connectionString, connectionOpts).then((conn) => {\n conn.on('error', (err) => {\n reject(err);\n });\n conn.on('blocked', (reason) => {\n console.warn(reason); // eslint-disable-line no-console\n });\n conn.on('unblocked', (reason) => {\n console.warn(reason); // eslint-disable-line no-console\n });\n this._amqpConnection = conn;\n resolve(this._amqpConnection);\n }).catch((reason) => {\n reject(reason);\n });\n }\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Creates a channel on current connection\n *\n * @private\n * @param {String} channelName - indicates the channel name\n * @param {Object} opts - channel options\n * @return a promise containing the current channel\n */\n _createChannel(channelName, opts = {}) {\n channelName = `${channelName}${(opts.withConfirm === true) ? 'WithConfirm' : ''}`;\n return new Promise((resolve, reject) => {\n if (this._amqpChannels[channelName]) {\n resolve(this._amqpChannels[channelName]);\n } else {\n this._connect().then((conn) => {\n if (opts.withConfirm === true) {\n return conn.createConfirmChannel();\n } else {\n return conn.createChannel();\n }\n }).then((ch) => {\n this._amqpChannels[channelName] = ch;\n resolve(ch);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n /**\n * Close a channel on current connection\n *\n * @private\n * @param {String} channelName - indicates if the channel is input or output\n * @return a promise containing the result of the operation\n */\n _closeChannel(channelName, opts = {}) {\n channelName = `${channelName}${(opts.withConfirm === true) ? 'WithConfirm' : ''}`;\n return new Promise((resolve, reject) => {\n const ch = this._amqpChannels[channelName];\n if (ch === undefined) {\n reject('Invalid Channel Object');\n } else {\n ch.close().then(() => {\n this._amqpChannels[channelName] = undefined;\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n /**\n * Generate the routing key for a specific channel\n *\n * @private\n * @param {String} channel - channel name on which you want to publish a message\n * @return a string that represents the routing key for that channel\n */\n _routingKeyFor(channel) {\n return `${this.deviceId()}.${channel}`;\n }\n\n /**\n * Automatically parse message content\n *\n * @private\n * @param {Object/String} message - the received message\n * @return an object containing the input message with parsed content\n */\n _parseContent(message) {\n let parsedMessage = message;\n if (Buffer.isBuffer(parsedMessage)) {\n const content = parsedMessage.toString('utf-8');\n try {\n parsedMessage = JSON.parse(content);\n } catch (ex) {\n parsedMessage = content;\n }\n }\n return parsedMessage;\n }\n\n /**\n * Check if the SDK have to automatically ack messages\n *\n * @private\n * @param {String} ack - the ack type, it should be 'manual' or 'auto'\n * @return boolean - true if messages have to be autoacked, false otherwise\n */\n _autoAck(ack) {\n if (ack) {\n if (!_.includes(CONFIG.ackTypes, ack)) {\n console.error('Wrong acknowledge type'); // eslint-disable-line no-console\n }\n switch (ack) {\n case 'auto':\n return true;\n default:\n return false;\n }\n }\n return false;\n }\n\n}\n\nexport default AmqpClient;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file +{"version":3,"sources":["protocols/amqpClient.js"],"names":[],"mappings":"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","file":"protocols/amqpClient.js","sourcesContent":["/**\n * A module that exports an AmqpClient client\n * which inherits from the SpaceBunny base client\n * @module AmqpClient\n */\n\n// Import some helpers modules\nimport merge from 'merge';\nimport Promise from 'bluebird';\nimport when from 'when';\nimport _ from 'lodash';\n\n// Import amqplib\nimport amqp from 'amqplib';\n\n// Import SpaceBunny main module from which AmqpClient inherits\nimport SpaceBunny from '../spacebunny';\nimport AmqpMessage from '../messages/amqpMessage';\nconst CONFIG = require('../../config/constants').CONFIG;\n\nclass AmqpClient extends SpaceBunny {\n\n /**\n * @constructor\n * @param {Object} opts - options must contain api-key or connection options\n * (deviceId and secret) for devices.\n */\n constructor(opts) {\n super(opts);\n this._amqpConnection = undefined;\n this._amqpChannels = {};\n const amqpOptions = CONFIG.amqp;\n this._protocol = amqpOptions.protocol;\n this._sslProtocol = amqpOptions.ssl.protocol;\n this._inputQueueArgs = amqpOptions.inputQueueArgs;\n this._deviceExchangeArgs = amqpOptions.deviceExchangeArgs;\n this._subscribeArgs = amqpOptions.subscribeArgs;\n this._publishArgs = amqpOptions.publishArgs;\n this._socketOptions = amqpOptions.socketOptions;\n }\n\n /**\n * Subscribe to input channel\n *\n * @param {function} callback - function called every time a message is received\n * passing the current message as argument\n * @param {Object} options - subscription options\n * @return promise containing the result of the subscription\n */\n onReceive(callback, opts) {\n opts = merge(this._subscribeArgs, opts);\n opts.noAck = (opts.ack === null);\n // Receive messages from imput queue\n return new Promise((resolve, reject) => {\n this._createChannel('input', opts).then((ch) => {\n return when.all([\n ch.checkQueue(`${this.deviceId()}.${this._inboxTopic}`, this._inputQueueArgs),\n ch.consume(`${this.deviceId()}.${this._inboxTopic}`, (message) => {\n // Create message object\n const amqpMessage = new AmqpMessage(message, this._deviceId, opts);\n const ackNeeded = this._autoAck(opts.ack);\n // Check if should be accepted or not\n if (amqpMessage.blackListed()) {\n if (ackNeeded) { ch.nack(message, opts.allUpTo, opts.requeue); }\n return;\n }\n // Call message callback\n callback(this._parseContent(amqpMessage.content), amqpMessage.fields, amqpMessage.properties);\n // Check if ACK is needed\n if (ackNeeded) { ch.ack(message, opts.allUpTo); }\n }, opts)\n ]);\n }).then((res) => {\n resolve(res);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Publish a message on a specific channel\n *\n * @param {String} channel - channel name on which you want to publish a message\n * @param {Object} message - the message payload\n * @param {Object} opts - publication options\n * @return promise containing the result of the subscription\n */\n publish(channel, message, opts = {}) {\n opts = merge(this._publishArgs, opts);\n return new Promise((resolve, reject) => {\n this._createChannel('output', opts).then((ch) => {\n const bufferedMessage = new Buffer(this._encapsulateContent(message));\n const promises = [\n ch.checkExchange(this.deviceId()),\n ch.publish(this.deviceId(), this._routingKeyFor(channel), bufferedMessage, opts)\n ];\n if (opts.withConfirm === true) {\n promises.push(ch.waitForConfirms());\n }\n return when.all(promises);\n }).then((res) => {\n resolve(res);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Destroy the connection between the amqp client and broker\n *\n * @return a promise containing the result of the operation\n */\n disconnect() {\n return new Promise((resolve, reject) => {\n if (this._amqpConnection === undefined) {\n reject('Not Connected');\n } else {\n this._amqpConnection.close().then(() => {\n this._amqpConnection = undefined;\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n // ------------ PRIVATE METHODS -------------------\n\n /**\n * Establish an amqp connection with the broker\n * using configurations retrieved from the endpoint.\n * If the connnection already exists, returns the current connnection\n *\n * @private\n * @return a promise containing current connection\n */\n _connect() {\n let connectionOpts = merge({}, this._socketOptions);\n\n return new Promise((resolve, reject) => {\n this.getEndpointConfigs().then((endpointConfigs) => {\n const connectionParams = endpointConfigs.connection;\n if (this._amqpConnection !== undefined) {\n resolve(this._amqpConnection);\n } else {\n // TODO if ssl change connections string and connection parameters\n let connectionString = '';\n if (this._ssl) {\n if (this._checkSslOptions()) {\n connectionString = `${this._sslProtocol}://${connectionParams.deviceId || connectionParams.client}:` +\n `${connectionParams.secret}@${connectionParams.host}:` +\n `${connectionParams.protocols.amqp.sslPort}/${connectionParams.vhost.replace('/', '%2f')}`;\n connectionOpts = merge(connectionOpts, this._sslOpts);\n } else {\n reject('Missing required SSL connection parameters');\n }\n } else {\n connectionString = `${this._protocol}://${connectionParams.deviceId || connectionParams.client}:` +\n `${connectionParams.secret}@${connectionParams.host}:` +\n `${connectionParams.protocols.amqp.port}/${connectionParams.vhost.replace('/', '%2f')}`;\n }\n amqp.connect(connectionString, connectionOpts).then((conn) => {\n conn.on('error', (err) => {\n reject(err);\n });\n conn.on('blocked', (reason) => {\n console.warn(reason); // eslint-disable-line no-console\n });\n conn.on('unblocked', (reason) => {\n console.warn(reason); // eslint-disable-line no-console\n });\n this._amqpConnection = conn;\n resolve(this._amqpConnection);\n }).catch((reason) => {\n reject(reason);\n });\n }\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Creates a channel on current connection\n *\n * @private\n * @param {String} channelName - indicates the channel name\n * @param {Object} opts - channel options\n * @return a promise containing the current channel\n */\n _createChannel(channelName, opts = {}) {\n channelName = `${channelName}${(opts.withConfirm === true) ? 'WithConfirm' : ''}`;\n return new Promise((resolve, reject) => {\n if (this._amqpChannels[channelName]) {\n resolve(this._amqpChannels[channelName]);\n } else {\n this._connect().then((conn) => {\n if (opts.withConfirm === true) {\n return conn.createConfirmChannel();\n } else {\n return conn.createChannel();\n }\n }).then((ch) => {\n this._amqpChannels[channelName] = ch;\n resolve(ch);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n /**\n * Close a channel on current connection\n *\n * @private\n * @param {String} channelName - indicates if the channel is input or output\n * @return a promise containing the result of the operation\n */\n _closeChannel(channelName, opts = {}) {\n channelName = `${channelName}${(opts.withConfirm === true) ? 'WithConfirm' : ''}`;\n return new Promise((resolve, reject) => {\n const ch = this._amqpChannels[channelName];\n if (ch === undefined) {\n reject('Invalid Channel Object');\n } else {\n ch.close().then(() => {\n this._amqpChannels[channelName] = undefined;\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n /**\n * Generate the routing key for a specific channel\n *\n * @private\n * @param {String} channel - channel name on which you want to publish a message\n * @return a string that represents the routing key for that channel\n */\n _routingKeyFor(channel) {\n return `${this.deviceId()}.${channel}`;\n }\n\n /**\n * Check if the SDK have to automatically ack messages\n *\n * @private\n * @param {String} ack - the ack type, it should be 'manual' or 'auto'\n * @return boolean - true if messages have to be autoacked, false otherwise\n */\n _autoAck(ack) {\n if (ack) {\n if (!_.includes(CONFIG[this._protocol].ackTypes, ack)) {\n console.error('Wrong acknowledge type'); // eslint-disable-line no-console\n }\n switch (ack) {\n case 'auto':\n return true;\n default:\n return false;\n }\n }\n return true;\n }\n\n}\n\nexport default AmqpClient;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file diff --git a/lib/protocols/stompClient.js b/lib/protocols/stompClient.js index 6d05a22..91d70d7 100644 --- a/lib/protocols/stompClient.js +++ b/lib/protocols/stompClient.js @@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var _includes2 = require('lodash/includes'); + +var _includes3 = _interopRequireDefault(_includes2); + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); @@ -24,6 +28,10 @@ var _spacebunny = require('../spacebunny'); var _spacebunny2 = _interopRequireDefault(_spacebunny); +var _stompMessage = require('../messages/stompMessage'); + +var _stompMessage2 = _interopRequireDefault(_stompMessage); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -95,13 +103,26 @@ var StompClient = function (_SpaceBunny) { // subscribe for input messages return new _bluebird2.default(function (resolve, reject) { _this2._connect().then(function (client) { - // amq/queue is the form for existing queues - _this2._subscription = client.subscribe(_this2._subcriptionFor(_this2._existingQueuePrefix, _this2._inboxTopic), function (message) { - // TODO filterMine and filterWeb - callback(message); - }, function (reason) { - reject(reason); - }); + var topic = _this2._subcriptionFor(_this2._existingQueuePrefix, _this2._inboxTopic); + var subscriptionCallback = function subscriptionCallback(message) { + // Create message object + var stompMessage = new _stompMessage2.default(message, _this2._deviceId, opts); + var ackNeeded = _this2._autoAck(opts.ack); + // Check if should be accepted or not + if (stompMessage.blackListed()) { + if (ackNeeded) { + message.nack(); + } + return; + } + // Call message callback + callback(_this2._parseContent(stompMessage.body), stompMessage.headers); + // Check if ACK is needed + if (ackNeeded) { + message.ack(); + } + }; + _this2._subscription = client.subscribe(topic, subscriptionCallback); resolve(true); }).catch(function (reason) { reject(reason); @@ -259,6 +280,33 @@ var StompClient = function (_SpaceBunny) { value: function _destinationFor(type, channel) { return '/' + type + '/' + this.deviceId() + '/' + this.deviceId() + '.' + channel; } + + /** + * Check if the SDK have to automatically ack messages + * By default STOMP messages are acked by the server + * they need to be acked if client subscribes with { ack: 'client' } option + * + * @private + * @param {String} ack - the ack type, it should be 'client' or null + * @return boolean - true if messages have to be autoacked, false otherwise + */ + + }, { + key: '_autoAck', + value: function _autoAck(ack) { + if (ack) { + if (!(0, _includes3.default)(CONFIG[this._protocol].ackTypes, ack)) { + console.error('Wrong acknowledge type'); // eslint-disable-line no-console + } + switch (ack) { + case 'client': + return false; + default: + return true; + } + } + return false; + } }]); return StompClient; diff --git a/lib/protocols/stompClient.js.map b/lib/protocols/stompClient.js.map index e7be28e..33e1ee0 100644 --- a/lib/protocols/stompClient.js.map +++ b/lib/protocols/stompClient.js.map @@ -1 +1 @@ -{"version":3,"sources":["protocols/stompClient.js"],"names":[],"mappings":"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","file":"protocols/stompClient.js","sourcesContent":["/**\n * A module that exports an StompClient client\n * which inherits from the SpaceBunny base client\n * @module StompClient\n */\n\n// Import some helpers modules\nimport merge from 'merge';\nimport Promise from 'bluebird';\n\n// Import stomp library\nimport Stomp from 'stompjs';\n\n// Import SpaceBunny main module from which StompClient inherits\nimport SpaceBunny from '../spacebunny';\n\nconst CONFIG = require('../../config/constants').CONFIG;\n\nclass StompClient extends SpaceBunny {\n\n /**\n * @constructor\n * @param {Object} opts - options must contain api-key or connection options\n * (deviceId and secret) for devices.\n */\n constructor(opts) {\n super(opts);\n this._stompConnection = undefined;\n this._subscription = undefined;\n if (typeof process === 'object' && `${process}` === '[object process]') {\n this._protocol = 'stomp';\n } else {\n this._protocol = 'webStomp';\n }\n const stompOpts = CONFIG.stomp;\n const webStompOpts = CONFIG.webStomp;\n this._webSocketOpts = webStompOpts.webSocket;\n this._connectionHeaders = stompOpts.connection.headers;\n this._existingQueuePrefix = stompOpts.existingQueuePrefix;\n }\n\n /**\n * Subscribe to input channel\n *\n * @param {function} callback - function called every time a message is received\n * passing the current message as argument\n * @param {Object} options - subscription options\n * @return promise containing the result of the subscription\n */\n onReceive(callback, opts) {\n opts = merge({}, opts);\n // subscribe for input messages\n return new Promise((resolve, reject) => {\n this._connect().then((client) => {\n // amq/queue is the form for existing queues\n this._subscription = client.subscribe(\n this._subcriptionFor(this._existingQueuePrefix, this._inboxTopic), (message) => {\n // TODO filterMine and filterWeb\n callback(message);\n }, (reason) => {\n reject(reason);\n });\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Publish a message on a specific channel\n *\n * @param {String} channel - channel name on which you want to publish a message\n * @param {Object} message - the message payload\n * @param {Object} opts - publication options\n * @return a promise containing the result of the operation\n */\n publish(channel, message, opts) {\n opts = merge({}, opts);\n // Publish message\n return new Promise((resolve, reject) => {\n this._connect().then((client) => {\n const destination = this._destinationFor('exchange', channel);\n client.send(destination, this._connectionHeaders, this._encapsulateContent(message));\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Destroy the connection between the stomp client and broker\n *\n * @return a promise containing the result of the operation\n */\n disconnect() {\n return new Promise((resolve, reject) => {\n if (this._stompConnection === undefined) {\n reject('Invalid connection');\n } else {\n if (this._subscription !== undefined) {\n this._subscription.unsubscribe();\n }\n this._stompConnection.disconnect(() => {\n this._stompConnection = undefined;\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n // ------------ PRIVATE METHODS -------------------\n\n /**\n * Establish an stomp connection with the broker.\n * If a connection already exists, returns the current connection\n *\n * @private\n * @param {Object} opts - connection options\n * @return a promise containing current connection\n */\n _connect(opts) {\n opts = merge({}, opts);\n return new Promise((resolve, reject) => {\n this.getEndpointConfigs().then((endpointConfigs) => {\n const connectionParams = endpointConfigs.connection;\n if (this._stompConnection !== undefined) {\n resolve(this._stompConnection);\n } else {\n try {\n let client = undefined;\n if (typeof process === 'object' && `${process}` === '[object process]') {\n // code is runnning in nodejs: STOMP uses TCP sockets\n if (this._ssl) {\n client = Stomp.overTCP(connectionParams.host, connectionParams.protocols.stomp.sslPort, this._sslOpts);\n } else {\n client = Stomp.overTCP(connectionParams.host, connectionParams.protocols.stomp.port);\n }\n } else {\n // code is runnning in a browser: web STOMP uses Web sockets\n const protocol = (this._ssl) ? this._webSocketOpts.ssl.protocol : this._webSocketOpts.protocol;\n const port = (this._ssl) ? connectionParams.protocols.webStomp.sslPort :\n connectionParams.protocols.webStomp.port;\n const connectionString = `${protocol}://${connectionParams.host}:${port}/${this._webSocketOpts.endpoint}`;\n const ws = new WebSocket(connectionString);\n client = Stomp.over(ws);\n client.heartbeat.outgoing = 10000;\n client.heartbeat.incoming = 10000;\n client.debug = null;\n }\n const headers = merge(this._connectionHeaders, {\n login: connectionParams.deviceId || connectionParams.client,\n passcode: connectionParams.secret,\n host: connectionParams.vhost\n });\n client.connect(headers, () => {\n this._stompConnection = client;\n resolve(this._stompConnection);\n }, (err) => {\n reject(err);\n });\n } catch (reason) {\n reject(reason);\n }\n }\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Generate the subscription string for a specific channel\n *\n * @private\n * @param {String} type - resource type on which subscribe or publish [exchange/queue]\n * @param {String} channel - channel name on which you want to publish a message\n * @return a string that represents the topic name for that channel\n */\n _subcriptionFor(type, channel) {\n return `/${type}/${this.deviceId()}.${channel}`;\n }\n\n /**\n * Generate the destination string for a specific channel\n *\n * @private\n * @param {String} type - resource type on which subscribe or publish [exchange/queue]\n * @param {String} channel - channel name on which you want to publish a message\n * @return a string that represents the topic name for that channel\n */\n _destinationFor(type, channel) {\n return `/${type}/${this.deviceId()}/${this.deviceId()}.${channel}`;\n }\n\n}\n\nexport default StompClient;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file +{"version":3,"sources":["protocols/stompClient.js"],"names":[],"mappings":"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","file":"protocols/stompClient.js","sourcesContent":["/**\n * A module that exports an StompClient client\n * which inherits from the SpaceBunny base client\n * @module StompClient\n */\n\n// Import some helpers modules\nimport merge from 'merge';\nimport Promise from 'bluebird';\nimport _ from 'lodash';\n\n// Import stomp library\nimport Stomp from 'stompjs';\n\n// Import SpaceBunny main module from which StompClient inherits\nimport SpaceBunny from '../spacebunny';\nimport StompMessage from '../messages/stompMessage';\nconst CONFIG = require('../../config/constants').CONFIG;\n\nclass StompClient extends SpaceBunny {\n\n /**\n * @constructor\n * @param {Object} opts - options must contain api-key or connection options\n * (deviceId and secret) for devices.\n */\n constructor(opts) {\n super(opts);\n this._stompConnection = undefined;\n this._subscription = undefined;\n if (typeof process === 'object' && `${process}` === '[object process]') {\n this._protocol = 'stomp';\n } else {\n this._protocol = 'webStomp';\n }\n const stompOpts = CONFIG.stomp;\n const webStompOpts = CONFIG.webStomp;\n this._webSocketOpts = webStompOpts.webSocket;\n this._connectionHeaders = stompOpts.connection.headers;\n this._existingQueuePrefix = stompOpts.existingQueuePrefix;\n }\n\n /**\n * Subscribe to input channel\n *\n * @param {function} callback - function called every time a message is received\n * passing the current message as argument\n * @param {Object} options - subscription options\n * @return promise containing the result of the subscription\n */\n onReceive(callback, opts) {\n opts = merge({}, opts);\n // subscribe for input messages\n return new Promise((resolve, reject) => {\n this._connect().then((client) => {\n const topic = this._subcriptionFor(this._existingQueuePrefix, this._inboxTopic);\n const subscriptionCallback = (message) => {\n // Create message object\n const stompMessage = new StompMessage(message, this._deviceId, opts);\n const ackNeeded = this._autoAck(opts.ack);\n // Check if should be accepted or not\n if (stompMessage.blackListed()) {\n if (ackNeeded) { message.nack(); }\n return;\n }\n // Call message callback\n callback(this._parseContent(stompMessage.body), stompMessage.headers);\n // Check if ACK is needed\n if (ackNeeded) { message.ack(); }\n };\n this._subscription = client.subscribe(topic, subscriptionCallback);\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Publish a message on a specific channel\n *\n * @param {String} channel - channel name on which you want to publish a message\n * @param {Object} message - the message payload\n * @param {Object} opts - publication options\n * @return a promise containing the result of the operation\n */\n publish(channel, message, opts) {\n opts = merge({}, opts);\n // Publish message\n return new Promise((resolve, reject) => {\n this._connect().then((client) => {\n const destination = this._destinationFor('exchange', channel);\n client.send(destination, this._connectionHeaders, this._encapsulateContent(message));\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Destroy the connection between the stomp client and broker\n *\n * @return a promise containing the result of the operation\n */\n disconnect() {\n return new Promise((resolve, reject) => {\n if (this._stompConnection === undefined) {\n reject('Invalid connection');\n } else {\n if (this._subscription !== undefined) {\n this._subscription.unsubscribe();\n }\n this._stompConnection.disconnect(() => {\n this._stompConnection = undefined;\n resolve(true);\n }).catch((reason) => {\n reject(reason);\n });\n }\n });\n }\n\n // ------------ PRIVATE METHODS -------------------\n\n /**\n * Establish an stomp connection with the broker.\n * If a connection already exists, returns the current connection\n *\n * @private\n * @param {Object} opts - connection options\n * @return a promise containing current connection\n */\n _connect(opts) {\n opts = merge({}, opts);\n return new Promise((resolve, reject) => {\n this.getEndpointConfigs().then((endpointConfigs) => {\n const connectionParams = endpointConfigs.connection;\n if (this._stompConnection !== undefined) {\n resolve(this._stompConnection);\n } else {\n try {\n let client = undefined;\n if (typeof process === 'object' && `${process}` === '[object process]') {\n // code is runnning in nodejs: STOMP uses TCP sockets\n if (this._ssl) {\n client = Stomp.overTCP(connectionParams.host, connectionParams.protocols.stomp.sslPort, this._sslOpts);\n } else {\n client = Stomp.overTCP(connectionParams.host, connectionParams.protocols.stomp.port);\n }\n } else {\n // code is runnning in a browser: web STOMP uses Web sockets\n const protocol = (this._ssl) ? this._webSocketOpts.ssl.protocol : this._webSocketOpts.protocol;\n const port = (this._ssl) ? connectionParams.protocols.webStomp.sslPort :\n connectionParams.protocols.webStomp.port;\n const connectionString = `${protocol}://${connectionParams.host}:${port}/${this._webSocketOpts.endpoint}`;\n const ws = new WebSocket(connectionString);\n client = Stomp.over(ws);\n client.heartbeat.outgoing = 10000;\n client.heartbeat.incoming = 10000;\n client.debug = null;\n }\n const headers = merge(this._connectionHeaders, {\n login: connectionParams.deviceId || connectionParams.client,\n passcode: connectionParams.secret,\n host: connectionParams.vhost\n });\n client.connect(headers, () => {\n this._stompConnection = client;\n resolve(this._stompConnection);\n }, (err) => {\n reject(err);\n });\n } catch (reason) {\n reject(reason);\n }\n }\n }).catch((reason) => {\n reject(reason);\n });\n });\n }\n\n /**\n * Generate the subscription string for a specific channel\n *\n * @private\n * @param {String} type - resource type on which subscribe or publish [exchange/queue]\n * @param {String} channel - channel name on which you want to publish a message\n * @return a string that represents the topic name for that channel\n */\n _subcriptionFor(type, channel) {\n return `/${type}/${this.deviceId()}.${channel}`;\n }\n\n /**\n * Generate the destination string for a specific channel\n *\n * @private\n * @param {String} type - resource type on which subscribe or publish [exchange/queue]\n * @param {String} channel - channel name on which you want to publish a message\n * @return a string that represents the topic name for that channel\n */\n _destinationFor(type, channel) {\n return `/${type}/${this.deviceId()}/${this.deviceId()}.${channel}`;\n }\n\n /**\n * Check if the SDK have to automatically ack messages\n * By default STOMP messages are acked by the server\n * they need to be acked if client subscribes with { ack: 'client' } option\n *\n * @private\n * @param {String} ack - the ack type, it should be 'client' or null\n * @return boolean - true if messages have to be autoacked, false otherwise\n */\n _autoAck(ack) {\n if (ack) {\n if (!_.includes(CONFIG[this._protocol].ackTypes, ack)) {\n console.error('Wrong acknowledge type'); // eslint-disable-line no-console\n }\n switch (ack) {\n case 'client':\n return false;\n default:\n return true;\n }\n }\n return false;\n }\n\n}\n\nexport default StompClient;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file diff --git a/lib/spacebunny.js b/lib/spacebunny.js index ddbb630..a1502a0 100644 --- a/lib/spacebunny.js +++ b/lib/spacebunny.js @@ -244,7 +244,7 @@ var SpaceBunny = function () { * Check if a stream exists * * @param {String} streamName - stream name - * @return true if stream exists false otherwise + * @return true if stream exists, false otherwise */ }, { @@ -352,6 +352,29 @@ var SpaceBunny = function () { } return hostname; } + + /** + * Automatically parse message content + * + * @private + * @param {Object/String} message - the received message + * @return an object containing the input message with parsed content + */ + + }, { + key: '_parseContent', + value: function _parseContent(message) { + var parsedMessage = message; + if (Buffer.isBuffer(parsedMessage)) { + var content = parsedMessage.toString('utf-8'); + try { + parsedMessage = JSON.parse(content); + } catch (ex) { + parsedMessage = content; + } + } + return parsedMessage; + } }]); return SpaceBunny; diff --git a/lib/spacebunny.js.map b/lib/spacebunny.js.map index 166fc26..074d243 100644 --- a/lib/spacebunny.js.map +++ b/lib/spacebunny.js.map @@ -1 +1 @@ -{"version":3,"sources":["spacebunny.js"],"names":[],"mappings":"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","file":"spacebunny.js","sourcesContent":["/**\n * A module that exports the base SpaceBunny client\n * @module SpaceBunny\n */\n\n// Import some helpers modules\nimport fs from 'fs';\nimport merge from 'merge';\nimport axios from 'axios';\nimport humps from 'humps';\nimport Promise from 'bluebird';\nimport { startsWith, filter } from 'lodash';\n\n// TODO validate enpointConfig object format with Joi\n// import Joi from 'joi';\n\nconst CONFIG = require('../config/constants').CONFIG;\n\n/**\n * @constructor\n * @param {Object} opts - constructor options may contain api-key or connection options\n */\nclass SpaceBunny {\n constructor(opts = {}) {\n this._connectionParams = merge({}, humps.camelizeKeys(opts));\n this._endpointConfigs = undefined;\n this._endpointUrl = this._connectionParams.endpointUrl;\n this._apiKey = this._connectionParams.apiKey;\n this._channels = this._connectionParams.channels;\n this._deviceId = this._connectionParams.deviceId;\n this._client = this._connectionParams.client;\n this._secret = this._connectionParams.secret;\n this._host = this._connectionParams.host;\n this._port = this._connectionParams.port;\n this._vhost = this._connectionParams.vhost;\n this._protocol = CONFIG.protocol;\n this._inboxTopic = this._connectionParams.inputTopic || CONFIG.inboxTopic;\n this._liveStreamSuffix = CONFIG.liveStreamSuffix;\n this._tempQueueSuffix = CONFIG.tempQueueSuffix;\n this._liveStreams = [];\n this._ssl = this._connectionParams.ssl || false;\n this._sslOpts = {};\n if (this._connectionParams.cert) { this._sslOpts.cert = fs.readFileSync(this._connectionParams.cert); }\n if (this._connectionParams.key) { this._sslOpts.key = fs.readFileSync(this._connectionParams.key); }\n if (this._connectionParams.passphrase) { this._sslOpts.passphrase = this._connectionParams.passphrase; }\n if (this._connectionParams.ca) { this._sslOpts.ca = [fs.readFileSync(this._connectionParams.ca)];}\n if (this._connectionParams.pfx) { this._sslOpts.pfx = fs.readFileSync(this._connectionParams.pfx); }\n this._sslOpts.secureProtocol = this._connectionParams.secureProtocol || CONFIG.ssl.secureProtocol;\n }\n\n // TODO this function should return a Promise!! Need to be async\n /**\n * Check if api-key or connection parameters have already been passed\n * If at least api-key is passed ask the endpoint for the configurations\n * else if also connection parameters are not passed raise an exception\n *\n * @return an Object containing the connection parameters\n */\n getEndpointConfigs() {\n return new Promise((resolve, reject) => {\n // Resolve with configs if already retrieved\n if (this._endpointConfigs !== undefined) {\n resolve(this._endpointConfigs);\n }\n // Contact endpoint to retrieve configs\n // Switch endpoint if you are using sdk as device or as access key stream\n let endpoint = '';\n if ((this._deviceId && this._secret) || this._apiKey) { // Device credentials\n endpoint = CONFIG.deviceEndpoint;\n // uses endpoint passed from user, default endpoint otherwise\n const hostname = this._generateHostname(endpoint);\n const uri = `${hostname}${endpoint.api_version}${endpoint.path}`;\n if (this._apiKey) { // Get configs from endpoint\n const options = { url: uri, method: 'get', headers: { 'Api-Key': this._apiKey }, responseType: 'json' };\n axios(options).then((response) => {\n this._endpointConfigs = humps.camelizeKeys(response.data);\n this._connectionParams = this._endpointConfigs.connection;\n resolve(this._endpointConfigs);\n }).catch((err) => {\n reject(err);\n });\n } else if (this._deviceId && this._secret && this._host && this._port && this._vhost) {\n // Manually provided configs\n this._connectionParams.protocols = {};\n if (this._ssl) {\n this._connectionParams.protocols[this._protocol] = { sslPort: this._port };\n } else {\n this._connectionParams.protocols[this._protocol] = { port: this._port };\n }\n this._endpointConfigs = {\n connection: this._connectionParams,\n channels: []\n };\n resolve(this._endpointConfigs);\n }\n } else if (this._client && this._secret) { // Access key credentials\n if (this._host && this._port && this._vhost) {\n // Manually provided configs\n this._connectionParams.protocols = {};\n if (this._ssl) {\n this._connectionParams.protocols[this._protocol] = { sslPort: this._port };\n } else {\n this._connectionParams.protocols[this._protocol] = { port: this._port };\n }\n this._endpointConfigs = {\n connection: this._connectionParams,\n liveStreams: []\n };\n resolve(this._endpointConfigs);\n } else {\n // Get configs from endpoint\n endpoint = CONFIG.accessKeyEndpoint;\n // uses endpoint passed from user, default endpoint otherwise\n const hostname = this._generateHostname(endpoint);\n const uri = `${hostname}${endpoint.api_version}${endpoint.path}`;\n const options = {\n url: uri,\n method: 'get',\n headers: { 'Access-Key-Client': this._client, 'Access-Key-Secret': this._secret },\n responseType: 'json'\n };\n axios(options).then((response) => {\n this._endpointConfigs = humps.camelizeKeys(response.data);\n this._connectionParams = this._endpointConfigs.connection;\n this._liveStreams = this._endpointConfigs.liveStreams || [];\n resolve(this._endpointConfigs);\n }).catch((err) => {\n reject(err);\n });\n }\n } else { // No configs or missing some info\n reject('Missing Api Key or wrong connection parameters');\n }\n });\n }\n\n /**\n * @return all channels configured for the current device\n */\n channels() {\n this.getEndpointConfigs().then((endpointConfigs) => {\n this._channels = endpointConfigs.channels.map((obj) => {\n return obj.name;\n });\n return this._channels || [];\n });\n }\n\n /**\n * @return the device ID for the current device\n */\n deviceId() {\n this._deviceId = this._deviceId || this._connectionParams.deviceId;\n return this._deviceId;\n }\n\n /**\n * Return a Stream ID from a stream name given in input\n *\n * @param {String} streamName - stream name\n * @return the stream ID which corresponds to the input stream name\n */\n liveStreamByName(streamName) {\n const liveStreams = filter(this._liveStreams, (stream) => { return stream.name === streamName; });\n if (liveStreams.length > 0) {\n return liveStreams[0].id || streamName;\n } else {\n return streamName;\n }\n }\n\n /**\n * Check if a stream exists\n *\n * @param {String} streamName - stream name\n * @return true if stream exists false otherwise\n */\n liveStreamExists(streamName) {\n const liveStreams = filter(this._liveStreams, (stream) => { return stream.name === streamName; });\n return (liveStreams.length > 0);\n }\n\n /**\n * Generate a temporary queue name\n *\n * @private\n * @param {String} prefix - client id or stream name\n * @param {String} suffix - channel name or defaul live stream suffix\n * @param {Numeric} currentTime - current timestamp\n * @return a string that represents the topic name for that channel\n */\n tempQueue(prefix, suffix, currentTime) {\n const timestamp = currentTime || new Date().getTime();\n return `${timestamp}-${this._connectionParams.client}-` +\n `${this.exchangeName(prefix, suffix)}.` +\n `${this._tempQueueSuffix}`;\n }\n\n /**\n * Generate the exchange name for a device's channel\n *\n * @private\n * @param {String} prefix - It could be a device id or a stream name\n * @param {String} suffix - It could be a channel name or a the default stream suffix (live_stream)\n * @return a string that represents the complete exchange name\n */\n exchangeName(prefix, suffix) {\n return (prefix && suffix) ? `${this.liveStreamByName(prefix)}.${suffix}` : `${suffix}`;\n }\n\n // ------------ PRIVATE METHODS -------------------\n\n /**\n * Encapsulates contens for publishing messages.\n * If the content is a valid JSON the function stringifies the content\n *\n * @private\n * @param {Object} content - content to publish, could be a string or a JSON object\n * @return the content encapsulated in the proper way\n */\n _encapsulateContent(content) {\n let encapsulatedContent = content;\n try {\n encapsulatedContent = JSON.stringify(content);\n } catch (ex) {\n encapsulatedContent = content;\n }\n return encapsulatedContent;\n }\n\n /**\n * Check if the required parameters are present to open a secure connection\n *\n * @private\n * @return true when a combination of valid parameters is present, false otherwise\n */\n _checkSslOptions() {\n const sslOpts = this._sslOpts;\n if (sslOpts.ca) {\n if (sslOpts.cert && sslOpts.key) {\n return true;\n } else if (sslOpts.pfx) {\n return true;\n } else {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /**\n * Generate the complete hostname string for an endpoint\n *\n * @private\n * @return the string representing the endpoint url\n */\n _generateHostname(endpoint) {\n let hostname = `${(this._endpointUrl || endpoint.url)}`;\n const endpointProtocol = (this._ssl) ? CONFIG.endpoint.secureProtocol : CONFIG.endpoint.protocol;\n if (!startsWith(hostname, endpointProtocol)) {\n hostname = `${endpointProtocol}://${hostname}`;\n }\n return hostname;\n }\n\n}\n\nexport default SpaceBunny;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file +{"version":3,"sources":["spacebunny.js"],"names":[],"mappings":"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","file":"spacebunny.js","sourcesContent":["/**\n * A module that exports the base SpaceBunny client\n * @module SpaceBunny\n */\n\n// Import some helpers modules\nimport fs from 'fs';\nimport merge from 'merge';\nimport axios from 'axios';\nimport humps from 'humps';\nimport Promise from 'bluebird';\nimport { startsWith, filter } from 'lodash';\n\n// TODO validate enpointConfig object format with Joi\n// import Joi from 'joi';\n\nconst CONFIG = require('../config/constants').CONFIG;\n\n/**\n * @constructor\n * @param {Object} opts - constructor options may contain api-key or connection options\n */\nclass SpaceBunny {\n constructor(opts = {}) {\n this._connectionParams = merge({}, humps.camelizeKeys(opts));\n this._endpointConfigs = undefined;\n this._endpointUrl = this._connectionParams.endpointUrl;\n this._apiKey = this._connectionParams.apiKey;\n this._channels = this._connectionParams.channels;\n this._deviceId = this._connectionParams.deviceId;\n this._client = this._connectionParams.client;\n this._secret = this._connectionParams.secret;\n this._host = this._connectionParams.host;\n this._port = this._connectionParams.port;\n this._vhost = this._connectionParams.vhost;\n this._protocol = CONFIG.protocol;\n this._inboxTopic = this._connectionParams.inputTopic || CONFIG.inboxTopic;\n this._liveStreamSuffix = CONFIG.liveStreamSuffix;\n this._tempQueueSuffix = CONFIG.tempQueueSuffix;\n this._liveStreams = [];\n this._ssl = this._connectionParams.ssl || false;\n this._sslOpts = {};\n if (this._connectionParams.cert) { this._sslOpts.cert = fs.readFileSync(this._connectionParams.cert); }\n if (this._connectionParams.key) { this._sslOpts.key = fs.readFileSync(this._connectionParams.key); }\n if (this._connectionParams.passphrase) { this._sslOpts.passphrase = this._connectionParams.passphrase; }\n if (this._connectionParams.ca) { this._sslOpts.ca = [fs.readFileSync(this._connectionParams.ca)];}\n if (this._connectionParams.pfx) { this._sslOpts.pfx = fs.readFileSync(this._connectionParams.pfx); }\n this._sslOpts.secureProtocol = this._connectionParams.secureProtocol || CONFIG.ssl.secureProtocol;\n }\n\n // TODO this function should return a Promise!! Need to be async\n /**\n * Check if api-key or connection parameters have already been passed\n * If at least api-key is passed ask the endpoint for the configurations\n * else if also connection parameters are not passed raise an exception\n *\n * @return an Object containing the connection parameters\n */\n getEndpointConfigs() {\n return new Promise((resolve, reject) => {\n // Resolve with configs if already retrieved\n if (this._endpointConfigs !== undefined) {\n resolve(this._endpointConfigs);\n }\n // Contact endpoint to retrieve configs\n // Switch endpoint if you are using sdk as device or as access key stream\n let endpoint = '';\n if ((this._deviceId && this._secret) || this._apiKey) { // Device credentials\n endpoint = CONFIG.deviceEndpoint;\n // uses endpoint passed from user, default endpoint otherwise\n const hostname = this._generateHostname(endpoint);\n const uri = `${hostname}${endpoint.api_version}${endpoint.path}`;\n if (this._apiKey) { // Get configs from endpoint\n const options = { url: uri, method: 'get', headers: { 'Api-Key': this._apiKey }, responseType: 'json' };\n axios(options).then((response) => {\n this._endpointConfigs = humps.camelizeKeys(response.data);\n this._connectionParams = this._endpointConfigs.connection;\n resolve(this._endpointConfigs);\n }).catch((err) => {\n reject(err);\n });\n } else if (this._deviceId && this._secret && this._host && this._port && this._vhost) {\n // Manually provided configs\n this._connectionParams.protocols = {};\n if (this._ssl) {\n this._connectionParams.protocols[this._protocol] = { sslPort: this._port };\n } else {\n this._connectionParams.protocols[this._protocol] = { port: this._port };\n }\n this._endpointConfigs = {\n connection: this._connectionParams,\n channels: []\n };\n resolve(this._endpointConfigs);\n }\n } else if (this._client && this._secret) { // Access key credentials\n if (this._host && this._port && this._vhost) {\n // Manually provided configs\n this._connectionParams.protocols = {};\n if (this._ssl) {\n this._connectionParams.protocols[this._protocol] = { sslPort: this._port };\n } else {\n this._connectionParams.protocols[this._protocol] = { port: this._port };\n }\n this._endpointConfigs = {\n connection: this._connectionParams,\n liveStreams: []\n };\n resolve(this._endpointConfigs);\n } else {\n // Get configs from endpoint\n endpoint = CONFIG.accessKeyEndpoint;\n // uses endpoint passed from user, default endpoint otherwise\n const hostname = this._generateHostname(endpoint);\n const uri = `${hostname}${endpoint.api_version}${endpoint.path}`;\n const options = {\n url: uri,\n method: 'get',\n headers: { 'Access-Key-Client': this._client, 'Access-Key-Secret': this._secret },\n responseType: 'json'\n };\n axios(options).then((response) => {\n this._endpointConfigs = humps.camelizeKeys(response.data);\n this._connectionParams = this._endpointConfigs.connection;\n this._liveStreams = this._endpointConfigs.liveStreams || [];\n resolve(this._endpointConfigs);\n }).catch((err) => {\n reject(err);\n });\n }\n } else { // No configs or missing some info\n reject('Missing Api Key or wrong connection parameters');\n }\n });\n }\n\n /**\n * @return all channels configured for the current device\n */\n channels() {\n this.getEndpointConfigs().then((endpointConfigs) => {\n this._channels = endpointConfigs.channels.map((obj) => {\n return obj.name;\n });\n return this._channels || [];\n });\n }\n\n /**\n * @return the device ID for the current device\n */\n deviceId() {\n this._deviceId = this._deviceId || this._connectionParams.deviceId;\n return this._deviceId;\n }\n\n /**\n * Return a Stream ID from a stream name given in input\n *\n * @param {String} streamName - stream name\n * @return the stream ID which corresponds to the input stream name\n */\n liveStreamByName(streamName) {\n const liveStreams = filter(this._liveStreams, (stream) => { return stream.name === streamName; });\n if (liveStreams.length > 0) {\n return liveStreams[0].id || streamName;\n } else {\n return streamName;\n }\n }\n\n /**\n * Check if a stream exists\n *\n * @param {String} streamName - stream name\n * @return true if stream exists, false otherwise\n */\n liveStreamExists(streamName) {\n const liveStreams = filter(this._liveStreams, (stream) => { return stream.name === streamName; });\n return (liveStreams.length > 0);\n }\n\n /**\n * Generate a temporary queue name\n *\n * @private\n * @param {String} prefix - client id or stream name\n * @param {String} suffix - channel name or defaul live stream suffix\n * @param {Numeric} currentTime - current timestamp\n * @return a string that represents the topic name for that channel\n */\n tempQueue(prefix, suffix, currentTime) {\n const timestamp = currentTime || new Date().getTime();\n return `${timestamp}-${this._connectionParams.client}-` +\n `${this.exchangeName(prefix, suffix)}.` +\n `${this._tempQueueSuffix}`;\n }\n\n /**\n * Generate the exchange name for a device's channel\n *\n * @private\n * @param {String} prefix - It could be a device id or a stream name\n * @param {String} suffix - It could be a channel name or a the default stream suffix (live_stream)\n * @return a string that represents the complete exchange name\n */\n exchangeName(prefix, suffix) {\n return (prefix && suffix) ? `${this.liveStreamByName(prefix)}.${suffix}` : `${suffix}`;\n }\n\n // ------------ PRIVATE METHODS -------------------\n\n /**\n * Encapsulates contens for publishing messages.\n * If the content is a valid JSON the function stringifies the content\n *\n * @private\n * @param {Object} content - content to publish, could be a string or a JSON object\n * @return the content encapsulated in the proper way\n */\n _encapsulateContent(content) {\n let encapsulatedContent = content;\n try {\n encapsulatedContent = JSON.stringify(content);\n } catch (ex) {\n encapsulatedContent = content;\n }\n return encapsulatedContent;\n }\n\n /**\n * Check if the required parameters are present to open a secure connection\n *\n * @private\n * @return true when a combination of valid parameters is present, false otherwise\n */\n _checkSslOptions() {\n const sslOpts = this._sslOpts;\n if (sslOpts.ca) {\n if (sslOpts.cert && sslOpts.key) {\n return true;\n } else if (sslOpts.pfx) {\n return true;\n } else {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /**\n * Generate the complete hostname string for an endpoint\n *\n * @private\n * @return the string representing the endpoint url\n */\n _generateHostname(endpoint) {\n let hostname = `${(this._endpointUrl || endpoint.url)}`;\n const endpointProtocol = (this._ssl) ? CONFIG.endpoint.secureProtocol : CONFIG.endpoint.protocol;\n if (!startsWith(hostname, endpointProtocol)) {\n hostname = `${endpointProtocol}://${hostname}`;\n }\n return hostname;\n }\n\n /**\n * Automatically parse message content\n *\n * @private\n * @param {Object/String} message - the received message\n * @return an object containing the input message with parsed content\n */\n _parseContent(message) {\n let parsedMessage = message;\n if (Buffer.isBuffer(parsedMessage)) {\n const content = parsedMessage.toString('utf-8');\n try {\n parsedMessage = JSON.parse(content);\n } catch (ex) {\n parsedMessage = content;\n }\n }\n return parsedMessage;\n }\n\n}\n\nexport default SpaceBunny;\n"],"sourceRoot":"/Users/gfoiani/Dev/work/spacebunny/sdk/node/src"} \ No newline at end of file diff --git a/src/message.js b/src/messages/amqpMessage.js similarity index 83% rename from src/message.js rename to src/messages/amqpMessage.js index 5dbe6a1..c600d4a 100644 --- a/src/message.js +++ b/src/messages/amqpMessage.js @@ -3,9 +3,9 @@ * @module Message */ -const CONFIG = require('../config/constants').CONFIG; +const CONFIG = require('../../config/constants').CONFIG; -class Message { +class AmqpMessage { /** * @constructor @@ -40,13 +40,13 @@ class Message { /** * Check if a message comes from API - * Check if the source exchange is equals to inputExchange + * Check if it contains 'x-from-sb-api' header * * @return Boolean - true if it comes from API, false otherwise */ fromApi() { - return (this.fields.exchange === CONFIG.inputExchange); + return (this.properties.headers && this.properties.headers[CONFIG.fromApiHeader]); } } -export default Message; +export default AmqpMessage; diff --git a/src/messages/stompMessage.js b/src/messages/stompMessage.js new file mode 100644 index 0000000..075b9ba --- /dev/null +++ b/src/messages/stompMessage.js @@ -0,0 +1,52 @@ +/** + * A wrapper for the message object + * @module Message + */ + +const CONFIG = require('../../config/constants').CONFIG; + +class StompMessage { + + /** + * @constructor + * @param {Object} message - the message received from the channel + * @param {String} receiverId - the receiver id + * @param {Object} opts - subscription options + */ + constructor(message, receiverId, opts = {}) { + this.body = message.body; + this.headers = message.headers; + try { + const destination = this.headers.destination.split('/'); + [this.senderId, this.channelName] = destination[destination.length - 1].split('.'); + } catch (ex) { + console.error('Wrong routing key format'); // eslint-disable-line no-console + } + this._receiverId = receiverId; + this._discardMine = opts.discardMine || false; + this._discardFromApi = opts.discardFromApi || false; + } + + /** + * Check if a message should be accepted of rejected + * + * @return Boolean - true if should be not considered, false otherwise + */ + blackListed() { + if (this._discardMine && this._receiverId === this.senderId && !this.fromApi()) return true; + if (this._discardFromApi && this.fromApi()) return true; + return false; + } + + /** + * Check if a message comes from API + * Check if it contains 'x-from-sb-api' header + * + * @return Boolean - true if it comes from API, false otherwise + */ + fromApi() { + return (this.headers && this.headers[CONFIG.fromApiHeader]); + } +} + +export default StompMessage; diff --git a/src/protocols/amqpClient.js b/src/protocols/amqpClient.js index 4d3d46a..6828a1f 100644 --- a/src/protocols/amqpClient.js +++ b/src/protocols/amqpClient.js @@ -15,7 +15,7 @@ import amqp from 'amqplib'; // Import SpaceBunny main module from which AmqpClient inherits import SpaceBunny from '../spacebunny'; -import Message from '../message'; +import AmqpMessage from '../messages/amqpMessage'; const CONFIG = require('../../config/constants').CONFIG; class AmqpClient extends SpaceBunny { @@ -55,18 +55,19 @@ class AmqpClient extends SpaceBunny { this._createChannel('input', opts).then((ch) => { return when.all([ ch.checkQueue(`${this.deviceId()}.${this._inboxTopic}`, this._inputQueueArgs), - ch.consume(`${this.deviceId()}.${this._inboxTopic}`, (res) => { + ch.consume(`${this.deviceId()}.${this._inboxTopic}`, (message) => { // Create message object - const message = new Message(res, this._deviceId, opts); - // Chec if should be accepted or not - if (message.blackListed()) { - ch.nack(res, opts.allUpTo, opts.requeue); + const amqpMessage = new AmqpMessage(message, this._deviceId, opts); + const ackNeeded = this._autoAck(opts.ack); + // Check if should be accepted or not + if (amqpMessage.blackListed()) { + if (ackNeeded) { ch.nack(message, opts.allUpTo, opts.requeue); } return; } // Call message callback - callback(this._parseContent(res.content), res.fields, res.properties); + callback(this._parseContent(amqpMessage.content), amqpMessage.fields, amqpMessage.properties); // Check if ACK is needed - if (this._autoAck(opts.ack)) { ch.ack(res, opts.allUpTo); } + if (ackNeeded) { ch.ack(message, opts.allUpTo); } }, opts) ]); }).then((res) => { @@ -248,26 +249,6 @@ class AmqpClient extends SpaceBunny { return `${this.deviceId()}.${channel}`; } - /** - * Automatically parse message content - * - * @private - * @param {Object/String} message - the received message - * @return an object containing the input message with parsed content - */ - _parseContent(message) { - let parsedMessage = message; - if (Buffer.isBuffer(parsedMessage)) { - const content = parsedMessage.toString('utf-8'); - try { - parsedMessage = JSON.parse(content); - } catch (ex) { - parsedMessage = content; - } - } - return parsedMessage; - } - /** * Check if the SDK have to automatically ack messages * @@ -277,7 +258,7 @@ class AmqpClient extends SpaceBunny { */ _autoAck(ack) { if (ack) { - if (!_.includes(CONFIG.ackTypes, ack)) { + if (!_.includes(CONFIG[this._protocol].ackTypes, ack)) { console.error('Wrong acknowledge type'); // eslint-disable-line no-console } switch (ack) { @@ -287,7 +268,7 @@ class AmqpClient extends SpaceBunny { return false; } } - return false; + return true; } } diff --git a/src/protocols/stompClient.js b/src/protocols/stompClient.js index facddc7..ef5583a 100644 --- a/src/protocols/stompClient.js +++ b/src/protocols/stompClient.js @@ -7,13 +7,14 @@ // Import some helpers modules import merge from 'merge'; import Promise from 'bluebird'; +import _ from 'lodash'; // Import stomp library import Stomp from 'stompjs'; // Import SpaceBunny main module from which StompClient inherits import SpaceBunny from '../spacebunny'; - +import StompMessage from '../messages/stompMessage'; const CONFIG = require('../../config/constants').CONFIG; class StompClient extends SpaceBunny { @@ -52,14 +53,22 @@ class StompClient extends SpaceBunny { // subscribe for input messages return new Promise((resolve, reject) => { this._connect().then((client) => { - // amq/queue is the form for existing queues - this._subscription = client.subscribe( - this._subcriptionFor(this._existingQueuePrefix, this._inboxTopic), (message) => { - // TODO filterMine and filterWeb - callback(message); - }, (reason) => { - reject(reason); - }); + const topic = this._subcriptionFor(this._existingQueuePrefix, this._inboxTopic); + const subscriptionCallback = (message) => { + // Create message object + const stompMessage = new StompMessage(message, this._deviceId, opts); + const ackNeeded = this._autoAck(opts.ack); + // Check if should be accepted or not + if (stompMessage.blackListed()) { + if (ackNeeded) { message.nack(); } + return; + } + // Call message callback + callback(this._parseContent(stompMessage.body), stompMessage.headers); + // Check if ACK is needed + if (ackNeeded) { message.ack(); } + }; + this._subscription = client.subscribe(topic, subscriptionCallback); resolve(true); }).catch((reason) => { reject(reason); @@ -196,6 +205,30 @@ class StompClient extends SpaceBunny { return `/${type}/${this.deviceId()}/${this.deviceId()}.${channel}`; } + /** + * Check if the SDK have to automatically ack messages + * By default STOMP messages are acked by the server + * they need to be acked if client subscribes with { ack: 'client' } option + * + * @private + * @param {String} ack - the ack type, it should be 'client' or null + * @return boolean - true if messages have to be autoacked, false otherwise + */ + _autoAck(ack) { + if (ack) { + if (!_.includes(CONFIG[this._protocol].ackTypes, ack)) { + console.error('Wrong acknowledge type'); // eslint-disable-line no-console + } + switch (ack) { + case 'client': + return false; + default: + return true; + } + } + return false; + } + } export default StompClient; diff --git a/src/spacebunny.js b/src/spacebunny.js index 5e6e386..955c930 100644 --- a/src/spacebunny.js +++ b/src/spacebunny.js @@ -264,6 +264,26 @@ class SpaceBunny { return hostname; } + /** + * Automatically parse message content + * + * @private + * @param {Object/String} message - the received message + * @return an object containing the input message with parsed content + */ + _parseContent(message) { + let parsedMessage = message; + if (Buffer.isBuffer(parsedMessage)) { + const content = parsedMessage.toString('utf-8'); + try { + parsedMessage = JSON.parse(content); + } catch (ex) { + parsedMessage = content; + } + } + return parsedMessage; + } + } export default SpaceBunny; From 532d984fde2ffa456a71cb0b617c4ac3d7f1af35 Mon Sep 17 00:00:00 2001 From: Giovanni Foiani Date: Thu, 31 Mar 2016 14:59:02 +0200 Subject: [PATCH 2/4] Remove vendor split --- dist/spacebunny.js | 4 ++-- dist/vendors.js | 1 - make-webpack.config.js | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 dist/vendors.js diff --git a/dist/spacebunny.js b/dist/spacebunny.js index 9f161fd..8746d43 100644 --- a/dist/spacebunny.js +++ b/dist/spacebunny.js @@ -1,4 +1,4 @@ -webpackJsonp([0,1],[function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.StompStreamClient=t.MqttStreamClient=t.AmqpStreamClient=t.StreamClient=t.StompClient=t.MqttClient=t.AmqpClient=t.Client=void 0;var i=n(2),o=r(i),s=n(231),a=r(s),u=n(283),c=r(u),l=n(291),f=r(l),h=n(292),p=r(h),d=n(293),v=r(d);"undefined"!=typeof window&&(window.StompClient=c["default"],window.StompStreamClient=v["default"]),t.Client=o["default"],t.AmqpClient=o["default"],t.MqttClient=a["default"],t.StompClient=c["default"],t.StreamClient=f["default"],t.AmqpStreamClient=f["default"],t.MqttStreamClient=p["default"],t.StompStreamClient=v["default"]},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),u=r(a),c=function(){function e(e,t){for(var n=0;n @@ -74,4 +74,4 @@ this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once( r(s)}})["catch"](function(e){r(e)})})}},{key:"_subcriptionFor",value:function(e,t){return"/"+e+"/"+this.deviceId()+"."+t}},{key:"_destinationFor",value:function(e,t){return"/"+e+"/"+this.deviceId()+"/"+this.deviceId()+"."+t}},{key:"_autoAck",value:function(e){if(e)switch((0,u["default"])(_[this._protocol].ackTypes,e)||console.error("Wrong acknowledge type"),e){case"client":return!1;default:return!0}return!1}}]),n}(m["default"]);t["default"]=E}).call(t,n(36))},function(e,t,n){var r=n(285),i=n(286);e.exports=r.Stomp,e.exports.overTCP=i.overTCP,e.exports.overWS=i.overWS},function(e,t){(function(){var e,n,r,i,o={}.hasOwnProperty,s=[].slice;e={LF:"\n",NULL:"\x00"},r=function(){function t(e,t,n){this.command=e,this.headers=null!=t?t:{},this.body=null!=n?n:""}var n;return t.prototype.toString=function(){var n,r,i,s,a;n=[this.command],s=this.headers["content-length"]===!1,s&&delete this.headers["content-length"],i=this.headers;for(r in i)o.call(i,r)&&(a=i[r],n.push(r+":"+a));return this.body&&!s&&n.push("content-length:"+t.sizeOfUTF8(this.body)),n.push(e.LF+this.body),n.join(e.LF)},t.sizeOfUTF8=function(e){return e?encodeURI(e).match(/%..|./g).length:0},n=function(n){var r,i,o,s,a,u,c,l,f,h,p,d,v,g,y,m,b,w;for(s=n.search(RegExp(""+e.LF+e.LF)),a=n.substring(0,s).split(e.LF),o=a.shift(),u={},w=function(e){return e.replace(/^\s+|\s+$/g,"")},g=a.reverse(),f=0,d=g.length;d>f;f++)v=g[f],l=v.indexOf(":"),u[w(v.substring(0,l))]=w(v.substring(l+1));if(r="",b=s+2,u["content-length"])p=parseInt(u["content-length"]),r=(""+n).substring(b,b+p);else for(i=null,c=h=y=b,m=n.length;(m>=y?m>h:h>m)&&(i=n.charAt(c),i!==e.NULL);c=m>=y?++h:--h)r+=i;return new t(o,u,r)},t.unmarshall=function(t){var r,i,o,s;return i=t.split(RegExp(""+e.NULL+e.LF+"*")),s={frames:[],partial:""},s.frames=function(){var e,t,o,s;for(o=i.slice(0,-1),s=[],e=0,t=o.length;t>e;e++)r=o[e],s.push(n(r));return s}(),o=i.slice(-1)[0],o===e.LF||-1!==o.search(RegExp(""+e.NULL+e.LF+"*$"))?s.frames.push(n(o)):s.partial=o,s},t.marshall=function(n,r,i){var o;return o=new t(n,r,i),o.toString()+e.NULL},t}(),n=function(){function t(e){this.ws=e,this.ws.binaryType="arraybuffer",this.counter=0,this.connected=!1,this.heartbeat={outgoing:1e4,incoming:1e4},this.maxWebSocketFrameSize=16384,this.subscriptions={},this.partialData=""}var n;return t.prototype.debug=function(e){var t;return"undefined"!=typeof window&&null!==window&&null!=(t=window.console)?t.log(e):void 0},n=function(){return Date.now?Date.now():(new Date).valueOf},t.prototype._transmit=function(e,t,n){var i;for(i=r.marshall(e,t,n),"function"==typeof this.debug&&this.debug(">>> "+i);;){if(!(i.length>this.maxWebSocketFrameSize))return this.ws.send(i);this.ws.send(i.substring(0,this.maxWebSocketFrameSize)),i=i.substring(this.maxWebSocketFrameSize),"function"==typeof this.debug&&this.debug("remaining = "+i.length)}},t.prototype._setupHeartbeat=function(t){var r,o,s,a,u,c;if((r=t.version)===i.VERSIONS.V1_1||r===i.VERSIONS.V1_2)return o=function(){var e,n,r,i;for(r=t["heart-beat"].split(","),i=[],e=0,n=r.length;n>e;e++)c=r[e],i.push(parseInt(c));return i}(),a=o[0],s=o[1],0!==this.heartbeat.outgoing&&0!==s&&(u=Math.max(this.heartbeat.outgoing,s),"function"==typeof this.debug&&this.debug("send PING every "+u+"ms"),this.pinger=i.setInterval(u,function(t){return function(){return t.ws.send(e.LF),"function"==typeof t.debug?t.debug(">>> PING"):void 0}}(this))),0!==this.heartbeat.incoming&&0!==a?(u=Math.max(this.heartbeat.incoming,a),"function"==typeof this.debug&&this.debug("check PONG every "+u+"ms"),this.ponger=i.setInterval(u,function(e){return function(){var t;return t=n()-e.serverActivity,t>2*u?("function"==typeof e.debug&&e.debug("did not receive server activity for the last "+t+"ms"),e.ws.close()):void 0}}(this))):void 0},t.prototype._parseConnect=function(){var e,t,n,r;switch(e=1<=arguments.length?s.call(arguments,0):[],r={},e.length){case 2:r=e[0],t=e[1];break;case 3:e[1]instanceof Function?(r=e[0],t=e[1],n=e[2]):(r.login=e[0],r.passcode=e[1],t=e[2]);break;case 4:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3];break;default:r.login=e[0],r.passcode=e[1],t=e[2],n=e[3],r.host=e[4]}return[r,t,n]},t.prototype.connect=function(){var t,o,a,u;return t=1<=arguments.length?s.call(arguments,0):[],u=this._parseConnect.apply(this,t),a=u[0],this.connectCallback=u[1],o=u[2],"function"==typeof this.debug&&this.debug("Opening Web Socket..."),this.ws.onmessage=function(t){return function(i){var s,a,u,c,l,f,h,p,d,v,g,y,m;if(c="undefined"!=typeof ArrayBuffer&&i.data instanceof ArrayBuffer?(s=new Uint8Array(i.data),"function"==typeof t.debug?t.debug("--- got data length: "+s.length):void 0,function(){var e,t,n;for(n=[],e=0,t=s.length;t>e;e++)a=s[e],n.push(String.fromCharCode(a));return n}().join("")):i.data,t.serverActivity=n(),c===e.LF)return void("function"==typeof t.debug&&t.debug("<<< PONG"));for("function"==typeof t.debug&&t.debug("<<< "+c),m=r.unmarshall(t.partialData+c),t.partialData=m.partial,v=m.frames,g=[],f=0,h=v.length;h>f;f++)switch(l=v[f],l.command){case"CONNECTED":"function"==typeof t.debug&&t.debug("connected to server "+l.headers.server),t.connected=!0,t._setupHeartbeat(l.headers),g.push("function"==typeof t.connectCallback?t.connectCallback(l):void 0);break;case"MESSAGE":y=l.headers.subscription,d=t.subscriptions[y]||t.onreceive,d?(u=t,p=l.headers["message-id"],l.ack=function(e){return null==e&&(e={}),u.ack(p,y,e)},l.nack=function(e){return null==e&&(e={}),u.nack(p,y,e)},g.push(d(l))):g.push("function"==typeof t.debug?t.debug("Unhandled received MESSAGE: "+l):void 0);break;case"RECEIPT":g.push("function"==typeof t.onreceipt?t.onreceipt(l):void 0);break;case"ERROR":g.push("function"==typeof o?o(l):void 0);break;default:g.push("function"==typeof t.debug?t.debug("Unhandled frame: "+l):void 0)}return g}}(this),this.ws.onclose=function(e){return function(){var t;return t="Whoops! Lost connection to "+e.ws.url,"function"==typeof e.debug&&e.debug(t),e._cleanUp(),"function"==typeof o?o(t):void 0}}(this),this.ws.onopen=function(e){return function(){return"function"==typeof e.debug&&e.debug("Web Socket Opened..."),a["accept-version"]=i.VERSIONS.supportedVersions(),a["heart-beat"]=[e.heartbeat.outgoing,e.heartbeat.incoming].join(","),e._transmit("CONNECT",a)}}(this)},t.prototype.disconnect=function(e,t){return null==t&&(t={}),this._transmit("DISCONNECT",t),this.ws.onclose=null,this.ws.close(),this._cleanUp(),"function"==typeof e?e():void 0},t.prototype._cleanUp=function(){return this.connected=!1,this.pinger&&i.clearInterval(this.pinger),this.ponger?i.clearInterval(this.ponger):void 0},t.prototype.send=function(e,t,n){return null==t&&(t={}),null==n&&(n=""),t.destination=e,this._transmit("SEND",t,n)},t.prototype.subscribe=function(e,t,n){var r;return null==n&&(n={}),n.id||(n.id="sub-"+this.counter++),n.destination=e,this.subscriptions[n.id]=t,this._transmit("SUBSCRIBE",n),r=this,{id:n.id,unsubscribe:function(){return r.unsubscribe(n.id)}}},t.prototype.unsubscribe=function(e){return delete this.subscriptions[e],this._transmit("UNSUBSCRIBE",{id:e})},t.prototype.begin=function(e){var t,n;return n=e||"tx-"+this.counter++,this._transmit("BEGIN",{transaction:n}),t=this,{id:n,commit:function(){return t.commit(n)},abort:function(){return t.abort(n)}}},t.prototype.commit=function(e){return this._transmit("COMMIT",{transaction:e})},t.prototype.abort=function(e){return this._transmit("ABORT",{transaction:e})},t.prototype.ack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("ACK",n)},t.prototype.nack=function(e,t,n){return null==n&&(n={}),n["message-id"]=e,n.subscription=t,this._transmit("NACK",n)},t}(),i={VERSIONS:{V1_0:"1.0",V1_1:"1.1",V1_2:"1.2",supportedVersions:function(){return"1.1,1.0"}},client:function(e,t){var r,o;return null==t&&(t=["v10.stomp","v11.stomp"]),r=i.WebSocketClass||WebSocket,o=new r(e,t),new n(o)},over:function(e){return new n(e)},Frame:r},"undefined"!=typeof t&&null!==t&&(t.Stomp=i),"undefined"!=typeof window&&null!==window?(i.setInterval=function(e,t){return window.setInterval(t,e)},i.clearInterval=function(e){return window.clearInterval(e)},window.Stomp=i):t||(self.Stomp=i)}).call(this)},function(e,t,n){(function(){var e,r,i,o,s,a,u;e=n(285),r=n(108),s=n(108),e.Stomp.setInterval=function(e,t){return setInterval(t,e)},e.Stomp.clearInterval=function(e){return clearInterval(e)},a=function(e,t,n){var i,o;return i=null,o={url:"tcp://"+e+":"+t,send:function(e){return i.write(e)},close:function(){return i.end()}},i=n?s.connect(t,e,n,function(e){return i.authorized?o.onopen():(console.error("SSL is not authorized: "+i.authorizationError),"function"==typeof o.onclose?o.onclose(e):void 0)}):r.connect(t,e,function(e){return o.onopen()}),i.on("error",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),i.on("close",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),i.on("data",function(e){var t;return t={data:e.toString()},o.onmessage(t)}),o},u=function(e){var t,r,i,o;return t=n(287).client,r=null,o={url:e,send:function(e){return r.sendUTF(e)},close:function(){return r.close()}},i=new t,i.on("connect",function(e){return r=e,o.onopen(),r.on("error",function(e){return"function"==typeof o.onclose?o.onclose(e):void 0}),r.on("close",function(){return"function"==typeof o.onclose?o.onclose():void 0}),r.on("message",function(e){var t;return"utf8"===e.type?(t={data:e.utf8Data},o.onmessage(t)):void 0})}),i.connect(e),o},i=function(t,n,r){var i;return i=a(t,n,r),e.Stomp.over(i)},o=function(t){var n;return n=u(t),e.Stomp.over(n)},t.overTCP=i,t.overWS=o}).call(this)},function(e,t,n){function r(e,t){var n;return n=t?new o(e,t):new o(e)}var i=function(){return this}(),o=i.WebSocket||i.MozWebSocket,s=n(288);e.exports={w3cwebsocket:o?r:null,version:s}},function(e,t,n){e.exports=n(289).version},function(e,t){e.exports={_args:[["websocket@latest","/Users/gfoiani/Dev/work/spacebunny/sdk/node/node_modules/stompjs"]],_from:"websocket@latest",_id:"websocket@1.0.22",_inCache:!0,_installable:!0,_location:"/websocket",_nodeVersion:"3.3.1",_npmUser:{email:"brian@worlize.com",name:"theturtle32"},_npmVersion:"2.14.3",_phantomChildren:{},_requested:{name:"websocket",raw:"websocket@latest",rawSpec:"latest",scope:null,spec:"latest",type:"tag"},_requiredBy:["/stompjs"],_resolved:"https://registry.npmjs.org/websocket/-/websocket-1.0.22.tgz",_shasum:"8c33e3449f879aaf518297c9744cebf812b9e3d8",_shrinkwrap:null,_spec:"websocket@latest",_where:"/Users/gfoiani/Dev/work/spacebunny/sdk/node/node_modules/stompjs",author:{email:"brian@worlize.com",name:"Brian McKelvey",url:"https://www.worlize.com/"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},config:{verbose:!1},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"~2.2.0",nan:"~2.0.5","typedarray-to-buffer":"~3.0.3",yaeti:"~0.0.4"},description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^0.0.1",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^1.11.2","jshint-stylish":"^1.0.2",tape:"^4.0.1"},directories:{lib:"./lib"},dist:{shasum:"8c33e3449f879aaf518297c9744cebf812b9e3d8",tarball:"http://registry.npmjs.org/websocket/-/websocket-1.0.22.tgz"},engines:{node:">=0.8.0"},gitHead:"19108bbfd7d94a5cd02dbff3495eafee9e901ca4",homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["RFC-6455","client","comet","networking","push","realtime","server","socket","websocket","websockets"],license:"Apache-2.0",main:"index",maintainers:[{name:"theturtle32",email:"brian@worlize.com"}],name:"websocket",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.22"}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(u){i=!0,o=u}finally{try{!r&&a["return"]&&a["return"]()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,t){for(var n=0;n0&&(a=o[0].callback||s),a(t,r)}),r(!0))})})["catch"](function(e){i(e)})})}},{key:"_streamChannelTopicFor",value:function(e,t){return e+"/"+t}},{key:"_streamTopicFor",value:function(e){return this.liveStreamByName(e)+"/"+this._liveStreamSuffix}}]),t}(p["default"]);delete d.onReceive,delete d.publish,delete d._topicFor,t["default"]=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;nn;n++)t(e[n],n)}e.exports=o;var u=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},c=n(91);c.inherits=n(73);var l=n(r),f=n(i);c.inherits(o,l),a(u(f.prototype),function(e){o.prototype[e]||(o.prototype[e]=f.prototype[e])})}).call(t,n(36))},function(e,t,n,r){function i(e){return this instanceof i?void o.call(this,e):new i(e)}e.exports=i;var o=n(r),s=n(91);s.inherits=n(73),s.inherits(i,o),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){(function(t){function i(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function o(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function s(e){var t=n(r);return this instanceof s||this instanceof t?(this._writableState=new o(e,this),this.writable=!0,void x.call(this)):new s(e)}function a(e,n,r){var i=new Error("write after end");e.emit("error",i),t.nextTick(function(){r(i)})}function u(e,n,r,i){var o=!0;if(!_.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!n.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),t.nextTick(function(){i(s)}),o=!1}return o}function c(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new _(t,n)),t}function l(e,t,n,r,o){n=c(t,n,r),_.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var a;!t.decoder||i||r||(n=t.decoder.write(n),a=!t.objectMode&&0===n.length),i||(t.reading=!1),a||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&v(e))),y(e,t)}else i||(t.reading=!1);return l(t)}function l(e){return!e.ended&&(e.needReadable||e.length=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function h(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=f(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function p(e,t){var n=null;return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function d(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,v(e)}}function v(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(M("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U(g,e):g(e))}function g(e){M("emit readable"),e.emit("readable"),x(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U(m,e,t))}function m(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)n=o?r.join(""):1===r.length?r[0]:j.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,U(C,t,e))}function C(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function S(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function T(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=u;var U=n(266),B=n(r),j=n(88).Buffer;u.ReadableState=a;var O,A=(n(84),function(e,t){return e.listeners(t).length});!function(){try{O=n(83)}catch(e){}finally{O||(O=n(84).EventEmitter)}}();var j=n(88).Buffer,R=n(91);R.inherits=n(73);var L=n(i),M=void 0;M=L&&L.debuglog?L.debuglog("stream"):function(){};var F;R.inherits(u,O);var P,P;u.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new j(e,t),t="")),c(this,n,e,t,!1)},u.prototype.unshift=function(e){var t=this._readableState;return c(this,t,e,"",!0)},u.prototype.isPaused=function(){return this._readableState.flowing===!1},u.prototype.setEncoding=function(e){return F||(F=n(95).StringDecoder),this._readableState.decoder=new F(e),this._readableState.encoding=e,this};var N=8388608;u.prototype.read=function(e){M("read",e);var t=this._readableState,n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return M("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?k(this):v(this),null;if(e=h(e,t),0===e&&t.ended)return 0===t.length&&k(this),null;var r=t.needReadable;M("need readable",r),(0===t.length||t.length-e0?I(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&k(this),null!==i&&this.emit("data",i),i},u.prototype._read=function(e){this.emit("error",new Error("not implemented"))},u.prototype.pipe=function(e,n){function r(e){M("onunpipe"),e===f&&o()}function i(){M("onend"),e.end()}function o(){M("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",v),e.removeListener("error",a),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),f.removeListener("data",s),g=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||v()}function s(t){M("ondata");var n=e.write(t);!1===n&&(1!==h.pipesCount||h.pipes[0]!==e||1!==f.listenerCount("data")||g||(M("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++),f.pause())}function a(t){M("onerror",t),l(),e.removeListener("error",a),0===A(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),l()}function c(){M("onfinish"),e.removeListener("close",u),l()}function l(){M("unpipe"),f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,M("pipe count=%d opts=%j",h.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,d=p?i:o;h.endEmitted?U(d):f.once("end",d),e.on("unpipe",r);var v=b(f);e.on("drain",v);var g=!1;return f.on("data",s),e._events&&e._events.error?B(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",f),h.flowing||(M("pipe resume"),f.resume()),e},u.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,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var o=T(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},u.prototype.on=function(e,t){var n=O.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&!this._readableState.endEmitted){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&v(this,r):U(w,this))}return n},u.prototype.addListener=u.prototype.on,u.prototype.resume=function(){var e=this._readableState;return e.flowing||(M("resume"),e.flowing=!0,_(this,e)),this},u.prototype.pause=function(){return M("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(M("pause"),this._readableState.flowing=!1,this.emit("pause")),this},u.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(M("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(M("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return S(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){M("wrapped _read",t),n&&(n=!1,e.resume())},r},u._fromList=I}).call(t,n(36))},function(e,t,n,r,i){(function(t,o){"use strict";function s(){}function a(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function u(e,t){O=O||n(r),e=e||{},this.objectMode=!!e.objectMode,t instanceof O&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new k(this),this.corkedRequestsFree.next=new k(this)}function c(e){return O=O||n(i),this instanceof c||this instanceof O?(this._writableState=new u(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),void B.call(this)):new c(e)}function l(e,t){var n=new Error("write after end");e.emit("error",n),C(t,n)}function f(e,t,n,r){var i=!0;if(!T.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),C(r,o),i=!1}return i}function h(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new T(t,n)),t}function p(e,t,n,r,i){n=h(t,n,r),T.isBuffer(n)&&(r="buffer");var o=t.objectMode?1:n.length;t.length+=o;var s=t.length-1?o:C,T=n(88).Buffer;c.WritableState=u;var U=n(91);U.inherits=n(73);var B,j={deprecate:n(271)};!function(){try{B=n(83)}catch(e){}finally{B||(B=n(84).EventEmitter)}}();var T=n(88).Buffer;U.inherits(c,B);var O;u.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(u.prototype,"buffer",{get:j.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var O;c.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},c.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),T.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=s),r.ended?l(this,n):f(this,r,e,n)&&(r.pendingcb++,i=p(this,r,e,t,n)),i},c.prototype.cork=function(){var e=this._writableState;e.corked++},c.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||w(this,e))},c.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);this._writableState.defaultEncoding=e},c.prototype._write=function(e,t,n){n(new Error("not implemented"))},c.prototype._writev=null,c.prototype.end=function(e,t,n){var r=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),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||I(this,r,n)}}).call(t,n(36),n(37).setImmediate)}]); \ No newline at end of file +!function(a){"use strict";s=function(e){var t=n(r),s=n(i),a=n(o).asap;return t({scheduler:new s(a)})}.call(t,n,t,e),!(void 0!==s&&(e.exports=s))}(n(42))},function(e,t,n,r,i){(function(t){function o(e){return this instanceof o?(l.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",s)):new o(e)}function s(){this.allowHalfOpen||this._writableState.ended||t.nextTick(this.end.bind(this))}function a(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}e.exports=o;var u=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},c=n(91);c.inherits=n(73);var l=n(r),f=n(i);c.inherits(o,l),a(u(f.prototype),function(e){o.prototype[e]||(o.prototype[e]=f.prototype[e])})}).call(t,n(36))},function(e,t,n,r){function i(e){return this instanceof i?void o.call(this,e):new i(e)}e.exports=i;var o=n(r),s=n(91);s.inherits=n(73),s.inherits(i,o),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){e.exports=n(r)},function(e,t,n,r){(function(t){function i(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function o(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function s(e){var t=n(r);return this instanceof s||this instanceof t?(this._writableState=new o(e,this),this.writable=!0,void x.call(this)):new s(e)}function a(e,n,r){var i=new Error("write after end");e.emit("error",i),t.nextTick(function(){r(i)})}function u(e,n,r,i){var o=!0;if(!_.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!n.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),t.nextTick(function(){i(s)}),o=!1}return o}function c(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new _(t,n)),t}function l(e,t,n,r,o){n=c(t,n,r),_.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{var a;!t.decoder||i||r||(n=t.decoder.write(n),a=!t.objectMode&&0===n.length),i||(t.reading=!1),a||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&v(e))),y(e,t)}else i||(t.reading=!1);return l(t)}function l(e){return!e.ended&&(e.needReadable||e.length=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function h(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=f(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function p(e,t){var n=null;return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function d(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,v(e)}}function v(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(M("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U(g,e):g(e))}function g(e){M("emit readable"),e.emit("readable"),x(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U(m,e,t))}function m(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)n=o?r.join(""):1===r.length?r[0]:j.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],f=Math.min(e-u,a.length);o?n+=a.slice(0,f):a.copy(n,u,0,f),f0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,U(C,t,e))}function C(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function S(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function T(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}e.exports=u;var U=n(266),B=n(r),j=n(88).Buffer;u.ReadableState=a;var O,A=(n(84),function(e,t){return e.listeners(t).length});!function(){try{O=n(83)}catch(e){}finally{O||(O=n(84).EventEmitter)}}();var j=n(88).Buffer,R=n(91);R.inherits=n(73);var L=n(i),M=void 0;M=L&&L.debuglog?L.debuglog("stream"):function(){};var F;R.inherits(u,O);var P,P;u.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new j(e,t),t="")),c(this,n,e,t,!1)},u.prototype.unshift=function(e){var t=this._readableState;return c(this,t,e,"",!0)},u.prototype.isPaused=function(){return this._readableState.flowing===!1},u.prototype.setEncoding=function(e){return F||(F=n(95).StringDecoder),this._readableState.decoder=new F(e),this._readableState.encoding=e,this};var N=8388608;u.prototype.read=function(e){M("read",e);var t=this._readableState,n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return M("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?k(this):v(this),null;if(e=h(e,t),0===e&&t.ended)return 0===t.length&&k(this),null;var r=t.needReadable;M("need readable",r),(0===t.length||t.length-e0?I(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&k(this),null!==i&&this.emit("data",i),i},u.prototype._read=function(e){this.emit("error",new Error("not implemented"))},u.prototype.pipe=function(e,n){function r(e){M("onunpipe"),e===f&&o()}function i(){M("onend"),e.end()}function o(){M("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",v),e.removeListener("error",a),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),f.removeListener("data",s),g=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||v()}function s(t){M("ondata");var n=e.write(t);!1===n&&(1!==h.pipesCount||h.pipes[0]!==e||1!==f.listenerCount("data")||g||(M("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++),f.pause())}function a(t){M("onerror",t),l(),e.removeListener("error",a),0===A(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),l()}function c(){M("onfinish"),e.removeListener("close",u),l()}function l(){M("unpipe"),f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,M("pipe count=%d opts=%j",h.pipesCount,n);var p=(!n||n.end!==!1)&&e!==t.stdout&&e!==t.stderr,d=p?i:o;h.endEmitted?U(d):f.once("end",d),e.on("unpipe",r);var v=b(f);e.on("drain",v);var g=!1;return f.on("data",s),e._events&&e._events.error?B(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",f),h.flowing||(M("pipe resume"),f.resume()),e},u.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,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var o=T(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},u.prototype.on=function(e,t){var n=O.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&!this._readableState.endEmitted){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&v(this,r):U(w,this))}return n},u.prototype.addListener=u.prototype.on,u.prototype.resume=function(){var e=this._readableState;return e.flowing||(M("resume"),e.flowing=!0,_(this,e)),this},u.prototype.pause=function(){return M("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(M("pause"),this._readableState.flowing=!1,this.emit("pause")),this},u.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(M("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(M("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return S(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){M("wrapped _read",t),n&&(n=!1,e.resume())},r},u._fromList=I}).call(t,n(36))},function(e,t,n,r,i){(function(t,o){"use strict";function s(){}function a(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function u(e,t){O=O||n(r),e=e||{},this.objectMode=!!e.objectMode,t instanceof O&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new k(this),this.corkedRequestsFree.next=new k(this)}function c(e){return O=O||n(i),this instanceof c||this instanceof O?(this._writableState=new u(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),void B.call(this)):new c(e)}function l(e,t){var n=new Error("write after end");e.emit("error",n),C(t,n)}function f(e,t,n,r){var i=!0;if(!T.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),C(r,o),i=!1}return i}function h(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new T(t,n)),t}function p(e,t,n,r,i){n=h(t,n,r),T.isBuffer(n)&&(r="buffer");var o=t.objectMode?1:n.length;t.length+=o;var s=t.length-1?o:C,T=n(88).Buffer;c.WritableState=u;var U=n(91);U.inherits=n(73);var B,j={deprecate:n(271)};!function(){try{B=n(83)}catch(e){}finally{B||(B=n(84).EventEmitter)}}();var T=n(88).Buffer;U.inherits(c,B);var O;u.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(u.prototype,"buffer",{get:j.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var O;c.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},c.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),T.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=s),r.ended?l(this,n):f(this,r,e,n)&&(r.pendingcb++,i=p(this,r,e,t,n)),i},c.prototype.cork=function(){var e=this._writableState;e.corked++},c.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||w(this,e))},c.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);this._writableState.defaultEncoding=e},c.prototype._write=function(e,t,n){n(new Error("not implemented"))},c.prototype._writev=null,c.prototype.end=function(e,t,n){var r=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),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||I(this,r,n)}}).call(t,n(36),n(37).setImmediate)}])); \ No newline at end of file diff --git a/dist/vendors.js b/dist/vendors.js deleted file mode 100644 index 5dc42fb..0000000 --- a/dist/vendors.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var n=window.webpackJsonp;window.webpackJsonp=function(c,o){for(var i,p,s=0,u=[];s Date: Thu, 31 Mar 2016 16:29:27 +0200 Subject: [PATCH 3/4] Update Readme Update examples Remove useless dependency Update some dependencies --- README.md | 80 ++++++++++++++++++++++++-- dist/device/index.html | 5 +- dist/spacebunny.js | 2 +- dist/stream/index.html | 5 +- examples/device/mqtt/publisher.js | 32 ++++++----- examples/device/mqtt/receiver.js | 22 ++++--- examples/device/stomp/receiver.js | 9 ++- examples/stream/amqp/streamer.js | 36 ++++++------ examples/stream/mqtt/streamer.js | 44 +++++++------- examples/stream/stomp/streamer.js | 47 ++++++++------- lib/protocols/stompStreamClient.js | 2 +- lib/protocols/stompStreamClient.js.map | 2 +- package.json | 9 ++- public/device/index.html | 5 +- public/stream/index.html | 5 +- src/protocols/stompStreamClient.js | 2 +- 16 files changed, 200 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index 054b0d1..67f5907 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Please feel free to contribute! `npm install spacebunny --save` -## Usage +## Basic usage ### Device @@ -60,12 +60,16 @@ amqpClient.onReceive(messageCallback).then(function(res) { }); ``` -For more advanced usage please refer to example files +For more advanced usage please refer to example files in `examples` folder ### Stream A stream client can read from multiple live streams hooks -In this example the streamer receives all messages from stream `my-stream` + +#### AMQP streamer + +In this example the streamer receives all messages from stream `my-stream` and `my-stream-2` + ```javascript 'use strict'; var AmqpStreamClient = require('spacebunny').AmqpStreamClient; @@ -82,6 +86,7 @@ var streamClient = new AmqpStreamClient(connectionParams); // Use your stream name var streamHooks = [ { stream: 'my-stream', callback: messageCallback }, + { stream: 'my-stream-2', callback: messageCallback } ]; streamClient.streamFrom(streamHooks).then(function(res) { console.log(res); @@ -89,8 +94,75 @@ streamClient.streamFrom(streamHooks).then(function(res) { console.error(reason); }); ``` +For more advanced usage please refer to example files in `examples` folder + +## Usage within a web page + +Space Bunny Node SDK is bundled using Webpack to allow the integration of the library within a web page + +### Device + +#### STOMP receiver and publisher + +In this example a device waits for incoming messages on its `inbox` channel and publishes a single message on the first configured channel + +```html + + +``` + +For more advanced usage please refer to example files in `dist` folder + +### Stream + +A stream client can read from multiple live streams hooks + +#### STOMP streamer + +In this example the streamer receives all messages from stream `my-stream` and `my-stream-2` + +```html + + +``` -For more advanced usage please refer to example files +For more advanced usage please refer to example files in `dist` folder ## Watch changes to src files (with automatic transpilation on save) diff --git a/dist/device/index.html b/dist/device/index.html index 89611d5..9d88e51 100644 --- a/dist/device/index.html +++ b/dist/device/index.html @@ -67,7 +67,6 @@

Send a Message

- - - -