1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3420],{3139:e=>{function t(e,t,r,n){return Math.round(e/r)+" "+n+(t>=1.5*r?"s":"")}e.exports=function(e,r){r=r||{};var n,i,o,s,a=typeof e;if("string"===a&&e.length>0){var l=e;if(!((l=String(l)).length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(u){var c=parseFloat(u[1]);switch((u[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*c;case"weeks":case"week":case"w":return 6048e5*c;case"days":case"day":case"d":return 864e5*c;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*c;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*c;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:break}}}return}if("number"===a&&isFinite(e)){return r.long?(i=Math.abs(n=e))>=864e5?t(n,i,864e5,"day"):i>=36e5?t(n,i,36e5,"hour"):i>=6e4?t(n,i,6e4,"minute"):i>=1e3?t(n,i,1e3,"second"):n+" ms":(s=Math.abs(o=e))>=864e5?Math.round(o/864e5)+"d":s>=36e5?Math.round(o/36e5)+"h":s>=6e4?Math.round(o/6e4)+"m":s>=1e3?Math.round(o/1e3)+"s":o+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},3140:(e,t,r)=>{"use strict";var n=r(65364);let i=r(95284).EventEmitter,o=r(19092),s=r(70174),a=r(72924),l=r(42560),u=r(43002),c=r(8121).Writable,h=r(93570),p=r(31175),f=r(7367),d=r(70145),g=r(49078),b=r(71673)("mqttjs:client"),m=n?n.nextTick:function(e){setTimeout(e,0)},y=r.g.setImmediate||function(e){m(e)},_={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},v={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 invali
1d",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 w(e,t){let r;t.properties&&(r=t.properties.topicAlias);let n=t.topic.toString();if(0===n.length)if(void 0===r)return Error("Unregistered Topic Alias");else{if(void 0===(n=e.topicAliasSend.getTopicByAlias(r)))return Error("Unregistered Topic Alias");t.topic=n}r&&delete t.properties.topicAlias}function S(e,t,r){b("sendPacket :: packet: %O",t),b("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),b("sendPacket :: writing to stream");let n=l.writeToStream(t,e.stream,e.options);b("sendPacket :: writeToStream result %s",n),!n&&r&&r!==E?(b("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(b("sendPacket :: invoking cb"),r())}function k(e,t,r,n){let i;b("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let o=t;if("publish"===o.cmd&&(i=w(e,o=f(t))))return r&&r(i);e.outgoingStore.put(o,function(i){if(i)return r&&r(i);n(),S(e,t,r)})}function E(e){b("nop ::",e)}function I(e,t){let r,n=this;if(!(this instanceof I))return new I(e,t);for(r in this.options=t||{},_)void 0===this.options[r]?this.options[r]=_[r]:this.options[r]=t[r];b("MqttClient :: options.protocol",t.protocol),b("MqttClient :: options.protocolVersion",t.protocolVersion),b("MqttClient :: options.username",t.username),b("MqttClient :: options.keepalive",t.keepalive),b("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),b("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),b("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),b("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new u:this.options.messageIdProvider,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._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?b("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",function(){let e=this.queue;b("connect :: sending queued packets"),function t(){let r=e.shift();b("deliver :: entry %o",r);let i=null;if(!r)return void n._resubscribe();b("deliver :: call _sendPacket for %o",i=r.packet);let o=!0;i.messageId&&0!==i.messageId&&!n.messageIdProvider.register(i.messageId)&&(o=!1),o?n._sendPacket(i,function(e){r.cb&&r.cb(e),t()}):(b("messageId: %d has already used. The message is skipped and removed.",i.messageId),t())}()}),this.on("close",function(){b("close :: connected set to `false`"),this.connected=!1,b("close :: clearing connackTimer"),clearTimeout(this.connackTimer),b("close :: clearing ping timer"),null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),b("close :: calling _setupReconnect"),this._setupReconnect()}),i.call(this),b("MqttClient :: setting up stream"),this._setupStream()}h(I,i),I.prototype._setupStream=function(){let e=this,t=new c,r=l.parser(this.options),n=null,i=[];function o(){if(i.length)m(s);else{let e=n;n=null,e()}}function s(){b("work :: getting next packet in queue");let t=i.shift();if(t)b("work :: packet pulled from queue"),e._handlePacket(t,o);else{b("work :: no packets in queue");let e=n;n=null,b("work :: done flag is %s",!!e),e&&e()}}b("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),b("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",function(e){b("parser :: on packet push to packets array."),i.push(e)}),t._write=function(e,t,i){n=i,b("writable stream :: parsing buffer"),r.parse(e),s()},b("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",function(t){b("streamErrorHandler :: error",t.message),t.code?(b
1("streamErrorHandler :: emitting error"),e.emit("error",t)):E(t)}),this.stream.on("close",function(){var t;b("(%s)stream :: on close",e.options.clientId),(t=e.outgoing)&&(b("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(t).forEach(function(e){t[e].volatile&&"function"==typeof t[e].cb&&(t[e].cb(Error("Connection closed")),delete t[e])})),b("stream: emit close to MqttClient"),e.emit("close")}),b("_setupStream: sending packet `connect`");let a=Object.create(this.options);if(a.cmd="connect",this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),S(this,a),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end(()=>this.emit("error",Error("Packet has no Authentication Method"))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&S(this,g({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){b("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)},this.options.connectTimeout)},I.prototype._handlePacket=function(e,t){let r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(b("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},I.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==E?e(Error("client disconnecting")):this.emit("error",Error("client disconnecting"))),this.disconnecting},I.prototype.publish=function(e,t,r,n){b("publish :: message `%s` to topic `%s`",t,e);let i=this.options;if("function"==typeof r&&(n=r,r=null),r=g({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(n))return this;let o=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&null===(s=o._nextId()))return b("No messageId left"),!1;let a={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===i.protocolVersion&&(a.properties=r.properties),b("publish :: qos",r.qos),r.qos){case 1:case 2:o.outgoing[a.messageId]={volatile:!1,cb:n||E},b("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,void 0,r.cbStorePut);break;default:b("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,n,r.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:n}),this},I.prototype.subscribe=function(){let e=this,t=Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=[],n=t.shift(),i=n.resubscribe,o=t.pop()||E,s=t.pop(),a=this.options.protocolVersion;delete n.resubscribe,"string"==typeof n&&(n=[n]),"function"!=typeof o&&(s=o,o=E);let l=d.validateTopics(n);if(null!==l)return y(o,Error("Invalid topic "+l)),this;if(this._checkDisconnecting(o))return b("subscribe: discconecting true"),this;let u={qos:0};if(5===a&&(u.nl=!1,u.rap=!1,u.rh=0),s=g(u,s),Array.isArray(n)?n.forEach(function(t){if(b("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||i){let e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),b("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),r.push(e)}}
1):Object.keys(n).forEach(function(t){if(b("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<n[t].qos||i){let e={topic:t,qos:n[t].qos};5===a&&(e.nl=n[t].nl,e.rap=n[t].rap,e.rh=n[t].rh,e.properties=s.properties),b("subscribe: pushing `%s` to subs list",e),r.push(e)}}),!r.length)return o(null,[]),this;let c=function(){let t=e._nextId();if(null===t)return b("No messageId left"),!1;let n={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(n.properties=s.properties),e.options.resubscribe){b("subscribe :: resubscribe true");let t=[];r.forEach(function(r){if(e.options.reconnectPeriod>0){let n={qos:r.qos};5===a&&(n.nl=r.nl||!1,n.rap=r.rap||!1,n.rh=r.rh||0,n.properties=r.properties),e._resubscribeTopics[r.topic]=n,t.push(r.topic)}}),e.messageIdToTopic[n.messageId]=t}return e.outgoing[n.messageId]={volatile:!0,cb:function(e,t){if(!e){let e=t.granted;for(let t=0;t<e.length;t+=1)r[t].qos=e[t]}o(e,r)}},b("subscribe :: call _sendPacket"),e._sendPacket(n),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!c())&&this._storeProcessingQueue.push({invoke:c,callback:o}),this},I.prototype.unsubscribe=function(){let e=this,t=Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=t.shift(),n=t.pop()||E,i=t.pop();"string"==typeof r&&(r=[r]),"function"!=typeof n&&(i=n,n=E);let o=d.validateTopics(r);if(null!==o)return y(n,Error("Invalid topic "+o)),this;if(e._checkDisconnecting(n))return this;let s=function(){let t=e._nextId();if(null===t)return b("No messageId left"),!1;let o={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof r?o.unsubscriptions=[r]:Array.isArray(r)&&(o.unsubscriptions=r),e.options.resubscribe&&o.unsubscriptions.forEach(function(t){delete e._resubscribeTopics[t]}),"object"==typeof i&&i.properties&&(o.properties=i.properties),e.outgoing[o.messageId]={volatile:!0,cb:n},b("unsubscribe: call _sendPacket"),e._sendPacket(o),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:n}),this},I.prototype.end=function(e,t,r){let n=this;function i(){b("end :: closeStores: closing incoming and outgoing stores"),n.disconnected=!0,n.incomingStore.close(function(e){n.outgoingStore.close(function(t){b("end :: closeStores: emitting end"),n.emit("end"),r&&(b("end :: closeStores: invoking callback with args"),r(e||t))})}),n._deferredReconnect&&n._deferredReconnect()}function o(){b("end :: (%s) :: finish :: calling _cleanUp with force %s",n.options.clientId,e),n._cleanUp(e,()=>{b("end :: finish :: calling process.nextTick on closeStores"),m(i.bind(n))},t)}return(b("end :: (%s)",this.options.clientId),(null==e||"boolean"!=typeof e)&&(r=t||E,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=E))),"object"!=typeof t&&(r=t,t=null),b("end :: cb? %s",!!r),r=r||E,this.disconnecting)?r():(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(b("end :: (%s) :: calling finish in 10ms once outgoing is empty",n.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(b("end :: (%s) :: immediately calling finish",n.options.clientId),o())),this},I.prototype.removeOutgoingMessage=function(e){let t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},function(){t(Error("Message removed"))}),this},I.prototype.reconnect=function(e){b("client reconnect");let 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},I.prototype._reconnect=function(){b("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),b("client already connected. disconnecting first.")):(b("_reconnect: calling _setupStream"),this._setupStream())},I.prototype._setupReconnect=function(){let e=this;e.disconnecting||e.reconnectTimer||!(e.options.reconnectPeriod>0)?b("_setupReconnect :: doing nothing..."):(this.reconnecting||(b("_setupReconnect :: emit `offline` state"),this.emit
1("offline"),b("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),b("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval(function(){b("reconnectTimer :: reconnect triggered!"),e._reconnect()},e.options.reconnectPeriod))},I.prototype._clearReconnect=function(){b("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},I.prototype._cleanUp=function(e,t){let r=arguments[2];if(t&&(b("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),b("_cleanUp :: forced? %s",e),e){var n;0===this.options.reconnectPeriod&&this.options.clean&&(n=this.outgoing)&&(b("flush: queue exists? %b",!!n),Object.keys(n).forEach(function(e){"function"==typeof n[e].cb&&(n[e].cb(Error("Connection closed")),delete n[e])})),b("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy()}else{let e=g({cmd:"disconnect"},r);b("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,y.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(b("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(b("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(b("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},I.prototype._sendPacket=function(e,t,r){b("_sendPacket :: (%s) :: start",this.options.clientId),r=r||E,t=t||E;let n=function(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let r;t.properties&&(r=t.properties.topicAlias);let n=t.topic.toString();if(e.topicAliasSend)if(r){if(0!==n.length&&(b("applyTopicAlias :: register topic: %s - alias: %d",n,r),!e.topicAliasSend.put(n,r)))return b("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),Error("Sending Topic Alias out of range")}else 0!==n.length&&(e.options.autoAssignTopicAlias?(r=e.topicAliasSend.getAliasByTopic(n))?(t.topic="",t.properties={...t.properties,topicAlias:r},b("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",n,r)):(r=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(n,r),t.properties={...t.properties,topicAlias:r},b("applyTopicAlias :: auto assign topic: %s - alias: %d",n,r)):e.options.autoUseTopicAlias&&(r=e.topicAliasSend.getAliasByTopic(n))&&(t.topic="",t.properties={...t.properties,topicAlias:r},b("applyTopicAlias :: auto use topic: %s - alias: %d",n,r)));else if(r)return b("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),Error("Sending Topic Alias out of range")}}(this,e);if(n)return void t(n);if(!this.connected){if("auth"===e.cmd){this._shiftPingInterval(),S(this,e,t);return}b("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(e,t,r);return}switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":k(this,e,t,r);return;default:S(this,e,t);return}switch(e.qos){case 2:case 1:k(this,e,t,r);break;default:S(this,e,t)}b("_sendPacket :: (%s) :: end",this.options.clientId)},I.prototype._storePacket=function(e,t,r){b("_storePacket :: packet: %o",e),b("_storePacket :: cb? %s",!!t),r=r||E;let n=e;if("publish"===n.cmd){let r=w(this,n=f(e));if(r)return t&&t(r)}0===(n.qos||0)&&this.queueQoSZero||"publish"!==n.cmd?this.queue.push({packet:n,cb:t}):n.qos>0?(t=this.outgoing[n.messageId]?this.outgoing[n.messageId].cb:null,this.outgoingStore.put(n,function(e){if(e)return t&&t(e);r()})):t&&t(Error("No connection to broker"))},I.prototype._setupPingTimer=function(){b("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);let e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=p(function(){e._checkPing()},1e3*this.options.keepalive))},I.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},I.prototype._checkPing=function(){b("_checkPing :: checking ping..."),this.pingResp?(b("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(b("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},I.prototype._handlePingresp=function(){this.pingResp=!0},I.prototype._handleConnack=function(e){b("_handleConnack");let t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>
165535)return void this.emit("error",Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(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)}if(0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){let e=Error("Connection refused: "+v[r]);e.code=r,this.emit("error",e)}},I.prototype._handleAuth=function(e){let t=this.options.protocolVersion,r=5===t?e.reasonCode:e.returnCode;if(5!==t){let e=Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);e.code=r,this.emit("error",e);return}let n=this;this.handleAuth(e,function(e,t){if(e)return void n.emit("error",e);if(24===r)n.reconnecting=!1,n._sendPacket(t);else{let t=Error("Connection refused: "+v[r]);e.code=r,n.emit("error",t)}})},I.prototype.handleAuth=function(e,t){t()},I.prototype._handlePublish=function(e,t){b("_handlePublish: packet %o",e),t=void 0!==t?t:E;let r=e.topic.toString(),n=e.payload,i=e.qos,o=e.messageId,s=this,a=this.options,l=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===r.length)if(t>0&&t<=65535){let e=this.topicAliasRecv.getTopicByAlias(t);if(e)b("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r=e,t);else{b("_handlePublish :: unregistered topic alias. alias: %d",t),this.emit("error",Error("Received unregistered Topic Alias"));return}}else{b("_handlePublish :: topic alias out of range. alias: %d",t),this.emit("error",Error("Received Topic Alias is out of range"));return}else if(this.topicAliasRecv.put(r,t))b("_handlePublish :: registered topic: %s - alias: %d",r,t);else{b("_handlePublish :: topic alias out of range. alias: %d",t),this.emit("error",Error("Received Topic Alias is out of range"));return}}switch(b("_handlePublish: qos %d",i),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===l.indexOf(n)?s.emit("error",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===l.indexOf(a)?s.emit("error",Error("Wrong reason code for puback")):void(!a&&s.emit("message",r,n,e),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);break;default:b("_handlePublish: unknown QoS. Doing nothing.")}},I.prototype.handleMessage=function(e,t){t()},I.prototype._handleAck=function(e){let t,r=e.messageId,n=e.cmd,i=null,o=this.outgoing[r]?this.outgoing[r].cb:null,s=this;if(!o)return void b("_handleAck :: Server sent an ack in error. Ignoring.");switch(b("_handleAck :: packet type",n),n){case"pubcomp":case"puback":{let n=e.reasonCode;n&&n>0&&16!==n&&((t=Error("Publish error: "+v[n])).code=n,o(t,e)),delete this.outgoing[r],this.outgoingStore.del(e,o),this.messageIdProvider.deallocate(r),this._invokeStoreProcessingQueue();break}case"pubrec":{i={cmd:"pubrel",qos:2,messageId:r};let n=e.reasonCode;n&&n>0&&16!==n?((t=Error("Publish error: "+v[n])).code=n,o(t,e)):this._sendPacket(i);break}case"suback":delete this.outgoing[r],this.messageIdProvider.deallocate(r);for(let t=0;t<e.granted.length;t++)if((128&e.granted[t])!=0){let e=this.messageIdToTopic[r];e&&e.forEach(function(e){delete s._resubscribeTopics[e]})}this._invokeStoreProcessingQueue(),o(null,e);break;case"unsuback":delete this.outgoing[r],this.messageIdProvider.deallocate(r),this._invokeStoreProcessingQueue(),o(null);break;default:s.emit("error",Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")},I.prototype._handlePubrel=function(e,t){b("handling pubrel packet"),t=void 0!==t?t:E;let r=e.messageId,n=this,i={cmd:"pubcomp",messageId:r};n.incomingStore.get(e,function(e,r){e?n._sendPacket(i,t):(n.emit("message",r.topic,r.payload,r),n.handleMessage(r,function(e){if(e)return t(e);n.incomingStore.del(r,E),n._sendPacket(i,t)}))})}
1,I.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},I.prototype._nextId=function(){return this.messageIdProvider.allocate()},I.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},I.prototype._resubscribe=function(){b("_resubscribe");let e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){b("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){let r={};r[e[t]]=this._resubscribeTopics[e[t]],r.resubscribe=!0,this.subscribe(r,{properties:r[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},I.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);let t=this;this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,!function r(){let n=t.outgoingStore.createStream();function i(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function o(){n.destroy(),n=null,t._flushStoreProcessingQueue(),i()}t.once("close",o),n.on("error",function(e){i(),t._flushStoreProcessingQueue(),t.removeListener("close",o),t.emit("error",e)}),n.on("end",function(){let n=!0;for(let e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){n=!1;break}n?(i(),t.removeListener("close",o),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):r()}),function e(){let r;if(!n)return;t._storeProcessing=!0;let i=n.read(1);return i?t._packetIdsDuringStoreProcessing[i.messageId]?void e():void(t.disconnecting||t.reconnectTimer?n.destroy&&n.destroy():(r=t.outgoing[i.messageId]?t.outgoing[i.messageId].cb:null,t.outgoing[i.messageId]={volatile:!1,cb:function(t,n){r&&r(t,n),e()}},t._packetIdsDuringStoreProcessing[i.messageId]=!0,t.messageIdProvider.register(i.messageId)?t._sendPacket(i):b("messageId: %d has already used.",i.messageId))):void n.once("readable",e)}()}()},I.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){let e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},I.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},I.prototype._flushStoreProcessingQueue=function(){for(let e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(Error("Connection closed")),e.callback&&e.callback(Error("Connection closed"));this._storeProcessingQueue.splice(0)},e.exports=I},4589:(e,t,r)=>{var n=r(82909).Buffer;let i=r(89328),o=r(95284);class s extends o{constructor(){super(),this._array=Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e,t=0,r=Array(this._array.length),i=this._array,o=0;for(e=0;e<i.length&&void 0!==i[e];e++)"string"!=typeof i[e]?r[e]=i[e].length:r[e]=n.byteLength(i[e]),t+=r[e];let s=n.allocUnsafe(t);for(e=0;e<i.length&&void 0!==i[e];e++)"string"!=typeof i[e]?i[e].copy(s,o):s.write(i[e],o),o+=r[e];return s}}e.exports=function(e,t){let r=new s;return i(e,r,t),r.concat()}},7367:(e,t,r)=>{"use strict";e.exports=r(25286)()},8121:(e,t,r)=>{(t=e.exports=r(27690)).Stream=t,t.Readable=t,t.Writable=r(91190),t.Duplex=r(75968),t.Transform=r(12682),t.PassThrough=r(57292),t.finished=r(97212),t.pipeline=r(72802)},10311:(e,t,r)=>{var n=r(82909).Buffer,i=r(65364),o=r(8121),s=r(53655),a=r(93570),l=r(85290),u=n.from&&n.from!==Uint8Array.from?n.from([0]):new n([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},h=function(e,t){e._autoDestroy&&e.destroy(t)},p=function(e,t){return function(r){r?h(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(){},d=function(e,t,r){if(!(this instanceof d))return new d(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)}
1;a(d,o.Duplex),d.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new d(e,t,r)},d.prototype.cork=function(){1==++this._corked&&this.emit("cork")},d.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},d.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(null===e||!1===e)return void this.end();var t=this,r=s(e,{writable:!0,readable:!1},p(this,this._forwardEnd)),n=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&i.nextTick(n),this._writable=e,this._writable.on("drain",n),this._unwrite=function(){t._writable.removeListener("drain",n),r()},this.uncork()},d.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(null===e||!1===e){this.push(null),this.resume();return}var t=this,r=s(e,{writable:!1,readable:!0},p(this)),n=function(){t._forward()},i=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e),this._readable2.on("readable",n),this._readable2.on("end",i),this._unread=function(){t._readable2.removeListener("readable",n),t._readable2.removeListener("end",i),r()},this._forward()},d.prototype._read=function(){this._drained=!0,this._forward()},d.prototype._forward=function(){var e;if(!this._forwarding&&this._readable2&&this._drained){for(this._forwarding=!0;this._drained&&null!==(e=l(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},d.prototype.destroy=function(e,t){if(t||(t=f),this.destroyed)return t(null);this.destroyed=!0;var r=this;i.nextTick(function(){r._destroy(e),t(null)})},d.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},d.prototype._write=function(e,t,r){if(!this.destroyed){if(this._corked)return c(this,this._write.bind(this,e,t,r));if(e===u)return this._finish(r);if(!this._writable)return r();!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()}},d.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,function(){var r,n;r=t._forwardEnd&&t._writable,n=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)},!r||r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n())})},d.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(u),o.Writable.prototype.end.call(this,r))},e.exports=d},12483:(e,t,r)=>{"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){var n,i,s;n=e,i=t,s=r[t],(i=o(i))in n?Object.defineProperty(n,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[i]=s}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var s=r(82909).Buffer,a=r(15340).inspect,l=a&&a.custom||"inspect";e.exports=function(){var e;function t(){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");this.head=null,this.tail=null,this.length=0}return e=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,n=s.allocUnsafe(e>>>0),i=this.head,o=0;i;)t=i.data,r=o,s.prototype.copy.call(t,n,r),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:l,value:function(e,t){return a(this,i(i({},t),{},{depth:0,customInspect:!1}))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}()},12682:(e,t,r)=>{"use strict";e.exports=c;
1var n=r(98190).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,l=r(75968);function u(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function c(e){if(!(this instanceof c))return new c(e);l.call(this,e),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush(function(t,r){p(e,t,r)})}function p(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(93570)(c,l),c.prototype.push=function(e,t){return this._transformState.needTransform=!1,l.prototype.push.call(this,e,t)},c.prototype._transform=function(e,t,r){r(new i("_transform()"))},c.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},c.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},c.prototype._destroy=function(e,t){l.prototype._destroy.call(this,e,function(e){t(e)})}},13762:(e,t,r)=>{let n=r(36007);e.exports.t=n},14627:(e,t,r)=>{var n=r(82909).Buffer;let i=e.exports;for(let e in i.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},i.codes={},i.types){let t=i.types[e];i.codes[t]=e}for(let e in i.CMD_SHIFT=4,i.CMD_MASK=240,i.DUP_MASK=8,i.QOS_MASK=3,i.QOS_SHIFT=1,i.RETAIN_MASK=1,i.VARBYTEINT_MASK=127,i.VARBYTEINT_FIN_MASK=128,i.VARBYTEINT_MAX=0xfffffff,i.SESSIONPRESENT_MASK=1,i.SESSIONPRESENT_HEADER=n.from([i.SESSIONPRESENT_MASK]),i.CONNACK_HEADER=n.from([i.codes.connack<<i.CMD_SHIFT]),i.USERNAME_MASK=128,i.PASSWORD_MASK=64,i.WILL_RETAIN_MASK=32,i.WILL_QOS_MASK=24,i.WILL_QOS_SHIFT=3,i.WILL_FLAG_MASK=4,i.CLEAN_SESSION_MASK=2,i.CONNECT_HEADER=n.from([i.codes.connect<<i.CMD_SHIFT]),i.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},i.propertiesCodes={},i.properties){let t=i.properties[e];i.propertiesCodes[t]=e}function o(e){return[0,1,2].map(t=>[0,1].map(r=>[0,1].map(o=>{let s=n.alloc(1);return s.writeUInt8(i.codes[e]<<i.CMD_SHIFT|(r?i.DUP_MASK:0)|t<<i.QOS_SHIFT|o,0,!0),s})))}i.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},i.PUBLISH_HEADER=o("publish"),i.SUBSCRIBE_HEADER=o("subscribe"),i.SUBSCRIBE_OPTIONS_QOS_MASK=3,i.SUBSCRIBE_OPTIONS_NL_MASK=1,i.SUBSCRIBE_OPTIONS_NL_SHIFT=2,i.SUBSCRIBE_OPTIONS_RAP_MASK=1,i.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,i.SUBSCRIBE_OPTIONS_RH_MASK=3,i.SUBSCRIBE_OPTIONS_RH_SHIFT=4,i.SUBSCRIBE_OPTIONS_RH=[0,16,32],i.SUBSCRIBE_OPTIONS_NL=4,i.SUBSCRIBE_OPTIONS_RAP=8,i.SUBSCRIBE_OPTIONS_QOS=[0,1,2],i.UNSUBSCRIBE_HEADER=o("unsubscribe"),i.ACKS={unsuback:o("unsuback"),puback:o("puback"),pubcomp:o("pubcomp"),pubrel:o("pubrel"),pubrec:o("pubrec")},i.SUBACK_HEADER=n.from([i.codes.suback<<i.CMD_SHIFT]),i.VERSION3=n.from([3]),i.VERSION4=n.from([4]),i.VERSION5=n.from([5]),i.VERSION131=n.from([131]),i.VERSION132=n.from([132]),i.QOS=[0,1,2].map(e=>n.from([e])),i.EMPTY={pingreq:n.from([i.codes.pingreq<<4,0]),pingresp:n.from([i.codes.pingresp<<4,0]),disconnect:n.from([i.codes.disconnect<<4,0])}},15773:(e,t,r)=>{"use strict";var n=r(96081).Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){var t;if(!e)return"utf8";for(;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";
1case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=c,this.end=h,t=3;break;default:this.write=p,this.end=f;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if((192&t[0])!=128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((192&t[1])!=128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(192&t[2])!=128)return e.lastNeed=2,"�"}}(this,e,0);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length)}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function c(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){var t,r;if(0===e.length)return"";if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var r=function(e,t,r){var n=t.length-1;if(n<r)return 0;var i=s(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||-2===i?0:(i=s(t[n]))>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||-2===i?0:(i=s(t[n]))>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},16791:(e,t,r)=>{"use strict";function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach(function(e){t.push(e)});else if(arguments.length>0)for(var r=0,i=arguments.length;r<i;r++)t.push(arguments[r]);return t}function i(e,t,r,n){if(!(this instanceof i))return new i(e,t,r,n);this.list=n,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=n,n.Node=i,n.create=n,n.prototype.removeNode=function(e){if(e.list!==this)throw Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},n.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},n.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},n.prototype.push=function(){for(var e,t,r=0,n=arguments.length;r<n;r++){e=this,t=arguments[r],e.tail=new i(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}return this.length},n.prototype.unshift=function(){for(var e,t,r=0,n=arguments.length;r<n;r++){e=this,t=arguments[r],e.head=new i(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}return this.length},n.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},n.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},n.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;null!==r;n++)e.call(t,r.value,n,this),r=r.next},n.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;null!==r;n--)e.call(t,r.value,n,this),r=r.prev},n.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},n.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},n.prototype.map=function(e,t){t=t||this;for(var r=new n,i=this.head;null!==i;)r.push(e.call(t,i.value,this)),i=i.next;return r},n.prototype.mapReverse=function(e,t){t=t||this;for(var r=new n,i=this.tail;null!==i;)r.push(e.call(t,i.value,this)),i=i.prev;return r},n.prototype.reduce=function(e,t){var r,n=this.head;if(arguments.length>1)r=t;else if(this.head)n=this.head.next,r=this.head.value;else throw TypeError("Reduce of empty list with no initial value");for(var i=0;null!==n;i++)r=e(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else if(this.tail)n=this.tail.prev,r=this.tail.value;else throw TypeError("Reduce of empty list with no initial value");for(var i=this.length-1;null!==n;i--)r=e(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var e=Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},n.prototype.toArrayReverse=function(){for(var e=Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},n.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var i=0,o=this.head;null!==o&&i<e;i++)o=o.next;for(;null!==o&&i<t;i++,o=o.next)r.push(o.value);return r},n.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var i=this.length,o=this.tail;null!==o&&i>t;i--)o=o.prev;
1for(;null!==o&&i>e;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,o=this.head;null!==o&&n<e;n++)o=o.next;for(var s=[],n=0;o&&n<t;n++)s.push(o.value),o=this.removeNode(o);null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev);for(var n=0;n<r.length;n++)o=function(e,t,r){var n=t===e.head?new i(r,null,t,e):new i(r,t,t.next,e);return null===n.next&&(e.tail=n),null===n.prev&&(e.head=n),e.length++,n}(this,o,r[n]);return s},n.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=t,this.tail=e,this};try{r(95281)(n)}catch(e){}},17540:(e,t,r)=>{var n=r(82909).Buffer;let i={},o=n.isBuffer(n.from([1,2]).subarray(0,1));function s(e){let t=n.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}e.exports={cache:i,generateCache:function(){for(let e=0;e<65536;e++)i[e]=s(e)},generateNumber:s,genBufVariableByteInt:function(e){let t=0,r=0,i=n.allocUnsafe(4);do t=e%128|0,(e=e/128|0)>0&&(t|=128),i.writeUInt8(t,r++);while(e>0&&r<4);return e>0&&(r=0),o?i.subarray(0,r):i.slice(0,r)},generate4ByteBuffer:function(e){let t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},19092:(e,t,r)=>{"use strict";let n=r(49078),i=r(8121).Readable,o={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=n(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){let e=new i(o),t=[],r=!1,n=0;return this._inflights.forEach(function(e,r){t.push(e)}),e._read=function(){!r&&n<t.length?this.push(t[n++]):this.push(null)},e.destroy=function(){if(r)return;let e=this;r=!0,setTimeout(function(){e.emit("close")},0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},e.exports=a},25286:(e,t,r)=>{"use strict";var n=r(82909).Buffer;function i(e){return e instanceof n?n.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}e.exports=function(e){if((e=e||{}).circles)return function(e){let t=[],r=[],n=new Map;if(n.set(Date,e=>new Date(e)),n.set(Map,(e,t)=>new Map(s(Array.from(e),t))),n.set(Set,(e,t)=>new Set(s(Array.from(e),t))),e.constructorHandlers)for(let t of e.constructorHandlers)n.set(t[0],t[1]);let o=null;return e.proto?function e(a){if("object"!=typeof a||null===a)return a;if(Array.isArray(a))return s(a,e);if(a.constructor!==Object&&(o=n.get(a.constructor)))return o(a,e);let l={};for(let s in t.push(a),r.push(l),a){let u=a[s];if("object"!=typeof u||null===u)l[s]=u;else if(u.constructor!==Object&&(o=n.get(u.constructor)))l[s]=o(u,e);else if(ArrayBuffer.isView(u))l[s]=i(u);else{let n=t.indexOf(u);-1!==n?l[s]=r[n]:l[s]=e(u)}}return t.pop(),r.pop(),l}:function e(a){if("object"!=typeof a||null===a)return a;if(Array.isArray(a))return s(a,e);if(a.constructor!==Object&&(o=n.get(a.constructor)))return o(a,e);let l={};for(let s in t.push(a),r.push(l),a){if(!1===Object.hasOwnProperty.call(a,s))continue;let u=a[s];if("object"!=typeof u||null===u)l[s]=u;else if(u.constructor!==Object&&(o=n.get(u.constructor)))l[s]=o(u,e);else if(ArrayBuffer.isView(u))l[s]=i(u);else{let n=t.indexOf(u);-1!==n?l[s]=r[n]:l[s]=e(u)}}return t.pop(),r.pop(),l};function s(e,s){let a=Object.keys(e),l=Array(a.length);for(let u=0;u<a.length;u++){let c=a[u],h=e[c];if("object"!=typeof h||null===h)l[c]=h;else if(h.constructor!==Object&&(o=n.get(h.constructor)))l[c]=o(h,s);else if(ArrayBuffer.isView(h))l[c]=i(h);else{let e=t.indexOf(h);-1!==e?l[c]=r[e]:l[c]=s(h)}}return l}}(e);let t=new Map;if(t.set(Date,e=>new Date(e)),t.set(Map,(e,t)=>new Map(n(Array.from(e),t))),t.set(Set,(e,t)=>new Set(n(Array.from(e),t))),e.constructorHandlers)for(let r of e.constructorHandlers)t.set(r[0],r[1]);let r=null;return e.proto?function e(o){if("object"!=typeof o||null===o)return o;if(Array.isArray(o))return n(o,e);if(o.constructor!==Object&&(r=t.get(o.constructor)))return r(o,e);let s={};for(let n in o){let a=o[n];"object"!=typeof a||null===a?s[n]=a:a.constructor!==Object&&(r=t.get(a.constructor))?s[n]=r(a,e):ArrayBuffer.isView(a)?s[n]=i(a):s[n]=e(a)}return s}:function e(o){if("object"!=typeof o||null===o)return o;if(Array.isArray(o))return n(o,e);if(o.constructor!==Object&&(r=t.get(o.constructor)))return r(o,e);let s={};for(let n in o){if(!1===Object.hasOwnProperty.call(o,n))continue;let a=o[n];"object"!=typeof a||null===a?s[n]=a:a.constructor!==Object&&(r=t.get(a.constructor))?s[n]=r(a,e):ArrayBuffer.isView(a)?s[n]=i(a):s[n]=e(a)}return s};function n(e,n){let o=Object.keys(e),s=Array(o.length);for(let a=0;a<o.length;a++){let l=o[a],u=e[l];"object"!=typeof u||null===u?s[l]=u:u.constructor!==Object&&(r=t.get(u.constructor))?s[l]=r(u,n):ArrayBuffer.isView(u)?s[l]=i(u):s[l]=n(u)}return s}}},26322:(e,t,r)=>{"use strict";var n=r(65364);let{Buffer:i}=r(82909),o=r(68377),s=r(71673)("mqttjs:ws"),a=r(10311),l=r(8121).Transform,u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],c=void 0!==n&&"browser"===n.title||"function"==typeof r;function h(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function p(e){return e.hostname||(e.hostname="localhost"),e.port||("wss"===e.protocol?e.port=443:e.port=80),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={}),c||"wss"!==e.protocol||u.forEach(function(t){Object.prototype.hasOwnProperty.call(e,t)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,t)&&(e.wsOptions[t]=e[t])}),e}c?e.exports=function(e,t){let r;s("browserStreamBuilder");let n=function(e){let t=p(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw Error("Could not determine host. Specify host manually.");let e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!0!==t.binary&&void 0!==t.binary),t}(t).browserBufferSize||524288,o=t.browserBufferTimeout||1e3,u=!t.objectMode,c=function(e,t){let r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",n=new WebSocket(h(t,e),[r]);return n.binaryType="arraybuffer",n}(e,t),f=function(e,t,r){let n=new l({objectModeMode:e.objectMode});return n._write=t,n._flush=r,n}(t,function e(t,r,s){c.bufferedAmount>n&&setTimeout(e,o,t,r,s),u&&"string"==typeof t&&(t=i.from(t,"utf8"));try{c.send(t)}catch(e){return s(e)}s()},function(e){c.close(),e()});t.objectMode||(f._writev=_),f.on("close",()=>{c.close()});let d=void 0!==c.addEventListener;function g(){r.setReadable(f),r.setWritable(f),r.emit("connect")}function b(){r.end(),r.destroy()}function m(e){r.destroy(e)}function y(e){let t=e.data;t=t instanceof ArrayBuffer?i.from(t):i.from(t,"utf8"),f.push(t)}function _(e,t){let r=Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=i.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(i.concat(r),"binary",t)}return c.readyState===c.OPEN?r=f:(r=r=a(void 0,void 0,t),t.objectMode||(r._writev=_),d?c.addEventListener("open",g):c.onopen=g),r.socket=c,d?(c.addEventListener("close",b),c.addEventListener("error",m),c.addEventListener("message",y)):(c.onclose
1=b,c.onerror=m,c.onmessage=y),r}:e.exports=function(e,t){s("streamBuilder");let r=p(t),n=h(r,e),i=function(e,t,r){s("createWebSocket"),s("protocol: "+r.protocolId+" "+r.protocolVersion);let n="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return s("creating new Websocket for url: "+t+" and protocol: "+n),new o(t,[n],r.wsOptions)}(0,n,r),a=o.createWebSocketStream(i,r.wsOptions);return a.url=n,i.on("close",()=>{a.destroy()}),a}},27690:(e,t,r)=>{"use strict";var n,i,o,s,a,l=r(65364);e.exports=I,I.ReadableState=E,r(95284).EventEmitter;var u=function(e,t){return e.listeners(t).length},c=r(39389),h=r(82909).Buffer,p=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(79838);i=f&&f.debuglog?f.debuglog("stream"):function(){};var d=r(12483),g=r(67090),b=r(50677).getHighWaterMark,m=r(98190).F,y=m.ERR_INVALID_ARG_TYPE,_=m.ERR_STREAM_PUSH_AFTER_EOF,v=m.ERR_METHOD_NOT_IMPLEMENTED,w=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(93570)(I,c);var S=g.errorOrDestroy,k=["error","close","destroy","pause","resume"];function E(e,t,i){n=n||r(75968),e=e||{},"boolean"!=typeof i&&(i=t instanceof n),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=b(this,e,"readableHighWaterMark",i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(o||(o=r(15773).I),this.decoder=new o(e.encoding),this.encoding=e.encoding)}function I(e){if(n=n||r(75968),!(this instanceof I))return new I(e);var t=this instanceof n;this._readableState=new E(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function A(e,t,r,n,o){i("readableAddChunk",t);var s,a,l=e._readableState;if(null===t)l.reading=!1,function(e,t){if(i("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?P(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,x(e)))}}(e,l);else if(o||(a=function(e,t){var r;return h.isBuffer(t)||t instanceof p||"string"==typeof t||void 0===t||e.objectMode||(r=new y("chunk",["string","Buffer","Uint8Array"],t)),r}(l,t)),a)S(e,a);else if(l.objectMode||t&&t.length>0)if("string"==typeof t||l.objectMode||Object.getPrototypeOf(t)===h.prototype||(s=t,t=h.from(s)),n)l.endEmitted?S(e,new w):C(e,l,t,!0);else if(l.ended)S(e,new _);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(t=l.decoder.write(t),l.objectMode||0!==t.length?C(e,l,t,!1):R(e,l)):C(e,l,t,!1)}else n||(l.reading=!1,R(e,l));return!l.ended&&(l.length<l.highWaterMark||0===l.length)}function C(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&P(e)),R(e,t)}function T(e,t){var r;if(e<=0||0===t.length&&t.ended)return 0;if(t.objectMode)return 1;if(e!=e)if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length;return(e>t.highWaterMark&&((r=e)>=0x40000000?r=0x40000000:(r--,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r++),t.highWaterMark=r),e<=t.length)?e:t.ended?t.length:(t.needReadable=!0,0)}function P(e){var t=e._readableState;i("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(i("emitReadable",t.flowing),t.emittedReadable=!0,l.nextTick(x,e))}function x(e){var t=e._readableState;i("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,j(e)}function R(e,t){t.readingMore||(t.readingMore=!0,l.nextTick(O,e,t))}function O(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(i("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function N(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function M(e){i("readable nexttick read 0"),e.read(0)}function B(e,t){i("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),j(e),t.flowing&&!t.reading&&e.read(0)}function j(e){var t=e._readableState;for(i("flow",t.flowing);t.flowing&&null!==e.read(););}function L(e,t){var r;return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r)}function U(e){var t=e._readableState;i("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,l.nextTick(q,t,e))}function q(e,t){if(i("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function K(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return -1}Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),I.prototype.destroy=g.destroy,I.prototype._undestroy=g.undestroy,I.prototype._destroy=function(e,t){t(e)},I.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=h.from(e,t),t=""),r=!0),A(this,e,t,!1,r)},I.prototype.unshift=function(e){return A(this,e,null,!0,!1)},I.prototype.isPaused=function(){return!1===this._readableState.flowing},I.prototype.setEncoding=function(e){o||(o=r(15773).I);var t=new o(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;
1for(var n=this._readableState.buffer.head,i="";null!==n;)i+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this},I.prototype.read=function(e){i("read",e),e=parseInt(e,10);var t,r=this._readableState,n=e;if(0!==e&&(r.emittedReadable=!1),0===e&&r.needReadable&&((0!==r.highWaterMark?r.length>=r.highWaterMark:r.length>0)||r.ended))return i("read: emitReadable",r.length,r.ended),0===r.length&&r.ended?U(this):P(this),null;if(0===(e=T(e,r))&&r.ended)return 0===r.length&&U(this),null;var o=r.needReadable;return i("need readable",o),(0===r.length||r.length-e<r.highWaterMark)&&i("length less than watermark",o=!0),r.ended||r.reading?i("reading or ended",o=!1):o&&(i("do read"),r.reading=!0,r.sync=!0,0===r.length&&(r.needReadable=!0),this._read(r.highWaterMark),r.sync=!1,r.reading||(e=T(n,r))),null===(t=e>0?L(e,r):null)?(r.needReadable=r.length<=r.highWaterMark,e=0):(r.length-=e,r.awaitDrain=0),0===r.length&&(r.ended||(r.needReadable=!0),n!==e&&r.ended&&U(this)),null!==t&&this.emit("data",t),t},I.prototype._read=function(e){S(this,new v("_read()"))},I.prototype.pipe=function(e,t){var r,n=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,i("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===l.stdout||e===l.stderr?b:a;function a(){i("onend"),e.end()}o.endEmitted?l.nextTick(s):n.once("end",s),e.on("unpipe",function t(r,s){i("onunpipe"),r===n&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,i("cleanup"),e.removeListener("close",d),e.removeListener("finish",g),e.removeListener("drain",c),e.removeListener("error",f),e.removeListener("unpipe",t),n.removeListener("end",a),n.removeListener("end",b),n.removeListener("data",p),h=!0,o.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c())});var c=(r=n,function(){var e=r._readableState;i("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&u(r,"data")&&(e.flowing=!0,j(r))});e.on("drain",c);var h=!1;function p(t){i("ondata");var r=e.write(t);i("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==K(o.pipes,e))&&!h&&(i("false write response, pause",o.awaitDrain),o.awaitDrain++),n.pause())}function f(t){i("onerror",t),b(),e.removeListener("error",f),0===u(e,"error")&&S(e,t)}function d(){e.removeListener("finish",g),b()}function g(){i("onfinish"),e.removeListener("close",d),b()}function b(){i("unpipe"),n.unpipe(e)}return n.on("data",p),!function(e,t,r){if("function"==typeof e.prependListener)return e.prepe
1ndListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",f),e.once("close",d),e.once("finish",g),e.emit("pipe",n),o.flowing||(i("pipe resume"),n.resume()),e},I.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<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=K(t.pipes,e);return -1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},I.prototype.on=function(e,t){var r=c.prototype.on.call(this,e,t),n=this._readableState;return"data"===e?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"!==e||n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,i("on readable",n.length,n.reading),n.length?P(this):n.reading||l.nextTick(M,this)),r},I.prototype.addListener=I.prototype.on,I.prototype.removeListener=function(e,t){var r=c.prototype.removeListener.call(this,e,t);return"readable"===e&&l.nextTick(N,this),r},I.prototype.removeAllListeners=function(e){var t=c.prototype.removeAllListeners.apply(this,arguments);return("readable"===e||void 0===e)&&l.nextTick(N,this),t},I.prototype.resume=function(){var e,t,r=this._readableState;return r.flowing||(i("resume"),r.flowing=!r.readableListening,e=this,(t=r).resumeScheduled||(t.resumeScheduled=!0,l.nextTick(B,e,t))),r.paused=!1,this},I.prototype.pause=function(){return i("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(i("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},I.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var o in e.on("end",function(){if(i("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(o){if(i("wrapped data"),r.decoder&&(o=r.decoder.write(o)),!r.objectMode||null!=o)(r.objectMode||o&&o.length)&&(t.push(o)||(n=!0,e.pause()))}),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s<k.length;s++)e.on(k[s],this.emit.bind(this,k[s]));return this._read=function(t){i("wrapped _read",t),n&&(n=!1,e.resume())},this},"function"==typeof Symbol&&(I.prototype[Symbol.asyncIterator]=function(){return void 0===s&&(s=r(82607)),s(this)}),Object.defineProperty(I.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(I.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(I.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),I._fromList=L,Object.defineProperty(I.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(I.from=function(e,t){return void 0===a&&(a=r(96937)),a(I,e,t)})},29710:e=>{class t{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}e.exports=t},31175:e=>{"use strict";function t(e,t,r){var n=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=n._interval),n._interval&&clearInterval(n._interval),n._interval=setInterval(n._callback,e,n._args)},this.clear=function(){n._interval&&(clearInterval(n._interval),n._interval=void 0)},this.destroy=function(){n._interval&&clearInterval(n._interval),n._callback=void 0,n._interval=void 0,n._args=void 0}}e.exports=function(){if("function"!=typeof arguments[0])throw Error("callback needed");if("number"!=typeof arguments[1])throw Error("interval needed");if(arguments.length>0){e=Array(arguments.length-2);for(var e,r=0;r<e.length;r++)e[r]=arguments[r+2]}return new t(arguments[0],arguments[1],e)}},35943:e=>{e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw TypeError("need wrapper function");return Object.keys(t).forEach(function(e){n[e]=t[e]}),n;function n(){for(var e=Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),i=e[e.length-1];
1return"function"==typeof n&&n!==i&&Object.keys(i).forEach(function(e){n[e]=i[e]}),n}}},36007:(e,t,r)=>{"use strict";let n=r(56085).CD,i=r(71673)("number-allocator:trace"),o=r(71673)("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new n([],(e,t)=>e.compare(t)),i("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:+(e.low<this.low&&e.high<this.low)},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return i("alloc():empty"),null;let e=this.ss.begin(),t=e.pointer.low,r=e.pointer.high;return t+1<=r?this.ss.updateKeyByIterator(e,new s(t+1,r)):this.ss.eraseElementByPos(0),i("alloc():"+t),t},a.prototype.use=function(e){let t=new s(e,e),r=this.ss.lowerBound(t);if(!r.equals(this.ss.end())){let n=r.pointer.low,o=r.pointer.high;return r.pointer.equals(t)?(this.ss.eraseElementByIterator(r),i("use():"+e),!0):!(n>e)&&(n===e?this.ss.updateKeyByIterator(r,new s(n+1,o)):o===e?this.ss.updateKeyByIterator(r,new s(n,o-1)):(this.ss.updateKeyByIterator(r,new s(e+1,o)),this.ss.insert(new s(n,e-1))),i("use():"+e),!0)}return i("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void o("free():"+e+" is out of range");let t=new s(e,e),r=this.ss.upperBound(t);if(r.equals(this.ss.end())){if(r.equals(this.ss.begin()))return void this.ss.insert(t);r.pre();let n=r.pointer.high;r.pointer.high+1===e?this.ss.updateKeyByIterator(r,new s(n,e)):this.ss.insert(t)}else if(r.equals(this.ss.begin()))if(e+1===r.pointer.low){let t=r.pointer.high;this.ss.updateKeyByIterator(r,new s(e,t))}else this.ss.insert(t);else{let n=r.pointer.low,i=r.pointer.high;r.pre();let o=r.pointer.low;r.pointer.high+1===e?e+1===n?(this.ss.eraseElementByIterator(r),this.ss.updateKeyByIterator(r,new s(o,i))):this.ss.updateKeyByIterator(r,new s(o,e)):e+1===n?(this.ss.eraseElementByIterator(r.next()),this.ss.insert(new s(e,i))):this.ss.insert(t)}i("free():"+e)},a.prototype.clear=function(){i("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){for(let e of(console.log("length:"+this.ss.size()),this.ss))console.log(e)},e.exports=a},36685:(e,t,r)=>{"use strict";let{Buffer:n}=r(82909),i=Symbol.for("BufferList");function o(e){if(!(this instanceof o))return new o(e);o._init.call(this,e)}o._init=function(e){Object.defineProperty(this,i,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},o.prototype._new=function(e){return new o(e)},o.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;r<this._bufs.length;r++){let n=t+this._bufs[r].length;if(e<n||r===this._bufs.length-1)return[r,e-t];t=n}},o.prototype._reverseOffset=function(e){let t=e[0],r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},o.prototype.get=function(e){if(e>this.length||e<0)return;let t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,r,i){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length||i<=0)return e||n.alloc(0);let o=!!e,s=this._offset(r),a=i-r,l=a,u=o&&t||0,c=s[1];if(0===r&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,u),u+=this._bufs[t].length;return e}if(l<=this._bufs[s[0]].length-c)return o?this._bufs[s[0]].copy(e,t,c,c+l):this._bufs[s[0]].slice(c,c+l);o||(e=n.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){let r=this._bufs[t].length-c;if(l>r)this._bufs[t].copy(e,u,c),u+=r;else{this._bufs[t].copy(e,u,c,c+l),u+=r;break}l-=r,c&&(c=0)}return e.length>u?e.slice(0,u):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();let r=this._offset(e),n=this._offset(t),i=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!==r[1]&&(i[0]=i[0].slice(r[1])),this._new(i)},o.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},o.prototype.consume=function(e){if(Number.isNaN(e=Math.trunc(e))||e<=0)return this;for(;this._bufs.length;)if(e>=this._bufs[0].length)e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}return this},o.prototype.duplicate=function(){let e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},o.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(n.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},o.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=n.from([e]):"string"==typeof e?e=n.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),isNaN(t=Number(t||0))&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;let i=this._offset(t),o=i[0],s=i[1];for(;o<this._bufs.length;o++){let t=this._bufs[o];for(;s<t.length;)if(t.length-s>=e.length){let r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1}else{let t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++}s=0}return -1},o.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0},function(){let e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let t in e)!function(t){null===e[t]?o.prototype[t]=function(e,r){return this.slice(e,e+r)[t](0,r)}:o.prototype[t]=function(r=0){return this.slice(r,r+e[t])[t](0)}}(t)}(),o.prototype._isBufferList=function(e){return e instanceof o||o.isBufferList(e)},o.isBufferList=function(e){return null!=e&&e[i]},e.exports=o},38713:(e,t,r)=>{e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}};function n(e){try{if(!r.g.localStorage)return!1}catch(e){return!1}var t=r.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}},39389:(e,t,r)=>{e.exports=r(95284).EventEmitter},41713:(e,t,r)=>{"use strict";let n=r(84599),i=r(19413),o=r(71673)("mqttjs:tls");e.exports=function(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===i.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);let r=n.connect(t);function s(n){t.rejectUnauthorized&&e.emit("error",n),r.end()}return r.on("secureConnect",function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",Error("TLS not authorized")):r.removeListener("error",s)}),r.on("error",s),r}},42560:(e,t,r)=>{t.parser=r(64373).parser,t.generate=r(4589),t.writeToStream=r(89328)},43002:e=>{"use strict";function t(){if(!(this instanceof t))return new t;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}t.prototype.allocate=function(){let e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},t.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},t.prototype.register=function(e){return!0},t.prototype.deallocate=function(e){},t.prototype.clear=function(){},e.exports=t},49078:e=>{e.exports=function(){for(var e={},r=0;r<arguments.length;r++){var n=arguments[r];for(var i in n)t.call(n,i)&&(e[i]=n[i])}return e};var t=Object.prototype.hasOwnProperty},50591:(e,t,r)=>{"use strict";let n=r(19413),i=r(71673)("mqttjs:tcp");e.exports=function(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";let r=t.port,o=t.hostname;return i("port %d and host %s",r,o),n.createConnection(r,o)}},50677:(e,t,r)=>{"use strict";var n=r(98190).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,i){var o=null!=t.highWaterMark?t.highWaterMark:i?t[r]:null;
1if(null!=o){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},52023:(e,t,r)=>{var n=r(35943);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)};return t.onceError=(e.name||"Function wrapped with `once`")+" shouldn't be called more than once",t.called=!1,t}e.exports=n(i),e.exports.strict=n(o),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},53655:(e,t,r)=>{var n=r(65364),i=r(52023),o=function(){},s=r.g.Bare?queueMicrotask:n.nextTick.bind(n),a=function(e,t,r){if("function"==typeof t)return a(e,null,t);t||(t={}),r=i(r||o);var n=e._writableState,l=e._readableState,u=t.readable||!1!==t.readable&&e.readable,c=t.writable||!1!==t.writable&&e.writable,h=!1,p=function(){e.writable||f()},f=function(){c=!1,u||r.call(e)},d=function(){u=!1,c||r.call(e)},g=function(t){r.call(e,t?Error("exited with error code: "+t):null)},b=function(t){r.call(e,t)},m=function(){s(y)},y=function(){if(!h&&(u&&!(l&&l.ended&&!l.destroyed)||c&&!(n&&n.ended&&!n.destroyed)))return r.call(e,Error("premature close"))},_=function(){e.req.on("finish",f)};return e.setHeader&&"function"==typeof e.abort?(e.on("complete",f),e.on("abort",m),e.req?_():e.on("request",_)):c&&!n&&(e.on("end",p),e.on("close",p)),e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length&&e.on("exit",g),e.on("end",d),e.on("finish",f),!1!==t.error&&e.on("error",b),e.on("close",m),function(){h=!0,e.removeListener("complete",f),e.removeListener("abort",m),e.removeListener("request",_),e.req&&e.req.removeListener("finish",f),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",f),e.removeListener("exit",g),e.removeListener("end",d),e.removeListener("error",b),e.removeListener("close",m)}};e.exports=a},56085:(e,t,r)=>{"use strict";r.d(t,{CD:()=>v});var n=function(){var e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=function(){function e(e,t){this.ee=1,this.u=void 0,this.p=void 0,this.K=void 0,this.N=void 0,this.rr=void 0,this.u=e,this.p=t}return e.prototype.L=function(){var e=this;if(1===e.ee&&e.rr.rr===e)e=e.N;else if(e.K)for(e=e.K;e.N;)e=e.N;else{for(var t=e.rr;t.K===e;)t=(e=t).rr;e=t}return e},e.prototype.m=function(){var e=this;if(e.N){for(e=e.N;e.K;)e=e.K;return e}for(var t=e.rr;t.N===e;)t=(e=t).rr;return e.N!==t?t:e},e.prototype.ne=function(){var e=this.rr,t=this.N,r=t.K;
1return e.rr===this?e.rr=t:e.K===this?e.K=t:e.N=t,t.rr=e,t.K=this,this.rr=t,this.N=r,r&&(r.rr=this),t},e.prototype.te=function(){var e=this.rr,t=this.K,r=t.N;return e.rr===this?e.rr=t:e.K===this?e.K=t:e.N=t,t.rr=e,t.N=this,this.rr=t,this.K=r,r&&(r.rr=this),t},e}(),o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.tr=1,t}return n(t,e),t.prototype.ne=function(){var t=e.prototype.ne.call(this);return this.ie(),t.ie(),t},t.prototype.te=function(){var t=e.prototype.te.call(this);return this.ie(),t.ie(),t},t.prototype.ie=function(){this.tr=1,this.K&&(this.tr+=this.K.tr),this.N&&(this.tr+=this.N.tr)},t}(i),s=function(){var e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),a=function(){function e(e){void 0===e&&(e=0),this.iteratorType=e}return e.prototype.equals=function(e){return this.o===e.o},e}(),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t}(function(){function e(){this.M=0}return Object.defineProperty(e.prototype,"length",{get:function(){return this.M},enumerable:!1,configurable:!0}),e.prototype.size=function(){return this.M},e.prototype.empty=function(){return 0===this.M},e}());function u(){throw RangeError("Iterator access denied!")}var c=function(){var e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),h=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},p=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},f=function(e){function t(t,r){void 0===t&&(t=function(e,t){return e<t?-1:+(e>t)}),void 0===r&&(r=!1);var n=e.call(this)||this;return n.W=void 0,n.$=t,r?(n.re=o,n.v=function(e,t,r){var n=this.se(e,t,r);if(n){for(var i=n.rr;i!==this.h;)i.tr+=1,i=i.rr;var o=this.fe(n);if(o){var s=o.parentNode,a=o.grandParent,l=o.curNode;s.ie(),a.ie(),l.ie()}}return this.M},n.G=function(e){for(var t=this.he(e);t!==this.h;)t.tr-=1,t=t.rr}):(n.re=i,n.v=function(e,t,r){var n=this.se(e,t,r);return n&&this.fe(n),this.M},n.G=n.he),n.h=new n.re,n}return c(t,e),t.prototype.U=function(e,t){for(var r=this.h;e;){var n=this.$(e.u,t);if(n<0)e=e.N;else{if(!(n>0))return e;r=e,e=e.K}}return r},t.prototype.X=function(e,t){for(var r=this.h;e;)0>=this.$(e.u,t)?e=e.N:(r=e,e=e.K);return r},t.prototype.Y=function(e,t){for(var r=this.h;e;){var n=this.$(e.u,t);if(n<0)r=e,e=e.N;else{if(!(n>0))return e;e=e.K}}return r},t.prototype.Z=function(e,t){for(var r=this.h;e;)0>this.$(e.u,t)?(r=e,e=e.N):e=e.K;return r},t.prototype.ue=function(e){for(;;){var t=e.rr;if(t===this.h)return;if(1===e.ee){e.ee=0;return}if(e===t.K){var r=t.N;if(1===r.ee)r.ee=0,t.ee=1,t===this.W?this.W=t.ne():t.ne();else if(r.N&&1===r.N.ee){r.ee=t.ee,t.ee=0,r.N.ee=0,t===this.W?this.W=t.ne():t.ne();return}else r.K&&1===r.K.ee?(r.ee=1,r.K.ee=0,r.te()):(r.ee=1,e=t)}else{var r=t.K;if(1===r.ee)r.ee=0,t.ee=1,t===this.W?this.W=t.te():t.te();else if(r.K&&1===r.K.ee){r.ee=t.ee,t.ee=0,r.K.ee=0,t===this.W?this.W=t.te():t.te();return}else r.N&&1===r.N.ee?(r.ee=1,r.N.ee=0,r.ne()):(r.ee=1,e=t)}}},t.prototype.he=function(e){if(1===this.M)return this.clear(),this.h;for(var t,r,n=e;n.K||n.N;){if(n.N)for(n=n.N;n.K;)n=n.K;else n=n.K;
1t=h([n.u,e.u],2),e.u=t[0],n.u=t[1],r=h([n.p,e.p],2),e.p=r[0],n.p=r[1],e=n}this.h.K===n?this.h.K=n.rr:this.h.N===n&&(this.h.N=n.rr),this.ue(n);var i=n.rr;return n===i.K?i.K=void 0:i.N=void 0,this.M-=1,this.W.ee=0,i},t.prototype.ae=function(e,t){return void 0!==e&&(!!(this.ae(e.K,t)||t(e))||this.ae(e.N,t))},t.prototype.fe=function(e){for(;;){var t=e.rr;if(0===t.ee)return;var r=t.rr;if(t===r.K){var n=r.N;if(n&&1===n.ee){if(n.ee=t.ee=0,r===this.W)return;r.ee=1,e=r;continue}if(e===t.N){if(e.ee=0,e.K&&(e.K.rr=t),e.N&&(e.N.rr=r),t.N=e.K,r.K=e.N,e.K=t,e.N=r,r===this.W)this.W=e,this.h.rr=e;else{var i=r.rr;i.K===r?i.K=e:i.N=e}return e.rr=r.rr,t.rr=e,r.rr=e,r.ee=1,{parentNode:t,grandParent:r,curNode:e}}t.ee=0,r===this.W?this.W=r.te():r.te(),r.ee=1}else{var n=r.K;if(n&&1===n.ee){if(n.ee=t.ee=0,r===this.W)return;r.ee=1,e=r;continue}if(e===t.K){if(e.ee=0,e.K&&(e.K.rr=r),e.N&&(e.N.rr=t),r.N=e.K,t.K=e.N,e.K=r,e.N=t,r===this.W)this.W=e,this.h.rr=e;else{var i=r.rr;i.K===r?i.K=e:i.N=e}return e.rr=r.rr,t.rr=e,r.rr=e,r.ee=1,{parentNode:t,grandParent:r,curNode:e}}t.ee=0,r===this.W?this.W=r.ne():r.ne(),r.ee=1}return}},t.prototype.se=function(e,t,r){if(void 0===this.W){this.M+=1,this.W=new this.re(e,t),this.W.ee=0,this.W.rr=this.h,this.h.rr=this.W,this.h.K=this.W,this.h.N=this.W;return}var n,i=this.h.K,o=this.$(i.u,e);if(0===o){i.p=t;return}if(o>0)i.K=new this.re(e,t),i.K.rr=i,n=i.K,this.h.K=n;else{var s=this.h.N,a=this.$(s.u,e);if(0===a){s.p=t;return}if(a<0)s.N=new this.re(e,t),s.N.rr=s,n=s.N,this.h.N=n;else{if(void 0!==r){var l=r.o;if(l!==this.h){var u=this.$(l.u,e);if(0===u){l.p=t;return}if(u>0){var c=l.L(),h=this.$(c.u,e);if(0===h){c.p=t;return}h<0&&(n=new this.re(e,t),void 0===c.N?(c.N=n,n.rr=c):(l.K=n,n.rr=l))}}}if(void 0===n)for(n=this.W;;){var p=this.$(n.u,e);if(p>0){if(void 0===n.K){n.K=new this.re(e,t),n.K.rr=n,n=n.K;break}n=n.K}else if(p<0){if(void 0===n.N){n.N=new this.re(e,t),n.N.rr=n,n=n.N;break}n=n.N}else{n.p=t;return}}}}return this.M+=1,n},t.prototype.g=function(e,t){for(;e;){var r=this.$(e.u,t);if(r<0)e=e.N;else{if(!(r>0))return e;e=e.K}}return e||this.h},t.prototype.clear=function(){this.M=0,this.W=void 0,this.h.rr=void 0,this.h.K=this.h.N=void 0},t.prototype.updateKeyByIterator=function(e,t){var r=e.o;if(r===this.h&&u(),1===this.M)return r.u=t,!0;if(r===this.h.K)return this.$(r.m().u,t)>0&&(r.u=t,!0);if(r===this.h.N)return 0>this.$(r.L().u,t)&&(r.u=t,!0);var n=r.L().u;if(this.$(n,t)>=0)return!1;var i=r.m().u;return!(0>=this.$(i,t))&&(r.u=t,!0)},t.prototype.eraseElementByPos=function(e){if(e<0||e>this.M-1)throw RangeError();var t=0,r=this;return this.ae(this.W,function(n){return e===t?(r.G(n),!0):(t+=1,!1)}),this.M},t.prototype.eraseElementByKey=function(e){if(0===this.M)return!1;var t=this.g(this.W,e);return t!==this.h&&(this.G(t),!0)},t.prototype.eraseElementByIterator=function(e){var t=e.o;t===this.h&&u();var r=void 0===t.N;return 0===e.iteratorType?r&&e.next():r&&void 0!==t.K||e.next(),this.G(t),e},t.prototype.forEach=function(e){var t,r,n=0;try{for(var i=p(this),o=i.next();!o.done;o=i.next()){var s=o.value;e(s,n++,this)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},t.prototype.getElementByPos=function(e){if(e<0||e>this.M-1)throw RangeError();var t,r,n,i=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var a=s.value;if(i===e){n=a;break}i+=1}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n},t.prototype.getHeight=function(){if(0===this.M)return 0;var e=function(t){return t?Math.max(e(t.K),e(t.N))+1:0};return e(this.W)},t}(l),d=function(){var e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),g=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.o=t,i.h=r,0===i.iteratorType?(i.pre=function(){return this.o===this.h.K&&u(),this.o=this.o.L(),this},i.next=function(){return this.o===this.h&&u(),this.o=this.o.m(),this}):(i.pre=function(){return this.o===this.h.N&&u(),this.o=this.o.m(),this},i.next=function(){return this.o===this.h&&u(),this.o=this.o.L(),this}),i}return d(t,e),Object.defineProperty(t.prototype,"index",{get:function(){var e=this.o,t=this.h.rr;if(e===this.h)return t?t.tr-1:0;var r=0;for(e.K&&(r+=e.K.tr);e!==t;){var n=e.rr;e===n.N&&(r+=1,n.K&&(r+=n.K.tr)),e=n}return r}
1,enumerable:!1,configurable:!0}),t}(a),b=function(){var e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),m=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){var l=[o,a];if(r)throw TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&l[0]?n.return:l[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,l[1])).done)return i;switch(n=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,n=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){s=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]<i[3])){s.label=l[1];break}if(6===l[0]&&s.label<i[1]){s.label=i[1],i=l;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(l);break}i[2]&&s.ops.pop(),s.trys.pop();continue}l=t.call(e,s)}catch(e){l=[6,e],n=0}finally{r=i=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}},y=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},_=function(e){function t(t,r,n,i){var o=e.call(this,t,r,i)||this;return o.container=n,o}return b(t,e),Object.defineProperty(t.prototype,"pointer",{get:function(){return this.o===this.h&&u(),this.o.u},enumerable:!1,configurable:!0}),t.prototype.copy=function(){return new t(this.o,this.h,this.container,this.iteratorType)},t}(g);let v=function(e){function t(t,r,n){void 0===t&&(t=[]);var i=e.call(this,r,n)||this;return t.forEach(function(e){i.insert(e)}),i}return b(t,e),t.prototype.P=function(e){return m(this,function(t){switch(t.label){case 0:if(void 0===e)return[2];return[5,y(this.P(e.K))];case 1:return t.sent(),[4,e.u];case 2:return t.sent(),[5,y(this.P(e.N))];case 3:return t.sent(),[2]}})},t.prototype.begin=function(){return new _(this.h.K||this.h,this.h,this)},t.prototype.end=function(){return new _(this.h,this.h,this)},t.prototype.rBegin=function(){return new _(this.h.N||this.h,this.h,this,1)},t.prototype.rEnd=function(){return new _(this.h,this.h,this,1)},t.prototype.front=function(){return this.h.K?this.h.K.u:void 0},t.prototype.back=function(){return this.h.N?this.h.N.u:void 0},t.prototype.insert=function(e,t){return this.v(e,void 0,t)},t.prototype.find=function(e){return new _(this.g(this.W,e),this.h,this)},t.prototype.lowerBound=function(e){return new _(this.U(this.W,e),this.h,this)},t.prototype.upperBound=function(e){return new _(this.X(this.W,e),this.h,this)},t.prototype.reverseLowerBound=function(e){return new _(this.Y(this.W,e),this.h,this)},t.prototype.reverseUpperBound=function(e){return new _(this.Z(this.W,e),this.h,this)},t.prototype.union=function(e){var t=this;return e.forEach(function(e){t.insert(e)}),this.M},t.prototype[Symbol.iterator]=function(){return this.P(this.W)},t}(f)},57019:(e,t,r)=>{"use strict";let n,i,o,{Buffer:s}=r(82909),a=r(8121).Transform,l=r(10311);e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw Error("Could not determine host. Specify host manually.");let r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={});let u=function(e,t){let r="wxs"===e.protocol?"wss":"ws",n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);n=wx.connectSocket({url:u,protocols:[r]}),i=function(){let e=new a;return e._write=function(e,t,r){n.send({data:e.buffer,success:function(){r()},fail:function(e){r(Error(e))}})},e._flush=function(e){n.close({success:function(){e()}})},e}(),(o=l.obj())._destroy=function(e,t){n.close({success:function(){t&&t(e)}})};let c=o.destroy;return o.destroy=(function(){o.destroy=c;let e=this;setTimeout(function(){n.close({fail:function(){e._destroy(Error())}})},0)}).bind(o),n.onOpen(function(){o.setReadable(i),o.setWritable(i),o.emit("connect")}),n.onMessage(function(e){let t=e.data;t=t instanceof ArrayBuffer?s.from(t):s.from(t,"utf8"),i.push(t)}),n.onClose(function(){o.end(),o.destroy()}),n.onError(function(e){o.destroy(Error(e.errMsg))}),o}},57292:(e,t,r)=>{"use strict";e.exports=i;var n=r(12682);function i(e){if(!(this instanceof i))return new i(e);n.call(this,e)}r(93570)(i,n),i.prototype._transform=function(e,t,r){r(null,e)}},64373:(e,t,r)=>{let n=r(80941),i=r(95284),o=r(29710),s=r(14627),a=r(71673)("mqtt-packet:parser");class l extends i{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof l?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new l().parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("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++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);
1return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){let e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=(e&s.RETAIN_MASK)!=0,this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=(e&s.DUP_MASK)!=0,a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){let e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let 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(Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,n;a("_parseConnect");let i={},o=this.packet,l=this._parseString();if(null===l)return this._emitError(Error("Cannot parse protocolId"));if("MQTT"!==l&&"MQIsdp"!==l)return this._emitError(Error("Invalid protocolId"));if(o.protocolId=l,this._pos>=this._list.length)return this._emitError(Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=!0,o.protocolVersion=o.protocolVersion-128),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length||(i.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK)!=0,o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK)!=0,this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive))return this._emitError(Error("Packet too short"));if(5===o.protocolVersion){let e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}let u=this._parseString();if(null===u)return this._emitError(Error("Packet too short"));if(o.clientId=u,a("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){let e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(null===(e=this._parseString()))return this._emitError(Error("Cannot parse will topic"));if(o.will.topic=e,a("_parseConnect: packet.will.topic: %s",o.will.topic),null===(t=this._parseBuffer()))return this._emitError(Error("Cannot parse will payload"));o.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(i.username){if(null===(n=this._parseString()))return this._emitError(Error("Cannot parse username"));o.username=n,a("_parseConnect: packet.username: %s",o.username)}if(i.password){if(null===(r=this._parseBuffer()))return this._emitError(Error("Cannot parse password"));o.password=r}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");let e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(Error("Cannot parse return code"));if(5===this.settings.protocolVersion){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");let e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){let e,t,r,n,i,o,l;a("_parseSubscribe");let u=this.packet;if(1!==u.qos)return this._emitError(Error("Wrong subscribe header"));if(u.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){let e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(u.properties=e)}for(;this._pos<u.length;){if(null===(e=this._parseString()))return this._emitError(Error("Cannot parse topic"));if(this._pos>=u.length)return this._emitError(Error("Malformed Subscribe Payload"));r=(t=this._parseByte())&s.SUBSCRIBE_OPTIONS_QOS_MASK,o=(t>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK)!=0,i=(t>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,n=t>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:e,qos:r},5===this.settings.protocolVersion?(l.nl=o,l.rap=i,l.rh=n):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),u.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");let e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");let e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){let t=this._parseString();if(null===t)return this._emitError(Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");let e=this.packet;if(!this._parseMessageId())return this._emitError(Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){let t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);let e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){let e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");let e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();let t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){let e=this.packet;return(e.messageId=this._parseNum(),null===e.messageId)?(this._emitError(Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){let t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;let n=this._list.toString("utf8",this._pos,r);
1return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;let r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return -1;let e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return -1;let e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){let t;a("_parseVarByteNum");let r=0,n=1,i=0,o=!1,l=this._pos?this._pos:0;for(;r<4&&l+r<this._list.length;){if(i+=n*((t=this._list.readUInt8(l+r++))&s.VARBYTEINT_MASK),n*=128,(t&s.VARBYTEINT_FIN_MASK)==0){o=!0;break}if(this._list.length<=r)break}return!o&&4===r&&this._list.length>=r&&this._emitError(Error("Invalid variable byte integer")),l&&(this._pos+=r),a("_parseVarByteNum: result: %o",o=!!o&&(e?{bytes:r,value:i}:i)),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_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()}}_parseProperties(){a("_parseProperties");let e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){let e=this._parseByte();if(!e)return this._emitError(Error("Cannot parse property code type")),!1;let t=s.propertiesCodes[e];if(!t)return this._emitError(Error("Unknown property")),!1;if("userProperties"===t){r[t]||(r[t]=Object.create(null));let e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{let n=r[t][e.name];r[t][e.name]=[n],r[t][e.name].push(e.value)}else r[t][e.name]=e.value;continue}r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t])}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}e.exports=l},67090:(e,t,r)=>{"use strict";var n=r(65364);function i(e,t){s(e,t),o(e)}function o(e){(!e._writableState||e._writableState.emitClose)&&(!e._readableState||e._readableState.emitClose)&&e.emit("close")}function s(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return a||l?t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(s,this,e)):n.nextTick(s,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,e)):n.nextTick(i,r,e):t?(n.nextTick(o,r),t(e)):n.nextTick(o,r)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}}},68377:e=>{"use strict";e.exports=function(){throw Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},69630:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;let n=Number(new Date);a.diff=n-(r||n),a.prev=r,a.curr=n,r=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,n)=>{if("%%"===r)return"%";i++;let o=t.formatters[n];if("function"==typeof o){let t=e[i];r=o.call(a,t),e.splice(i,1),i--}return r}),t.formatArgs.call(a,e),(a.log||t.log).apply(a,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){let n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function i(e,t){let r=0,n=0,i=-1,o=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,o=r):r++,n++;else{if(-1===i)return!1;n=i+1,r=++o}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){let e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){for(let r of(t.save(e),t.namespaces=e,t.names=[],t.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(
1Boolean)))"-"===r[0]?t.skips.push(r.slice(1)):t.names.push(r)},t.enabled=function(e){for(let r of t.skips)if(i(e,r))return!1;for(let r of t.names)if(i(e,r))return!0;return!1},t.humanize=r(3139),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(r=>{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t)|0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},70145:e=>{"use strict";e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!function(e){let t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}(e[t]))return e[t];return null}}},70174:e=>{"use strict";function t(e){if(!(this instanceof t))return new t(e);this.aliasToTopic={},this.max=e}t.prototype.put=function(e,t){return 0!==t&&!(t>this.max)&&(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,!0)},t.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},t.prototype.clear=function(){this.aliasToTopic={}},e.exports=t},71673:(e,t,r)=>{var n=r(65364);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;let r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e},t.useColors=function(){let e;return"undefined"!=typeof window&&!!window.process&&("renderer"===window.process.type||!!window.process.__nwjs)||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),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"],t.log=console.debug||console.log||(()=>{}),e.exports=r(69630)(t);let{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},72802:(e,t,r)=>{"use strict";var n,i=r(98190).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function l(e){e()}function u(e,t){return e.pipe(t)}e.exports=function(){for(var e,t,i=arguments.length,c=Array(i),h=0;h<i;h++)c[h]=arguments[h];var p=(e=c).length&&"function"==typeof e[e.length-1]?e.pop():a;if(Array.isArray(c[0])&&(c=c[0]),c.length<2)throw new o("streams");var f=c.map(function(e,i){var o,a,u,h,d,g,b=i<c.length-1;return o=i>0,u=a=function(e){t||(t=e),e&&f.forEach(l),b||(f.forEach(l),p(t))},h=!1,a=function(){h||(h=!0,u.apply(void 0,arguments))},d=!1,e.on("close",function(){d=!0}
1),void 0===n&&(n=r(97212)),n(e,{readable:b,writable:o},function(e){if(e)return a(e);d=!0,a()}),g=!1,function(t){if(!d&&!g){if(g=!0,e.setHeader&&"function"==typeof e.abort)return e.abort();if("function"==typeof e.destroy)return e.destroy();a(t||new s("pipe"))}}});return c.reduce(u)}},72924:(e,t,r)=>{"use strict";let n=r(77421),i=r(13762).t;function o(e){if(!(this instanceof o))return new o(e);e>0&&(this.aliasToTopic=new n({max:e}),this.topicToAlias={},this.numberAllocator=new i(1,e),this.max=e,this.length=0)}o.prototype.put=function(e,t){if(0===t||t>this.max)return!1;let r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},o.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},o.prototype.getAliasByTopic=function(e){let t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},o.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},o.prototype.getLruAlias=function(){let e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},e.exports=o},73420:(e,t,r)=>{"use strict";var n=r(65364);let i=r(3140),o=r(19092),s=r(3305),a=r(49078),l=r(71673)("mqttjs"),u={};function c(e,t){var r;let n;if(l("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){let r=s.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=a(r,t)).protocol)throw Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if((r=t).auth&&((n=r.auth.match(/^(.+):(.+)$/))?(r.username=n[1],r.password=n[2]):r.username=r.auth),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key)if(t.protocol){if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}else throw Error("Missing secure protocol key");if(!u[t.protocol]){let e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(t,r){return(!e||r%2!=0)&&"function"==typeof u[t]})[0]}if(!1===t.clean&&!t.clientId)throw Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);let o=new i(function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),l("calling streambuilder for",t.protocol),u[t.protocol](e,t)},t);return o.on("error",function(){}),o}void 0!==n&&"browser"!==n.title||"function"!=typeof r?(u.mqtt=r(50591),u.tcp=r(50591),u.ssl=r(41713),u.tls=r(41713),u.mqtts=r(41713)):(u.wx=r(57019),u.wxs=r(57019),u.ali=r(99864),u.alis=r(99864)),u.ws=r(26322),u.wss=r(26322),e.exports=c,e.exports.connect=c,e.exports.MqttClient=i,e.exports.Store=o},75968:(e,t,r)=>{"use strict";var n=r(65364),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=c;var o=r(27690),s=r(91190);r(93570)(c,o);for(var a=i(s.prototype),l=0;l<a.length;l++){var u=a[l];c.prototype[u]||(c.prototype[u]=s.prototype[u])}function c(e){if(!(this instanceof c))return new c(e);o.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",h)))}function h(){this._writableState.ended||n.nextTick(p,this)}function p(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},77421:(e,t,r)=>{"use strict";let n=r(16791),i=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),l=Symbol("maxAge"),u=Symbol("dispose"),c=Symbol("noDisposeOnSet"),h=Symbol("lruList"),p=Symbol("cache"),f=Symbol("updateAgeOnGet"),d=()=>1;class g{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw TypeError("max must be a non-negative number");this[i]=e.max||1/0;let t=e.length||d;if(this[s]="function"!=typeof t?d:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw TypeError("maxAge must be a number");this[l]=e.maxAge||0,this[u]=e.dispose,this[c]=e.noDisposeOnSet||!1,this[f]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw TypeError("max must be a non-negative number");this[i]=e||1/0,y(this)}get max(){return this[i]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw TypeError("maxAge must be a non-negative number");this[l]=e,y(this)}get maxAge(){return this[l]}set lengthCalculator(e){"function"!=typeof e&&(e=d),e!==this[s]&&(this[s]=e,this[o]=0,this[h].forEac
1h(e=>{e.length=this[s](e.value,e.key),this[o]+=e.length})),y(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let r=this[h].tail;null!==r;){let n=r.prev;w(this,e,r,t),r=n}}forEach(e,t){t=t||this;for(let r=this[h].head;null!==r;){let n=r.next;w(this,e,r,t),r=n}}keys(){return this[h].toArray().map(e=>e.key)}values(){return this[h].toArray().map(e=>e.value)}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach(e=>this[u](e.key,e.value)),this[p]=new Map,this[h]=new n,this[o]=0}dump(){return this[h].map(e=>!m(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[h]}set(e,t,r){if((r=r||this[l])&&"number"!=typeof r)throw TypeError("maxAge must be a number");let n=r?Date.now():0,a=this[s](t,e);if(this[p].has(e)){if(a>this[i])return _(this,this[p].get(e)),!1;let s=this[p].get(e).value;return this[u]&&!this[c]&&this[u](e,s.value),s.now=n,s.maxAge=r,s.value=t,this[o]+=a-s.length,s.length=a,this.get(e),y(this),!0}let f=new v(e,t,a,n,r);return f.length>this[i]?(this[u]&&this[u](e,t),!1):(this[o]+=f.length,this[h].unshift(f),this[p].set(e,this[h].head),y(this),!0)}has(e){return!!this[p].has(e)&&!m(this,this[p].get(e).value)}get(e){return b(this,e,!0)}peek(e){return b(this,e,!1)}pop(){let e=this[h].tail;return e?(_(this,e),e.value):null}del(e){_(this,this[p].get(e))}load(e){this.reset();let t=Date.now();for(let r=e.length-1;r>=0;r--){let n=e[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{let e=i-t;e>0&&this.set(n.k,n.v,e)}}}prune(){this[p].forEach((e,t)=>b(this,t,!1))}}let b=(e,t,r)=>{let n=e[p].get(t);if(n){let t=n.value;if(m(e,t)){if(_(e,n),!e[a])return}else r&&(e[f]&&(n.value.now=Date.now()),e[h].unshiftNode(n));return t.value}},m=(e,t)=>{if(!t||!t.maxAge&&!e[l])return!1;let r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[l]&&r>e[l]},y=e=>{if(e[o]>e[i])for(let t=e[h].tail;e[o]>e[i]&&null!==t;){let r=t.prev;_(e,t),t=r}},_=(e,t)=>
1{if(t){let r=t.value;e[u]&&e[u](r.key,r.value),e[o]-=r.length,e[p].delete(r.key),e[h].removeNode(t)}};class v{constructor(e,t,r,n,i){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=i||0}}let w=(e,t,r,n)=>{let i=r.value;m(e,i)&&(_(e,r),e[a]||(i=void 0)),i&&t.call(n,i.value,i.key,e)};e.exports=g},80941:(e,t,r)=>{"use strict";let n=r(8121).Duplex,i=r(93570),o=r(36685);function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;let t=(function(e){this._callback&&(this._callback(e),this._callback=null)}).bind(this);this.on("pipe",function(e){e.on("error",t)}),this.on("unpipe",function(e){e.removeListener("error",t)}),e=null}o._init.call(this,e),n.call(this)}i(s,n),Object.assign(s.prototype,o.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof o||s.isBufferList(e)},s.isBufferList=o.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=o},82607:(e,t,r)=>{"use strict";var n,i=r(65364);function o(e,t,r){var n;return(t="symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?n:String(n))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=r(97212),a=Symbol("lastResolve"),l=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),h=Symbol("lastPromise"),p=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function g(e){var t=e[a];if(null!==t){var r=e[f].read();null!==r&&(e[h]=null,e[a]=null,e[l]=null,t(d(r,!1)))}}function b(e){i.nextTick(g,e)}var m=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((o(n={get stream(){return this[f]},next:function(){var e,t,r=this,n=this[u];if(null!==n)return Promise.reject(n);if(this[c])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise(function(e,t){i.nextTick(function(){r[u]?t(r[u]):e(d(void 0,!0))})});var o=this[h];if(o)t=new Promise((e=this,function(t,r){o.then(function(){if(e[c])return void t(d(void 0,!0));e[p](t,r)},r)}));else{var s=this[f].read();if(null!==s)return Promise.resolve(d(s,!1));t=new Promise(this[p])}return this[h]=t,t}},Symbol.asyncIterator,function(){return this}),o(n,"return",function(){var e=this;return new Promise(function(t,r){e[f].destroy(null,function(e){if(e)return void r(e);t(d(void 0,!0))})})}),n),m);e.exports=function(e){var t,r=Object.create(y,(o(t={},f,{value:e,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,l,{value:null,writable:!0}),o(t,u,{value:null,writable:!0}),o(t,c,{value:e._readableState.endEmitted,writable:!0}),o(t,p,{value:function(e,t){var n=r[f].read();n?(r[h]=null,r[a]=null,r[l]=null,e(d(n,!1))):(r[a]=e,r[l]=t)},writable:!0}),t));
1return r[h]=null,s(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[l];null!==t&&(r[h]=null,r[a]=null,r[l]=null,t(e)),r[u]=e;return}var n=r[a];null!==n&&(r[h]=null,r[a]=null,r[l]=null,n(d(void 0,!0))),r[c]=!0}),e.on("readable",b.bind(null,r)),r}},85290:e=>{e.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}(t)):null}},89328:(e,t,r)=>{var n=r(82909).Buffer;let i=r(14627),o=n.allocUnsafe(0),s=n.from([0]),a=r(17540),l=r(94287).nextTick,u=r(71673)("mqtt-packet:writeToStream"),c=a.cache,h=a.generateNumber,p=a.generateCache,f=a.genBufVariableByteInt,d=a.generate4ByteBuffer,g=S,b=!0;function m(e,t,r){switch(u("generate called"),t.cork&&(t.cork(),l(y,t)),b&&(b=!1,p()),u("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t,r){let o,s=e||{},a=s.protocolId||"MQTT",l=s.protocolVersion||4,u=s.will,c=s.clean,h=s.keepalive||0,p=s.clientId||"",f=s.username,d=s.password,b=s.properties;void 0===c&&(c=!0);let m=0;if(!a||"string"!=typeof a&&!n.isBuffer(a))return t.emit("error",Error("Invalid protocolId")),!1;if(m+=a.length+2,3!==l&&4!==l&&5!==l)return t.emit("error",Error("Invalid protocol version")),!1;if(m+=1,("string"==typeof p||n.isBuffer(p))&&(p||l>
1=4)&&(p||c))m+=n.byteLength(p)+2;else{if(l<4)return t.emit("error",Error("clientId must be supplied before 3.1.1")),!1;if(0==+c)return t.emit("error",Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof h||h<0||h>65535||h%1!=0)return t.emit("error",Error("Invalid keepalive")),!1;if(m+=2,m+=1,5===l){var y=I(t,b);if(!y)return!1;m+=y.length}if(u){if("object"!=typeof u)return t.emit("error",Error("Invalid will")),!1;if(!u.topic||"string"!=typeof u.topic)return t.emit("error",Error("Invalid will topic")),!1;if(m+=n.byteLength(u.topic)+2,m+=2,u.payload)if(!(u.payload.length>=0))return t.emit("error",Error("Invalid will payload")),!1;else"string"==typeof u.payload?m+=n.byteLength(u.payload):m+=u.payload.length;var _={};if(5===l){if(!(_=I(t,u.properties)))return!1;m+=_.length}}let S=!1;if(null!=f)if(!x(f))return t.emit("error",Error("Invalid username")),!1;else S=!0,m+=n.byteLength(f)+2;if(null!=d){if(!S)return t.emit("error",Error("Username is required to use password")),!1;if(!x(d))return t.emit("error",Error("Invalid password")),!1;m+=P(d)+2}return t.write(i.CONNECT_HEADER),v(t,m),E(t,a),s.bridgeMode&&(l+=128),t.write(131===l?i.VERSION131:132===l?i.VERSION132:4===l?i.VERSION4:5===l?i.VERSION5:i.VERSION3),o=0|(null!=f?i.USERNAME_MASK:0)|(null!=d?i.PASSWORD_MASK:0)|(u&&u.retain?i.WILL_RETAIN_MASK:0)|(u&&u.qos?u.qos<<i.WILL_QOS_SHIFT:0)|(u?i.WILL_FLAG_MASK:0)|(c?i.CLEAN_SESSION_MASK:0),t.write(n.from([o])),g(t,h),5===l&&y.write(),E(t,p),u&&(5===l&&_.write(),w(t,u.topic),E(t,u.payload)),null!=f&&E(t,f),null!=d&&E(t,d),!0}(e,t,0);case"connack":return function(e,t,r){let o=r?r.protocolVersion:4,a=e||{},l=5===o?a.reasonCode:a.returnCode,u=a.properties,c=2;if("number"!=typeof l)return t.emit("error",Error("Invalid return code")),!1;let h=null;if(5===o){if(!(h=I(t,u)))return!1;c+=h.length}return t.write(i.CONNACK_HEADER),v(t,c),t.write(a.sessionPresent?i.SESSIONPRESENT_HEADER:s),t.write(n.from([l])),null!=h&&h.write(),!0}(e,t,r);case"publish":return function(e,t,r){u("publish: packet: %o",e);let s=r?r.protocolVersion:4,a=e||{},l=a.qos||0,c=a.retain?i.RETAIN_MASK:0,h=a.topic,p=a.payload||o,f=a.messageId,d=a.properties,b=0;if("string"==typeof h)b+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",Error("Invalid topic")),!1;b+=h.length+2}
1if(n.isBuffer(p)?b+=p.length:b+=n.byteLength(p),l&&"number"!=typeof f)return t.emit("error",Error("Invalid messageId")),!1;l&&(b+=2);let m=null;if(5===s){if(!(m=I(t,d)))return!1;b+=m.length}return t.write(i.PUBLISH_HEADER[l][+!!a.dup][+!!c]),v(t,b),g(t,P(h)),t.write(h),l>0&&g(t,f),null!=m&&m.write(),u("publish: payload: %o",p),t.write(p)}(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,r){let o=r?r.protocolVersion:4,s=e||{},a=s.cmd||"puback",l=s.messageId,u=s.dup&&"pubrel"===a?i.DUP_MASK:0,c=0,h=s.reasonCode,p=s.properties,f=5===o?3:2;if("pubrel"===a&&(c=1),"number"!=typeof l)return t.emit("error",Error("Invalid messageId")),!1;let d=null;if(5===o&&"object"==typeof p){if(!(d=A(t,p,r,f)))return!1;f+=d.length}return t.write(i.ACKS[a][c][u][0]),v(t,f),g(t,l),5===o&&t.write(n.from([h])),null!==d&&d.write(),!0}(e,t,r);case"subscribe":return function(e,t,r){u("subscribe: packet: ");let o=r?r.protocolVersion:4,s=e||{},a=s.dup?i.DUP_MASK:0,l=s.messageId,c=s.subscriptions,h=s.properties,p=0;if("number"!=typeof l)return t.emit("error",Error("Invalid messageId")),!1;p+=2;let f=null;if(5===o){if(!(f=I(t,h)))return!1;p+=f.length}if("object"!=typeof c||!c.length)return t.emit("error",Error("Invalid subscriptions")),!1;for(let e=0;e<c.length;e+=1){let r=c[e].topic,i=c[e].qos;if("string"!=typeof r)return t.emit("error",Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof i)return t.emit("error",Error("Invalid subscriptions - invalid qos")),!1;if(5===o){if("boolean"!=typeof(c[e].nl||!1))return t.emit("error",Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(c[e].rap||!1))return t.emit("error",Error("Invalid subscriptions - invalid Retain as Published")),!1;let r=c[e].rh||0;if("number"!=typeof r||r>2)return t.emit("error",Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=n.byteLength(r)+2+1}u("subscribe: writing to stream: %o",i.SUBSCRIBE_HEADER),t.write(i.SUBSCRIBE_HEADER[1][+!!a][0]),v(t,p),g(t,l),null!==f&&f.write();let d=!0;for(let e of c){let r,s=e.topic,a=e.qos,l=+e.nl,u=+e.rap,c=e.rh;w(t,s),r=i.SUBSCRIBE_OPTIONS_QOS[a],5===o&&(r|=l?i.SUBSCRIBE_OPTIONS_NL:0,r|=u?i.SUBSCRIBE_OPTIONS_RAP:0,r|=c?i.SUBSCRIBE_OPTIONS_RH[c]:0),d=t.write(n.from([r]))}return d}(e,t,r);case"suback":return function(e,t,r){let o=r?r.protocolVersion:4,s=e||{},a=s.messageId,l=s.granted,u=s.properties,c=0;if("number"!=typeof a)return t.emit("error",Error("Invalid messageId")),!1;if(c+=2,"object"!=typeof l||!l.length)return t.emit("error",Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",Error("Invalid qos vector")),!1;c+=1}let h=null;if(5===o){if(!(h=A(t,u,r,c)))return!1;c+=h.length}return t.write(i.SUBACK_HEADER),v(t,c),g(t,a),null!==h&&h.write(),t.write(n.from(l))}(e,t,r);case"unsubscribe":return function(e,t,r){let o=r?r.protocolVersion:4,s=e||{},a=s.messageId,l=s.dup?i.DUP_MASK:0,u=s.unsubscriptions,c=s.properties,h=0;if("number"!=typeof a)return t.emit("error",Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof u||!u.length)return t.emit("error",Error("Invalid unsubscriptions")),!1;for(let e=0;e<u.length;e+=1){if("string"!=typeof u[e])return t.emit("error",Error("Invalid unsubscriptions")),!1;h+=n.byteLength(u[e])+2}let p=null;if(5===o){if(!(p=I(t,c)))return!1;h+=p.length}t.write(i.UNSUBSCRIBE_HEADER[1][+!!l][0]),v(t,h),g(t,a),null!==p&&p.write();let f=!0;for(let e=0;e<u.length;e++)f=w(t,u[e]);return f}(e,t,r);case"unsuback":return function(e,t,r){let o=r?r.protocolVersion:4,s=e||{},a=s.messageId,l=s.dup?i.DUP_MASK:0,u=s.granted,c=s.properties,h=s.cmd,p=2;if("number"!=typeof a)return t.emit("error",Error("Invalid messageId")),!1;if(5===o)if("object"!=typeof u||!u.length)return t.emit("error",Error("Invalid qos vector")),!1;else for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",Error("Invalid qos vector")),!1;p+=1}let f=null;if(5===o){if(!(f=A(t,c,r,p)))return!1;p+=f.length}return t.write(i.ACKS[h][0][l][0]),v(t,p),g(t,a),null!==f&&f.write(),5===o&&t.write(n.from(u)),!0}(e,t,r);case"pingreq":case"pingresp":var a;return a=e,t.write(i.EMPTY[a.cmd]);case"disconnect":return function(e,t,r){let o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,l=s.properties,u=+(5===o),c=null;if(5===o){if(!(c=A(t,l,r,u)))return!1;u+=c.length}return t.write(n.from([i.codes.disconnect<<4])),v(t,u),5===o&&t.write(n.from([a])),null!==c&&c.write(),!0}(e,t,r);case"auth":return function(e,t,r){let o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,l=s.properties,u=+(5===o);5!==o&&t.emit("error",Error("Invalid mqtt version for auth packet"));let c=A(t,l,r,u);return!!c&&(u+=c.length,t.write(n.from([i.codes.auth<<4])),v(t,u),t.write(n.from([a])),null!==c&&c.write(),!0)}(e,t,r);default:return t.emit("error",Error("Unknown command")),!1}}function y(e){e.uncork()}Object.defineProperty(m,"cacheNumbers",{get:()=>g===S,set(e){e?(c&&0!==Object.keys(c).length||(b=!0),g=S):(b=!1,g=k)}});let _={};function v(e,t){if(t>i.VARBYTEINT_MAX)return e.emit("error",Error(`Invalid variable byte integer: ${t}`)),!1;let r=_[t];return!r&&(r=f(t),t<16384&&(_[t]=r)),u("writeVarByteInt: writing to stream
1: %o",r),e.write(r)}function w(e,t){let r=n.byteLength(t);return g(e,r),u("writeString: %s",t),e.write(t,"utf8")}function S(e,t){return u("writeNumberCached: number: %d",t),u("writeNumberCached: %o",c[t]),e.write(c[t])}function k(e,t){let r=h(t);return u("writeNumberGenerated: %o",r),e.write(r)}function E(e,t){"string"==typeof t?w(e,t):t?(g(e,t.length),e.write(t)):g(e,0)}function I(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){T(e,{},0)}};let r=0;function o(t,r){let o=i.propertiesTypes[t],s=0;switch(o){case"byte":if("boolean"!=typeof r)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=2;break;case"int8":if("number"!=typeof r||r<0||r>255)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=2;break;case"binary":if(r&&null===r)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=1+n.byteLength(r)+2;break;case"int16":if("number"!=typeof r||r<0||r>65535)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=3;break;case"int32":if("number"!=typeof r||r<0||r>0xffffffff)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=5;break;case"var":if("number"!=typeof r||r<0||r>0xfffffff)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=1+n.byteLength(f(r));break;case"string":if("string"!=typeof r)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=3+n.byteLength(r.toString());break;case"pair":if("object"!=typeof r)return e.emit("error",Error(`Invalid ${t}: ${r}`)),!1;s+=Object.getOwnPropertyNames(r).reduce((e,t)=>{let i=r[t];return Array.isArray(i)?e+=i.reduce((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString()),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(r[t].toString()),e},0);break;default:return e.emit("error",Error(`Invalid property ${t}: ${r}`)),!1}return s}if(t)for(let e in t){let n=0,i=0,s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(!(i=o(e,s[t])))return!1;n+=i}else{if(!(i=o(e,s)))return!1;n=i}if(!n)return!1;r+=n}return{length:n.byteLength(f(r))+r,write(){T(e,t,r)}}}function A(e,t,r,n){let i=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0,s=I(e,t);if(o)for(;n+s.length>o;){let r=i.shift();if(!r||!t[r])return!1;delete t[r],s=I(e,t)}return s}function C(e,t,r){switch(i.propertiesTypes[t]){case"byte":e.write(n.from([i.properties[t]])),e.write(n.from([+r]));break;case"int8":e.write(n.from([i.properties[t]])),e.write(n.from([r]));break;case"binary":e.write(n.from([i.properties[t]])),E(e,r);break;case"int16":e.write(n.from([i.properties[t]])),g(e,r);break;case"int32":e.write(n.from([i.properties[t]])),function(e,t){let r=d(t);u("write4ByteNumber: %o",r),e.write(r)}(e,r);break;case"var":e.write(n.from([i.properties[t]])),v(e,r);break;case"string":e.write(n.from([i.properties[t]])),w(e,r);break;case"pair":Object.getOwnPropertyNames(r).forEach(o=>{let s=r[o];if(Array.isArray(s))s.forEach(r=>{var s,a;e.write(n.from([i.properties[t]])),s=o.toString(),a=r.toString(),w(e,s),w(e,a)});else{var a,l;e.write(n.from([i.properties[t]])),a=o.toString(),l=s.toString(),w(e,a),w(e,l)}});break;default:return e.emit("error",Error(`Invalid property ${t} value: ${r}`)),!1}}function T(e,t,r){for(let n in v(e,r),t)if(Object.prototype.hasOwnProperty.call(t,n)&&null!==t[n]){let r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)C(e,n,r[t]);else C(e,n,r)}}function P(e){return e?e instanceof n?e.length:n.byteLength(e):0}function x(e){return"string"==typeof e||e instanceof n}e.exports=m},91190:(e,t,r)=>{"use strict";var n,i,o=r(65364);function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){var r=t,n=e,i=r.entry;for(r.entry=null;i;){var o=i.callback;n.pendingcb--,o(void 0),i=i.next}n.corkedRequestsFree.next=r}}e.exports=I,I.WritableState=E;var a={deprecate:r(38713)},l=r(39389),u=r(82909).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},h=r(67090),p=r(50677).getHighWaterMark,f=r(98190).F,d=f.ERR_INVALID_ARG_TYPE,g=f.ERR_METHOD_NOT_IMPLEMENTED,b=f.ERR_MULTIPLE_CALLBACK,m=f.ERR_STREAM_CANNOT_PIPE,y=f.ERR_STREAM_DESTROYED,_=f.ERR_STREAM_NULL_VALUES,v=f.E
1RR_STREAM_WRITE_AFTER_END,w=f.ERR_UNKNOWN_ENCODING,S=h.errorOrDestroy;function k(){}function E(e,t,i){n=n||r(75968),e=e||{},"boolean"!=typeof i&&(i=t instanceof n),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=p(this,e,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===e.decodeStrings;this.decodeStrings=!a,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"!=typeof i)throw new b;if(r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,t)--r.pendingcb,n?(o.nextTick(i,t),o.nextTick(R,e,r),e._writableState.errorEmitted=!0,S(e,t)):(i(t),e._writableState.errorEmitted=!0,S(e,t),R(e,r));else{var s=P(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||T(e,r),n?o.nextTick(C,e,r,s,i):C(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.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}r(93570)(I,l),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t};try{Object.defineProperty(E.prototype,"buffer",{get:a.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}function I(e){var t=this instanceof(n=n||r(75968));if(!t&&!i.call(I,this))return new I(e);this._writableState=new E(e,this,t),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 A(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new y("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function C(e,t,r,n){var i,o;r||(i=e,0===(o=t).length&&o.needDrain&&(o.needDrain=!1,i.emit("drain"))),t.pendingcb--,n(),R(e,t)}function T(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=Array(t.bufferedRequestCount),i=t.corkedRequestsFree;i.entry=r;for(var o=0,a=!0;r;)n[o]=r,r.isBuf||(a=!1),r=r.next,o+=1;n.allBuffers=a,A(e,t,!0,t.length,n,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,u=r.encoding,c=r.callback,h=t.objectMode?1:l.length;if(A(e,t,!1,h,l,u,c),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function P(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final(function(r){t.pendingcb--,r&&S(e,r),t.prefinished=!0,e.emit("prefinish"),R(e,t)})}function R(e,t){var r=P(t);if(r&&(t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,o.nextTick(x,e,t))),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(i=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!i.call(this,e)||this===I&&e&&e._writableState instanceof E}})):i=function(e){return e instanceof this},I.prototype.pipe=function(){S(this,new m)},I.prototype.write=function(e,t,r){var n,i,s,a,l,h,p,f=this._writableState,g=!1,b=!f.objectMode&&(n=e,u.isBuffer(n)||n instanceof c);return(b&&!u.isBuffer(e)&&(i=e,e=u.from(i)),"function"==typeof t&&(r=t,t=null),b?t="buffer":t||(t=f.defaultEncoding),"function"!=typeof r&&(r=k),f.ending)?(s=r,S(this,a=new v),o.nextTick(s,a)):(b||(l=e,h=r,null===l?p=new _:"string"==typeof l||f.objectMode||(p=new d("chunk",["string","Buffer"],l)),!p||(S(this,p),o.nextTick(h,p),0)))&&(f.pendingcb++,g=function(e,t,r,n,i,o){if(!r){var s,a,l=(s=n,a=i,t.objectMode||!1===t.decodeStrings||"string"!=typeof s||(s=u.from(s,a)),s);n!==l&&(r=!0,i="buffer",n=l)}var c=t.objectMode?1:n.length;t.length+=c;var h=t.length<t.highWaterMark;if(h||(t.needDrain=!0),t.writing||t.corked){var p=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},p?p.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else A(e,t,!1,c,n,i,o);return h}(this,f,b,e,t,r)),g},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||T(this,e))},I.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 w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,r){r(new g("_write()"))},I.prototype._writev=null,I.prototype.end=function(e,t,r){var n,i,s,a=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),a.corked&&(a.corked=1,this.uncork()),a.ending||(n=this,i=a,s=r,i.ending=!0,R(n,i),s&&(i.finished?o.nextTick(s):n.once("finish",s)),i.ended=!0,n.writable=!1),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=h.destroy,I.prototype._undestroy=h.undestroy,I.prototype._destroy=function(e,t){t(e)}},93570:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},94287:(e,t,r)=>{"use strict";var n=r(65364);void 0!==n&&n.version&&0!==n.version.indexOf("v0.")&&(0!==n.version.indexOf("v1.")||0===n.version.indexOf("v1.8."))?e.exports=n:e.exports={nextTick:function(e,t,r,i){if("function"!=typeof e)throw TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return n.nextTick(e);case 2:return n.nextTick(function(){e.call(null,t)});case 3:return n.nextTick(function(){e.call(null,t,r)});case 4:return n.nextTick(function(){e.call(null,t,r,i)});default:for(o=Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return n.nextTick(function(){e.apply(null,o)})}}}},95281:e=>{"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},96081:(e,t,r)=>{var n=r(82909),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw TypeError("Argument must be a number");return n.SlowBuffer(e)}},96937:e=>{e.exports=function(){throw Error("Readable.from is not available in the browser")}},97212:(e,t,r)=>{"use strict";var n=r(98190).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),s=o||i,a=!1,o=function(){if(!a){a=!0;for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(this,t)}};var s,a,l=r.readable||!1!==r.readable&&t.readable,u=r.writable||!1!==r.writable&&t.writable,c=function(){t.writable||p()},h=t._writableState&&t._writableState.finished,p=function(){u=!1,h=!0,l||o.call(t)},f=t._readableState&&t._readableState.endEmitted,d=function(){l=!1,f=!0,u||o.call(t)},g=function(e){o.call(t,e)},b=function(){var e;return l&&!f?(t._readableState&&t._readableState.ended||(e=new n),o.call(t,e)):u&&!h?(t._writableState&&t._writableState.ended||(e=new n),o.call(t,e)):void 0},m=function(){t.req.on("finish",p)};return t.setHeader&&"function"==typeof t.abort?(t.on("complete",p),t.on("abort",b),t.req?m():t.on("request",m)):u&&!t._writableState&&(t.on("end",c),t.on("close",c)),t.on("end",d),t.on("finish",p),!1!==r.error&&t.on("error",g),t.on("close",b),function(){t.removeListener("complete",p),t.removeListener("abort",b),t.removeListener("request",m),t.req&&t.req.removeListener("finish",p),t.removeListener("end",c),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("end",d),t.removeListener("error",g),t.removeListener("close",b)}}},98190:e=>{"use strict";var t={};function r(e,r,n){n||(n=Error);var i=function(e){function t(t,n,i){return e.call(this,"string"==typeof r?r:r(t,n,i))||this}return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e,t}(n);i.prototype.name=n.name,i.prototype.code=e,t[e]=i}function n(e,t){if(!Array.isArray(e))return"of ".concat(t," ").concat(String(e));var r=e.length;return(e=e.map(function(e){return String(e)}),r>2)?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invali
1d for option "'+e+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(e,t,r){if("string"==typeof t&&(i="not ",t.substr(0,i.length)===i)?(l="must not be",t=t.replace(/^not /,"")):l="must be",o=" argument",(void 0===s||s>e.length)&&(s=e.length),e.substring(s-o.length,s)===o)u="The ".concat(e," ").concat(l," ").concat(n(t,"type"));else{var i,o,s,a,l,u,c=("number"!=typeof a&&(a=0),a+1>e.length||-1===e.indexOf(".",a))?"argument":"property";u='The "'.concat(e,'" ').concat(c," ").concat(l," ").concat(n(t,"type"))}return u+". Received type ".concat(typeof r)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},99864:(e,t,r)=>{"use strict";let n,i,o,{Buffer:s}=r(82909),a=r(8121).Transform,l=r(10311),u=!1;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw Error("Could not determine host. Specify host manually.");let r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={});let c=function(e,t){let r="alis"===e.protocol?"wss":"ws",n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);return(n=t.my).connectSocket({url:c,protocols:r}),i=function(){let e=new a;return e._write=function(e,t,r){n.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(Error())}})},e._flush=function(e){n.closeSocket({success:function(){e()}})},e}(),o=l.obj(),u||(u=!0,n.onSocketOpen(function(){o.setReadable(i),o.setWritable(i),o.emit("connect")}),n.onSocketMessage(function(e){if("string"==typeof e.data){let t=s.from(e.data,"base64");i.push(t)}else{let t=new FileReader;t.addEventListener("load",function(){let e=t.result;e=e instanceof ArrayBuffer?s.from(e):s.from(e,"utf8"),i.push(e)}),t.readAsArrayBuffer(e.data)}}),n.onSocketClose(function(){o.end(),o.destroy()}),n.onSocketError(function(e){o.destroy(e)})),o}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.