(this["webpackJsonpgonzo-test-client"]=this["webpackJsonpgonzo-test-client"]||[]).push([[64],{"/LkU":function(e,t,r){"use strict";(function(t){var n=r("VT4K"),i=r("CxY0"),o=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],s="browser"===t.title;function a(e,t){var r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.port||("wss"===e.protocol?e.port=443:e.port=80),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={}),s||"wss"!==e.protocol||o.forEach((function(t){e.hasOwnProperty(t)&&!e.wsOptions.hasOwnProperty(t)&&(e.wsOptions[t]=e[t])}))}(t);var i=function(e,t){var r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"===typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}(t,e);return n(i,[r],t.wsOptions)}e.exports=s?function(e,t){if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"===typeof document)throw new Error("Could not determine host. Specify host manually.");var r=i.parse(document.URL);t.hostname=r.hostname,t.port||(t.port=r.port)}return a(e,t)}:function(e,t){return a(e,t)}}).call(this,r("8oxB"))},"/jyY":function(e,t,r){"use strict";var n=r(11);e.exports=function(e,t){var r;function i(n){t.rejectUnauthorized&&e.emit("error",n),r.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,(r=n.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",i)})),r.on("error",i),r}},"2yJ6":function(e,t,r){var n=r("lh5l"),i=r("5R+2");e.exports=i.bind(null,n)},"34ae":function(e,t,r){"use strict";(function(t,n){var i=r("fiWp"),o=r("6gh9"),s=r("NAn0"),a=r("A10f").Writable,c=r("P7XM"),u=r("KaIO"),p=r("roTD"),l=r("U6jy"),h=t.setImmediate||function(e){n.nextTick(e)},f={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},d={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function g(e,t,r){e.emit("packetsend",t),!s.writeToStream(t,e.stream,e.options)&&r?e.stream.once("drain",r):r&&r()}function m(e){e&&Object.keys(e).forEach((function(t){"function"===typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])}))}function b(e,t,r,n){e.outgoingStore.put(t,(function(i){if(i)return r&&r(i);n(),g(e,t,r)}))}function _(){}function y(e,t){var r,n=this;if(!(this instanceof y))return new y(e,t);for(r in this.options=t||{},f)"undefined"===typeof this.options[r]?this.options[r]=f[r]:this.options[r]=t[r];this.options.clientId="string"===typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.outgoingStore=t.outgoingStore||new o,this.incomingStore=t.incomingStore||new o,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this._firstConnection=!0,this.on("close",(function(){this.connected=!1,clearTimeout(this.connackTimer)})),this.on("connect",(function(){var e=this.queue;!function t(){var r,i=e.shift();i&&(r=i.packet,n._sendPacket(r,(function(e){i.cb&&i.cb(e),t()})))}()})),this.on("close",(function(){null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null)})),this.on("close",this._setupReconnect),i.EventEmitter.call(this),this._setupStream()}c(y,i.EventEmitter),y.prototype._setupStream=function(){var e,t=this,r=new a,i=s.parser(this.options),o=null,c=[];function u(){if(c.length)n.nextTick(p);else{var e=o;o=null,e()}}function p(){var e=c.shift();if(e)t._handlePacket(e,u);else{var r=o;o=null,r&&r()}}if(this._clearReconnect(),this.stream=this.streamBuilder(this),i.on("packet",(function(e){c.push(e)})),r._write=function(e,t,r){o=r,i.parse(e),p()},this.stream.pipe(r),this.stream.on("error",_),this.stream.on("close",(function(){var e;(e=t.outgoing)&&Object.keys(e).forEach((function(t){e[t].volatile&&"function"===typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})),t.emit("close")})),(e=Object.create(this.options)).cmd="connect",g(this,e),i.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return this.emit("error",new Error("Packet has no Authentication Method")),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"===typeof this.options.authPacket)g(this,l({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){t._cleanUp(!0)}),this.options.connectTimeout)},y.prototype._handlePacket=function(e,t){var r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSizeo.properties.topicAliasMaximum||!o.properties.topicAliasMaximum&&r.properties.topicAlias))&&delete i.properties.topicAlias),r.qos){case 1:case 2:this.outgoing[i.messageId]={volatile:!1,cb:n||_},this._storeProcessing?(this._packetIdsDuringStoreProcessing[i.messageId]=!1,this._storePacket(i,void 0,r.cbStorePut)):this._sendPacket(i,void 0,r.cbStorePut);break;default:this._storeProcessing?this._storePacket(i,n,r.cbStorePut):this._sendPacket(i,n,r.cbStorePut)}return this},y.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),r=0;r0){var t={qos:e.qos};5===f&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),u._resubscribeTopics[e.topic]=t,g.push(e.topic)}})),u.messageIdToTopic[e.messageId]=g}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var r=t.granted,n=0;n0?this.once("outgoingEmpty",setTimeout.bind(null,o,10)):o()),this},y.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},y.prototype.reconnect=function(e){var t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},y.prototype._reconnect=function(){this.emit("reconnect"),this._setupStream()},y.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0&&(this.reconnecting||(this.emit("offline"),this.reconnecting=!0),e.reconnectTimer=setInterval((function(){e._reconnect()}),e.options.reconnectPeriod))},y.prototype._clearReconnect=function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},y.prototype._cleanUp=function(e,t){var r=arguments[2];if(t&&this.stream.on("close",t),e)0===this.options.reconnectPeriod&&this.options.clean&&m(this.outgoing),this.stream.destroy();else{var n=l({cmd:"disconnect"},r);this._sendPacket(n,h.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(this.stream.removeListener("close",t),t())},y.prototype._sendPacket=function(e,t,r){if(r=r||_,this.connected){switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void b(this,e,t,r);default:return void g(this,e,t)}switch(e.qos){case 2:case 1:b(this,e,t,r);break;case 0:default:g(this,e,t)}}else this._storePacket(e,t,r)},y.prototype._storePacket=function(e,t,r){r=r||_,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},y.prototype._setupPingTimer=function(){var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=u((function(){e._checkPing()}),1e3*this.options.keepalive))},y.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},y.prototype._checkPing=function(){this.pingResp?(this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):this._cleanUp(!0)},y.prototype._handlePingresp=function(){this.pingResp=!0},y.prototype._handleConnack=function(e){var t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=e.properties.topicAliasMaximum),e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)),0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){var n=new Error("Connection refused: "+d[r]);n.code=r,this.emit("error",n)}},y.prototype._handlePublish=function(e,t){t="undefined"!==typeof t?t:_;var r=e.topic.toString(),n=e.payload,i=e.qos,o=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];switch(i){case 2:a.customHandleAcks(r,n,e,(function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===c.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:o,reasonCode:n},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:o},t)})))}));break;case 1:a.customHandleAcks(r,n,e,(function(i,a){return i instanceof Error||(a=i,i=null),i?s.emit("error",i):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:o,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,n,e),this.handleMessage(e,t)}},y.prototype.handleMessage=function(e,t){t()},y.prototype._handleAck=function(e){var t,r=e.messageId,n=e.cmd,i=null,o=this.outgoing[r]?this.outgoing[r].cb:null,s=this;if(o){switch(n){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+d[a])).code=a,o(t,e)),delete this.outgoing[r],this.outgoingStore.del(e,o);break;case"pubrec":i={cmd:"pubrel",qos:2,messageId:r};var c=e.reasonCode;c&&c>0&&16!==c?((t=new Error("Publish error: "+d[c])).code=c,o(t,e)):this._sendPacket(i);break;case"suback":delete this.outgoing[r];for(var u=0;u0)if(this.options.resubscribe)if(5===this.options.protocolVersion)for(var r=0;r=31||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r("RU6O")(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this,r("8oxB"))},"5R+2":function(e,t){e.exports=function(e,t,r){for(var n=(2<>8,0),t.writeUInt8(255&e,1),t}e.exports={cache:i,generateCache:function(){for(var e=0;e<65536;e++)i[e]=o(e)},generateNumber:o,genBufVariableByteInt:function(e){var t=0,r=0,i=function(e){return e>=0&&e<128?1:e>=128&&e<16384?2:e>=16384&&e<2097152?3:e>=2097152&&e<268435456?4:0}(e),o=n.allocUnsafe(i);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),o.writeUInt8(t,r++)}while(e>0);return{data:o,length:i}},generate4ByteBuffer:function(e){var t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},A10f:function(e,t,r){(t=e.exports=r("hfij")).Stream=t,t.Readable=t,t.Writable=r("E6id"),t.Duplex=r("vj/L"),t.Transform=r("PKL7"),t.PassThrough=r("cFgR")},Be78:function(e,t,r){"use strict";var n=r(10);e.exports=function(e,t){var r,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",r=t.port,i=t.hostname,n.createConnection(r,i)}},E6id:function(e,t,r){"use strict";(function(t,n,i){var o=r("lm0R");function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=_;var a,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:o.nextTick;_.WritableState=b;var u=Object.create(r("Onz0"));u.inherits=r("P7XM");var p={deprecate:r("t9FE")},l=r("nt6u"),h=r("hwdV").Buffer,f=i.Uint8Array||function(){};var d,g=r("7bOu");function m(){}function b(e,t){a=a||r("vj/L"),e=e||{};var n=t instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,p=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:p,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),E(e,t))}(e,r,n,t,i);else{var s=S(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?c(v,e,r,s,i):v(e,r,s,i)}}(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 s(this)}function _(e){if(a=a||r("vj/L"),!d.call(_,this)&&!(this instanceof a))return new _(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"===typeof e.write&&(this._write=e.write),"function"===typeof e.writev&&(this._writev=e.writev),"function"===typeof e.destroy&&(this._destroy=e.destroy),"function"===typeof e.final&&(this._final=e.final)),l.call(this)}function y(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function v(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,y(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,p=r.encoding,l=r.callback;if(y(e,t,!1,t.objectMode?1:u.length,u,p,l),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function k(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)}))}function E(e,t){var r=S(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"===typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(k,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(_,l),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:p.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"===typeof Symbol&&Symbol.hasInstance&&"function"===typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(_,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===_&&(e&&e._writableState instanceof b)}})):d=function(e){return e instanceof this},_.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},_.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=e,h.isBuffer(n)||n instanceof f);return a&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"===typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!==typeof r&&(r=m),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"===typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!==typeof t||(t=h.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(_.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),_.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},_.prototype._writev=null,_.prototype.end=function(e,t,r){var n=this._writableState;"function"===typeof e?(r=e,e=null,t=null):"function"===typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(_.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),_.prototype.destroy=g.destroy,_.prototype._undestroy=g.undestroy,_.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r("8oxB"),r("URgk").setImmediate,r("yLpj"))},Fng5:function(e,t,r){"use strict";var n=r("hwdV").Buffer,i=r(7);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=o,i=a,t.copy(r,i),a+=s.data.length,s=s.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},H612:function(e,t,r){"use strict";var n=r("Uelk"),i=r("P7XM"),o=r("fiWp").EventEmitter,s=r("p8mi"),a=r("solC"),c=r("5Px2")("mqtt-packet:parser");function u(e){if(!(this instanceof u))return new u(e);this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState()}i(u,o),u.prototype._resetState=function(){c("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new s,this.error=null,this._list=n(),this._stateCounter=0},u.prototype.parse=function(e){for(this.error&&this._resetState(),this._list.append(e),c("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,c("parse: state complete. _stateCounter is now: %d",this._stateCounter),c("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return c("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length},u.prototype._parseHeader=function(){var e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!==(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!==(e&a.DUP_MASK),c("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0},u.prototype._parseLength=function(){var e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),c("_parseLength %d",e.value),!!e},u.prototype._parsePayload=function(){c("_parsePayload: payload %O",this._list);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._parseConfirmation();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":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return c("_parsePayload complete result: %s",e),e},u.prototype._parseConnect=function(){var e,t,r,n,i,o;c("_parseConnect");var s={},u=this.packet;if(null===(e=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==e&&"MQIsdp"!==e)return this._emitError(new Error("Invalid protocolId"));if(u.protocolId=e,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(u.protocolVersion=this._list.readUInt8(this._pos),3!==u.protocolVersion&&4!==u.protocolVersion&&5!==u.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,s.will&&(u.will={},u.will.retain=0!==(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),u.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),u.clean=0!==(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,u.keepalive=this._parseNum(),-1===u.keepalive)return this._emitError(new Error("Packet too short"));if(5===u.protocolVersion){var p=this._parseProperties();Object.getOwnPropertyNames(p).length&&(u.properties=p)}if(null===(t=this._parseString()))return this._emitError(new Error("Packet too short"));if(u.clientId=t,c("_parseConnect: packet.clientId: %s",u.clientId),s.will){if(5===u.protocolVersion){var l=this._parseProperties();Object.getOwnPropertyNames(l).length&&(u.will.properties=l)}if(null===(r=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(u.will.topic=r,c("_parseConnect: packet.will.topic: %s",u.will.topic),null===(n=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));u.will.payload=n,c("_parseConnect: packet.will.paylaod: %s",u.will.payload)}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));u.username=o,c("_parseConnect: packet.username: %s",u.username)}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));u.password=i}return this.settings=u,c("_parseConnect: complete"),u},u.prototype._parseConnack=function(){c("_parseConnack");var e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}c("_parseConnack: complete")},u.prototype._parsePublish=function(){c("_parsePublish");var e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),c("_parsePublish: payload from buffer list: %o",e.payload)}},u.prototype._parseSubscribe=function(){c("_parseSubscribe");var e,t,r,n,i,o,s,u=this.packet;if(1!==u.qos)return this._emitError(new Error("Wrong subscribe header"));if(u.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){var p=this._parseProperties();Object.getOwnPropertyNames(p).length&&(u.properties=p)}for(;this._pos=u.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=(t=this._parseByte())&a.SUBSCRIBE_OPTIONS_QOS_MASK,o=0!==(t>>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK),i=0!==(t>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK),n=t>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,s={topic:e,qos:r},5===this.settings.protocolVersion&&(s.nl=o,s.rap=i,s.rh=n),c("_parseSubscribe: push subscription `%s` to subscription",s),u.subscriptions.push(s)}}},u.prototype._parseSuback=function(){c("_parseSuback");var e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos2&&(e.reasonCode=this._parseByte(),c("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)),e.length>3)){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0},u.prototype._parseDisconnect=function(){var e=this.packet;if(c("_parseDisconnect"),5===this.settings.protocolVersion){e.reasonCode=this._parseByte();var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return c("_parseDisconnect result: true"),!0},u.prototype._parseAuth=function(){c("_parseAuth");var e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();var t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),c("_parseAuth: result: true"),!0},u.prototype._parseMessageId=function(){var e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(c("_parseMessageId: packet.messageId %d",e.messageId),!0)},u.prototype._parseString=function(e){var t,r=this._parseNum(),n=r+this._pos;return-1===r||n>this._list.length||n>this.packet.length?null:(t=this._list.toString("utf8",this._pos,n),this._pos+=r,c("_parseString: result: %s",t),t)},u.prototype._parseStringPair=function(){return c("_parseStringPair"),{name:this._parseString(),value:this._parseString()}},u.prototype._parseBuffer=function(){var e,t=this._parseNum(),r=t+this._pos;return-1===t||r>this._list.length||r>this.packet.length?null:(e=this._list.slice(this._pos,r),this._pos+=t,c("_parseBuffer: result: %o",e),e)},u.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var e=this._list.readUInt16BE(this._pos);return this._pos+=2,c("_parseNum: result: %s",e),e},u.prototype._parse4ByteNum=function(){if(this._list.length-this._pos<4)return-1;var e=this._list.readUInt32BE(this._pos);return this._pos+=4,c("_parse4ByteNum: result: %s",e),e},u.prototype._parseVarByteNum=function(e){c("_parseVarByteNum");for(var t,r=0,n=1,i=0,o=!0,s=this._pos?this._pos:0;r<5&&(i+=n*((t=this._list.readUInt8(s+r++))&a.LENGTH_MASK),n*=128,0!==(t&a.LENGTH_FIN_MASK));)if(this._list.length<=r){o=!1;break}return s&&(this._pos+=r),c("_parseVarByteNum: result: %o",o=!!o&&(e?{bytes:r,value:i}:i)),o},u.prototype._parseByte=function(){var e=this._list.readUInt8(this._pos);return this._pos++,c("_parseByte: result: %o",e),e},u.prototype._parseByType=function(e){switch(c("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}},u.prototype._parseProperties=function(){c("_parseProperties");for(var e=this._parseVarByteNum(),t=this._pos+e,r={};this._pos=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var a=typeof e;if("string"===a&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*i;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===a&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return s(e,t,o,"day");if(t>=i)return s(e,t,i,"hour");if(t>=n)return s(e,t,n,"minute");if(t>=r)return s(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},cFgR:function(e,t,r){"use strict";e.exports=o;var n=r("PKL7"),i=Object.create(r("Onz0"));function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}i.inherits=r("P7XM"),i.inherits(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},cTUk:function(e,t,r){"use strict";var n=r("solC"),i=r("hwdV").Buffer,o=i.allocUnsafe(0),s=i.from([0]),a=r("8Mu8"),c=r("lm0R").nextTick,u=r("5Px2")("mqtt-packet:writeToStream"),p=a.cache,l=a.generateNumber,h=a.generateCache,f=a.genBufVariableByteInt,d=a.generate4ByteBuffer,g=k,m=!0;function b(e,t,r){switch(u("generate called"),t.cork&&(t.cork(),c(_,t)),m&&(m=!1,h()),u("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t,r){var o=e||{},s=o.protocolId||"MQTT",a=o.protocolVersion||4,c=o.will,u=o.clean,p=o.keepalive||0,l=o.clientId||"",h=o.username,f=o.password,d=o.properties;void 0===u&&(u=!0);var m=0;if(!s||"string"!==typeof s&&!i.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;m+=s.length+2;if(3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;m+=1;if("string"!==typeof l&&!i.isBuffer(l)||!l&&4!==a||!l&&!u){if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*u===0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}else m+=l.length+2;if("number"!==typeof p||p<0||p>65535||p%1!==0)return t.emit("error",new Error("Invalid keepalive")),!1;m+=2;if(m+=1,5===a){var b=C(t,d);m+=b.length}if(c){if("object"!==typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!==typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(m+=i.byteLength(c.topic)+2,m+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"===typeof c.payload?m+=i.byteLength(c.payload):m+=c.payload.length}var _={};5===a&&(_=C(t,c.properties),m+=_.length)}var y=!1;if(null!=h){if(!O(h))return t.emit("error",new Error("Invalid username")),!1;y=!0,m+=i.byteLength(h)+2}if(null!=f){if(!y)return t.emit("error",new Error("Username is required to use password")),!1;if(!O(f))return t.emit("error",new Error("Invalid password")),!1;m+=A(f)+2}t.write(n.CONNECT_HEADER),v(t,m),I(t,s),t.write(4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);var S=0;S|=null!=h?n.USERNAME_MASK:0,S|=null!=f?n.PASSWORD_MASK:0,S|=c&&c.retain?n.WILL_RETAIN_MASK:0,S|=c&&c.qos?c.qos<0&&g(t,f);null!=b&&b.write();return u("publish: payload: %o",h),t.write(h)}(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,r){var o=r?r.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,u=s.dup&&"pubrel"===a?n.DUP_MASK:0,p=0,l=s.reasonCode,h=s.properties,f=5===o?3:2;"pubrel"===a&&(p=1);if("number"!==typeof c)return t.emit("error",new Error("Invalid messageId")),!1;var d=null;if(5===o&&"object"===typeof h){if(!(d=P(t,h,r,f)))return!1;f+=d.length}t.write(n.ACKS[a][p][u][0]),v(t,f),g(t,c),5===o&&t.write(i.from([l]));null!==d&&d.write();return!0}(e,t,r);case"subscribe":return function(e,t,r){u("subscribe: packet: ");var o=r?r.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,p=s.subscriptions,l=s.properties,h=0;if("number"!==typeof c)return t.emit("error",new Error("Invalid messageId")),!1;h+=2;var f=null;5===o&&(f=C(t,l),h+=f.length);if("object"!==typeof p||!p.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(var d=0;d2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}h+=i.byteLength(m)+2+1}u("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),t.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),v(t,h),g(t,c),null!==f&&f.write();for(var y=!0,S=0;So;){var a=i.shift();if(!a||!t[a])return!1;delete t[a],s=C(e,t)}return s}function M(e,t,r){switch(n.propertiesTypes[t]){case"byte":e.write(i.from([n.properties[t]])),e.write(i.from([+r]));break;case"int8":e.write(i.from([n.properties[t]])),e.write(i.from([r]));break;case"binary":e.write(i.from([n.properties[t]])),I(e,r);break;case"int16":e.write(i.from([n.properties[t]])),g(e,r);break;case"int32":e.write(i.from([n.properties[t]])),function(e,t){var r=d(t);u("write4ByteNumber: %o",r),e.write(r)}(e,r);break;case"var":e.write(i.from([n.properties[t]])),v(e,r);break;case"string":e.write(i.from([n.properties[t]])),w(e,r);break;case"pair":Object.getOwnPropertyNames(r).forEach((function(o){var s=r[o];Array.isArray(s)?s.forEach((function(r){e.write(i.from([n.properties[t]])),S(e,o.toString(),r.toString())})):(e.write(i.from([n.properties[t]])),S(e,o.toString(),s.toString()))}));break;default:return e.emit("error",new Error("Invalid property "+t+" value: "+r)),!1}}function T(e,t,r){for(var n in v(e,r),t)if(t.hasOwnProperty(n)&&null!==t[n]){var i=t[n];if(Array.isArray(i))for(var o=0;o0?("string"===typeof t||s.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):I(e,s)):w(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function k(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(E,e):E(e))}function E(e){f("emit readable"),e.emit("readable"),T(e)}function I(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(C,e,t))}function C(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=u.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function O(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(x,t,e))}function x(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?O(this):k(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&O(this),null;var n,i=t.needReadable;return f("need readable",i),(0===t.length||t.length-e0?A(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&O(this)),null!==n&&this.emit("data",n),n},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,f("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?p:y;function u(t,n){f("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,f("cleanup"),e.removeListener("close",b),e.removeListener("finish",_),e.removeListener("drain",l),e.removeListener("error",m),e.removeListener("unpipe",u),r.removeListener("end",p),r.removeListener("end",y),r.removeListener("data",g),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function p(){f("onend"),e.end()}o.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",u);var l=function(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,T(e))}}(r);e.on("drain",l);var h=!1;var d=!1;function g(t){f("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==R(o.pipes,e))&&!h&&(f("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function m(t){f("onerror",t),y(),e.removeListener("error",m),0===a(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",_),y()}function _(){f("onfinish"),e.removeListener("close",b),y()}function y(){f("unpipe"),r.unpipe(e)}return r.on("data",g),function(e,t,r){if("function"===typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",m),e.once("close",b),e.once("finish",_),e.emit("pipe",r),o.flowing||(f("pipe resume"),r.resume()),e},y.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o