mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
32 lines
228 KiB
JavaScript
32 lines
228 KiB
JavaScript
var Au=Object.create;var gr=Object.defineProperty;var Nu=Object.getOwnPropertyDescriptor;var Bu=Object.getOwnPropertyNames;var Mu=Object.getPrototypeOf,qu=Object.prototype.hasOwnProperty;var b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Lu=(e,t)=>{for(var r in t)gr(e,r,{get:t[r],enumerable:!0})},Rs=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Bu(t))!qu.call(e,n)&&n!==r&&gr(e,n,{get:()=>t[n],enumerable:!(i=Nu(t,n))||i.enumerable});return e};var Du=(e,t,r)=>(r=e!=null?Au(Mu(e)):{},Rs(t||!e||!e.__esModule?gr(r,"default",{value:e,enumerable:!0}):r,e)),Uu=e=>Rs(gr({},"__esModule",{value:!0}),e);var br=b((by,Os)=>{Os.exports=Fu;var ju=Object.prototype.hasOwnProperty;function Fu(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)ju.call(r,i)&&(e[i]=r[i])}return e}});var Oi=b((yy,ks)=>{ks.exports=require("stream")});var qs=b((vy,Ms)=>{"use strict";function Ps(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function As(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ps(Object(r),!0).forEach(function(i){Wu(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ps(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Wu(e,t,r){return t=Bs(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ns(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Bs(i.key),i)}}function Vu(e,t,r){return t&&Ns(e.prototype,t),r&&Ns(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Bs(e){var t=$u(e,"string");return typeof t=="symbol"?t:String(t)}function $u(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ku=require("buffer"),yr=Ku.Buffer,Gu=require("util"),ki=Gu.inspect,zu=ki&&ki.custom||"inspect";function Yu(e,t,r){yr.prototype.copy.call(e,t,r)}Ms.exports=function(){function e(){Hu(this,e),this.head=null,this.tail=null,this.length=0}return Vu(e,[{key:"push",value:function(r){var i={data:r,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length}},{key:"unshift",value:function(r){var i={data:r,next:this.head};this.length===0&&(this.tail=i),this.head=i,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var i=this.head,n=""+i.data;i=i.next;)n+=r+i.data;return n}},{key:"concat",value:function(r){if(this.length===0)return yr.alloc(0);for(var i=yr.allocUnsafe(r>>>0),n=this.head,s=0;n;)Yu(n.data,i,s),s+=n.data.length,n=n.next;return i}},{key:"consume",value:function(r,i){var n;return r<this.head.data.length?(n=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?n=this.shift():n=i?this._getString(r):this._getBuffer(r),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var i=this.head,n=1,s=i.data;for(r-=s.length;i=i.next;){var o=i.data,f=r>o.length?o.length:r;if(f===o.length?s+=o:s+=o.slice(0,r),r-=f,r===0){f===o.length?(++n,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=o.slice(f));break}++n}return this.length-=n,s}},{key:"_getBuffer",value:function(r){var i=yr.allocUnsafe(r),n=this.head,s=1;for(n.data.copy(i),r-=n.data.length;n=n.next;){var o=n.data,f=r>o.length?o.length:r;if(o.copy(i,i.length-r,0,f),r-=f,r===0){f===o.length?(++s,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(f));break}++s}return this.length-=s,i}},{key:zu,value:function(r,i){return ki(this,As(As({},i),{},{depth:0,customInspect:!1}))}}]),e}()});var Ai=b((my,Ds)=>{"use strict";function Qu(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return i||n?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(Pi,this,e)):process.nextTick(Pi,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(s){!t&&s?r._writableState?r._writableState.errorEmitted?process.nextTick(vr,r):(r._writableState.errorEmitted=!0,process.nextTick(Ls,r,s)):process.nextTick(Ls,r,s):t?(process.nextTick(vr,r),t(s)):process.nextTick(vr,r)}),this)}function Ls(e,t){Pi(e,t),vr(e)}function vr(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function Ju(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Pi(e,t){e.emit("error",t)}function Xu(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}Ds.exports={destroy:Qu,undestroy:Ju,errorOrDestroy:Xu}});var Be=b((wy,Fs)=>{"use strict";var js={};function ce(e,t,r){r||(r=Error);function i(s,o,f){return typeof t=="string"?t:t(s,o,f)}class n extends r{constructor(o,f,a){super(i(o,f,a))}}n.prototype.name=r.name,n.prototype.code=e,js[e]=n}function Us(e,t){if(Array.isArray(e)){let r=e.length;return e=e.map(i=>String(i)),r>2?`one of ${t} ${e.slice(0,r-1).join(", ")}, or `+e[r-1]:r===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}else return`of ${t} ${String(e)}`}function Zu(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function ec(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function tc(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}ce("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);ce("ERR_INVALID_ARG_TYPE",function(e,t,r){let i;typeof t=="string"&&Zu(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";let n;if(ec(e," argument"))n=`The ${e} ${i} ${Us(t,"type")}`;else{let s=tc(e,".")?"property":"argument";n=`The "${e}" ${s} ${i} ${Us(t,"type")}`}return n+=`. Received type ${typeof r}`,n},TypeError);ce("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");ce("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});ce("ERR_STREAM_PREMATURE_CLOSE","Premature close");ce("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});ce("ERR_MULTIPLE_CALLBACK","Callback called multiple times");ce("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");ce("ERR_STREAM_WRITE_AFTER_END","write after end");ce("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);ce("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);ce("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Fs.exports.codes=js});var Ni=b((Sy,Ws)=>{"use strict";var rc=Be().codes.ERR_INVALID_OPT_VALUE;function ic(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function nc(e,t,r,i){var n=ic(t,i,r);if(n!=null){if(!(isFinite(n)&&Math.floor(n)===n)||n<0){var s=i?r:"highWaterMark";throw new rc(s,n)}return Math.floor(n)}return e.objectMode?16:16*1024}Ws.exports={getHighWaterMark:nc}});var Hs=b((Ey,Bi)=>{typeof Object.create=="function"?Bi.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Bi.exports=function(t,r){if(r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t}}});var ie=b((xy,qi)=>{try{if(Mi=require("util"),typeof Mi.inherits!="function")throw"";qi.exports=Mi.inherits}catch{qi.exports=Hs()}var Mi});var Li=b((Cy,Vs)=>{Vs.exports=require("util").deprecate});var ji=b((Ty,Qs)=>{"use strict";Qs.exports=$;function Ks(e){var t=this;this.next=null,this.entry=null,this.finish=function(){Pc(t,e)}}var lt;$.WritableState=kt;var sc={deprecate:Li()},Gs=Oi(),wr=require("buffer").Buffer,oc=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function ac(e){return wr.from(e)}function fc(e){return wr.isBuffer(e)||e instanceof oc}var Ui=Ai(),lc=Ni(),uc=lc.getHighWaterMark,Me=Be().codes,cc=Me.ERR_INVALID_ARG_TYPE,hc=Me.ERR_METHOD_NOT_IMPLEMENTED,dc=Me.ERR_MULTIPLE_CALLBACK,pc=Me.ERR_STREAM_CANNOT_PIPE,_c=Me.ERR_STREAM_DESTROYED,gc=Me.ERR_STREAM_NULL_VALUES,bc=Me.ERR_STREAM_WRITE_AFTER_END,yc=Me.ERR_UNKNOWN_ENCODING,ut=Ui.errorOrDestroy;ie()($,Gs);function vc(){}function kt(e,t,r){lt=lt||Ye(),e=e||{},typeof r!="boolean"&&(r=t instanceof lt),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=uc(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(n){Tc(t,n)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Ks(this)}kt.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(kt.prototype,"buffer",{get:sc.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var mr;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(mr=Function.prototype[Symbol.hasInstance],Object.defineProperty($,Symbol.hasInstance,{value:function(t){return mr.call(this,t)?!0:this!==$?!1:t&&t._writableState instanceof kt}})):mr=function(t){return t instanceof this};function $(e){lt=lt||Ye();var t=this instanceof lt;if(!t&&!mr.call($,this))return new $(e);this._writableState=new kt(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Gs.call(this)}$.prototype.pipe=function(){ut(this,new pc)};function mc(e,t){var r=new bc;ut(e,r),process.nextTick(t,r)}function wc(e,t,r,i){var n;return r===null?n=new gc:typeof r!="string"&&!t.objectMode&&(n=new cc("chunk",["string","Buffer"],r)),n?(ut(e,n),process.nextTick(i,n),!1):!0}$.prototype.write=function(e,t,r){var i=this._writableState,n=!1,s=!i.objectMode&&fc(e);return s&&!wr.isBuffer(e)&&(e=ac(e)),typeof t=="function"&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=vc),i.ending?mc(this,r):(s||wc(this,i,e,r))&&(i.pendingcb++,n=Ec(this,i,s,e,t,r)),n};$.prototype.cork=function(){this._writableState.corked++};$.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&zs(this,e))};$.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new yc(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty($.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Sc(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=wr.from(t,r)),t}Object.defineProperty($.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Ec(e,t,r,i,n,s){if(!r){var o=Sc(t,i,n);i!==o&&(r=!0,n="buffer",i=o)}var f=t.objectMode?1:i.length;t.length+=f;var a=t.length<t.highWaterMark;if(a||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:s,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Di(e,t,!1,f,i,n,s);return a}function Di(e,t,r,i,n,s,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new _c("write")):r?e._writev(n,t.onwrite):e._write(n,s,t.onwrite),t.sync=!1}function xc(e,t,r,i,n){--t.pendingcb,r?(process.nextTick(n,i),process.nextTick(Ot,e,t),e._writableState.errorEmitted=!0,ut(e,i)):(n(i),e._writableState.errorEmitted=!0,ut(e,i),Ot(e,t))}function Cc(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function Tc(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(typeof n!="function")throw new dc;if(Cc(r),t)xc(e,r,i,t,n);else{var s=Ys(r)||e.destroyed;!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&zs(e,r),i?process.nextTick($s,e,r,s,n):$s(e,r,s,n)}}function $s(e,t,r,i){r||Ic(e,t),t.pendingcb--,i(),Ot(e,t)}function Ic(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function zs(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var o=0,f=!0;r;)n[o]=r,r.isBuf||(f=!1),r=r.next,o+=1;n.allBuffers=f,Di(e,t,!0,t.length,n,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new Ks(t),t.bufferedRequestCount=0}else{for(;r;){var a=r.chunk,l=r.encoding,u=r.callback,h=t.objectMode?1:a.length;if(Di(e,t,!1,h,a,l,u),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}$.prototype._write=function(e,t,r){r(new hc("_write()"))};$.prototype._writev=null;$.prototype.end=function(e,t,r){var i=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||kc(this,i,r),this};Object.defineProperty($.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Ys(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Rc(e,t){e._final(function(r){t.pendingcb--,r&&ut(e,r),t.prefinished=!0,e.emit("prefinish"),Ot(e,t)})}function Oc(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,process.nextTick(Rc,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ot(e,t){var r=Ys(t);if(r&&(Oc(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var i=e._readableState;(!i||i.autoDestroy&&i.endEmitted)&&e.destroy()}return r}function kc(e,t,r){t.ending=!0,Ot(e,t),r&&(t.finished?process.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function Pc(e,t,r){var i=e.entry;for(e.entry=null;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});$.prototype.destroy=Ui.destroy;$.prototype._undestroy=Ui.undestroy;$.prototype._destroy=function(e,t){t(e)}});var Ye=b((Iy,Xs)=>{"use strict";var Ac=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Xs.exports=me;var Js=Hi(),Wi=ji();ie()(me,Js);for(Fi=Ac(Wi.prototype),Sr=0;Sr<Fi.length;Sr++)Er=Fi[Sr],me.prototype[Er]||(me.prototype[Er]=Wi.prototype[Er]);var Fi,Er,Sr;function me(e){if(!(this instanceof me))return new me(e);Js.call(this,e),Wi.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",Nc)))}Object.defineProperty(me.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(me.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(me.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Nc(){this._writableState.ended||process.nextTick(Bc,this)}function Bc(e){e.end()}Object.defineProperty(me.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var to=b((Vi,eo)=>{var xr=require("buffer"),we=xr.Buffer;function Zs(e,t){for(var r in e)t[r]=e[r]}we.from&&we.alloc&&we.allocUnsafe&&we.allocUnsafeSlow?eo.exports=xr:(Zs(xr,Vi),Vi.Buffer=Qe);function Qe(e,t,r){return we(e,t,r)}Qe.prototype=Object.create(we.prototype);Zs(we,Qe);Qe.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return we(e,t,r)};Qe.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=we(e);return t!==void 0?typeof r=="string"?i.fill(t,r):i.fill(t):i.fill(0),i};Qe.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return we(e)};Qe.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return xr.SlowBuffer(e)}});var Gi=b(io=>{"use strict";var Ki=to().Buffer,ro=Ki.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Mc(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function qc(e){var t=Mc(e);if(typeof t!="string"&&(Ki.isEncoding===ro||!ro(e)))throw new Error("Unknown encoding: "+e);return t||e}io.StringDecoder=Pt;function Pt(e){this.encoding=qc(e);var t;switch(this.encoding){case"utf16le":this.text=Wc,this.end=Hc,t=4;break;case"utf8":this.fillLast=Uc,t=4;break;case"base64":this.text=Vc,this.end=$c,t=3;break;default:this.write=Kc,this.end=Gc;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ki.allocUnsafe(t)}Pt.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Pt.prototype.end=Fc;Pt.prototype.text=jc;Pt.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function $i(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Lc(e,t,r){var i=t.length-1;if(i<r)return 0;var n=$i(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||n===-2?0:(n=$i(t[i]),n>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||n===-2?0:(n=$i(t[i]),n>=0?(n>0&&(n===2?n=0:e.lastNeed=n-3),n):0))}function Dc(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function Uc(e){var t=this.lastTotal-this.lastNeed,r=Dc(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function jc(e,t){var r=Lc(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function Fc(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function Wc(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function Hc(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function Vc(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function $c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Kc(e){return e.toString(this.encoding)}function Gc(e){return e&&e.length?this.write(e):""}});var Cr=b((Oy,oo)=>{"use strict";var no=Be().codes.ERR_STREAM_PREMATURE_CLOSE;function zc(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];e.apply(this,i)}}}function Yc(){}function Qc(e){return e.setHeader&&typeof e.abort=="function"}function so(e,t,r){if(typeof t=="function")return so(e,null,t);t||(t={}),r=zc(r||Yc);var i=t.readable||t.readable!==!1&&e.readable,n=t.writable||t.writable!==!1&&e.writable,s=function(){e.writable||f()},o=e._writableState&&e._writableState.finished,f=function(){n=!1,o=!0,i||r.call(e)},a=e._readableState&&e._readableState.endEmitted,l=function(){i=!1,a=!0,n||r.call(e)},u=function(g){r.call(e,g)},h=function(){var g;if(i&&!a)return(!e._readableState||!e._readableState.ended)&&(g=new no),r.call(e,g);if(n&&!o)return(!e._writableState||!e._writableState.ended)&&(g=new no),r.call(e,g)},c=function(){e.req.on("finish",f)};return Qc(e)?(e.on("complete",f),e.on("abort",h),e.req?c():e.on("request",c)):n&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",l),e.on("finish",f),t.error!==!1&&e.on("error",u),e.on("close",h),function(){e.removeListener("complete",f),e.removeListener("abort",h),e.removeListener("request",c),e.req&&e.req.removeListener("finish",f),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",f),e.removeListener("end",l),e.removeListener("error",u),e.removeListener("close",h)}}oo.exports=so});var fo=b((ky,ao)=>{"use strict";var Tr;function qe(e,t,r){return t=Jc(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Jc(e){var t=Xc(e,"string");return typeof t=="symbol"?t:String(t)}function Xc(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Zc=Cr(),Le=Symbol("lastResolve"),Je=Symbol("lastReject"),At=Symbol("error"),Ir=Symbol("ended"),Xe=Symbol("lastPromise"),zi=Symbol("handlePromise"),Ze=Symbol("stream");function De(e,t){return{value:e,done:t}}function eh(e){var t=e[Le];if(t!==null){var r=e[Ze].read();r!==null&&(e[Xe]=null,e[Le]=null,e[Je]=null,t(De(r,!1)))}}function th(e){process.nextTick(eh,e)}function rh(e,t){return function(r,i){e.then(function(){if(t[Ir]){r(De(void 0,!0));return}t[zi](r,i)},i)}}var ih=Object.getPrototypeOf(function(){}),nh=Object.setPrototypeOf((Tr={get stream(){return this[Ze]},next:function(){var t=this,r=this[At];if(r!==null)return Promise.reject(r);if(this[Ir])return Promise.resolve(De(void 0,!0));if(this[Ze].destroyed)return new Promise(function(o,f){process.nextTick(function(){t[At]?f(t[At]):o(De(void 0,!0))})});var i=this[Xe],n;if(i)n=new Promise(rh(i,this));else{var s=this[Ze].read();if(s!==null)return Promise.resolve(De(s,!1));n=new Promise(this[zi])}return this[Xe]=n,n}},qe(Tr,Symbol.asyncIterator,function(){return this}),qe(Tr,"return",function(){var t=this;return new Promise(function(r,i){t[Ze].destroy(null,function(n){if(n){i(n);return}r(De(void 0,!0))})})}),Tr),ih),sh=function(t){var r,i=Object.create(nh,(r={},qe(r,Ze,{value:t,writable:!0}),qe(r,Le,{value:null,writable:!0}),qe(r,Je,{value:null,writable:!0}),qe(r,At,{value:null,writable:!0}),qe(r,Ir,{value:t._readableState.endEmitted,writable:!0}),qe(r,zi,{value:function(s,o){var f=i[Ze].read();f?(i[Xe]=null,i[Le]=null,i[Je]=null,s(De(f,!1))):(i[Le]=s,i[Je]=o)},writable:!0}),r));return i[Xe]=null,Zc(t,function(n){if(n&&n.code!=="ERR_STREAM_PREMATURE_CLOSE"){var s=i[Je];s!==null&&(i[Xe]=null,i[Le]=null,i[Je]=null,s(n)),i[At]=n;return}var o=i[Le];o!==null&&(i[Xe]=null,i[Le]=null,i[Je]=null,o(De(void 0,!0))),i[Ir]=!0}),t.on("readable",th.bind(null,i)),i};ao.exports=sh});var ho=b((Py,co)=>{"use strict";function lo(e,t,r,i,n,s,o){try{var f=e[s](o),a=f.value}catch(l){r(l);return}f.done?t(a):Promise.resolve(a).then(i,n)}function oh(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var s=e.apply(t,r);function o(a){lo(s,i,n,o,f,"next",a)}function f(a){lo(s,i,n,o,f,"throw",a)}o(void 0)})}}function uo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function ah(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?uo(Object(r),!0).forEach(function(i){fh(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uo(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function fh(e,t,r){return t=lh(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function lh(e){var t=uh(e,"string");return typeof t=="symbol"?t:String(t)}function uh(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ch=Be().codes.ERR_INVALID_ARG_TYPE;function hh(e,t,r){var i;if(t&&typeof t.next=="function")i=t;else if(t&&t[Symbol.asyncIterator])i=t[Symbol.asyncIterator]();else if(t&&t[Symbol.iterator])i=t[Symbol.iterator]();else throw new ch("iterable",["Iterable"],t);var n=new e(ah({objectMode:!0},r)),s=!1;n._read=function(){s||(s=!0,o())};function o(){return f.apply(this,arguments)}function f(){return f=oh(function*(){try{var a=yield i.next(),l=a.value,u=a.done;u?n.push(null):n.push(yield l)?o():s=!1}catch(h){n.destroy(h)}}),f.apply(this,arguments)}return n}co.exports=hh});var Hi=b((Ny,Eo)=>{"use strict";Eo.exports=B;var ct;B.ReadableState=bo;var Ay=require("events").EventEmitter,go=function(t,r){return t.listeners(r).length},Bt=Oi(),Rr=require("buffer").Buffer,dh=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function ph(e){return Rr.from(e)}function _h(e){return Rr.isBuffer(e)||e instanceof dh}var Yi=require("util"),P;Yi&&Yi.debuglog?P=Yi.debuglog("stream"):P=function(){};var gh=qs(),rn=Ai(),bh=Ni(),yh=bh.getHighWaterMark,Or=Be().codes,vh=Or.ERR_INVALID_ARG_TYPE,mh=Or.ERR_STREAM_PUSH_AFTER_EOF,wh=Or.ERR_METHOD_NOT_IMPLEMENTED,Sh=Or.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,ht,Qi,Ji;ie()(B,Bt);var Nt=rn.errorOrDestroy,Xi=["error","close","destroy","pause","resume"];function Eh(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function bo(e,t,r){ct=ct||Ye(),e=e||{},typeof r!="boolean"&&(r=t instanceof ct),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=yh(this,e,"readableHighWaterMark",r),this.buffer=new gh,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(ht||(ht=Gi().StringDecoder),this.decoder=new ht(e.encoding),this.encoding=e.encoding)}function B(e){if(ct=ct||Ye(),!(this instanceof B))return new B(e);var t=this instanceof ct;this._readableState=new bo(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Bt.call(this)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});B.prototype.destroy=rn.destroy;B.prototype._undestroy=rn.undestroy;B.prototype._destroy=function(e,t){t(e)};B.prototype.push=function(e,t){var r=this._readableState,i;return r.objectMode?i=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Rr.from(e,t),t=""),i=!0),yo(this,e,t,!1,i)};B.prototype.unshift=function(e){return yo(this,e,null,!0,!1)};function yo(e,t,r,i,n){P("readableAddChunk",t);var s=e._readableState;if(t===null)s.reading=!1,Th(e,s);else{var o;if(n||(o=xh(s,t)),o)Nt(e,o);else if(s.objectMode||t&&t.length>0)if(typeof t!="string"&&!s.objectMode&&Object.getPrototypeOf(t)!==Rr.prototype&&(t=ph(t)),i)s.endEmitted?Nt(e,new Sh):Zi(e,s,t,!0);else if(s.ended)Nt(e,new mh);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||t.length!==0?Zi(e,s,t,!1):tn(e,s)):Zi(e,s,t,!1)}else i||(s.reading=!1,tn(e,s))}return!s.ended&&(s.length<s.highWaterMark||s.length===0)}function Zi(e,t,r,i){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&kr(e)),tn(e,t)}function xh(e,t){var r;return!_h(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new vh("chunk",["string","Buffer","Uint8Array"],t)),r}B.prototype.isPaused=function(){return this._readableState.flowing===!1};B.prototype.setEncoding=function(e){ht||(ht=Gi().StringDecoder);var t=new ht(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";r!==null;)i+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),i!==""&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var po=1073741824;function Ch(e){return e>=po?e=po:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function _o(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=Ch(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}B.prototype.read=function(e){P("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return P("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?en(this):kr(this),null;if(e=_o(e,t),e===0&&t.ended)return t.length===0&&en(this),null;var i=t.needReadable;P("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,P("length less than watermark",i)),t.ended||t.reading?(i=!1,P("reading or ended",i)):i&&(P("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=_o(r,t)));var n;return e>0?n=wo(e,t):n=null,n===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&en(this)),n!==null&&this.emit("data",n),n};function Th(e,t){if(P("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?kr(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,vo(e)))}}function kr(e){var t=e._readableState;P("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(P("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(vo,e))}function vo(e){var t=e._readableState;P("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,nn(e)}function tn(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(Ih,e,t))}function Ih(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(P("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}B.prototype._read=function(e){Nt(this,new wh("_read()"))};B.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,P("pipe count=%d opts=%j",i.pipesCount,t);var n=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,s=n?f:v;i.endEmitted?process.nextTick(s):r.once("end",s),e.on("unpipe",o);function o(m,p){P("onunpipe"),m===r&&p&&p.hasUnpiped===!1&&(p.hasUnpiped=!0,u())}function f(){P("onend"),e.end()}var a=Rh(r);e.on("drain",a);var l=!1;function u(){P("cleanup"),e.removeListener("close",d),e.removeListener("finish",g),e.removeListener("drain",a),e.removeListener("error",c),e.removeListener("unpipe",o),r.removeListener("end",f),r.removeListener("end",v),r.removeListener("data",h),l=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&a()}r.on("data",h);function h(m){P("ondata");var p=e.write(m);P("dest.write",p),p===!1&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&So(i.pipes,e)!==-1)&&!l&&(P("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function c(m){P("onerror",m),v(),e.removeListener("error",c),go(e,"error")===0&&Nt(e,m)}Eh(e,"error",c);function d(){e.removeListener("finish",g),v()}e.once("close",d);function g(){P("onfinish"),e.removeListener("close",d),v()}e.once("finish",g);function v(){P("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(P("pipe resume"),r.resume()),e};function Rh(e){return function(){var r=e._readableState;P("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&go(e,"data")&&(r.flowing=!0,nn(e))}}B.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<n;s++)i[s].emit("unpipe",this,{hasUnpiped:!1});return this}var o=So(t.pipes,e);return o===-1?this:(t.pipes.splice(o,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};B.prototype.on=function(e,t){var r=Bt.prototype.on.call(this,e,t),i=this._readableState;return e==="data"?(i.readableListening=this.listenerCount("readable")>0,i.flowing!==!1&&this.resume()):e==="readable"&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,P("on readable",i.length,i.reading),i.length?kr(this):i.reading||process.nextTick(Oh,this)),r};B.prototype.addListener=B.prototype.on;B.prototype.removeListener=function(e,t){var r=Bt.prototype.removeListener.call(this,e,t);return e==="readable"&&process.nextTick(mo,this),r};B.prototype.removeAllListeners=function(e){var t=Bt.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&process.nextTick(mo,this),t};function mo(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function Oh(e){P("readable nexttick read 0"),e.read(0)}B.prototype.resume=function(){var e=this._readableState;return e.flowing||(P("resume"),e.flowing=!e.readableListening,kh(this,e)),e.paused=!1,this};function kh(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(Ph,e,t))}function Ph(e,t){P("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),nn(e),t.flowing&&!t.reading&&e.read(0)}B.prototype.pause=function(){return P("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(P("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function nn(e){var t=e._readableState;for(P("flow",t.flowing);t.flowing&&e.read()!==null;);}B.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;e.on("end",function(){if(P("wrapped end"),r.decoder&&!r.ended){var o=r.decoder.end();o&&o.length&&t.push(o)}t.push(null)}),e.on("data",function(o){if(P("wrapped data"),r.decoder&&(o=r.decoder.write(o)),!(r.objectMode&&o==null)&&!(!r.objectMode&&(!o||!o.length))){var f=t.push(o);f||(i=!0,e.pause())}});for(var n in e)this[n]===void 0&&typeof e[n]=="function"&&(this[n]=function(f){return function(){return e[f].apply(e,arguments)}}(n));for(var s=0;s<Xi.length;s++)e.on(Xi[s],this.emit.bind(this,Xi[s]));return this._read=function(o){P("wrapped _read",o),i&&(i=!1,e.resume())},this};typeof Symbol=="function"&&(B.prototype[Symbol.asyncIterator]=function(){return Qi===void 0&&(Qi=fo()),Qi(this)});Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});B._fromList=wo;Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function wo(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function en(e){var t=e._readableState;P("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(Ah,t,e))}function Ah(e,t){if(P("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(B.from=function(e,t){return Ji===void 0&&(Ji=ho()),Ji(B,e,t)});function So(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}});var sn=b((By,Co)=>{"use strict";Co.exports=Ce;var Pr=Be().codes,Nh=Pr.ERR_METHOD_NOT_IMPLEMENTED,Bh=Pr.ERR_MULTIPLE_CALLBACK,Mh=Pr.ERR_TRANSFORM_ALREADY_TRANSFORMING,qh=Pr.ERR_TRANSFORM_WITH_LENGTH_0,Ar=Ye();ie()(Ce,Ar);function Lh(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new Bh);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function Ce(e){if(!(this instanceof Ce))return new Ce(e);Ar.call(this,e),this._transformState={afterTransform:Lh.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Dh)}function Dh(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){xo(e,t,r)}):xo(this,null,null)}Ce.prototype.push=function(e,t){return this._transformState.needTransform=!1,Ar.prototype.push.call(this,e,t)};Ce.prototype._transform=function(e,t,r){r(new Nh("_transform()"))};Ce.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}};Ce.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Ce.prototype._destroy=function(e,t){Ar.prototype._destroy.call(this,e,function(r){t(r)})};function xo(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new qh;if(e._transformState.transforming)throw new Mh;return e.push(null)}});var Ro=b((My,Io)=>{"use strict";Io.exports=Mt;var To=sn();ie()(Mt,To);function Mt(e){if(!(this instanceof Mt))return new Mt(e);To.call(this,e)}Mt.prototype._transform=function(e,t,r){r(null,e)}});var No=b((qy,Ao)=>{"use strict";var on;function Uh(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var Po=Be().codes,jh=Po.ERR_MISSING_ARGS,Fh=Po.ERR_STREAM_DESTROYED;function Oo(e){if(e)throw e}function Wh(e){return e.setHeader&&typeof e.abort=="function"}function Hh(e,t,r,i){i=Uh(i);var n=!1;e.on("close",function(){n=!0}),on===void 0&&(on=Cr()),on(e,{readable:t,writable:r},function(o){if(o)return i(o);n=!0,i()});var s=!1;return function(o){if(!n&&!s){if(s=!0,Wh(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();i(o||new Fh("pipe"))}}}function ko(e){e()}function Vh(e,t){return e.pipe(t)}function $h(e){return!e.length||typeof e[e.length-1]!="function"?Oo:e.pop()}function Kh(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=$h(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new jh("streams");var n,s=t.map(function(o,f){var a=f<t.length-1,l=f>0;return Hh(o,a,l,function(u){n||(n=u),u&&s.forEach(ko),!a&&(s.forEach(ko),i(n))})});return t.reduce(Vh)}Ao.exports=Kh});var Ue=b((he,Lt)=>{var qt=require("stream");process.env.READABLE_STREAM==="disable"&&qt?(Lt.exports=qt.Readable,Object.assign(Lt.exports,qt),Lt.exports.Stream=qt):(he=Lt.exports=Hi(),he.Stream=qt||he,he.Readable=he,he.Writable=ji(),he.Duplex=Ye(),he.Transform=sn(),he.PassThrough=Ro(),he.finished=Cr(),he.pipeline=No())});var Nr=b((Ly,Bo)=>{"use strict";var Gh=br(),zh=Ue().Readable,Yh={objectMode:!0},Qh={clean:!0};function je(e){if(!(this instanceof je))return new je(e);this.options=e||{},this.options=Gh(Qh,e),this._inflights=new Map}je.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this};je.prototype.createStream=function(){var e=new zh(Yh),t=!1,r=[],i=0;return this._inflights.forEach(function(n,s){r.push(n)}),e._read=function(){!t&&i<r.length?this.push(r[i++]):this.push(null)},e.destroy=function(){if(!t){var n=this;t=!0,setTimeout(function(){n.emit("close")},0)}},e};je.prototype.del=function(e,t){return e=this._inflights.get(e.messageId),e?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this};je.prototype.get=function(e,t){return e=this._inflights.get(e.messageId),e?t(null,e):t&&t(new Error("missing packet")),this};je.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()};Bo.exports=je});var Lo=b((Dy,qo)=>{"use strict";var{Buffer:ye}=require("buffer"),Mo=Symbol.for("BufferList");function H(e){if(!(this instanceof H))return new H(e);H._init.call(this,e)}H._init=function(t){Object.defineProperty(this,Mo,{value:!0}),this._bufs=[],this.length=0,t&&this.append(t)};H.prototype._new=function(t){return new H(t)};H.prototype._offset=function(t){if(t===0)return[0,0];let r=0;for(let i=0;i<this._bufs.length;i++){let n=r+this._bufs[i].length;if(t<n||i===this._bufs.length-1)return[i,t-r];r=n}};H.prototype._reverseOffset=function(e){let t=e[0],r=e[1];for(let i=0;i<t;i++)r+=this._bufs[i].length;return r};H.prototype.get=function(t){if(t>this.length||t<0)return;let r=this._offset(t);return this._bufs[r[0]][r[1]]};H.prototype.slice=function(t,r){return typeof t=="number"&&t<0&&(t+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,t,r)};H.prototype.copy=function(t,r,i,n){if((typeof i!="number"||i<0)&&(i=0),(typeof n!="number"||n>this.length)&&(n=this.length),i>=this.length||n<=0)return t||ye.alloc(0);let s=!!t,o=this._offset(i),f=n-i,a=f,l=s&&r||0,u=o[1];if(i===0&&n===this.length){if(!s)return this._bufs.length===1?this._bufs[0]:ye.concat(this._bufs,this.length);for(let h=0;h<this._bufs.length;h++)this._bufs[h].copy(t,l),l+=this._bufs[h].length;return t}if(a<=this._bufs[o[0]].length-u)return s?this._bufs[o[0]].copy(t,r,u,u+a):this._bufs[o[0]].slice(u,u+a);s||(t=ye.allocUnsafe(f));for(let h=o[0];h<this._bufs.length;h++){let c=this._bufs[h].length-u;if(a>c)this._bufs[h].copy(t,l,u),l+=c;else{this._bufs[h].copy(t,l,u,u+a),l+=c;break}a-=c,u&&(u=0)}return t.length>l?t.slice(0,l):t};H.prototype.shallowSlice=function(t,r){if(t=t||0,r=typeof r!="number"?this.length:r,t<0&&(t+=this.length),r<0&&(r+=this.length),t===r)return this._new();let i=this._offset(t),n=this._offset(r),s=this._bufs.slice(i[0],n[0]+1);return n[1]===0?s.pop():s[s.length-1]=s[s.length-1].slice(0,n[1]),i[1]!==0&&(s[0]=s[0].slice(i[1])),this._new(s)};H.prototype.toString=function(t,r,i){return this.slice(r,i).toString(t)};H.prototype.consume=function(t){if(t=Math.trunc(t),Number.isNaN(t)||t<=0)return this;for(;this._bufs.length;)if(t>=this._bufs[0].length)t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}return this};H.prototype.duplicate=function(){let t=this._new();for(let r=0;r<this._bufs.length;r++)t.append(this._bufs[r]);return t};H.prototype.append=function(t){if(t==null)return this;if(t.buffer)this._appendBuffer(ye.from(t.buffer,t.byteOffset,t.byteLength));else if(Array.isArray(t))for(let r=0;r<t.length;r++)this.append(t[r]);else if(this._isBufferList(t))for(let r=0;r<t._bufs.length;r++)this.append(t._bufs[r]);else typeof t=="number"&&(t=t.toString()),this._appendBuffer(ye.from(t));return this};H.prototype._appendBuffer=function(t){this._bufs.push(t),this.length+=t.length};H.prototype.indexOf=function(e,t,r){if(r===void 0&&typeof t=="string"&&(r=t,t=void 0),typeof e=="function"||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof e=="number"?e=ye.from([e]):typeof e=="string"?e=ye.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=ye.from(e.buffer,e.byteOffset,e.byteLength):ye.isBuffer(e)||(e=ye.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let i=this._offset(t),n=i[0],s=i[1];for(;n<this._bufs.length;n++){let o=this._bufs[n];for(;s<o.length;)if(o.length-s>=e.length){let a=o.indexOf(e,s);if(a!==-1)return this._reverseOffset([n,a]);s=o.length-e.length+1}else{let a=this._reverseOffset([n,s]);if(this._match(a,e))return a;s++}s=0}return-1};H.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0};(function(){let e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let t in e)(function(r){e[r]===null?H.prototype[r]=function(i,n){return this.slice(i,i+n)[r](0,n)}:H.prototype[r]=function(i=0){return this.slice(i,i+e[r])[r](0)}})(t)})();H.prototype._isBufferList=function(t){return t instanceof H||H.isBufferList(t)};H.isBufferList=function(t){return t!=null&&t[Mo]};qo.exports=H});var Do=b((Uy,Br)=>{"use strict";var an=Ue().Duplex,Jh=ie(),Dt=Lo();function ee(e){if(!(this instanceof ee))return new ee(e);if(typeof e=="function"){this._callback=e;let t=function(i){this._callback&&(this._callback(i),this._callback=null)}.bind(this);this.on("pipe",function(i){i.on("error",t)}),this.on("unpipe",function(i){i.removeListener("error",t)}),e=null}Dt._init.call(this,e),an.call(this)}Jh(ee,an);Object.assign(ee.prototype,Dt.prototype);ee.prototype._new=function(t){return new ee(t)};ee.prototype._write=function(t,r,i){this._appendBuffer(t),typeof i=="function"&&i()};ee.prototype._read=function(t){if(!this.length)return this.push(null);t=Math.min(t,this.length),this.push(this.slice(0,t)),this.consume(t)};ee.prototype.end=function(t){an.prototype.end.call(this,t),this._callback&&(this._callback(null,this.slice()),this._callback=null)};ee.prototype._destroy=function(t,r){this._bufs.length=0,this.length=0,r(t)};ee.prototype._isBufferList=function(t){return t instanceof ee||t instanceof Dt||ee.isBufferList(t)};ee.isBufferList=Dt.isBufferList;Br.exports=ee;Br.exports.BufferListStream=ee;Br.exports.BufferList=Dt});var jo=b((jy,Uo)=>{var fn=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}};Uo.exports=fn});var ln=b((Fy,Fo)=>{var E=Fo.exports;E.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"};E.codes={};for(let e in E.types){let t=E.types[e];E.codes[t]=e}E.CMD_SHIFT=4;E.CMD_MASK=240;E.DUP_MASK=8;E.QOS_MASK=3;E.QOS_SHIFT=1;E.RETAIN_MASK=1;E.VARBYTEINT_MASK=127;E.VARBYTEINT_FIN_MASK=128;E.VARBYTEINT_MAX=268435455;E.SESSIONPRESENT_MASK=1;E.SESSIONPRESENT_HEADER=Buffer.from([E.SESSIONPRESENT_MASK]);E.CONNACK_HEADER=Buffer.from([E.codes.connack<<E.CMD_SHIFT]);E.USERNAME_MASK=128;E.PASSWORD_MASK=64;E.WILL_RETAIN_MASK=32;E.WILL_QOS_MASK=24;E.WILL_QOS_SHIFT=3;E.WILL_FLAG_MASK=4;E.CLEAN_SESSION_MASK=2;E.CONNECT_HEADER=Buffer.from([E.codes.connect<<E.CMD_SHIFT]);E.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11};E.propertiesCodes={};for(let e in E.properties){let t=E.properties[e];E.propertiesCodes[t]=e}E.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"};function Fe(e){return[0,1,2].map(t=>[0,1].map(r=>[0,1].map(i=>{let n=Buffer.alloc(1);return n.writeUInt8(E.codes[e]<<E.CMD_SHIFT|(r?E.DUP_MASK:0)|t<<E.QOS_SHIFT|i,0,!0),n})))}E.PUBLISH_HEADER=Fe("publish");E.SUBSCRIBE_HEADER=Fe("subscribe");E.SUBSCRIBE_OPTIONS_QOS_MASK=3;E.SUBSCRIBE_OPTIONS_NL_MASK=1;E.SUBSCRIBE_OPTIONS_NL_SHIFT=2;E.SUBSCRIBE_OPTIONS_RAP_MASK=1;E.SUBSCRIBE_OPTIONS_RAP_SHIFT=3;E.SUBSCRIBE_OPTIONS_RH_MASK=3;E.SUBSCRIBE_OPTIONS_RH_SHIFT=4;E.SUBSCRIBE_OPTIONS_RH=[0,16,32];E.SUBSCRIBE_OPTIONS_NL=4;E.SUBSCRIBE_OPTIONS_RAP=8;E.SUBSCRIBE_OPTIONS_QOS=[0,1,2];E.UNSUBSCRIBE_HEADER=Fe("unsubscribe");E.ACKS={unsuback:Fe("unsuback"),puback:Fe("puback"),pubcomp:Fe("pubcomp"),pubrel:Fe("pubrel"),pubrec:Fe("pubrec")};E.SUBACK_HEADER=Buffer.from([E.codes.suback<<E.CMD_SHIFT]);E.VERSION3=Buffer.from([3]);E.VERSION4=Buffer.from([4]);E.VERSION5=Buffer.from([5]);E.VERSION131=Buffer.from([131]);E.VERSION132=Buffer.from([132]);E.QOS=[0,1,2].map(e=>Buffer.from([e]));E.EMPTY={pingreq:Buffer.from([E.codes.pingreq<<4,0]),pingresp:Buffer.from([E.codes.pingresp<<4,0]),disconnect:Buffer.from([E.codes.disconnect<<4,0])}});var Ho=b((Wy,Wo)=>{var dt=1e3,pt=dt*60,_t=pt*60,et=_t*24,Xh=et*7,Zh=et*365.25;Wo.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return ed(e);if(r==="number"&&isFinite(e))return t.long?rd(e):td(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ed(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),i=(t[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*Zh;case"weeks":case"week":case"w":return r*Xh;case"days":case"day":case"d":return r*et;case"hours":case"hour":case"hrs":case"hr":case"h":return r*_t;case"minutes":case"minute":case"mins":case"min":case"m":return r*pt;case"seconds":case"second":case"secs":case"sec":case"s":return r*dt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function td(e){var t=Math.abs(e);return t>=et?Math.round(e/et)+"d":t>=_t?Math.round(e/_t)+"h":t>=pt?Math.round(e/pt)+"m":t>=dt?Math.round(e/dt)+"s":e+"ms"}function rd(e){var t=Math.abs(e);return t>=et?Mr(e,t,et,"day"):t>=_t?Mr(e,t,_t,"hour"):t>=pt?Mr(e,t,pt,"minute"):t>=dt?Mr(e,t,dt,"second"):e+" ms"}function Mr(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}});var un=b((Hy,Vo)=>{function id(e){r.debug=r,r.default=r,r.coerce=a,r.disable=s,r.enable=n,r.enabled=o,r.humanize=Ho(),r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let h=0;for(let c=0;c<u.length;c++)h=(h<<5)-h+u.charCodeAt(c),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=t;function r(u){let h,c=null,d,g;function v(...m){if(!v.enabled)return;let p=v,_=Number(new Date),x=_-(h||_);p.diff=x,p.prev=h,p.curr=_,h=_,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let S=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(w,A)=>{if(w==="%%")return"%";S++;let N=r.formatters[A];if(typeof N=="function"){let W=m[S];w=N.call(p,W),m.splice(S,1),S--}return w}),r.formatArgs.call(p,m),(p.log||r.log).apply(p,m)}return v.namespace=u,v.useColors=r.useColors(),v.color=r.selectColor(u),v.extend=i,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(d!==r.namespaces&&(d=r.namespaces,g=r.enabled(u)),g),set:m=>{c=m}}),typeof r.init=="function"&&r.init(v),v}function i(u,h){let c=r(this.namespace+(typeof h>"u"?":":h)+u);return c.log=this.log,c}function n(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let h,c=(typeof u=="string"?u:"").split(/[\s,]+/),d=c.length;for(h=0;h<d;h++)c[h]&&(u=c[h].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.slice(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...r.names.map(f),...r.skips.map(f).map(h=>"-"+h)].join(",");return r.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let h,c;for(h=0,c=r.skips.length;h<c;h++)if(r.skips[h].test(u))return!1;for(h=0,c=r.names.length;h<c;h++)if(r.names[h].test(u))return!0;return!1}function f(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack||u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}Vo.exports=id});var $o=b((ae,qr)=>{ae.formatArgs=sd;ae.save=od;ae.load=ad;ae.useColors=nd;ae.storage=fd();ae.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();ae.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"];function nd(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function sd(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+qr.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(i=r))}),e.splice(i,0,t)}ae.log=console.debug||console.log||(()=>{});function od(e){try{e?ae.storage.setItem("debug",e):ae.storage.removeItem("debug")}catch{}}function ad(){let e;try{e=ae.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function fd(){try{return localStorage}catch{}}qr.exports=un()(ae);var{formatters:ld}=qr.exports;ld.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Go=b((Vy,Ko)=>{"use strict";Ko.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}});var Qo=b(($y,Yo)=>{"use strict";var ud=require("os"),zo=require("tty"),de=Go(),{env:Y}=process,Lr;de("no-color")||de("no-colors")||de("color=false")||de("color=never")?Lr=0:(de("color")||de("colors")||de("color=true")||de("color=always"))&&(Lr=1);function cd(){if("FORCE_COLOR"in Y)return Y.FORCE_COLOR==="true"?1:Y.FORCE_COLOR==="false"?0:Y.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Y.FORCE_COLOR,10),3)}function hd(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function dd(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let i=cd();i!==void 0&&(Lr=i);let n=r?Lr:i;if(n===0)return 0;if(r){if(de("color=16m")||de("color=full")||de("color=truecolor"))return 3;if(de("color=256"))return 2}if(e&&!t&&n===void 0)return 0;let s=n||0;if(Y.TERM==="dumb")return s;if(process.platform==="win32"){let o=ud.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in Y)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in Y)||Y.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in Y)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Y.TEAMCITY_VERSION)?1:0;if(Y.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Y){let o=Number.parseInt((Y.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Y.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Y.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Y.TERM)||"COLORTERM"in Y?1:s}function cn(e,t={}){let r=dd(e,{streamIsTTY:e&&e.isTTY,...t});return hd(r)}Yo.exports={supportsColor:cn,stdout:cn({isTTY:zo.isatty(1)}),stderr:cn({isTTY:zo.isatty(2)})}});var Xo=b((Q,Ur)=>{var pd=require("tty"),Dr=require("util");Q.init=wd;Q.log=yd;Q.formatArgs=gd;Q.save=vd;Q.load=md;Q.useColors=_d;Q.destroy=Dr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Q.colors=[6,2,3,4,5,1];try{let e=Qo();e&&(e.stderr||e).level>=2&&(Q.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}Q.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),i=process.env[t];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),e[r]=i,e},{});function _d(){return"colors"in Q.inspectOpts?!!Q.inspectOpts.colors:pd.isatty(process.stderr.fd)}function gd(e){let{namespace:t,useColors:r}=this;if(r){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),s=` ${n};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
|
|
`).join(`
|
|
`+s),e.push(n+"m+"+Ur.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=bd()+t+" "+e[0]}function bd(){return Q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function yd(...e){return process.stderr.write(Dr.formatWithOptions(Q.inspectOpts,...e)+`
|
|
`)}function vd(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function md(){return process.env.DEBUG}function wd(e){e.inspectOpts={};let t=Object.keys(Q.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=Q.inspectOpts[t[r]]}Ur.exports=un()(Q);var{formatters:Jo}=Ur.exports;Jo.o=function(e){return this.inspectOpts.colors=this.useColors,Dr.inspect(e,this.inspectOpts).split(`
|
|
`).map(t=>t.trim()).join(" ")};Jo.O=function(e){return this.inspectOpts.colors=this.useColors,Dr.inspect(e,this.inspectOpts)}});var We=b((Ky,hn)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?hn.exports=$o():hn.exports=Xo()});var ta=b((Gy,ea)=>{var Sd=Do(),Ed=require("events"),Zo=jo(),j=ln(),I=We()("mqtt-packet:parser"),dn=class e extends Ed{constructor(){super(),this.parser=this.constructor.parser}static parser(t){return this instanceof e?(this.settings=t||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new e().parser(t)}_resetState(){I("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new Zo,this.error=null,this._list=Sd(),this._stateCounter=0}parse(t){for(this.error&&this._resetState(),this._list.append(t),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(){let t=this._list.readUInt8(0);return this.packet.cmd=j.types[t>>j.CMD_SHIFT],this.packet.retain=(t&j.RETAIN_MASK)!==0,this.packet.qos=t>>j.QOS_SHIFT&j.QOS_MASK,this.packet.dup=(t&j.DUP_MASK)!==0,I("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){let t=this._parseVarByteNum(!0);return t&&(this.packet.length=t.value,this._list.consume(t.bytes)),I("_parseLength %d",t.value),!!t}_parsePayload(){I("_parsePayload: payload %O",this._list);let t=!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"))}t=!0}return I("_parsePayload complete result: %s",t),t}_parseConnect(){I("_parseConnect");let t,r,i,n,s={},o=this.packet,f=this._parseString();if(f===null)return this._emitError(new Error("Cannot parse protocolId"));if(f!=="MQTT"&&f!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=f,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=!0,o.protocolVersion=o.protocolVersion-128),o.protocolVersion!==3&&o.protocolVersion!==4&&o.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(s.username=this._list.readUInt8(this._pos)&j.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&j.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&j.WILL_FLAG_MASK,s.will&&(o.will={},o.will.retain=(this._list.readUInt8(this._pos)&j.WILL_RETAIN_MASK)!==0,o.will.qos=(this._list.readUInt8(this._pos)&j.WILL_QOS_MASK)>>j.WILL_QOS_SHIFT),o.clean=(this._list.readUInt8(this._pos)&j.CLEAN_SESSION_MASK)!==0,this._pos++,o.keepalive=this._parseNum(),o.keepalive===-1)return this._emitError(new Error("Packet too short"));if(o.protocolVersion===5){let l=this._parseProperties();Object.getOwnPropertyNames(l).length&&(o.properties=l)}let a=this._parseString();if(a===null)return this._emitError(new Error("Packet too short"));if(o.clientId=a,I("_parseConnect: packet.clientId: %s",o.clientId),s.will){if(o.protocolVersion===5){let l=this._parseProperties();Object.getOwnPropertyNames(l).length&&(o.will.properties=l)}if(t=this._parseString(),t===null)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=t,I("_parseConnect: packet.will.topic: %s",o.will.topic),r=this._parseBuffer(),r===null)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=r,I("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(s.username){if(n=this._parseString(),n===null)return this._emitError(new Error("Cannot parse username"));o.username=n,I("_parseConnect: packet.username: %s",o.username)}if(s.password){if(i=this._parseBuffer(),i===null)return this._emitError(new Error("Cannot parse password"));o.password=i}return this.settings=o,I("_parseConnect: complete"),o}_parseConnack(){I("_parseConnack");let t=this.packet;if(this._list.length<1)return null;if(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&j.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?t.reasonCode=this._list.readUInt8(this._pos++):t.reasonCode=0;else{if(this._list.length<2)return null;t.returnCode=this._list.readUInt8(this._pos++)}if(t.returnCode===-1||t.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(t.properties=r)}I("_parseConnack: complete")}_parsePublish(){I("_parsePublish");let t=this.packet;if(t.topic=this._parseString(),t.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(t.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(t.properties=r)}t.payload=this._list.slice(this._pos,t.length),I("_parsePublish: payload from buffer list: %o",t.payload)}}_parseSubscribe(){I("_parseSubscribe");let t=this.packet,r,i,n,s,o,f,a;if(t.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(t.subscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let l=this._parseProperties();Object.getOwnPropertyNames(l).length&&(t.properties=l)}for(;this._pos<t.length;){if(r=this._parseString(),r===null)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=t.length)return this._emitError(new Error("Malformed Subscribe Payload"));i=this._parseByte(),n=i&j.SUBSCRIBE_OPTIONS_QOS_MASK,f=(i>>j.SUBSCRIBE_OPTIONS_NL_SHIFT&j.SUBSCRIBE_OPTIONS_NL_MASK)!==0,o=(i>>j.SUBSCRIBE_OPTIONS_RAP_SHIFT&j.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,s=i>>j.SUBSCRIBE_OPTIONS_RH_SHIFT&j.SUBSCRIBE_OPTIONS_RH_MASK,a={topic:r,qos:n},this.settings.protocolVersion===5?(a.nl=f,a.rap=o,a.rh=s):this.settings.bridgeMode&&(a.rh=0,a.rap=!0,a.nl=!0),I("_parseSubscribe: push subscription `%s` to subscription",a),t.subscriptions.push(a)}}}_parseSuback(){I("_parseSuback");let t=this.packet;if(this.packet.granted=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(t.properties=r)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){I("_parseUnsubscribe");let t=this.packet;if(t.unsubscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(t.properties=r)}for(;this._pos<t.length;){let r=this._parseString();if(r===null)return this._emitError(new Error("Cannot parse topic"));I("_parseUnsubscribe: push topic `%s` to unsubscriptions",r),t.unsubscriptions.push(r)}}}_parseUnsuback(){I("_parseUnsuback");let t=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(this.settings.protocolVersion===5){let r=this._parseProperties();for(Object.getOwnPropertyNames(r).length&&(t.properties=r),t.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){I("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);let t=this.packet;if(this._parseMessageId(),this.settings.protocolVersion===5&&(t.length>2?(t.reasonCode=this._parseByte(),I("_parseConfirmation: packet.reasonCode `%d`",t.reasonCode)):t.reasonCode=0,t.length>3)){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(t.properties=r)}return!0}_parseDisconnect(){let t=this.packet;if(I("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?t.reasonCode=this._parseByte():t.reasonCode=0;let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(t.properties=r)}return I("_parseDisconnect result: true"),!0}_parseAuth(){I("_parseAuth");let t=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));t.reasonCode=this._parseByte();let r=this._parseProperties();return Object.getOwnPropertyNames(r).length&&(t.properties=r),I("_parseAuth: result: true"),!0}_parseMessageId(){let t=this.packet;return t.messageId=this._parseNum(),t.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(I("_parseMessageId: packet.messageId %d",t.messageId),!0)}_parseString(t){let r=this._parseNum(),i=r+this._pos;if(r===-1||i>this._list.length||i>this.packet.length)return null;let n=this._list.toString("utf8",this._pos,i);return this._pos+=r,I("_parseString: result: %s",n),n}_parseStringPair(){return I("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let t=this._parseNum(),r=t+this._pos;if(t===-1||r>this._list.length||r>this.packet.length)return null;let i=this._list.slice(this._pos,r);return this._pos+=t,I("_parseBuffer: result: %o",i),i}_parseNum(){if(this._list.length-this._pos<2)return-1;let t=this._list.readUInt16BE(this._pos);return this._pos+=2,I("_parseNum: result: %s",t),t}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;let t=this._list.readUInt32BE(this._pos);return this._pos+=4,I("_parse4ByteNum: result: %s",t),t}_parseVarByteNum(t){I("_parseVarByteNum");let r=4,i=0,n=1,s=0,o=!1,f,a=this._pos?this._pos:0;for(;i<r&&a+i<this._list.length;){if(f=this._list.readUInt8(a+i++),s+=n*(f&j.VARBYTEINT_MASK),n*=128,!(f&j.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=i)break}return!o&&i===r&&this._list.length>=i&&this._emitError(new Error("Invalid variable byte integer")),a&&(this._pos+=i),o=o?t?{bytes:i,value:s}:s:!1,I("_parseVarByteNum: result: %o",o),o}_parseByte(){let t;return this._pos<this._list.length&&(t=this._list.readUInt8(this._pos),this._pos++),I("_parseByte: result: %o",t),t}_parseByType(t){switch(I("_parseByType: type: %s",t),t){case"byte":return this._parseByte()!==0;case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){I("_parseProperties");let t=this._parseVarByteNum(),i=this._pos+t,n={};for(;this._pos<i;){let s=this._parseByte();if(!s)return this._emitError(new Error("Cannot parse property code type")),!1;let o=j.propertiesCodes[s];if(!o)return this._emitError(new Error("Unknown property")),!1;if(o==="userProperties"){n[o]||(n[o]=Object.create(null));let f=this._parseByType(j.propertiesTypes[o]);if(n[o][f.name])if(Array.isArray(n[o][f.name]))n[o][f.name].push(f.value);else{let a=n[o][f.name];n[o][f.name]=[a],n[o][f.name].push(f.value)}else n[o][f.name]=f.value;continue}n[o]?Array.isArray(n[o])?n[o].push(this._parseByType(j.propertiesTypes[o])):(n[o]=[n[o]],n[o].push(this._parseByType(j.propertiesTypes[o]))):n[o]=this._parseByType(j.propertiesTypes[o])}return n}_newPacket(){return I("_newPacket"),this.packet&&(this._list.consume(this.packet.length),I("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),I("_newPacket: new packet"),this.packet=new Zo,this._pos=0,!0}_emitError(t){I("_emitError"),this.error=t,this.emit("error",t)}};ea.exports=dn});var sa=b((zy,na)=>{var ra={},xd=Buffer.isBuffer(Buffer.from([1,2]).subarray(0,1));function ia(e){let t=Buffer.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(e&255,1),t}function Cd(){for(let e=0;e<65536;e++)ra[e]=ia(e)}function Td(e){let r=0,i=0,n=Buffer.allocUnsafe(4);do r=e%128|0,e=e/128|0,e>0&&(r=r|128),n.writeUInt8(r,i++);while(e>0&&i<4);return e>0&&(i=0),xd?n.subarray(0,i):n.slice(0,i)}function Id(e){let t=Buffer.allocUnsafe(4);return t.writeUInt32BE(e,0),t}na.exports={cache:ra,generateCache:Cd,generateNumber:ia,genBufVariableByteInt:Td,generate4ByteBuffer:Id}});var gt=b((Yy,pn)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?pn.exports={nextTick:Rd}:pn.exports=process;function Rd(e,t,r,i){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var n=arguments.length,s,o;switch(n){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,r)});case 4:return process.nextTick(function(){e.call(null,t,r,i)});default:for(s=new Array(n-1),o=0;o<s.length;)s[o++]=arguments[o];return process.nextTick(function(){e.apply(null,s)})}}});var bn=b((Qy,da)=>{var O=ln(),Od=Buffer.allocUnsafe(0),kd=Buffer.from([0]),Ut=sa(),Pd=gt().nextTick,pe=We()("mqtt-packet:writeToStream"),jr=Ut.cache,Ad=Ut.generateNumber,Nd=Ut.generateCache,_n=Ut.genBufVariableByteInt,Bd=Ut.generate4ByteBuffer,ne=gn,Fr=!0;function ca(e,t,r){switch(pe("generate called"),t.cork&&(t.cork(),Pd(Md,t)),Fr&&(Fr=!1,Nd()),pe("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return qd(e,t,r);case"connack":return Ld(e,t,r);case"publish":return Dd(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return Ud(e,t,r);case"subscribe":return jd(e,t,r);case"suback":return Fd(e,t,r);case"unsubscribe":return Wd(e,t,r);case"unsuback":return Hd(e,t,r);case"pingreq":case"pingresp":return Vd(e,t,r);case"disconnect":return $d(e,t,r);case"auth":return Kd(e,t,r);default:return t.emit("error",new Error("Unknown command")),!1}}Object.defineProperty(ca,"cacheNumbers",{get(){return ne===gn},set(e){e?((!jr||Object.keys(jr).length===0)&&(Fr=!0),ne=gn):(Fr=!1,ne=Gd)}});function Md(e){e.uncork()}function qd(e,t,r){let i=e||{},n=i.protocolId||"MQTT",s=i.protocolVersion||4,o=i.will,f=i.clean,a=i.keepalive||0,l=i.clientId||"",u=i.username,h=i.password,c=i.properties;f===void 0&&(f=!0);let d=0;if(!n||typeof n!="string"&&!Buffer.isBuffer(n))return t.emit("error",new Error("Invalid protocolId")),!1;if(d+=n.length+2,s!==3&&s!==4&&s!==5)return t.emit("error",new Error("Invalid protocol version")),!1;if(d+=1,(typeof l=="string"||Buffer.isBuffer(l))&&(l||s>=4)&&(l||f))d+=Buffer.byteLength(l)+2;else{if(s<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(f*1===0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof a!="number"||a<0||a>65535||a%1!==0)return t.emit("error",new Error("Invalid keepalive")),!1;if(d+=2,d+=1,s===5){var g=He(t,c);if(!g)return!1;d+=g.length}if(o){if(typeof o!="object")return t.emit("error",new Error("Invalid will")),!1;if(!o.topic||typeof o.topic!="string")return t.emit("error",new Error("Invalid will topic")),!1;if(d+=Buffer.byteLength(o.topic)+2,d+=2,o.payload)if(o.payload.length>=0)typeof o.payload=="string"?d+=Buffer.byteLength(o.payload):d+=o.payload.length;else return t.emit("error",new Error("Invalid will payload")),!1;var v={};if(s===5){if(v=He(t,o.properties),!v)return!1;d+=v.length}}let m=!1;if(u!=null)if(ua(u))m=!0,d+=Buffer.byteLength(u)+2;else return t.emit("error",new Error("Invalid username")),!1;if(h!=null){if(!m)return t.emit("error",new Error("Username is required to use password")),!1;if(ua(h))d+=ha(h)+2;else return t.emit("error",new Error("Invalid password")),!1}t.write(O.CONNECT_HEADER),_e(t,d),bt(t,n),i.bridgeMode&&(s+=128),t.write(s===131?O.VERSION131:s===132?O.VERSION132:s===4?O.VERSION4:s===5?O.VERSION5:O.VERSION3);let p=0;return p|=u!=null?O.USERNAME_MASK:0,p|=h!=null?O.PASSWORD_MASK:0,p|=o&&o.retain?O.WILL_RETAIN_MASK:0,p|=o&&o.qos?o.qos<<O.WILL_QOS_SHIFT:0,p|=o?O.WILL_FLAG_MASK:0,p|=f?O.CLEAN_SESSION_MASK:0,t.write(Buffer.from([p])),ne(t,a),s===5&&g.write(),bt(t,l),o&&(s===5&&v.write(),tt(t,o.topic),bt(t,o.payload)),u!=null&&bt(t,u),h!=null&&bt(t,h),!0}function Ld(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=i===5?n.reasonCode:n.returnCode,o=n.properties,f=2;if(typeof s!="number")return t.emit("error",new Error("Invalid return code")),!1;let a=null;if(i===5){if(a=He(t,o),!a)return!1;f+=a.length}return t.write(O.CONNACK_HEADER),_e(t,f),t.write(n.sessionPresent?O.SESSIONPRESENT_HEADER:kd),t.write(Buffer.from([s])),a?.write(),!0}function Dd(e,t,r){pe("publish: packet: %o",e);let i=r?r.protocolVersion:4,n=e||{},s=n.qos||0,o=n.retain?O.RETAIN_MASK:0,f=n.topic,a=n.payload||Od,l=n.messageId,u=n.properties,h=0;if(typeof f=="string")h+=Buffer.byteLength(f)+2;else if(Buffer.isBuffer(f))h+=f.length+2;else return t.emit("error",new Error("Invalid topic")),!1;if(Buffer.isBuffer(a)?h+=a.length:h+=Buffer.byteLength(a),s&&typeof l!="number")return t.emit("error",new Error("Invalid messageId")),!1;s&&(h+=2);let c=null;if(i===5){if(c=He(t,u),!c)return!1;h+=c.length}return t.write(O.PUBLISH_HEADER[s][n.dup?1:0][o?1:0]),_e(t,h),ne(t,ha(f)),t.write(f),s>0&&ne(t,l),c?.write(),pe("publish: payload: %o",a),t.write(a)}function Ud(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=n.cmd||"puback",o=n.messageId,f=n.dup&&s==="pubrel"?O.DUP_MASK:0,a=0,l=n.reasonCode,u=n.properties,h=i===5?3:2;if(s==="pubrel"&&(a=1),typeof o!="number")return t.emit("error",new Error("Invalid messageId")),!1;let c=null;if(i===5&&typeof u=="object"){if(c=jt(t,u,r,h),!c)return!1;h+=c.length}return t.write(O.ACKS[s][a][f][0]),_e(t,h),ne(t,o),i===5&&t.write(Buffer.from([l])),c!==null&&c.write(),!0}function jd(e,t,r){pe("subscribe: packet: ");let i=r?r.protocolVersion:4,n=e||{},s=n.dup?O.DUP_MASK:0,o=n.messageId,f=n.subscriptions,a=n.properties,l=0;if(typeof o!="number")return t.emit("error",new Error("Invalid messageId")),!1;l+=2;let u=null;if(i===5){if(u=He(t,a),!u)return!1;l+=u.length}if(typeof f=="object"&&f.length)for(let c=0;c<f.length;c+=1){let d=f[c].topic,g=f[c].qos;if(typeof d!="string")return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if(typeof g!="number")return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(i===5){if(typeof(f[c].nl||!1)!="boolean")return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(f[c].rap||!1)!="boolean")return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;let p=f[c].rh||0;if(typeof p!="number"||p>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}l+=Buffer.byteLength(d)+2+1}else return t.emit("error",new Error("Invalid subscriptions")),!1;pe("subscribe: writing to stream: %o",O.SUBSCRIBE_HEADER),t.write(O.SUBSCRIBE_HEADER[1][s?1:0][0]),_e(t,l),ne(t,o),u!==null&&u.write();let h=!0;for(let c of f){let d=c.topic,g=c.qos,v=+c.nl,m=+c.rap,p=c.rh,_;tt(t,d),_=O.SUBSCRIBE_OPTIONS_QOS[g],i===5&&(_|=v?O.SUBSCRIBE_OPTIONS_NL:0,_|=m?O.SUBSCRIBE_OPTIONS_RAP:0,_|=p?O.SUBSCRIBE_OPTIONS_RH[p]:0),h=t.write(Buffer.from([_]))}return h}function Fd(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=n.messageId,o=n.granted,f=n.properties,a=0;if(typeof s!="number")return t.emit("error",new Error("Invalid messageId")),!1;if(a+=2,typeof o=="object"&&o.length)for(let u=0;u<o.length;u+=1){if(typeof o[u]!="number")return t.emit("error",new Error("Invalid qos vector")),!1;a+=1}else return t.emit("error",new Error("Invalid qos vector")),!1;let l=null;if(i===5){if(l=jt(t,f,r,a),!l)return!1;a+=l.length}return t.write(O.SUBACK_HEADER),_e(t,a),ne(t,s),l!==null&&l.write(),t.write(Buffer.from(o))}function Wd(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=n.messageId,o=n.dup?O.DUP_MASK:0,f=n.unsubscriptions,a=n.properties,l=0;if(typeof s!="number")return t.emit("error",new Error("Invalid messageId")),!1;if(l+=2,typeof f=="object"&&f.length)for(let c=0;c<f.length;c+=1){if(typeof f[c]!="string")return t.emit("error",new Error("Invalid unsubscriptions")),!1;l+=Buffer.byteLength(f[c])+2}else return t.emit("error",new Error("Invalid unsubscriptions")),!1;let u=null;if(i===5){if(u=He(t,a),!u)return!1;l+=u.length}t.write(O.UNSUBSCRIBE_HEADER[1][o?1:0][0]),_e(t,l),ne(t,s),u!==null&&u.write();let h=!0;for(let c=0;c<f.length;c++)h=tt(t,f[c]);return h}function Hd(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=n.messageId,o=n.dup?O.DUP_MASK:0,f=n.granted,a=n.properties,l=n.cmd,u=0,h=2;if(typeof s!="number")return t.emit("error",new Error("Invalid messageId")),!1;if(i===5)if(typeof f=="object"&&f.length)for(let d=0;d<f.length;d+=1){if(typeof f[d]!="number")return t.emit("error",new Error("Invalid qos vector")),!1;h+=1}else return t.emit("error",new Error("Invalid qos vector")),!1;let c=null;if(i===5){if(c=jt(t,a,r,h),!c)return!1;h+=c.length}return t.write(O.ACKS[l][u][o][0]),_e(t,h),ne(t,s),c!==null&&c.write(),i===5&&t.write(Buffer.from(f)),!0}function Vd(e,t,r){return t.write(O.EMPTY[e.cmd])}function $d(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=n.reasonCode,o=n.properties,f=i===5?1:0,a=null;if(i===5){if(a=jt(t,o,r,f),!a)return!1;f+=a.length}return t.write(Buffer.from([O.codes.disconnect<<4])),_e(t,f),i===5&&t.write(Buffer.from([s])),a!==null&&a.write(),!0}function Kd(e,t,r){let i=r?r.protocolVersion:4,n=e||{},s=n.reasonCode,o=n.properties,f=i===5?1:0;i!==5&&t.emit("error",new Error("Invalid mqtt version for auth packet"));let a=jt(t,o,r,f);return a?(f+=a.length,t.write(Buffer.from([O.codes.auth<<4])),_e(t,f),t.write(Buffer.from([s])),a!==null&&a.write(),!0):!1}var oa={};function _e(e,t){if(t>O.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let r=oa[t];return r||(r=_n(t),t<16384&&(oa[t]=r)),pe("writeVarByteInt: writing to stream: %o",r),e.write(r)}function tt(e,t){let r=Buffer.byteLength(t);return ne(e,r),pe("writeString: %s",t),e.write(t,"utf8")}function aa(e,t,r){tt(e,t),tt(e,r)}function gn(e,t){return pe("writeNumberCached: number: %d",t),pe("writeNumberCached: %o",jr[t]),e.write(jr[t])}function Gd(e,t){let r=Ad(t);return pe("writeNumberGenerated: %o",r),e.write(r)}function zd(e,t){let r=Bd(t);return pe("write4ByteNumber: %o",r),e.write(r)}function bt(e,t){typeof t=="string"?tt(e,t):t?(ne(e,t.length),e.write(t)):ne(e,0)}function He(e,t){if(typeof t!="object"||t.length!=null)return{length:1,write(){la(e,{},0)}};let r=0;function i(s,o){let f=O.propertiesTypes[s],a=0;switch(f){case"byte":{if(typeof o!="boolean")return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=2;break}case"int8":{if(typeof o!="number"||o<0||o>255)return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=2;break}case"binary":{if(o&&o===null)return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=1+Buffer.byteLength(o)+2;break}case"int16":{if(typeof o!="number"||o<0||o>65535)return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=3;break}case"int32":{if(typeof o!="number"||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=5;break}case"var":{if(typeof o!="number"||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=1+Buffer.byteLength(_n(o));break}case"string":{if(typeof o!="string")return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=3+Buffer.byteLength(o.toString());break}case"pair":{if(typeof o!="object")return e.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;a+=Object.getOwnPropertyNames(o).reduce((l,u)=>{let h=o[u];return Array.isArray(h)?l+=h.reduce((c,d)=>(c+=3+Buffer.byteLength(u.toString())+2+Buffer.byteLength(d.toString()),c),0):l+=3+Buffer.byteLength(u.toString())+2+Buffer.byteLength(o[u].toString()),l},0);break}default:return e.emit("error",new Error(`Invalid property ${s}: ${o}`)),!1}return a}if(t)for(let s in t){let o=0,f=0,a=t[s];if(Array.isArray(a))for(let l=0;l<a.length;l++){if(f=i(s,a[l]),!f)return!1;o+=f}else{if(f=i(s,a),!f)return!1;o=f}if(!o)return!1;r+=o}return{length:Buffer.byteLength(_n(r))+r,write(){la(e,t,r)}}}function jt(e,t,r,i){let n=["reasonString","userProperties"],s=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0,o=He(e,t);if(s)for(;i+o.length>s;){let f=n.shift();if(f&&t[f])delete t[f],o=He(e,t);else return!1}return o}function fa(e,t,r){switch(O.propertiesTypes[t]){case"byte":{e.write(Buffer.from([O.properties[t]])),e.write(Buffer.from([+r]));break}case"int8":{e.write(Buffer.from([O.properties[t]])),e.write(Buffer.from([r]));break}case"binary":{e.write(Buffer.from([O.properties[t]])),bt(e,r);break}case"int16":{e.write(Buffer.from([O.properties[t]])),ne(e,r);break}case"int32":{e.write(Buffer.from([O.properties[t]])),zd(e,r);break}case"var":{e.write(Buffer.from([O.properties[t]])),_e(e,r);break}case"string":{e.write(Buffer.from([O.properties[t]])),tt(e,r);break}case"pair":{Object.getOwnPropertyNames(r).forEach(n=>{let s=r[n];Array.isArray(s)?s.forEach(o=>{e.write(Buffer.from([O.properties[t]])),aa(e,n.toString(),o.toString())}):(e.write(Buffer.from([O.properties[t]])),aa(e,n.toString(),s.toString()))});break}default:return e.emit("error",new Error(`Invalid property ${t} value: ${r}`)),!1}}function la(e,t,r){_e(e,r);for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==null){let n=t[i];if(Array.isArray(n))for(let s=0;s<n.length;s++)fa(e,i,n[s]);else fa(e,i,n)}}function ha(e){return e?e instanceof Buffer?e.length:Buffer.byteLength(e):0}function ua(e){return typeof e=="string"||e instanceof Buffer}da.exports=ca});var _a=b((Jy,pa)=>{var Yd=bn(),Qd=require("events");function Jd(e,t){let r=new yn;return Yd(e,r,t),r.concat()}var yn=class extends Qd{constructor(){super(),this._array=new Array(20),this._i=0}write(t){return this._array[this._i++]=t,!0}concat(){let t=0,r=new Array(this._array.length),i=this._array,n=0,s;for(s=0;s<i.length&&i[s]!==void 0;s++)typeof i[s]!="string"?r[s]=i[s].length:r[s]=Buffer.byteLength(i[s]),t+=r[s];let o=Buffer.allocUnsafe(t);for(s=0;s<i.length&&i[s]!==void 0;s++)typeof i[s]!="string"?(i[s].copy(o,n),n+=r[s]):(o.write(i[s],n),n+=r[s]);return o}};pa.exports=Jd});var ga=b(Wr=>{Wr.parser=ta().parser;Wr.generate=_a();Wr.writeToStream=bn()});var ya=b((Zy,ba)=>{"use strict";function Xd(e,t,r){var i=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(n){n||(n=i._interval),i._interval&&clearInterval(i._interval),i._interval=setInterval(i._callback,n,i._args)},this.clear=function(){i._interval&&(clearInterval(i._interval),i._interval=void 0)},this.destroy=function(){i._interval&&clearInterval(i._interval),i._callback=void 0,i._interval=void 0,i._args=void 0}}function Zd(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new Xd(arguments[0],arguments[1],e)}ba.exports=Zd});var ma=b((ev,va)=>{"use strict";function ep(e){for(var t=e.split("/"),r=0;r<t.length;r++)if(t[r]!=="+"){if(t[r]==="#")return r===t.length-1;if(t[r].indexOf("+")!==-1||t[r].indexOf("#")!==-1)return!1}return!0}function tp(e){if(e.length===0)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!ep(e[t]))return e[t];return null}va.exports={validateTopics:tp}});var wn=b((tv,Ta)=>{"use strict";var Ea=require("events").EventEmitter,Hr=Nr(),xa=ga(),rp=Ue().Writable,ip=ie(),np=ya(),sp=ma(),Vr=br(),y=We()("mqttjs:client"),mn=process?process.nextTick:function(e){setTimeout(e,0)},Ca=global.setImmediate||function(e){mn(e)},wa={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},op=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],vn={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function ap(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function Ft(e,t,r){y("sendPacket :: packet: %O",t),y("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),y("sendPacket :: writing to stream");var i=xa.writeToStream(t,e.stream,e.options);y("sendPacket :: writeToStream result %s",i),!i&&r?(y("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(y("sendPacket :: invoking cb"),r())}function fp(e){e&&(y("flush: queue exists? %b",!!e),Object.keys(e).forEach(function(t){typeof e[t].cb=="function"&&(e[t].cb(new Error("Connection closed")),delete e[t])}))}function lp(e){e&&(y("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach(function(t){e[t].volatile&&typeof e[t].cb=="function"&&(e[t].cb(new Error("Connection closed")),delete e[t])}))}function Sa(e,t,r,i){y("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,function(s){if(s)return r&&r(s);i(),Ft(e,t,r)})}function se(e){y("nop ::",e)}function M(e,t){var r,i=this;if(!(this instanceof M))return new M(e,t);this.options=t||{};for(r in wa)typeof this.options[r]>"u"?this.options[r]=wa[r]:this.options[r]=t[r];y("MqttClient :: options.protocol",t.protocol),y("MqttClient :: options.protocolVersion",t.protocolVersion),y("MqttClient :: options.username",t.username),y("MqttClient :: options.keepalive",t.keepalive),y("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),y("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.options.clientId=typeof t.clientId=="string"?t.clientId:ap(),y("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=t.protocolVersion===5&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.outgoingStore=t.outgoingStore||new Hr,this.incomingStore=t.incomingStore||new Hr,this.queueQoSZero=t.queueQoSZero===void 0?!0:t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this.nextId=Math.max(1,Math.floor(Math.random()*65535)),this.outgoing={},this._firstConnection=!0,this.on("connect",function(){var n=this.queue;function s(){var o=n.shift();y("deliver :: entry %o",o);var f=null;o&&(f=o.packet,y("deliver :: call _sendPacket for %o",f),i._sendPacket(f,function(a){o.cb&&o.cb(a),s()}))}y("connect :: sending queued packets"),s()}),this.on("close",function(){y("close :: connected set to `false`"),this.connected=!1,y("close :: clearing connackTimer"),clearTimeout(this.connackTimer),y("close :: clearing ping timer"),i.pingTimer!==null&&(i.pingTimer.clear(),i.pingTimer=null),y("close :: calling _setupReconnect"),this._setupReconnect()}),Ea.call(this),y("MqttClient :: setting up stream"),this._setupStream()}ip(M,Ea);M.prototype._setupStream=function(){var e,t=this,r=new rp,i=xa.parser(this.options),n=null,s=[];y("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),y("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),i.on("packet",function(u){y("parser :: on packet push to packets array."),s.push(u)});function o(){if(s.length)mn(f);else{var u=n;n=null,u()}}function f(){y("work :: getting next packet in queue");var u=s.shift();if(u)y("work :: packet pulled from queue"),t._handlePacket(u,o);else{y("work :: no packets in queue");var h=n;n=null,y("work :: done flag is %s",!!h),h&&h()}}r._write=function(u,h,c){n=c,y("writable stream :: parsing buffer"),i.parse(u),f()};function a(u){y("streamErrorHandler :: error",u.message),op.includes(u.code)?(y("streamErrorHandler :: emitting error"),t.emit("error",u)):se(u)}if(y("_setupStream :: pipe stream to writable stream"),this.stream.pipe(r),this.stream.on("error",a),this.stream.on("close",function(){y("(%s)stream :: on close",t.options.clientId),lp(t.outgoing),y("stream: emit close to MqttClient"),t.emit("close")}),y("_setupStream: sending packet `connect`"),e=Object.create(this.options),e.cmd="connect",Ft(this,e),i.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"){var l=Vr({cmd:"auth",reasonCode:0},this.options.authPacket);Ft(this,l)}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){y("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)},this.options.connectTimeout)};M.prototype._handlePacket=function(e,t){var r=this.options;if(r.protocolVersion===5&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(y("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t();break;default:break}};M.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting};M.prototype.publish=function(e,t,r,i){y("publish :: message `%s` to topic `%s`",t,e);var n,s=this.options;typeof r=="function"&&(i=r,r=null);var o={qos:0,retain:!1,dup:!1};if(r=Vr(o,r),this._checkDisconnecting(i))return this;switch(n={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:this._nextId(),dup:r.dup},s.protocolVersion===5&&(n.properties=r.properties,(!s.properties&&n.properties&&n.properties.topicAlias||r.properties&&s.properties&&(r.properties.topicAlias&&s.properties.topicAliasMaximum&&r.properties.topicAlias>s.properties.topicAliasMaximum||!s.properties.topicAliasMaximum&&r.properties.topicAlias))&&delete n.properties.topicAlias),y("publish :: qos",r.qos),r.qos){case 1:case 2:this.outgoing[n.messageId]={volatile:!1,cb:i||se},this._storeProcessing?(y("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[n.messageId]=!1,this._storePacket(n,void 0,r.cbStorePut)):(y("MqttClient:publish: packet cmd: %s",n.cmd),this._sendPacket(n,void 0,r.cbStorePut));break;default:this._storeProcessing?(y("_storeProcessing enabled"),this._storePacket(n,i,r.cbStorePut)):(y("MqttClient:publish: packet cmd: %s",n.cmd),this._sendPacket(n,i,r.cbStorePut));break}return this};M.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),r=0;r<arguments.length;r++)t[r]=arguments[r];var i=[],n=t.shift(),s=n.resubscribe,o=t.pop()||se,f=t.pop(),a,l=this,u=this.options.protocolVersion;if(delete n.resubscribe,typeof n=="string"&&(n=[n]),typeof o!="function"&&(f=o,o=se),a=sp.validateTopics(n),a!==null)return Ca(o,new Error("Invalid topic "+a)),this;if(this._checkDisconnecting(o))return y("subscribe: discconecting true"),this;var h={qos:0};if(u===5&&(h.nl=!1,h.rap=!1,h.rh=0),f=Vr(h,f),Array.isArray(n)?n.forEach(function(d){if(y("subscribe: array topic %s",d),!l._resubscribeTopics.hasOwnProperty(d)||l._resubscribeTopics[d].qos<f.qos||s){var g={topic:d,qos:f.qos};u===5&&(g.nl=f.nl,g.rap=f.rap,g.rh=f.rh,g.properties=f.properties),y("subscribe: pushing topic `%s` and qos `%s` to subs list",g.topic,g.qos),i.push(g)}}):Object.keys(n).forEach(function(d){if(y("subscribe: object topic %s",d),!l._resubscribeTopics.hasOwnProperty(d)||l._resubscribeTopics[d].qos<n[d].qos||s){var g={topic:d,qos:n[d].qos};u===5&&(g.nl=n[d].nl,g.rap=n[d].rap,g.rh=n[d].rh,g.properties=f.properties),y("subscribe: pushing `%s` to subs list",g),i.push(g)}}),e={cmd:"subscribe",subscriptions:i,qos:1,retain:!1,dup:!1,messageId:this._nextId()},f.properties&&(e.properties=f.properties),!i.length){o(null,[]);return}if(this.options.resubscribe){y("subscribe :: resubscribe true");var c=[];i.forEach(function(d){if(l.options.reconnectPeriod>0){var g={qos:d.qos};u===5&&(g.nl=d.nl||!1,g.rap=d.rap||!1,g.rh=d.rh||0,g.properties=d.properties),l._resubscribeTopics[d.topic]=g,c.push(d.topic)}}),l.messageIdToTopic[e.messageId]=c}return this.outgoing[e.messageId]={volatile:!0,cb:function(d,g){if(!d)for(var v=g.granted,m=0;m<v.length;m+=1)i[m].qos=v[m];o(d,i)}},y("subscribe :: call _sendPacket"),this._sendPacket(e),this};M.prototype.unsubscribe=function(){for(var e={cmd:"unsubscribe",qos:1,messageId:this._nextId()},t=this,r=new Array(arguments.length),i=0;i<arguments.length;i++)r[i]=arguments[i];var n=r.shift(),s=r.pop()||se,o=r.pop();return typeof n=="string"&&(n=[n]),typeof s!="function"&&(o=s,s=se),this._checkDisconnecting(s)?this:(typeof n=="string"?e.unsubscriptions=[n]:Array.isArray(n)&&(e.unsubscriptions=n),this.options.resubscribe&&e.unsubscriptions.forEach(function(f){delete t._resubscribeTopics[f]}),typeof o=="object"&&o.properties&&(e.properties=o.properties),this.outgoing[e.messageId]={volatile:!0,cb:s},y("unsubscribe: call _sendPacket"),this._sendPacket(e),this)};M.prototype.end=function(e,t,r){var i=this;y("end :: (%s)",this.options.clientId),(e==null||typeof e!="boolean")&&(r=t||se,t=e,e=!1,typeof t!="object"&&(r=t,t=null,typeof r!="function"&&(r=se))),typeof t!="object"&&(r=t,t=null),y("end :: cb? %s",!!r),r=r||se;function n(){y("end :: closeStores: closing incoming and outgoing stores"),i.disconnected=!0,i.incomingStore.close(function(o){i.outgoingStore.close(function(f){if(y("end :: closeStores: emitting end"),i.emit("end"),r){let a=o||f;y("end :: closeStores: invoking callback with args"),r(a)}})}),i._deferredReconnect&&i._deferredReconnect()}function s(){y("end :: (%s) :: finish :: calling _cleanUp with force %s",i.options.clientId,e),i._cleanUp(e,()=>{y("end :: finish :: calling process.nextTick on closeStores"),mn(n.bind(i))},t)}return this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(y("end :: (%s) :: calling finish in 10ms once outgoing is empty",i.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,s,10))):(y("end :: (%s) :: immediately calling finish",i.options.clientId),s()),this)};M.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},function(){t(new Error("Message removed"))}),this};M.prototype.reconnect=function(e){y("client reconnect");var t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new Hr,t.outgoingStore=t.options.outgoingStore||new Hr,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this};M.prototype._reconnect=function(){y("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),y("client already connected. disconnecting first.")):(y("_reconnect: calling _setupStream"),this._setupStream())};M.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(y("_setupReconnect :: emit `offline` state"),this.emit("offline"),y("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),y("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval(function(){y("reconnectTimer :: reconnect triggered!"),e._reconnect()},e.options.reconnectPeriod)):y("_setupReconnect :: doing nothing...")};M.prototype._clearReconnect=function(){y("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)};M.prototype._cleanUp=function(e,t){var r=arguments[2];if(t&&(y("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),y("_cleanUp :: forced? %s",e),e)this.options.reconnectPeriod===0&&this.options.clean&&fp(this.outgoing),y("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var i=Vr({cmd:"disconnect"},r);y("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(i,Ca.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(y("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(y("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(y("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())};M.prototype._sendPacket=function(e,t,r){if(y("_sendPacket :: (%s) :: start",this.options.clientId),r=r||se,!this.connected){y("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(e,t,r);return}switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":Sa(this,e,t,r);return;default:Ft(this,e,t);return}switch(e.qos){case 2:case 1:Sa(this,e,t,r);break;case 0:default:Ft(this,e,t);break}y("_sendPacket :: (%s) :: end",this.options.clientId)};M.prototype._storePacket=function(e,t,r){y("_storePacket :: packet: %o",e),y("_storePacket :: cb? %s",!!t),r=r||se,(e.qos||0)===0&&this.queueQoSZero||e.cmd!=="publish"?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,function(i){if(i)return t&&t(i);r()})):t&&t(new Error("No connection to broker"))};M.prototype._setupPingTimer=function(){y("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=np(function(){e._checkPing()},this.options.keepalive*1e3))};M.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)};M.prototype._checkPing=function(){y("_checkPing :: checking ping..."),this.pingResp?(y("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(y("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))};M.prototype._handlePingresp=function(){this.pingResp=!0};M.prototype._handleConnack=function(e){y("_handleConnack");var t=this.options,r=t.protocolVersion,i=r===5?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=e.properties.topicAliasMaximum),e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)),i===0)this.reconnecting=!1,this._onConnect(e);else if(i>0){var n=new Error("Connection refused: "+vn[i]);n.code=i,this.emit("error",n)}};M.prototype._handlePublish=function(e,t){y("_handlePublish: packet %o",e),t=typeof t<"u"?t:se;var r=e.topic.toString(),i=e.payload,n=e.qos,s=e.messageId,o=this,f=this.options,a=[0,16,128,131,135,144,145,151,153];switch(y("_handlePublish: qos %d",n),n){case 2:{f.customHandleAcks(r,i,e,function(l,u){if(l instanceof Error||(u=l,l=null),l)return o.emit("error",l);if(a.indexOf(u)===-1)return o.emit("error",new Error("Wrong reason code for pubrec"));u?o._sendPacket({cmd:"pubrec",messageId:s,reasonCode:u},t):o.incomingStore.put(e,function(){o._sendPacket({cmd:"pubrec",messageId:s},t)})});break}case 1:{f.customHandleAcks(r,i,e,function(l,u){if(l instanceof Error||(u=l,l=null),l)return o.emit("error",l);if(a.indexOf(u)===-1)return o.emit("error",new Error("Wrong reason code for puback"));u||o.emit("message",r,i,e),o.handleMessage(e,function(h){if(h)return t&&t(h);o._sendPacket({cmd:"puback",messageId:s,reasonCode:u},t)})});break}case 0:this.emit("message",r,i,e),this.handleMessage(e,t);break;default:y("_handlePublish: unknown QoS. Doing nothing.");break}};M.prototype.handleMessage=function(e,t){t()};M.prototype._handleAck=function(e){var t=e.messageId,r=e.cmd,i=null,n=this.outgoing[t]?this.outgoing[t].cb:null,s=this,o;if(!n){y("_handleAck :: Server sent an ack in error. Ignoring.");return}switch(y("_handleAck :: packet type",r),r){case"pubcomp":case"puback":var f=e.reasonCode;f&&f>0&&f!==16&&(o=new Error("Publish error: "+vn[f]),o.code=f,n(o,e)),delete this.outgoing[t],this.outgoingStore.del(e,n);break;case"pubrec":i={cmd:"pubrel",qos:2,messageId:t};var a=e.reasonCode;a&&a>0&&a!==16?(o=new Error("Publish error: "+vn[a]),o.code=a,n(o,e)):this._sendPacket(i);break;case"suback":delete this.outgoing[t];for(var l=0;l<e.granted.length;l++)if(e.granted[l]&128){var u=this.messageIdToTopic[t];u&&u.forEach(function(h){delete s._resubscribeTopics[h]})}n(null,e);break;case"unsuback":delete this.outgoing[t],n(null);break;default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&Object.keys(this.outgoing).length===0&&this.emit("outgoingEmpty")};M.prototype._handlePubrel=function(e,t){y("handling pubrel packet"),t=typeof t<"u"?t:se;var r=e.messageId,i=this,n={cmd:"pubcomp",messageId:r};i.incomingStore.get(e,function(s,o){s?i._sendPacket(n,t):(i.emit("message",o.topic,o.payload,o),i.handleMessage(o,function(f){if(f)return t(f);i.incomingStore.del(o,se),i._sendPacket(n,t)}))})};M.prototype._handleDisconnect=function(e){this.emit("disconnect",e)};M.prototype._nextId=function(){var e=this.nextId++;return this.nextId===65536&&(this.nextId=1),e};M.prototype.getLastMessageId=function(){return this.nextId===1?65535:this.nextId-1};M.prototype._resubscribe=function(e){y("_resubscribe");var t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion===5&&!e.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){y("_resubscribe: protocolVersion 5");for(var r=0;r<t.length;r++){var i={};i[t[r]]=this._resubscribeTopics[t[r]],i.resubscribe=!0,this.subscribe(i,{properties:i[t[r]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1};M.prototype._onConnect=function(e){if(this.disconnected){this.emit("connect",e);return}var t=this;this._setupPingTimer(),this._resubscribe(e),this.connected=!0;function r(){var i=t.outgoingStore.createStream();function n(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}t.once("close",s),i.on("error",function(f){n(),t.removeListener("close",s),t.emit("error",f)});function s(){i.destroy(),i=null,n()}function o(){if(i){t._storeProcessing=!0;var f=i.read(1),a;if(!f){i.once("readable",o);return}if(t._packetIdsDuringStoreProcessing[f.messageId]){o();return}!t.disconnecting&&!t.reconnectTimer?(a=t.outgoing[f.messageId]?t.outgoing[f.messageId].cb:null,t.outgoing[f.messageId]={volatile:!1,cb:function(l,u){a&&a(l,u),o()}},t._packetIdsDuringStoreProcessing[f.messageId]=!0,t._sendPacket(f)):i.destroy&&i.destroy()}}i.on("end",function(){var f=!0;for(var a in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[a]){f=!1;break}f?(n(),t.removeListener("close",s),t.emit("connect",e)):r()}),o()}r()};Ta.exports=M});var Sn=b((rv,Ia)=>{"use strict";var up=require("net"),cp=We()("mqttjs:tcp");function hp(e,t){var r,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",r=t.port,i=t.hostname,cp("port %d and host %s",r,i),up.createConnection(r,i)}Ia.exports=hp});var $r=b((iv,Ra)=>{"use strict";var dp=require("tls"),pp=We()("mqttjs:tls");function _p(e,t){var r;t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.servername=t.host,t.rejectUnauthorized=t.rejectUnauthorized!==!1,delete t.path,pp("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized),r=dp.connect(t),r.on("secureConnect",function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",i)});function i(n){t.rejectUnauthorized&&e.emit("error",n),r.end()}return r.on("error",i),r}Ra.exports=_p});var Pa=b((nv,ka)=>{ka.exports=Oa;function Oa(e,t){if(e&&t)return Oa(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(i){r[i]=e[i]}),r;function r(){for(var i=new Array(arguments.length),n=0;n<i.length;n++)i[n]=arguments[n];var s=e.apply(this,i),o=i[i.length-1];return typeof s=="function"&&s!==o&&Object.keys(o).forEach(function(f){s[f]=o[f]}),s}}});var Ba=b((sv,En)=>{var Aa=Pa();En.exports=Aa(Kr);En.exports.strict=Aa(Na);Kr.proto=Kr(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Kr(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Na(this)},configurable:!0})});function Kr(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Na(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}});var xn=b((ov,qa)=>{var gp=Ba(),bp=function(){},yp=function(e){return e.setHeader&&typeof e.abort=="function"},vp=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3},Ma=function(e,t,r){if(typeof t=="function")return Ma(e,null,t);t||(t={}),r=gp(r||bp);var i=e._writableState,n=e._readableState,s=t.readable||t.readable!==!1&&e.readable,o=t.writable||t.writable!==!1&&e.writable,f=!1,a=function(){e.writable||l()},l=function(){o=!1,s||r.call(e)},u=function(){s=!1,o||r.call(e)},h=function(m){r.call(e,m?new Error("exited with error code: "+m):null)},c=function(m){r.call(e,m)},d=function(){process.nextTick(g)},g=function(){if(!f){if(s&&!(n&&n.ended&&!n.destroyed))return r.call(e,new Error("premature close"));if(o&&!(i&&i.ended&&!i.destroyed))return r.call(e,new Error("premature close"))}},v=function(){e.req.on("finish",l)};return yp(e)?(e.on("complete",l),e.on("abort",d),e.req?v():e.on("request",v)):o&&!i&&(e.on("end",a),e.on("close",a)),vp(e)&&e.on("exit",h),e.on("end",u),e.on("finish",l),t.error!==!1&&e.on("error",c),e.on("close",d),function(){f=!0,e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",v),e.req&&e.req.removeListener("finish",l),e.removeListener("end",a),e.removeListener("close",a),e.removeListener("finish",l),e.removeListener("exit",h),e.removeListener("end",u),e.removeListener("error",c),e.removeListener("close",d)}};qa.exports=Ma});var Cn=b((av,La)=>{La.exports=mp;function mp(e){var t=e._readableState;return t?t.objectMode||typeof e._duplexState=="number"?e.read():e.read(wp(t)):null}function wp(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}});var zr=b((fv,Fa)=>{var Gr=Ue(),Da=xn(),Sp=ie(),Ep=Cn(),Ua=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),Tn=function(e,t){e._corked?e.once("uncork",t):t()},xp=function(e,t){e._autoDestroy&&e.destroy(t)},ja=function(e,t){return function(r){r?xp(e,r.message==="premature close"?null:r):t&&!e._ended&&e.end()}},Cp=function(e,t){if(!e||e._writableState&&e._writableState.finished)return t();if(e._writableState)return e.end(t);e.end(),t()},Tp=function(){},Ip=function(e){return new Gr.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},J=function(e,t,r){if(!(this instanceof J))return new J(e,t,r);Gr.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||r.autoDestroy!==!1,this._forwardDestroy=!r||r.destroy!==!1,this._forwardEnd=!r||r.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};Sp(J,Gr.Duplex);J.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new J(e,t,r)};J.prototype.cork=function(){++this._corked===1&&this.emit("cork")};J.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};J.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.end();return}var t=this,r=Da(e,{writable:!0,readable:!1},ja(this,this._forwardEnd)),i=function(){var s=t._ondrain;t._ondrain=null,s&&s()},n=function(){t._writable.removeListener("drain",i),r()};this._unwrite&&process.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=n,this.uncork()};J.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.push(null),this.resume();return}var t=this,r=Da(e,{writable:!1,readable:!0},ja(this)),i=function(){t._forward()},n=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",i),t._readable2.removeListener("end",n),r()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:Ip(e),this._readable2.on("readable",i),this._readable2.on("end",n),this._unread=s,this._forward()};J.prototype._read=function(){this._drained=!0,this._forward()};J.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var e;this._drained&&(e=Ep(this._readable2))!==null;)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}};J.prototype.destroy=function(e,t){if(t||(t=Tp),this.destroyed)return t(null);this.destroyed=!0;var r=this;process.nextTick(function(){r._destroy(e),t(null)})};J.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")};J.prototype._write=function(e,t,r){if(!this.destroyed){if(this._corked)return Tn(this,this._write.bind(this,e,t,r));if(e===Ua)return this._finish(r);if(!this._writable)return r();this._writable.write(e)===!1?this._ondrain=r:this.destroyed||r()}};J.prototype._finish=function(e){var t=this;this.emit("preend"),Tn(this,function(){Cp(t._forwardEnd&&t._writable,function(){t._writableState.prefinished===!1&&(t._writableState.prefinished=!0),t.emit("prefinish"),Tn(t,e)})})};J.prototype.end=function(e,t,r){return typeof e=="function"?this.end(null,null,e):typeof t=="function"?this.end(e,null,t):(this._ended=!0,e&&this.write(e),!this._writableState.ending&&!this._writableState.destroyed&&this.write(Ua),Gr.Writable.prototype.end.call(this,r))};Fa.exports=J});var In=b((lv,Wa)=>{"use strict";var Rp=Ue().Transform,Op=zr(),Te,Yr,fe;function kp(){var e=new Rp;return e._write=function(t,r,i){Te.send({data:t.buffer,success:function(){i()},fail:function(n){i(new Error(n))}})},e._flush=function(r){Te.close({success:function(){r()}})},e}function Pp(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function Ap(e,t){var r=e.protocol==="wxs"?"wss":"ws",i=r+"://"+e.hostname+e.path;return e.port&&e.port!==80&&e.port!==443&&(i=r+"://"+e.hostname+":"+e.port+e.path),typeof e.transformWsUrl=="function"&&(i=e.transformWsUrl(i,e,t)),i}function Np(){Te.onOpen(function(){fe.setReadable(Yr),fe.setWritable(Yr),fe.emit("connect")}),Te.onMessage(function(e){var t=e.data;t instanceof ArrayBuffer?t=Buffer.from(t):t=Buffer.from(t,"utf8"),Yr.push(t)}),Te.onClose(function(){fe.end(),fe.destroy()}),Te.onError(function(e){fe.destroy(new Error(e.errMsg))})}function Bp(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var r=t.protocolId==="MQIsdp"&&t.protocolVersion===3?"mqttv3.1":"mqtt";Pp(t);var i=Ap(t,e);Te=wx.connectSocket({url:i,protocols:[r]}),Yr=kp(),fe=Op.obj(),fe._destroy=function(s,o){Te.close({success:function(){o&&o(s)}})};var n=fe.destroy;return fe.destroy=function(){fe.destroy=n;var s=this;setTimeout(function(){Te.close({fail:function(){s._destroy(new Error)}})},0)}.bind(fe),Np(),fe}Wa.exports=Bp});var Rn=b((uv,Va)=>{"use strict";var Mp=Ue().Transform,qp=zr(),$e,Wt,Ve,Ha=!1;function Lp(){var e=new Mp;return e._write=function(t,r,i){$e.sendSocketMessage({data:t.buffer,success:function(){i()},fail:function(){i(new Error)}})},e._flush=function(r){$e.closeSocket({success:function(){r()}})},e}function Dp(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function Up(e,t){var r=e.protocol==="alis"?"wss":"ws",i=r+"://"+e.hostname+e.path;return e.port&&e.port!==80&&e.port!==443&&(i=r+"://"+e.hostname+":"+e.port+e.path),typeof e.transformWsUrl=="function"&&(i=e.transformWsUrl(i,e,t)),i}function jp(){Ha||(Ha=!0,$e.onSocketOpen(function(){Ve.setReadable(Wt),Ve.setWritable(Wt),Ve.emit("connect")}),$e.onSocketMessage(function(e){if(typeof e.data=="string"){var t=Buffer.from(e.data,"base64");Wt.push(t)}else{var r=new FileReader;r.addEventListener("load",function(){var i=r.result;i instanceof ArrayBuffer?i=Buffer.from(i):i=Buffer.from(i,"utf8"),Wt.push(i)}),r.readAsArrayBuffer(e.data)}}),$e.onSocketClose(function(){Ve.end(),Ve.destroy()}),$e.onSocketError(function(e){Ve.destroy(e)}))}function Fp(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var r=t.protocolId==="MQIsdp"&&t.protocolVersion===3?"mqttv3.1":"mqtt";Dp(t);var i=Up(t,e);return $e=t.my,$e.connectSocket({url:i,protocols:r}),Wt=Lp(),Ve=qp.obj(),jp(),Ve}Va.exports=Fp});var rt=b((cv,$a)=>{"use strict";$a.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}}});var Ht=b((hv,On)=>{"use strict";var{EMPTY_BUFFER:Wp}=rt();function Ka(e,t){if(e.length===0)return Wp;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),i=0;for(let n=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return i<t?r.slice(0,i):r}function Ga(e,t,r,i,n){for(let s=0;s<n;s++)r[i+s]=e[s]^t[s&3]}function za(e,t){let r=e.length;for(let i=0;i<r;i++)e[i]^=t[i&3]}function Ya(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Qr(e){if(Qr.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=Buffer.from(e):ArrayBuffer.isView(e)?t=Buffer.from(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Qr.readOnly=!1),t}try{let e=require("bufferutil"),t=e.BufferUtil||e;On.exports={concat:Ka,mask(r,i,n,s,o){o<48?Ga(r,i,n,s,o):t.mask(r,i,n,s,o)},toArrayBuffer:Ya,toBuffer:Qr,unmask(r,i){r.length<32?za(r,i):t.unmask(r,i)}}}catch{On.exports={concat:Ka,mask:Ga,toArrayBuffer:Ya,toBuffer:Qr,unmask:za}}});var Xa=b((dv,Ja)=>{"use strict";var Qa=Symbol("kDone"),kn=Symbol("kRun"),Pn=class{constructor(t){this[Qa]=()=>{this.pending--,this[kn]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[kn]()}[kn](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[Qa])}}};Ja.exports=Pn});var Kt=b((pv,rf)=>{"use strict";var Vt=require("zlib"),Za=Ht(),Hp=Xa(),{kStatusCode:ef,NOOP:Vp}=rt(),$p=Buffer.from([0,0,255,255]),Zr=Symbol("permessage-deflate"),Ie=Symbol("total-length"),$t=Symbol("callback"),Ke=Symbol("buffers"),Xr=Symbol("error"),Jr,An=class{constructor(t,r,i){if(this._maxPayload=i|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!Jr){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Jr=new Hp(n)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[$t];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let r=this._options,i=t.find(n=>!(r.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>n.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!n.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(t){let r=t[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(t){return t.forEach(r=>{Object.keys(r).forEach(i=>{let n=r[i];if(n.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(n=n[0],i==="client_max_window_bits"){if(n!==!0){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${i}": ${n}`);n=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${n}`)}else if(i==="server_max_window_bits"){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${i}": ${n}`);n=s}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${n}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=n})}),t}decompress(t,r,i){Jr.add(n=>{this._decompress(t,r,(s,o)=>{n(),i(s,o)})})}compress(t,r,i){Jr.add(n=>{this._compress(t,r,(s,o)=>{n(),i(s,o)})})}_decompress(t,r,i){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Vt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Vt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[Zr]=this,this._inflate[Ie]=0,this._inflate[Ke]=[],this._inflate.on("error",Gp),this._inflate.on("data",tf)}this._inflate[$t]=i,this._inflate.write(t),r&&this._inflate.write($p),this._inflate.flush(()=>{let s=this._inflate[Xr];if(s){this._inflate.close(),this._inflate=null,i(s);return}let o=Za.concat(this._inflate[Ke],this._inflate[Ie]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ie]=0,this._inflate[Ke]=[],r&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),i(null,o)})}_compress(t,r,i){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Vt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Vt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[Ie]=0,this._deflate[Ke]=[],this._deflate.on("error",Vp),this._deflate.on("data",Kp)}this._deflate[$t]=i,this._deflate.write(t),this._deflate.flush(Vt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Za.concat(this._deflate[Ke],this._deflate[Ie]);r&&(s=s.slice(0,s.length-4)),this._deflate[$t]=null,this._deflate[Ie]=0,this._deflate[Ke]=[],r&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),i(null,s)})}};rf.exports=An;function Kp(e){this[Ke].push(e),this[Ie]+=e.length}function tf(e){if(this[Ie]+=e.length,this[Zr]._maxPayload<1||this[Ie]<=this[Zr]._maxPayload){this[Ke].push(e);return}this[Xr]=new RangeError("Max payload size exceeded"),this[Xr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Xr][ef]=1009,this.removeListener("data",tf),this.reset()}function Gp(e){this[Zr]._inflate=null,e[ef]=1007,this[$t](e)}});var Bn=b((_v,Nn)=>{"use strict";function nf(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function sf(e){let t=e.length,r=0;for(;r<t;)if(!(e[r]&128))r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return!1;r+=2}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return!1;r+=3}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return!1;r+=4}else return!1;return!0}try{let e=require("utf-8-validate");typeof e=="object"&&(e=e.Validation.isValidUTF8),Nn.exports={isValidStatusCode:nf,isValidUTF8(t){return t.length<150?sf(t):e(t)}}}catch{Nn.exports={isValidStatusCode:nf,isValidUTF8:sf}}});var Dn=b((gv,cf)=>{"use strict";var{Writable:zp}=require("stream"),of=Kt(),{BINARY_TYPES:Yp,EMPTY_BUFFER:Qp,kStatusCode:Jp,kWebSocket:Xp}=rt(),{concat:Mn,toArrayBuffer:Zp,unmask:e_}=Ht(),{isValidStatusCode:t_,isValidUTF8:af}=Bn(),Gt=0,ff=1,lf=2,uf=3,qn=4,r_=5,Ln=class extends zp{constructor(t,r,i,n){super(),this._binaryType=t||Yp[0],this[Xp]=void 0,this._extensions=r||{},this._isServer=!!i,this._maxPayload=n|0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=Gt,this._loop=!1}_write(t,r,i){if(this._opcode===8&&this._state==Gt)return i();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(i)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=i.slice(t),i.slice(0,t)}let r=Buffer.allocUnsafe(t);do{let i=this._buffers[0],n=r.length-t;t>=i.length?r.set(this._buffers.shift(),n):(r.set(new Uint8Array(i.buffer,i.byteOffset,t),n),this._buffers[0]=i.slice(t)),t-=i.length}while(t>0);return r}startLoop(t){let r;this._loop=!0;do switch(this._state){case Gt:r=this.getInfo();break;case ff:r=this.getPayloadLength16();break;case lf:r=this.getPayloadLength64();break;case uf:this.getMask();break;case qn:r=this.getData(t);break;default:this._loop=!1;return}while(this._loop);t(r)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48)return this._loop=!1,z(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let r=(t[0]&64)===64;if(r&&!this._extensions[of.extensionName])return this._loop=!1,z(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r)return this._loop=!1,z(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,z(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,z(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,z(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(r)return this._loop=!1,z(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,z(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,z(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,z(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,z(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=ff;else if(this._payloadLength===127)this._state=lf;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);return r>Math.pow(2,21)-1?(this._loop=!1,z(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,z(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=uf:this._state=qn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=qn}getData(t){let r=Qp;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&e_(r,this._mask)}if(this._opcode>7)return this.controlMessage(r);if(this._compressed){this._state=r_,this.decompress(r,t);return}return r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage()}decompress(t,r){this._extensions[of.extensionName].decompress(t,this._fin,(n,s)=>{if(n)return r(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return r(z(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}let o=this.dataMessage();if(o)return r(o);this.startLoop(r)})}dataMessage(){if(this._fin){let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Mn(r,t):this._binaryType==="arraybuffer"?i=Zp(Mn(r,t)):i=r,this.emit("message",i)}else{let i=Mn(r,t);if(!af(i))return this._loop=!1,z(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",i.toString())}}this._state=Gt}controlMessage(t){if(this._opcode===8)if(this._loop=!1,t.length===0)this.emit("conclude",1005,""),this.end();else{if(t.length===1)return z(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let r=t.readUInt16BE(0);if(!t_(r))return z(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let i=t.slice(2);if(!af(i))return z(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",r,i.toString()),this.end()}}else this._opcode===9?this.emit("ping",t):this.emit("pong",t);this._state=Gt}};cf.exports=Ln;function z(e,t,r,i,n){let s=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(s,z),s.code=n,s[Jp]=i,s}});var jn=b((vv,pf)=>{"use strict";var bv=require("net"),yv=require("tls"),{randomFillSync:i_}=require("crypto"),hf=Kt(),{EMPTY_BUFFER:n_}=rt(),{isValidStatusCode:s_}=Bn(),{mask:df,toBuffer:Re}=Ht(),it=Buffer.alloc(4),Un=class e{constructor(t,r){this._extensions=r||{},this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(t,r){let i=r.mask&&r.readOnly,n=r.mask?6:2,s=t.length;t.length>=65536?(n+=8,s=127):t.length>125&&(n+=2,s=126);let o=Buffer.allocUnsafe(i?t.length+n:n);return o[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(o[0]|=64),o[1]=s,s===126?o.writeUInt16BE(t.length,2):s===127&&(o.writeUInt32BE(0,2),o.writeUInt32BE(t.length,6)),r.mask?(i_(it,0,4),o[1]|=128,o[n-4]=it[0],o[n-3]=it[1],o[n-2]=it[2],o[n-1]=it[3],i?(df(t,it,o,n,t.length),[o]):(df(t,it,t,0,t.length),[o,t])):[o,t]}close(t,r,i,n){let s;if(t===void 0)s=n_;else{if(typeof t!="number"||!s_(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||r==="")s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else{let o=Buffer.byteLength(r);if(o>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+o),s.writeUInt16BE(t,0),s.write(r,2)}}this._deflating?this.enqueue([this.doClose,s,i,n]):this.doClose(s,i,n)}doClose(t,r,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:8,mask:r,readOnly:!1}),i)}ping(t,r,i){let n=Re(t);if(n.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,n,r,Re.readOnly,i]):this.doPing(n,r,Re.readOnly,i)}doPing(t,r,i,n){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:9,mask:r,readOnly:i}),n)}pong(t,r,i){let n=Re(t);if(n.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,n,r,Re.readOnly,i]):this.doPong(n,r,Re.readOnly,i)}doPong(t,r,i,n){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:10,mask:r,readOnly:i}),n)}send(t,r,i){let n=Re(t),s=this._extensions[hf.extensionName],o=r.binary?2:1,f=r.compress;if(this._firstFragment?(this._firstFragment=!1,f&&s&&(f=n.length>=s._threshold),this._compress=f):(f=!1,o=0),r.fin&&(this._firstFragment=!0),s){let a={fin:r.fin,rsv1:f,opcode:o,mask:r.mask,readOnly:Re.readOnly};this._deflating?this.enqueue([this.dispatch,n,this._compress,a,i]):this.dispatch(n,this._compress,a,i)}else this.sendFrame(e.frame(n,{fin:r.fin,rsv1:!1,opcode:o,mask:r.mask,readOnly:Re.readOnly}),i)}dispatch(t,r,i,n){if(!r){this.sendFrame(e.frame(t,i),n);return}let s=this._extensions[hf.extensionName];this._bufferedBytes+=t.length,this._deflating=!0,s.compress(t,i.fin,(o,f)=>{if(this._socket.destroyed){let a=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(a);for(let l=0;l<this._queue.length;l++){let u=this._queue[l][4];typeof u=="function"&&u(a)}return}this._bufferedBytes-=t.length,this._deflating=!1,i.readOnly=!1,this.sendFrame(e.frame(f,i),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[1].length,Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[1].length,this._queue.push(t)}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r)}};pf.exports=Un});var gf=b((mv,_f)=>{"use strict";var yt=class{constructor(t,r){this.target=r,this.type=t}},Fn=class extends yt{constructor(t,r){super("message",r),this.data=t}},Wn=class extends yt{constructor(t,r,i){super("close",i),this.wasClean=i._closeFrameReceived&&i._closeFrameSent,this.reason=r,this.code=t}},Hn=class extends yt{constructor(t){super("open",t)}},Vn=class extends yt{constructor(t,r){super("error",r),this.message=t.message,this.error=t}},o_={addEventListener(e,t,r){if(typeof t!="function")return;function i(a){t.call(this,new Fn(a,this))}function n(a,l){t.call(this,new Wn(a,l,this))}function s(a){t.call(this,new Vn(a,this))}function o(){t.call(this,new Hn(this))}let f=r&&r.once?"once":"on";e==="message"?(i._listener=t,this[f](e,i)):e==="close"?(n._listener=t,this[f](e,n)):e==="error"?(s._listener=t,this[f](e,s)):e==="open"?(o._listener=t,this[f](e,o)):this[f](e,t)},removeEventListener(e,t){let r=this.listeners(e);for(let i=0;i<r.length;i++)(r[i]===t||r[i]._listener===t)&&this.removeListener(e,r[i])}};_f.exports=o_});var $n=b((wv,bf)=>{"use strict";var zt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Se(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}function a_(e){let t=Object.create(null);if(e===void 0||e==="")return t;let r=Object.create(null),i=!1,n=!1,s=!1,o,f,a=-1,l=-1,u=0;for(;u<e.length;u++){let c=e.charCodeAt(u);if(o===void 0)if(l===-1&&zt[c]===1)a===-1&&(a=u);else if(c===32||c===9)l===-1&&a!==-1&&(l=u);else if(c===59||c===44){if(a===-1)throw new SyntaxError(`Unexpected character at index ${u}`);l===-1&&(l=u);let d=e.slice(a,l);c===44?(Se(t,d,r),r=Object.create(null)):o=d,a=l=-1}else throw new SyntaxError(`Unexpected character at index ${u}`);else if(f===void 0)if(l===-1&&zt[c]===1)a===-1&&(a=u);else if(c===32||c===9)l===-1&&a!==-1&&(l=u);else if(c===59||c===44){if(a===-1)throw new SyntaxError(`Unexpected character at index ${u}`);l===-1&&(l=u),Se(r,e.slice(a,l),!0),c===44&&(Se(t,o,r),r=Object.create(null),o=void 0),a=l=-1}else if(c===61&&a!==-1&&l===-1)f=e.slice(a,u),a=l=-1;else throw new SyntaxError(`Unexpected character at index ${u}`);else if(n){if(zt[c]!==1)throw new SyntaxError(`Unexpected character at index ${u}`);a===-1?a=u:i||(i=!0),n=!1}else if(s)if(zt[c]===1)a===-1&&(a=u);else if(c===34&&a!==-1)s=!1,l=u;else if(c===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${u}`);else if(c===34&&e.charCodeAt(u-1)===61)s=!0;else if(l===-1&&zt[c]===1)a===-1&&(a=u);else if(a!==-1&&(c===32||c===9))l===-1&&(l=u);else if(c===59||c===44){if(a===-1)throw new SyntaxError(`Unexpected character at index ${u}`);l===-1&&(l=u);let d=e.slice(a,l);i&&(d=d.replace(/\\/g,""),i=!1),Se(r,f,d),c===44&&(Se(t,o,r),r=Object.create(null),o=void 0),f=void 0,a=l=-1}else throw new SyntaxError(`Unexpected character at index ${u}`)}if(a===-1||s)throw new SyntaxError("Unexpected end of input");l===-1&&(l=u);let h=e.slice(a,l);return o===void 0?Se(t,h,r):(f===void 0?Se(r,h,!0):i?Se(r,f,h.replace(/\\/g,"")):Se(r,f,h),Se(t,o,r)),t}function f_(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(i=>[t].concat(Object.keys(i).map(n=>{let s=i[n];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?n:`${n}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bf.exports={format:f_,parse:a_}});var Jn=b((Ev,If)=>{"use strict";var l_=require("events"),u_=require("https"),c_=require("http"),mf=require("net"),h_=require("tls"),{randomBytes:d_,createHash:p_}=require("crypto"),{Readable:Sv}=require("stream"),{URL:Kn}=require("url"),Ge=Kt(),__=Dn(),g_=jn(),{BINARY_TYPES:yf,EMPTY_BUFFER:Gn,GUID:b_,kStatusCode:y_,kWebSocket:te,NOOP:wf}=rt(),{addEventListener:v_,removeEventListener:m_}=gf(),{format:w_,parse:S_}=$n(),{toBuffer:E_}=Ht(),Oe=["CONNECTING","OPEN","CLOSING","CLOSED"],zn=[8,13],x_=30*1e3,K=class e extends l_{constructor(t,r,i){super(),this._binaryType=yf[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(r)?r=r.join(", "):typeof r=="object"&&r!==null&&(i=r,r=void 0),Sf(this,t,r,i)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(t){yf.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(t){}get onerror(){}set onerror(t){}get onopen(){}set onopen(t){}get onmessage(){}set onmessage(t){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,r,i){let n=new __(this.binaryType,this._extensions,this._isServer,i);this._sender=new g_(t,this._extensions),this._receiver=n,this._socket=t,n[te]=this,t[te]=this,n.on("conclude",I_),n.on("drain",R_),n.on("error",O_),n.on("message",k_),n.on("ping",P_),n.on("pong",A_),t.setTimeout(0),t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",xf),t.on("data",ei),t.on("end",Cf),t.on("error",Tf),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ge.extensionName]&&this._extensions[Ge.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING)return le(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),x_)}}ping(t,r,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Qn(this,t,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||Gn,r,i)}pong(t,r,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Qn(this,t,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||Gn,r,i)}send(t,r,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Qn(this,t,i);return}let n={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Ge.extensionName]||(n.compress=!1),this._sender.send(t||Gn,n,i)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING)return le(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(K,"CONNECTING",{enumerable:!0,value:Oe.indexOf("CONNECTING")});Object.defineProperty(K.prototype,"CONNECTING",{enumerable:!0,value:Oe.indexOf("CONNECTING")});Object.defineProperty(K,"OPEN",{enumerable:!0,value:Oe.indexOf("OPEN")});Object.defineProperty(K.prototype,"OPEN",{enumerable:!0,value:Oe.indexOf("OPEN")});Object.defineProperty(K,"CLOSING",{enumerable:!0,value:Oe.indexOf("CLOSING")});Object.defineProperty(K.prototype,"CLOSING",{enumerable:!0,value:Oe.indexOf("CLOSING")});Object.defineProperty(K,"CLOSED",{enumerable:!0,value:Oe.indexOf("CLOSED")});Object.defineProperty(K.prototype,"CLOSED",{enumerable:!0,value:Oe.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(e=>{Object.defineProperty(K.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(K.prototype,`on${e}`,{enumerable:!0,get(){let t=this.listeners(e);for(let r=0;r<t.length;r++)if(t[r]._listener)return t[r]._listener},set(t){let r=this.listeners(e);for(let i=0;i<r.length;i++)r[i]._listener&&this.removeListener(e,r[i]);this.addEventListener(e,t)}})});K.prototype.addEventListener=v_;K.prototype.removeEventListener=m_;If.exports=K;function Sf(e,t,r,i){let n={protocolVersion:zn[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0};if(!zn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${zn.join(", ")})`);let s;t instanceof Kn?(s=t,e._url=t.href):(s=new Kn(t),e._url=t);let o=s.protocol==="ws+unix:";if(!s.host&&(!o||!s.pathname)){let d=new Error(`Invalid URL: ${e.url}`);if(e._redirects===0)throw d;Yn(e,d);return}let f=s.protocol==="wss:"||s.protocol==="https:",a=f?443:80,l=d_(16).toString("base64"),u=f?u_.get:c_.get,h;if(n.createConnection=f?T_:C_,n.defaultPort=n.defaultPort||a,n.port=s.port||a,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers={"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket",...n.headers},n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(h=new Ge(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=w_({[Ge.extensionName]:h.offer()})),r&&(n.headers["Sec-WebSocket-Protocol"]=r),n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),o){let d=n.path.split(":");n.socketPath=d[0],n.path=d[1]}if(n.followRedirects){if(e._redirects===0){e._originalUnixSocket=o,e._originalSecure=f,e._originalHostOrSocketPath=o?n.socketPath:s.host;let d=i&&i.headers;if(i={...i,headers:{}},d)for(let[g,v]of Object.entries(d))i.headers[g.toLowerCase()]=v}else{let d=o?e._originalUnixSocket?n.socketPath===e._originalHostOrSocketPath:!1:e._originalUnixSocket?!1:s.host===e._originalHostOrSocketPath;(!d||e._originalSecure&&!f)&&(delete n.headers.authorization,delete n.headers.cookie,d||delete n.headers.host,n.auth=void 0)}n.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64"))}let c=e._req=u(n);n.timeout&&c.on("timeout",()=>{le(e,c,"Opening handshake has timed out")}),c.on("error",d=>{c===null||c.aborted||(c=e._req=null,Yn(e,d))}),c.on("response",d=>{let g=d.headers.location,v=d.statusCode;if(g&&n.followRedirects&&v>=300&&v<400){if(++e._redirects>n.maxRedirects){le(e,c,"Maximum redirects exceeded");return}c.abort();let m;try{m=new Kn(g,t)}catch(p){Yn(e,p);return}Sf(e,m,r,i)}else e.emit("unexpected-response",c,d)||le(e,c,`Unexpected server response: ${d.statusCode}`)}),c.on("upgrade",(d,g,v)=>{if(e.emit("upgrade",d),e.readyState!==K.CONNECTING)return;c=e._req=null;let m=d.headers.upgrade;if(m===void 0||m.toLowerCase()!=="websocket"){le(e,g,"Invalid Upgrade header");return}let p=p_("sha1").update(l+b_).digest("base64");if(d.headers["sec-websocket-accept"]!==p){le(e,g,"Invalid Sec-WebSocket-Accept header");return}let _=d.headers["sec-websocket-protocol"],x=(r||"").split(/, */),S;if(!r&&_?S="Server sent a subprotocol but none was requested":r&&!_?S="Server sent no subprotocol":_&&!x.includes(_)&&(S="Server sent an invalid subprotocol"),S){le(e,g,S);return}_&&(e._protocol=_);let C=d.headers["sec-websocket-extensions"];if(C!==void 0){if(!h){le(e,g,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let w;try{w=S_(C)}catch{le(e,g,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(w);if(A.length){if(A.length!==1||A[0]!==Ge.extensionName){le(e,g,"Server indicated an extension that was not requested");return}try{h.accept(w[Ge.extensionName])}catch{le(e,g,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Ge.extensionName]=h}}e.setSocket(g,v,n.maxPayload)})}function Yn(e,t){e._readyState=K.CLOSING,e.emit("error",t),e.emitClose()}function C_(e){return e.path=e.socketPath,mf.connect(e)}function T_(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=mf.isIP(e.host)?"":e.host),h_.connect(e)}function le(e,t,r){e._readyState=K.CLOSING;let i=new Error(r);Error.captureStackTrace(i,le),t.setHeader?(t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),t.once("abort",e.emitClose.bind(e)),e.emit("error",i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Qn(e,t,r){if(t){let i=E_(t).length;e._socket?e._sender._bufferedBytes+=i:e._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${e.readyState} (${Oe[e.readyState]})`);r(i)}}function I_(e,t){let r=this[te];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[te]!==void 0&&(r._socket.removeListener("data",ei),process.nextTick(Ef,r._socket),e===1005?r.close():r.close(e,t))}function R_(){this[te]._socket.resume()}function O_(e){let t=this[te];t._socket[te]!==void 0&&(t._socket.removeListener("data",ei),process.nextTick(Ef,t._socket),t.close(e[y_])),t.emit("error",e)}function vf(){this[te].emitClose()}function k_(e){this[te].emit("message",e)}function P_(e){let t=this[te];t.pong(e,!t._isServer,wf),t.emit("ping",e)}function A_(e){this[te].emit("pong",e)}function Ef(e){e.resume()}function xf(){let e=this[te];this.removeListener("close",xf),this.removeListener("data",ei),this.removeListener("end",Cf),e._readyState=K.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[te]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",vf),e._receiver.on("finish",vf))}function ei(e){this[te]._receiver.write(e)||this.pause()}function Cf(){let e=this[te];e._readyState=K.CLOSING,e._receiver.end(),this.end()}function Tf(){let e=this[te];this.removeListener("error",Tf),this.on("error",wf),e&&(e._readyState=K.CLOSING,this.destroy())}});var Pf=b((xv,kf)=>{"use strict";var{Duplex:N_}=require("stream");function Rf(e){e.emit("close")}function B_(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Of(e){this.removeListener("error",Of),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function M_(e,t){let r=!0,i=!0;function n(){r&&e._socket.resume()}e.readyState===e.CONNECTING?e.once("open",function(){e._receiver.removeAllListeners("drain"),e._receiver.on("drain",n)}):(e._receiver.removeAllListeners("drain"),e._receiver.on("drain",n));let s=new N_({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(f){s.push(f)||(r=!1,e._socket.pause())}),e.once("error",function(f){s.destroyed||(i=!1,s.destroy(f))}),e.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(o,f){if(e.readyState===e.CLOSED){f(o),process.nextTick(Rf,s);return}let a=!1;e.once("error",function(u){a=!0,f(u)}),e.once("close",function(){a||f(o),process.nextTick(Rf,s)}),i&&e.terminate()},s._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",function(){s._final(o)});return}e._socket!==null&&(e._socket._writableState.finished?(o(),s._readableState.endEmitted&&s.destroy()):(e._socket.once("finish",function(){o()}),e.close()))},s._read=function(){(e.readyState===e.OPEN||e.readyState===e.CLOSING)&&!r&&(r=!0,e._receiver._writableState.needDrain||e._socket.resume())},s._write=function(o,f,a){if(e.readyState===e.CONNECTING){e.once("open",function(){s._write(o,f,a)});return}e.send(o,a)},s.on("end",B_),s.on("error",Of),s}kf.exports=M_});var qf=b((Rv,Mf)=>{"use strict";var q_=require("events"),ti=require("http"),Cv=require("https"),Tv=require("net"),Iv=require("tls"),{createHash:L_}=require("crypto"),nt=Kt(),D_=Jn(),{format:U_,parse:j_}=$n(),{GUID:F_,kWebSocket:W_}=rt(),H_=/^[+/0-9A-Za-z]{22}==$/,Af=0,Nf=1,Bf=2,Zn=class extends q_{constructor(t,r){if(super(),t={maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=ti.createServer((i,n)=>{let s=ti.STATUS_CODES[426];n.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),n.end(s)}),this._server.listen(t.port,t.host,t.backlog,r)):t.server&&(this._server=t.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=V_(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,s,o)=>{this.handleUpgrade(n,s,o,i)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set),this.options=t,this._state=Af}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(t&&this.once("close",t),this._state===Bf){process.nextTick(Xn,this);return}if(this._state===Nf)return;if(this._state=Nf,this.clients)for(let i of this.clients)i.terminate();let r=this._server;if(r&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){r.close(Xn.bind(void 0,this));return}process.nextTick(Xn,this)}shouldHandle(t){if(this.options.path){let r=t.url.indexOf("?");if((r!==-1?t.url.slice(0,r):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,r,i,n){r.on("error",es);let s=t.headers["sec-websocket-key"]!==void 0?t.headers["sec-websocket-key"].trim():!1,o=t.headers.upgrade,f=+t.headers["sec-websocket-version"],a={};if(t.method!=="GET"||o===void 0||o.toLowerCase()!=="websocket"||!s||!H_.test(s)||f!==8&&f!==13||!this.shouldHandle(t))return Yt(r,400);if(this.options.perMessageDeflate){let l=new nt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=j_(t.headers["sec-websocket-extensions"]);u[nt.extensionName]&&(l.accept(u[nt.extensionName]),a[nt.extensionName]=l)}catch{return Yt(r,400)}}if(this.options.verifyClient){let l={origin:t.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(l,(u,h,c,d)=>{if(!u)return Yt(r,h||401,c,d);this.completeUpgrade(s,a,t,r,i,n)});return}if(!this.options.verifyClient(l))return Yt(r,401)}this.completeUpgrade(s,a,t,r,i,n)}completeUpgrade(t,r,i,n,s,o){if(!n.readable||!n.writable)return n.destroy();if(n[W_])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Af)return Yt(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${L_("sha1").update(t+F_).digest("base64")}`],l=new D_(null),u=i.headers["sec-websocket-protocol"];if(u&&(u=u.split(",").map($_),this.options.handleProtocols?u=this.options.handleProtocols(u,i):u=u[0],u&&(a.push(`Sec-WebSocket-Protocol: ${u}`),l._protocol=u)),r[nt.extensionName]){let h=r[nt.extensionName].params,c=U_({[nt.extensionName]:[h]});a.push(`Sec-WebSocket-Extensions: ${c}`),l._extensions=r}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
`).join(`\r
|
|
`)),n.removeListener("error",es),l.setSocket(n,s,this.options.maxPayload),this.clients&&(this.clients.add(l),l.on("close",()=>this.clients.delete(l))),o(l,i)}};Mf.exports=Zn;function V_(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return function(){for(let i of Object.keys(t))e.removeListener(i,t[i])}}function Xn(e){e._state=Bf,e.emit("close")}function es(){this.destroy()}function Yt(e,t,r,i){e.writable&&(r=r||ti.STATUS_CODES[t],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},e.write(`HTTP/1.1 ${t} ${ti.STATUS_CODES[t]}\r
|
|
`+Object.keys(i).map(n=>`${n}: ${i[n]}`).join(`\r
|
|
`)+`\r
|
|
\r
|
|
`+r)),e.removeListener("error",es),e.destroy()}function $_(e){return e.trim()}});var ri=b((Ov,Lf)=>{"use strict";var Qt=Jn();Qt.createWebSocketStream=Pf();Qt.Server=qf();Qt.Receiver=Dn();Qt.Sender=jn();Lf.exports=Qt});var rs=b((kv,ts)=>{"use strict";var Df=ri(),Jt=We()("mqttjs:ws"),K_=zr(),G_=Ue().Transform,z_=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],Uf=typeof process<"u"&&process.title==="browser"||typeof __webpack_require__=="function";function jf(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return typeof e.transformWsUrl=="function"&&(r=e.transformWsUrl(r,e,t)),r}function Ff(e){let t=e;return e.hostname||(t.hostname="localhost"),e.port||(e.protocol==="wss"?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),!Uf&&e.protocol==="wss"&&z_.forEach(function(r){e.hasOwnProperty(r)&&!e.wsOptions.hasOwnProperty(r)&&(t.wsOptions[r]=e[r])}),t}function Y_(e){let t=Ff(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");let r=new URL(document.URL);t.hostname=r.hostname,t.port||(t.port=r.port)}return t.objectMode===void 0&&(t.objectMode=!(t.binary===!0||t.binary===void 0)),t}function Q_(e,t,r){Jt("createWebSocket"),Jt("protocol: "+r.protocolId+" "+r.protocolVersion);let i=r.protocolId==="MQIsdp"&&r.protocolVersion===3?"mqttv3.1":"mqtt";return Jt("creating new Websocket for url: "+t+" and protocol: "+i),new Df(t,[i],r.wsOptions)}function J_(e,t){let r=t.protocolId==="MQIsdp"&&t.protocolVersion===3?"mqttv3.1":"mqtt",i=jf(t,e),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}function X_(e,t){Jt("streamBuilder");let r=Ff(t),i=jf(r,e),n=Q_(e,i,r),s=Df.createWebSocketStream(n,r.wsOptions);return s.url=i,n.on("close",()=>{s.destroy()}),s}function Z_(e,t){Jt("browserStreamBuilder");let r,n=Y_(t).browserBufferSize||1024*512,s=t.browserBufferTimeout||1e3,o=!t.objectMode,f=J_(e,t),a=u(t,m,p);t.objectMode||(a._writev=v),a.on("close",()=>{f.close()});let l=typeof f.addEventListener<"u";f.readyState===f.OPEN?r=a:(r=r=K_(void 0,void 0,t),t.objectMode||(r._writev=v),l?f.addEventListener("open",h):f.onopen=h),r.socket=f,l?(f.addEventListener("close",c),f.addEventListener("error",d),f.addEventListener("message",g)):(f.onclose=c,f.onerror=d,f.onmessage=g);function u(_,x,S){let C=new G_({objectModeMode:_.objectMode});return C._write=x,C._flush=S,C}function h(){r.setReadable(a),r.setWritable(a),r.emit("connect")}function c(){r.end(),r.destroy()}function d(_){r.destroy(_)}function g(_){let x=_.data;x instanceof ArrayBuffer?x=Buffer.from(x):x=Buffer.from(x,"utf8"),a.push(x)}function v(_,x){let S=new Array(_.length);for(let C=0;C<_.length;C++)typeof _[C].chunk=="string"?S[C]=Buffer.from(_[C],"utf8"):S[C]=_[C].chunk;this._write(Buffer.concat(S),"binary",x)}function m(_,x,S){f.bufferedAmount>n&&setTimeout(m,s,_,x,S),o&&typeof _=="string"&&(_=Buffer.from(_,"utf8"));try{f.send(_)}catch(C){return S(C)}S()}function p(_){f.close(),_()}return r}Uf?ts.exports=Z_:ts.exports=X_});var $f=b((Pv,Xt)=>{"use strict";var Hf=wn(),eg=Nr(),tg=require("url"),rg=br(),Wf=We()("mqttjs"),oe={};typeof process<"u"&&process.title!=="browser"||typeof __webpack_require__!="function"?(oe.mqtt=Sn(),oe.tcp=Sn(),oe.ssl=$r(),oe.tls=$r(),oe.mqtts=$r()):(oe.wx=In(),oe.wxs=In(),oe.ali=Rn(),oe.alis=Rn());oe.ws=rs();oe.wss=rs();function ig(e){var t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function Vf(e,t){if(Wf("connecting to an MQTT broker..."),typeof e=="object"&&!t&&(t=e,e=null),t=t||{},e){var r=tg.parse(e,!0);if(r.port!=null&&(r.port=Number(r.port)),t=rg(r,t),t.protocol===null)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(ig(t),t.query&&typeof t.query.clientId=="string"&&(t.clientId=t.query.clientId),t.cert&&t.key)if(t.protocol){if(["mqtts","wss","wxs","alis"].indexOf(t.protocol)===-1)switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}else throw new Error("Missing secure protocol key");if(!oe[t.protocol]){var i=["mqtts","wss"].indexOf(t.protocol)!==-1;t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(o,f){return i&&f%2===0?!1:typeof oe[o]=="function"})[0]}if(t.clean===!1&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);function n(o){return t.servers&&((!o._reconnectCount||o._reconnectCount===t.servers.length)&&(o._reconnectCount=0),t.host=t.servers[o._reconnectCount].host,t.port=t.servers[o._reconnectCount].port,t.protocol=t.servers[o._reconnectCount].protocol?t.servers[o._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,o._reconnectCount++),Wf("calling streambuilder for",t.protocol),oe[t.protocol](o,t)}var s=new Hf(n,t);return s.on("error",function(){}),s}Xt.exports=Vf;Xt.exports.connect=Vf;Xt.exports.MqttClient=Hf;Xt.exports.Store=eg});var Gf=b((Av,Zt)=>{var Kf=wn(),ng=$f(),sg=Nr();Zt.exports.connect=ng;Zt.exports.MqttClient=Kf;Zt.exports.Client=Kf;Zt.exports.Store=sg});var ni=b((ii,zf)=>{(function(e,t){typeof ii=="object"?zf.exports=ii=t():typeof define=="function"&&define.amd?define([],t):e.CryptoJS=t()})(ii,function(){var e=e||function(t,r){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof require=="function")try{i=require("crypto")}catch{}var n=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function p(){}return function(_){var x;return p.prototype=_,x=new p,p.prototype=null,x}}(),o={},f=o.lib={},a=f.Base=function(){return{extend:function(p){var _=s(this);return p&&_.mixIn(p),(!_.hasOwnProperty("init")||this.init===_.init)&&(_.init=function(){_.$super.init.apply(this,arguments)}),_.init.prototype=_,_.$super=this,_},create:function(){var p=this.extend();return p.init.apply(p,arguments),p},init:function(){},mixIn:function(p){for(var _ in p)p.hasOwnProperty(_)&&(this[_]=p[_]);p.hasOwnProperty("toString")&&(this.toString=p.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),l=f.WordArray=a.extend({init:function(p,_){p=this.words=p||[],_!=r?this.sigBytes=_:this.sigBytes=p.length*4},toString:function(p){return(p||h).stringify(this)},concat:function(p){var _=this.words,x=p.words,S=this.sigBytes,C=p.sigBytes;if(this.clamp(),S%4)for(var w=0;w<C;w++){var A=x[w>>>2]>>>24-w%4*8&255;_[S+w>>>2]|=A<<24-(S+w)%4*8}else for(var N=0;N<C;N+=4)_[S+N>>>2]=x[N>>>2];return this.sigBytes+=C,this},clamp:function(){var p=this.words,_=this.sigBytes;p[_>>>2]&=4294967295<<32-_%4*8,p.length=t.ceil(_/4)},clone:function(){var p=a.clone.call(this);return p.words=this.words.slice(0),p},random:function(p){for(var _=[],x=0;x<p;x+=4)_.push(n());return new l.init(_,p)}}),u=o.enc={},h=u.Hex={stringify:function(p){for(var _=p.words,x=p.sigBytes,S=[],C=0;C<x;C++){var w=_[C>>>2]>>>24-C%4*8&255;S.push((w>>>4).toString(16)),S.push((w&15).toString(16))}return S.join("")},parse:function(p){for(var _=p.length,x=[],S=0;S<_;S+=2)x[S>>>3]|=parseInt(p.substr(S,2),16)<<24-S%8*4;return new l.init(x,_/2)}},c=u.Latin1={stringify:function(p){for(var _=p.words,x=p.sigBytes,S=[],C=0;C<x;C++){var w=_[C>>>2]>>>24-C%4*8&255;S.push(String.fromCharCode(w))}return S.join("")},parse:function(p){for(var _=p.length,x=[],S=0;S<_;S++)x[S>>>2]|=(p.charCodeAt(S)&255)<<24-S%4*8;return new l.init(x,_)}},d=u.Utf8={stringify:function(p){try{return decodeURIComponent(escape(c.stringify(p)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(p){return c.parse(unescape(encodeURIComponent(p)))}},g=f.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(p){typeof p=="string"&&(p=d.parse(p)),this._data.concat(p),this._nDataBytes+=p.sigBytes},_process:function(p){var _,x=this._data,S=x.words,C=x.sigBytes,w=this.blockSize,A=w*4,N=C/A;p?N=t.ceil(N):N=t.max((N|0)-this._minBufferSize,0);var W=N*w,ze=t.min(W*4,C);if(W){for(var ve=0;ve<W;ve+=w)this._doProcessBlock(S,ve);_=S.splice(0,W),x.sigBytes-=ze}return new l.init(_,ze)},clone:function(){var p=a.clone.call(this);return p._data=this._data.clone(),p},_minBufferSize:0}),v=f.Hasher=g.extend({cfg:a.extend(),init:function(p){this.cfg=this.cfg.extend(p),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(p){return this._append(p),this._process(),this},finalize:function(p){p&&this._append(p);var _=this._doFinalize();return _},blockSize:512/32,_createHelper:function(p){return function(_,x){return new p.init(x).finalize(_)}},_createHmacHelper:function(p){return function(_,x){return new m.HMAC.init(p,x).finalize(_)}}}),m=o.algo={};return o}(Math);return e})});var is=b((si,Yf)=>{(function(e,t){typeof si=="object"?Yf.exports=si=t(ni()):typeof define=="function"&&define.amd?define(["./core"],t):t(e.CryptoJS)})(si,function(e){return function(t){var r=e,i=r.lib,n=i.WordArray,s=i.Hasher,o=r.algo,f=[],a=[];(function(){function h(v){for(var m=t.sqrt(v),p=2;p<=m;p++)if(!(v%p))return!1;return!0}function c(v){return(v-(v|0))*4294967296|0}for(var d=2,g=0;g<64;)h(d)&&(g<8&&(f[g]=c(t.pow(d,1/2))),a[g]=c(t.pow(d,1/3)),g++),d++})();var l=[],u=o.SHA256=s.extend({_doReset:function(){this._hash=new n.init(f.slice(0))},_doProcessBlock:function(h,c){for(var d=this._hash.words,g=d[0],v=d[1],m=d[2],p=d[3],_=d[4],x=d[5],S=d[6],C=d[7],w=0;w<64;w++){if(w<16)l[w]=h[c+w]|0;else{var A=l[w-15],N=(A<<25|A>>>7)^(A<<14|A>>>18)^A>>>3,W=l[w-2],ze=(W<<15|W>>>17)^(W<<13|W>>>19)^W>>>10;l[w]=N+l[w-7]+ze+l[w-16]}var ve=_&x^~_&S,hr=g&v^g&m^v&m,Ti=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),Rt=(_<<26|_>>>6)^(_<<21|_>>>11)^(_<<7|_>>>25),dr=C+Rt+ve+a[w]+l[w],pr=Ti+hr;C=S,S=x,x=_,_=p+dr|0,p=m,m=v,v=g,g=dr+pr|0}d[0]=d[0]+g|0,d[1]=d[1]+v|0,d[2]=d[2]+m|0,d[3]=d[3]+p|0,d[4]=d[4]+_|0,d[5]=d[5]+x|0,d[6]=d[6]+S|0,d[7]=d[7]+C|0},_doFinalize:function(){var h=this._data,c=h.words,d=this._nDataBytes*8,g=h.sigBytes*8;return c[g>>>5]|=128<<24-g%32,c[(g+64>>>9<<4)+14]=t.floor(d/4294967296),c[(g+64>>>9<<4)+15]=d,h.sigBytes=c.length*4,this._process(),this._hash},clone:function(){var h=s.clone.call(this);return h._hash=this._hash.clone(),h}});r.SHA256=s._createHelper(u),r.HmacSHA256=s._createHmacHelper(u)}(Math),e.SHA256})});var Jf=b((oi,Qf)=>{(function(e,t){typeof oi=="object"?Qf.exports=oi=t(ni()):typeof define=="function"&&define.amd?define(["./core"],t):t(e.CryptoJS)})(oi,function(e){(function(){var t=e,r=t.lib,i=r.Base,n=t.enc,s=n.Utf8,o=t.algo,f=o.HMAC=i.extend({init:function(a,l){a=this._hasher=new a.init,typeof l=="string"&&(l=s.parse(l));var u=a.blockSize,h=u*4;l.sigBytes>h&&(l=a.finalize(l)),l.clamp();for(var c=this._oKey=l.clone(),d=this._iKey=l.clone(),g=c.words,v=d.words,m=0;m<u;m++)g[m]^=1549556828,v[m]^=909522486;c.sigBytes=d.sigBytes=h,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var l=this._hasher,u=l.finalize(a);l.reset();var h=l.finalize(this._oKey.clone().concat(u));return h}})})()})});var Zf=b((ai,Xf)=>{(function(e,t,r){typeof ai=="object"?Xf.exports=ai=t(ni(),is(),Jf()):typeof define=="function"&&define.amd?define(["./core","./sha256","./hmac"],t):t(e.CryptoJS)})(ai,function(e){return e.HmacSHA256})});var tl=b((Nv,el)=>{el.exports={INVALID_CONNECT_OPTIONS:"Invalid connect options supplied.",INVALID_CLIENT_ID_OPTION:'Invalid "clientId" (mqtt client id) option supplied.',INVALID_RECONNECT_TIMING:"Invalid reconnect timing options supplied.",INVALID_OFFLINE_QUEUEING_PARAMETERS:"Invalid offline queueing options supplied."}});var er=b((Bv,rl)=>{rl.exports=function(e){return typeof e>"u"||e===null}});var nl=b((Mv,il)=>{il.exports={NO_KEY_OPTION:'No "keyPath" or "privateKey" option supplied.',NO_CERT_OPTION:'No "certPath" or "clientCert" option supplied.',NO_CA_OPTION:'No "caPath" or "caCert" option supplied.',INVALID_KEY_PATH_OPTION:'Invalid "keyPath" option supplied.',INVALID_CERT_PATH_OPTION:'Invalid "certPath" option supplied.',INVALID_CA_PATH_OPTION:'Invalid "caPath" option supplied.',INVALID_CLIENT_CERT_OPTION:'Invalid "clientCert" option supplied.',INVALID_PRIVATE_KEY_OPTION:'Invalid "privateKey" option supplied.',INVALID_CA_CERT_OPTION:'Invalid "caCert" option supplied.'}});var ol=b((qv,sl)=>{var ge=require("fs"),be=er(),ke=nl();sl.exports=function(e){if(be(e.keyPath)&&be(e.privateKey))throw new Error(ke.NO_KEY_OPTION);if(be(e.certPath)&&be(e.clientCert))throw new Error(ke.NO_CERT_OPTION);if(be(e.caPath)&&be(e.caCert))throw new Error(ke.NO_CA_OPTION);if(!be(e.caCert))if(Buffer.isBuffer(e.caCert))e.ca=e.caCert;else if(ge.existsSync(e.caCert))e.ca=ge.readFileSync(e.caCert);else throw new Error(ke.INVALID_CA_CERT_OPTION);if(!be(e.privateKey))if(Buffer.isBuffer(e.privateKey))e.key=e.privateKey;else if(ge.existsSync(e.privateKey))e.key=ge.readFileSync(e.privateKey);else throw new Error(ke.INVALID_PRIVATE_KEY_OPTION);if(!be(e.clientCert))if(Buffer.isBuffer(e.clientCert))e.cert=e.clientCert;else if(ge.existsSync(e.clientCert))e.cert=ge.readFileSync(e.clientCert);else throw new Error(ke.INVALID_CLIENT_CERT_OPTION);if(ge.existsSync(e.keyPath))e.key=ge.readFileSync(e.keyPath);else if(!be(e.keyPath))throw new Error(ke.INVALID_KEY_PATH_OPTION);if(ge.existsSync(e.certPath))e.cert=ge.readFileSync(e.certPath);else if(!be(e.certPath))throw new Error(ke.INVALID_CERT_PATH_OPTION);if(ge.existsSync(e.caPath))e.ca=ge.readFileSync(e.caPath);else if(!be(e.caPath))throw new Error(ke.INVALID_CA_PATH_OPTION);e.requestCert=!0,e.rejectUnauthorized=!0}});var al=b((Lv,og)=>{og.exports={name:"aws-iot-device-sdk",description:"AWS IoT Node.js SDK for Embedded Devices",version:"2.2.15",author:{name:"Amazon Web Services",email:"",url:"http://aws.amazon.com"},homepage:"https://github.com/aws/aws-iot-device-sdk-js",main:"index.js",engines:{node:">=8.17.0"},repository:{type:"git",url:"git://github.com/aws/aws-iot-device-sdk-js"},bugs:{url:"http://github.com/aws/aws-iot-device-sdk-js/issues"},license:"Apache-2.0",keywords:["api","amazon","aws","iot","mqtt"],dependencies:{"crypto-js":"4.2.0",minimist:"1.2.6",mqtt:"4.2.8","@httptoolkit/websocket-stream":"^6.0.1"},devDependencies:{gulp:"^3.9.0","gulp-beautify":"^2.0.0","gulp-concat":"^2.6.0","gulp-coverage":"^0.3.38","gulp-jscs":"^4.0.0","gulp-jshint":"^2.0.0","gulp-mocha":"^3.0.1",jshint:"^2.9.1","jshint-stylish":"^2.2.1",rewire:"^2.5.1",sinon:"^1.17.3"},scripts:{test:"node ./node_modules/gulp/bin/gulp.js test --verbose",browserize:"./scripts/browserize.sh",beautify:"node ./node_modules/gulp/bin/gulp.js beautify"}}});var ll=b((Dv,fl)=>{var ag=require("tls");function fg(e,t){var r;r=ag.connect(t);function i(n){e.emit("error",n),r.end()}return r.on("secureConnect",function(){r.authorized?r.removeListener("error",i):r.emit("error",new Error("TLS not authorized"))}),r.on("error",i),r}fl.exports=fg});var cl=b((Uv,ul)=>{var lg={}.toString;ul.exports=Array.isArray||function(e){return lg.call(e)=="[object Array]"}});var ns=b((jv,hl)=>{hl.exports=require("stream")});var mt=b((ss,pl)=>{var fi=require("buffer"),Pe=fi.Buffer;function dl(e,t){for(var r in e)t[r]=e[r]}Pe.from&&Pe.alloc&&Pe.allocUnsafe&&Pe.allocUnsafeSlow?pl.exports=fi:(dl(fi,ss),ss.Buffer=vt);function vt(e,t,r){return Pe(e,t,r)}dl(Pe,vt);vt.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Pe(e,t,r)};vt.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=Pe(e);return t!==void 0?typeof r=="string"?i.fill(t,r):i.fill(t):i.fill(0),i};vt.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Pe(e)};vt.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return fi.SlowBuffer(e)}});var wt=b(re=>{function ug(e){return Array.isArray?Array.isArray(e):li(e)==="[object Array]"}re.isArray=ug;function cg(e){return typeof e=="boolean"}re.isBoolean=cg;function hg(e){return e===null}re.isNull=hg;function dg(e){return e==null}re.isNullOrUndefined=dg;function pg(e){return typeof e=="number"}re.isNumber=pg;function _g(e){return typeof e=="string"}re.isString=_g;function gg(e){return typeof e=="symbol"}re.isSymbol=gg;function bg(e){return e===void 0}re.isUndefined=bg;function yg(e){return li(e)==="[object RegExp]"}re.isRegExp=yg;function vg(e){return typeof e=="object"&&e!==null}re.isObject=vg;function mg(e){return li(e)==="[object Date]"}re.isDate=mg;function wg(e){return li(e)==="[object Error]"||e instanceof Error}re.isError=wg;function Sg(e){return typeof e=="function"}re.isFunction=Sg;function Eg(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}re.isPrimitive=Eg;re.isBuffer=Buffer.isBuffer;function li(e){return Object.prototype.toString.call(e)}});var gl=b((Wv,os)=>{"use strict";function xg(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _l=mt().Buffer,tr=require("util");function Cg(e,t,r){e.copy(t,r)}os.exports=function(){function e(){xg(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var i={data:r,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length},e.prototype.unshift=function(r){var i={data:r,next:this.head};this.length===0&&(this.tail=i),this.head=i,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var i=this.head,n=""+i.data;i=i.next;)n+=r+i.data;return n},e.prototype.concat=function(r){if(this.length===0)return _l.alloc(0);for(var i=_l.allocUnsafe(r>>>0),n=this.head,s=0;n;)Cg(n.data,i,s),s+=n.data.length,n=n.next;return i},e}();tr&&tr.inspect&&tr.inspect.custom&&(os.exports.prototype[tr.inspect.custom]=function(){var e=tr.inspect({length:this.length});return this.constructor.name+" "+e})});var as=b((Hv,bl)=>{"use strict";var ui=gt();function Tg(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return i||n?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,ui.nextTick(ci,this,e)):ui.nextTick(ci,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(s){!t&&s?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,ui.nextTick(ci,r,s)):ui.nextTick(ci,r,s):t&&t(s)}),this)}function Ig(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function ci(e,t){e.emit("error",t)}bl.exports={destroy:Tg,undestroy:Ig}});var ls=b((Vv,Cl)=>{"use strict";var st=gt();Cl.exports=G;function vl(e){var t=this;this.next=null,this.entry=null,this.finish=function(){$g(t,e)}}var Rg=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:st.nextTick,St;G.WritableState=ir;var ml=Object.create(wt());ml.inherits=ie();var Og={deprecate:Li()},wl=ns(),di=mt().Buffer,kg=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function Pg(e){return di.from(e)}function Ag(e){return di.isBuffer(e)||e instanceof kg}var Sl=as();ml.inherits(G,wl);function Ng(){}function ir(e,t){St=St||ot(),e=e||{};var r=t instanceof St;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,n=e.writableHighWaterMark,s=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:r&&(n||n===0)?this.highWaterMark=n:this.highWaterMark=s,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=e.decodeStrings===!1;this.decodeStrings=!o,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(f){jg(t,f)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new vl(this)}ir.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(ir.prototype,"buffer",{get:Og.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var hi;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(hi=Function.prototype[Symbol.hasInstance],Object.defineProperty(G,Symbol.hasInstance,{value:function(e){return hi.call(this,e)?!0:this!==G?!1:e&&e._writableState instanceof ir}})):hi=function(e){return e instanceof this};function G(e){if(St=St||ot(),!hi.call(G,this)&&!(this instanceof St))return new G(e);this._writableState=new ir(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),wl.call(this)}G.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function Bg(e,t){var r=new Error("write after end");e.emit("error",r),st.nextTick(t,r)}function Mg(e,t,r,i){var n=!0,s=!1;return r===null?s=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),st.nextTick(i,s),n=!1),n}G.prototype.write=function(e,t,r){var i=this._writableState,n=!1,s=!i.objectMode&&Ag(e);return s&&!di.isBuffer(e)&&(e=Pg(e)),typeof t=="function"&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=Ng),i.ended?Bg(this,r):(s||Mg(this,i,e,r))&&(i.pendingcb++,n=Lg(this,i,s,e,t,r)),n};G.prototype.cork=function(){var e=this._writableState;e.corked++};G.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&El(this,e))};G.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function qg(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=di.from(t,r)),t}Object.defineProperty(G.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Lg(e,t,r,i,n,s){if(!r){var o=qg(t,i,n);i!==o&&(r=!0,n="buffer",i=o)}var f=t.objectMode?1:i.length;t.length+=f;var a=t.length<t.highWaterMark;if(a||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:s,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else fs(e,t,!1,f,i,n,s);return a}function fs(e,t,r,i,n,s,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(n,t.onwrite):e._write(n,s,t.onwrite),t.sync=!1}function Dg(e,t,r,i,n){--t.pendingcb,r?(st.nextTick(n,i),st.nextTick(rr,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(n(i),e._writableState.errorEmitted=!0,e.emit("error",i),rr(e,t))}function Ug(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function jg(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(Ug(r),t)Dg(e,r,i,t,n);else{var s=xl(r);!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&El(e,r),i?Rg(yl,e,r,s,n):yl(e,r,s,n)}}function yl(e,t,r,i){r||Fg(e,t),t.pendingcb--,i(),rr(e,t)}function Fg(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function El(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var o=0,f=!0;r;)n[o]=r,r.isBuf||(f=!1),r=r.next,o+=1;n.allBuffers=f,fs(e,t,!0,t.length,n,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new vl(t),t.bufferedRequestCount=0}else{for(;r;){var a=r.chunk,l=r.encoding,u=r.callback,h=t.objectMode?1:a.length;if(fs(e,t,!1,h,a,l,u),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}G.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};G.prototype._writev=null;G.prototype.end=function(e,t,r){var i=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||Vg(this,i,r)};function xl(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Wg(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),rr(e,t)})}function Hg(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,st.nextTick(Wg,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function rr(e,t){var r=xl(t);return r&&(Hg(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function Vg(e,t,r){t.ending=!0,rr(e,t),r&&(t.finished?st.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function $g(e,t,r){var i=e.entry;for(e.entry=null;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty(G.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});G.prototype.destroy=Sl.destroy;G.prototype._undestroy=Sl.undestroy;G.prototype._destroy=function(e,t){this.end(),t(e)}});var ot=b(($v,Ol)=>{"use strict";var Tl=gt(),Kg=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Ol.exports=Ae;var Il=Object.create(wt());Il.inherits=ie();var Rl=hs(),cs=ls();Il.inherits(Ae,Rl);for(us=Kg(cs.prototype),pi=0;pi<us.length;pi++)_i=us[pi],Ae.prototype[_i]||(Ae.prototype[_i]=cs.prototype[_i]);var us,_i,pi;function Ae(e){if(!(this instanceof Ae))return new Ae(e);Rl.call(this,e),cs.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",Gg)}Object.defineProperty(Ae.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Gg(){this.allowHalfOpen||this._writableState.ended||Tl.nextTick(zg,this)}function zg(e){e.end()}Object.defineProperty(Ae.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});Ae.prototype._destroy=function(e,t){this.push(null),this.end(),Tl.nextTick(t,e)}});var _s=b(Pl=>{"use strict";var ps=mt().Buffer,kl=ps.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Yg(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function Qg(e){var t=Yg(e);if(typeof t!="string"&&(ps.isEncoding===kl||!kl(e)))throw new Error("Unknown encoding: "+e);return t||e}Pl.StringDecoder=nr;function nr(e){this.encoding=Qg(e);var t;switch(this.encoding){case"utf16le":this.text=rb,this.end=ib,t=4;break;case"utf8":this.fillLast=Zg,t=4;break;case"base64":this.text=nb,this.end=sb,t=3;break;default:this.write=ob,this.end=ab;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=ps.allocUnsafe(t)}nr.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};nr.prototype.end=tb;nr.prototype.text=eb;nr.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function ds(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Jg(e,t,r){var i=t.length-1;if(i<r)return 0;var n=ds(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||n===-2?0:(n=ds(t[i]),n>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||n===-2?0:(n=ds(t[i]),n>=0?(n>0&&(n===2?n=0:e.lastNeed=n-3),n):0))}function Xg(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function Zg(e){var t=this.lastTotal-this.lastNeed,r=Xg(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function eb(e,t){var r=Jg(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function tb(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function rb(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function ib(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function nb(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function sb(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function ob(e){return e.toString(this.encoding)}function ab(e){return e&&e.length?this.write(e):""}});var hs=b((zv,Hl)=>{"use strict";var xt=gt();Hl.exports=V;var fb=cl(),sr;V.ReadableState=Dl;var Gv=require("events").EventEmitter,Ml=function(e,t){return e.listeners(t).length},ms=ns(),or=mt().Buffer,lb=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function ub(e){return or.from(e)}function cb(e){return or.isBuffer(e)||e instanceof lb}var ql=Object.create(wt());ql.inherits=ie();var gs=require("util"),q=void 0;gs&&gs.debuglog?q=gs.debuglog("stream"):q=function(){};var hb=gl(),Ll=as(),Et;ql.inherits(V,ms);var bs=["error","close","destroy","pause","resume"];function db(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):fb(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Dl(e,t){sr=sr||ot(),e=e||{};var r=t instanceof sr;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,n=e.readableHighWaterMark,s=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:r&&(n||n===0)?this.highWaterMark=n:this.highWaterMark=s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new hb,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Et||(Et=_s().StringDecoder),this.decoder=new Et(e.encoding),this.encoding=e.encoding)}function V(e){if(sr=sr||ot(),!(this instanceof V))return new V(e);this._readableState=new Dl(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),ms.call(this)}Object.defineProperty(V.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});V.prototype.destroy=Ll.destroy;V.prototype._undestroy=Ll.undestroy;V.prototype._destroy=function(e,t){this.push(null),t(e)};V.prototype.push=function(e,t){var r=this._readableState,i;return r.objectMode?i=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=or.from(e,t),t=""),i=!0),Ul(this,e,t,!1,i)};V.prototype.unshift=function(e){return Ul(this,e,null,!0,!1)};function Ul(e,t,r,i,n){var s=e._readableState;if(t===null)s.reading=!1,bb(e,s);else{var o;n||(o=pb(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?(typeof t!="string"&&!s.objectMode&&Object.getPrototypeOf(t)!==or.prototype&&(t=ub(t)),i?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ys(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||t.length!==0?ys(e,s,t,!1):jl(e,s)):ys(e,s,t,!1))):i||(s.reading=!1)}return _b(s)}function ys(e,t,r,i){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&gi(e)),jl(e,t)}function pb(e,t){var r;return!cb(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function _b(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}V.prototype.isPaused=function(){return this._readableState.flowing===!1};V.prototype.setEncoding=function(e){return Et||(Et=_s().StringDecoder),this._readableState.decoder=new Et(e),this._readableState.encoding=e,this};var Al=8388608;function gb(e){return e>=Al?e=Al:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Nl(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=gb(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}V.prototype.read=function(e){q("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return q("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?vs(this):gi(this),null;if(e=Nl(e,t),e===0&&t.ended)return t.length===0&&vs(this),null;var i=t.needReadable;q("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,q("length less than watermark",i)),t.ended||t.reading?(i=!1,q("reading or ended",i)):i&&(q("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Nl(r,t)));var n;return e>0?n=Fl(e,t):n=null,n===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&vs(this)),n!==null&&this.emit("data",n),n};function bb(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,gi(e)}}function gi(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(q("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?xt.nextTick(Bl,e):Bl(e))}function Bl(e){q("emit readable"),e.emit("readable"),ws(e)}function jl(e,t){t.readingMore||(t.readingMore=!0,xt.nextTick(yb,e,t))}function yb(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(q("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}V.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};V.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,q("pipe count=%d opts=%j",i.pipesCount,t);var n=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,s=n?f:m;i.endEmitted?xt.nextTick(s):r.once("end",s),e.on("unpipe",o);function o(p,_){q("onunpipe"),p===r&&_&&_.hasUnpiped===!1&&(_.hasUnpiped=!0,u())}function f(){q("onend"),e.end()}var a=vb(r);e.on("drain",a);var l=!1;function u(){q("cleanup"),e.removeListener("close",g),e.removeListener("finish",v),e.removeListener("drain",a),e.removeListener("error",d),e.removeListener("unpipe",o),r.removeListener("end",f),r.removeListener("end",m),r.removeListener("data",c),l=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&a()}var h=!1;r.on("data",c);function c(p){q("ondata"),h=!1;var _=e.write(p);_===!1&&!h&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&Wl(i.pipes,e)!==-1)&&!l&&(q("false write response, pause",i.awaitDrain),i.awaitDrain++,h=!0),r.pause())}function d(p){q("onerror",p),m(),e.removeListener("error",d),Ml(e,"error")===0&&e.emit("error",p)}db(e,"error",d);function g(){e.removeListener("finish",v),m()}e.once("close",g);function v(){q("onfinish"),e.removeListener("close",g),m()}e.once("finish",v);function m(){q("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(q("pipe resume"),r.resume()),e};function vb(e){return function(){var t=e._readableState;q("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&Ml(e,"data")&&(t.flowing=!0,ws(e))}}V.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<n;s++)i[s].emit("unpipe",this,{hasUnpiped:!1});return this}var o=Wl(t.pipes,e);return o===-1?this:(t.pipes.splice(o,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};V.prototype.on=function(e,t){var r=ms.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var i=this._readableState;!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&gi(this):xt.nextTick(mb,this))}return r};V.prototype.addListener=V.prototype.on;function mb(e){q("readable nexttick read 0"),e.read(0)}V.prototype.resume=function(){var e=this._readableState;return e.flowing||(q("resume"),e.flowing=!0,wb(this,e)),this};function wb(e,t){t.resumeScheduled||(t.resumeScheduled=!0,xt.nextTick(Sb,e,t))}function Sb(e,t){t.reading||(q("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),ws(e),t.flowing&&!t.reading&&e.read(0)}V.prototype.pause=function(){return q("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(q("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function ws(e){var t=e._readableState;for(q("flow",t.flowing);t.flowing&&e.read()!==null;);}V.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;e.on("end",function(){if(q("wrapped end"),r.decoder&&!r.ended){var o=r.decoder.end();o&&o.length&&t.push(o)}t.push(null)}),e.on("data",function(o){if(q("wrapped data"),r.decoder&&(o=r.decoder.write(o)),!(r.objectMode&&o==null)&&!(!r.objectMode&&(!o||!o.length))){var f=t.push(o);f||(i=!0,e.pause())}});for(var n in e)this[n]===void 0&&typeof e[n]=="function"&&(this[n]=function(o){return function(){return e[o].apply(e,arguments)}}(n));for(var s=0;s<bs.length;s++)e.on(bs[s],this.emit.bind(this,bs[s]));return this._read=function(o){q("wrapped _read",o),i&&(i=!1,e.resume())},this};Object.defineProperty(V.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});V._fromList=Fl;function Fl(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=Eb(e,t.buffer,t.decoder),r}function Eb(e,t,r){var i;return e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?i=t.shift():i=r?xb(e,t):Cb(e,t),i}function xb(e,t){var r=t.head,i=1,n=r.data;for(e-=n.length;r=r.next;){var s=r.data,o=e>s.length?s.length:e;if(o===s.length?n+=s:n+=s.slice(0,e),e-=o,e===0){o===s.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(o));break}++i}return t.length-=i,n}function Cb(e,t){var r=or.allocUnsafe(e),i=t.head,n=1;for(i.data.copy(r),e-=i.data.length;i=i.next;){var s=i.data,o=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,o),e-=o,e===0){o===s.length?(++n,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=s.slice(o));break}++n}return t.length-=n,r}function vs(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,xt.nextTick(Tb,t,e))}function Tb(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Wl(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}});var Ss=b((Yv,Kl)=>{"use strict";Kl.exports=Ne;var bi=ot(),$l=Object.create(wt());$l.inherits=ie();$l.inherits(Ne,bi);function Ib(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function Ne(e){if(!(this instanceof Ne))return new Ne(e);bi.call(this,e),this._transformState={afterTransform:Ib.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Rb)}function Rb(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){Vl(e,t,r)}):Vl(this,null,null)}Ne.prototype.push=function(e,t){return this._transformState.needTransform=!1,bi.prototype.push.call(this,e,t)};Ne.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};Ne.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}};Ne.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Ne.prototype._destroy=function(e,t){var r=this;bi.prototype._destroy.call(this,e,function(i){t(i),r.emit("close")})};function Vl(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var Ql=b((Qv,Yl)=>{"use strict";Yl.exports=ar;var Gl=Ss(),zl=Object.create(wt());zl.inherits=ie();zl.inherits(ar,Gl);function ar(e){if(!(this instanceof ar))return new ar(e);Gl.call(this,e)}ar.prototype._transform=function(e,t,r){r(null,e)}});var Es=b((X,yi)=>{var Ee=require("stream");process.env.READABLE_STREAM==="disable"&&Ee?(yi.exports=Ee,X=yi.exports=Ee.Readable,X.Readable=Ee.Readable,X.Writable=Ee.Writable,X.Duplex=Ee.Duplex,X.Transform=Ee.Transform,X.PassThrough=Ee.PassThrough,X.Stream=Ee):(X=yi.exports=hs(),X.Stream=Ee||X,X.Readable=X,X.Writable=ls(),X.Duplex=ot(),X.Transform=Ss(),X.PassThrough=Ql())});var tu=b((Jv,eu)=>{var vi=Es(),Jl=xn(),Ob=ie(),kb=Cn(),Xl=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),xs=function(e,t){e._corked?e.once("uncork",t):t()},Pb=function(e,t){e._autoDestroy&&e.destroy(t)},Zl=function(e,t){return function(r){r?Pb(e,r.message==="premature close"?null:r):t&&!e._ended&&e.end()}},Ab=function(e,t){if(!e||e._writableState&&e._writableState.finished)return t();if(e._writableState)return e.end(t);e.end(),t()},Nb=function(e){return new vi.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},Z=function(e,t,r){if(!(this instanceof Z))return new Z(e,t,r);vi.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||r.autoDestroy!==!1,this._forwardDestroy=!r||r.destroy!==!1,this._forwardEnd=!r||r.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};Ob(Z,vi.Duplex);Z.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new Z(e,t,r)};Z.prototype.cork=function(){++this._corked===1&&this.emit("cork")};Z.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};Z.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.end();return}var t=this,r=Jl(e,{writable:!0,readable:!1},Zl(this,this._forwardEnd)),i=function(){var s=t._ondrain;t._ondrain=null,s&&s()},n=function(){t._writable.removeListener("drain",i),r()};this._unwrite&&process.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=n,this.uncork()};Z.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.push(null),this.resume();return}var t=this,r=Jl(e,{writable:!1,readable:!0},Zl(this)),i=function(){t._forward()},n=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",i),t._readable2.removeListener("end",n),r()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:Nb(e),this._readable2.on("readable",i),this._readable2.on("end",n),this._unread=s,this._forward()};Z.prototype._read=function(){this._drained=!0,this._forward()};Z.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var e;this._drained&&(e=kb(this._readable2))!==null;)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}};Z.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;process.nextTick(function(){t._destroy(e)})}};Z.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")};Z.prototype._write=function(e,t,r){if(this.destroyed)return r();if(this._corked)return xs(this,this._write.bind(this,e,t,r));if(e===Xl)return this._finish(r);if(!this._writable)return r();this._writable.write(e)===!1?this._ondrain=r:r()};Z.prototype._finish=function(e){var t=this;this.emit("preend"),xs(this,function(){Ab(t._forwardEnd&&t._writable,function(){t._writableState.prefinished===!1&&(t._writableState.prefinished=!0),t.emit("prefinish"),xs(t,e)})})};Z.prototype.end=function(e,t,r){return typeof e=="function"?this.end(null,null,e):typeof t=="function"?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(Xl),vi.Writable.prototype.end.call(this,r))};eu.exports=Z});var iu=b((Xv,ru)=>{"use strict";ru.exports=ri()});var Cs=b((Zv,su)=>{"use strict";var Bb=Es().Transform,Mb=tu(),nu=iu(),Ct=mt().Buffer;su.exports=Lb;function qb(e,t,r){var i=new Bb({objectMode:e.objectMode});return i._write=t,i._flush=r,i}function Lb(e,t,r){var i,n,s=process.title==="browser",o=!!global.WebSocket,f=s?g:d;t&&!Array.isArray(t)&&typeof t=="object"&&(r=t,t=void 0,(typeof r.protocol=="string"||Array.isArray(r.protocol))&&(t=r.protocol)),r||(r={}),r.objectMode===void 0&&(r.objectMode=!(r.binary===!0||r.binary===void 0));var a=qb(r,f,v);r.objectMode||(a._writev=C);var l=r.browserBufferSize||1024*512,u=r.browserBufferTimeout||1e3;typeof e=="object"?n=e:(o&&s?n=new nu(e,t):n=new nu(e,t,r),n.binaryType="arraybuffer");var h=typeof n.addEventListener>"u";n.readyState===n.OPEN?i=a:(i=Mb(void 0,void 0,r),r.objectMode||(i._writev=C),h?n.addEventListener("open",m):n.onopen=m),i.socket=n,h?(n.addEventListener("close",p),n.addEventListener("error",_),n.addEventListener("message",x)):(n.onclose=p,n.onerror=_,n.onmessage=x),a.on("close",S);var c=!r.objectMode;function d(w,A,N){if(n.readyState!==n.OPEN){N();return}c&&typeof w=="string"&&(w=Ct.from(w,"utf8")),n.send(w,N)}function g(w,A,N){if(n.bufferedAmount>l){setTimeout(g,u,w,A,N);return}c&&typeof w=="string"&&(w=Ct.from(w,"utf8"));try{n.send(w)}catch(W){return N(W)}N()}function v(w){n.close(),w()}function m(){i.setReadable(a),i.setWritable(a),i.emit("connect")}function p(w){i.emit("ws-close",w),i.end(),i.destroy()}function _(w){i.destroy(w)}function x(w){var A=w.data;A instanceof ArrayBuffer?A=Ct.from(A):A=Ct.from(A,"utf8"),a.push(A)}function S(){n.close()}function C(w,A){for(var N=new Array(w.length),W=0;W<w.length;W++)typeof w[W].chunk=="string"?N[W]=Ct.from(w[W],"utf8"):N[W]=w[W].chunk;this._write(Ct.concat(N),"binary",A)}return i}});var ou=b((em,Ts)=>{"use strict";var Db=ri().Server,Ub=Cs(),mi=class extends Db{constructor(t,r){super(t);var i=!1;this.on("newListener",function(n){!i&&n==="stream"&&(i=!0,this.on("connection",function(s,o){this.emit("stream",Ub(s,t),o)}))}),r&&this.on("stream",r)}};Ts.exports.Server=mi;Ts.exports.createServer=function(e,t){return new mi(e,t)}});var fu=b((tm,wi)=>{var au=ou();wi.exports=Cs();wi.exports.Server=au.Server;wi.exports.createServer=au.createServer});var uu=b((rm,lu)=>{var jb=fu();function Fb(e,t){return jb(t.url,["mqttv3.1"],t.websocketOptions)}lu.exports=Fb});var Si=b((im,cr)=>{var Wb=require("events"),Hb=require("util").inherits,Vb=Gf(),lr=Zf(),cu=is(),xe=tl(),k=er(),$b=ol(),Kb=require("path"),Gb=require("fs");function fr(e){return e>9?e:"0"+e}function zb(){var e=new Date;return e.getUTCFullYear()+""+fr(e.getUTCMonth()+1)+fr(e.getUTCDate())+"T"+fr(e.getUTCHours())+fr(e.getUTCMinutes())+fr(e.getUTCSeconds())+"Z"}function Yb(e){return e.substring(0,e.indexOf("T"))}function Qb(e,t,r,i){var n=lr(t,"AWS4"+e,{asBytes:!0}),s=lr(r,n,{asBytes:!0}),o=lr(i,s,{asBytes:!0}),f=lr("aws4_request",o,{asBytes:!0});return f}function Jb(e,t,r,i,n,s,o,f,a,l,u,h,c,d){var g="host",v="host:"+r.toLowerCase()+`
|
|
`,m=e+`
|
|
`+i+`
|
|
`+n+`
|
|
`+v+`
|
|
`+g+`
|
|
`+cu(l,{asBytes:!0});c===!0&&console.log("canonical request: "+m+`
|
|
`);var p=cu(m,{asBytes:!0});c===!0&&console.log("hashed canonical request: "+p+`
|
|
`);var _=`AWS4-HMAC-SHA256
|
|
`+h+`
|
|
`+u+"/"+f+"/"+a+`/aws4_request
|
|
`+p;c===!0&&console.log("string to sign: "+_+`
|
|
`);var x=Qb(o,u,f,a);c===!0&&console.log("signing key: "+x+`
|
|
`);var S=lr(_,x,{asBytes:!0});c===!0&&console.log("signature: "+S+`
|
|
`);var C=n+"&X-Amz-Signature="+S;k(d)||(C+="&X-Amz-Security-Token="+encodeURIComponent(d));var w=t+r+i+"?"+C;return c===!0&&console.log("url: "+w+`
|
|
`),w}function hu(e,t,r,i){var n=zb(),s=Yb(n),o="/mqtt",f="iotdevicegateway",a="X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential="+t+"%2F"+s+"%2F"+e.region+"%2F"+f+"%2Faws4_request&X-Amz-Date="+n+"&X-Amz-SignedHeaders=host",l=e.host;return!k(e.port)&&e.port!==443&&(l=e.host+":"+e.port),Jb("GET","wss://",l,o,a,t,r,e.region,f,"",s,n,e.debug,i)}function du(e){var t="/mqtt",r=e.host;return!k(e.port)&&e.port!==443&&(r=e.host+":"+e.port),"wss://"+r+t+(e.customAuthQueryString||"")}function Xb(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(this,e[r],parseInt(r,10))}function Zb(e){var t={},r={};return Xb(e.split(/\r?\n/),function(i){i=i.split(/(^|\s)[;#]/)[0];var n=i.match(/^\s*\[([^\[\]]+)\]\s*$/);if(n)r=n[1];else if(r){var s=i.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/);s&&(t[r]=t[r]||{},t[r][s[1]]=s[2])}}),t}function ur(e){if(!(this instanceof ur))return new ur(e);var t=this,r=[],i=!0,n=0,s="oldest";r.length=0;var o=[],f=50;o.length=0;var a=[],l=!0;a.length=0;var u=[];u.length=0;var h="inactive",c=null,d=250,g=300,v=1e3,m=2e4,p=128e3,_,x=null,S,C,w,A="?SDK=JavaScript&Version=",N=al(),W=N.version,ze=A+W;if(k(e)||Object.keys(e).length===0)throw new Error(xe.INVALID_CONNECT_OPTIONS);if(k(e.keepalive)&&(e.keepalive=g),(k(e.enableMetrics)||e.enableMetrics===!0)&&(k(e.username)?e.username=ze:e.username+=ze),k(e.baseReconnectTimeMs)||(v=e.baseReconnectTimeMs),k(e.minimumConnectionTimeMs)||(m=e.minimumConnectionTimeMs),k(e.maximumReconnectTimeMs)||(p=e.maximumReconnectTimeMs),k(e.drainTimeMs)||(d=e.drainTimeMs),k(e.autoResubscribe)||(l=e.autoResubscribe),k(e.offlineQueueing)||(i=e.offlineQueueing),k(e.offlineQueueMaxSize)||(n=e.offlineQueueMaxSize),k(e.offlineQueueDropBehavior)||(s=e.offlineQueueDropBehavior),_=v,e.reconnectPeriod=_,e.fastDisconnectDetection=!0,e.resubscribe=!1,e.baseReconnectTimeMs<=0)throw new Error(xe.INVALID_RECONNECT_TIMING);if(p<v)throw new Error(xe.INVALID_RECONNECT_TIMING);if(m<v)throw new Error(xe.INVALID_RECONNECT_TIMING);if(s!=="newest"&&s!=="oldest")throw new Error(xe.INVALID_OFFLINE_QUEUEING_PARAMETERS);if(n<0)throw new Error(xe.INVALID_OFFLINE_QUEUEING_PARAMETERS);if(k(e.protocol)&&(e.protocol="mqtts"),k(e.host))throw new Error(xe.INVALID_CONNECT_OPTIONS);if(k(e.servername)&&(e.servername=e.host.split(":")[0]),e.protocol==="mqtts")k(e.port)&&(e.port=8883),$b(e);else if(e.protocol==="wss"||e.protocol==="wss-custom-auth"){if(e.protocol==="wss"){if(k(e.accessKeyId)?S=process.env.AWS_ACCESS_KEY_ID:S=e.accessKeyId,k(e.secretKey)?C=process.env.AWS_SECRET_ACCESS_KEY:C=e.secretKey,k(e.sessionToken)?w=process.env.AWS_SESSION_TOKEN:w=e.sessionToken,k(S)||k(C)){var ve,hr=e.profile||process.env.AWS_PROFILE||"default";try{k(e.filename)?ve=xu():ve=e.filename;var Ti=Zb(Gb.readFileSync(ve,"utf-8")),Rt=Ti[hr];S=Rt.aws_access_key_id,C=Rt.aws_secret_access_key,w=Rt.aws_session_token}catch(T){console.log(T),console.log("Failed to read credentials for AWS_PROFILE "+hr+" from "+ve)}}if(k(S)||k(C))throw console.log("To connect via WebSocket/SigV4, AWS Access Key ID and AWS Secret Key must be passed either in options or as environment variables; see README.md"),new Error(xe.INVALID_CONNECT_OPTIONS)}else if(k(e.customAuthHeaders)&&k(e.customAuthQueryString))throw console.log("To authenticate with a custom authorizer, you must provide the required HTTP headers or queryString; see README.md"),new Error(xe.INVALID_CONNECT_OPTIONS);if(!k(e.host)&&k(e.region)){var dr=/[a-zA-Z0-9]+\.iot\.([^\.]+)\.amazonaws\..+/,pr=dr.exec(e.host);if(pr===null)throw console.log("Host endpoint is not valid"),new Error(xe.INVALID_CONNECT_OPTIONS);e.region=pr[1]}k(e.port)&&(e.port=443),k(e.websocketOptions)?e.websocketOptions={protocol:"mqttv3.1"}:e.websocketOptions.protocol="mqttv3.1",e.protocol==="wss-custom-auth"&&(e.websocketOptions.headers=e.customAuthHeaders)}!k(e)&&e.debug===!0&&(console.log(e),console.log("attempting new mqtt connection..."));var Ii={};Ii.mqtts=ll(),Ii.wss=uu();function xu(){var T=process.env.HOME||process.env.USERPROFILE||(process.env.HOMEPATH?(process.env.HOMEDRIVE||"C:/")+process.env.HOMEPATH:null);return Kb.join(T,".aws","credentials")}function Cu(T,R){var U=a.filter(function(ue){return ue.topic===T});U.length===0&&a.push({topic:T,options:R})}function Tu(T,R){var U=a.filter(function(ue){return ue.topic!==T});a=U}function Ri(T,R,U){var ue=null;l!==!1&&(T==="subscribe"?ue=Cu:T==="unsubscribe"&&(ue=Tu),Object.prototype.toString.call(R)==="[object Array]"?R.forEach(function(Pu,py,_y){ue(Pu,U)}):ue(R,U))}function _r(){return h==="inactive"}function Iu(T){var R=e.protocol;if(R==="wss"){var U;S===""||C===""?U="wss://no-credentials-available":U=hu(e,S,C,w),e.debug===!0&&console.log("using websockets, will connect to '"+U+"'..."),e.url=U}else R==="wss-custom-auth"&&(e.url=du(e),e.debug===!0&&console.log("using websockets custom auth, will connect to '"+e.url+"'..."),R="wss");return Ii[R](T,e)}var D=new Vb.MqttClient(Iu,e);function Ru(){_=v,D.options.reconnectPeriod=_,x=null,h="stable"}function Ou(){var T=!0;return n>0&&r.length>=n&&(s==="oldest"?r.shift():T=!1),T}function ku(){var T=u.shift();if(!k(T))k(T.callback)?D.subscribe(T.topic,T.options):D.subscribe(T.topic,T.options,T.callback);else{var R=o.shift();if(!k(R))Ri(R.type,R.topics,R.options),R.type==="subscribe"?k(R.callback)?D.subscribe(R.topics,R.options):D.subscribe(R.topics,R.options,R.callback):R.type==="unsubscribe"&&D.unsubscribe(R.topics,R.callback);else{var U=r.shift();k(U)||D.publish(U.topic,U.message,U.options,U.callback),r.length===0&&(clearInterval(c),c=null)}}}D.on("connect",function(T){x===null&&(x=setTimeout(Ru,m)),h="established",c===null&&(u=a.slice(0),c=setInterval(ku,d)),t.emit("connect",T)}),D.on("close",function(T){k(T)||t.emit("error",T),!k(e)&&e.debug===!0&&console.log("connection lost - will attempt reconnection in "+D.options.reconnectPeriod/1e3+" seconds..."),clearTimeout(x),x=null,clearInterval(c),c=null,h="inactive",t.emit("close")}),D.on("reconnect",function(){_=_*2,_=Math.min(p,_),D.options.reconnectPeriod=_,t.emit("reconnect")}),D.on("end",function(){t.emit("end")}),D.on("offline",function(){t.emit("offline")}),D.on("error",function(T){t.emit("error",T)}),D.on("packetsend",function(T){t.emit("packetsend",T)}),D.on("packetreceive",function(T){t.emit("packetreceive",T)}),D.on("message",function(T,R,U){t.emit("message",T,R,U)}),this.publish=function(T,R,U,ue){i===!0&&(_r()||c!==null)?Ou()&&r.push({topic:T,message:R,options:U,callback:ue}):(i===!0||!_r())&&D.publish(T,R,U,ue)},this.subscribe=function(T,R,U){!_r()||l===!1?(Ri("subscribe",T,R),k(U)?D.subscribe(T,R):D.subscribe(T,R,U)):o.length<f?o.push({type:"subscribe",topics:T,options:R,callback:U}):t.emit("error",new Error("Maximum queued offline subscription reached"))},this.unsubscribe=function(T,R){!_r()||l===!1?(Ri("unsubscribe",T),D.unsubscribe(T,R)):o.length<f&&o.push({type:"unsubscribe",topics:T,options:e,callback:R})},this.end=function(T,R){D.end(T,R)},this.handleMessage=D.handleMessage.bind(D),D.handleMessage=function(T,R){t.handleMessage(T,R)},this.updateWebSocketCredentials=function(T,R,U,ue){S=T,C=R,w=U},this.getWebsocketHeaders=function(){return e.websocketOptions.headers},this.updateCustomAuthHeaders=function(T){e.websocketOptions.headers=T},this.simulateNetworkFailure=function(){D.stream.emit("error",new Error("simulated connection error")),D.stream.end()}}Hb(ur,Wb.EventEmitter);cr.exports=ur;cr.exports.DeviceClient=ur;cr.exports.prepareWebSocketUrl=hu;cr.exports.prepareWebSocketCustomAuthUrl=du});var bu=b((nm,gu)=>{var _u=require("events"),ey=require("util").inherits,ty=Si(),L=er();function pu(e,t,r){return L(r)?"$aws/things/"+e+"/shadow/"+t:"$aws/things/"+e+"/shadow/"+t+"/"+r}function ry(e,t){var r=!1;return e[0]==="$aws"&&e[1]==="things"&&e[3]==="shadow"&&(e[4]==="update"||e[4]==="get"||e[4]==="delete")&&(t==="subscribe"?(e[5]==="accepted"||e[5]==="rejected"||e[5]==="delta")&&e.length===6&&(r=!0):e.length===5&&(r=!0)),r}function Ei(e,t){if(!(this instanceof Ei))return new Ei(e,t);var r=this,i=[{}],n=0,s=1e4,o=!0,f=ty.DeviceClient(e);L(t)||L(t.operationTimeout)||(s=t.operationTimeout),this._handleSubscriptions=function(a,l,u,h){for(var c=[],d=0,g=l.length;d<g;d++)for(var v=0,m=l[d].operations.length;v<m;v++)for(var p=0,_=l[d].statii.length;p<_;p++)c.push(pu(a,l[d].operations[v],l[d].statii[p]));i[a].debug===!0&&console.log(u+" on "+c);var x=[];x.push(c),u==="subscribe"?(x.push({qos:i[a].qos}),x.push(function(S,C){if(!L(h)){if(S){h(S);return}for(var w=[],A=0,N=C.length;A<N;A++)C[A].qos===128&&w.push(C[A]);if(w.length>0){h("Not all subscriptions were granted",w);return}h()}})):L(h)||x.push(h),f[u].apply(f,x)},this._handleMessages=function(a,l,u,h){var c={};try{c=JSON.parse(h.toString())}catch(v){e.debug===!0&&console.error("failed parsing JSON '"+h.toString()+"', "+v);return}var d=c.clientToken,g=c.version;if(delete c.clientToken,!L(g)&&u!=="rejected"){if(L(i[a].version)||g>=i[a].version)i[a].version=g;else if(l!=="delete"&&i[a].discardStale===!0){e.debug===!0&&console.warn("out-of-date version '"+g+"' on '"+a+"' (local version '"+i[a].version+"')");return}}if(u==="delta"){this.emit("delta",a,c);return}if(L(i[a].clientToken)||i[a].clientToken!==d){u==="accepted"&&l!=="get"&&this.emit("foreignStateChange",a,l,c);return}clearTimeout(i[a].timeout),delete i[a].timeout,delete i[a].clientToken,i[a].pending=!1,i[a].persistentSubscribe===!1&&this._handleSubscriptions(a,[{operations:[l],statii:["accepted","rejected"]}],"unsubscribe"),this.emit("status",a,u,d,c)},f.on("connect",function(){r.emit("connect")}),f.on("close",function(){r.emit("close")}),f.on("reconnect",function(){r.emit("reconnect")}),f.on("offline",function(){r.emit("offline")}),f.on("error",function(a){r.emit("error",a)}),f.on("packetsend",function(a){r.emit("packetsend",a)}),f.on("packetreceive",function(a){r.emit("packetreceive",a)}),f.on("message",function(a,l){if(o===!0){var u=a.split("/");ry(u,"subscribe")?i.hasOwnProperty(u[2])&&r._handleMessages(u[2],u[4],u[5],l):r.emit("message",a,l)}}),this._thingOperation=function(a,l,u){var h=null;if(i.hasOwnProperty(a))if(i[a].pending===!1){i[a].pending=!0;var c;if(L(u.clientToken)){var d=e.clientId.length;d>48?c=e.clientId.substr(d-48)+"-"+n++:c=e.clientId+"-"+n++}else c=u.clientToken;i[a].clientToken=c;var g=pu(a,l);i[a].timeout=setTimeout(function(v,m){i[v].persistentSubscribe===!1&&r._handleSubscriptions(v,[{operations:[l],statii:["accepted","rejected"]}],"unsubscribe"),i[v].pending=!1,delete i[v].timeout,delete i[v].clientToken,r.emit("timeout",v,m)},s,a,c),i[a].persistentSubscribe===!1?this._handleSubscriptions(a,[{operations:[l],statii:["accepted","rejected"]}],"subscribe",function(v,m){if(!L(v)||!L(m)){console.warn("failed subscription to accepted/rejected topics");return}L(u)||(!L(i[a].version)&&i[a].enableVersioning&&(u.version=i[a].version),u.clientToken=c,f.publish(g,JSON.stringify(u),{qos:i[a].qos}),!L(i[a])&&i[a].debug===!0&&console.log("publishing '"+JSON.stringify(u)+" on '"+g+"'"))}):(!L(i[a].version)&&i[a].enableVersioning&&(u.version=i[a].version),u.clientToken=c,f.publish(g,JSON.stringify(u),{qos:i[a].qos}),i[a].debug===!0&&console.log("publishing '"+JSON.stringify(u)+" on '"+g+"'")),h=c}else e.debug===!0&&console.error(l+" still in progress on thing: ",a);else e.debug===!0&&console.error("attempting to "+l+" unknown thing: ",a);return h},this.register=function(a,l,u){if(i.hasOwnProperty(a))e.debug===!0&&console.error("thing already registered: ",a);else{var h=!1,c=[];i[a]={persistentSubscribe:!0,debug:!1,discardStale:!0,enableVersioning:!0,qos:0,pending:!0},typeof l=="function"&&(u=l,l=null),L(l)||(L(l.ignoreDeltas)||(h=l.ignoreDeltas),L(l.persistentSubscribe)||(i[a].persistentSubscribe=l.persistentSubscribe),L(l.debug)||(i[a].debug=l.debug),L(l.discardStale)||(i[a].discardStale=l.discardStale),L(l.enableVersioning)||(i[a].enableVersioning=l.enableVersioning),L(l.qos)||(i[a].qos=l.qos)),h===!1&&c.push({operations:["update"],statii:["delta"]}),i[a].persistentSubscribe===!0&&c.push({operations:["update","get","delete"],statii:["accepted","rejected"]}),c.length>0?this._handleSubscriptions(a,c,"subscribe",function(d,g){L(d)&&L(g)&&(i[a].pending=!1),L(u)||u(d,g)}):(i[a].pending=!1,L(u)||u())}},this.unregister=function(a){if(i.hasOwnProperty(a)){var l=[];l.push({operations:["update"],statii:["delta"]}),i[a].persistentSubscribe===!0&&l.push({operations:["update","get","delete"],statii:["accepted","rejected"]}),this._handleSubscriptions(a,l,"unsubscribe"),L(i[a].timeout)||clearTimeout(i[a].timeout),delete i[a]}else e.debug===!0&&console.error("attempting to unregister unknown thing: ",a)},this.update=function(a,l){var u=null;return L(l.version)?u=r._thingOperation(a,"update",l):console.error("message can't contain 'version' property"),u},this.get=function(a,l){var u={};return L(l)||(u.clientToken=l),r._thingOperation(a,"get",u)},this.delete=function(a,l){var u={};return L(l)||(u.clientToken=l),r._thingOperation(a,"delete",u)},this.publish=function(a,l,u,h){f.publish(a,l,u,h)},this.subscribe=function(a,l,u){var h=[];typeof a=="string"?h.push(a):typeof a=="object"&&a.length&&(h=a),f.subscribe(h,l,u)},this.unsubscribe=function(a,l){var u=[];typeof a=="string"?u.push(a):typeof a=="object"&&a.length&&(u=a),f.unsubscribe(u,l)},this.end=function(a,l){f.end(a,l)},this.updateWebSocketCredentials=function(a,l,u,h){f.updateWebSocketCredentials(a,l,u,h)},this.updateCustomAuthHeaders=function(a){f.updateCustomAuthHeaders(a)},this.setConnectionStatus=function(a){o=a},_u.EventEmitter.call(this)}ey(Ei,_u.EventEmitter);gu.exports=Ei});var vu=b((sm,yu)=>{var iy=require("events"),ny=require("util").inherits,sy=Si(),F=er();function oy(e){return e[0]==="$aws"&&e[1]==="things"&&e[3]==="jobs"}function Tt(e,t,r){var i="$aws/things/"+e+"/jobs/";return F(r)?r=t:i+=t.toString()+"/",i+=r,i}function xi(e){if(!(this instanceof xi))return new xi(e);var t=this,r=[],i=sy.DeviceClient(e);this._updateJobStatus=function(n,s,o,f,a){typeof f=="function"&&(a=f,f=void 0),!F(e)&&e.debug===!0&&console.log("updateJobStatus:",{thingName:n,jobId:s.id,status:o,statusDetails:f}),i.publish(Tt(n,s.id,"update"),JSON.stringify({status:o,statusDetails:f}),null,function(l){F(l)&&(s.status={status:o,statusDetails:f}),F(a)||a(l)})},this._buildJobObject=function(n,s){if(F(s)||F(s.jobId))return null;var o={};return o.id=s.jobId,o.document=s.jobDocument,o.operation=o.document.operation,o.status={status:s.status,statusDetails:s.statusDetails},o.inProgress=function(f,a){t._updateJobStatus(n,o,"IN_PROGRESS",f,a)},o.failed=function(f,a){t._updateJobStatus(n,o,"FAILED",f,a)},o.succeeded=function(f,a){t._updateJobStatus(n,o,"SUCCEEDED",f,a)},o},this._handleMessages=function(n,s){var o=n.split("/");if(!oy(o)){t.emit("message",n,s);return}var f=o[2],a=r.find(function(c){return c.thingName===f});if(!F(a)){var l={};try{l=JSON.parse(s.toString())}catch(c){e.debug===!0&&console.error("failed parsing JSON '"+s.toString()+"', "+c);return}if(!(F(l.execution)||F(l.execution.jobId)||F(l.execution.jobDocument))){var u=l.execution.jobDocument.operation,h=a.operations.find(function(c){return F(u)?F(c.operationName):u===c.operationName});F(h)&&(h=a.operations.find(function(c){return F(c.operationName)}),F(h))||h.callback(null,t._buildJobObject(f,l.execution))}}},this.subscribeToJobs=function(n,s,o){F(o)&&(o=s,s=null),!F(e)&&e.debug===!0&&console.log("subscribeToJobs:",{thingName:n,operationName:s});var f=r.find(function(l){return l.thingName===n});F(f)&&(f={thingName:n,operations:[]},r.push(f),i.subscribe([Tt(n,"$next/get/accepted"),Tt(n,"notify-next")],function(l,u){F(l)||o(l)}));var a=f.operations.find(function(l){return F(s)?F(l.operationName):s===l.operationName});F(a)?(a={operationName:s,callback:o},f.operations.push(a)):a.callback=o},this.unsubscribeFromJobs=function(n,s,o){F(o)&&(o=s,s=null),!F(e)&&e.debug===!0&&console.log("unsubscribeFromJobs:",{thingName:n,operationName:s});var f=r.findIndex(function(u){return u.thingName===n}),a=new Error("subscription not found for given thing");if(f<0){o(a);return}var l=r[f].operations.findIndex(function(u){return F(s)?F(u.operationName):s===u.operationName});if(l<0){o(a);return}if(r[f].operations.splice(l,1),r[f].operations.length===0){r.splice(f,1),i.unsubscribe([Tt(n,"$next/get/accepted"),Tt(n,"notify-next")],o);return}o()},this.startJobNotifications=function(n,s){!F(e)&&e.debug===!0&&console.log("startJobNotifications:",{thingName:n}),i.publish(Tt(n,"$next","get"),"{}",s)},i.on("connect",function(){t.emit("connect")}),i.on("close",function(){t.emit("close")}),i.on("reconnect",function(){t.emit("reconnect")}),i.on("offline",function(){t.emit("offline")}),i.on("error",function(n){t.emit("error",n)}),i.on("message",t._handleMessages),this.publish=i.publish,this.subscribe=i.subscribe,this.unsubscribe=i.unsubscribe,this.end=i.end,this.handleMessage=i.handleMessage,this.updateWebSocketCredentials=i.updateWebSocketCredentials,this.simulateNetworkFailure=i.simulateNetworkFailure}ny(xi,iy.EventEmitter);yu.exports=xi});var mu=b((om,Ci)=>{Ci.exports.device=Si();Ci.exports.thingShadow=bu();Ci.exports.jobs=vu()});var dy={};Lu(dy,{handler:()=>hy});module.exports=Uu(dy);var wu=Du(mu(),1),ay=["PATH","NODE_PATH","LD_LIBRARY_PATH","PWD","SHLVL"],fy=Object.fromEntries(Object.entries(process.env).filter(([e])=>!ay.includes(e))),Is=e=>{let t=process.env.AWS_REGION,r=process.env.SLS_SERVICE,i=process.env.SLS_STAGE,n=`sls/${t}/${r}/${i}`;return e&&(n+=`/${e}`),n},at={request:Is(`${process.env.SLS_FUNCTION}/request`),response:Is(`${process.env.SLS_FUNCTION}/response`),heartbeat:Is("_heartbeat")},It=new Map,ft=new wu.default.device({protocol:"wss",host:process.env.SLS_IOT_ENDPOINT});ft.on("connect",()=>{console.log("Successfully connected to AWS IoT")});ft.on("close",(...e)=>{console.log("AWS IoT connection closed"),console.log(e)});ft.on("error",(...e)=>{console.error("AWS IoT connection error occurred"),console.error(e)});ft.on("message",async(e,t)=>{let r=JSON.parse(t?.toString()||"{}");console.log("Received message from AWS IoT:"),console.log(e),e===at.heartbeat&&It.set(at.heartbeat,Date.now()),e===at.response&&r.requestId&&It.set(r.requestId,r)});ft.subscribe(at.heartbeat,{qos:1});ft.subscribe(at.response,{qos:1});var Su=(e=1e3)=>new Promise(t=>{setTimeout(()=>t(),e)}),Eu=async()=>{await Su(2e3);let e=It.get(at.heartbeat);return e&&Date.now()-e<2e3?await Eu():"Dev Mode Disconnected: This AWS Lambda function is instrumented with Serverless Framework's Dev Mode but the Dev Mode session is no longer active. Run `serverless dev` to reconnect, or `serverless deploy` to remove Dev Mode's instrumentation and restore the original code."},ly=async e=>{let{response:t,error:r}=await uy(e);if(r){console.error("Error occurred during lambda invocation on the local machine:");let i=new Error(r.message);throw i.stack=r.stack,i.name=r.name,i}return t},uy=async e=>{for(;!It.get(e);)await Su(100);let t=It.get(e);return It.delete(e),t},cy=async(e,t)=>new Promise((r,i)=>{ft.publish(e,t?JSON.stringify(t):"{}",{qos:1},n=>{n?(console.error(`Failed to publish message to AWS IoT: ${n.message}`),i(n)):(console.log("Message successfully published to AWS IoT topic:"),console.log(e),r(t))})}),hy=async(e,t)=>{let{functionName:r,functionVersion:i,memoryLimitInMB:n,logGroupName:s,logStreamName:o,clientContext:f,identity:a,invokedFunctionArn:l,awsRequestId:u,callbackWaitsForEmptyEventLoop:h}=t;return await cy(at.request,{event:e,environment:fy,context:{awsRequestId:u,functionName:r,functionVersion:i,memoryLimitInMB:n,logGroupName:s,logStreamName:o,clientContext:f,identity:a,invokedFunctionArn:l,callbackWaitsForEmptyEventLoop:h}}),await Promise.race([ly(u),Eu()])};0&&(module.exports={handler});
|
|
/*! Bundled license information:
|
|
|
|
safe-buffer/index.js:
|
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
*/
|