var Re=Object.defineProperty,Be=Object.defineProperties;var Ne=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var Se=(ie,oe,I)=>oe in ie?Re(ie,oe,{enumerable:!0,configurable:!0,writable:!0,value:I}):ie[oe]=I,be=(ie,oe)=>{for(var I in oe||(oe={}))Ee.call(oe,I)&&Se(ie,I,oe[I]);if(me)for(var I of me(oe))Ce.call(oe,I)&&Se(ie,I,oe[I]);return ie},ve=(ie,oe)=>Be(ie,Ne(oe));var Te=(ie,oe)=>{var I={};for(var z in ie)Ee.call(ie,z)&&oe.indexOf(z)<0&&(I[z]=ie[z]);if(ie!=null&&me)for(var z of me(ie))oe.indexOf(z)<0&&Ce.call(ie,z)&&(I[z]=ie[z]);return I};import{c as fe,d as Le,r as je,a as he,o as Ue,b as _e,e as ge,w as ee,f as J,g as pe,h as ce,i as xe,u as de,j as ae,t as Ae,k as Ie,l as Pe,F as Oe}from"./index-P0FmoEvT.js";import{c as we}from"./_commonjs-dynamic-modules-TDtrdbi3.js";var ke={exports:{}},Me;function qe(){return Me||(Me=1,function(ie,oe){(function(I){ie.exports=I()})(function(){return function(){return function I(z,q,w){function p(i,e){if(!q[i]){if(!z[i]){var a=typeof we=="function"&&we;if(!e&&a)return a(i,!0);if(d)return d(i,!0);var n=new Error("Cannot find module '"+i+"'");throw n.code="MODULE_NOT_FOUND",n}var t=q[i]={exports:{}};z[i][0].call(t.exports,function(o){return p(z[i][1][o]||o)},t,t.exports,I,z,q,w)}return q[i].exports}for(var d=typeof we=="function"&&we,u=0;u0&&(A.topicAliasMaximum>65535?c("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new i(A.topicAliasMaximum)),this.on("connect",function(){const B=this.queue;c("connect :: sending queued packets"),function P(){const M=B.shift();c("deliver :: entry %o",M);let R=null;if(!M)return void L._resubscribe();R=M.packet,c("deliver :: call _sendPacket for %o",R);let O=!0;R.messageId&&R.messageId!==0&&(L.messageIdProvider.register(R.messageId)||(O=!1)),O?L._sendPacket(R,function(U){M.cb&&M.cb(U),P()}):(c("messageId: %d has already used. The message is skipped and removed.",R.messageId),P())}()}),this.on("close",function(){c("close :: connected set to `false`"),this.connected=!1,c("close :: clearing connackTimer"),clearTimeout(this.connackTimer),c("close :: clearing ping timer"),L.pingTimer!==null&&(L.pingTimer.clear(),L.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),c("close :: calling _setupReconnect"),this._setupReconnect()}),d.call(this),c("MqttClient :: setting up stream"),this._setupStream()}o(C,d),C.prototype._setupStream=function(){const k=this,A=new t,N=a.parser(this.options);let L=null;const B=[];function P(){if(B.length)v(M);else{const O=L;L=null,O()}}function M(){c("work :: getting next packet in queue");const O=B.shift();if(O)c("work :: packet pulled from queue"),k._handlePacket(O,P);else{c("work :: no packets in queue");const U=L;L=null,c("work :: done flag is %s",!!U),U&&U()}}c("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),c("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),N.on("packet",function(O){c("parser :: on packet push to packets array."),B.push(O)}),A._write=function(O,U,H){L=H,c("writable stream :: parsing buffer"),N.parse(O),M()},c("_setupStream :: pipe stream to writable stream"),this.stream.pipe(A),this.stream.on("error",function(O){c("streamErrorHandler :: error",O.message),T.includes(O.code)?(c("streamErrorHandler :: emitting error"),k.emit("error",O)):y(O)}),this.stream.on("close",function(){var O;c("(%s)stream :: on close",k.options.clientId),(O=k.outgoing)&&(c("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(O).forEach(function(U){O[U].volatile&&typeof O[U].cb=="function"&&(O[U].cb(new Error("Connection closed")),delete O[U])})),c("stream: emit close to MqttClient"),k.emit("close")}),c("_setupStream: sending packet `connect`");const R=Object.create(this.options);if(R.cmd="connect",this.topicAliasRecv&&(R.properties||(R.properties={}),this.topicAliasRecv&&(R.properties.topicAliasMaximum=this.topicAliasRecv.max)),W(this,R),N.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return k.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"&&W(this,g({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){c("!!connectTimeout hit!! Calling _cleanUp with force `true`"),k._cleanUp(!0)},this.options.connectTimeout)},C.prototype._handlePacket=function(k,A){const N=this.options;if(N.protocolVersion===5&&N.properties&&N.properties.maximumPacketSize&&N.properties.maximumPacketSize0||!M())&&this._storeProcessingQueue.push({invoke:M,cbStorePut:N.cbStorePut,callback:L}),this},C.prototype.subscribe=function(){const k=this,A=new Array(arguments.length);for(let V=0;V0){const r={qos:G.qos};R===5&&(r.nl=G.nl||!1,r.rap=G.rap||!1,r.rh=G.rh||0,r.properties=G.properties),k._resubscribeTopics[G.topic]=r,$.push(G.topic)}}),k.messageIdToTopic[K.messageId]=$}return k.outgoing[K.messageId]={volatile:!0,cb:function($,G){if(!$){const r=G.granted;for(let s=0;s0||!H())&&this._storeProcessingQueue.push({invoke:H,callback:P}),this},C.prototype.unsubscribe=function(){const k=this,A=new Array(arguments.length);for(let R=0;R0||!M())&&this._storeProcessingQueue.push({invoke:M,callback:L}),this},C.prototype.end=function(k,A,N){const L=this;function B(){c("end :: (%s) :: finish :: calling _cleanUp with force %s",L.options.clientId,k),L._cleanUp(k,()=>{c("end :: finish :: calling process.nextTick on closeStores"),v(function(){c("end :: closeStores: closing incoming and outgoing stores"),L.disconnected=!0,L.incomingStore.close(function(P){L.outgoingStore.close(function(M){if(c("end :: closeStores: emitting end"),L.emit("end"),N){const R=P||M;c("end :: closeStores: invoking callback with args"),N(R)}})}),L._deferredReconnect&&L._deferredReconnect()}.bind(L))},A)}return c("end :: (%s)",this.options.clientId),k!=null&&typeof k=="boolean"||(N=A||y,A=k,k=!1,typeof A!="object"&&(N=A,A=null,typeof N!="function"&&(N=y))),typeof A!="object"&&(N=A,A=null),c("end :: cb? %s",!!N),N=N||y,this.disconnecting?(N(),this):(this._clearReconnect(),this.disconnecting=!0,!k&&Object.keys(this.outgoing).length>0?(c("end :: (%s) :: calling finish in 10ms once outgoing is empty",L.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,B,10))):(c("end :: (%s) :: immediately calling finish",L.options.clientId),B()),this)},C.prototype.removeOutgoingMessage=function(k){const A=this.outgoing[k]?this.outgoing[k].cb:null;return delete this.outgoing[k],this.outgoingStore.del({messageId:k},function(){A(new Error("Message removed"))}),this},C.prototype.reconnect=function(k){c("client reconnect");const A=this,N=function(){k?(A.options.incomingStore=k.incomingStore,A.options.outgoingStore=k.outgoingStore):(A.options.incomingStore=null,A.options.outgoingStore=null),A.incomingStore=A.options.incomingStore||new u,A.outgoingStore=A.options.outgoingStore||new u,A.disconnecting=!1,A.disconnected=!1,A._deferredReconnect=null,A._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=N:N(),this},C.prototype._reconnect=function(){c("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),c("client already connected. disconnecting first.")):(c("_reconnect: calling _setupStream"),this._setupStream())},C.prototype._setupReconnect=function(){const k=this;!k.disconnecting&&!k.reconnectTimer&&k.options.reconnectPeriod>0?(this.reconnecting||(c("_setupReconnect :: emit `offline` state"),this.emit("offline"),c("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),c("_setupReconnect :: setting reconnectTimer for %d ms",k.options.reconnectPeriod),k.reconnectTimer=setInterval(function(){c("reconnectTimer :: reconnect triggered!"),k._reconnect()},k.options.reconnectPeriod)):c("_setupReconnect :: doing nothing...")},C.prototype._clearReconnect=function(){c("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},C.prototype._cleanUp=function(k,A){const N=arguments[2];if(A&&(c("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",A)),c("_cleanUp :: forced? %s",k),k)this.options.reconnectPeriod===0&&this.options.clean&&(L=this.outgoing)&&(c("flush: queue exists? %b",!!L),Object.keys(L).forEach(function(B){typeof L[B].cb=="function"&&(L[B].cb(new Error("Connection closed")),delete L[B])})),c("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const B=g({cmd:"disconnect"},N);c("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(B,_.bind(null,this.stream.end.bind(this.stream)))}var L;this.disconnecting||(c("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(c("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),A&&!this.connected&&(c("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",A),A())},C.prototype._sendPacket=function(k,A,N){c("_sendPacket :: (%s) :: start",this.options.clientId),N=N||y,A=A||y;const L=function(B,P){if(B.options.protocolVersion===5&&P.cmd==="publish"){let M;P.properties&&(M=P.properties.topicAlias);const R=P.topic.toString();if(B.topicAliasSend)if(M){if(R.length!==0&&(c("applyTopicAlias :: register topic: %s - alias: %d",R,M),!B.topicAliasSend.put(R,M)))return c("applyTopicAlias :: error out of range. topic: %s - alias: %d",R,M),new Error("Sending Topic Alias out of range")}else R.length!==0&&(B.options.autoAssignTopicAlias?(M=B.topicAliasSend.getAliasByTopic(R))?(P.topic="",P.properties=ve(be({},P.properties),{topicAlias:M}),c("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",R,M)):(M=B.topicAliasSend.getLruAlias(),B.topicAliasSend.put(R,M),P.properties=ve(be({},P.properties),{topicAlias:M}),c("applyTopicAlias :: auto assign topic: %s - alias: %d",R,M)):B.options.autoUseTopicAlias&&(M=B.topicAliasSend.getAliasByTopic(R))&&(P.topic="",P.properties=ve(be({},P.properties),{topicAlias:M}),c("applyTopicAlias :: auto use topic: %s - alias: %d",R,M)));else if(M)return c("applyTopicAlias :: error out of range. topic: %s - alias: %d",R,M),new Error("Sending Topic Alias out of range")}}(this,k);if(L)A(L);else{if(!this.connected)return k.cmd==="auth"?(this._shiftPingInterval(),void W(this,k,A)):(c("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(k,A,N));switch(this._shiftPingInterval(),k.cmd){case"publish":break;case"pubrel":return void m(this,k,A,N);default:return void W(this,k,A)}switch(k.qos){case 2:case 1:m(this,k,A,N);break;case 0:default:W(this,k,A)}c("_sendPacket :: (%s) :: end",this.options.clientId)}},C.prototype._storePacket=function(k,A,N){c("_storePacket :: packet: %o",k),c("_storePacket :: cb? %s",!!A),N=N||y;let L=k;if(L.cmd==="publish"){const B=F(this,L=l(k));if(B)return A&&A(B)}(L.qos||0)===0&&this.queueQoSZero||L.cmd!=="publish"?this.queue.push({packet:L,cb:A}):L.qos>0?(A=this.outgoing[L.messageId]?this.outgoing[L.messageId].cb:null,this.outgoingStore.put(L,function(B){if(B)return A&&A(B);N()})):A&&A(new Error("No connection to broker"))},C.prototype._setupPingTimer=function(){c("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const k=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=f(function(){k._checkPing()},1e3*this.options.keepalive))},C.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},C.prototype._checkPing=function(){c("_checkPing :: checking ping..."),this.pingResp?(c("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(c("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},C.prototype._handlePingresp=function(){this.pingResp=!0},C.prototype._handleConnack=function(k){c("_handleConnack");const A=this.options,N=A.protocolVersion===5?k.reasonCode:k.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,k.properties){if(k.properties.topicAliasMaximum){if(k.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));k.properties.topicAliasMaximum>0&&(this.topicAliasSend=new e(k.properties.topicAliasMaximum))}k.properties.serverKeepAlive&&A.keepalive&&(A.keepalive=k.properties.serverKeepAlive,this._shiftPingInterval()),k.properties.maximumPacketSize&&(A.properties||(A.properties={}),A.properties.maximumPacketSize=k.properties.maximumPacketSize)}if(N===0)this.reconnecting=!1,this._onConnect(k);else if(N>0){const L=new Error("Connection refused: "+S[N]);L.code=N,this.emit("error",L)}},C.prototype._handleAuth=function(k){const A=this.options.protocolVersion,N=A===5?k.reasonCode:k.returnCode;if(A!==5){const B=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+A);return B.code=N,void this.emit("error",B)}const L=this;this.handleAuth(k,function(B,P){if(B)L.emit("error",B);else if(N===24)L.reconnecting=!1,L._sendPacket(P);else{const M=new Error("Connection refused: "+S[N]);B.code=N,L.emit("error",M)}})},C.prototype.handleAuth=function(k,A){A()},C.prototype._handlePublish=function(k,A){c("_handlePublish: packet %o",k),A=A!==void 0?A:y;let N=k.topic.toString();const L=k.payload,B=k.qos,P=k.messageId,M=this,R=this.options,O=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let U;if(k.properties&&(U=k.properties.topicAlias),U!==void 0)if(N.length===0){if(!(U>0&&U<=65535))return c("_handlePublish :: topic alias out of range. alias: %d",U),void this.emit("error",new Error("Received Topic Alias is out of range"));{const H=this.topicAliasRecv.getTopicByAlias(U);if(!H)return c("_handlePublish :: unregistered topic alias. alias: %d",U),void this.emit("error",new Error("Received unregistered Topic Alias"));c("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",N=H,U)}}else{if(!this.topicAliasRecv.put(N,U))return c("_handlePublish :: topic alias out of range. alias: %d",U),void this.emit("error",new Error("Received Topic Alias is out of range"));c("_handlePublish :: registered topic: %s - alias: %d",N,U)}}switch(c("_handlePublish: qos %d",B),B){case 2:R.customHandleAcks(N,L,k,function(U,H){return U instanceof Error||(H=U,U=null),U?M.emit("error",U):O.indexOf(H)===-1?M.emit("error",new Error("Wrong reason code for pubrec")):void(H?M._sendPacket({cmd:"pubrec",messageId:P,reasonCode:H},A):M.incomingStore.put(k,function(){M._sendPacket({cmd:"pubrec",messageId:P},A)}))});break;case 1:R.customHandleAcks(N,L,k,function(U,H){return U instanceof Error||(H=U,U=null),U?M.emit("error",U):O.indexOf(H)===-1?M.emit("error",new Error("Wrong reason code for puback")):(H||M.emit("message",N,L,k),void M.handleMessage(k,function(V){if(V)return A&&A(V);M._sendPacket({cmd:"puback",messageId:P,reasonCode:H},A)}))});break;case 0:this.emit("message",N,L,k),this.handleMessage(k,A);break;default:c("_handlePublish: unknown QoS. Doing nothing.")}},C.prototype.handleMessage=function(k,A){A()},C.prototype._handleAck=function(k){const A=k.messageId,N=k.cmd;let L=null;const B=this.outgoing[A]?this.outgoing[A].cb:null,P=this;let M;if(B){switch(c("_handleAck :: packet type",N),N){case"pubcomp":case"puback":{const R=k.reasonCode;R&&R>0&&R!==16&&((M=new Error("Publish error: "+S[R])).code=R,B(M,k)),delete this.outgoing[A],this.outgoingStore.del(k,B),this.messageIdProvider.deallocate(A),this._invokeStoreProcessingQueue();break}case"pubrec":{L={cmd:"pubrel",qos:2,messageId:A};const R=k.reasonCode;R&&R>0&&R!==16?((M=new Error("Publish error: "+S[R])).code=R,B(M,k)):this._sendPacket(L);break}case"suback":delete this.outgoing[A],this.messageIdProvider.deallocate(A);for(let R=0;R0)if(this.options.resubscribe)if(this.options.protocolVersion===5){c("_resubscribe: protocolVersion 5");for(let A=0;A0){const k=this._storeProcessingQueue[0];if(k&&k.invoke())return this._storeProcessingQueue.shift(),!0}return!1},C.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},C.prototype._flushStoreProcessingQueue=function(){for(const k of this._storeProcessingQueue)k.cbStorePut&&k.cbStorePut(new Error("Connection closed")),k.callback&&k.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},z.exports=C}).call(this)}).call(this,I("_process"),typeof fe!="undefined"?fe:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(I,z,q){const{Buffer:w}=I("buffer"),p=I("readable-stream").Transform,d=I("duplexify");let u,i,e,a=!1;z.exports=function(n,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const o=t.protocolId==="MQIsdp"&&t.protocolVersion===3?"mqttv3.1":"mqtt";(function(l){l.hostname||(l.hostname="localhost"),l.path||(l.path="/"),l.wsOptions||(l.wsOptions={})})(t);const f=function(l,h){const g=l.protocol==="alis"?"wss":"ws";let c=g+"://"+l.hostname+l.path;return l.port&&l.port!==80&&l.port!==443&&(c=g+"://"+l.hostname+":"+l.port+l.path),typeof l.transformWsUrl=="function"&&(c=l.transformWsUrl(c,l,h)),c}(t,n);return(u=t.my).connectSocket({url:f,protocols:o}),i=function(){const l=new p;return l._write=function(h,g,c){u.sendSocketMessage({data:h.buffer,success:function(){c()},fail:function(){c(new Error)}})},l._flush=function(h){u.closeSocket({success:function(){h()}})},l}(),e=d.obj(),a||(a=!0,u.onSocketOpen(function(){e.setReadable(i),e.setWritable(i),e.emit("connect")}),u.onSocketMessage(function(l){if(typeof l.data=="string"){const h=w.from(l.data,"base64");i.push(h)}else{const h=new FileReader;h.addEventListener("load",function(){let g=h.result;g=g instanceof ArrayBuffer?w.from(g):w.from(g,"utf8"),i.push(g)}),h.readAsArrayBuffer(l.data)}}),u.onSocketClose(function(){e.end(),e.destroy()}),u.onSocketError(function(l){e.destroy(l)})),e}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(I,z,q){const w=I("net"),p=I("debug")("mqttjs:tcp");z.exports=function(d,u){u.port=u.port||1883,u.hostname=u.hostname||u.host||"localhost";const i=u.port,e=u.hostname;return p("port %d and host %s",i,e),w.createConnection(i,e)}},{debug:18,net:16}],4:[function(I,z,q){const w=I("tls"),p=I("net"),d=I("debug")("mqttjs:tls");z.exports=function(u,i){i.port=i.port||8883,i.host=i.hostname||i.host||"localhost",p.isIP(i.host)===0&&(i.servername=i.host),i.rejectUnauthorized=i.rejectUnauthorized!==!1,delete i.path,d("port %d host %s rejectUnauthorized %b",i.port,i.host,i.rejectUnauthorized);const e=w.connect(i);function a(n){i.rejectUnauthorized&&u.emit("error",n),e.end()}return e.on("secureConnect",function(){i.rejectUnauthorized&&!e.authorized?e.emit("error",new Error("TLS not authorized")):e.removeListener("error",a)}),e.on("error",a),e}},{debug:18,net:16,tls:16}],5:[function(I,z,q){(function(w){(function(){const{Buffer:p}=I("buffer"),d=I("ws"),u=I("debug")("mqttjs:ws"),i=I("duplexify"),e=I("readable-stream").Transform,a=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],n=w!==void 0&&w.title==="browser"||typeof __webpack_require__=="function";function t(f,l){let h=f.protocol+"://"+f.hostname+":"+f.port+f.path;return typeof f.transformWsUrl=="function"&&(h=f.transformWsUrl(h,f,l)),h}function o(f){const l=f;return f.hostname||(l.hostname="localhost"),f.port||(f.protocol==="wss"?l.port=443:l.port=80),f.path||(l.path="/"),f.wsOptions||(l.wsOptions={}),n||f.protocol!=="wss"||a.forEach(function(h){Object.prototype.hasOwnProperty.call(f,h)&&!Object.prototype.hasOwnProperty.call(f.wsOptions,h)&&(l.wsOptions[h]=f[h])}),l}z.exports=n?function(f,l){let h;u("browserStreamBuilder");const g=function(C){const k=o(C);if(k.hostname||(k.hostname=k.host),!k.hostname){if(typeof document=="undefined")throw new Error("Could not determine host. Specify host manually.");const A=new URL(document.URL);k.hostname=A.hostname,k.port||(k.port=A.port)}return k.objectMode===void 0&&(k.objectMode=!(k.binary===!0||k.binary===void 0)),k}(l).browserBufferSize||524288,c=l.browserBufferTimeout||1e3,v=!l.objectMode,_=function(C,k){const A=k.protocolId==="MQIsdp"&&k.protocolVersion===3?"mqttv3.1":"mqtt",N=t(k,C),L=new WebSocket(N,[A]);return L.binaryType="arraybuffer",L}(f,l),E=function(C,k,A){const N=new e({objectModeMode:C.objectMode});return N._write=k,N._flush=A,N}(l,function C(k,A,N){_.bufferedAmount>g&&setTimeout(C,c,k,A,N),v&&typeof k=="string"&&(k=p.from(k,"utf8"));try{_.send(k)}catch(L){return N(L)}N()},function(C){_.close(),C()});l.objectMode||(E._writev=y),E.on("close",()=>{_.close()});const T=_.addEventListener!==void 0;function S(){h.setReadable(E),h.setWritable(E),h.emit("connect")}function F(){h.end(),h.destroy()}function W(C){h.destroy(C)}function m(C){let k=C.data;k=k instanceof ArrayBuffer?p.from(k):p.from(k,"utf8"),E.push(k)}function y(C,k){const A=new Array(C.length);for(let N=0;N{v.destroy()}),v}}).call(this)}).call(this,I("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(I,z,q){const{Buffer:w}=I("buffer"),p=I("readable-stream").Transform,d=I("duplexify");let u,i,e;z.exports=function(a,n){if(n.hostname=n.hostname||n.host,!n.hostname)throw new Error("Could not determine host. Specify host manually.");const t=n.protocolId==="MQIsdp"&&n.protocolVersion===3?"mqttv3.1":"mqtt";(function(l){l.hostname||(l.hostname="localhost"),l.path||(l.path="/"),l.wsOptions||(l.wsOptions={})})(n);const o=function(l,h){const g=l.protocol==="wxs"?"wss":"ws";let c=g+"://"+l.hostname+l.path;return l.port&&l.port!==80&&l.port!==443&&(c=g+"://"+l.hostname+":"+l.port+l.path),typeof l.transformWsUrl=="function"&&(c=l.transformWsUrl(c,l,h)),c}(n,a);u=wx.connectSocket({url:o,protocols:[t]}),i=function(){const l=new p;return l._write=function(h,g,c){u.send({data:h.buffer,success:function(){c()},fail:function(v){c(new Error(v))}})},l._flush=function(h){u.close({success:function(){h()}})},l}(),(e=d.obj())._destroy=function(l,h){u.close({success:function(){h&&h(l)}})};const f=e.destroy;return e.destroy=function(){e.destroy=f;const l=this;setTimeout(function(){u.close({fail:function(){l._destroy(new Error)}})},0)}.bind(e),u.onOpen(function(){e.setReadable(i),e.setWritable(i),e.emit("connect")}),u.onMessage(function(l){let h=l.data;h=h instanceof ArrayBuffer?w.from(h):w.from(h,"utf8"),i.push(h)}),u.onClose(function(){e.end(),e.destroy()}),u.onError(function(l){e.destroy(new Error(l.errMsg))}),e}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(I,z,q){function w(){if(!(this instanceof w))return new w;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}w.prototype.allocate=function(){const p=this.nextId++;return this.nextId===65536&&(this.nextId=1),p},w.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},w.prototype.register=function(p){return!0},w.prototype.deallocate=function(p){},w.prototype.clear=function(){},z.exports=w},{}],8:[function(I,z,q){const w=I("xtend"),p=I("readable-stream").Readable,d={objectMode:!0},u={clean:!0};function i(e){if(!(this instanceof i))return new i(e);this.options=e||{},this.options=w(u,e),this._inflights=new Map}i.prototype.put=function(e,a){return this._inflights.set(e.messageId,e),a&&a(),this},i.prototype.createStream=function(){const e=new p(d),a=[];let n=!1,t=0;return this._inflights.forEach(function(o,f){a.push(o)}),e._read=function(){!n&&tthis.max)&&(this.aliasToTopic[d]=p,this.length=Object.keys(this.aliasToTopic).length,!0)},w.prototype.getTopicByAlias=function(p){return this.aliasToTopic[p]},w.prototype.clear=function(){this.aliasToTopic={}},z.exports=w},{}],10:[function(I,z,q){const w=I("lru-cache"),p=I("number-allocator").NumberAllocator;function d(u){if(!(this instanceof d))return new d(u);u>0&&(this.aliasToTopic=new w({max:u}),this.topicToAlias={},this.numberAllocator=new p(1,u),this.max=u,this.length=0)}d.prototype.put=function(u,i){if(i===0||i>this.max)return!1;const e=this.aliasToTopic.get(i);return e&&delete this.topicToAlias[e],this.aliasToTopic.set(i,u),this.topicToAlias[u]=i,this.numberAllocator.use(i),this.length=this.aliasToTopic.length,!0},d.prototype.getTopicByAlias=function(u){return this.aliasToTopic.get(u)},d.prototype.getAliasByTopic=function(u){const i=this.topicToAlias[u];return i!==void 0&&this.aliasToTopic.get(i),i},d.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},d.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},z.exports=d},{"lru-cache":37,"number-allocator":46}],11:[function(I,z,q){function w(p){const d=p.split("/");for(let u=0;u0?h-4:h;for(f=0;f<_;f+=4)o=p[t.charCodeAt(f)]<<18|p[t.charCodeAt(f+1)]<<12|p[t.charCodeAt(f+2)]<<6|p[t.charCodeAt(f+3)],c[v++]=o>>16&255,c[v++]=o>>8&255,c[v++]=255&o;return g===2&&(o=p[t.charCodeAt(f)]<<2|p[t.charCodeAt(f+1)]>>4,c[v++]=255&o),g===1&&(o=p[t.charCodeAt(f)]<<10|p[t.charCodeAt(f+1)]<<4|p[t.charCodeAt(f+2)]>>2,c[v++]=o>>8&255,c[v++]=255&o),c},q.fromByteArray=function(t){for(var o,f=t.length,l=f%3,h=[],g=0,c=f-l;gc?c:g+16383));return l===1?(o=t[f-1],h.push(w[o>>2]+w[o<<4&63]+"==")):l===2&&(o=(t[f-2]<<8)+t[f-1],h.push(w[o>>10]+w[o>>4&63]+w[o<<2&63]+"=")),h.join("")};for(var w=[],p=[],d=typeof Uint8Array!="undefined"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,e=u.length;i0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.indexOf("=");return f===-1&&(f=o),[f,f===o?0:4-f%4]}function n(t,o,f){for(var l,h,g=[],c=o;c>18&63]+w[h>>12&63]+w[h>>6&63]+w[63&h]);return g.join("")}p[45]=62,p[95]=63},{}],14:[function(I,z,q){const{Buffer:w}=I("buffer"),p=Symbol.for("BufferList");function d(u){if(!(this instanceof d))return new d(u);d._init.call(this,u)}d._init=function(u){Object.defineProperty(this,p,{value:!0}),this._bufs=[],this.length=0,u&&this.append(u)},d.prototype._new=function(u){return new d(u)},d.prototype._offset=function(u){if(u===0)return[0,0];let i=0;for(let e=0;ethis.length||u<0)return;const i=this._offset(u);return this._bufs[i[0]][i[1]]},d.prototype.slice=function(u,i){return typeof u=="number"&&u<0&&(u+=this.length),typeof i=="number"&&i<0&&(i+=this.length),this.copy(null,0,u,i)},d.prototype.copy=function(u,i,e,a){if((typeof e!="number"||e<0)&&(e=0),(typeof a!="number"||a>this.length)&&(a=this.length),e>=this.length||a<=0)return u||w.alloc(0);const n=!!u,t=this._offset(e),o=a-e;let f=o,l=n&&i||0,h=t[1];if(e===0&&a===this.length){if(!n)return this._bufs.length===1?this._bufs[0]:w.concat(this._bufs,this.length);for(let g=0;gc)){this._bufs[g].copy(u,l,h,h+f),l+=c;break}this._bufs[g].copy(u,l,h),l+=c,f-=c,h&&(h=0)}return u.length>l?u.slice(0,l):u},d.prototype.shallowSlice=function(u,i){if(u=u||0,i=typeof i!="number"?this.length:i,u<0&&(u+=this.length),i<0&&(i+=this.length),u===i)return this._new();const e=this._offset(u),a=this._offset(i),n=this._bufs.slice(e[0],a[0]+1);return a[1]===0?n.pop():n[n.length-1]=n[n.length-1].slice(0,a[1]),e[1]!==0&&(n[0]=n[0].slice(e[1])),this._new(n)},d.prototype.toString=function(u,i,e){return this.slice(i,e).toString(u)},d.prototype.consume=function(u){if(u=Math.trunc(u),Number.isNaN(u)||u<=0)return this;for(;this._bufs.length;){if(!(u>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(u),this.length-=u;break}u-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},d.prototype.duplicate=function(){const u=this._new();for(let i=0;ithis.length?this.length:i;const a=this._offset(i);let n=a[0],t=a[1];for(;n=u.length){const f=o.indexOf(u,t);if(f!==-1)return this._reverseOffset([n,f]);t=o.length-u.length+1}else{const f=this._reverseOffset([n,t]);if(this._match(f,u))return f;t++}t=0}return-1},d.prototype._match=function(u,i){if(this.length-uu)throw new RangeError('The value "'+r+'" is invalid for option "size"');var s=new Uint8Array(r);return s.__proto__=e.prototype,s}function e(r,s,b){if(typeof r=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return t(r)}return a(r,s,b)}function a(r,s,b){if(typeof r=="string")return function(D,Q){if(typeof Q=="string"&&Q!==""||(Q="utf8"),!e.isEncoding(Q))throw new TypeError("Unknown encoding: "+Q);var Z=0|l(D,Q),Y=i(Z),X=Y.write(D,Q);return X!==Z&&(Y=Y.slice(0,X)),Y}(r,s);if(ArrayBuffer.isView(r))return o(r);if(r==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if($(r,ArrayBuffer)||r&&$(r.buffer,ArrayBuffer))return function(D,Q,Z){if(Q<0||D.byteLength=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return 0|r}function l(r,s){if(e.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||$(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var b=r.length,x=arguments.length>2&&arguments[2]===!0;if(!x&&b===0)return 0;for(var j=!1;;)switch(s){case"ascii":case"latin1":case"binary":return b;case"utf8":case"utf-8":return H(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*b;case"hex":return b>>>1;case"base64":return V(r).length;default:if(j)return x?-1:H(r).length;s=(""+s).toLowerCase(),j=!0}}function h(r,s,b){var x=r[s];r[s]=r[b],r[b]=x}function g(r,s,b,x,j){if(r.length===0)return-1;if(typeof b=="string"?(x=b,b=0):b>2147483647?b=2147483647:b<-2147483648&&(b=-2147483648),G(b=+b)&&(b=j?0:r.length-1),b<0&&(b=r.length+b),b>=r.length){if(j)return-1;b=r.length-1}else if(b<0){if(!j)return-1;b=0}if(typeof s=="string"&&(s=e.from(s,x)),e.isBuffer(s))return s.length===0?-1:c(r,s,b,x,j);if(typeof s=="number")return s&=255,typeof Uint8Array.prototype.indexOf=="function"?j?Uint8Array.prototype.indexOf.call(r,s,b):Uint8Array.prototype.lastIndexOf.call(r,s,b):c(r,[s],b,x,j);throw new TypeError("val must be string, number or Buffer")}function c(r,s,b,x,j){var D,Q=1,Z=r.length,Y=s.length;if(x!==void 0&&((x=String(x).toLowerCase())==="ucs2"||x==="ucs-2"||x==="utf16le"||x==="utf-16le")){if(r.length<2||s.length<2)return-1;Q=2,Z/=2,Y/=2,b/=2}function X(ue,re){return Q===1?ue[re]:ue.readUInt16BE(re*Q)}if(j){var te=-1;for(D=b;DZ&&(b=Z-Y),D=b;D>=0;D--){for(var le=!0,se=0;sej&&(x=j):x=j;var D=s.length;x>D/2&&(x=D/2);for(var Q=0;Q>8,Y=Q%256,X.push(Y),X.push(Z);return X}(s,r.length-b),r,b,x)}function W(r,s,b){return s===0&&b===r.length?p.fromByteArray(r):p.fromByteArray(r.slice(s,b))}function m(r,s,b){b=Math.min(r.length,b);for(var x=[],j=s;j239?4:X>223?3:X>191?2:1;if(j+le<=b)switch(le){case 1:X<128&&(te=X);break;case 2:(192&(D=r[j+1]))==128&&(Y=(31&X)<<6|63&D)>127&&(te=Y);break;case 3:D=r[j+1],Q=r[j+2],(192&D)==128&&(192&Q)==128&&(Y=(15&X)<<12|(63&D)<<6|63&Q)>2047&&(Y<55296||Y>57343)&&(te=Y);break;case 4:D=r[j+1],Q=r[j+2],Z=r[j+3],(192&D)==128&&(192&Q)==128&&(192&Z)==128&&(Y=(15&X)<<18|(63&D)<<12|(63&Q)<<6|63&Z)>65535&&Y<1114112&&(te=Y)}te===null?(te=65533,le=1):te>65535&&(te-=65536,x.push(te>>>10&1023|55296),te=56320|1023&te),x.push(te),j+=le}return function(se){var ue=se.length;if(ue<=y)return String.fromCharCode.apply(String,se);for(var re="",ne=0;nethis.length||((x===void 0||x>this.length)&&(x=this.length),x<=0)||(x>>>=0)<=(b>>>=0))return"";for(s||(s="utf8");;)switch(s){case"hex":return A(this,b,x);case"utf8":case"utf-8":return m(this,b,x);case"ascii":return C(this,b,x);case"latin1":case"binary":return k(this,b,x);case"base64":return W(this,b,x);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,b,x);default:if(j)throw new TypeError("Unknown encoding: "+s);s=(s+"").toLowerCase(),j=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(r){if(!e.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r||e.compare(this,r)===0},e.prototype.inspect=function(){var r="",s=q.INSPECT_MAX_BYTES;return r=this.toString("hex",0,s).replace(/(.{2})/g,"$1 ").trim(),this.length>s&&(r+=" ... "),""},e.prototype.compare=function(r,s,b,x,j){if($(r,Uint8Array)&&(r=e.from(r,r.offset,r.byteLength)),!e.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(s===void 0&&(s=0),b===void 0&&(b=r?r.length:0),x===void 0&&(x=0),j===void 0&&(j=this.length),s<0||b>r.length||x<0||j>this.length)throw new RangeError("out of range index");if(x>=j&&s>=b)return 0;if(x>=j)return-1;if(s>=b)return 1;if(s>>>=0,b>>>=0,x>>>=0,j>>>=0,this===r)return 0;for(var D=j-x,Q=b-s,Z=Math.min(D,Q),Y=this.slice(x,j),X=r.slice(s,b),te=0;te>>=0,isFinite(b)?(b>>>=0,x===void 0&&(x="utf8")):(x=b,b=void 0)}var j=this.length-s;if((b===void 0||b>j)&&(b=j),r.length>0&&(b<0||s<0)||s>this.length)throw new RangeError("Attempt to write outside buffer bounds");x||(x="utf8");for(var D=!1;;)switch(x){case"hex":return v(this,r,s,b);case"utf8":case"utf-8":return _(this,r,s,b);case"ascii":return E(this,r,s,b);case"latin1":case"binary":return T(this,r,s,b);case"base64":return S(this,r,s,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,r,s,b);default:if(D)throw new TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),D=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var y=4096;function C(r,s,b){var x="";b=Math.min(r.length,b);for(var j=s;jx)&&(b=x);for(var j="",D=s;Db)throw new RangeError("Trying to access beyond buffer length")}function B(r,s,b,x,j,D){if(!e.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>j||sr.length)throw new RangeError("Index out of range")}function P(r,s,b,x,j,D){if(b+x>r.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("Index out of range")}function M(r,s,b,x,j){return s=+s,b>>>=0,j||P(r,0,b,4),d.write(r,s,b,x,23,4),b+4}function R(r,s,b,x,j){return s=+s,b>>>=0,j||P(r,0,b,8),d.write(r,s,b,x,52,8),b+8}e.prototype.slice=function(r,s){var b=this.length;r=~~r,s=s===void 0?b:~~s,r<0?(r+=b)<0&&(r=0):r>b&&(r=b),s<0?(s+=b)<0&&(s=0):s>b&&(s=b),s>>=0,s>>>=0,b||L(r,s,this.length);for(var x=this[r],j=1,D=0;++D>>=0,s>>>=0,b||L(r,s,this.length);for(var x=this[r+--s],j=1;s>0&&(j*=256);)x+=this[r+--s]*j;return x},e.prototype.readUInt8=function(r,s){return r>>>=0,s||L(r,1,this.length),this[r]},e.prototype.readUInt16LE=function(r,s){return r>>>=0,s||L(r,2,this.length),this[r]|this[r+1]<<8},e.prototype.readUInt16BE=function(r,s){return r>>>=0,s||L(r,2,this.length),this[r]<<8|this[r+1]},e.prototype.readUInt32LE=function(r,s){return r>>>=0,s||L(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},e.prototype.readUInt32BE=function(r,s){return r>>>=0,s||L(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},e.prototype.readIntLE=function(r,s,b){r>>>=0,s>>>=0,b||L(r,s,this.length);for(var x=this[r],j=1,D=0;++D=(j*=128)&&(x-=Math.pow(2,8*s)),x},e.prototype.readIntBE=function(r,s,b){r>>>=0,s>>>=0,b||L(r,s,this.length);for(var x=s,j=1,D=this[r+--x];x>0&&(j*=256);)D+=this[r+--x]*j;return D>=(j*=128)&&(D-=Math.pow(2,8*s)),D},e.prototype.readInt8=function(r,s){return r>>>=0,s||L(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},e.prototype.readInt16LE=function(r,s){r>>>=0,s||L(r,2,this.length);var b=this[r]|this[r+1]<<8;return 32768&b?4294901760|b:b},e.prototype.readInt16BE=function(r,s){r>>>=0,s||L(r,2,this.length);var b=this[r+1]|this[r]<<8;return 32768&b?4294901760|b:b},e.prototype.readInt32LE=function(r,s){return r>>>=0,s||L(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},e.prototype.readInt32BE=function(r,s){return r>>>=0,s||L(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},e.prototype.readFloatLE=function(r,s){return r>>>=0,s||L(r,4,this.length),d.read(this,r,!0,23,4)},e.prototype.readFloatBE=function(r,s){return r>>>=0,s||L(r,4,this.length),d.read(this,r,!1,23,4)},e.prototype.readDoubleLE=function(r,s){return r>>>=0,s||L(r,8,this.length),d.read(this,r,!0,52,8)},e.prototype.readDoubleBE=function(r,s){return r>>>=0,s||L(r,8,this.length),d.read(this,r,!1,52,8)},e.prototype.writeUIntLE=function(r,s,b,x){r=+r,s>>>=0,b>>>=0,x||B(this,r,s,b,Math.pow(2,8*b)-1,0);var j=1,D=0;for(this[s]=255&r;++D>>=0,b>>>=0,x||B(this,r,s,b,Math.pow(2,8*b)-1,0);var j=b-1,D=1;for(this[s+j]=255&r;--j>=0&&(D*=256);)this[s+j]=r/D&255;return s+b},e.prototype.writeUInt8=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,1,255,0),this[s]=255&r,s+1},e.prototype.writeUInt16LE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,2,65535,0),this[s]=255&r,this[s+1]=r>>>8,s+2},e.prototype.writeUInt16BE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,2,65535,0),this[s]=r>>>8,this[s+1]=255&r,s+2},e.prototype.writeUInt32LE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,4,4294967295,0),this[s+3]=r>>>24,this[s+2]=r>>>16,this[s+1]=r>>>8,this[s]=255&r,s+4},e.prototype.writeUInt32BE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,4,4294967295,0),this[s]=r>>>24,this[s+1]=r>>>16,this[s+2]=r>>>8,this[s+3]=255&r,s+4},e.prototype.writeIntLE=function(r,s,b,x){if(r=+r,s>>>=0,!x){var j=Math.pow(2,8*b-1);B(this,r,s,b,j-1,-j)}var D=0,Q=1,Z=0;for(this[s]=255&r;++D>0)-Z&255;return s+b},e.prototype.writeIntBE=function(r,s,b,x){if(r=+r,s>>>=0,!x){var j=Math.pow(2,8*b-1);B(this,r,s,b,j-1,-j)}var D=b-1,Q=1,Z=0;for(this[s+D]=255&r;--D>=0&&(Q*=256);)r<0&&Z===0&&this[s+D+1]!==0&&(Z=1),this[s+D]=(r/Q>>0)-Z&255;return s+b},e.prototype.writeInt8=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,1,127,-128),r<0&&(r=255+r+1),this[s]=255&r,s+1},e.prototype.writeInt16LE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,2,32767,-32768),this[s]=255&r,this[s+1]=r>>>8,s+2},e.prototype.writeInt16BE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,2,32767,-32768),this[s]=r>>>8,this[s+1]=255&r,s+2},e.prototype.writeInt32LE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,4,2147483647,-2147483648),this[s]=255&r,this[s+1]=r>>>8,this[s+2]=r>>>16,this[s+3]=r>>>24,s+4},e.prototype.writeInt32BE=function(r,s,b){return r=+r,s>>>=0,b||B(this,r,s,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[s]=r>>>24,this[s+1]=r>>>16,this[s+2]=r>>>8,this[s+3]=255&r,s+4},e.prototype.writeFloatLE=function(r,s,b){return M(this,r,s,!0,b)},e.prototype.writeFloatBE=function(r,s,b){return M(this,r,s,!1,b)},e.prototype.writeDoubleLE=function(r,s,b){return R(this,r,s,!0,b)},e.prototype.writeDoubleBE=function(r,s,b){return R(this,r,s,!1,b)},e.prototype.copy=function(r,s,b,x){if(!e.isBuffer(r))throw new TypeError("argument should be a Buffer");if(b||(b=0),x||x===0||(x=this.length),s>=r.length&&(s=r.length),s||(s=0),x>0&&x=this.length)throw new RangeError("Index out of range");if(x<0)throw new RangeError("sourceEnd out of bounds");x>this.length&&(x=this.length),r.length-s=0;--D)r[D+s]=this[D+b];else Uint8Array.prototype.set.call(r,this.subarray(b,x),s);return j},e.prototype.fill=function(r,s,b,x){if(typeof r=="string"){if(typeof s=="string"?(x=s,s=0,b=this.length):typeof b=="string"&&(x=b,b=this.length),x!==void 0&&typeof x!="string")throw new TypeError("encoding must be a string");if(typeof x=="string"&&!e.isEncoding(x))throw new TypeError("Unknown encoding: "+x);if(r.length===1){var j=r.charCodeAt(0);(x==="utf8"&&j<128||x==="latin1")&&(r=j)}}else typeof r=="number"&&(r&=255);if(s<0||this.length>>=0,b=b===void 0?this.length:b>>>0,r||(r=0),typeof r=="number")for(D=s;D55295&&b<57344){if(!j){if(b>56319){(s-=3)>-1&&D.push(239,191,189);continue}if(Q+1===x){(s-=3)>-1&&D.push(239,191,189);continue}j=b;continue}if(b<56320){(s-=3)>-1&&D.push(239,191,189),j=b;continue}b=65536+(j-55296<<10|b-56320)}else j&&(s-=3)>-1&&D.push(239,191,189);if(j=null,b<128){if((s-=1)<0)break;D.push(b)}else if(b<2048){if((s-=2)<0)break;D.push(b>>6|192,63&b|128)}else if(b<65536){if((s-=3)<0)break;D.push(b>>12|224,b>>6&63|128,63&b|128)}else{if(!(b<1114112))throw new Error("Invalid code point");if((s-=4)<0)break;D.push(b>>18|240,b>>12&63|128,b>>6&63|128,63&b|128)}}return D}function V(r){return p.toByteArray(function(s){if((s=(s=s.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;s.length%4!=0;)s+="=";return s}(r))}function K(r,s,b,x){for(var j=0;j=s.length||j>=r.length);++j)s[j+b]=r[j];return j}function $(r,s){return r instanceof s||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===s.name}function G(r){return r!=r}}).call(this)}).call(this,I("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(I,z,q){(function(w){(function(){q.formatArgs=function(d){if(d[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+d[0]+(this.useColors?"%c ":" ")+"+"+z.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;d.splice(1,0,u,"color: inherit");let i=0,e=0;d[0].replace(/%[a-zA-Z%]/g,a=>{a!=="%%"&&a==="%c"&&(e=++i)}),d.splice(e,0,u)},q.save=function(d){try{d?q.storage.setItem("debug",d):q.storage.removeItem("debug")}catch(u){}},q.load=function(){let d;try{d=q.storage.getItem("debug")}catch(u){}return!d&&w!==void 0&&"env"in w&&(d=w.env.DEBUG),d},q.useColors=function(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},q.storage=function(){try{return localStorage}catch(d){}}(),q.destroy=(()=>{let d=!1;return()=>{d||(d=!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`."))}})(),q.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"],q.log=console.debug||console.log||(()=>{}),z.exports=I("./common")(q);const{formatters:p}=z.exports;p.j=function(d){try{return JSON.stringify(d)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}}).call(this)}).call(this,I("_process"))},{"./common":19,_process:50}],19:[function(I,z,q){z.exports=function(w){function p(i){let e,a,n,t=null;function o(...f){if(!o.enabled)return;const l=o,h=Number(new Date),g=h-(e||h);l.diff=g,l.prev=e,l.curr=h,e=h,f[0]=p.coerce(f[0]),typeof f[0]!="string"&&f.unshift("%O");let c=0;f[0]=f[0].replace(/%([a-zA-Z%])/g,(v,_)=>{if(v==="%%")return"%";c++;const E=p.formatters[_];if(typeof E=="function"){const T=f[c];v=E.call(l,T),f.splice(c,1),c--}return v}),p.formatArgs.call(l,f),(l.log||p.log).apply(l,f)}return o.namespace=i,o.useColors=p.useColors(),o.color=p.selectColor(i),o.extend=d,o.destroy=p.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>t!==null?t:(a!==p.namespaces&&(a=p.namespaces,n=p.enabled(i)),n),set:f=>{t=f}}),typeof p.init=="function"&&p.init(o),o}function d(i,e){const a=p(this.namespace+(e===void 0?":":e)+i);return a.log=this.log,a}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}return p.debug=p,p.default=p,p.coerce=function(i){return i instanceof Error?i.stack||i.message:i},p.disable=function(){const i=[...p.names.map(u),...p.skips.map(u).map(e=>"-"+e)].join(",");return p.enable(""),i},p.enable=function(i){let e;p.save(i),p.namespaces=i,p.names=[],p.skips=[];const a=(typeof i=="string"?i:"").split(/[\s,]+/),n=a.length;for(e=0;e{p[i]=w[i]}),p.names=[],p.skips=[],p.formatters={},p.selectColor=function(i){let e=0;for(let a=0;a0&&F.length>T){F.warned=!0;var W=new Error("Possible EventEmitter memory leak detected. "+F.length+' "'+String(v)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');W.name="MaxListenersExceededWarning",W.emitter=c,W.type=v,W.count=F.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",W.name,W.message)}}else F=S[v]=_,++c._eventsCount;return c}function o(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var c=new Array(arguments.length),v=0;v1&&(v=arguments[1]),v instanceof Error)throw v;var m=new Error('Unhandled "error" event. ('+v+")");throw m.context=v,m}if(!(_=F[c]))return!1;var y=typeof _=="function";switch(E=arguments.length){case 1:(function(C,k,A){if(k)C.call(A);else for(var N=C.length,L=g(C,N),B=0;B=0;S--)if(_[S]===v||_[S].listener===v){F=_[S].listener,T=S;break}if(T<0)return this;T===0?_.shift():function(W,m){for(var y=m,C=y+1,k=W.length;C=0;E--)this.removeListener(c,v[E]);return this},u.prototype.listeners=function(c){return l(this,c,!0)},u.prototype.rawListeners=function(c){return l(this,c,!1)},u.listenerCount=function(c,v){return typeof c.listenerCount=="function"?c.listenerCount(v):h.call(c,v)},u.prototype.listenerCount=h,u.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(I,z,q){q.read=function(w,p,d,u,i){var e,a,n=8*i-u-1,t=(1<>1,f=-7,l=d?i-1:0,h=d?-1:1,g=w[p+l];for(l+=h,e=g&(1<<-f)-1,g>>=-f,f+=n;f>0;e=256*e+w[p+l],l+=h,f-=8);for(a=e&(1<<-f)-1,e>>=-f,f+=u;f>0;a=256*a+w[p+l],l+=h,f-=8);if(e===0)e=1-o;else{if(e===t)return a?NaN:1/0*(g?-1:1);a+=Math.pow(2,u),e-=o}return(g?-1:1)*a*Math.pow(2,e-u)},q.write=function(w,p,d,u,i,e){var a,n,t,o=8*e-i-1,f=(1<>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=u?0:e-1,c=u?1:-1,v=p<0||p===0&&1/p<0?1:0;for(p=Math.abs(p),isNaN(p)||p===1/0?(n=isNaN(p)?1:0,a=f):(a=Math.floor(Math.log(p)/Math.LN2),p*(t=Math.pow(2,-a))<1&&(a--,t*=2),(p+=a+l>=1?h/t:h*Math.pow(2,1-l))*t>=2&&(a++,t/=2),a+l>=f?(n=0,a=f):a+l>=1?(n=(p*t-1)*Math.pow(2,i),a+=l):(n=p*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;w[d+g]=255&n,g+=c,n/=256,i-=8);for(a=a<0;w[d+g]=255&a,g+=c,a/=256,o-=8);w[d+g-c]|=128*v}},{}],24:[function(I,z,q){typeof Object.create=="function"?z.exports=function(w,p){p&&(w.super_=p,w.prototype=Object.create(p.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}))}:z.exports=function(w,p){if(p){w.super_=p;var d=function(){};d.prototype=p.prototype,w.prototype=new d,w.prototype.constructor=w}}},{}],25:[function(I,z,q){Object.defineProperty(q,"__esModule",{value:!0});var w=function(){function p(d,u){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=d,this.value=u}return p.prototype.rotateLeft=function(){var d=this.parent,u=this.brother,i=this.leftChild,e=this.rightChild;if(!e)throw new Error("unknown error");var a=e.leftChild,n=e.rightChild;return d&&(d.leftChild===this?d.leftChild=e:d.rightChild===this&&(d.rightChild=e)),e.parent=d,e.brother=u,e.leftChild=this,e.rightChild=n,u&&(u.brother=e),this.parent=e,this.brother=n,this.leftChild=i,this.rightChild=a,n&&(n.parent=e,n.brother=this),i&&(i.parent=this,i.brother=a),a&&(a.parent=this,a.brother=i),e},p.prototype.rotateRight=function(){var d=this.parent,u=this.brother,i=this.leftChild;if(!i)throw new Error("unknown error");var e=this.rightChild,a=i.leftChild,n=i.rightChild;return d&&(d.leftChild===this?d.leftChild=i:d.rightChild===this&&(d.rightChild=i)),i.parent=d,i.brother=u,i.leftChild=a,i.rightChild=this,u&&(u.brother=i),a&&(a.parent=i,a.brother=this),this.parent=i,this.brother=a,this.leftChild=n,this.rightChild=e,n&&(n.parent=this,n.brother=e),e&&(e.parent=this,e.brother=n),i},p.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},p.TreeNodeColorType={red:!0,black:!1},p}();Object.freeze(w),q.default=w},{}],26:[function(I,z,q){var w=this&&this.__generator||function(d,u){var i,e,a,n,t={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return n={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function o(f){return function(l){return function(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,e&&(a=2&h[0]?e.return:h[0]?e.throw||((a=e.return)&&a.call(e),0):e.next)&&!(a=a.call(e,h[1])).done)return a;switch(e=0,a&&(h=[2&h[0],a.value]),h[0]){case 0:case 1:a=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,e=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(!(a=(a=t.trys).length>0&&a[a.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!a||h[1]>a[0]&&h[1]_)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(v/p.bucketSize),curNodePointerIndex:v%p.bucketSize}};this.getElementByPos=function(g){var c=l(g),v=c.curNodeBucketIndex,_=c.curNodePointerIndex;return i[v][_]},this.eraseElementByPos=function(g){var c=this;if(g<0||g>f)throw new Error("pos should more than 0 and less than queue's size");if(g===0)this.popFront();else if(g===this.size())this.popBack();else{for(var v=[],_=g+1;_0?--t:e0&&--f)},this.setElementByPos=function(g,c){var v=l(g),_=v.curNodeBucketIndex,E=v.curNodePointerIndex;i[_][E]=c},this.insert=function(g,c,v){var _=this;if(v===void 0&&(v=1),g===0)for(;v--;)this.pushFront(c);else if(g===this.size())for(;v--;)this.pushBack(c);else{for(var E=[],T=g;T0?--a:e>0&&(--e,a=p.bucketSize-1)),++f,i[e][a]=g},this.popFront=function(){this.empty()||(this.size()!==1&&(a0&&--f)},this.shrinkToFit=function(){var g=this,c=[];this.forEach(function(T){c.push(T)});var v=c.length;i=[];for(var _=Math.ceil(v/p.bucketSize),E=0;E<_;++E)i.push(new Array(p.bucketSize));this.clear(),c.forEach(function(T){return g.pushBack(T)})},this.cut=function(g){if(g<0)this.clear();else{var c=l(g),v=c.curNodeBucketIndex,_=c.curNodePointerIndex;n=v,t=_,f=g+1}},this[Symbol.iterator]=function(){return function(){var g,c;return w(this,function(v){switch(v.label){case 0:if(f===0)return[2];if(e!==n)return[3,5];c=a,v.label=1;case 1:return c<=t?[4,i[e][c]]:[3,4];case 2:v.sent(),v.label=3;case 3:return++c,[3,1];case 4:return[2];case 5:c=a,v.label=6;case 6:return c0&&o[o.length-1])&&(v[0]===6||v[0]===2)){l=0;continue}if(v[0]===3&&(!o||v[1]>o[0]&&v[1]=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(q,"__esModule",{value:!0});var d=I("../LinkList/LinkList"),u=I("../Map/Map");function i(e,a,n){var t=this;if(e===void 0&&(e=[]),a===void 0&&(a=i.initSize),n=n||function(h){var g,c,v=0,_="";if(typeof h=="number")v=((v=Math.floor(h))<<5)-v,v&=v;else{_=typeof h!="string"?JSON.stringify(h):h;try{for(var E=p(_),T=E.next();!T.done;T=E.next())v=(v<<5)-v+T.value.charCodeAt(0),v&=v}catch(S){g={error:S}}finally{try{T&&!T.done&&(c=E.return)&&c.call(E)}finally{if(g)throw g.error}}}return v^=v>>>16},(a&a-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var o=0,f=[],l=Math.max(i.initSize,Math.min(i.maxSize,a));this.size=function(){return o},this.empty=function(){return o===0},this.clear=function(){o=0,l=a,f=[]},this.forEach=function(h){var g=0;f.forEach(function(c){c.forEach(function(v){h(v,g++)})})},this.setElement=function(h,g){var c,v;if(h==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(g!=null){var _=n(h)&l-1;if(f[_]){var E=f[_].size();if(f[_]instanceof d.default){try{for(var T=p(f[_]),S=T.next();!S.done;S=T.next()){var F=S.value;if(F.key===h)return void(F.value=g)}}catch(m){c={error:m}}finally{try{S&&!S.done&&(v=T.return)&&v.call(T)}finally{if(c)throw c.error}}f[_].pushBack({key:h,value:g}),f[_].size()>=i.treeifyThreshold&&(f[_]=new u.default(f[_]))}else f[_].setElement(h,g);var W=f[_].size();o+=W-E}else++o,f[_]=new d.default([{key:h,value:g}]);o>l*i.sigma&&function(m){if(!(m>=i.maxSize)){l=2*m;var y=[];f.forEach(function(C,k){if(!C.empty()){if(C instanceof d.default&&C.size()===1){var A=C.front(),N=A.key,L=A.value;y[n(N)&l-1]=new d.default([{key:N,value:L}])}else if(C instanceof u.default){var B=new d.default,P=new d.default;C.forEach(function(O){(n(O.key)&m)==0?B.pushBack(O):P.pushBack(O)}),B.size()>i.untreeifyThreshold?y[k]=new u.default(B):B.size()&&(y[k]=B),P.size()>i.untreeifyThreshold?y[k+m]=new u.default(P):P.size()&&(y[k+m]=P)}else{var M=new d.default,R=new d.default;C.forEach(function(O){(n(O.key)&m)==0?M.pushBack(O):R.pushBack(O)}),M.size()&&(y[k]=M),R.size()&&(y[k+m]=R)}f[k].clear()}}),f=y}}.call(this,l)}else this.eraseElementByKey(h)},this.getElementByKey=function(h){var g,c,v=n(h)&l-1;if(f[v]){if(f[v]instanceof u.default)return f[v].getElementByKey(h);try{for(var _=p(f[v]),E=_.next();!E.done;E=_.next()){var T=E.value;if(T.key===h)return T.value}}catch(S){g={error:S}}finally{try{E&&!E.done&&(c=_.return)&&c.call(_)}finally{if(g)throw g.error}}}},this.eraseElementByKey=function(h){var g,c,v=n(h)&l-1;if(f[v]){var _=f[v].size();if(f[v]instanceof u.default)f[v].eraseElementByKey(h),f[v].size()<=i.untreeifyThreshold&&(f[v]=new d.default(f[v]));else{var E=-1;try{for(var T=p(f[v]),S=T.next();!S.done;S=T.next())if(++E,S.value.key===h){f[v].eraseElementByPos(E);break}}catch(W){g={error:W}}finally{try{S&&!S.done&&(c=T.return)&&c.call(T)}finally{if(g)throw g.error}}}var F=f[v].size();o+=F-_}},this.find=function(h){var g,c,v=n(h)&l-1;if(!f[v])return!1;if(f[v]instanceof u.default)return f[v].find(h);try{for(var _=p(f[v]),E=_.next();!E.done;E=_.next())if(E.value.key===h)return!0}catch(T){g={error:T}}finally{try{E&&!E.done&&(c=_.return)&&c.call(_)}finally{if(g)throw g.error}}return!1},this[Symbol.iterator]=function(){return function(){var h,g,c,v,_,E;return w(this,function(T){switch(T.label){case 0:h=0,T.label=1;case 1:if(!(h=l)return[3,10];T.label=2;case 2:T.trys.push([2,7,8,9]),_=void 0,g=p(f[h]),c=g.next(),T.label=3;case 3:return c.done?[3,6]:[4,c.value];case 4:T.sent(),T.label=5;case 5:return c=g.next(),[3,3];case 6:return[3,9];case 7:return v=T.sent(),_={error:v},[3,9];case 8:try{c&&!c.done&&(E=g.return)&&E.call(g)}finally{if(_)throw _.error}return[7];case 9:return++h,[3,1];case 10:return[2]}})}()},e.forEach(function(h){var g=h.key,c=h.value;return t.setElement(g,c)}),Object.freeze(this)}i.initSize=16,i.maxSize=1<<30,i.sigma=.75,i.treeifyThreshold=8,i.untreeifyThreshold=6,i.minTreeifySize=64,Object.freeze(i),q.default=i},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(I,z,q){var w=this&&this.__generator||function(e,a){var n,t,o,f,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return f={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function h(g){return function(c){return function(v){if(n)throw new TypeError("Generator is already executing.");for(;l;)try{if(n=1,t&&(o=2&v[0]?t.return:v[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,v[1])).done)return o;switch(t=0,o&&(v=[2&v[0],o.value]),v[0]){case 0:case 1:o=v;break;case 4:return l.label++,{value:v[1],done:!1};case 5:l.label++,t=v[1],v=[0];continue;case 7:v=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(v[0]===6||v[0]===2)){l=0;continue}if(v[0]===3&&(!o||v[1]>o[0]&&v[1]=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(q,"__esModule",{value:!0});var d=I("../Set/Set"),u=I("../LinkList/LinkList");function i(e,a,n){var t=this;if(e===void 0&&(e=[]),a===void 0&&(a=i.initSize),n=n||function(h){var g=0,c="";if(typeof h=="number")g=((g=Math.floor(h))<<5)-g,g&=g;else{c=typeof h!="string"?JSON.stringify(h):h;for(var v=0;v>>16},(a&a-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var o=0,f=[],l=Math.max(i.initSize,Math.min(i.maxSize,a));this.size=function(){return o},this.empty=function(){return o===0},this.clear=function(){o=0,l=a,f=[]},this.forEach=function(h){var g=0;f.forEach(function(c){c.forEach(function(v){h(v,g++)})})},this.insert=function(h){if(h==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var g=n(h)&l-1;if(f[g]){var c=f[g].size();if(f[g]instanceof u.default){if(f[g].find(h))return;f[g].pushBack(h),f[g].size()>=i.treeifyThreshold&&(f[g]=new d.default(f[g]))}else f[g].insert(h);var v=f[g].size();o+=v-c}else f[g]=new u.default([h]),++o;o>l*i.sigma&&function(_){if(!(_>=i.maxSize)){l=2*_;var E=[];f.forEach(function(T,S){if(!T.empty()){if(T instanceof u.default&&T.size()===1){var F=T.front();if(F===void 0)throw new Error("unknown error");E[n(F)&l-1]=new u.default([F])}else if(T instanceof d.default){var W=new u.default,m=new u.default;T.forEach(function(k){(n(k)&_)==0?W.pushBack(k):m.pushBack(k)}),W.size()>i.untreeifyThreshold?E[S]=new d.default(W):W.size()&&(E[S]=W),m.size()>i.untreeifyThreshold?E[S+_]=new d.default(m):m.size()&&(E[S+_]=m)}else{var y=new u.default,C=new u.default;T.forEach(function(k){(n(k)&_)==0?y.pushBack(k):C.pushBack(k)}),y.size()&&(E[S]=y),C.size()&&(E[S+_]=C)}f[S].clear()}}),f=E}}.call(this,l)},this.eraseElementByValue=function(h){var g=n(h)&l-1;if(f[g]){var c=f[g].size();f[g].eraseElementByValue(h),f[g]instanceof d.default&&f[g].size()<=i.untreeifyThreshold&&(f[g]=new u.default(f[g]));var v=f[g].size();o+=v-c}},this.find=function(h){var g=n(h)&l-1;return!!f[g]&&f[g].find(h)},this[Symbol.iterator]=function(){return function(){var h,g,c,v,_,E;return w(this,function(T){switch(T.label){case 0:h=0,T.label=1;case 1:if(!(h=l)return[3,10];T.label=2;case 2:T.trys.push([2,7,8,9]),_=void 0,g=p(f[h]),c=g.next(),T.label=3;case 3:return c.done?[3,6]:[4,c.value];case 4:T.sent(),T.label=5;case 5:return c=g.next(),[3,3];case 6:return[3,9];case 7:return v=T.sent(),_={error:v},[3,9];case 8:try{c&&!c.done&&(E=g.return)&&E.call(g)}finally{if(_)throw _.error}return[7];case 9:return++h,[3,1];case 10:return[2]}})}()},e.forEach(function(h){return t.insert(h)}),Object.freeze(this)}i.initSize=16,i.maxSize=1<<30,i.sigma=.75,i.treeifyThreshold=8,i.untreeifyThreshold=6,i.minTreeifySize=64,Object.freeze(i),q.default=i},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(I,z,q){var w=this&&this.__generator||function(u,i){var e,a,n,t,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return t={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(t[Symbol.iterator]=function(){return this}),t;function f(l){return function(h){return function(g){if(e)throw new TypeError("Generator is already executing.");for(;o;)try{if(e=1,a&&(n=2&g[0]?a.return:g[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,g[1])).done)return n;switch(a=0,n&&(g=[2&g[0],n.value]),g[0]){case 0:case 1:n=g;break;case 4:return o.label++,{value:g[1],done:!1};case 5:o.label++,a=g[1],g=[0];continue;case 7:g=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(g[0]===6||g[0]===2)){o=0;continue}if(g[0]===3&&(!n||g[1]>n[0]&&g[1]=e)throw new Error("pos must more then 0 and less then the list length");for(var o=a;t--&&o;)o=o.next;if(!o||o.value===void 0)throw new Error("unknown error");return o.value},this.eraseElementByPos=function(t){if(t<0||t>=e)throw new Error("erase pos must more then 0 and less then the list length");if(t===0)this.popFront();else if(t===e-1)this.popBack();else{for(var o=a;t--;){if(!(o!=null&&o.next))throw new Error("unknown error");o=o.next}if(!o||!o.pre||!o.next)throw new Error("unknown error");var f=o.pre,l=o.next;l.pre=f,f.next=l,e>0&&--e}},this.eraseElementByValue=function(t){for(;a&&a.value===t;)this.popFront();for(;n&&n.value===t;)this.popBack();if(a)for(var o=a;o;){if(o.value===t){var f=o.pre,l=o.next;l&&(l.pre=f),f&&(f.next=l),e>0&&--e}o=o.next}},this.pushBack=function(t){if(t==null)throw new Error("you can't push null or undefined here");++e;var o=new p(t);n?(n.next=o,o.pre=n,n=o):a=n=o},this.popBack=function(){n&&(e>0&&--e,n&&(a===n?a=n=void 0:(n=n.pre)&&(n.next=void 0)))},this.setElementByPos=function(t,o){if(o==null)throw new Error("you can't set null or undefined here");if(t<0||t>=e)throw new Error("pos must more then 0 and less then the list length");for(var f=a;t--;){if(!f)throw new Error("unknown error");f=f.next}f&&(f.value=o)},this.insert=function(t,o,f){if(f===void 0&&(f=1),o==null)throw new Error("you can't insert null or undefined here");if(t<0||t>e)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(f<0)throw new Error("insert size must more than 0");if(t===0)for(;f--;)this.pushFront(o);else if(t===e)for(;f--;)this.pushBack(o);else{for(var l=a,h=1;h0&&--e;t.next=o.next,t.next&&(t.next.pre=t),t=t.next}},this.sort=function(t){var o=[];this.forEach(function(l){o.push(l)}),o.sort(t);var f=a;o.forEach(function(l){f&&(f.value=l,f=f.next)})},this.pushFront=function(t){if(t==null)throw new Error("you can't push null or undefined here");++e;var o=new p(t);a?(o.next=a,a.pre=o,a=o):a=n=o},this.popFront=function(){a&&(e>0&&--e,a&&(a===n?a=n=void 0:(a=a.next)&&(a.pre=void 0)))},this.merge=function(t){var o=this,f=a;t.forEach(function(l){for(;f&&f.value!==void 0&&f.value<=l;)f=f.next;if(f===void 0)o.pushBack(l),f=n;else if(f===a)o.pushFront(l),f=a;else{++e;var h=f.pre;h&&(h.next=new p(l),h.next.pre=h,h.next.next=f,f&&(f.pre=h.next))}})},this[Symbol.iterator]=function(){return function(){var t;return w(this,function(o){switch(o.label){case 0:t=a,o.label=1;case 1:if(t===void 0)return[3,3];if(!t.value)throw new Error("unknown error");return[4,t.value];case 2:return o.sent(),t=t.next,[3,1];case 3:return[2]}})}()},u.forEach(function(t){return i.pushBack(t)}),Object.freeze(this)}Object.freeze(d),q.default=d},{}],30:[function(I,z,q){var w=this&&this.__generator||function(i,e){var a,n,t,o,f={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(h){return function(g){return function(c){if(a)throw new TypeError("Generator is already executing.");for(;f;)try{if(a=1,n&&(t=2&c[0]?n.return:c[0]?n.throw||((t=n.return)&&t.call(n),0):n.next)&&!(t=t.call(n,c[1])).done)return t;switch(n=0,t&&(c=[2&c[0],t.value]),c[0]){case 0:case 1:t=c;break;case 4:return f.label++,{value:c[1],done:!1};case 5:f.label++,n=c[1],c=[0];continue;case 7:c=f.ops.pop(),f.trys.pop();continue;default:if(!(t=(t=f.trys).length>0&&t[t.length-1])&&(c[0]===6||c[0]===2)){f=0;continue}if(c[0]===3&&(!t||c[1]>t[0]&&c[1]=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(q,"__esModule",{value:!0});var d=I("../Base/TreeNode");function u(i,e){var a=this;i===void 0&&(i=[]),e=e||function(m,y){return my?1:0};var n=0,t=new d.default;t.color=d.default.TreeNodeColorType.black,this.size=function(){return n},this.empty=function(){return n===0},this.clear=function(){n=0,t.key=t.value=void 0,t.leftChild=t.rightChild=t.brother=void 0};var o=function(m){if(!m||m.key===void 0)throw new Error("unknown error");return m.leftChild?o(m.leftChild):m},f=function(m){if(!m||m.key===void 0)throw new Error("unknown error");return m.rightChild?f(m.rightChild):m};this.front=function(){if(!this.empty()){var m=o(t);if(m.key===void 0||m.value===void 0)throw new Error("unknown error");return{key:m.key,value:m.value}}},this.back=function(){if(!this.empty()){var m=f(t);if(m.key===void 0||m.value===void 0)throw new Error("unknown error");return{key:m.key,value:m.value}}},this.forEach=function(m){var y,C,k=0;try{for(var A=p(this),N=A.next();!N.done;N=A.next())m(N.value,k++)}catch(L){y={error:L}}finally{try{N&&!N.done&&(C=A.return)&&C.call(A)}finally{if(y)throw y.error}}},this.getElementByPos=function(m){var y,C;if(m<0||m>=this.size())throw new Error("pos must more than 0 and less than set's size");var k=0;try{for(var A=p(this),N=A.next();!N.done;N=A.next()){var L=N.value;if(k===m)return L;++k}}catch(B){y={error:B}}finally{try{N&&!N.done&&(C=A.return)&&C.call(A)}finally{if(y)throw y.error}}throw new Error("unknown Error")};var l=function(m,y){if(m&&m.key!==void 0&&m.value!==void 0){var C=e(m.key,y);return C===0?{key:m.key,value:m.value}:C<0?l(m.rightChild,y):l(m.leftChild,y)||{key:m.key,value:m.value}}};this.lowerBound=function(m){return l(t,m)};var h=function(m,y){if(m&&m.key!==void 0&&m.value!==void 0)return e(m.key,y)<=0?h(m.rightChild,y):h(m.leftChild,y)||{key:m.key,value:m.value}};this.upperBound=function(m){return h(t,m)};var g=function(m,y){if(m&&m.key!==void 0&&m.value!==void 0){var C=e(m.key,y);return C===0?{key:m.key,value:m.value}:C>0?g(m.leftChild,y):g(m.rightChild,y)||{key:m.key,value:m.value}}};this.reverseLowerBound=function(m){return g(t,m)};var c=function(m,y){if(m&&m.key!==void 0&&m.value!==void 0)return e(m.key,y)>=0?c(m.leftChild,y):c(m.rightChild,y)||{key:m.key,value:m.value}};this.reverseUpperBound=function(m){return c(t,m)};var v=function(m){var y=m.parent;if(!y){if(m===t)return;throw new Error("unknown error")}if(m.color!==d.default.TreeNodeColorType.red){var C=m.brother;if(!C)throw new Error("unknown error");if(m===y.leftChild)if(C.color===d.default.TreeNodeColorType.red){C.color=d.default.TreeNodeColorType.black,y.color=d.default.TreeNodeColorType.red;var k=y.rotateLeft();t===y&&(t=k),v(m)}else C.color===d.default.TreeNodeColorType.black&&(C.rightChild&&C.rightChild.color===d.default.TreeNodeColorType.red?(C.color=y.color,y.color=d.default.TreeNodeColorType.black,C.rightChild&&(C.rightChild.color=d.default.TreeNodeColorType.black),k=y.rotateLeft(),t===y&&(t=k),m.color=d.default.TreeNodeColorType.black):C.rightChild&&C.rightChild.color!==d.default.TreeNodeColorType.black||!C.leftChild||C.leftChild.color!==d.default.TreeNodeColorType.red?C.leftChild&&C.leftChild.color!==d.default.TreeNodeColorType.black||C.rightChild&&C.rightChild.color!==d.default.TreeNodeColorType.black||(C.color=d.default.TreeNodeColorType.red,v(y)):(C.color=d.default.TreeNodeColorType.red,C.leftChild&&(C.leftChild.color=d.default.TreeNodeColorType.black),k=C.rotateRight(),t===C&&(t=k),v(m)));else m===y.rightChild&&(C.color===d.default.TreeNodeColorType.red?(C.color=d.default.TreeNodeColorType.black,y.color=d.default.TreeNodeColorType.red,k=y.rotateRight(),t===y&&(t=k),v(m)):C.color===d.default.TreeNodeColorType.black&&(C.leftChild&&C.leftChild.color===d.default.TreeNodeColorType.red?(C.color=y.color,y.color=d.default.TreeNodeColorType.black,C.leftChild&&(C.leftChild.color=d.default.TreeNodeColorType.black),k=y.rotateRight(),t===y&&(t=k),m.color=d.default.TreeNodeColorType.black):C.leftChild&&C.leftChild.color!==d.default.TreeNodeColorType.black||!C.rightChild||C.rightChild.color!==d.default.TreeNodeColorType.red?C.leftChild&&C.leftChild.color!==d.default.TreeNodeColorType.black||C.rightChild&&C.rightChild.color!==d.default.TreeNodeColorType.black||(C.color=d.default.TreeNodeColorType.red,v(y)):(C.color=d.default.TreeNodeColorType.red,C.rightChild&&(C.rightChild.color=d.default.TreeNodeColorType.black),k=C.rotateLeft(),t===C&&(t=k),v(m))))}else m.color=d.default.TreeNodeColorType.black},_=function(m){for(var y=m;y.leftChild||y.rightChild;){if(y.rightChild){y=o(y.rightChild);var C=m.key;m.key=y.key,y.key=C;var k=m.value;m.value=y.value,y.value=k,m=y}y.leftChild&&(y=f(y.leftChild),C=m.key,m.key=y.key,y.key=C,k=m.value,m.value=y.value,y.value=k,m=y)}v(y),y&&y.remove(),--n,t.color=d.default.TreeNodeColorType.black},E=function(m,y){return!(!m||m.key===void 0)&&(!!E(m.leftChild,y)||!!y(m)||E(m.rightChild,y))};this.eraseElementByPos=function(m){if(m<0||m>=n)throw new Error("pos must more than 0 and less than set's size");var y=0;E(t,function(C){return m===y?(_(C),!0):(++y,!1)})},this.eraseElementByKey=function(m){if(!this.empty()){var y=F(t,m);y!==void 0&&y.key!==void 0&&e(y.key,m)===0&&_(y)}};var T=function(m,y){if(!m||m.key===void 0)throw new Error("unknown error");var C=e(y,m.key);return C<0?m.leftChild?T(m.leftChild,y):(m.leftChild=new d.default,m.leftChild.parent=m,m.leftChild.brother=m.rightChild,m.rightChild&&(m.rightChild.brother=m.leftChild),m.leftChild):C>0?m.rightChild?T(m.rightChild,y):(m.rightChild=new d.default,m.rightChild.parent=m,m.rightChild.brother=m.leftChild,m.leftChild&&(m.leftChild.brother=m.rightChild),m.rightChild):m},S=function(m){var y=m.parent;if(!y){if(m===t)return;throw new Error("unknown error")}if(y.color!==d.default.TreeNodeColorType.black&&y.color===d.default.TreeNodeColorType.red){var C=y.brother,k=y.parent;if(!k)throw new Error("unknown error");if(C&&C.color===d.default.TreeNodeColorType.red)C.color=y.color=d.default.TreeNodeColorType.black,k.color=d.default.TreeNodeColorType.red,S(k);else if(!C||C.color===d.default.TreeNodeColorType.black)if(y===k.leftChild)if(m===y.leftChild){y.color=d.default.TreeNodeColorType.black,k.color=d.default.TreeNodeColorType.red;var A=k.rotateRight();k===t&&(t=A)}else m===y.rightChild&&(A=y.rotateLeft(),k===t&&(t=A),S(y));else y===k.rightChild&&(m===y.leftChild?(A=y.rotateRight(),k===t&&(t=A),S(y)):m===y.rightChild&&(y.color=d.default.TreeNodeColorType.black,k.color=d.default.TreeNodeColorType.red,A=k.rotateLeft(),k===t&&(t=A)))}};this.setElement=function(m,y){if(m==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(y!=null){if(this.empty())return++n,t.key=m,t.value=y,void(t.color=d.default.TreeNodeColorType.black);var C=T(t,m);C.key===void 0||e(C.key,m)!==0?(++n,C.key=m,C.value=y,S(C),t.color=d.default.TreeNodeColorType.black):C.value=y}else this.eraseElementByKey(m)};var F=function(m,y){if(m&&m.key!==void 0){var C=e(y,m.key);return C<0?F(m.leftChild,y):C>0?F(m.rightChild,y):m}};this.find=function(m){return!!F(t,m)},this.getElementByKey=function(m){var y=F(t,m);if((y==null?void 0:y.key)===void 0||(y==null?void 0:y.value)===void 0)throw new Error("unknown error");return y.value},this.union=function(m){var y=this;m.forEach(function(C){var k=C.key,A=C.value;return y.setElement(k,A)})},this.getHeight=function(){if(this.empty())return 0;var m=function(y){return y?Math.max(m(y.leftChild),m(y.rightChild))+1:1};return m(t)};var W=function(m){return w(this,function(y){switch(y.label){case 0:return m&&m.key!==void 0&&m.value!==void 0?[5,p(W(m.leftChild))]:[2];case 1:return y.sent(),[4,{key:m.key,value:m.value}];case 2:return y.sent(),[5,p(W(m.rightChild))];case 3:return y.sent(),[2]}})};this[Symbol.iterator]=function(){return W(t)},i.forEach(function(m){var y=m.key,C=m.value;return a.setElement(y,C)}),Object.freeze(this)}Object.freeze(u),q.default=u},{"../Base/TreeNode":25}],31:[function(I,z,q){function w(p,d){p===void 0&&(p=[]),d=d||function(n,t){return n>t?-1:n=i)throw new Error("unknown error");if(t<0||t>=i)throw new Error("unknown error");var o=u[n];u[n]=u[t],u[t]=o},a=function(n){if(n<0||n>=i)throw new Error("unknown error");var t=2*n+1,o=2*n+2;t0&&e(n,t),o0&&e(n,o)};(function(){for(var n=Math.floor((i-1)/2);n>=0;--n)for(var t=n,o=2*t+1;o0&&(l=f),d(u[t],u[l])<=0)break;e(t,l),o=2*(t=l)+1}})(),this.size=function(){return i},this.empty=function(){return i===0},this.clear=function(){i=0,u.length=0},this.push=function(n){if(u.push(n),++i!==1)for(var t=i-1;t>0;){var o=Math.floor((t-1)/2);if(d(u[o],n)<=0)break;a(o),t=o}},this.pop=function(){if(!this.empty())if(this.size()!==1){var n=u[i-1];--i;for(var t=0;t=this.size())break;var l=o;if(f0&&(l=f),d(u[l],n)>=0)break;u[t]=u[l],t=l}u[t]=n}else--i},this.top=function(){return u[0]},Object.freeze(this)}Object.defineProperty(q,"__esModule",{value:!0}),Object.freeze(w),q.default=w},{}],32:[function(I,z,q){Object.defineProperty(q,"__esModule",{value:!0});var w=I("../LinkList/LinkList");function p(d){d===void 0&&(d=[]);var u=new w.default(d);this.size=function(){return u.size()},this.empty=function(){return u.empty()},this.clear=function(){u.clear()},this.push=function(i){u.pushBack(i)},this.pop=function(){u.popFront()},this.front=function(){return u.front()},Object.freeze(this)}Object.freeze(p),q.default=p},{"../LinkList/LinkList":29}],33:[function(I,z,q){var w=this&&this.__generator||function(i,e){var a,n,t,o,f={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(h){return function(g){return function(c){if(a)throw new TypeError("Generator is already executing.");for(;f;)try{if(a=1,n&&(t=2&c[0]?n.return:c[0]?n.throw||((t=n.return)&&t.call(n),0):n.next)&&!(t=t.call(n,c[1])).done)return t;switch(n=0,t&&(c=[2&c[0],t.value]),c[0]){case 0:case 1:t=c;break;case 4:return f.label++,{value:c[1],done:!1};case 5:f.label++,n=c[1],c=[0];continue;case 7:c=f.ops.pop(),f.trys.pop();continue;default:if(!(t=(t=f.trys).length>0&&t[t.length-1])&&(c[0]===6||c[0]===2)){f=0;continue}if(c[0]===3&&(!t||c[1]>t[0]&&c[1]=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(q,"__esModule",{value:!0});var d=I("../Base/TreeNode");function u(i,e){var a=this;i===void 0&&(i=[]),e=e||function(m,y){return my?1:0};var n=0,t=new d.default;t.color=d.default.TreeNodeColorType.black,this.size=function(){return n},this.empty=function(){return n===0},this.clear=function(){n=0,t.key=void 0,t.leftChild=t.rightChild=t.brother=t.parent=void 0,t.color=d.default.TreeNodeColorType.black};var o=function(m){if(!m||m.key===void 0)throw new Error("unknown error");return m.leftChild?o(m.leftChild):m},f=function(m){if(!m||m.key===void 0)throw new Error("unknown error");return m.rightChild?f(m.rightChild):m};this.front=function(){if(!this.empty())return o(t).key},this.back=function(){if(!this.empty())return f(t).key},this.forEach=function(m){var y,C,k=0;try{for(var A=p(this),N=A.next();!N.done;N=A.next())m(N.value,k++)}catch(L){y={error:L}}finally{try{N&&!N.done&&(C=A.return)&&C.call(A)}finally{if(y)throw y.error}}},this.getElementByPos=function(m){var y,C;if(m<0||m>=this.size())throw new Error("pos must more than 0 and less than set's size");var k=0;try{for(var A=p(this),N=A.next();!N.done;N=A.next()){var L=N.value;if(k===m)return L;++k}}catch(B){y={error:B}}finally{try{N&&!N.done&&(C=A.return)&&C.call(A)}finally{if(y)throw y.error}}throw new Error("unknown error")};var l=function(m){var y=m.parent;if(!y){if(m===t)return;throw new Error("unknown error")}if(m.color!==d.default.TreeNodeColorType.red){var C=m.brother;if(!C)throw new Error("unknown error");if(m===y.leftChild)if(C.color===d.default.TreeNodeColorType.red){C.color=d.default.TreeNodeColorType.black,y.color=d.default.TreeNodeColorType.red;var k=y.rotateLeft();t===y&&(t=k),l(m)}else C.color===d.default.TreeNodeColorType.black&&(C.rightChild&&C.rightChild.color===d.default.TreeNodeColorType.red?(C.color=y.color,y.color=d.default.TreeNodeColorType.black,C.rightChild&&(C.rightChild.color=d.default.TreeNodeColorType.black),k=y.rotateLeft(),t===y&&(t=k),m.color=d.default.TreeNodeColorType.black):C.rightChild&&C.rightChild.color!==d.default.TreeNodeColorType.black||!C.leftChild||C.leftChild.color!==d.default.TreeNodeColorType.red?C.leftChild&&C.leftChild.color!==d.default.TreeNodeColorType.black||C.rightChild&&C.rightChild.color!==d.default.TreeNodeColorType.black||(C.color=d.default.TreeNodeColorType.red,l(y)):(C.color=d.default.TreeNodeColorType.red,C.leftChild&&(C.leftChild.color=d.default.TreeNodeColorType.black),k=C.rotateRight(),t===C&&(t=k),l(m)));else m===y.rightChild&&(C.color===d.default.TreeNodeColorType.red?(C.color=d.default.TreeNodeColorType.black,y.color=d.default.TreeNodeColorType.red,k=y.rotateRight(),t===y&&(t=k),l(m)):C.color===d.default.TreeNodeColorType.black&&(C.leftChild&&C.leftChild.color===d.default.TreeNodeColorType.red?(C.color=y.color,y.color=d.default.TreeNodeColorType.black,C.leftChild&&(C.leftChild.color=d.default.TreeNodeColorType.black),k=y.rotateRight(),t===y&&(t=k),m.color=d.default.TreeNodeColorType.black):C.leftChild&&C.leftChild.color!==d.default.TreeNodeColorType.black||!C.rightChild||C.rightChild.color!==d.default.TreeNodeColorType.red?C.leftChild&&C.leftChild.color!==d.default.TreeNodeColorType.black||C.rightChild&&C.rightChild.color!==d.default.TreeNodeColorType.black||(C.color=d.default.TreeNodeColorType.red,l(y)):(C.color=d.default.TreeNodeColorType.red,C.rightChild&&(C.rightChild.color=d.default.TreeNodeColorType.black),k=C.rotateLeft(),t===C&&(t=k),l(m))))}else m.color=d.default.TreeNodeColorType.black},h=function(m){for(var y=m;y.leftChild||y.rightChild;){if(y.rightChild){y=o(y.rightChild);var C=m.key;m.key=y.key,y.key=C,m=y}y.leftChild&&(y=f(y.leftChild),C=m.key,m.key=y.key,y.key=C,m=y)}l(y),y&&y.remove(),--n,t.color=d.default.TreeNodeColorType.black},g=function(m,y){return!(!m||m.key===void 0)&&(!!g(m.leftChild,y)||!!y(m)||g(m.rightChild,y))};this.eraseElementByPos=function(m){if(m<0||m>=n)throw new Error("pos must more than 0 and less than set's size");var y=0;g(t,function(C){return m===y?(h(C),!0):(++y,!1)})},this.eraseElementByValue=function(m){if(!this.empty()){var y=_(t,m);y!==void 0&&y.key!==void 0&&e(y.key,m)===0&&h(y)}};var c=function(m,y){if(!m||m.key===void 0)throw new Error("unknown error");var C=e(y,m.key);return C<0?m.leftChild?c(m.leftChild,y):(m.leftChild=new d.default,m.leftChild.parent=m,m.leftChild.brother=m.rightChild,m.rightChild&&(m.rightChild.brother=m.leftChild),m.leftChild):C>0?m.rightChild?c(m.rightChild,y):(m.rightChild=new d.default,m.rightChild.parent=m,m.rightChild.brother=m.leftChild,m.leftChild&&(m.leftChild.brother=m.rightChild),m.rightChild):m},v=function(m){var y=m.parent;if(!y){if(m===t)return;throw new Error("unknown error")}if(y.color!==d.default.TreeNodeColorType.black&&y.color===d.default.TreeNodeColorType.red){var C=y.brother,k=y.parent;if(!k)throw new Error("unknown error");if(C&&C.color===d.default.TreeNodeColorType.red)C.color=y.color=d.default.TreeNodeColorType.black,k.color=d.default.TreeNodeColorType.red,v(k);else if(!C||C.color===d.default.TreeNodeColorType.black)if(y===k.leftChild)if(m===y.leftChild){y.color=d.default.TreeNodeColorType.black,k.color=d.default.TreeNodeColorType.red;var A=k.rotateRight();k===t&&(t=A)}else m===y.rightChild&&(A=y.rotateLeft(),k===t&&(t=A),v(y));else y===k.rightChild&&(m===y.leftChild?(A=y.rotateRight(),k===t&&(t=A),v(y)):m===y.rightChild&&(y.color=d.default.TreeNodeColorType.black,k.color=d.default.TreeNodeColorType.red,A=k.rotateLeft(),k===t&&(t=A)))}};this.insert=function(m){if(m==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++n,t.key=m,void(t.color=d.default.TreeNodeColorType.black);var y=c(t,m);y.key!==void 0&&e(y.key,m)===0||(++n,y.key=m,v(y),t.color=d.default.TreeNodeColorType.black)};var _=function(m,y){if(m&&m.key!==void 0){var C=e(y,m.key);return C<0?_(m.leftChild,y):C>0?_(m.rightChild,y):m}};this.find=function(m){var y=_(t,m);return y!==void 0&&y.key!==void 0&&e(y.key,m)===0};var E=function(m,y){if(m&&m.key!==void 0){var C=e(m.key,y);if(C===0)return m.key;if(C<0)return E(m.rightChild,y);var k=E(m.leftChild,y);return k!==void 0?k:m.key}};this.lowerBound=function(m){return E(t,m)};var T=function(m,y){if(m&&m.key!==void 0){if(e(m.key,y)<=0)return T(m.rightChild,y);var C=T(m.leftChild,y);return C!==void 0?C:m.key}};this.upperBound=function(m){return T(t,m)};var S=function(m,y){if(m&&m.key!==void 0){var C=e(m.key,y);if(C===0)return m.key;if(C>0)return S(m.leftChild,y);var k=S(m.rightChild,y);return k!==void 0?k:m.key}};this.reverseLowerBound=function(m){return S(t,m)};var F=function(m,y){if(m&&m.key!==void 0){if(e(m.key,y)>=0)return F(m.leftChild,y);var C=F(m.rightChild,y);return C!==void 0?C:m.key}};this.reverseUpperBound=function(m){return F(t,m)},this.union=function(m){var y=this;m.forEach(function(C){return y.insert(C)})},this.getHeight=function(){if(this.empty())return 0;var m=function(y){return y?Math.max(m(y.leftChild),m(y.rightChild))+1:1};return m(t)};var W=function(m){return w(this,function(y){switch(y.label){case 0:return m&&m.key!==void 0?[5,p(W(m.leftChild))]:[2];case 1:return y.sent(),[4,m.key];case 2:return y.sent(),[5,p(W(m.rightChild))];case 3:return y.sent(),[2]}})};this[Symbol.iterator]=function(){return W(t)},i.forEach(function(m){return a.insert(m)}),Object.freeze(this)}Object.freeze(u),q.default=u},{"../Base/TreeNode":25}],34:[function(I,z,q){function w(p){var d=this;p===void 0&&(p=[]);var u=0,i=[];this.size=function(){return u},this.empty=function(){return u===0},this.clear=function(){u=0,i.length=0},this.push=function(e){i.push(e),++u},this.pop=function(){i.pop(),u>0&&--u},this.top=function(){return i[u-1]},p.forEach(function(e){return d.push(e)}),Object.freeze(this)}Object.defineProperty(q,"__esModule",{value:!0}),Object.freeze(w),q.default=w},{}],35:[function(I,z,q){var w=this&&this.__generator||function(e,a){var n,t,o,f,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return f={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function h(g){return function(c){return function(v){if(n)throw new TypeError("Generator is already executing.");for(;l;)try{if(n=1,t&&(o=2&v[0]?t.return:v[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,v[1])).done)return o;switch(t=0,o&&(v=[2&v[0],o.value]),v[0]){case 0:case 1:o=v;break;case 4:return l.label++,{value:v[1],done:!1};case 5:l.label++,t=v[1],v=[0];continue;case 7:v=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(v[0]===6||v[0]===2)){l=0;continue}if(v[0]===3&&(!o||v[1]>o[0]&&v[1]0)&&!(t=f.next()).done;)l.push(t.value)}catch(h){o={error:h}}finally{try{t&&!t.done&&(n=f.return)&&n.call(f)}finally{if(o)throw o.error}}return l},d=this&&this.__spreadArray||function(e,a,n){if(n||arguments.length===2)for(var t,o=0,f=a.length;o=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")};function i(e){var a=this;e===void 0&&(e=[]);var n=0,t=[];this.size=function(){return n},this.empty=function(){return n===0},this.clear=function(){n=0,t.length=0},this.front=function(){if(!this.empty())return t[0]},this.back=function(){if(!this.empty())return t[n-1]},this.forEach=function(o){t.forEach(o)},this.getElementByPos=function(o){if(o<0||o>=n)throw new Error("pos must more than 0 and less than vector's size");return t[o]},this.eraseElementByPos=function(o){if(o<0||o>=n)throw new Error("pos must more than 0 and less than vector's size");for(var f=o;fl;)this.popBack()},this.pushBack=function(o){t.push(o),++n},this.popBack=function(){t.pop(),n>0&&--n},this.setElementByPos=function(o,f){if(o<0||o>=n)throw new Error("pos must more than 0 and less than vector's size");t[o]=f},this.insert=function(o,f,l){if(l===void 0&&(l=1),o<0||o>n)throw new Error("pos must more than 0 and less than or equal to vector's size");t.splice.apply(t,d([o,0],p(new Array(l).fill(f)),!1)),n+=l},this.find=function(o){return t.includes(o)},this.reverse=function(){t.reverse()},this.unique=function(){var o,f=[];this.forEach(function(h,g){g!==0&&h===o||(f.push(h),o=h)}),f.forEach(function(h,g){t[g]=h});for(var l=f.length;n>l;)this.popBack()},this.sort=function(o){t.sort(o)},this[Symbol.iterator]=function(){return function(){return w(this,function(o){switch(o.label){case 0:return[5,u(t)];case 1:return[2,o.sent()]}})}()},e.forEach(function(o){return a.pushBack(o)}),Object.freeze(this)}Object.defineProperty(q,"__esModule",{value:!0}),Object.freeze(i),q.default=i},{}],36:[function(I,z,q){Object.defineProperty(q,"__esModule",{value:!0}),q.HashMap=q.HashSet=q.Map=q.Set=q.PriorityQueue=q.Deque=q.LinkList=q.Queue=q.Stack=q.Vector=void 0;var w=I("./Vector/Vector");q.Vector=w.default;var p=I("./Stack/Stack");q.Stack=p.default;var d=I("./Queue/Queue");q.Queue=d.default;var u=I("./LinkList/LinkList");q.LinkList=u.default;var i=I("./Deque/Deque");q.Deque=i.default;var e=I("./PriorityQueue/PriorityQueue");q.PriorityQueue=e.default;var a=I("./Set/Set");q.Set=a.default;var n=I("./Map/Map");q.Map=n.default;var t=I("./HashSet/HashSet");q.HashSet=t.default;var o=I("./HashMap/HashMap");q.HashMap=o.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(I,z,q){const w=I("yallist"),p=Symbol("max"),d=Symbol("length"),u=Symbol("lengthCalculator"),i=Symbol("allowStale"),e=Symbol("maxAge"),a=Symbol("dispose"),n=Symbol("noDisposeOnSet"),t=Symbol("lruList"),o=Symbol("cache"),f=Symbol("updateAgeOnGet"),l=()=>1,h=(T,S,F)=>{const W=T[o].get(S);if(W){const m=W.value;if(g(T,m)){if(v(T,W),!T[i])return}else F&&(T[f]&&(W.value.now=Date.now()),T[t].unshiftNode(W));return m.value}},g=(T,S)=>{if(!S||!S.maxAge&&!T[e])return!1;const F=Date.now()-S.now;return S.maxAge?F>S.maxAge:T[e]&&F>T[e]},c=T=>{if(T[d]>T[p])for(let S=T[t].tail;T[d]>T[p]&&S!==null;){const F=S.prev;v(T,S),S=F}},v=(T,S)=>{if(S){const F=S.value;T[a]&&T[a](F.key,F.value),T[d]-=F.length,T[o].delete(F.key),T[t].removeNode(S)}};class _{constructor(S,F,W,m,y){this.key=S,this.value=F,this.length=W,this.now=m,this.maxAge=y||0}}const E=(T,S,F,W)=>{let m=F.value;g(T,m)&&(v(T,F),T[i]||(m=void 0)),m&&S.call(W,m.value,m.key,T)};z.exports=class{constructor(T){if(typeof T=="number"&&(T={max:T}),T||(T={}),T.max&&(typeof T.max!="number"||T.max<0))throw new TypeError("max must be a non-negative number");this[p]=T.max||1/0;const S=T.length||l;if(this[u]=typeof S!="function"?l:S,this[i]=T.stale||!1,T.maxAge&&typeof T.maxAge!="number")throw new TypeError("maxAge must be a number");this[e]=T.maxAge||0,this[a]=T.dispose,this[n]=T.noDisposeOnSet||!1,this[f]=T.updateAgeOnGet||!1,this.reset()}set max(T){if(typeof T!="number"||T<0)throw new TypeError("max must be a non-negative number");this[p]=T||1/0,c(this)}get max(){return this[p]}set allowStale(T){this[i]=!!T}get allowStale(){return this[i]}set maxAge(T){if(typeof T!="number")throw new TypeError("maxAge must be a non-negative number");this[e]=T,c(this)}get maxAge(){return this[e]}set lengthCalculator(T){typeof T!="function"&&(T=l),T!==this[u]&&(this[u]=T,this[d]=0,this[t].forEach(S=>{S.length=this[u](S.value,S.key),this[d]+=S.length})),c(this)}get lengthCalculator(){return this[u]}get length(){return this[d]}get itemCount(){return this[t].length}rforEach(T,S){S=S||this;for(let F=this[t].tail;F!==null;){const W=F.prev;E(this,T,F,S),F=W}}forEach(T,S){S=S||this;for(let F=this[t].head;F!==null;){const W=F.next;E(this,T,F,S),F=W}}keys(){return this[t].toArray().map(T=>T.key)}values(){return this[t].toArray().map(T=>T.value)}reset(){this[a]&&this[t]&&this[t].length&&this[t].forEach(T=>this[a](T.key,T.value)),this[o]=new Map,this[t]=new w,this[d]=0}dump(){return this[t].map(T=>!g(this,T)&&{k:T.key,v:T.value,e:T.now+(T.maxAge||0)}).toArray().filter(T=>T)}dumpLru(){return this[t]}set(T,S,F){if((F=F||this[e])&&typeof F!="number")throw new TypeError("maxAge must be a number");const W=F?Date.now():0,m=this[u](S,T);if(this[o].has(T)){if(m>this[p])return v(this,this[o].get(T)),!1;const C=this[o].get(T).value;return this[a]&&(this[n]||this[a](T,C.value)),C.now=W,C.maxAge=F,C.value=S,this[d]+=m-C.length,C.length=m,this.get(T),c(this),!0}const y=new _(T,S,m,W,F);return y.length>this[p]?(this[a]&&this[a](T,S),!1):(this[d]+=y.length,this[t].unshift(y),this[o].set(T,this[t].head),c(this),!0)}has(T){if(!this[o].has(T))return!1;const S=this[o].get(T).value;return!g(this,S)}get(T){return h(this,T,!0)}peek(T){return h(this,T,!1)}pop(){const T=this[t].tail;return T?(v(this,T),T.value):null}del(T){v(this,this[o].get(T))}load(T){this.reset();const S=Date.now();for(let F=T.length-1;F>=0;F--){const W=T[F],m=W.e||0;if(m===0)this.set(W.k,W.v);else{const y=m-S;y>0&&this.set(W.k,W.v,y)}}}prune(){this[o].forEach((T,S)=>h(this,S,!1))}}},{yallist:83}],38:[function(I,z,q){(function(w){(function(){const p=z.exports;p.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"},p.codes={};for(const u in p.types){const i=p.types[u];p.codes[i]=u}p.CMD_SHIFT=4,p.CMD_MASK=240,p.DUP_MASK=8,p.QOS_MASK=3,p.QOS_SHIFT=1,p.RETAIN_MASK=1,p.VARBYTEINT_MASK=127,p.VARBYTEINT_FIN_MASK=128,p.VARBYTEINT_MAX=268435455,p.SESSIONPRESENT_MASK=1,p.SESSIONPRESENT_HEADER=w.from([p.SESSIONPRESENT_MASK]),p.CONNACK_HEADER=w.from([p.codes.connack<[0,1].map(e=>[0,1].map(a=>{const n=w.alloc(1);return n.writeUInt8(p.codes[u]<w.from([u])),p.EMPTY={pingreq:w.from([p.codes.pingreq<<4,0]),pingresp:w.from([p.codes.pingresp<<4,0]),disconnect:w.from([p.codes.disconnect<<4,0])}}).call(this)}).call(this,I("buffer").Buffer)},{buffer:17}],39:[function(I,z,q){(function(w){(function(){const p=I("./writeToStream"),d=I("events");class u extends d{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const a=new Array(this._array.length),n=this._array;let t,o=0;for(t=0;t>8,0),a.writeUInt8(255&e,1),a}z.exports={cache:d,generateCache:function(){for(let e=0;e<65536;e++)d[e]=i(e)},generateNumber:i,genBufVariableByteInt:function(e){let a=0,n=0;const t=w.allocUnsafe(4);do a=e%128|0,(e=e/128|0)>0&&(a|=128),t.writeUInt8(a,n++);while(e>0&&n<4);return e>0&&(n=0),u?t.subarray(0,n):t.slice(0,n)},generate4ByteBuffer:function(e){const a=w.allocUnsafe(4);return a.writeUInt32BE(e,0),a}}}).call(this)}).call(this,I("buffer").Buffer)},{buffer:17}],42:[function(I,z,q){z.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},{}],43:[function(I,z,q){const w=I("bl"),p=I("events"),d=I("./packet"),u=I("./constants"),i=I("debug")("mqtt-packet:parser");class e extends p{constructor(){super(),this.parser=this.constructor.parser}static parser(n){return this instanceof e?(this.settings=n||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new e().parser(n)}_resetState(){i("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new d,this.error=null,this._list=w(),this._stateCounter=0}parse(n){for(this.error&&this._resetState(),this._list.append(n),i("parse: current state: %s",this._states[this._stateCounter]);(this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,i("parse: state complete. _stateCounter is now: %d",this._stateCounter),i("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return i("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const n=this._list.readUInt8(0);return this.packet.cmd=u.types[n>>u.CMD_SHIFT],this.packet.retain=(n&u.RETAIN_MASK)!=0,this.packet.qos=n>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=(n&u.DUP_MASK)!=0,i("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const n=this._parseVarByteNum(!0);return n&&(this.packet.length=n.value,this._list.consume(n.bytes)),i("_parseLength %d",n.value),!!n}_parsePayload(){i("_parsePayload: payload %O",this._list);let n=!1;if(this.packet.length===0||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}n=!0}return i("_parsePayload complete result: %s",n),n}_parseConnect(){let n,t,o,f;i("_parseConnect");const l={},h=this.packet,g=this._parseString();if(g===null)return this._emitError(new Error("Cannot parse protocolId"));if(g!=="MQTT"&&g!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(h.protocolId=g,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(h.protocolVersion=this._list.readUInt8(this._pos),h.protocolVersion>=128&&(h.bridgeMode=!0,h.protocolVersion=h.protocolVersion-128),h.protocolVersion!==3&&h.protocolVersion!==4&&h.protocolVersion!==5)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(l.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,l.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,l.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,l.will&&(h.will={},h.will.retain=(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK)!=0,h.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),h.clean=(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK)!=0,this._pos++,h.keepalive=this._parseNum(),h.keepalive===-1)return this._emitError(new Error("Packet too short"));if(h.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(h.properties=v)}const c=this._parseString();if(c===null)return this._emitError(new Error("Packet too short"));if(h.clientId=c,i("_parseConnect: packet.clientId: %s",h.clientId),l.will){if(h.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(h.will.properties=v)}if((n=this._parseString())===null)return this._emitError(new Error("Cannot parse will topic"));if(h.will.topic=n,i("_parseConnect: packet.will.topic: %s",h.will.topic),(t=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse will payload"));h.will.payload=t,i("_parseConnect: packet.will.paylaod: %s",h.will.payload)}if(l.username){if((f=this._parseString())===null)return this._emitError(new Error("Cannot parse username"));h.username=f,i("_parseConnect: packet.username: %s",h.username)}if(l.password){if((o=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse password"));h.password=o}return this.settings=h,i("_parseConnect: complete"),h}_parseConnack(){i("_parseConnack");const n=this.packet;if(this._list.length<1)return null;if(n.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?n.reasonCode=this._list.readUInt8(this._pos++):n.reasonCode=0;else{if(this._list.length<2)return null;n.returnCode=this._list.readUInt8(this._pos++)}if(n.returnCode===-1||n.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(n.properties=t)}i("_parseConnack: complete")}_parsePublish(){i("_parsePublish");const n=this.packet;if(n.topic=this._parseString(),n.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(n.qos>0)||this._parseMessageId()){if(this.settings.protocolVersion===5){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(n.properties=t)}n.payload=this._list.slice(this._pos,n.length),i("_parsePublish: payload from buffer list: %o",n.payload)}}_parseSubscribe(){i("_parseSubscribe");const n=this.packet;let t,o,f,l,h,g,c;if(n.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(n.properties=v)}for(;this._pos=n.length)return this._emitError(new Error("Malformed Subscribe Payload"));f=(o=this._parseByte())&u.SUBSCRIBE_OPTIONS_QOS_MASK,g=(o>>u.SUBSCRIBE_OPTIONS_NL_SHIFT&u.SUBSCRIBE_OPTIONS_NL_MASK)!=0,h=(o>>u.SUBSCRIBE_OPTIONS_RAP_SHIFT&u.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,l=o>>u.SUBSCRIBE_OPTIONS_RH_SHIFT&u.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:f},this.settings.protocolVersion===5?(c.nl=g,c.rap=h,c.rh=l):this.settings.bridgeMode&&(c.rh=0,c.rap=!0,c.nl=!0),i("_parseSubscribe: push subscription `%s` to subscription",c),n.subscriptions.push(c)}}}_parseSuback(){i("_parseSuback");const n=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(n.properties=t)}for(;this._pos2?(n.reasonCode=this._parseByte(),i("_parseConfirmation: packet.reasonCode `%d`",n.reasonCode)):n.reasonCode=0,n.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(n.properties=t)}return!0}_parseDisconnect(){const n=this.packet;if(i("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?n.reasonCode=this._parseByte():n.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(n.properties=t)}return i("_parseDisconnect result: true"),!0}_parseAuth(){i("_parseAuth");const n=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));n.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(n.properties=t),i("_parseAuth: result: true"),!0}_parseMessageId(){const n=this.packet;return n.messageId=this._parseNum(),n.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(i("_parseMessageId: packet.messageId %d",n.messageId),!0)}_parseString(n){const t=this._parseNum(),o=t+this._pos;if(t===-1||o>this._list.length||o>this.packet.length)return null;const f=this._list.toString("utf8",this._pos,o);return this._pos+=t,i("_parseString: result: %s",f),f}_parseStringPair(){return i("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const n=this._parseNum(),t=n+this._pos;if(n===-1||t>this._list.length||t>this.packet.length)return null;const o=this._list.slice(this._pos,t);return this._pos+=n,i("_parseBuffer: result: %o",o),o}_parseNum(){if(this._list.length-this._pos<2)return-1;const n=this._list.readUInt16BE(this._pos);return this._pos+=2,i("_parseNum: result: %s",n),n}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const n=this._list.readUInt32BE(this._pos);return this._pos+=4,i("_parse4ByteNum: result: %s",n),n}_parseVarByteNum(n){i("_parseVarByteNum");let t,o=0,f=1,l=0,h=!1;const g=this._pos?this._pos:0;for(;o<4&&g+o=o&&this._emitError(new Error("Invalid variable byte integer")),g&&(this._pos+=o),i("_parseVarByteNum: result: %o",h=!!h&&(n?{bytes:o,value:l}:l)),h}_parseByte(){let n;return this._pos=4)&&(s||G))D+=w.byteLength(s)+2;else{if(K<4)return O.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*G==0)return O.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof r!="number"||r<0||r>65535||r%1!=0)return O.emit("error",new Error("Invalid keepalive")),!1;if(D+=2,D+=1,K===5){var Q=y(O,j);if(!Q)return!1;D+=Q.length}if($){if(typeof $!="object")return O.emit("error",new Error("Invalid will")),!1;if(!$.topic||typeof $.topic!="string")return O.emit("error",new Error("Invalid will topic")),!1;if(D+=w.byteLength($.topic)+2,D+=2,$.payload){if(!($.payload.length>=0))return O.emit("error",new Error("Invalid will payload")),!1;typeof $.payload=="string"?D+=w.byteLength($.payload):D+=$.payload.length}var Z={};if(K===5){if(!(Z=y(O,$.properties)))return!1;D+=Z.length}}let Y=!1;if(b!=null){if(!L(b))return O.emit("error",new Error("Invalid username")),!1;Y=!0,D+=w.byteLength(b)+2}if(x!=null){if(!Y)return O.emit("error",new Error("Username is required to use password")),!1;if(!L(x))return O.emit("error",new Error("Invalid password")),!1;D+=N(x)+2}O.write(p.CONNECT_HEADER),E(O,D),m(O,V),H.bridgeMode&&(K+=128),O.write(K===131?p.VERSION131:K===132?p.VERSION132:K===4?p.VERSION4:K===5?p.VERSION5:p.VERSION3);let X=0;return X|=b!=null?p.USERNAME_MASK:0,X|=x!=null?p.PASSWORD_MASK:0,X|=$&&$.retain?p.WILL_RETAIN_MASK:0,X|=$&&$.qos?$.qos<0&&h(O,s),j!=null&&j.write(),a("publish: payload: %o",r),O.write(r)}(B,P,M);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(R,O,U){const H=U?U.protocolVersion:4,V=R||{},K=V.cmd||"puback",$=V.messageId,G=V.dup&&K==="pubrel"?p.DUP_MASK:0;let r=0;const s=V.reasonCode,b=V.properties;let x=H===5?3:2;if(K==="pubrel"&&(r=1),typeof $!="number")return O.emit("error",new Error("Invalid messageId")),!1;let j=null;if(H===5&&typeof b=="object"){if(!(j=C(O,b,U,x)))return!1;x+=j.length}return O.write(p.ACKS[K][r][G][0]),E(O,x),h(O,$),H===5&&O.write(w.from([s])),j!==null&&j.write(),!0}(B,P,M);case"subscribe":return function(R,O,U){a("subscribe: packet: ");const H=U?U.protocolVersion:4,V=R||{},K=V.dup?p.DUP_MASK:0,$=V.messageId,G=V.subscriptions,r=V.properties;let s=0;if(typeof $!="number")return O.emit("error",new Error("Invalid messageId")),!1;s+=2;let b=null;if(H===5){if(!(b=y(O,r)))return!1;s+=b.length}if(typeof G!="object"||!G.length)return O.emit("error",new Error("Invalid subscriptions")),!1;for(let j=0;j2)return O.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}s+=w.byteLength(D)+2+1}a("subscribe: writing to stream: %o",p.SUBSCRIBE_HEADER),O.write(p.SUBSCRIBE_HEADER[1][K?1:0][0]),E(O,s),h(O,$),b!==null&&b.write();let x=!0;for(const j of G){const D=j.topic,Q=j.qos,Z=+j.nl,Y=+j.rap,X=j.rh;let te;T(O,D),te=p.SUBSCRIBE_OPTIONS_QOS[Q],H===5&&(te|=Z?p.SUBSCRIBE_OPTIONS_NL:0,te|=Y?p.SUBSCRIBE_OPTIONS_RAP:0,te|=X?p.SUBSCRIBE_OPTIONS_RH[X]:0),x=O.write(w.from([te]))}return x}(B,P,M);case"suback":return function(R,O,U){const H=U?U.protocolVersion:4,V=R||{},K=V.messageId,$=V.granted,G=V.properties;let r=0;if(typeof K!="number")return O.emit("error",new Error("Invalid messageId")),!1;if(r+=2,typeof $!="object"||!$.length)return O.emit("error",new Error("Invalid qos vector")),!1;for(let b=0;b<$.length;b+=1){if(typeof $[b]!="number")return O.emit("error",new Error("Invalid qos vector")),!1;r+=1}let s=null;if(H===5){if(!(s=C(O,G,U,r)))return!1;r+=s.length}return O.write(p.SUBACK_HEADER),E(O,r),h(O,K),s!==null&&s.write(),O.write(w.from($))}(B,P,M);case"unsubscribe":return function(R,O,U){const H=U?U.protocolVersion:4,V=R||{},K=V.messageId,$=V.dup?p.DUP_MASK:0,G=V.unsubscriptions,r=V.properties;let s=0;if(typeof K!="number")return O.emit("error",new Error("Invalid messageId")),!1;if(s+=2,typeof G!="object"||!G.length)return O.emit("error",new Error("Invalid unsubscriptions")),!1;for(let j=0;jh===F,set(B){B?(n&&Object.keys(n).length!==0||(g=!0),h=F):(g=!1,h=W)}});const _={};function E(B,P){if(P>p.VARBYTEINT_MAX)return B.emit("error",new Error(`Invalid variable byte integer: ${P}`)),!1;let M=_[P];return M||(M=f(P),P<16384&&(_[P]=M)),a("writeVarByteInt: writing to stream: %o",M),B.write(M)}function T(B,P){const M=w.byteLength(P);return h(B,M),a("writeString: %s",P),B.write(P,"utf8")}function S(B,P,M){T(B,P),T(B,M)}function F(B,P){return a("writeNumberCached: number: %d",P),a("writeNumberCached: %o",n[P]),B.write(n[P])}function W(B,P){const M=t(P);return a("writeNumberGenerated: %o",M),B.write(M)}function m(B,P){typeof P=="string"?T(B,P):P?(h(B,P.length),B.write(P)):h(B,0)}function y(B,P){if(typeof P!="object"||P.length!=null)return{length:1,write(){A(B,{},0)}};let M=0;function R(O,U){let H=0;switch(p.propertiesTypes[O]){case"byte":if(typeof U!="boolean")return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=2;break;case"int8":if(typeof U!="number"||U<0||U>255)return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=2;break;case"binary":if(U&&U===null)return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=1+w.byteLength(U)+2;break;case"int16":if(typeof U!="number"||U<0||U>65535)return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=3;break;case"int32":if(typeof U!="number"||U<0||U>4294967295)return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=5;break;case"var":if(typeof U!="number"||U<0||U>268435455)return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=1+w.byteLength(f(U));break;case"string":if(typeof U!="string")return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=3+w.byteLength(U.toString());break;case"pair":if(typeof U!="object")return B.emit("error",new Error(`Invalid ${O}: ${U}`)),!1;H+=Object.getOwnPropertyNames(U).reduce((V,K)=>{const $=U[K];return Array.isArray($)?V+=$.reduce((G,r)=>G+=3+w.byteLength(K.toString())+2+w.byteLength(r.toString()),0):V+=3+w.byteLength(K.toString())+2+w.byteLength(U[K].toString()),V},0);break;default:return B.emit("error",new Error(`Invalid property ${O}: ${U}`)),!1}return H}if(P)for(const O in P){let U=0,H=0;const V=P[O];if(Array.isArray(V))for(let K=0;KU;){const V=O.shift();if(!V||!P[V])return!1;delete P[V],H=y(B,P)}return H}function k(B,P,M){switch(p.propertiesTypes[P]){case"byte":B.write(w.from([p.properties[P]])),B.write(w.from([+M]));break;case"int8":B.write(w.from([p.properties[P]])),B.write(w.from([M]));break;case"binary":B.write(w.from([p.properties[P]])),m(B,M);break;case"int16":B.write(w.from([p.properties[P]])),h(B,M);break;case"int32":B.write(w.from([p.properties[P]])),function(R,O){const U=l(O);a("write4ByteNumber: %o",U),R.write(U)}(B,M);break;case"var":B.write(w.from([p.properties[P]])),E(B,M);break;case"string":B.write(w.from([p.properties[P]])),T(B,M);break;case"pair":Object.getOwnPropertyNames(M).forEach(R=>{const O=M[R];Array.isArray(O)?O.forEach(U=>{B.write(w.from([p.properties[P]])),S(B,R.toString(),U.toString())}):(B.write(w.from([p.properties[P]])),S(B,R.toString(),O.toString()))});break;default:return B.emit("error",new Error(`Invalid property ${P} value: ${M}`)),!1}}function A(B,P,M){E(B,M);for(const R in P)if(Object.prototype.hasOwnProperty.call(P,R)&&P[R]!==null){const O=P[R];if(Array.isArray(O))for(let U=0;U=1.5*o;return Math.round(n/o)+" "+f+(l?"s":"")}z.exports=function(n,t){t=t||{};var o=typeof n;if(o==="string"&&n.length>0)return function(f){if(!((f=String(f)).length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(l){var h=parseFloat(l[1]);switch((l[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return h*e;case"weeks":case"week":case"w":return h*i;case"days":case"day":case"d":return h*u;case"hours":case"hour":case"hrs":case"hr":case"h":return h*d;case"minutes":case"minute":case"mins":case"min":case"m":return h*p;case"seconds":case"second":case"secs":case"sec":case"s":return h*w;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}(n);if(o==="number"&&isFinite(n))return t.long?function(f){var l=Math.abs(f);return l>=u?a(f,l,u,"day"):l>=d?a(f,l,d,"hour"):l>=p?a(f,l,p,"minute"):l>=w?a(f,l,w,"second"):f+" ms"}(n):function(f){var l=Math.abs(f);return l>=u?Math.round(f/u)+"d":l>=d?Math.round(f/d)+"h":l>=p?Math.round(f/p)+"m":l>=w?Math.round(f/w)+"s":f+"ms"}(n);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(n))}},{}],46:[function(I,z,q){const w=I("./lib/number-allocator.js");z.exports.NumberAllocator=w},{"./lib/number-allocator.js":47}],47:[function(I,z,q){const w=I("js-sdsl").Set,p=I("debug")("number-allocator:trace"),d=I("debug")("number-allocator:error");function u(e,a){this.low=e,this.high=a}function i(e,a){if(!(this instanceof i))return new i(e,a);this.min=e,this.max=a,this.ss=new w([],(n,t)=>n.compare(t)),p("Create"),this.clear()}u.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},u.prototype.compare=function(e){return this.lowe)return!1;if(n.low===e)return++n.low,p("use():"+e),!0;if(n.high===e)return--n.high,p("use():"+e),!0;const t=n.low;return n.low=e+1,this.ss.insert(new u(t,e-1)),p("use():"+e),!0}return p("use():failed"),!1},i.prototype.free=function(e){if(ethis.max)return void d("free():"+e+" is out of range");const a=new u(e,e),n=this.ss.lowerBound(a);if(n){if(n.low<=e&&e<=n.high)return void d("free():"+e+" has already been vacant");if(n===this.ss.front())e+1===n.low?--n.low:this.ss.insert(a);else{const t=this.ss.reverseLowerBound(a);t.high+1===e?e+1===n.low?(this.ss.eraseElementByValue(t),n.low=t.low):t.high=e:e+1===n.low?n.low=e:this.ss.insert(a)}}else{if(n===this.ss.front())return void this.ss.insert(a);const t=this.ss.reverseLowerBound(a);t.high+1===e?t.high=e:this.ss.insert(a)}p("free():"+e)},i.prototype.clear=function(){p("clear()"),this.ss.clear(),this.ss.insert(new u(this.min,this.max))},i.prototype.intervalCount=function(){return this.ss.size()},i.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},z.exports=i},{debug:18,"js-sdsl":36}],48:[function(I,z,q){var w=I("wrappy");function p(u){var i=function(){return i.called?i.value:(i.called=!0,i.value=u.apply(this,arguments))};return i.called=!1,i}function d(u){var i=function(){if(i.called)throw new Error(i.onceError);return i.called=!0,i.value=u.apply(this,arguments)},e=u.name||"Function wrapped with `once`";return i.onceError=e+" shouldn't be called more than once",i.called=!1,i}z.exports=w(p),z.exports.strict=w(d),p.proto=p(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return p(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return d(this)},configurable:!0})})},{wrappy:79}],49:[function(I,z,q){(function(w){(function(){w===void 0||!w.version||w.version.indexOf("v0.")===0||w.version.indexOf("v1.")===0&&w.version.indexOf("v1.8.")!==0?z.exports={nextTick:function(p,d,u,i){if(typeof p!="function")throw new TypeError('"callback" argument must be a function');var e,a,n=arguments.length;switch(n){case 0:case 1:return w.nextTick(p);case 2:return w.nextTick(function(){p.call(null,d)});case 3:return w.nextTick(function(){p.call(null,d,u)});case 4:return w.nextTick(function(){p.call(null,d,u,i)});default:for(e=new Array(n-1),a=0;a1)for(var _=1;_= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=t-o,W=Math.floor,m=String.fromCharCode;function y(R){throw new RangeError(S[R])}function C(R,O){for(var U=R.length,H=[];U--;)H[U]=O(R[U]);return H}function k(R,O){var U=R.split("@"),H="";return U.length>1&&(H=U[0]+"@",R=U[1]),H+C((R=R.replace(T,".")).split("."),O).join(".")}function A(R){for(var O,U,H=[],V=0,K=R.length;V=55296&&O<=56319&&V65535&&(U+=m((O-=65536)>>>10&1023|55296),O=56320|1023&O),U+=m(O)}).join("")}function L(R,O){return R+22+75*(R<26)-((O!=0)<<5)}function B(R,O,U){var H=0;for(R=U?W(R/h):R>>1,R+=W(R/O);R>F*f>>1;H+=t)R=W(R/F);return W(H+(F+1)*R/(R+l))}function P(R){var O,U,H,V,K,$,G,r,s,b,x,j=[],D=R.length,Q=0,Z=c,Y=g;for((U=R.lastIndexOf(v))<0&&(U=0),H=0;H=128&&y("not-basic"),j.push(R.charCodeAt(H));for(V=U>0?U+1:0;V=D&&y("invalid-input"),((r=(x=R.charCodeAt(V++))-48<10?x-22:x-65<26?x-65:x-97<26?x-97:t)>=t||r>W((n-Q)/$))&&y("overflow"),Q+=r*$,!(r<(s=G<=Y?o:G>=Y+f?f:G-Y));G+=t)$>W(n/(b=t-s))&&y("overflow"),$*=b;Y=B(Q-K,O=j.length+1,K==0),W(Q/O)>n-Z&&y("overflow"),Z+=W(Q/O),Q%=O,j.splice(Q++,0,Z)}return N(j)}function M(R){var O,U,H,V,K,$,G,r,s,b,x,j,D,Q,Z,Y=[];for(j=(R=A(R)).length,O=c,U=0,K=g,$=0;$=O&&xW((n-U)/(D=H+1))&&y("overflow"),U+=(G-O)*D,O=G,$=0;$n&&y("overflow"),x==O){for(r=U,s=t;!(r<(b=s<=K?o:s>=K+f?f:s-K));s+=t)Z=r-b,Q=t-b,Y.push(m(L(b+Z%Q,0))),r=W(Z/Q);Y.push(m(L(r,0))),K=B(U,D,H==V),U=0,++H}++U,++O}return Y.join("")}if(e={version:"1.4.1",ucs2:{decode:A,encode:N},decode:P,encode:M,toASCII:function(R){return k(R,function(O){return E.test(O)?"xn--"+M(O):O})},toUnicode:function(R){return k(R,function(O){return _.test(O)?P(O.slice(4).toLowerCase()):O})}},d&&u)if(z.exports==d)u.exports=e;else for(a in e)e.hasOwnProperty(a)&&(d[a]=e[a]);else p.punycode=e})(this)}).call(this)}).call(this,typeof fe!="undefined"?fe:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],52:[function(I,z,q){function w(d,u){return Object.prototype.hasOwnProperty.call(d,u)}z.exports=function(d,u,i,e){u=u||"&",i=i||"=";var a={};if(typeof d!="string"||d.length===0)return a;var n=/\+/g;d=d.split(u);var t=1e3;e&&typeof e.maxKeys=="number"&&(t=e.maxKeys);var o=d.length;t>0&&o>t&&(o=t);for(var f=0;f=0?(l=v.substr(0,_),h=v.substr(_+1)):(l=v,h=""),g=decodeURIComponent(l),c=decodeURIComponent(h),w(a,g)?p(a[g])?a[g].push(c):a[g]=[a[g],c]:a[g]=c}return a};var p=Array.isArray||function(d){return Object.prototype.toString.call(d)==="[object Array]"}},{}],53:[function(I,z,q){var w=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}};z.exports=function(i,e,a,n){return e=e||"&",a=a||"=",i===null&&(i=void 0),typeof i=="object"?d(u(i),function(t){var o=encodeURIComponent(w(t))+a;return p(i[t])?d(i[t],function(f){return o+encodeURIComponent(w(f))}).join(e):o+encodeURIComponent(w(i[t]))}).join(e):n?encodeURIComponent(w(n))+a+encodeURIComponent(w(i)):""};var p=Array.isArray||function(i){return Object.prototype.toString.call(i)==="[object Array]"};function d(i,e){if(i.map)return i.map(e);for(var a=[],n=0;n2?"one of ".concat(i," ").concat(u.slice(0,e-1).join(", "),", or ")+u[e-1]:e===2?"one of ".concat(i," ").concat(u[0]," or ").concat(u[1]):"of ".concat(i," ").concat(u[0])}return"of ".concat(i," ").concat(String(u))}p("ERR_INVALID_OPT_VALUE",function(u,i){return'The value "'+i+'" is invalid for option "'+u+'"'},TypeError),p("ERR_INVALID_ARG_TYPE",function(u,i,e){var a,n,t;if(typeof i=="string"&&(n="not ",i.substr(0,n.length)===n)?(a="must not be",i=i.replace(/^not /,"")):a="must be",function(f,l,h){return(h===void 0||h>f.length)&&(h=f.length),f.substring(h-l.length,h)===l}(u," argument"))t="The ".concat(u," ").concat(a," ").concat(d(i,"type"));else{var o=function(f,l,h){return typeof h!="number"&&(h=0),!(h+l.length>f.length)&&f.indexOf(l,h)!==-1}(u,".")?"property":"argument";t='The "'.concat(u,'" ').concat(o," ").concat(a," ").concat(d(i,"type"))}return t+=". Received type ".concat(typeof e)},TypeError),p("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),p("ERR_METHOD_NOT_IMPLEMENTED",function(u){return"The "+u+" method is not implemented"}),p("ERR_STREAM_PREMATURE_CLOSE","Premature close"),p("ERR_STREAM_DESTROYED",function(u){return"Cannot call "+u+" after a stream was destroyed"}),p("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),p("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),p("ERR_STREAM_WRITE_AFTER_END","write after end"),p("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),p("ERR_UNKNOWN_ENCODING",function(u){return"Unknown encoding: "+u},TypeError),p("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),z.exports.codes=w},{}],56:[function(I,z,q){(function(w){(function(){var p=Object.keys||function(f){var l=[];for(var h in f)l.push(h);return l};z.exports=n;var d=I("./_stream_readable"),u=I("./_stream_writable");I("inherits")(n,d);for(var i=p(u.prototype),e=0;e0)if(typeof s=="string"||Q.objectMode||Object.getPrototypeOf(s)===e.prototype||(s=function(Z){return e.from(Z)}(s)),x)Q.endEmitted?F(r,new S):k(r,Q,s,!0);else if(Q.ended)F(r,new E);else{if(Q.destroyed)return!1;Q.reading=!1,Q.decoder&&!b?(s=Q.decoder.write(s),Q.objectMode||s.length!==0?k(r,Q,s,!1):P(r,Q)):k(r,Q,s,!1)}else x||(Q.reading=!1,P(r,Q));return!Q.ended&&(Q.lengths.highWaterMark&&(s.highWaterMark=function(b){return b>=A?b=A:(b--,b|=b>>>1,b|=b>>>2,b|=b>>>4,b|=b>>>8,b|=b>>>16,b++),b}(r)),r<=s.length?r:s.ended?s.length:(s.needReadable=!0,0))}function L(r){var s=r._readableState;n("emitReadable",s.needReadable,s.emittedReadable),s.needReadable=!1,s.emittedReadable||(n("emitReadable",s.flowing),s.emittedReadable=!0,w.nextTick(B,r))}function B(r){var s=r._readableState;n("emitReadable_",s.destroyed,s.length,s.ended),s.destroyed||!s.length&&!s.ended||(r.emit("readable"),s.emittedReadable=!1),s.needReadable=!s.flowing&&!s.ended&&s.length<=s.highWaterMark,H(r)}function P(r,s){s.readingMore||(s.readingMore=!0,w.nextTick(M,r,s))}function M(r,s){for(;!s.reading&&!s.ended&&(s.length0,s.resumeScheduled&&!s.paused?s.flowing=!0:r.listenerCount("data")>0&&r.resume()}function O(r){n("readable nexttick read 0"),r.read(0)}function U(r,s){n("resume",s.reading),s.reading||r.read(0),s.resumeScheduled=!1,r.emit("resume"),H(r),s.flowing&&!s.reading&&r.read(0)}function H(r){var s=r._readableState;for(n("flow",s.flowing);s.flowing&&r.read()!==null;);}function V(r,s){return s.length===0?null:(s.objectMode?b=s.buffer.shift():!r||r>=s.length?(b=s.decoder?s.buffer.join(""):s.buffer.length===1?s.buffer.first():s.buffer.concat(s.length),s.buffer.clear()):b=s.buffer.consume(r,s.decoder),b);var b}function K(r){var s=r._readableState;n("endReadable",s.endEmitted),s.endEmitted||(s.ended=!0,w.nextTick($,s,r))}function $(r,s){if(n("endReadableNT",r.endEmitted,r.length),!r.endEmitted&&r.length===0&&(r.endEmitted=!0,s.readable=!1,s.emit("end"),r.autoDestroy)){var b=s._writableState;(!b||b.autoDestroy&&b.finished)&&s.destroy()}}function G(r,s){for(var b=0,x=r.length;b=s.highWaterMark:s.length>0)||s.ended))return n("read: emitReadable",s.length,s.ended),s.length===0&&s.ended?K(this):L(this),null;if((r=N(r,s))===0&&s.ended)return s.length===0&&K(this),null;var x,j=s.needReadable;return n("need readable",j),(s.length===0||s.length-r0?V(r,s):null)===null?(s.needReadable=s.length<=s.highWaterMark,r=0):(s.length-=r,s.awaitDrain=0),s.length===0&&(s.ended||(s.needReadable=!0),b!==r&&s.ended&&K(this)),x!==null&&this.emit("data",x),x},y.prototype._read=function(r){F(this,new T("_read()"))},y.prototype.pipe=function(r,s){var b=this,x=this._readableState;switch(x.pipesCount){case 0:x.pipes=r;break;case 1:x.pipes=[x.pipes,r];break;default:x.pipes.push(r)}x.pipesCount+=1,n("pipe count=%d opts=%j",x.pipesCount,s);var j=(!s||s.end!==!1)&&r!==w.stdout&&r!==w.stderr?Q:ue;function D(re,ne){n("onunpipe"),re===b&&ne&&ne.hasUnpiped===!1&&(ne.hasUnpiped=!0,n("cleanup"),r.removeListener("close",le),r.removeListener("finish",se),r.removeListener("drain",Z),r.removeListener("error",te),r.removeListener("unpipe",D),b.removeListener("end",Q),b.removeListener("end",ue),b.removeListener("data",X),Y=!0,!x.awaitDrain||r._writableState&&!r._writableState.needDrain||Z())}function Q(){n("onend"),r.end()}x.endEmitted?w.nextTick(j):b.once("end",j),r.on("unpipe",D);var Z=function(re){return function(){var ne=re._readableState;n("pipeOnDrain",ne.awaitDrain),ne.awaitDrain&&ne.awaitDrain--,ne.awaitDrain===0&&u(re,"data")&&(ne.flowing=!0,H(re))}}(b);r.on("drain",Z);var Y=!1;function X(re){n("ondata");var ne=r.write(re);n("dest.write",ne),ne===!1&&((x.pipesCount===1&&x.pipes===r||x.pipesCount>1&&G(x.pipes,r)!==-1)&&!Y&&(n("false write response, pause",x.awaitDrain),x.awaitDrain++),b.pause())}function te(re){n("onerror",re),ue(),r.removeListener("error",te),u(r,"error")===0&&F(r,re)}function le(){r.removeListener("finish",se),ue()}function se(){n("onfinish"),r.removeListener("close",le),ue()}function ue(){n("unpipe"),b.unpipe(r)}return b.on("data",X),function(re,ne,ye){if(typeof re.prependListener=="function")return re.prependListener(ne,ye);re._events&&re._events[ne]?Array.isArray(re._events[ne])?re._events[ne].unshift(ye):re._events[ne]=[ye,re._events[ne]]:re.on(ne,ye)}(r,"error",te),r.once("close",le),r.once("finish",se),r.emit("pipe",b),x.flowing||(n("pipe resume"),b.resume()),r},y.prototype.unpipe=function(r){var s=this._readableState,b={hasUnpiped:!1};if(s.pipesCount===0)return this;if(s.pipesCount===1)return r&&r!==s.pipes?this:(r||(r=s.pipes),s.pipes=null,s.pipesCount=0,s.flowing=!1,r&&r.emit("unpipe",this,b),this);if(!r){var x=s.pipes,j=s.pipesCount;s.pipes=null,s.pipesCount=0,s.flowing=!1;for(var D=0;D0,x.flowing!==!1&&this.resume()):r==="readable"&&(x.endEmitted||x.readableListening||(x.readableListening=x.needReadable=!0,x.flowing=!1,x.emittedReadable=!1,n("on readable",x.length,x.reading),x.length?L(this):x.reading||w.nextTick(O,this))),b},y.prototype.addListener=y.prototype.on,y.prototype.removeListener=function(r,s){var b=i.prototype.removeListener.call(this,r,s);return r==="readable"&&w.nextTick(R,this),b},y.prototype.removeAllListeners=function(r){var s=i.prototype.removeAllListeners.apply(this,arguments);return r!=="readable"&&r!==void 0||w.nextTick(R,this),s},y.prototype.resume=function(){var r=this._readableState;return r.flowing||(n("resume"),r.flowing=!r.readableListening,function(s,b){b.resumeScheduled||(b.resumeScheduled=!0,w.nextTick(U,s,b))}(this,r)),r.paused=!1,this},y.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},y.prototype.wrap=function(r){var s=this,b=this._readableState,x=!1;for(var j in r.on("end",function(){if(n("wrapped end"),b.decoder&&!b.ended){var Q=b.decoder.end();Q&&Q.length&&s.push(Q)}s.push(null)}),r.on("data",function(Q){n("wrapped data"),b.decoder&&(Q=b.decoder.write(Q)),(!b.objectMode||Q!=null)&&(b.objectMode||Q&&Q.length)&&(s.push(Q)||(x=!0,r.pause()))}),r)this[j]===void 0&&typeof r[j]=="function"&&(this[j]=function(Q){return function(){return r[Q].apply(r,arguments)}}(j));for(var D=0;D-1))throw new S(P);return this._writableState.defaultEncoding=P,this},Object.defineProperty(y.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(P,M,R){R(new g("_write()"))},y.prototype._writev=null,y.prototype.end=function(P,M,R){var O=this._writableState;return typeof P=="function"?(R=P,P=null,M=null):typeof M=="function"&&(R=M,M=null),P!=null&&this.write(P,M),O.corked&&(O.corked=1,this.uncork()),O.ending||function(U,H,V){H.ending=!0,B(U,H),V&&(H.finished?w.nextTick(V):U.once("finish",V)),H.ended=!0,U.writable=!1}(this,O,R),this},Object.defineProperty(y.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(y.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(P){this._writableState&&(this._writableState.destroyed=P)}}),y.prototype.destroy=o.destroy,y.prototype._undestroy=o.undestroy,y.prototype._destroy=function(P,M){M(P)}}).call(this)}).call(this,I("_process"),typeof fe!="undefined"?fe:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(I,z,q){(function(w){(function(){var p;function d(v,_,E){return _ in v?Object.defineProperty(v,_,{value:E,enumerable:!0,configurable:!0,writable:!0}):v[_]=E,v}var u=I("./end-of-stream"),i=Symbol("lastResolve"),e=Symbol("lastReject"),a=Symbol("error"),n=Symbol("ended"),t=Symbol("lastPromise"),o=Symbol("handlePromise"),f=Symbol("stream");function l(v,_){return{value:v,done:_}}function h(v){var _=v[i];if(_!==null){var E=v[f].read();E!==null&&(v[t]=null,v[i]=null,v[e]=null,_(l(E,!1)))}}var g=Object.getPrototypeOf(function(){}),c=Object.setPrototypeOf((d(p={get stream(){return this[f]},next:function(){var v=this,_=this[a];if(_!==null)return Promise.reject(_);if(this[n])return Promise.resolve(l(void 0,!0));if(this[f].destroyed)return new Promise(function(F,W){w.nextTick(function(){v[a]?W(v[a]):F(l(void 0,!0))})});var E,T=this[t];if(T)E=new Promise(function(F,W){return function(m,y){F.then(function(){W[n]?m(l(void 0,!0)):W[o](m,y)},y)}}(T,this));else{var S=this[f].read();if(S!==null)return Promise.resolve(l(S,!1));E=new Promise(this[o])}return this[t]=E,E}},Symbol.asyncIterator,function(){return this}),d(p,"return",function(){var v=this;return new Promise(function(_,E){v[f].destroy(null,function(T){T?E(T):_(l(void 0,!0))})})}),p),g);z.exports=function(v){var _,E=Object.create(c,(d(_={},f,{value:v,writable:!0}),d(_,i,{value:null,writable:!0}),d(_,e,{value:null,writable:!0}),d(_,a,{value:null,writable:!0}),d(_,n,{value:v._readableState.endEmitted,writable:!0}),d(_,o,{value:function(T,S){var F=E[f].read();F?(E[t]=null,E[i]=null,E[e]=null,T(l(F,!1))):(E[i]=T,E[e]=S)},writable:!0}),_));return E[t]=null,u(v,function(T){if(T&&T.code!=="ERR_STREAM_PREMATURE_CLOSE"){var S=E[e];return S!==null&&(E[t]=null,E[i]=null,E[e]=null,S(T)),void(E[a]=T)}var F=E[i];F!==null&&(E[t]=null,E[i]=null,E[e]=null,F(l(void 0,!0))),E[n]=!0}),v.on("readable",function(T){w.nextTick(h,T)}.bind(null,E)),E}}).call(this)}).call(this,I("_process"))},{"./end-of-stream":64,_process:50}],62:[function(I,z,q){function w(a,n){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);n&&(o=o.filter(function(f){return Object.getOwnPropertyDescriptor(a,f).enumerable})),t.push.apply(t,o)}return t}function p(a,n,t){return n in a?Object.defineProperty(a,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[n]=t,a}function d(a,n){for(var t=0;t0?this.tail.next=f:this.head=f,this.tail=f,++this.length}},{key:"unshift",value:function(o){var f={data:o,next:this.head};this.length===0&&(this.tail=f),this.head=f,++this.length}},{key:"shift",value:function(){if(this.length!==0){var o=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,o}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(o){if(this.length===0)return"";for(var f=this.head,l=""+f.data;f=f.next;)l+=o+f.data;return l}},{key:"concat",value:function(o){if(this.length===0)return u.alloc(0);for(var f,l,h,g=u.allocUnsafe(o>>>0),c=this.head,v=0;c;)f=c.data,l=g,h=v,u.prototype.copy.call(f,l,h),v+=c.data.length,c=c.next;return g}},{key:"consume",value:function(o,f){var l;return og.length?g.length:o;if(c===g.length?h+=g:h+=g.slice(0,o),(o-=c)===0){c===g.length?(++l,f.next?this.head=f.next:this.head=this.tail=null):(this.head=f,f.data=g.slice(c));break}++l}return this.length-=l,h}},{key:"_getBuffer",value:function(o){var f=u.allocUnsafe(o),l=this.head,h=1;for(l.data.copy(f),o-=l.data.length;l=l.next;){var g=l.data,c=o>g.length?g.length:o;if(g.copy(f,f.length-o,0,c),(o-=c)===0){c===g.length?(++h,l.next?this.head=l.next:this.head=this.tail=null):(this.head=l,l.data=g.slice(c));break}++h}return this.length-=h,f}},{key:e,value:function(o,f){return i(this,function(l){for(var h=1;h0,function(_){f||(f=_),_&&h.forEach(e),v||(h.forEach(e),l(f))})});return t.reduce(a)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(I,z,q){var w=I("../../../errors").codes.ERR_INVALID_OPT_VALUE;z.exports={getHighWaterMark:function(p,d,u,i){var e=function(a,n,t){return a.highWaterMark!=null?a.highWaterMark:n?a[t]:null}(d,i,u);if(e!=null){if(!isFinite(e)||Math.floor(e)!==e||e<0)throw new w(i?u:"highWaterMark",e);return Math.floor(e)}return p.objectMode?16:16384}}},{"../../../errors":55}],68:[function(I,z,q){z.exports=I("events").EventEmitter},{events:22}],69:[function(I,z,q){(q=z.exports=I("./lib/_stream_readable.js")).Stream=q,q.Readable=q,q.Writable=I("./lib/_stream_writable.js"),q.Duplex=I("./lib/_stream_duplex.js"),q.Transform=I("./lib/_stream_transform.js"),q.PassThrough=I("./lib/_stream_passthrough.js"),q.finished=I("./lib/internal/streams/end-of-stream.js"),q.pipeline=I("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(I,z,q){z.exports=function(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var w;if(arguments.length>0){w=new Array(arguments.length-2);for(var p=0;p>5==6?2:l>>4==14?3:l>>3==30?4:l>>6==2?-1:-2}function i(l){var h=this.lastTotal-this.lastNeed,g=function(c,v,_){if((192&v[0])!=128)return c.lastNeed=0,"�";if(c.lastNeed>1&&v.length>1){if((192&v[1])!=128)return c.lastNeed=1,"�";if(c.lastNeed>2&&v.length>2&&(192&v[2])!=128)return c.lastNeed=2,"�"}}(this,l);return g!==void 0?g:this.lastNeed<=l.length?(l.copy(this.lastChar,h,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(l.copy(this.lastChar,h,0,l.length),void(this.lastNeed-=l.length))}function e(l,h){if((l.length-h)%2==0){var g=l.toString("utf16le",h);if(g){var c=g.charCodeAt(g.length-1);if(c>=55296&&c<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=l[l.length-2],this.lastChar[1]=l[l.length-1],g.slice(0,-1)}return g}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=l[l.length-1],l.toString("utf16le",h,l.length-1)}function a(l){var h=l&&l.length?this.write(l):"";if(this.lastNeed){var g=this.lastTotal-this.lastNeed;return h+this.lastChar.toString("utf16le",0,g)}return h}function n(l,h){var g=(l.length-h)%3;return g===0?l.toString("base64",h):(this.lastNeed=3-g,this.lastTotal=3,g===1?this.lastChar[0]=l[l.length-1]:(this.lastChar[0]=l[l.length-2],this.lastChar[1]=l[l.length-1]),l.toString("base64",h,l.length-g))}function t(l){var h=l&&l.length?this.write(l):"";return this.lastNeed?h+this.lastChar.toString("base64",0,3-this.lastNeed):h}function o(l){return l.toString(this.encoding)}function f(l){return l&&l.length?this.write(l):""}q.StringDecoder=d,d.prototype.write=function(l){if(l.length===0)return"";var h,g;if(this.lastNeed){if((h=this.fillLast(l))===void 0)return"";g=this.lastNeed,this.lastNeed=0}else g=0;return g=0?(S>0&&(v.lastNeed=S-1),S):--T=0?(S>0&&(v.lastNeed=S-2),S):--T=0?(S>0&&(S===2?S=0:v.lastNeed=S-3),S):0}(this,l,h);if(!this.lastNeed)return l.toString("utf8",h);this.lastTotal=g;var c=l.length-(g-this.lastNeed);return l.copy(this.lastChar,0,c),l.toString("utf8",h,c)},d.prototype.fillLast=function(l){if(this.lastNeed<=l.length)return l.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);l.copy(this.lastChar,this.lastTotal-this.lastNeed,0,l.length),this.lastNeed-=l.length}},{"safe-buffer":73}],76:[function(I,z,q){var w=I("punycode"),p=I("./util");function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}q.parse=_,q.resolve=function(E,T){return _(E,!1,!0).resolve(T)},q.resolveObject=function(E,T){return E?_(E,!1,!0).resolveObject(T):T},q.format=function(E){return p.isString(E)&&(E=_(E)),E instanceof d?E.format():d.prototype.format.call(E)},q.Url=d;var u=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,e=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",` `," "]),n=["'"].concat(a),t=["%","/","?",";","#"].concat(n),o=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,l=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,h={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},c={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=I("querystring");function _(E,T,S){if(E&&p.isObject(E)&&E instanceof d)return E;var F=new d;return F.parse(E,T,S),F}d.prototype.parse=function(E,T,S){if(!p.isString(E))throw new TypeError("Parameter 'url' must be a string, not "+typeof E);var F=E.indexOf("?"),W=F!==-1&&F127?K+="x":K+=V[$];if(!K.match(f)){var r=U.slice(0,M),s=U.slice(M+1),b=V.match(l);b&&(r.push(b[1]),s.unshift(b[2])),s.length&&(y="/"+s.join(".")+y),this.hostname=r.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),O||(this.hostname=w.toASCII(this.hostname));var x=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+x,this.href+=this.host,O&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),y[0]!=="/"&&(y="/"+y))}if(!h[A])for(M=0,H=n.length;M0)&&S.host.split("@"))&&(S.auth=b.shift(),S.host=S.hostname=b.shift())),S.search=E.search,S.query=E.query,p.isNull(S.pathname)&&p.isNull(S.search)||(S.path=(S.pathname?S.pathname:"")+(S.search?S.search:"")),S.href=S.format(),S;if(!V.length)return S.pathname=null,S.search?S.path="/"+S.search:S.path=null,S.href=S.format(),S;for(var $=V.slice(-1)[0],G=(S.host||E.host||V.length>1)&&($==="."||$==="..")||$==="",r=0,s=V.length;s>=0;s--)($=V[s])==="."?V.splice(s,1):$===".."?(V.splice(s,1),r++):r&&(V.splice(s,1),r--);if(!U&&!H)for(;r--;r)V.unshift("..");!U||V[0]===""||V[0]&&V[0].charAt(0)==="/"||V.unshift(""),G&&V.join("/").substr(-1)!=="/"&&V.push("");var b,x=V[0]===""||V[0]&&V[0].charAt(0)==="/";return K&&(S.hostname=S.host=x?"":V.length?V.shift():"",(b=!!(S.host&&S.host.indexOf("@")>0)&&S.host.split("@"))&&(S.auth=b.shift(),S.host=S.hostname=b.shift())),(U=U||S.host&&V.length)&&!x&&V.unshift(""),V.length?S.pathname=V.join("/"):(S.pathname=null,S.path=null),p.isNull(S.pathname)&&p.isNull(S.search)||(S.path=(S.pathname?S.pathname:"")+(S.search?S.search:"")),S.auth=E.auth||S.auth,S.slashes=S.slashes||E.slashes,S.href=S.format(),S},d.prototype.parseHost=function(){var E=this.host,T=i.exec(E);T&&((T=T[0])!==":"&&(this.port=T.substr(1)),E=E.substr(0,E.length-T.length)),E&&(this.hostname=E)}},{"./util":77,punycode:51,querystring:54}],77:[function(I,z,q){z.exports={isString:function(w){return typeof w=="string"},isObject:function(w){return typeof w=="object"&&w!==null},isNull:function(w){return w===null},isNullOrUndefined:function(w){return w==null}}},{}],78:[function(I,z,q){(function(w){(function(){function p(d){try{if(!w.localStorage)return!1}catch(i){return!1}var u=w.localStorage[d];return u!=null&&String(u).toLowerCase()==="true"}z.exports=function(d,u){if(p("noDeprecation"))return d;var i=!1;return function(){if(!i){if(p("throwDeprecation"))throw new Error(u);p("traceDeprecation")?console.trace(u):console.warn(u),i=!0}return d.apply(this,arguments)}}}).call(this)}).call(this,typeof fe!="undefined"?fe:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],79:[function(I,z,q){z.exports=function w(p,d){if(p&&d)return w(p)(d);if(typeof p!="function")throw new TypeError("need wrapper function");return Object.keys(p).forEach(function(i){u[i]=p[i]}),u;function u(){for(var i=new Array(arguments.length),e=0;e0)for(var n=0,t=arguments.length;n1)n=a;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");t=this.head.next,n=this.head.value}for(var o=0;t!==null;o++)n=e(n,t.value,o),t=t.next;return n},w.prototype.reduceReverse=function(e,a){var n,t=this.tail;if(arguments.length>1)n=a;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");t=this.tail.prev,n=this.tail.value}for(var o=this.length-1;t!==null;o--)n=e(n,t.value,o),t=t.prev;return n},w.prototype.toArray=function(){for(var e=new Array(this.length),a=0,n=this.head;n!==null;a++)e[a]=n.value,n=n.next;return e},w.prototype.toArrayReverse=function(){for(var e=new Array(this.length),a=0,n=this.tail;n!==null;a++)e[a]=n.value,n=n.prev;return e},w.prototype.slice=function(e,a){(a=a||this.length)<0&&(a+=this.length),(e=e||0)<0&&(e+=this.length);var n=new w;if(athis.length&&(a=this.length);for(var t=0,o=this.head;o!==null&&tthis.length&&(a=this.length);for(var t=this.length,o=this.tail;o!==null&&t>a;t--)o=o.prev;for(;o!==null&&t>e;t--,o=o.prev)n.push(o.value);return n},w.prototype.splice=function(e,a,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var t=0,o=this.head;o!==null&&t{d.value={connected:!1},a.value=0,e.value="",i.value=!1},t=()=>{if(a.value+=1,a.value>5)try{d.value.end(),n()}catch(v){}},o=()=>{try{e.value="connect";const v=q,{protocol:_,host:E,port:T}=v,S=Te(v,["protocol","host","port"]),F=`${_}://${E}:${T}/mqtt`;d.value=De.connect(F,S),d.value.on&&(d.value.on("connect",()=>{e.value=""}),d.value.on("reconnect",t),d.value.on("error",W=>{}),d.value.on("message",(W,m)=>{u.value=u.value.concat(m.toString())}))}catch(_){e.value=""}},f=()=>{e.value="subscribe";const{topic:v,qos:_}=w.value;d.value.subscribe(v,{qos:_},(E,T)=>{e.value="",!E&&(i.value=!0)})},l=()=>{e.value="unsubscribe";const{topic:v,qos:_}=w.value;d.value.unsubscribe(v,{qos:_},E=>{e.value="",i.value=!1})},h=()=>{e.value="publish";const{topic:v,qos:_,payload:E}=p.value;d.value.publish(v,E,{qos:_},T=>{e.value=""})},g=()=>{if(d.value.connected){e.value="disconnect";try{d.value.end(!1,()=>{n()})}catch(v){e.value=""}}},c=v=>{q.port=v==="wss"?8084:8083};return Ue(()=>{try{d.value.end&&d.value.end()}catch(v){}}),(v,_)=>{const E=ce("el-link"),T=ce("el-option"),S=ce("el-select"),F=ce("el-form-item"),W=ce("el-col"),m=ce("el-input"),y=ce("el-button"),C=ce("el-row"),k=ce("el-form"),A=ce("el-card"),N=ce("el-text");return ge(),_e(A,{shadow:"never","body-style":{padding:"20px"}},{header:ee(()=>[pe("div",null,[_[14]||(_[14]=ae(" 基于 ")),J(E,{type:"primary",underline:!1,href:"https://github.com/mqttjs/MQTT.js",target:"_blank"},{default:ee(()=>_[12]||(_[12]=[ae(" MQTT.js ")])),_:1}),_[15]||(_[15]=ae(" 和 免费的公共MQTT代理 ")),J(E,{type:"primary",underline:!1,href:"broker.emqx.io",target:"_blank"},{default:ee(()=>_[13]||(_[13]=[ae(" EMQX ")])),_:1}),_[16]||(_[16]=ae(" 实现的一套 MQTT 客户端 "))]),J(E,{class:"mt-2",href:"https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/able/mqtt-client.vue",target:"_blank"},{default:ee(()=>_[17]||(_[17]=[ae(" 代码位置 src/views/able/mqtt-client.vue ")])),_:1})]),default:ee(()=>[J(A,{shadow:"never"},{default:ee(()=>[_[19]||(_[19]=pe("h1",null,"设置",-1)),J(k,{"label-position":"top",model:q},{default:ee(()=>[J(C,{gutter:20},{default:ee(()=>[J(W,{span:8},{default:ee(()=>[J(F,{prop:"protocol",label:"协议"},{default:ee(()=>[J(S,{modelValue:q.protocol,"onUpdate:modelValue":_[0]||(_[0]=L=>q.protocol=L),onChange:c},{default:ee(()=>[J(T,{label:"ws://",value:"ws"}),J(T,{label:"wss://",value:"wss"})]),_:1},8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"host",label:"主机"},{default:ee(()=>[J(m,{modelValue:q.host,"onUpdate:modelValue":_[1]||(_[1]=L=>q.host=L)},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"port",label:"端口"},{default:ee(()=>[J(m,{modelValue:q.port,"onUpdate:modelValue":_[2]||(_[2]=L=>q.port=L),modelModifiers:{number:!0},type:"number",placeholder:"8083/8084"},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"clientId",label:"客户端ID"},{default:ee(()=>[J(m,{modelValue:q.clientId,"onUpdate:modelValue":_[3]||(_[3]=L=>q.clientId=L)},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"username",label:"用户名"},{default:ee(()=>[J(m,{modelValue:q.username,"onUpdate:modelValue":_[4]||(_[4]=L=>q.username=L)},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"password",label:"密码"},{default:ee(()=>[J(m,{modelValue:q.password,"onUpdate:modelValue":_[5]||(_[5]=L=>q.password=L)},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:24},{default:ee(()=>[J(y,{type:"primary",disabled:de(d).connected,loading:e.value==="connect",onClick:o},{default:ee(()=>[ae(Ae(de(d).connected?"已连接":"连接"),1)]),_:1},8,["disabled","loading"]),de(d).connected?(ge(),_e(y,{key:0,type:"danger",loading:e.value==="disconnect",onClick:g},{default:ee(()=>_[18]||(_[18]=[ae(" 断开连接 ")])),_:1},8,["loading"])):xe("",!0)]),_:1})]),_:1})]),_:1},8,["model"])]),_:1}),J(A,{shadow:"never",class:"mt-4"},{default:ee(()=>[_[21]||(_[21]=pe("h1",null,"订阅",-1)),J(k,{"label-position":"top",model:w.value},{default:ee(()=>[J(C,{gutter:20,align:"middle"},{default:ee(()=>[J(W,{span:8},{default:ee(()=>[J(F,{prop:"topic",label:"主题"},{default:ee(()=>[J(m,{modelValue:w.value.topic,"onUpdate:modelValue":_[6]||(_[6]=L=>w.value.topic=L),disabled:i.value},null,8,["modelValue","disabled"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"qos",label:"通信质量"},{default:ee(()=>[J(S,{modelValue:w.value.qos,"onUpdate:modelValue":_[7]||(_[7]=L=>w.value.qos=L),disabled:i.value},{default:ee(()=>[(ge(),Ie(Oe,null,Pe(z,L=>J(T,{key:L,label:L,value:L},null,8,["label","value"])),64))]),_:1},8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1}),J(C,null,{default:ee(()=>[J(W,null,{default:ee(()=>[J(y,{type:"primary",class:"sub-btn",loading:e.value==="subscribe",disabled:!de(d).connected||i.value,onClick:f},{default:ee(()=>[ae(Ae(i.value?"已订阅":"订阅"),1)]),_:1},8,["loading","disabled"]),i.value?(ge(),_e(y,{key:0,type:"primary",class:"sub-btn",loading:e.value==="unsubscribe",disabled:!de(d).connected,onClick:l},{default:ee(()=>_[20]||(_[20]=[ae(" 取消订阅 ")])),_:1},8,["loading","disabled"])):xe("",!0)]),_:1})]),_:1})]),_:1},8,["model"])]),_:1}),J(A,{shadow:"never",class:"mt-4"},{default:ee(()=>[_[25]||(_[25]=pe("h1",null,"发布",-1)),J(k,{"label-position":"top",model:p.value},{default:ee(()=>[J(C,{gutter:20},{default:ee(()=>[J(W,{span:8},{default:ee(()=>[J(F,{prop:"topic"},{label:ee(()=>[_[23]||(_[23]=pe("span",null,"主题",-1)),J(N,{type:"info",size:"small"},{default:ee(()=>_[22]||(_[22]=[ae(" 可将订阅主题设置为topic/browser,测试MQTT的自发自收。 ")])),_:1})]),default:ee(()=>[J(m,{modelValue:p.value.topic,"onUpdate:modelValue":_[8]||(_[8]=L=>p.value.topic=L)},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"payload",label:"有效载荷"},{default:ee(()=>[J(m,{modelValue:p.value.payload,"onUpdate:modelValue":_[9]||(_[9]=L=>p.value.payload=L)},null,8,["modelValue"])]),_:1})]),_:1}),J(W,{span:8},{default:ee(()=>[J(F,{prop:"qos",label:"通信质量"},{default:ee(()=>[J(S,{modelValue:p.value.qos,"onUpdate:modelValue":_[10]||(_[10]=L=>p.value.qos=L)},{default:ee(()=>[(ge(),Ie(Oe,null,Pe(z,L=>J(T,{key:L,label:L,value:L},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"]),J(W,{span:24},{default:ee(()=>[J(y,{type:"primary",loading:e.value==="publish",disabled:!de(d).connected,onClick:h},{default:ee(()=>_[24]||(_[24]=[ae(" 发布 ")])),_:1},8,["loading","disabled"])]),_:1})]),_:1}),J(A,{shadow:"never",class:"mt-4"},{default:ee(()=>[_[26]||(_[26]=pe("h1",null,"接收",-1)),J(W,{span:24},{default:ee(()=>[J(m,{modelValue:u.value,"onUpdate:modelValue":_[11]||(_[11]=L=>u.value=L),type:"textarea",rows:3,readonly:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})}}});export{He as default};