@sebbo2002/vestaboard2mqtt 6.0.6-develop.2 → 7.0.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1 @@
1
- "use strict";var Su=Object.create;var hr=Object.defineProperty;var Eu=Object.getOwnPropertyDescriptor;var xu=Object.getOwnPropertyNames;var Tu=Object.getPrototypeOf,Cu=Object.prototype.hasOwnProperty;var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Gn=(t,e)=>{for(var r in e)hr(t,r,{get:e[r],enumerable:!0})},Qn=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of xu(e))!Cu.call(t,n)&&n!==r&&hr(t,n,{get:()=>e[n],enumerable:!(i=Eu(e,n))||i.enumerable});return t};var ui=(t,e,r)=>(r=t!=null?Su(Tu(t)):{},Qn(e||!t||!t.__esModule?hr(r,"default",{value:t,enumerable:!0}):r,t)),Yn=t=>Qn(hr({},"__esModule",{value:!0}),t);var dr=g((Yg,Xn)=>{"use strict";Xn.exports=Ou;var Pu=Object.prototype.hasOwnProperty;function Ou(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var i in r)Pu.call(r,i)&&(t[i]=r[i])}return t}});var fi=g((Xg,Jn)=>{"use strict";Jn.exports=require("stream")});var rs=g((Jg,ts)=>{"use strict";function Zn(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,i)}return r}function Iu(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Zn(Object(r),!0).forEach(function(i){Ru(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Zn(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function Ru(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Au(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function es(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Bu(t,e,r){return e&&es(t.prototype,e),r&&es(t,r),t}var ku=require("buffer"),pr=ku.Buffer,Lu=require("util"),ci=Lu.inspect,Mu=ci&&ci.custom||"inspect";function qu(t,e,r){pr.prototype.copy.call(t,e,r)}ts.exports=(function(){function t(){Au(this,t),this.head=null,this.tail=null,this.length=0}return Bu(t,[{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 pr.alloc(0);for(var i=pr.allocUnsafe(r>>>0),n=this.head,s=0;n;)qu(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,a=r>o.length?o.length:r;if(a===o.length?s+=o:s+=o.slice(0,r),r-=a,r===0){a===o.length?(++n,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=o.slice(a));break}++n}return this.length-=n,s}},{key:"_getBuffer",value:function(r){var i=pr.allocUnsafe(r),n=this.head,s=1;for(n.data.copy(i),r-=n.data.length;n=n.next;){var o=n.data,a=r>o.length?o.length:r;if(o.copy(i,i.length-r,0,a),r-=a,r===0){a===o.length?(++s,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(a));break}++s}return this.length-=s,i}},{key:Mu,value:function(r,i){return ci(this,Iu({},i,{depth:0,customInspect:!1}))}}]),t})()});var di=g((Zg,ns)=>{"use strict";function Nu(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return i||n?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(hi,this,t)):process.nextTick(hi,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(s){!e&&s?r._writableState?r._writableState.errorEmitted?process.nextTick(gr,r):(r._writableState.errorEmitted=!0,process.nextTick(is,r,s)):process.nextTick(is,r,s):e?(process.nextTick(gr,r),e(s)):process.nextTick(gr,r)}),this)}function is(t,e){hi(t,e),gr(t)}function gr(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function Du(){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 hi(t,e){t.emit("error",e)}function Uu(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}ns.exports={destroy:Nu,undestroy:Du,errorOrDestroy:Uu}});var Be=g((ey,as)=>{"use strict";var os={};function ne(t,e,r){r||(r=Error);function i(s,o,a){return typeof e=="string"?e:e(s,o,a)}class n extends r{constructor(o,a,u){super(i(o,a,u))}}n.prototype.name=r.name,n.prototype.code=t,os[t]=n}function ss(t,e){if(Array.isArray(t)){let r=t.length;return t=t.map(i=>String(i)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}else return`of ${e} ${String(t)}`}function ju(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function Fu(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function Wu(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}ne("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);ne("ERR_INVALID_ARG_TYPE",function(t,e,r){let i;typeof e=="string"&&ju(e,"not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be";let n;if(Fu(t," argument"))n=`The ${t} ${i} ${ss(e,"type")}`;else{let s=Wu(t,".")?"property":"argument";n=`The "${t}" ${s} ${i} ${ss(e,"type")}`}return n+=`. Received type ${typeof r}`,n},TypeError);ne("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");ne("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});ne("ERR_STREAM_PREMATURE_CLOSE","Premature close");ne("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});ne("ERR_MULTIPLE_CALLBACK","Callback called multiple times");ne("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");ne("ERR_STREAM_WRITE_AFTER_END","write after end");ne("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);ne("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);ne("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");as.exports.codes=os});var pi=g((ty,ls)=>{"use strict";var Vu=Be().codes.ERR_INVALID_OPT_VALUE;function Hu(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Ku(t,e,r,i){var n=Hu(e,i,r);if(n!=null){if(!(isFinite(n)&&Math.floor(n)===n)||n<0){var s=i?r:"highWaterMark";throw new Vu(s,n)}return Math.floor(n)}return t.objectMode?16:16*1024}ls.exports={getHighWaterMark:Ku}});var us=g((ry,gi)=>{"use strict";typeof Object.create=="function"?gi.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:gi.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}}});var we=g((iy,_i)=>{"use strict";try{if(yi=require("util"),typeof yi.inherits!="function")throw"";_i.exports=yi.inherits}catch{_i.exports=us()}var yi});var cs=g((ny,fs)=>{"use strict";fs.exports=require("util").deprecate});var bi=g((sy,_s)=>{"use strict";_s.exports=L;function ds(t){var e=this;this.next=null,this.entry=null,this.finish=function(){vf(e,t)}}var yt;L.WritableState=Lt;var zu={deprecate:cs()},ps=fi(),_r=require("buffer").Buffer,$u=global.Uint8Array||function(){};function Gu(t){return _r.from(t)}function Qu(t){return _r.isBuffer(t)||t instanceof $u}var vi=di(),Yu=pi(),Xu=Yu.getHighWaterMark,ke=Be().codes,Ju=ke.ERR_INVALID_ARG_TYPE,Zu=ke.ERR_METHOD_NOT_IMPLEMENTED,ef=ke.ERR_MULTIPLE_CALLBACK,tf=ke.ERR_STREAM_CANNOT_PIPE,rf=ke.ERR_STREAM_DESTROYED,nf=ke.ERR_STREAM_NULL_VALUES,sf=ke.ERR_STREAM_WRITE_AFTER_END,of=ke.ERR_UNKNOWN_ENCODING,_t=vi.errorOrDestroy;we()(L,ps);function af(){}function Lt(t,e,r){yt=yt||Je(),t=t||{},typeof r!="boolean"&&(r=e instanceof yt),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=Xu(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=t.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(n){pf(e,n)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new ds(this)}Lt.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(Lt.prototype,"buffer",{get:zu.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var yr;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(yr=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(e){return yr.call(this,e)?!0:this!==L?!1:e&&e._writableState instanceof Lt}})):yr=function(e){return e instanceof this};function L(t){yt=yt||Je();var e=this instanceof yt;if(!e&&!yr.call(L,this))return new L(t);this._writableState=new Lt(t,this,e),this.writable=!0,t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final)),ps.call(this)}L.prototype.pipe=function(){_t(this,new tf)};function lf(t,e){var r=new sf;_t(t,r),process.nextTick(e,r)}function uf(t,e,r,i){var n;return r===null?n=new nf:typeof r!="string"&&!e.objectMode&&(n=new Ju("chunk",["string","Buffer"],r)),n?(_t(t,n),process.nextTick(i,n),!1):!0}L.prototype.write=function(t,e,r){var i=this._writableState,n=!1,s=!i.objectMode&&Qu(t);return s&&!_r.isBuffer(t)&&(t=Gu(t)),typeof e=="function"&&(r=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),typeof r!="function"&&(r=af),i.ending?lf(this,r):(s||uf(this,i,t,r))&&(i.pendingcb++,n=cf(this,i,s,t,e,r)),n};L.prototype.cork=function(){this._writableState.corked++};L.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&gs(this,t))};L.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new of(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function ff(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=_r.from(e,r)),e}Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function cf(t,e,r,i,n,s){if(!r){var o=ff(e,i,n);i!==o&&(r=!0,n="buffer",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:s,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else mi(t,e,!1,a,i,n,s);return u}function mi(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new rf("write")):r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function hf(t,e,r,i,n){--e.pendingcb,r?(process.nextTick(n,i),process.nextTick(kt,t,e),t._writableState.errorEmitted=!0,_t(t,i)):(n(i),t._writableState.errorEmitted=!0,_t(t,i),kt(t,e))}function df(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function pf(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if(typeof n!="function")throw new ef;if(df(r),e)hf(t,r,i,e,n);else{var s=ys(r)||t.destroyed;!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&gs(t,r),i?process.nextTick(hs,t,r,s,n):hs(t,r,s,n)}}function hs(t,e,r,i){r||gf(t,e),e.pendingcb--,i(),kt(t,e)}function gf(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function gs(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var o=0,a=!0;r;)n[o]=r,r.isBuf||(a=!1),r=r.next,o+=1;n.allBuffers=a,mi(t,e,!0,e.length,n,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new ds(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,f=r.callback,h=e.objectMode?1:u.length;if(mi(t,e,!1,h,u,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}r===null&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}L.prototype._write=function(t,e,r){r(new Zu("_write()"))};L.prototype._writev=null;L.prototype.end=function(t,e,r){var i=this._writableState;return typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null),t!=null&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||mf(this,i,r),this};Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function ys(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}function yf(t,e){t._final(function(r){e.pendingcb--,r&&_t(t,r),e.prefinished=!0,t.emit("prefinish"),kt(t,e)})}function _f(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(yf,t,e)):(e.prefinished=!0,t.emit("prefinish")))}function kt(t,e){var r=ys(e);if(r&&(_f(t,e),e.pendingcb===0&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}function mf(t,e,r){e.ending=!0,kt(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}function vf(t,e,r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});L.prototype.destroy=vi.destroy;L.prototype._undestroy=vi.undestroy;L.prototype._destroy=function(t,e){e(t)}});var Je=g((oy,vs)=>{"use strict";var bf=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};vs.exports=ge;var ms=Ei(),Si=bi();we()(ge,ms);for(wi=bf(Si.prototype),mr=0;mr<wi.length;mr++)vr=wi[mr],ge.prototype[vr]||(ge.prototype[vr]=Si.prototype[vr]);var wi,vr,mr;function ge(t){if(!(this instanceof ge))return new ge(t);ms.call(this,t),Si.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",wf)))}Object.defineProperty(ge.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(ge.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(ge.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function wf(){this._writableState.ended||process.nextTick(Sf,this)}function Sf(t){t.end()}Object.defineProperty(ge.prototype,"destroyed",{enumerable:!1,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)}})});var Ss=g((xi,ws)=>{"use strict";var br=require("buffer"),ye=br.Buffer;function bs(t,e){for(var r in t)e[r]=t[r]}ye.from&&ye.alloc&&ye.allocUnsafe&&ye.allocUnsafeSlow?ws.exports=br:(bs(br,xi),xi.Buffer=Ze);function Ze(t,e,r){return ye(t,e,r)}Ze.prototype=Object.create(ye.prototype);bs(ye,Ze);Ze.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return ye(t,e,r)};Ze.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var i=ye(t);return e!==void 0?typeof r=="string"?i.fill(e,r):i.fill(e):i.fill(0),i};Ze.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return ye(t)};Ze.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return br.SlowBuffer(t)}});var Pi=g(xs=>{"use strict";var Ci=Ss().Buffer,Es=Ci.isEncoding||function(t){switch(t=""+t,t&&t.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 Ef(t){if(!t)return"utf8";for(var e;;)switch(t){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 t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function xf(t){var e=Ef(t);if(typeof e!="string"&&(Ci.isEncoding===Es||!Es(t)))throw new Error("Unknown encoding: "+t);return e||t}xs.StringDecoder=Mt;function Mt(t){this.encoding=xf(t);var e;switch(this.encoding){case"utf16le":this.text=Rf,this.end=Af,e=4;break;case"utf8":this.fillLast=Pf,e=4;break;case"base64":this.text=Bf,this.end=kf,e=3;break;default:this.write=Lf,this.end=Mf;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ci.allocUnsafe(e)}Mt.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};Mt.prototype.end=If;Mt.prototype.text=Of;Mt.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function Ti(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function Tf(t,e,r){var i=e.length-1;if(i<r)return 0;var n=Ti(e[i]);return n>=0?(n>0&&(t.lastNeed=n-1),n):--i<r||n===-2?0:(n=Ti(e[i]),n>=0?(n>0&&(t.lastNeed=n-2),n):--i<r||n===-2?0:(n=Ti(e[i]),n>=0?(n>0&&(n===2?n=0:t.lastNeed=n-3),n):0))}function Cf(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function Pf(t){var e=this.lastTotal-this.lastNeed,r=Cf(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function Of(t,e){var r=Tf(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)}function If(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Rf(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function Af(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function Bf(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function kf(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function Lf(t){return t.toString(this.encoding)}function Mf(t){return t&&t.length?this.write(t):""}});var wr=g((ly,Ps)=>{"use strict";var Ts=Be().codes.ERR_STREAM_PREMATURE_CLOSE;function qf(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];t.apply(this,i)}}}function Nf(){}function Df(t){return t.setHeader&&typeof t.abort=="function"}function Cs(t,e,r){if(typeof e=="function")return Cs(t,null,e);e||(e={}),r=qf(r||Nf);var i=e.readable||e.readable!==!1&&t.readable,n=e.writable||e.writable!==!1&&t.writable,s=function(){t.writable||a()},o=t._writableState&&t._writableState.finished,a=function(){n=!1,o=!0,i||r.call(t)},u=t._readableState&&t._readableState.endEmitted,l=function(){i=!1,u=!0,n||r.call(t)},f=function(m){r.call(t,m)},h=function(){var m;if(i&&!u)return(!t._readableState||!t._readableState.ended)&&(m=new Ts),r.call(t,m);if(n&&!o)return(!t._writableState||!t._writableState.ended)&&(m=new Ts),r.call(t,m)},c=function(){t.req.on("finish",a)};return Df(t)?(t.on("complete",a),t.on("abort",h),t.req?c():t.on("request",c)):n&&!t._writableState&&(t.on("end",s),t.on("close",s)),t.on("end",l),t.on("finish",a),e.error!==!1&&t.on("error",f),t.on("close",h),function(){t.removeListener("complete",a),t.removeListener("abort",h),t.removeListener("request",c),t.req&&t.req.removeListener("finish",a),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",a),t.removeListener("end",l),t.removeListener("error",f),t.removeListener("close",h)}}Ps.exports=Cs});var Is=g((uy,Os)=>{"use strict";var Sr;function Le(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Uf=wr(),Me=Symbol("lastResolve"),et=Symbol("lastReject"),qt=Symbol("error"),Er=Symbol("ended"),tt=Symbol("lastPromise"),Oi=Symbol("handlePromise"),rt=Symbol("stream");function qe(t,e){return{value:t,done:e}}function jf(t){var e=t[Me];if(e!==null){var r=t[rt].read();r!==null&&(t[tt]=null,t[Me]=null,t[et]=null,e(qe(r,!1)))}}function Ff(t){process.nextTick(jf,t)}function Wf(t,e){return function(r,i){t.then(function(){if(e[Er]){r(qe(void 0,!0));return}e[Oi](r,i)},i)}}var Vf=Object.getPrototypeOf(function(){}),Hf=Object.setPrototypeOf((Sr={get stream(){return this[rt]},next:function(){var e=this,r=this[qt];if(r!==null)return Promise.reject(r);if(this[Er])return Promise.resolve(qe(void 0,!0));if(this[rt].destroyed)return new Promise(function(o,a){process.nextTick(function(){e[qt]?a(e[qt]):o(qe(void 0,!0))})});var i=this[tt],n;if(i)n=new Promise(Wf(i,this));else{var s=this[rt].read();if(s!==null)return Promise.resolve(qe(s,!1));n=new Promise(this[Oi])}return this[tt]=n,n}},Le(Sr,Symbol.asyncIterator,function(){return this}),Le(Sr,"return",function(){var e=this;return new Promise(function(r,i){e[rt].destroy(null,function(n){if(n){i(n);return}r(qe(void 0,!0))})})}),Sr),Vf),Kf=function(e){var r,i=Object.create(Hf,(r={},Le(r,rt,{value:e,writable:!0}),Le(r,Me,{value:null,writable:!0}),Le(r,et,{value:null,writable:!0}),Le(r,qt,{value:null,writable:!0}),Le(r,Er,{value:e._readableState.endEmitted,writable:!0}),Le(r,Oi,{value:function(s,o){var a=i[rt].read();a?(i[tt]=null,i[Me]=null,i[et]=null,s(qe(a,!1))):(i[Me]=s,i[et]=o)},writable:!0}),r));return i[tt]=null,Uf(e,function(n){if(n&&n.code!=="ERR_STREAM_PREMATURE_CLOSE"){var s=i[et];s!==null&&(i[tt]=null,i[Me]=null,i[et]=null,s(n)),i[qt]=n;return}var o=i[Me];o!==null&&(i[tt]=null,i[Me]=null,i[et]=null,o(qe(void 0,!0))),i[Er]=!0}),e.on("readable",Ff.bind(null,i)),i};Os.exports=Kf});var ks=g((fy,Bs)=>{"use strict";function Rs(t,e,r,i,n,s,o){try{var a=t[s](o),u=a.value}catch(l){r(l);return}a.done?e(u):Promise.resolve(u).then(i,n)}function zf(t){return function(){var e=this,r=arguments;return new Promise(function(i,n){var s=t.apply(e,r);function o(u){Rs(s,i,n,o,a,"next",u)}function a(u){Rs(s,i,n,o,a,"throw",u)}o(void 0)})}}function As(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,i)}return r}function $f(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?As(Object(r),!0).forEach(function(i){Gf(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):As(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function Gf(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Qf=Be().codes.ERR_INVALID_ARG_TYPE;function Yf(t,e,r){var i;if(e&&typeof e.next=="function")i=e;else if(e&&e[Symbol.asyncIterator])i=e[Symbol.asyncIterator]();else if(e&&e[Symbol.iterator])i=e[Symbol.iterator]();else throw new Qf("iterable",["Iterable"],e);var n=new t($f({objectMode:!0},r)),s=!1;n._read=function(){s||(s=!0,o())};function o(){return a.apply(this,arguments)}function a(){return a=zf(function*(){try{var u=yield i.next(),l=u.value,f=u.done;f?n.push(null):n.push(yield l)?o():s=!1}catch(h){n.destroy(h)}}),a.apply(this,arguments)}return n}Bs.exports=Yf});var Ei=g((hy,Vs)=>{"use strict";Vs.exports=P;var mt;P.ReadableState=Ns;var cy=require("events").EventEmitter,qs=function(e,r){return e.listeners(r).length},Dt=fi(),xr=require("buffer").Buffer,Xf=global.Uint8Array||function(){};function Jf(t){return xr.from(t)}function Zf(t){return xr.isBuffer(t)||t instanceof Xf}var Ii=require("util"),x;Ii&&Ii.debuglog?x=Ii.debuglog("stream"):x=function(){};var ec=rs(),qi=di(),tc=pi(),rc=tc.getHighWaterMark,Tr=Be().codes,ic=Tr.ERR_INVALID_ARG_TYPE,nc=Tr.ERR_STREAM_PUSH_AFTER_EOF,sc=Tr.ERR_METHOD_NOT_IMPLEMENTED,oc=Tr.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,vt,Ri,Ai;we()(P,Dt);var Nt=qi.errorOrDestroy,Bi=["error","close","destroy","pause","resume"];function ac(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function Ns(t,e,r){mt=mt||Je(),t=t||{},typeof r!="boolean"&&(r=e instanceof mt),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=rc(this,t,"readableHighWaterMark",r),this.buffer=new ec,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=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(vt||(vt=Pi().StringDecoder),this.decoder=new vt(t.encoding),this.encoding=t.encoding)}function P(t){if(mt=mt||Je(),!(this instanceof P))return new P(t);var e=this instanceof mt;this._readableState=new Ns(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),Dt.call(this)}Object.defineProperty(P.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});P.prototype.destroy=qi.destroy;P.prototype._undestroy=qi.undestroy;P.prototype._destroy=function(t,e){e(t)};P.prototype.push=function(t,e){var r=this._readableState,i;return r.objectMode?i=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=xr.from(t,e),e=""),i=!0),Ds(this,t,e,!1,i)};P.prototype.unshift=function(t){return Ds(this,t,null,!0,!1)};function Ds(t,e,r,i,n){x("readableAddChunk",e);var s=t._readableState;if(e===null)s.reading=!1,fc(t,s);else{var o;if(n||(o=lc(s,e)),o)Nt(t,o);else if(s.objectMode||e&&e.length>0)if(typeof e!="string"&&!s.objectMode&&Object.getPrototypeOf(e)!==xr.prototype&&(e=Jf(e)),i)s.endEmitted?Nt(t,new oc):ki(t,s,e,!0);else if(s.ended)Nt(t,new nc);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||e.length!==0?ki(t,s,e,!1):Mi(t,s)):ki(t,s,e,!1)}else i||(s.reading=!1,Mi(t,s))}return!s.ended&&(s.length<s.highWaterMark||s.length===0)}function ki(t,e,r,i){e.flowing&&e.length===0&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&Cr(t)),Mi(t,e)}function lc(t,e){var r;return!Zf(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new ic("chunk",["string","Buffer","Uint8Array"],e)),r}P.prototype.isPaused=function(){return this._readableState.flowing===!1};P.prototype.setEncoding=function(t){vt||(vt=Pi().StringDecoder);var e=new vt(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";r!==null;)i+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),i!==""&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var Ls=1073741824;function uc(t){return t>=Ls?t=Ls:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function Ms(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=uc(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}P.prototype.read=function(t){x("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return x("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Li(this):Cr(this),null;if(t=Ms(t,e),t===0&&e.ended)return e.length===0&&Li(this),null;var i=e.needReadable;x("need readable",i),(e.length===0||e.length-t<e.highWaterMark)&&(i=!0,x("length less than watermark",i)),e.ended||e.reading?(i=!1,x("reading or ended",i)):i&&(x("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=Ms(r,e)));var n;return t>0?n=Fs(t,e):n=null,n===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&Li(this)),n!==null&&this.emit("data",n),n};function fc(t,e){if(x("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?Cr(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,Us(t)))}}function Cr(t){var e=t._readableState;x("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(x("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(Us,t))}function Us(t){var e=t._readableState;x("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Ni(t)}function Mi(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(cc,t,e))}function cc(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(x("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}P.prototype._read=function(t){Nt(this,new sc("_read()"))};P.prototype.pipe=function(t,e){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t);break}i.pipesCount+=1,x("pipe count=%d opts=%j",i.pipesCount,e);var n=(!e||e.end!==!1)&&t!==process.stdout&&t!==process.stderr,s=n?a:y;i.endEmitted?process.nextTick(s):r.once("end",s),t.on("unpipe",o);function o(v,b){x("onunpipe"),v===r&&b&&b.hasUnpiped===!1&&(b.hasUnpiped=!0,f())}function a(){x("onend"),t.end()}var u=hc(r);t.on("drain",u);var l=!1;function f(){x("cleanup"),t.removeListener("close",d),t.removeListener("finish",m),t.removeListener("drain",u),t.removeListener("error",c),t.removeListener("unpipe",o),r.removeListener("end",a),r.removeListener("end",y),r.removeListener("data",h),l=!0,i.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u()}r.on("data",h);function h(v){x("ondata");var b=t.write(v);x("dest.write",b),b===!1&&((i.pipesCount===1&&i.pipes===t||i.pipesCount>1&&Ws(i.pipes,t)!==-1)&&!l&&(x("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function c(v){x("onerror",v),y(),t.removeListener("error",c),qs(t,"error")===0&&Nt(t,v)}ac(t,"error",c);function d(){t.removeListener("finish",m),y()}t.once("close",d);function m(){x("onfinish"),t.removeListener("close",d),y()}t.once("finish",m);function y(){x("unpipe"),r.unpipe(t)}return t.emit("pipe",r),i.flowing||(x("pipe resume"),r.resume()),t};function hc(t){return function(){var r=t._readableState;x("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&qs(t,"data")&&(r.flowing=!0,Ni(t))}}P.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s<n;s++)i[s].emit("unpipe",this,{hasUnpiped:!1});return this}var o=Ws(e.pipes,t);return o===-1?this:(e.pipes.splice(o,1),e.pipesCount-=1,e.pipesCount===1&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r),this)};P.prototype.on=function(t,e){var r=Dt.prototype.on.call(this,t,e),i=this._readableState;return t==="data"?(i.readableListening=this.listenerCount("readable")>0,i.flowing!==!1&&this.resume()):t==="readable"&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,x("on readable",i.length,i.reading),i.length?Cr(this):i.reading||process.nextTick(dc,this)),r};P.prototype.addListener=P.prototype.on;P.prototype.removeListener=function(t,e){var r=Dt.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(js,this),r};P.prototype.removeAllListeners=function(t){var e=Dt.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(js,this),e};function js(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function dc(t){x("readable nexttick read 0"),t.read(0)}P.prototype.resume=function(){var t=this._readableState;return t.flowing||(x("resume"),t.flowing=!t.readableListening,pc(this,t)),t.paused=!1,this};function pc(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(gc,t,e))}function gc(t,e){x("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Ni(t),e.flowing&&!e.reading&&t.read(0)}P.prototype.pause=function(){return x("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(x("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Ni(t){var e=t._readableState;for(x("flow",e.flowing);e.flowing&&t.read()!==null;);}P.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;t.on("end",function(){if(x("wrapped end"),r.decoder&&!r.ended){var o=r.decoder.end();o&&o.length&&e.push(o)}e.push(null)}),t.on("data",function(o){if(x("wrapped data"),r.decoder&&(o=r.decoder.write(o)),!(r.objectMode&&o==null)&&!(!r.objectMode&&(!o||!o.length))){var a=e.push(o);a||(i=!0,t.pause())}});for(var n in t)this[n]===void 0&&typeof t[n]=="function"&&(this[n]=(function(a){return function(){return t[a].apply(t,arguments)}})(n));for(var s=0;s<Bi.length;s++)t.on(Bi[s],this.emit.bind(this,Bi[s]));return this._read=function(o){x("wrapped _read",o),i&&(i=!1,t.resume())},this};typeof Symbol=="function"&&(P.prototype[Symbol.asyncIterator]=function(){return Ri===void 0&&(Ri=Is()),Ri(this)});Object.defineProperty(P.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(P.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(P.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}});P._fromList=Fs;Object.defineProperty(P.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function Fs(t,e){if(e.length===0)return null;var r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function Li(t){var e=t._readableState;x("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(yc,e,t))}function yc(t,e){if(x("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}typeof Symbol=="function"&&(P.from=function(t,e){return Ai===void 0&&(Ai=ks()),Ai(P,t,e)});function Ws(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}});var Di=g((dy,Ks)=>{"use strict";Ks.exports=Se;var Pr=Be().codes,_c=Pr.ERR_METHOD_NOT_IMPLEMENTED,mc=Pr.ERR_MULTIPLE_CALLBACK,vc=Pr.ERR_TRANSFORM_ALREADY_TRANSFORMING,bc=Pr.ERR_TRANSFORM_WITH_LENGTH_0,Or=Je();we()(Se,Or);function wc(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new mc);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function Se(t){if(!(this instanceof Se))return new Se(t);Or.call(this,t),this._transformState={afterTransform:wc.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",Sc)}function Sc(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){Hs(t,e,r)}):Hs(this,null,null)}Se.prototype.push=function(t,e){return this._transformState.needTransform=!1,Or.prototype.push.call(this,t,e)};Se.prototype._transform=function(t,e,r){r(new _c("_transform()"))};Se.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}};Se.prototype._read=function(t){var e=this._transformState;e.writechunk!==null&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0};Se.prototype._destroy=function(t,e){Or.prototype._destroy.call(this,t,function(r){e(r)})};function Hs(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new bc;if(t._transformState.transforming)throw new vc;return t.push(null)}});var Gs=g((py,$s)=>{"use strict";$s.exports=Ut;var zs=Di();we()(Ut,zs);function Ut(t){if(!(this instanceof Ut))return new Ut(t);zs.call(this,t)}Ut.prototype._transform=function(t,e,r){r(null,t)}});var Zs=g((gy,Js)=>{"use strict";var Ui;function Ec(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var Xs=Be().codes,xc=Xs.ERR_MISSING_ARGS,Tc=Xs.ERR_STREAM_DESTROYED;function Qs(t){if(t)throw t}function Cc(t){return t.setHeader&&typeof t.abort=="function"}function Pc(t,e,r,i){i=Ec(i);var n=!1;t.on("close",function(){n=!0}),Ui===void 0&&(Ui=wr()),Ui(t,{readable:e,writable:r},function(o){if(o)return i(o);n=!0,i()});var s=!1;return function(o){if(!n&&!s){if(s=!0,Cc(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();i(o||new Tc("pipe"))}}}function Ys(t){t()}function Oc(t,e){return t.pipe(e)}function Ic(t){return!t.length||typeof t[t.length-1]!="function"?Qs:t.pop()}function Rc(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i=Ic(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new xc("streams");var n,s=e.map(function(o,a){var u=a<e.length-1,l=a>0;return Pc(o,u,l,function(f){n||(n=f),f&&s.forEach(Ys),!u&&(s.forEach(Ys),i(n))})});return e.reduce(Oc)}Js.exports=Rc});var Ne=g((se,Ft)=>{"use strict";var jt=require("stream");process.env.READABLE_STREAM==="disable"&&jt?(Ft.exports=jt.Readable,Object.assign(Ft.exports,jt),Ft.exports.Stream=jt):(se=Ft.exports=Ei(),se.Stream=jt||se,se.Readable=se,se.Writable=bi(),se.Duplex=Je(),se.Transform=Di(),se.PassThrough=Gs(),se.finished=wr(),se.pipeline=Zs())});var Ir=g((yy,eo)=>{"use strict";var Ac=dr(),Bc=Ne().Readable,kc={objectMode:!0},Lc={clean:!0};function De(t){if(!(this instanceof De))return new De(t);this.options=t||{},this.options=Ac(Lc,t),this._inflights=new Map}De.prototype.put=function(t,e){return this._inflights.set(t.messageId,t),e&&e(),this};De.prototype.createStream=function(){let t=new Bc(kc),e=[],r=!1,i=0;return this._inflights.forEach(function(n,s){e.push(n)}),t._read=function(){!r&&i<e.length?this.push(e[i++]):this.push(null)},t.destroy=function(){if(r)return;let n=this;r=!0,setTimeout(function(){n.emit("close")},0)},t};De.prototype.del=function(t,e){return t=this._inflights.get(t.messageId),t?(this._inflights.delete(t.messageId),e(null,t)):e&&e(new Error("missing packet")),this};De.prototype.get=function(t,e){return t=this._inflights.get(t.messageId),t?e(null,t):e&&e(new Error("missing packet")),this};De.prototype.close=function(t){this.options.clean&&(this._inflights=null),t&&t()};eo.exports=De});var ro=g((_y,to)=>{"use strict";function bt(t){if(!(this instanceof bt))return new bt(t);this.aliasToTopic={},this.max=t}bt.prototype.put=function(t,e){return e===0||e>this.max?!1:(this.aliasToTopic[e]=t,this.length=Object.keys(this.aliasToTopic).length,!0)};bt.prototype.getTopicByAlias=function(t){return this.aliasToTopic[t]};bt.prototype.clear=function(){this.aliasToTopic={}};to.exports=bt});var no=g((my,io)=>{"use strict";io.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var oo=g((vy,so)=>{"use strict";so.exports=O;O.Node=it;O.create=O;function O(t){var e=this;if(e instanceof O||(e=new O),e.tail=null,e.head=null,e.length=0,t&&typeof t.forEach=="function")t.forEach(function(n){e.push(n)});else if(arguments.length>0)for(var r=0,i=arguments.length;r<i;r++)e.push(arguments[r]);return e}O.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e};O.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}};O.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}};O.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)qc(this,arguments[t]);return this.length};O.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)Nc(this,arguments[t]);return this.length};O.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}};O.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}};O.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,i=0;r!==null;i++)t.call(e,r.value,i,this),r=r.next};O.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,i=this.length-1;r!==null;i--)t.call(e,r.value,i,this),r=r.prev};O.prototype.get=function(t){for(var e=0,r=this.head;r!==null&&e<t;e++)r=r.next;if(e===t&&r!==null)return r.value};O.prototype.getReverse=function(t){for(var e=0,r=this.tail;r!==null&&e<t;e++)r=r.prev;if(e===t&&r!==null)return r.value};O.prototype.map=function(t,e){e=e||this;for(var r=new O,i=this.head;i!==null;)r.push(t.call(e,i.value,this)),i=i.next;return r};O.prototype.mapReverse=function(t,e){e=e||this;for(var r=new O,i=this.tail;i!==null;)r.push(t.call(e,i.value,this)),i=i.prev;return r};O.prototype.reduce=function(t,e){var r,i=this.head;if(arguments.length>1)r=e;else if(this.head)i=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=0;i!==null;n++)r=t(r,i.value,n),i=i.next;return r};O.prototype.reduceReverse=function(t,e){var r,i=this.tail;if(arguments.length>1)r=e;else if(this.tail)i=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var n=this.length-1;i!==null;n--)r=t(r,i.value,n),i=i.prev;return r};O.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;r!==null;e++)t[e]=r.value,r=r.next;return t};O.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;r!==null;e++)t[e]=r.value,r=r.prev;return t};O.prototype.slice=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new O;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var i=0,n=this.head;n!==null&&i<t;i++)n=n.next;for(;n!==null&&i<e;i++,n=n.next)r.push(n.value);return r};O.prototype.sliceReverse=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new O;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var i=this.length,n=this.tail;n!==null&&i>e;i--)n=n.prev;for(;n!==null&&i>t;i--,n=n.prev)r.push(n.value);return r};O.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var i=0,n=this.head;n!==null&&i<t;i++)n=n.next;for(var s=[],i=0;n&&i<e;i++)s.push(n.value),n=this.removeNode(n);n===null&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev);for(var i=0;i<r.length;i++)n=Mc(this,n,r[i]);return s};O.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;r!==null;r=r.prev){var i=r.prev;r.prev=r.next,r.next=i}return this.head=e,this.tail=t,this};function Mc(t,e,r){var i=e===t.head?new it(r,null,e,t):new it(r,e,e.next,t);return i.next===null&&(t.tail=i),i.prev===null&&(t.head=i),t.length++,i}function qc(t,e){t.tail=new it(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function Nc(t,e){t.head=new it(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function it(t,e,r,i){if(!(this instanceof it))return new it(t,e,r,i);this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}try{no()(O)}catch{}});var co=g((by,fo)=>{"use strict";var Dc=oo(),nt=Symbol("max"),xe=Symbol("length"),wt=Symbol("lengthCalculator"),Vt=Symbol("allowStale"),st=Symbol("maxAge"),Ee=Symbol("dispose"),ao=Symbol("noDisposeOnSet"),W=Symbol("lruList"),ue=Symbol("cache"),uo=Symbol("updateAgeOnGet"),ji=()=>1,Wi=class{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");let r=this[nt]=e.max||1/0,i=e.length||ji;if(this[wt]=typeof i!="function"?ji:i,this[Vt]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[st]=e.maxAge||0,this[Ee]=e.dispose,this[ao]=e.noDisposeOnSet||!1,this[uo]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[nt]=e||1/0,Wt(this)}get max(){return this[nt]}set allowStale(e){this[Vt]=!!e}get allowStale(){return this[Vt]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[st]=e,Wt(this)}get maxAge(){return this[st]}set lengthCalculator(e){typeof e!="function"&&(e=ji),e!==this[wt]&&(this[wt]=e,this[xe]=0,this[W].forEach(r=>{r.length=this[wt](r.value,r.key),this[xe]+=r.length})),Wt(this)}get lengthCalculator(){return this[wt]}get length(){return this[xe]}get itemCount(){return this[W].length}rforEach(e,r){r=r||this;for(let i=this[W].tail;i!==null;){let n=i.prev;lo(this,e,i,r),i=n}}forEach(e,r){r=r||this;for(let i=this[W].head;i!==null;){let n=i.next;lo(this,e,i,r),i=n}}keys(){return this[W].toArray().map(e=>e.key)}values(){return this[W].toArray().map(e=>e.value)}reset(){this[Ee]&&this[W]&&this[W].length&&this[W].forEach(e=>this[Ee](e.key,e.value)),this[ue]=new Map,this[W]=new Dc,this[xe]=0}dump(){return this[W].map(e=>Rr(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[W]}set(e,r,i){if(i=i||this[st],i&&typeof i!="number")throw new TypeError("maxAge must be a number");let n=i?Date.now():0,s=this[wt](r,e);if(this[ue].has(e)){if(s>this[nt])return St(this,this[ue].get(e)),!1;let u=this[ue].get(e).value;return this[Ee]&&(this[ao]||this[Ee](e,u.value)),u.now=n,u.maxAge=i,u.value=r,this[xe]+=s-u.length,u.length=s,this.get(e),Wt(this),!0}let o=new Vi(e,r,s,n,i);return o.length>this[nt]?(this[Ee]&&this[Ee](e,r),!1):(this[xe]+=o.length,this[W].unshift(o),this[ue].set(e,this[W].head),Wt(this),!0)}has(e){if(!this[ue].has(e))return!1;let r=this[ue].get(e).value;return!Rr(this,r)}get(e){return Fi(this,e,!0)}peek(e){return Fi(this,e,!1)}pop(){let e=this[W].tail;return e?(St(this,e),e.value):null}del(e){St(this,this[ue].get(e))}load(e){this.reset();let r=Date.now();for(let i=e.length-1;i>=0;i--){let n=e[i],s=n.e||0;if(s===0)this.set(n.k,n.v);else{let o=s-r;o>0&&this.set(n.k,n.v,o)}}}prune(){this[ue].forEach((e,r)=>Fi(this,r,!1))}},Fi=(t,e,r)=>{let i=t[ue].get(e);if(i){let n=i.value;if(Rr(t,n)){if(St(t,i),!t[Vt])return}else r&&(t[uo]&&(i.value.now=Date.now()),t[W].unshiftNode(i));return n.value}},Rr=(t,e)=>{if(!e||!e.maxAge&&!t[st])return!1;let r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[st]&&r>t[st]},Wt=t=>{if(t[xe]>t[nt])for(let e=t[W].tail;t[xe]>t[nt]&&e!==null;){let r=e.prev;St(t,e),e=r}},St=(t,e)=>{if(e){let r=e.value;t[Ee]&&t[Ee](r.key,r.value),t[xe]-=r.length,t[ue].delete(r.key),t[W].removeNode(e)}},Vi=class{constructor(e,r,i,n,s){this.key=e,this.value=r,this.length=i,this.now=n,this.maxAge=s||0}},lo=(t,e,r,i)=>{let n=r.value;Rr(t,n)&&(St(t,r),t[Vt]||(n=void 0)),n&&e.call(i,n.value,n.key,t)};fo.exports=Wi});var Uc,A,Te,Et,Y=U(()=>{"use strict";Uc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),A=(function(){function t(e){e===void 0&&(e=t.NORMAL),this.iteratorType=e}return t.NORMAL=!1,t.REVERSE=!0,t})(),Te=(function(){function t(){this.length=0}return t.prototype.size=function(){return this.length},t.prototype.empty=function(){return this.length===0},t})(),Et=(function(t){Uc(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(Te)});var jc,Fc,ho,po=U(()=>{"use strict";Y();jc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),Fc=(function(t){jc(e,t);function e(r){r===void 0&&(r=[]);var i=t.call(this)||this;return i.stack=[],r.forEach(function(n){return i.push(n)}),i}return e.prototype.clear=function(){this.length=0,this.stack.length=0},e.prototype.push=function(r){this.stack.push(r),this.length+=1},e.prototype.pop=function(){this.stack.pop(),this.length>0&&(this.length-=1)},e.prototype.top=function(){return this.stack[this.length-1]},e})(Te),ho=Fc});var Wc,Vc,Ue,Ht=U(()=>{"use strict";Y();Wc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),Vc=(function(t){Wc(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(Et),Ue=Vc});function B(t,e,r){if(t<e||t>r)throw new RangeError}var je=U(()=>{"use strict"});var Hc,Ar,Hi=U(()=>{"use strict";je();Y();Hc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),Ar=(function(t){Hc(e,t);function e(r,i,n,s,o){var a=t.call(this,o)||this;return a.node=r,a.size=i,a.getElementByPos=n,a.setElementByPos=s,a.iteratorType===A.NORMAL?(a.pre=function(){if(this.node===0)throw new RangeError("Deque iterator access denied!");return this.node-=1,this},a.next=function(){if(this.node===this.size())throw new RangeError("Deque Iterator access denied!");return this.node+=1,this}):(a.pre=function(){if(this.node===this.size()-1)throw new RangeError("Deque iterator access denied!");return this.node+=1,this},a.next=function(){if(this.node===-1)throw new RangeError("Deque iterator access denied!");return this.node-=1,this}),a}return Object.defineProperty(e.prototype,"pointer",{get:function(){return B(this.node,0,this.size()-1),this.getElementByPos(this.node)},set:function(r){B(this.node,0,this.size()-1),this.setElementByPos(this.node,r)},enumerable:!1,configurable:!0}),e.prototype.equals=function(r){return this.node===r.node},e})(A)});var go,Kc,zc,$c,ot,Gc,Br,Ki=U(()=>{"use strict";Ht();je();Y();Hi();go=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),Kc=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},zc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},$c=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},ot=(function(t){go(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.copy=function(){return new e(this.node,this.size,this.getElementByPos,this.setElementByPos,this.iteratorType)},e})(Ar),Gc=(function(t){go(e,t);function e(r,i){r===void 0&&(r=[]),i===void 0&&(i=4096);var n=t.call(this)||this;n.first=0,n.curFirst=0,n.last=0,n.curLast=0,n.bucketNum=0,n.map=[];var s;if("size"in r)typeof r.size=="number"?s=r.size:s=r.size();else if("length"in r)s=r.length;else throw new RangeError("Can't get container's size!");n.bucketSize=i,n.bucketNum=Math.max(Math.ceil(s/n.bucketSize),1);for(var o=0;o<n.bucketNum;++o)n.map.push(new Array(n.bucketSize));var a=Math.ceil(s/n.bucketSize);return n.first=n.last=(n.bucketNum>>1)-(a>>1),n.curFirst=n.curLast=n.bucketSize-s%n.bucketSize>>1,r.forEach(function(u){return n.pushBack(u)}),n.size=n.size.bind(n),n.getElementByPos=n.getElementByPos.bind(n),n.setElementByPos=n.setElementByPos.bind(n),n}return e.prototype.reAllocate=function(){for(var r=[],i=Math.max(this.bucketNum>>1,1),n=0;n<i;++n)r[n]=new Array(this.bucketSize);for(var n=this.first;n<this.bucketNum;++n)r[r.length]=this.map[n];for(var n=0;n<this.last;++n)r[r.length]=this.map[n];r[r.length]=$c([],zc(this.map[this.last]),!1),this.first=i,this.last=r.length-1;for(var n=0;n<i;++n)r[r.length]=new Array(this.bucketSize);this.map=r,this.bucketNum=r.length},e.prototype.getElementIndex=function(r){var i=this.curFirst+r+1,n=i%this.bucketSize,s=n-1,o=this.first+(i-n)/this.bucketSize;return n===0&&(o-=1),o%=this.bucketNum,s<0&&(s+=this.bucketSize),{curNodeBucketIndex:o,curNodePointerIndex:s}},e.prototype.clear=function(){this.map=[[]],this.bucketNum=1,this.first=this.last=this.length=0,this.curFirst=this.curLast=this.bucketSize>>1},e.prototype.front=function(){return this.map[this.first][this.curFirst]},e.prototype.back=function(){return this.map[this.last][this.curLast]},e.prototype.begin=function(){return new ot(0,this.size,this.getElementByPos,this.setElementByPos)},e.prototype.end=function(){return new ot(this.length,this.size,this.getElementByPos,this.setElementByPos)},e.prototype.rBegin=function(){return new ot(this.length-1,this.size,this.getElementByPos,this.setElementByPos,A.REVERSE)},e.prototype.rEnd=function(){return new ot(-1,this.size,this.getElementByPos,this.setElementByPos,A.REVERSE)},e.prototype.pushBack=function(r){this.length&&(this.curLast<this.bucketSize-1?this.curLast+=1:this.last<this.bucketNum-1?(this.last+=1,this.curLast=0):(this.last=0,this.curLast=0),this.last===this.first&&this.curLast===this.curFirst&&this.reAllocate()),this.length+=1,this.map[this.last][this.curLast]=r},e.prototype.popBack=function(){this.length&&(this.map[this.last][this.curLast]=void 0,this.length!==1&&(this.curLast>0?this.curLast-=1:this.last>0?(this.last-=1,this.curLast=this.bucketSize-1):(this.last=this.bucketNum-1,this.curLast=this.bucketSize-1)),this.length-=1)},e.prototype.pushFront=function(r){this.length&&(this.curFirst>0?this.curFirst-=1:this.first>0?(this.first-=1,this.curFirst=this.bucketSize-1):(this.first=this.bucketNum-1,this.curFirst=this.bucketSize-1),this.first===this.last&&this.curFirst===this.curLast&&this.reAllocate()),this.length+=1,this.map[this.first][this.curFirst]=r},e.prototype.popFront=function(){this.length&&(this.map[this.first][this.curFirst]=void 0,this.length!==1&&(this.curFirst<this.bucketSize-1?this.curFirst+=1:this.first<this.bucketNum-1?(this.first+=1,this.curFirst=0):(this.first=0,this.curFirst=0)),this.length-=1)},e.prototype.forEach=function(r){for(var i=0;i<this.length;++i)r(this.getElementByPos(i),i)},e.prototype.getElementByPos=function(r){B(r,0,this.length-1);var i=this.getElementIndex(r),n=i.curNodeBucketIndex,s=i.curNodePointerIndex;return this.map[n][s]},e.prototype.setElementByPos=function(r,i){B(r,0,this.length-1);var n=this.getElementIndex(r),s=n.curNodeBucketIndex,o=n.curNodePointerIndex;this.map[s][o]=i},e.prototype.insert=function(r,i,n){if(n===void 0&&(n=1),B(r,0,this.length),r===0)for(;n--;)this.pushFront(i);else if(r===this.length)for(;n--;)this.pushBack(i);else{for(var s=[],o=r;o<this.length;++o)s.push(this.getElementByPos(o));this.cut(r-1);for(var o=0;o<n;++o)this.pushBack(i);for(var o=0;o<s.length;++o)this.pushBack(s[o])}},e.prototype.cut=function(r){if(r<0){this.clear();return}var i=this.getElementIndex(r),n=i.curNodeBucketIndex,s=i.curNodePointerIndex;this.last=n,this.curLast=s,this.length=r+1},e.prototype.eraseElementByPos=function(r){var i=this;if(B(r,0,this.length-1),r===0)this.popFront();else if(r===this.length-1)this.popBack();else{for(var n=[],s=r+1;s<this.length;++s)n.push(this.getElementByPos(s));this.cut(r),this.popBack(),n.forEach(function(o){return i.pushBack(o)})}},e.prototype.eraseElementByValue=function(r){if(this.length){for(var i=[],n=0;n<this.length;++n){var s=this.getElementByPos(n);s!==r&&i.push(s)}for(var o=i.length,n=0;n<o;++n)this.setElementByPos(n,i[n]);this.cut(o-1)}},e.prototype.eraseElementByIterator=function(r){var i=r.node;return this.eraseElementByPos(i),r=r.next(),r},e.prototype.find=function(r){for(var i=0;i<this.length;++i)if(this.getElementByPos(i)===r)return new ot(i,this.size,this.getElementByPos,this.setElementByPos);return this.end()},e.prototype.reverse=function(){for(var r=0,i=this.length-1;r<i;){var n=this.getElementByPos(r);this.setElementByPos(r,this.getElementByPos(i)),this.setElementByPos(i,n),r+=1,i-=1}},e.prototype.unique=function(){if(!(this.length<=1)){for(var r=1,i=this.getElementByPos(0),n=1;n<this.length;++n){var s=this.getElementByPos(n);s!==i&&(i=s,this.setElementByPos(r++,s))}for(;this.length>r;)this.popBack()}},e.prototype.sort=function(r){for(var i=[],n=0;n<this.length;++n)i.push(this.getElementByPos(n));i.sort(r);for(var n=0;n<this.length;++n)this.setElementByPos(n,i[n])},e.prototype.shrinkToFit=function(){if(this.length){var r=[];this.forEach(function(n){return r.push(n)}),this.bucketNum=Math.max(Math.ceil(this.length/this.bucketSize),1),this.length=this.first=this.last=this.curFirst=this.curLast=0,this.map=[];for(var i=0;i<this.bucketNum;++i)this.map.push(new Array(this.bucketSize));for(var i=0;i<r.length;++i)this.pushBack(r[i])}},e.prototype[Symbol.iterator]=function(){return function(){var r;return Kc(this,function(i){switch(i.label){case 0:r=0,i.label=1;case 1:return r<this.length?[4,this.getElementByPos(r)]:[3,4];case 2:i.sent(),i.label=3;case 3:return++r,[3,1];case 4:return[2]}})}.bind(this)()},e})(Ue),Br=Gc});var Qc,Yc,yo,_o=U(()=>{"use strict";Ki();Y();Qc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),Yc=(function(t){Qc(e,t);function e(r){r===void 0&&(r=[]);var i=t.call(this)||this;return i.queue=new Br(r),i.length=i.queue.size(),i}return e.prototype.clear=function(){this.queue.clear(),this.length=0},e.prototype.push=function(r){this.queue.pushBack(r),this.length+=1},e.prototype.pop=function(){this.queue.popFront(),this.length&&(this.length-=1)},e.prototype.front=function(){return this.queue.front()},e})(Te),yo=Yc});var Xc,kr,Jc,Zc,mo,vo=U(()=>{"use strict";Y();Xc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),kr=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Jc=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},Zc=(function(t){Xc(e,t);function e(r,i,n){var s;r===void 0&&(r=[]),i===void 0&&(i=function(d,m){return d>m?-1:d<m?1:0}),n===void 0&&(n=!0);var o=t.call(this)||this;o.cmp=i,Array.isArray(r)?o.priorityQueue=n?Jc([],kr(r),!1):r:(o.priorityQueue=[],r.forEach(function(d){return o.priorityQueue.push(d)})),o.length=o.priorityQueue.length;for(var a=o.length-1>>1;a>=0;--a)for(var u=a,l=u<<1|1;l<o.length;){var f=l,h=f+1,c=f;if(h<o.length&&o.cmp(o.priorityQueue[f],o.priorityQueue[h])>0&&(c=h),o.cmp(o.priorityQueue[u],o.priorityQueue[c])<=0)break;s=kr([o.priorityQueue[c],o.priorityQueue[u]],2),o.priorityQueue[u]=s[0],o.priorityQueue[c]=s[1],u=c,l=u<<1|1}return o}return e.prototype.adjust=function(r){var i,n,s=r<<1|1,o=(r<<1)+2;s<this.length&&this.cmp(this.priorityQueue[r],this.priorityQueue[s])>0&&(i=kr([this.priorityQueue[s],this.priorityQueue[r]],2),this.priorityQueue[r]=i[0],this.priorityQueue[s]=i[1]),o<this.length&&this.cmp(this.priorityQueue[r],this.priorityQueue[o])>0&&(n=kr([this.priorityQueue[o],this.priorityQueue[r]],2),this.priorityQueue[r]=n[0],this.priorityQueue[o]=n[1])},e.prototype.clear=function(){this.length=0,this.priorityQueue.length=0},e.prototype.push=function(r){if(this.priorityQueue.push(r),this.length+=1,this.length!==1)for(var i=this.length-1;i>0;){var n=i-1>>1;if(this.cmp(this.priorityQueue[n],r)<=0)break;this.adjust(n),i=n}},e.prototype.pop=function(){if(this.length){var r=this.priorityQueue[this.length-1];this.length-=1;for(var i=0;i<this.length;){var n=i<<1|1,s=(i<<1)+2;if(n>=this.length)break;var o=n;if(s<this.length&&this.cmp(this.priorityQueue[n],this.priorityQueue[s])>0&&(o=s),this.cmp(this.priorityQueue[o],r)>=0)break;this.priorityQueue[i]=this.priorityQueue[o],i=o}this.priorityQueue[i]=r,this.priorityQueue.pop()}},e.prototype.top=function(){return this.priorityQueue[0]},e})(Te),mo=Zc});var So,eh,bo,wo,th,at,rh,M,Lr=U(()=>{"use strict";Ht();je();Y();Hi();So=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),eh=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},bo=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},wo=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},th=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},at=(function(t){So(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.copy=function(){return new e(this.node,this.size,this.getElementByPos,this.setElementByPos,this.iteratorType)},e})(Ar),rh=(function(t){So(e,t);function e(r,i){r===void 0&&(r=[]),i===void 0&&(i=!0);var n=t.call(this)||this;return Array.isArray(r)?(n.vector=i?wo([],bo(r),!1):r,n.length=r.length):(n.vector=[],r.forEach(function(s){return n.pushBack(s)})),n.size=n.size.bind(n),n.getElementByPos=n.getElementByPos.bind(n),n.setElementByPos=n.setElementByPos.bind(n),n}return e.prototype.clear=function(){this.length=0,this.vector.length=0},e.prototype.begin=function(){return new at(0,this.size,this.getElementByPos,this.setElementByPos)},e.prototype.end=function(){return new at(this.length,this.size,this.getElementByPos,this.setElementByPos)},e.prototype.rBegin=function(){return new at(this.length-1,this.size,this.getElementByPos,this.setElementByPos,A.REVERSE)},e.prototype.rEnd=function(){return new at(-1,this.size,this.getElementByPos,this.setElementByPos,A.REVERSE)},e.prototype.front=function(){return this.vector[0]},e.prototype.back=function(){return this.vector[this.length-1]},e.prototype.forEach=function(r){for(var i=0;i<this.length;++i)r(this.vector[i],i)},e.prototype.getElementByPos=function(r){return B(r,0,this.length-1),this.vector[r]},e.prototype.eraseElementByPos=function(r){B(r,0,this.length-1),this.vector.splice(r,1),this.length-=1},e.prototype.eraseElementByValue=function(r){for(var i=0,n=0;n<this.length;++n)this.vector[n]!==r&&(this.vector[i++]=this.vector[n]);this.length=this.vector.length=i},e.prototype.eraseElementByIterator=function(r){var i=r.node;return r=r.next(),this.eraseElementByPos(i),r},e.prototype.pushBack=function(r){this.vector.push(r),this.length+=1},e.prototype.popBack=function(){this.length&&(this.vector.pop(),this.length-=1)},e.prototype.setElementByPos=function(r,i){B(r,0,this.length-1),this.vector[r]=i},e.prototype.insert=function(r,i,n){var s;n===void 0&&(n=1),B(r,0,this.length),(s=this.vector).splice.apply(s,wo([r,0],bo(new Array(n).fill(i)),!1)),this.length+=n},e.prototype.find=function(r){for(var i=0;i<this.length;++i)if(this.vector[i]===r)return new at(i,this.size,this.getElementByPos,this.getElementByPos);return this.end()},e.prototype.reverse=function(){this.vector.reverse()},e.prototype.unique=function(){for(var r=1,i=1;i<this.length;++i)this.vector[i]!==this.vector[i-1]&&(this.vector[r++]=this.vector[i]);this.length=this.vector.length=r},e.prototype.sort=function(r){this.vector.sort(r)},e.prototype[Symbol.iterator]=function(){return function(){return eh(this,function(r){switch(r.label){case 0:return[5,th(this.vector)];case 1:return[2,r.sent()]}})}.bind(this)()},e})(Ue),M=rh});var Eo,ih,Kt,lt,nh,xo,To=U(()=>{"use strict";Ht();je();Y();Eo=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),ih=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Kt=(function(){function t(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e}return t})(),lt=(function(t){Eo(e,t);function e(r,i,n){var s=t.call(this,n)||this;return s.node=r,s.header=i,s.iteratorType===A.NORMAL?(s.pre=function(){if(this.node.pre===this.header)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.pre,this},s.next=function(){if(this.node===this.header)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.next,this}):(s.pre=function(){if(this.node.next===this.header)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.next,this},s.next=function(){if(this.node===this.header)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.pre,this}),s}return Object.defineProperty(e.prototype,"pointer",{get:function(){if(this.node===this.header)throw new RangeError("LinkList iterator access denied!");return this.node.value},set:function(r){if(this.node===this.header)throw new RangeError("LinkList iterator access denied!");this.node.value=r},enumerable:!1,configurable:!0}),e.prototype.equals=function(r){return this.node===r.node},e.prototype.copy=function(){return new e(this.node,this.header,this.iteratorType)},e})(A),nh=(function(t){Eo(e,t);function e(r){r===void 0&&(r=[]);var i=t.call(this)||this;return i.header=new Kt,i.head=void 0,i.tail=void 0,r.forEach(function(n){return i.pushBack(n)}),i}return e.prototype.clear=function(){this.length=0,this.head=this.tail=void 0,this.header.pre=this.header.next=void 0},e.prototype.begin=function(){return new lt(this.head||this.header,this.header)},e.prototype.end=function(){return new lt(this.header,this.header)},e.prototype.rBegin=function(){return new lt(this.tail||this.header,this.header,A.REVERSE)},e.prototype.rEnd=function(){return new lt(this.header,this.header,A.REVERSE)},e.prototype.front=function(){return this.head?this.head.value:void 0},e.prototype.back=function(){return this.tail?this.tail.value:void 0},e.prototype.forEach=function(r){if(this.length)for(var i=this.head,n=0;i!==this.header;)r(i.value,n++),i=i.next},e.prototype.getElementByPos=function(r){B(r,0,this.length-1);for(var i=this.head;r--;)i=i.next;return i.value},e.prototype.eraseElementByPos=function(r){if(B(r,0,this.length-1),r===0)this.popFront();else if(r===this.length-1)this.popBack();else{for(var i=this.head;r--;)i=i.next;i=i;var n=i.pre,s=i.next;s.pre=n,n.next=s,this.length-=1}},e.prototype.eraseElementByValue=function(r){for(;this.head&&this.head.value===r;)this.popFront();for(;this.tail&&this.tail.value===r;)this.popBack();if(this.head)for(var i=this.head;i!==this.header;){if(i.value===r){var n=i.pre,s=i.next;s&&(s.pre=n),n&&(n.next=s),this.length-=1}i=i.next}},e.prototype.eraseElementByIterator=function(r){var i=r.node;if(i===this.header)throw new RangeError("Invalid iterator");if(r=r.next(),this.head===i)this.popFront();else if(this.tail===i)this.popBack();else{var n=i.pre,s=i.next;s&&(s.pre=n),n&&(n.next=s),this.length-=1}return r},e.prototype.pushBack=function(r){this.length+=1;var i=new Kt(r);this.tail?(this.tail.next=i,i.pre=this.tail,this.tail=i):(this.head=this.tail=i,this.header.next=this.head,this.head.pre=this.header),this.tail.next=this.header,this.header.pre=this.tail},e.prototype.popBack=function(){this.tail&&(this.length-=1,this.head===this.tail?(this.head=this.tail=void 0,this.header.next=void 0):(this.tail=this.tail.pre,this.tail&&(this.tail.next=void 0)),this.header.pre=this.tail,this.tail&&(this.tail.next=this.header))},e.prototype.setElementByPos=function(r,i){B(r,0,this.length-1);for(var n=this.head;r--;)n=n.next;n.value=i},e.prototype.insert=function(r,i,n){if(n===void 0&&(n=1),B(r,0,this.length),!(n<=0))if(r===0)for(;n--;)this.pushFront(i);else if(r===this.length)for(;n--;)this.pushBack(i);else{for(var s=this.head,o=1;o<r;++o)s=s.next;var a=s.next;for(this.length+=n;n--;)s.next=new Kt(i),s.next.pre=s,s=s.next;s.next=a,a&&(a.pre=s)}},e.prototype.find=function(r){if(!this.head)return this.end();for(var i=this.head;i!==this.header;){if(i.value===r)return new lt(i,this.header);i=i.next}return this.end()},e.prototype.reverse=function(){if(!(this.length<=1))for(var r=this.head,i=this.tail,n=0;n<<1<this.length;){var s=r.value;r.value=i.value,i.value=s,r=r.next,i=i.pre,n+=1}},e.prototype.unique=function(){if(!(this.length<=1))for(var r=this.head;r!==this.header;){for(var i=r;i.next&&i.value===i.next.value;)i=i.next,this.length-=1;r.next=i.next,r.next&&(r.next.pre=r),r=r.next}},e.prototype.sort=function(r){if(!(this.length<=1)){var i=[];this.forEach(function(s){return i.push(s)}),i.sort(r);var n=this.head;i.forEach(function(s){n.value=s,n=n.next})}},e.prototype.pushFront=function(r){this.length+=1;var i=new Kt(r);this.head?(i.next=this.head,this.head.pre=i,this.head=i):(this.head=this.tail=i,this.tail.next=this.header,this.header.pre=this.tail),this.header.next=this.head,this.head.pre=this.header},e.prototype.popFront=function(){this.head&&(this.length-=1,this.head===this.tail?(this.head=this.tail=void 0,this.header.pre=this.tail):(this.head=this.head.next,this.head&&(this.head.pre=this.header)),this.header.next=this.head)},e.prototype.merge=function(r){var i=this;if(!this.head){r.forEach(function(s){return i.pushBack(s)});return}var n=this.head;r.forEach(function(s){for(;n&&n!==i.header&&n.value<=s;)n=n.next;if(n===i.header)i.pushBack(s),n=i.tail;else if(n===i.head)i.pushFront(s),n=i.head;else{i.length+=1;var o=n.pre;o.next=new Kt(s),o.next.pre=o,o.next.next=n,n.pre=o.next}})},e.prototype[Symbol.iterator]=function(){return function(){var r;return ih(this,function(i){switch(i.label){case 0:if(!this.head)return[2];r=this.head,i.label=1;case 1:return r===this.header?[3,3]:[4,r.value];case 2:return i.sent(),r=r.next,[3,1];case 3:return[2]}})}.bind(this)()},e})(Ue),xo=nh});var sh,w,Co=U(()=>{"use strict";sh=(function(){function t(e,r){this.color=!0,this.key=void 0,this.value=void 0,this.left=void 0,this.right=void 0,this.parent=void 0,this.key=e,this.value=r}return t.prototype.pre=function(){var e=this;if(e.color===t.RED&&e.parent.parent===e)e=e.right;else if(e.left)for(e=e.left;e.right;)e=e.right;else{for(var r=e.parent;r.left===e;)e=r,r=e.parent;e=r}return e},t.prototype.next=function(){var e=this;if(e.right)for(e=e.right;e.left;)e=e.left;else{for(var r=e.parent;r.right===e;)e=r,r=e.parent;e.right!==r&&(e=r)}return e},t.prototype.rotateLeft=function(){var e=this.parent,r=this.right,i=r.left;return e.parent===this?e.parent=r:e.left===this?e.left=r:e.right=r,r.parent=e,r.left=this,this.parent=r,this.right=i,i&&(i.parent=this),r},t.prototype.rotateRight=function(){var e=this.parent,r=this.left,i=r.right;return e.parent===this?e.parent=r:e.left===this?e.left=r:e.right=r,r.parent=e,r.right=this,this.parent=r,this.left=i,i&&(i.parent=this),r},t.prototype.remove=function(){var e=this.parent;this===e.left?e.left=void 0:e.right=void 0},t.RED=!0,t.BLACK=!1,t})(),w=sh});var oh,Po,ah,xt,Mr=U(()=>{"use strict";Co();Y();je();oh=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),Po=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},ah=(function(t){oh(e,t);function e(r){r===void 0&&(r=function(n,s){return n<s?-1:n>s?1:0});var i=t.call(this)||this;return i.root=void 0,i.header=new w,i.inOrderTraversal=function(n,s){if(n===void 0)return!1;var o=i.inOrderTraversal(n.left,s);return o||s(n)?!0:i.inOrderTraversal(n.right,s)},i.cmp=r,i}return e.prototype._lowerBound=function(r,i){for(var n;r;){var s=this.cmp(r.key,i);if(s<0)r=r.right;else if(s>0)n=r,r=r.left;else return r}return n===void 0?this.header:n},e.prototype._upperBound=function(r,i){for(var n;r;){var s=this.cmp(r.key,i);s<=0?r=r.right:s>0&&(n=r,r=r.left)}return n===void 0?this.header:n},e.prototype._reverseLowerBound=function(r,i){for(var n;r;){var s=this.cmp(r.key,i);if(s<0)n=r,r=r.right;else if(s>0)r=r.left;else return r}return n===void 0?this.header:n},e.prototype._reverseUpperBound=function(r,i){for(var n;r;){var s=this.cmp(r.key,i);s<0?(n=r,r=r.right):s>=0&&(r=r.left)}return n===void 0?this.header:n},e.prototype.eraseNodeSelfBalance=function(r){for(;;){var i=r.parent;if(i===this.header)return;if(r.color===w.RED){r.color=w.BLACK;return}if(r===i.left){var n=i.right;if(n.color===w.RED)n.color=w.BLACK,i.color=w.RED,i===this.root?this.root=i.rotateLeft():i.rotateLeft();else if(n.color===w.BLACK)if(n.right&&n.right.color===w.RED){n.color=i.color,i.color=w.BLACK,n.right.color=w.BLACK,i===this.root?this.root=i.rotateLeft():i.rotateLeft();return}else n.left&&n.left.color===w.RED?(n.color=w.RED,n.left.color=w.BLACK,n.rotateRight()):(n.color=w.RED,r=i)}else{var n=i.left;if(n.color===w.RED)n.color=w.BLACK,i.color=w.RED,i===this.root?this.root=i.rotateRight():i.rotateRight();else if(n.left&&n.left.color===w.RED){n.color=i.color,i.color=w.BLACK,n.left.color=w.BLACK,i===this.root?this.root=i.rotateRight():i.rotateRight();return}else n.right&&n.right.color===w.RED?(n.color=w.RED,n.right.color=w.BLACK,n.rotateLeft()):(n.color=w.RED,r=i)}}},e.prototype.eraseNode=function(r){var i,n;if(this.length===1){this.clear();return}for(var s=r;s.left||s.right;){if(s.right)for(s=s.right;s.left;)s=s.left;else s.left&&(s=s.left);i=Po([s.key,r.key],2),r.key=i[0],s.key=i[1],n=Po([s.value,r.value],2),r.value=n[0],s.value=n[1],r=s}this.header.left===s?this.header.left=s.parent:this.header.right===s&&(this.header.right=s.parent),this.eraseNodeSelfBalance(s),s.remove(),this.length-=1,this.root.color=w.BLACK},e.prototype.insertNodeSelfBalance=function(r){for(;;){var i=r.parent;if(i.color===w.BLACK)return;var n=i.parent;if(i===n.left){var s=n.right;if(s&&s.color===w.RED){if(s.color=i.color=w.BLACK,n===this.root)return;n.color=w.RED,r=n;continue}else if(r===i.right){if(r.color=w.BLACK,r.left&&(r.left.parent=i),r.right&&(r.right.parent=n),i.right=r.left,n.left=r.right,r.left=i,r.right=n,n===this.root)this.root=r,this.header.parent=r;else{var o=n.parent;o.left===n?o.left=r:o.right=r}r.parent=n.parent,i.parent=r,n.parent=r}else i.color=w.BLACK,n===this.root?this.root=n.rotateRight():n.rotateRight();n.color=w.RED}else{var s=n.left;if(s&&s.color===w.RED){if(s.color=i.color=w.BLACK,n===this.root)return;n.color=w.RED,r=n;continue}else if(r===i.left){if(r.color=w.BLACK,r.left&&(r.left.parent=n),r.right&&(r.right.parent=i),n.right=r.left,i.left=r.right,r.left=n,r.right=i,n===this.root)this.root=r,this.header.parent=r;else{var o=n.parent;o.left===n?o.left=r:o.right=r}r.parent=n.parent,i.parent=r,n.parent=r}else i.color=w.BLACK,n===this.root?this.root=n.rotateLeft():n.rotateLeft();n.color=w.RED}return}},e.prototype.findElementNode=function(r,i){for(;r;){var n=this.cmp(r.key,i);if(n<0)r=r.right;else if(n>0)r=r.left;else return r}return r},e.prototype.set=function(r,i,n){if(this.root===void 0){this.length+=1,this.root=new w(r,i),this.root.color=w.BLACK,this.root.parent=this.header,this.header.parent=this.root,this.header.left=this.root,this.header.right=this.root;return}var s,o=this.header.left,a=this.cmp(o.key,r);if(a===0){o.value=i;return}else if(a>0)o.left=new w(r,i),o.left.parent=o,s=o.left,this.header.left=s;else{var u=this.header.right,l=this.cmp(u.key,r);if(l===0){u.value=i;return}else if(l<0)u.right=new w(r,i),u.right.parent=u,s=u.right,this.header.right=s;else{if(n!==void 0){var f=n.node;if(f!==this.header){var h=this.cmp(f.key,r);if(h===0){f.value=i;return}else if(h>0){var c=f.pre(),d=this.cmp(c.key,r);if(d===0){c.value=i;return}else d<0&&(s=new w(r,i),c.right===void 0?(c.right=s,s.parent=c):(f.left=s,s.parent=f))}}}if(s===void 0)for(s=this.root;;){var m=this.cmp(s.key,r);if(m>0){if(s.left===void 0){s.left=new w(r,i),s.left.parent=s,s=s.left;break}s=s.left}else if(m<0){if(s.right===void 0){s.right=new w(r,i),s.right.parent=s,s=s.right;break}s=s.right}else{s.value=i;return}}}}this.length+=1,this.insertNodeSelfBalance(s)},e.prototype.clear=function(){this.length=0,this.root=void 0,this.header.parent=void 0,this.header.left=this.header.right=void 0},e.prototype.updateKeyByIterator=function(r,i){var n=r.node;if(n===this.header)throw new TypeError("Invalid iterator!");if(this.length===1)return n.key=i,!0;if(n===this.header.left)return this.cmp(n.next().key,i)>0?(n.key=i,!0):!1;if(n===this.header.right)return this.cmp(n.pre().key,i)<0?(n.key=i,!0):!1;var s=n.pre().key;if(this.cmp(s,i)>=0)return!1;var o=n.next().key;return this.cmp(o,i)<=0?!1:(n.key=i,!0)},e.prototype.eraseElementByPos=function(r){var i=this;B(r,0,this.length-1);var n=0;this.inOrderTraversal(this.root,function(s){return r===n?(i.eraseNode(s),!0):(n+=1,!1)})},e.prototype.eraseElementByKey=function(r){if(this.length){var i=this.findElementNode(this.root,r);i!==void 0&&this.eraseNode(i)}},e.prototype.eraseElementByIterator=function(r){var i=r.node;if(i===this.header)throw new RangeError("Invalid iterator");return i.right===void 0&&(r=r.next()),this.eraseNode(i),r},e.prototype.getHeight=function(){if(!this.length)return 0;var r=function(i){return i?Math.max(r(i.left),r(i.right))+1:0};return r(this.root)},e})(Et),xt=ah});var lh,uh,qr,zi=U(()=>{"use strict";Y();lh=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),uh=(function(t){lh(e,t);function e(r,i,n){var s=t.call(this,n)||this;return s.node=r,s.header=i,s.iteratorType===A.NORMAL?(s.pre=function(){if(this.node===this.header.left)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.pre(),this},s.next=function(){if(this.node===this.header)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.next(),this}):(s.pre=function(){if(this.node===this.header.right)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.next(),this},s.next=function(){if(this.node===this.header)throw new RangeError("LinkList iterator access denied!");return this.node=this.node.pre(),this}),s}return e.prototype.equals=function(r){return this.node===r.node},e})(A),qr=uh});var Oo,fh,Nr,fe,ch,Ce,$i=U(()=>{"use strict";Mr();Y();je();zi();Oo=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),fh=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Nr=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=(function(t){Oo(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return Object.defineProperty(e.prototype,"pointer",{get:function(){if(this.node===this.header)throw new RangeError("OrderedSet iterator access denied!");return this.node.key},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.node,this.header,this.iteratorType)},e})(qr),ch=(function(t){Oo(e,t);function e(r,i){r===void 0&&(r=[]);var n=t.call(this,i)||this;return n.iterationFunc=function(s){return fh(this,function(o){switch(o.label){case 0:return s===void 0?[2]:[5,Nr(this.iterationFunc(s.left))];case 1:return o.sent(),[4,s.key];case 2:return o.sent(),[5,Nr(this.iterationFunc(s.right))];case 3:return o.sent(),[2]}})},r.forEach(function(s){return n.insert(s)}),n.iterationFunc=n.iterationFunc.bind(n),n}return e.prototype.begin=function(){return new fe(this.header.left||this.header,this.header)},e.prototype.end=function(){return new fe(this.header,this.header)},e.prototype.rBegin=function(){return new fe(this.header.right||this.header,this.header,A.REVERSE)},e.prototype.rEnd=function(){return new fe(this.header,this.header,A.REVERSE)},e.prototype.front=function(){return this.header.left?this.header.left.key:void 0},e.prototype.back=function(){return this.header.right?this.header.right.key:void 0},e.prototype.forEach=function(r){var i,n,s=0;try{for(var o=Nr(this),a=o.next();!a.done;a=o.next()){var u=a.value;r(u,s++)}}catch(l){i={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},e.prototype.getElementByPos=function(r){var i,n;B(r,0,this.length-1);var s,o=0;try{for(var a=Nr(this),u=a.next();!u.done;u=a.next()){var l=u.value;o===r&&(s=l),o+=1}}catch(f){i={error:f}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return s},e.prototype.insert=function(r,i){this.set(r,void 0,i)},e.prototype.find=function(r){var i=this.findElementNode(this.root,r);return i!==void 0?new fe(i,this.header):this.end()},e.prototype.lowerBound=function(r){var i=this._lowerBound(this.root,r);return new fe(i,this.header)},e.prototype.upperBound=function(r){var i=this._upperBound(this.root,r);return new fe(i,this.header)},e.prototype.reverseLowerBound=function(r){var i=this._reverseLowerBound(this.root,r);return new fe(i,this.header)},e.prototype.reverseUpperBound=function(r){var i=this._reverseUpperBound(this.root,r);return new fe(i,this.header)},e.prototype.union=function(r){var i=this;r.forEach(function(n){return i.insert(n)})},e.prototype[Symbol.iterator]=function(){return this.iterationFunc(this.root)},e})(xt),Ce=ch});var Ro,hh,Io,Dr,ce,dh,he,Gi=U(()=>{"use strict";Y();je();Mr();zi();Ro=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),hh=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Io=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Dr=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ce=(function(t){Ro(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return Object.defineProperty(e.prototype,"pointer",{get:function(){var r=this;if(this.node===this.header)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(i,n){if(n==="0")return r.node.key;if(n==="1")return r.node.value},set:function(i,n,s){if(n!=="1")throw new TypeError("props must be 1");return r.node.value=s,!0}})},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.node,this.header,this.iteratorType)},e})(qr),dh=(function(t){Ro(e,t);function e(r,i){r===void 0&&(r=[]);var n=t.call(this,i)||this;return n.iterationFunc=function(s){return hh(this,function(o){switch(o.label){case 0:return s===void 0?[2]:[5,Dr(this.iterationFunc(s.left))];case 1:return o.sent(),[4,[s.key,s.value]];case 2:return o.sent(),[5,Dr(this.iterationFunc(s.right))];case 3:return o.sent(),[2]}})},n.iterationFunc=n.iterationFunc.bind(n),r.forEach(function(s){var o=Io(s,2),a=o[0],u=o[1];return n.setElement(a,u)}),n}return e.prototype.begin=function(){return new ce(this.header.left||this.header,this.header)},e.prototype.end=function(){return new ce(this.header,this.header)},e.prototype.rBegin=function(){return new ce(this.header.right||this.header,this.header,A.REVERSE)},e.prototype.rEnd=function(){return new ce(this.header,this.header,A.REVERSE)},e.prototype.front=function(){if(this.length){var r=this.header.left;return[r.key,r.value]}},e.prototype.back=function(){if(this.length){var r=this.header.right;return[r.key,r.value]}},e.prototype.forEach=function(r){var i,n,s=0;try{for(var o=Dr(this),a=o.next();!a.done;a=o.next()){var u=a.value;r(u,s++)}}catch(l){i={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},e.prototype.lowerBound=function(r){var i=this._lowerBound(this.root,r);return new ce(i,this.header)},e.prototype.upperBound=function(r){var i=this._upperBound(this.root,r);return new ce(i,this.header)},e.prototype.reverseLowerBound=function(r){var i=this._reverseLowerBound(this.root,r);return new ce(i,this.header)},e.prototype.reverseUpperBound=function(r){var i=this._reverseUpperBound(this.root,r);return new ce(i,this.header)},e.prototype.setElement=function(r,i,n){this.set(r,i,n)},e.prototype.find=function(r){var i=this.findElementNode(this.root,r);return i!==void 0?new ce(i,this.header):this.end()},e.prototype.getElementByKey=function(r){var i=this.findElementNode(this.root,r);return i?i.value:void 0},e.prototype.getElementByPos=function(r){var i,n;B(r,0,this.length-1);var s,o=0;try{for(var a=Dr(this),u=a.next();!u.done;u=a.next()){var l=u.value;if(o===r){s=l;break}o+=1}}catch(f){i={error:f}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return s},e.prototype.union=function(r){var i=this;r.forEach(function(n){var s=Io(n,2),o=s[0],a=s[1];return i.setElement(o,a)})},e.prototype[Symbol.iterator]=function(){return this.iterationFunc(this.root)},e})(xt),he=dh});var ph,gh,q,Ur=U(()=>{"use strict";Y();ph=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),gh=(function(t){ph(e,t);function e(r,i){r===void 0&&(r=16),i===void 0&&(i=function(s){var o;typeof s!="string"?o=JSON.stringify(s):o=s;for(var a=0,u=o.length,l=0;l<u;l++){var f=o.charCodeAt(l);a=(a<<5)-a+f,a|=0}return a>>>0});var n=t.call(this)||this;if(r<16||(r&r-1)!==0)throw new RangeError("InitBucketNum range error");return n.bucketNum=n.initBucketNum=r,n.hashFunc=i,n}return e.prototype.clear=function(){this.length=0,this.bucketNum=this.initBucketNum,this.hashTable=[]},e.sigma=.75,e.treeifyThreshold=8,e.untreeifyThreshold=6,e.minTreeifySize=64,e.maxBucketNum=1<<30,e})(Te),q=gh});var yh,_h,mh,vh,Ao,Bo=U(()=>{"use strict";Ur();Lr();$i();yh=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),_h=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},mh=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},vh=(function(t){yh(e,t);function e(r,i,n){r===void 0&&(r=[]);var s=t.call(this,i,n)||this;return s.hashTable=[],r.forEach(function(o){return s.insert(o)}),s}return e.prototype.reAllocate=function(){var r=this;if(!(this.bucketNum>=q.maxBucketNum)){var i=[],n=this.bucketNum;this.bucketNum<<=1;for(var s=Object.keys(this.hashTable),o=s.length,a=function(f){var h=parseInt(s[f]),c=u.hashTable[h],d=c.size();if(d===0)return"continue";if(d===1){var m=c.front();return i[u.hashFunc(m)&u.bucketNum-1]=new M([m],!1),"continue"}var y=[],v=[];c.forEach(function(b){var C=r.hashFunc(b);(C&n)===0?y.push(b):v.push(b)}),c instanceof Ce?(y.length>q.untreeifyThreshold?i[h]=new Ce(y):y.length&&(i[h]=new M(y,!1)),v.length>q.untreeifyThreshold?i[h+n]=new Ce(v):v.length&&(i[h+n]=new M(v,!1))):(y.length>=q.treeifyThreshold?i[h]=new Ce(y):y.length&&(i[h]=new M(y,!1)),v.length>=q.treeifyThreshold?i[h+n]=new Ce(v):v.length&&(i[h+n]=new M(v,!1)))},u=this,l=0;l<o;++l)a(l);this.hashTable=i}},e.prototype.forEach=function(r){for(var i=Object.values(this.hashTable),n=i.length,s=0,o=0;o<n;++o)i[o].forEach(function(a){return r(a,s++)})},e.prototype.insert=function(r){var i=this.hashFunc(r)&this.bucketNum-1,n=this.hashTable[i];if(!n)this.hashTable[i]=new M([r],!1),this.length+=1;else{var s=n.size();if(n instanceof M){if(!n.find(r).equals(n.end()))return;if(n.pushBack(r),s+1>=q.treeifyThreshold){if(this.bucketNum<=q.minTreeifySize){this.length+=1,this.reAllocate();return}this.hashTable[i]=new Ce(n)}this.length+=1}else{n.insert(r);var o=n.size();this.length+=o-s}}this.length>this.bucketNum*q.sigma&&this.reAllocate()},e.prototype.eraseElementByKey=function(r){var i=this.hashFunc(r)&this.bucketNum-1,n=this.hashTable[i];if(n){var s=n.size();if(s!==0)if(n instanceof M){n.eraseElementByValue(r);var o=n.size();this.length+=o-s}else{n.eraseElementByKey(r);var o=n.size();this.length+=o-s,o<=q.untreeifyThreshold&&(this.hashTable[i]=new M(n))}}},e.prototype.find=function(r){var i=this.hashFunc(r)&this.bucketNum-1,n=this.hashTable[i];return n?!n.find(r).equals(n.end()):!1},e.prototype[Symbol.iterator]=function(){return function(){var r,i,n,s,o,a,u,l,f,h;return _h(this,function(c){switch(c.label){case 0:r=Object.values(this.hashTable),i=r.length,n=0,c.label=1;case 1:if(!(n<i))return[3,10];s=r[n],c.label=2;case 2:c.trys.push([2,7,8,9]),o=(f=void 0,mh(s)),a=o.next(),c.label=3;case 3:return a.done?[3,6]:(u=a.value,[4,u]);case 4:c.sent(),c.label=5;case 5:return a=o.next(),[3,3];case 6:return[3,9];case 7:return l=c.sent(),f={error:l},[3,9];case 8:try{a&&!a.done&&(h=o.return)&&h.call(o)}finally{if(f)throw f.error}return[7];case 9:return++n,[3,1];case 10:return[2]}})}.bind(this)()},e})(q),Ao=vh});var bh,wh,zt,Sh,ko,Lo=U(()=>{"use strict";Ur();Lr();Gi();bh=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=n[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})(),wh=function(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(f){return u([l,f])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=l[0]&2?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(f){l=[6,f],n=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},zt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Sh=(function(t){bh(e,t);function e(r,i,n){r===void 0&&(r=[]);var s=t.call(this,i,n)||this;return s.hashTable=[],r.forEach(function(o){return s.setElement(o[0],o[1])}),s}return e.prototype.reAllocate=function(){var r=this;if(!(this.bucketNum>=q.maxBucketNum)){var i=[],n=this.bucketNum;this.bucketNum<<=1;for(var s=Object.keys(this.hashTable),o=s.length,a=function(f){var h=parseInt(s[f]),c=u.hashTable[h],d=c.size();if(d===0)return"continue";if(d===1){var m=c.front();return i[u.hashFunc(m[0])&u.bucketNum-1]=new M([m],!1),"continue"}var y=[],v=[];c.forEach(function(b){var C=r.hashFunc(b[0]);(C&n)===0?y.push(b):v.push(b)}),c instanceof he?(y.length>q.untreeifyThreshold?i[h]=new he(y):y.length&&(i[h]=new M(y,!1)),v.length>q.untreeifyThreshold?i[h+n]=new he(v):v.length&&(i[h+n]=new M(v,!1))):(y.length>=q.treeifyThreshold?i[h]=new he(y):y.length&&(i[h]=new M(y,!1)),v.length>=q.treeifyThreshold?i[h+n]=new he(v):v.length&&(i[h+n]=new M(v,!1)))},u=this,l=0;l<o;++l)a(l);this.hashTable=i}},e.prototype.forEach=function(r){for(var i=Object.values(this.hashTable),n=i.length,s=0,o=0;o<n;++o)i[o].forEach(function(a){return r(a,s++)})},e.prototype.setElement=function(r,i){var n,s,o=this.hashFunc(r)&this.bucketNum-1,a=this.hashTable[o];if(!a)this.length+=1,this.hashTable[o]=new M([[r,i]],!1);else{var u=a.size();if(a instanceof M){try{for(var l=zt(a),f=l.next();!f.done;f=l.next()){var h=f.value;if(h[0]===r){h[1]=i;return}}}catch(d){n={error:d}}finally{try{f&&!f.done&&(s=l.return)&&s.call(l)}finally{if(n)throw n.error}}if(a.pushBack([r,i]),u+1>=e.treeifyThreshold){if(this.bucketNum<=e.minTreeifySize){this.length+=1,this.reAllocate();return}this.hashTable[o]=new he(this.hashTable[o])}this.length+=1}else{a.setElement(r,i);var c=a.size();this.length+=c-u}}this.length>this.bucketNum*e.sigma&&this.reAllocate()},e.prototype.getElementByKey=function(r){var i,n,s=this.hashFunc(r)&this.bucketNum-1,o=this.hashTable[s];if(o){if(o instanceof he)return o.getElementByKey(r);try{for(var a=zt(o),u=a.next();!u.done;u=a.next()){var l=u.value;if(l[0]===r)return l[1]}}catch(f){i={error:f}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}}},e.prototype.eraseElementByKey=function(r){var i,n,s=this.hashFunc(r)&this.bucketNum-1,o=this.hashTable[s];if(o)if(o instanceof M){var a=0;try{for(var u=zt(o),l=u.next();!l.done;l=u.next()){var f=l.value;if(f[0]===r){o.eraseElementByPos(a),this.length-=1;return}a+=1}}catch(d){i={error:d}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(i)throw i.error}}}else{var h=o.size();o.eraseElementByKey(r);var c=o.size();this.length+=c-h,c<=q.untreeifyThreshold&&(this.hashTable[s]=new M(o))}},e.prototype.find=function(r){var i,n,s=this.hashFunc(r)&this.bucketNum-1,o=this.hashTable[s];if(!o)return!1;if(o instanceof he)return!o.find(r).equals(o.end());try{for(var a=zt(o),u=a.next();!u.done;u=a.next()){var l=u.value;if(l[0]===r)return!0}}catch(f){i={error:f}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return!1},e.prototype[Symbol.iterator]=function(){return function(){var r,i,n,s,o,a,u,l,f,h;return wh(this,function(c){switch(c.label){case 0:r=Object.values(this.hashTable),i=r.length,n=0,c.label=1;case 1:if(!(n<i))return[3,10];s=r[n],c.label=2;case 2:c.trys.push([2,7,8,9]),o=(f=void 0,zt(s)),a=o.next(),c.label=3;case 3:return a.done?[3,6]:(u=a.value,[4,u]);case 4:c.sent(),c.label=5;case 5:return a=o.next(),[3,3];case 6:return[3,9];case 7:return l=c.sent(),f={error:l},[3,9];case 8:try{a&&!a.done&&(h=o.return)&&h.call(o)}finally{if(f)throw f.error}return[7];case 9:return++n,[3,1];case 10:return[2]}})}.bind(this)()},e})(q),ko=Sh});var Mo={};Gn(Mo,{Container:()=>Et,ContainerIterator:()=>A,Deque:()=>Br,DequeIterator:()=>ot,HashContainer:()=>q,HashMap:()=>ko,HashSet:()=>Ao,LinkList:()=>xo,LinkListIterator:()=>lt,OrderedMap:()=>he,OrderedMapIterator:()=>ce,OrderedSet:()=>Ce,OrderedSetIterator:()=>fe,PriorityQueue:()=>mo,Queue:()=>yo,SequentialContainer:()=>Ue,Stack:()=>ho,TreeContainer:()=>xt,Vector:()=>M,VectorIterator:()=>at});var qo=U(()=>{"use strict";po();_o();vo();Lr();To();Ki();$i();Gi();Bo();Lo();Y();Ht();Mr();Ur()});var Do=g((q_,No)=>{"use strict";var Tt=1e3,Ct=Tt*60,Pt=Ct*60,ut=Pt*24,Eh=ut*7,xh=ut*365.25;No.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Th(t);if(r==="number"&&isFinite(t))return e.long?Ph(t):Ch(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Th(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*xh;case"weeks":case"week":case"w":return r*Eh;case"days":case"day":case"d":return r*ut;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Pt;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ct;case"seconds":case"second":case"secs":case"sec":case"s":return r*Tt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Ch(t){var e=Math.abs(t);return e>=ut?Math.round(t/ut)+"d":e>=Pt?Math.round(t/Pt)+"h":e>=Ct?Math.round(t/Ct)+"m":e>=Tt?Math.round(t/Tt)+"s":t+"ms"}function Ph(t){var e=Math.abs(t);return e>=ut?jr(t,e,ut,"day"):e>=Pt?jr(t,e,Pt,"hour"):e>=Ct?jr(t,e,Ct,"minute"):e>=Tt?jr(t,e,Tt,"second"):t+" ms"}function jr(t,e,r,i){var n=e>=r*1.5;return Math.round(t/r)+" "+i+(n?"s":"")}});var Qi=g((N_,Uo)=>{"use strict";function Oh(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=n,r.enabled=a,r.humanize=Do(),r.destroy=l,Object.keys(t).forEach(f=>{r[f]=t[f]}),r.names=[],r.skips=[],r.formatters={};function e(f){let h=0;for(let c=0;c<f.length;c++)h=(h<<5)-h+f.charCodeAt(c),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=e;function r(f){let h,c=null,d,m;function y(...v){if(!y.enabled)return;let b=y,C=Number(new Date),D=C-(h||C);b.diff=D,b.prev=h,b.curr=C,h=C,v[0]=r.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let K=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(Xe,Bt)=>{if(Xe==="%%")return"%";K++;let cr=r.formatters[Bt];if(typeof cr=="function"){let wu=v[K];Xe=cr.call(b,wu),v.splice(K,1),K--}return Xe}),r.formatArgs.call(b,v),(b.log||r.log).apply(b,v)}return y.namespace=f,y.useColors=r.useColors(),y.color=r.selectColor(f),y.extend=i,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(d!==r.namespaces&&(d=r.namespaces,m=r.enabled(f)),m),set:v=>{c=v}}),typeof r.init=="function"&&r.init(y),y}function i(f,h){let c=r(this.namespace+(typeof h>"u"?":":h)+f);return c.log=this.log,c}function n(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let h=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let c of h)c[0]==="-"?r.skips.push(c.slice(1)):r.names.push(c)}function s(f,h){let c=0,d=0,m=-1,y=0;for(;c<f.length;)if(d<h.length&&(h[d]===f[c]||h[d]==="*"))h[d]==="*"?(m=d,y=c,d++):(c++,d++);else if(m!==-1)d=m+1,y++,c=y;else return!1;for(;d<h.length&&h[d]==="*";)d++;return d===h.length}function o(){let f=[...r.names,...r.skips.map(h=>"-"+h)].join(",");return r.enable(""),f}function a(f){for(let h of r.skips)if(s(f,h))return!1;for(let h of r.names)if(s(f,h))return!0;return!1}function u(f){return f instanceof Error?f.stack||f.message:f}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}Uo.exports=Oh});var jo=g((Z,Fr)=>{"use strict";Z.formatArgs=Rh;Z.save=Ah;Z.load=Bh;Z.useColors=Ih;Z.storage=kh();Z.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();Z.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 Ih(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return 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&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Rh(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Fr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(i=r))}),t.splice(i,0,e)}Z.log=console.debug||console.log||(()=>{});function Ah(t){try{t?Z.storage.setItem("debug",t):Z.storage.removeItem("debug")}catch{}}function Bh(){let t;try{t=Z.storage.getItem("debug")||Z.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function kh(){try{return localStorage}catch{}}Fr.exports=Qi()(Z);var{formatters:Lh}=Fr.exports;Lh.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Wo=g((D_,Fo)=>{"use strict";Fo.exports=(t,e=process.argv)=>{let r=t.startsWith("-")?"":t.length===1?"-":"--",i=e.indexOf(r+t),n=e.indexOf("--");return i!==-1&&(n===-1||i<n)}});var Ko=g((U_,Ho)=>{"use strict";var Mh=require("os"),Vo=require("tty"),oe=Wo(),{env:V}=process,Fe;oe("no-color")||oe("no-colors")||oe("color=false")||oe("color=never")?Fe=0:(oe("color")||oe("colors")||oe("color=true")||oe("color=always"))&&(Fe=1);"FORCE_COLOR"in V&&(V.FORCE_COLOR==="true"?Fe=1:V.FORCE_COLOR==="false"?Fe=0:Fe=V.FORCE_COLOR.length===0?1:Math.min(parseInt(V.FORCE_COLOR,10),3));function Yi(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Xi(t,e){if(Fe===0)return 0;if(oe("color=16m")||oe("color=full")||oe("color=truecolor"))return 3;if(oe("color=256"))return 2;if(t&&!e&&Fe===void 0)return 0;let r=Fe||0;if(V.TERM==="dumb")return r;if(process.platform==="win32"){let i=Mh.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in V)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(i=>i in V)||V.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in V)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(V.TEAMCITY_VERSION)?1:0;if(V.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in V){let i=parseInt((V.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(V.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(V.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(V.TERM)||"COLORTERM"in V?1:r}function qh(t){let e=Xi(t,t&&t.isTTY);return Yi(e)}Ho.exports={supportsColor:qh,stdout:Yi(Xi(!0,Vo.isatty(1))),stderr:Yi(Xi(!0,Vo.isatty(2)))}});var $o=g((H,Vr)=>{"use strict";var Nh=require("tty"),Wr=require("util");H.init=Hh;H.log=Fh;H.formatArgs=Uh;H.save=Wh;H.load=Vh;H.useColors=Dh;H.destroy=Wr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");H.colors=[6,2,3,4,5,1];try{let t=Ko();t&&(t.stderr||t).level>=2&&(H.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{}H.inspectOpts=Object.keys(process.env).filter(t=>/^debug_/i.test(t)).reduce((t,e)=>{let r=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),i=process.env[e];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),t[r]=i,t},{});function Dh(){return"colors"in H.inspectOpts?!!H.inspectOpts.colors:Nh.isatty(process.stderr.fd)}function Uh(t){let{namespace:e,useColors:r}=this;if(r){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),s=` ${n};1m${e} \x1B[0m`;t[0]=s+t[0].split(`
2
- `).join(`
3
- `+s),t.push(n+"m+"+Vr.exports.humanize(this.diff)+"\x1B[0m")}else t[0]=jh()+e+" "+t[0]}function jh(){return H.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Fh(...t){return process.stderr.write(Wr.formatWithOptions(H.inspectOpts,...t)+`
4
- `)}function Wh(t){t?process.env.DEBUG=t:delete process.env.DEBUG}function Vh(){return process.env.DEBUG}function Hh(t){t.inspectOpts={};let e=Object.keys(H.inspectOpts);for(let r=0;r<e.length;r++)t.inspectOpts[e[r]]=H.inspectOpts[e[r]]}Vr.exports=Qi()(H);var{formatters:zo}=Vr.exports;zo.o=function(t){return this.inspectOpts.colors=this.useColors,Wr.inspect(t,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};zo.O=function(t){return this.inspectOpts.colors=this.useColors,Wr.inspect(t,this.inspectOpts)}});var _e=g((j_,Ji)=>{"use strict";typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ji.exports=jo():Ji.exports=$o()});var Qo=g((F_,Go)=>{"use strict";var Kh=(qo(),Yn(Mo)).OrderedSet,me=_e()("number-allocator:trace"),zh=_e()("number-allocator:error");function X(t,e){this.low=t,this.high=e}X.prototype.equals=function(t){return this.low===t.low&&this.high===t.high};X.prototype.compare=function(t){return this.low<t.low&&this.high<t.low?-1:t.low<this.low&&t.high<this.low?1:0};function ve(t,e){if(!(this instanceof ve))return new ve(t,e);this.min=t,this.max=e,this.ss=new Kh([],(r,i)=>r.compare(i)),me("Create"),this.clear()}ve.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low};ve.prototype.alloc=function(){if(this.ss.size()===0)return me("alloc():empty"),null;let t=this.ss.begin(),e=t.pointer.low,r=t.pointer.high,i=e;return i+1<=r?this.ss.updateKeyByIterator(t,new X(e+1,r)):this.ss.eraseElementByPos(0),me("alloc():"+i),i};ve.prototype.use=function(t){let e=new X(t,t),r=this.ss.lowerBound(e);if(!r.equals(this.ss.end())){let i=r.pointer.low,n=r.pointer.high;return r.pointer.equals(e)?(this.ss.eraseElementByIterator(r),me("use():"+t),!0):i>t?!1:i===t?(this.ss.updateKeyByIterator(r,new X(i+1,n)),me("use():"+t),!0):n===t?(this.ss.updateKeyByIterator(r,new X(i,n-1)),me("use():"+t),!0):(this.ss.updateKeyByIterator(r,new X(t+1,n)),this.ss.insert(new X(i,t-1)),me("use():"+t),!0)}return me("use():failed"),!1};ve.prototype.free=function(t){if(t<this.min||t>this.max){zh("free():"+t+" is out of range");return}let e=new X(t,t),r=this.ss.upperBound(e);if(r.equals(this.ss.end())){if(r.equals(this.ss.begin())){this.ss.insert(e);return}r.pre();let i=r.pointer.high;r.pointer.high+1===t?this.ss.updateKeyByIterator(r,new X(i,t)):this.ss.insert(e)}else if(r.equals(this.ss.begin()))if(t+1===r.pointer.low){let i=r.pointer.high-1,n=r.pointer.high;this.ss.updateKeyByIterator(r,new X(i,n))}else this.ss.insert(e);else{let i=r.pointer.low,n=r.pointer.high;r.pre();let s=r.pointer.low;if(r.pointer.high+1===t)if(t+1===i){this.ss.eraseElementByIterator(r);let a=r.pointer.high;this.ss.updateKeyByIterator(r,new X(s,a))}else this.ss.updateKeyByIterator(r,new X(s,t));else t+1===i?(this.ss.eraseElementByIterator(r.next()),this.ss.insert(new X(t,n))):this.ss.insert(e)}me("free():"+t)};ve.prototype.clear=function(){me("clear()"),this.ss.clear(),this.ss.insert(new X(this.min,this.max))};ve.prototype.intervalCount=function(){return this.ss.size()};ve.prototype.dump=function(){console.log("length:"+this.ss.size());for(let t of this.ss)console.log(t)};Go.exports=ve});var Zi=g((W_,Yo)=>{"use strict";var $h=Qo();Yo.exports.NumberAllocator=$h});var Jo=g((V_,Xo)=>{"use strict";var Gh=co(),Qh=Zi().NumberAllocator;function We(t){if(!(this instanceof We))return new We(t);t>0&&(this.aliasToTopic=new Gh({max:t}),this.topicToAlias={},this.numberAllocator=new Qh(1,t),this.max=t,this.length=0)}We.prototype.put=function(t,e){if(e===0||e>this.max)return!1;let r=this.aliasToTopic.get(e);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(e,t),this.topicToAlias[t]=e,this.numberAllocator.use(e),this.length=this.aliasToTopic.length,!0};We.prototype.getTopicByAlias=function(t){return this.aliasToTopic.get(t)};We.prototype.getAliasByTopic=function(t){let e=this.topicToAlias[t];return typeof e<"u"&&this.aliasToTopic.get(e),e};We.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0};We.prototype.getLruAlias=function(){let t=this.numberAllocator.firstVacant();return t||this.aliasToTopic.keys()[this.aliasToTopic.length-1]};Xo.exports=We});var ta=g((H_,ea)=>{"use strict";var{Buffer:de}=require("buffer"),Zo=Symbol.for("BufferList");function R(t){if(!(this instanceof R))return new R(t);R._init.call(this,t)}R._init=function(e){Object.defineProperty(this,Zo,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)};R.prototype._new=function(e){return new R(e)};R.prototype._offset=function(e){if(e===0)return[0,0];let r=0;for(let i=0;i<this._bufs.length;i++){let n=r+this._bufs[i].length;if(e<n||i===this._bufs.length-1)return[i,e-r];r=n}};R.prototype._reverseOffset=function(t){let e=t[0],r=t[1];for(let i=0;i<e;i++)r+=this._bufs[i].length;return r};R.prototype.get=function(e){if(e>this.length||e<0)return;let r=this._offset(e);return this._bufs[r[0]][r[1]]};R.prototype.slice=function(e,r){return typeof e=="number"&&e<0&&(e+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,e,r)};R.prototype.copy=function(e,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 e||de.alloc(0);let s=!!e,o=this._offset(i),a=n-i,u=a,l=s&&r||0,f=o[1];if(i===0&&n===this.length){if(!s)return this._bufs.length===1?this._bufs[0]:de.concat(this._bufs,this.length);for(let h=0;h<this._bufs.length;h++)this._bufs[h].copy(e,l),l+=this._bufs[h].length;return e}if(u<=this._bufs[o[0]].length-f)return s?this._bufs[o[0]].copy(e,r,f,f+u):this._bufs[o[0]].slice(f,f+u);s||(e=de.allocUnsafe(a));for(let h=o[0];h<this._bufs.length;h++){let c=this._bufs[h].length-f;if(u>c)this._bufs[h].copy(e,l,f),l+=c;else{this._bufs[h].copy(e,l,f,f+u),l+=c;break}u-=c,f&&(f=0)}return e.length>l?e.slice(0,l):e};R.prototype.shallowSlice=function(e,r){if(e=e||0,r=typeof r!="number"?this.length:r,e<0&&(e+=this.length),r<0&&(r+=this.length),e===r)return this._new();let i=this._offset(e),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)};R.prototype.toString=function(e,r,i){return this.slice(r,i).toString(e)};R.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;)if(e>=this._bufs[0].length)e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}return this};R.prototype.duplicate=function(){let e=this._new();for(let r=0;r<this._bufs.length;r++)e.append(this._bufs[r]);return e};R.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(de.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let r=0;r<e.length;r++)this.append(e[r]);else if(this._isBufferList(e))for(let r=0;r<e._bufs.length;r++)this.append(e._bufs[r]);else typeof e=="number"&&(e=e.toString()),this._appendBuffer(de.from(e));return this};R.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length};R.prototype.indexOf=function(t,e,r){if(r===void 0&&typeof e=="string"&&(r=e,e=void 0),typeof t=="function"||Array.isArray(t))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof t=="number"?t=de.from([t]):typeof t=="string"?t=de.from(t,r):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=de.from(t.buffer,t.byteOffset,t.byteLength):de.isBuffer(t)||(t=de.from(t)),e=Number(e||0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=this._offset(e),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>=t.length){let u=o.indexOf(t,s);if(u!==-1)return this._reverseOffset([n,u]);s=o.length-t.length+1}else{let u=this._reverseOffset([n,s]);if(this._match(u,t))return u;s++}s=0}return-1};R.prototype._match=function(t,e){if(this.length-t<e.length)return!1;for(let r=0;r<e.length;r++)if(this.get(t+r)!==e[r])return!1;return!0};(function(){let t={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 e in t)(function(r){t[r]===null?R.prototype[r]=function(i,n){return this.slice(i,i+n)[r](0,n)}:R.prototype[r]=function(i=0){return this.slice(i,i+t[r])[r](0)}})(e)})();R.prototype._isBufferList=function(e){return e instanceof R||R.isBufferList(e)};R.isBufferList=function(e){return e!=null&&e[Zo]};ea.exports=R});var ra=g((K_,Hr)=>{"use strict";var en=Ne().Duplex,Yh=we(),$t=ta();function G(t){if(!(this instanceof G))return new G(t);if(typeof t=="function"){this._callback=t;let e=function(i){this._callback&&(this._callback(i),this._callback=null)}.bind(this);this.on("pipe",function(i){i.on("error",e)}),this.on("unpipe",function(i){i.removeListener("error",e)}),t=null}$t._init.call(this,t),en.call(this)}Yh(G,en);Object.assign(G.prototype,$t.prototype);G.prototype._new=function(e){return new G(e)};G.prototype._write=function(e,r,i){this._appendBuffer(e),typeof i=="function"&&i()};G.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)};G.prototype.end=function(e){en.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)};G.prototype._destroy=function(e,r){this._bufs.length=0,this.length=0,r(e)};G.prototype._isBufferList=function(e){return e instanceof G||e instanceof $t||G.isBufferList(e)};G.isBufferList=$t.isBufferList;Hr.exports=G;Hr.exports.BufferListStream=G;Hr.exports.BufferList=$t});var na=g((z_,ia)=>{"use strict";var tn=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}};ia.exports=tn});var rn=g(($_,sa)=>{"use strict";var _=sa.exports;_.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"};_.codes={};for(let t in _.types){let e=_.types[t];_.codes[e]=t}_.CMD_SHIFT=4;_.CMD_MASK=240;_.DUP_MASK=8;_.QOS_MASK=3;_.QOS_SHIFT=1;_.RETAIN_MASK=1;_.VARBYTEINT_MASK=127;_.VARBYTEINT_FIN_MASK=128;_.VARBYTEINT_MAX=268435455;_.SESSIONPRESENT_MASK=1;_.SESSIONPRESENT_HEADER=Buffer.from([_.SESSIONPRESENT_MASK]);_.CONNACK_HEADER=Buffer.from([_.codes.connack<<_.CMD_SHIFT]);_.USERNAME_MASK=128;_.PASSWORD_MASK=64;_.WILL_RETAIN_MASK=32;_.WILL_QOS_MASK=24;_.WILL_QOS_SHIFT=3;_.WILL_FLAG_MASK=4;_.CLEAN_SESSION_MASK=2;_.CONNECT_HEADER=Buffer.from([_.codes.connect<<_.CMD_SHIFT]);_.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};_.propertiesCodes={};for(let t in _.properties){let e=_.properties[t];_.propertiesCodes[e]=t}_.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 Ve(t){return[0,1,2].map(e=>[0,1].map(r=>[0,1].map(i=>{let n=Buffer.alloc(1);return n.writeUInt8(_.codes[t]<<_.CMD_SHIFT|(r?_.DUP_MASK:0)|e<<_.QOS_SHIFT|i,0,!0),n})))}_.PUBLISH_HEADER=Ve("publish");_.SUBSCRIBE_HEADER=Ve("subscribe");_.SUBSCRIBE_OPTIONS_QOS_MASK=3;_.SUBSCRIBE_OPTIONS_NL_MASK=1;_.SUBSCRIBE_OPTIONS_NL_SHIFT=2;_.SUBSCRIBE_OPTIONS_RAP_MASK=1;_.SUBSCRIBE_OPTIONS_RAP_SHIFT=3;_.SUBSCRIBE_OPTIONS_RH_MASK=3;_.SUBSCRIBE_OPTIONS_RH_SHIFT=4;_.SUBSCRIBE_OPTIONS_RH=[0,16,32];_.SUBSCRIBE_OPTIONS_NL=4;_.SUBSCRIBE_OPTIONS_RAP=8;_.SUBSCRIBE_OPTIONS_QOS=[0,1,2];_.UNSUBSCRIBE_HEADER=Ve("unsubscribe");_.ACKS={unsuback:Ve("unsuback"),puback:Ve("puback"),pubcomp:Ve("pubcomp"),pubrel:Ve("pubrel"),pubrec:Ve("pubrec")};_.SUBACK_HEADER=Buffer.from([_.codes.suback<<_.CMD_SHIFT]);_.VERSION3=Buffer.from([3]);_.VERSION4=Buffer.from([4]);_.VERSION5=Buffer.from([5]);_.VERSION131=Buffer.from([131]);_.VERSION132=Buffer.from([132]);_.QOS=[0,1,2].map(t=>Buffer.from([t]));_.EMPTY={pingreq:Buffer.from([_.codes.pingreq<<4,0]),pingresp:Buffer.from([_.codes.pingresp<<4,0]),disconnect:Buffer.from([_.codes.disconnect<<4,0])}});var la=g((G_,aa)=>{"use strict";var Xh=ra(),Jh=require("events"),oa=na(),I=rn(),S=_e()("mqtt-packet:parser"),nn=class t extends Jh{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof t?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new t().parser(e)}_resetState(){S("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new oa,this.error=null,this._list=Xh(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),S("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++,S("parse: state complete. _stateCounter is now: %d",this._stateCounter),S("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return S("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){let e=this._list.readUInt8(0);return this.packet.cmd=I.types[e>>I.CMD_SHIFT],this.packet.retain=(e&I.RETAIN_MASK)!==0,this.packet.qos=e>>I.QOS_SHIFT&I.QOS_MASK,this.packet.dup=(e&I.DUP_MASK)!==0,S("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){let e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),S("_parseLength %d",e.value),!!e}_parsePayload(){S("_parsePayload: payload %O",this._list);let e=!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"))}e=!0}return S("_parsePayload complete result: %s",e),e}_parseConnect(){S("_parseConnect");let e,r,i,n,s={},o=this.packet,a=this._parseString();if(a===null)return this._emitError(new Error("Cannot parse protocolId"));if(a!=="MQTT"&&a!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=a,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)&I.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&I.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&I.WILL_FLAG_MASK,s.will&&(o.will={},o.will.retain=(this._list.readUInt8(this._pos)&I.WILL_RETAIN_MASK)!==0,o.will.qos=(this._list.readUInt8(this._pos)&I.WILL_QOS_MASK)>>I.WILL_QOS_SHIFT),o.clean=(this._list.readUInt8(this._pos)&I.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 u=this._parseString();if(u===null)return this._emitError(new Error("Packet too short"));if(o.clientId=u,S("_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(e=this._parseString(),e===null)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,S("_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,S("_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,S("_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,S("_parseConnect: complete"),o}_parseConnack(){S("_parseConnack");let e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&I.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(e.returnCode===-1||e.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(e.properties=r)}S("_parseConnack: complete")}_parsePublish(){S("_parsePublish");let e=this.packet;if(e.topic=this._parseString(),e.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(e.properties=r)}e.payload=this._list.slice(this._pos,e.length),S("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){S("_parseSubscribe");let e=this.packet,r,i,n,s,o,a,u;if(e.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let l=this._parseProperties();Object.getOwnPropertyNames(l).length&&(e.properties=l)}for(;this._pos<e.length;){if(r=this._parseString(),r===null)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));i=this._parseByte(),n=i&I.SUBSCRIBE_OPTIONS_QOS_MASK,a=(i>>I.SUBSCRIBE_OPTIONS_NL_SHIFT&I.SUBSCRIBE_OPTIONS_NL_MASK)!==0,o=(i>>I.SUBSCRIBE_OPTIONS_RAP_SHIFT&I.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,s=i>>I.SUBSCRIBE_OPTIONS_RH_SHIFT&I.SUBSCRIBE_OPTIONS_RH_MASK,u={topic:r,qos:n},this.settings.protocolVersion===5?(u.nl=a,u.rap=o,u.rh=s):this.settings.bridgeMode&&(u.rh=0,u.rap=!0,u.nl=!0),S("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_parseSuback(){S("_parseSuback");let e=this.packet;if(this.packet.granted=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(e.properties=r)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){S("_parseUnsubscribe");let e=this.packet;if(e.unsubscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(e.properties=r)}for(;this._pos<e.length;){let r=this._parseString();if(r===null)return this._emitError(new Error("Cannot parse topic"));S("_parseUnsubscribe: push topic `%s` to unsubscriptions",r),e.unsubscriptions.push(r)}}}_parseUnsuback(){S("_parseUnsuback");let e=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&&(e.properties=r),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){S("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);let e=this.packet;if(this._parseMessageId(),this.settings.protocolVersion===5&&(e.length>2?(e.reasonCode=this._parseByte(),S("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(e.properties=r)}return!0}_parseDisconnect(){let e=this.packet;if(S("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;let r=this._parseProperties();Object.getOwnPropertyNames(r).length&&(e.properties=r)}return S("_parseDisconnect result: true"),!0}_parseAuth(){S("_parseAuth");let e=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();let r=this._parseProperties();return Object.getOwnPropertyNames(r).length&&(e.properties=r),S("_parseAuth: result: true"),!0}_parseMessageId(){let e=this.packet;return e.messageId=this._parseNum(),e.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(S("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){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,S("_parseString: result: %s",n),n}_parseStringPair(){return S("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let e=this._parseNum(),r=e+this._pos;if(e===-1||r>this._list.length||r>this.packet.length)return null;let i=this._list.slice(this._pos,r);return this._pos+=e,S("_parseBuffer: result: %o",i),i}_parseNum(){if(this._list.length-this._pos<2)return-1;let e=this._list.readUInt16BE(this._pos);return this._pos+=2,S("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;let e=this._list.readUInt32BE(this._pos);return this._pos+=4,S("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){S("_parseVarByteNum");let r=4,i=0,n=1,s=0,o=!1,a,u=this._pos?this._pos:0;for(;i<r&&u+i<this._list.length;){if(a=this._list.readUInt8(u+i++),s+=n*(a&I.VARBYTEINT_MASK),n*=128,(a&I.VARBYTEINT_FIN_MASK)===0){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")),u&&(this._pos+=i),o=o?e?{bytes:i,value:s}:s:!1,S("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),S("_parseByte: result: %o",e),e}_parseByType(e){switch(S("_parseByType: type: %s",e),e){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(){S("_parseProperties");let e=this._parseVarByteNum(),i=this._pos+e,n={};for(;this._pos<i;){let s=this._parseByte();if(!s)return this._emitError(new Error("Cannot parse property code type")),!1;let o=I.propertiesCodes[s];if(!o)return this._emitError(new Error("Unknown property")),!1;if(o==="userProperties"){n[o]||(n[o]=Object.create(null));let a=this._parseByType(I.propertiesTypes[o]);if(n[o][a.name])if(Array.isArray(n[o][a.name]))n[o][a.name].push(a.value);else{let u=n[o][a.name];n[o][a.name]=[u],n[o][a.name].push(a.value)}else n[o][a.name]=a.value;continue}n[o]?Array.isArray(n[o])?n[o].push(this._parseByType(I.propertiesTypes[o])):(n[o]=[n[o]],n[o].push(this._parseByType(I.propertiesTypes[o]))):n[o]=this._parseByType(I.propertiesTypes[o])}return n}_newPacket(){return S("_newPacket"),this.packet&&(this._list.consume(this.packet.length),S("_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)),S("_newPacket: new packet"),this.packet=new oa,this._pos=0,!0}_emitError(e){S("_emitError"),this.error=e,this.emit("error",e)}};aa.exports=nn});var ha=g((Q_,ca)=>{"use strict";var ua={},Zh=Buffer.isBuffer(Buffer.from([1,2]).subarray(0,1));function fa(t){let e=Buffer.allocUnsafe(2);return e.writeUInt8(t>>8,0),e.writeUInt8(t&255,1),e}function ed(){for(let t=0;t<65536;t++)ua[t]=fa(t)}function td(t){let r=0,i=0,n=Buffer.allocUnsafe(4);do r=t%128|0,t=t/128|0,t>0&&(r=r|128),n.writeUInt8(r,i++);while(t>0&&i<4);return t>0&&(i=0),Zh?n.subarray(0,i):n.slice(0,i)}function rd(t){let e=Buffer.allocUnsafe(4);return e.writeUInt32BE(t,0),e}ca.exports={cache:ua,generateCache:ed,generateNumber:fa,genBufVariableByteInt:td,generate4ByteBuffer:rd}});var da=g((Y_,sn)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?sn.exports={nextTick:id}:sn.exports=process;function id(t,e,r,i){if(typeof t!="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(t);case 2:return process.nextTick(function(){t.call(null,e)});case 3:return process.nextTick(function(){t.call(null,e,r)});case 4:return process.nextTick(function(){t.call(null,e,r,i)});default:for(s=new Array(n-1),o=0;o<s.length;)s[o++]=arguments[o];return process.nextTick(function(){t.apply(null,s)})}}});var ln=g((X_,wa)=>{"use strict";var E=rn(),nd=Buffer.allocUnsafe(0),sd=Buffer.from([0]),Gt=ha(),od=da().nextTick,ae=_e()("mqtt-packet:writeToStream"),Kr=Gt.cache,ad=Gt.generateNumber,ld=Gt.generateCache,on=Gt.genBufVariableByteInt,ud=Gt.generate4ByteBuffer,J=an,zr=!0;function va(t,e,r){switch(ae("generate called"),e.cork&&(e.cork(),od(fd,e)),zr&&(zr=!1,ld()),ae("generate: packet.cmd: %s",t.cmd),t.cmd){case"connect":return cd(t,e,r);case"connack":return hd(t,e,r);case"publish":return dd(t,e,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return pd(t,e,r);case"subscribe":return gd(t,e,r);case"suback":return yd(t,e,r);case"unsubscribe":return _d(t,e,r);case"unsuback":return md(t,e,r);case"pingreq":case"pingresp":return vd(t,e,r);case"disconnect":return bd(t,e,r);case"auth":return wd(t,e,r);default:return e.emit("error",new Error("Unknown command")),!1}}Object.defineProperty(va,"cacheNumbers",{get(){return J===an},set(t){t?((!Kr||Object.keys(Kr).length===0)&&(zr=!0),J=an):(zr=!1,J=Sd)}});function fd(t){t.uncork()}function cd(t,e,r){let i=t||{},n=i.protocolId||"MQTT",s=i.protocolVersion||4,o=i.will,a=i.clean,u=i.keepalive||0,l=i.clientId||"",f=i.username,h=i.password,c=i.properties;a===void 0&&(a=!0);let d=0;if(!n||typeof n!="string"&&!Buffer.isBuffer(n))return e.emit("error",new Error("Invalid protocolId")),!1;if(d+=n.length+2,s!==3&&s!==4&&s!==5)return e.emit("error",new Error("Invalid protocol version")),!1;if(d+=1,(typeof l=="string"||Buffer.isBuffer(l))&&(l||s>=4)&&(l||a))d+=Buffer.byteLength(l)+2;else{if(s<4)return e.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(a*1===0)return e.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof u!="number"||u<0||u>65535||u%1!==0)return e.emit("error",new Error("Invalid keepalive")),!1;if(d+=2,d+=1,s===5){var m=He(e,c);if(!m)return!1;d+=m.length}if(o){if(typeof o!="object")return e.emit("error",new Error("Invalid will")),!1;if(!o.topic||typeof o.topic!="string")return e.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 e.emit("error",new Error("Invalid will payload")),!1;var y={};if(s===5){if(y=He(e,o.properties),!y)return!1;d+=y.length}}let v=!1;if(f!=null)if(ma(f))v=!0,d+=Buffer.byteLength(f)+2;else return e.emit("error",new Error("Invalid username")),!1;if(h!=null){if(!v)return e.emit("error",new Error("Username is required to use password")),!1;if(ma(h))d+=ba(h)+2;else return e.emit("error",new Error("Invalid password")),!1}e.write(E.CONNECT_HEADER),le(e,d),Ot(e,n),i.bridgeMode&&(s+=128),e.write(s===131?E.VERSION131:s===132?E.VERSION132:s===4?E.VERSION4:s===5?E.VERSION5:E.VERSION3);let b=0;return b|=f!=null?E.USERNAME_MASK:0,b|=h!=null?E.PASSWORD_MASK:0,b|=o&&o.retain?E.WILL_RETAIN_MASK:0,b|=o&&o.qos?o.qos<<E.WILL_QOS_SHIFT:0,b|=o?E.WILL_FLAG_MASK:0,b|=a?E.CLEAN_SESSION_MASK:0,e.write(Buffer.from([b])),J(e,u),s===5&&m.write(),Ot(e,l),o&&(s===5&&y.write(),ft(e,o.topic),Ot(e,o.payload)),f!=null&&Ot(e,f),h!=null&&Ot(e,h),!0}function hd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=i===5?n.reasonCode:n.returnCode,o=n.properties,a=2;if(typeof s!="number")return e.emit("error",new Error("Invalid return code")),!1;let u=null;if(i===5){if(u=He(e,o),!u)return!1;a+=u.length}return e.write(E.CONNACK_HEADER),le(e,a),e.write(n.sessionPresent?E.SESSIONPRESENT_HEADER:sd),e.write(Buffer.from([s])),u?.write(),!0}function dd(t,e,r){ae("publish: packet: %o",t);let i=r?r.protocolVersion:4,n=t||{},s=n.qos||0,o=n.retain?E.RETAIN_MASK:0,a=n.topic,u=n.payload||nd,l=n.messageId,f=n.properties,h=0;if(typeof a=="string")h+=Buffer.byteLength(a)+2;else if(Buffer.isBuffer(a))h+=a.length+2;else return e.emit("error",new Error("Invalid topic")),!1;if(Buffer.isBuffer(u)?h+=u.length:h+=Buffer.byteLength(u),s&&typeof l!="number")return e.emit("error",new Error("Invalid messageId")),!1;s&&(h+=2);let c=null;if(i===5){if(c=He(e,f),!c)return!1;h+=c.length}return e.write(E.PUBLISH_HEADER[s][n.dup?1:0][o?1:0]),le(e,h),J(e,ba(a)),e.write(a),s>0&&J(e,l),c?.write(),ae("publish: payload: %o",u),e.write(u)}function pd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.cmd||"puback",o=n.messageId,a=n.dup&&s==="pubrel"?E.DUP_MASK:0,u=0,l=n.reasonCode,f=n.properties,h=i===5?3:2;if(s==="pubrel"&&(u=1),typeof o!="number")return e.emit("error",new Error("Invalid messageId")),!1;let c=null;if(i===5&&typeof f=="object"){if(c=Qt(e,f,r,h),!c)return!1;h+=c.length}return e.write(E.ACKS[s][u][a][0]),le(e,h),J(e,o),i===5&&e.write(Buffer.from([l])),c!==null&&c.write(),!0}function gd(t,e,r){ae("subscribe: packet: ");let i=r?r.protocolVersion:4,n=t||{},s=n.dup?E.DUP_MASK:0,o=n.messageId,a=n.subscriptions,u=n.properties,l=0;if(typeof o!="number")return e.emit("error",new Error("Invalid messageId")),!1;l+=2;let f=null;if(i===5){if(f=He(e,u),!f)return!1;l+=f.length}if(typeof a=="object"&&a.length)for(let c=0;c<a.length;c+=1){let d=a[c].topic,m=a[c].qos;if(typeof d!="string")return e.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if(typeof m!="number")return e.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(i===5){if(typeof(a[c].nl||!1)!="boolean")return e.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(a[c].rap||!1)!="boolean")return e.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;let b=a[c].rh||0;if(typeof b!="number"||b>2)return e.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}l+=Buffer.byteLength(d)+2+1}else return e.emit("error",new Error("Invalid subscriptions")),!1;ae("subscribe: writing to stream: %o",E.SUBSCRIBE_HEADER),e.write(E.SUBSCRIBE_HEADER[1][s?1:0][0]),le(e,l),J(e,o),f!==null&&f.write();let h=!0;for(let c of a){let d=c.topic,m=c.qos,y=+c.nl,v=+c.rap,b=c.rh,C;ft(e,d),C=E.SUBSCRIBE_OPTIONS_QOS[m],i===5&&(C|=y?E.SUBSCRIBE_OPTIONS_NL:0,C|=v?E.SUBSCRIBE_OPTIONS_RAP:0,C|=b?E.SUBSCRIBE_OPTIONS_RH[b]:0),h=e.write(Buffer.from([C]))}return h}function yd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.granted,a=n.properties,u=0;if(typeof s!="number")return e.emit("error",new Error("Invalid messageId")),!1;if(u+=2,typeof o=="object"&&o.length)for(let f=0;f<o.length;f+=1){if(typeof o[f]!="number")return e.emit("error",new Error("Invalid qos vector")),!1;u+=1}else return e.emit("error",new Error("Invalid qos vector")),!1;let l=null;if(i===5){if(l=Qt(e,a,r,u),!l)return!1;u+=l.length}return e.write(E.SUBACK_HEADER),le(e,u),J(e,s),l!==null&&l.write(),e.write(Buffer.from(o))}function _d(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.dup?E.DUP_MASK:0,a=n.unsubscriptions,u=n.properties,l=0;if(typeof s!="number")return e.emit("error",new Error("Invalid messageId")),!1;if(l+=2,typeof a=="object"&&a.length)for(let c=0;c<a.length;c+=1){if(typeof a[c]!="string")return e.emit("error",new Error("Invalid unsubscriptions")),!1;l+=Buffer.byteLength(a[c])+2}else return e.emit("error",new Error("Invalid unsubscriptions")),!1;let f=null;if(i===5){if(f=He(e,u),!f)return!1;l+=f.length}e.write(E.UNSUBSCRIBE_HEADER[1][o?1:0][0]),le(e,l),J(e,s),f!==null&&f.write();let h=!0;for(let c=0;c<a.length;c++)h=ft(e,a[c]);return h}function md(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.dup?E.DUP_MASK:0,a=n.granted,u=n.properties,l=n.cmd,f=0,h=2;if(typeof s!="number")return e.emit("error",new Error("Invalid messageId")),!1;if(i===5)if(typeof a=="object"&&a.length)for(let d=0;d<a.length;d+=1){if(typeof a[d]!="number")return e.emit("error",new Error("Invalid qos vector")),!1;h+=1}else return e.emit("error",new Error("Invalid qos vector")),!1;let c=null;if(i===5){if(c=Qt(e,u,r,h),!c)return!1;h+=c.length}return e.write(E.ACKS[l][f][o][0]),le(e,h),J(e,s),c!==null&&c.write(),i===5&&e.write(Buffer.from(a)),!0}function vd(t,e,r){return e.write(E.EMPTY[t.cmd])}function bd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.reasonCode,o=n.properties,a=i===5?1:0,u=null;if(i===5){if(u=Qt(e,o,r,a),!u)return!1;a+=u.length}return e.write(Buffer.from([E.codes.disconnect<<4])),le(e,a),i===5&&e.write(Buffer.from([s])),u!==null&&u.write(),!0}function wd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.reasonCode,o=n.properties,a=i===5?1:0;i!==5&&e.emit("error",new Error("Invalid mqtt version for auth packet"));let u=Qt(e,o,r,a);return u?(a+=u.length,e.write(Buffer.from([E.codes.auth<<4])),le(e,a),e.write(Buffer.from([s])),u!==null&&u.write(),!0):!1}var pa={};function le(t,e){if(e>E.VARBYTEINT_MAX)return t.emit("error",new Error(`Invalid variable byte integer: ${e}`)),!1;let r=pa[e];return r||(r=on(e),e<16384&&(pa[e]=r)),ae("writeVarByteInt: writing to stream: %o",r),t.write(r)}function ft(t,e){let r=Buffer.byteLength(e);return J(t,r),ae("writeString: %s",e),t.write(e,"utf8")}function ga(t,e,r){ft(t,e),ft(t,r)}function an(t,e){return ae("writeNumberCached: number: %d",e),ae("writeNumberCached: %o",Kr[e]),t.write(Kr[e])}function Sd(t,e){let r=ad(e);return ae("writeNumberGenerated: %o",r),t.write(r)}function Ed(t,e){let r=ud(e);return ae("write4ByteNumber: %o",r),t.write(r)}function Ot(t,e){typeof e=="string"?ft(t,e):e?(J(t,e.length),t.write(e)):J(t,0)}function He(t,e){if(typeof e!="object"||e.length!=null)return{length:1,write(){_a(t,{},0)}};let r=0;function i(s,o){let a=E.propertiesTypes[s],u=0;switch(a){case"byte":{if(typeof o!="boolean")return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=2;break}case"int8":{if(typeof o!="number"||o<0||o>255)return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=2;break}case"binary":{if(o&&o===null)return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=1+Buffer.byteLength(o)+2;break}case"int16":{if(typeof o!="number"||o<0||o>65535)return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=3;break}case"int32":{if(typeof o!="number"||o<0||o>4294967295)return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=5;break}case"var":{if(typeof o!="number"||o<0||o>268435455)return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=1+Buffer.byteLength(on(o));break}case"string":{if(typeof o!="string")return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=3+Buffer.byteLength(o.toString());break}case"pair":{if(typeof o!="object")return t.emit("error",new Error(`Invalid ${s}: ${o}`)),!1;u+=Object.getOwnPropertyNames(o).reduce((l,f)=>{let h=o[f];return Array.isArray(h)?l+=h.reduce((c,d)=>(c+=3+Buffer.byteLength(f.toString())+2+Buffer.byteLength(d.toString()),c),0):l+=3+Buffer.byteLength(f.toString())+2+Buffer.byteLength(o[f].toString()),l},0);break}default:return t.emit("error",new Error(`Invalid property ${s}: ${o}`)),!1}return u}if(e)for(let s in e){let o=0,a=0,u=e[s];if(Array.isArray(u))for(let l=0;l<u.length;l++){if(a=i(s,u[l]),!a)return!1;o+=a}else{if(a=i(s,u),!a)return!1;o=a}if(!o)return!1;r+=o}return{length:Buffer.byteLength(on(r))+r,write(){_a(t,e,r)}}}function Qt(t,e,r,i){let n=["reasonString","userProperties"],s=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0,o=He(t,e);if(s)for(;i+o.length>s;){let a=n.shift();if(a&&e[a])delete e[a],o=He(t,e);else return!1}return o}function ya(t,e,r){switch(E.propertiesTypes[e]){case"byte":{t.write(Buffer.from([E.properties[e]])),t.write(Buffer.from([+r]));break}case"int8":{t.write(Buffer.from([E.properties[e]])),t.write(Buffer.from([r]));break}case"binary":{t.write(Buffer.from([E.properties[e]])),Ot(t,r);break}case"int16":{t.write(Buffer.from([E.properties[e]])),J(t,r);break}case"int32":{t.write(Buffer.from([E.properties[e]])),Ed(t,r);break}case"var":{t.write(Buffer.from([E.properties[e]])),le(t,r);break}case"string":{t.write(Buffer.from([E.properties[e]])),ft(t,r);break}case"pair":{Object.getOwnPropertyNames(r).forEach(n=>{let s=r[n];Array.isArray(s)?s.forEach(o=>{t.write(Buffer.from([E.properties[e]])),ga(t,n.toString(),o.toString())}):(t.write(Buffer.from([E.properties[e]])),ga(t,n.toString(),s.toString()))});break}default:return t.emit("error",new Error(`Invalid property ${e} value: ${r}`)),!1}}function _a(t,e,r){le(t,r);for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==null){let n=e[i];if(Array.isArray(n))for(let s=0;s<n.length;s++)ya(t,i,n[s]);else ya(t,i,n)}}function ba(t){return t?t instanceof Buffer?t.length:Buffer.byteLength(t):0}function ma(t){return typeof t=="string"||t instanceof Buffer}wa.exports=va});var Ea=g((J_,Sa)=>{"use strict";var xd=ln(),Td=require("events");function Cd(t,e){let r=new un;return xd(t,r,e),r.concat()}var un=class extends Td{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=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]),e+=r[s];let o=Buffer.allocUnsafe(e);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}};Sa.exports=Cd});var xa=g($r=>{"use strict";$r.parser=la().parser;$r.generate=Ea();$r.writeToStream=ln()});var fn=g((em,Ta)=>{"use strict";function Ke(){if(!(this instanceof Ke))return new Ke;this.nextId=Math.max(1,Math.floor(Math.random()*65535))}Ke.prototype.allocate=function(){let t=this.nextId++;return this.nextId===65536&&(this.nextId=1),t};Ke.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1};Ke.prototype.register=function(t){return!0};Ke.prototype.deallocate=function(t){};Ke.prototype.clear=function(){};Ta.exports=Ke});var Pa=g((tm,Ca)=>{"use strict";function Pd(t,e,r){var i=this;this._callback=t,this._args=r,this._interval=setInterval(t,e,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 Od(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var t;if(arguments.length>0){t=new Array(arguments.length-2);for(var e=0;e<t.length;e++)t[e]=arguments[e+2]}return new Pd(arguments[0],arguments[1],t)}Ca.exports=Od});var Ia=g((rm,Oa)=>{"use strict";Oa.exports=Id;function It(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function Id(t){if(t=t||{},t.circles)return Rd(t);return t.proto?i:r;function e(n,s){for(var o=Object.keys(n),a=new Array(o.length),u=0;u<o.length;u++){var l=o[u],f=n[l];typeof f!="object"||f===null?a[l]=f:f instanceof Date?a[l]=new Date(f):ArrayBuffer.isView(f)?a[l]=It(f):a[l]=s(f)}return a}function r(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return e(n,r);if(n instanceof Map)return new Map(e(Array.from(n),r));if(n instanceof Set)return new Set(e(Array.from(n),r));var s={};for(var o in n)if(Object.hasOwnProperty.call(n,o)!==!1){var a=n[o];typeof a!="object"||a===null?s[o]=a:a instanceof Date?s[o]=new Date(a):a instanceof Map?s[o]=new Map(e(Array.from(a),r)):a instanceof Set?s[o]=new Set(e(Array.from(a),r)):ArrayBuffer.isView(a)?s[o]=It(a):s[o]=r(a)}return s}function i(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return e(n,i);if(n instanceof Map)return new Map(e(Array.from(n),i));if(n instanceof Set)return new Set(e(Array.from(n),i));var s={};for(var o in n){var a=n[o];typeof a!="object"||a===null?s[o]=a:a instanceof Date?s[o]=new Date(a):a instanceof Map?s[o]=new Map(e(Array.from(a),i)):a instanceof Set?s[o]=new Set(e(Array.from(a),i)):ArrayBuffer.isView(a)?s[o]=It(a):s[o]=i(a)}return s}}function Rd(t){var e=[],r=[];return t.proto?s:n;function i(o,a){for(var u=Object.keys(o),l=new Array(u.length),f=0;f<u.length;f++){var h=u[f],c=o[h];if(typeof c!="object"||c===null)l[h]=c;else if(c instanceof Date)l[h]=new Date(c);else if(ArrayBuffer.isView(c))l[h]=It(c);else{var d=e.indexOf(c);d!==-1?l[h]=r[d]:l[h]=a(c)}}return l}function n(o){if(typeof o!="object"||o===null)return o;if(o instanceof Date)return new Date(o);if(Array.isArray(o))return i(o,n);if(o instanceof Map)return new Map(i(Array.from(o),n));if(o instanceof Set)return new Set(i(Array.from(o),n));var a={};e.push(o),r.push(a);for(var u in o)if(Object.hasOwnProperty.call(o,u)!==!1){var l=o[u];if(typeof l!="object"||l===null)a[u]=l;else if(l instanceof Date)a[u]=new Date(l);else if(l instanceof Map)a[u]=new Map(i(Array.from(l),n));else if(l instanceof Set)a[u]=new Set(i(Array.from(l),n));else if(ArrayBuffer.isView(l))a[u]=It(l);else{var f=e.indexOf(l);f!==-1?a[u]=r[f]:a[u]=n(l)}}return e.pop(),r.pop(),a}function s(o){if(typeof o!="object"||o===null)return o;if(o instanceof Date)return new Date(o);if(Array.isArray(o))return i(o,s);if(o instanceof Map)return new Map(i(Array.from(o),s));if(o instanceof Set)return new Set(i(Array.from(o),s));var a={};e.push(o),r.push(a);for(var u in o){var l=o[u];if(typeof l!="object"||l===null)a[u]=l;else if(l instanceof Date)a[u]=new Date(l);else if(l instanceof Map)a[u]=new Map(i(Array.from(l),s));else if(l instanceof Set)a[u]=new Set(i(Array.from(l),s));else if(ArrayBuffer.isView(l))a[u]=It(l);else{var f=e.indexOf(l);f!==-1?a[u]=r[f]:a[u]=s(l)}}return e.pop(),r.pop(),a}}});var Aa=g((im,Ra)=>{"use strict";Ra.exports=Ia()()});var ka=g((nm,Ba)=>{"use strict";function Ad(t){let e=t.split("/");for(let r=0;r<e.length;r++)if(e[r]!=="+"){if(e[r]==="#")return r===e.length-1;if(e[r].indexOf("+")!==-1||e[r].indexOf("#")!==-1)return!1}return!0}function Bd(t){if(t.length===0)return"empty_topic_list";for(let e=0;e<t.length;e++)if(!Ad(t[e]))return t[e];return null}Ba.exports={validateTopics:Bd}});var dn=g((sm,Fa)=>{"use strict";var qa=require("events").EventEmitter,Gr=Ir(),kd=ro(),Ld=Jo(),Na=xa(),Md=fn(),qd=Ne().Writable,Nd=we(),Dd=Pa(),Da=Aa(),Ua=ka(),Yr=dr(),p=_e()("mqttjs:client"),cn=process?process.nextTick:function(t){setTimeout(t,0)},hn=global.setImmediate||function(t){cn(t)},La={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},Ud=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],Qr={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 jd(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function Fd(t,e){if(t.options.protocolVersion===5&&e.cmd==="publish"){let r;e.properties&&(r=e.properties.topicAlias);let i=e.topic.toString();if(t.topicAliasSend)if(r){if(i.length!==0&&(p("applyTopicAlias :: register topic: %s - alias: %d",i,r),!t.topicAliasSend.put(i,r)))return p("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}else i.length!==0&&(t.options.autoAssignTopicAlias?(r=t.topicAliasSend.getAliasByTopic(i),r?(e.topic="",e.properties={...e.properties,topicAlias:r},p("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",i,r)):(r=t.topicAliasSend.getLruAlias(),t.topicAliasSend.put(i,r),e.properties={...e.properties,topicAlias:r},p("applyTopicAlias :: auto assign topic: %s - alias: %d",i,r))):t.options.autoUseTopicAlias&&(r=t.topicAliasSend.getAliasByTopic(i),r&&(e.topic="",e.properties={...e.properties,topicAlias:r},p("applyTopicAlias :: auto use topic: %s - alias: %d",i,r))));else if(r)return p("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}}function ja(t,e){let r;e.properties&&(r=e.properties.topicAlias);let i=e.topic.toString();if(i.length===0){if(typeof r>"u")return new Error("Unregistered Topic Alias");if(i=t.topicAliasSend.getTopicByAlias(r),typeof i>"u")return new Error("Unregistered Topic Alias");e.topic=i}r&&delete e.properties.topicAlias}function Rt(t,e,r){p("sendPacket :: packet: %O",e),p("sendPacket :: emitting `packetsend`"),t.emit("packetsend",e),p("sendPacket :: writing to stream");let i=Na.writeToStream(e,t.stream,t.options);p("sendPacket :: writeToStream result %s",i),!i&&r&&r!==z?(p("sendPacket :: handle events on `drain` once through callback."),t.stream.once("drain",r)):r&&(p("sendPacket :: invoking cb"),r())}function Wd(t){t&&(p("flush: queue exists? %b",!!t),Object.keys(t).forEach(function(e){typeof t[e].cb=="function"&&(t[e].cb(new Error("Connection closed")),delete t[e])}))}function Vd(t){t&&(p("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(t).forEach(function(e){t[e].volatile&&typeof t[e].cb=="function"&&(t[e].cb(new Error("Connection closed")),delete t[e])}))}function Ma(t,e,r,i){p("storeAndSend :: store packet with cmd %s to outgoingStore",e.cmd);let n=e,s;if(n.cmd==="publish"&&(n=Da(e),s=ja(t,n),s))return r&&r(s);t.outgoingStore.put(n,function(a){if(a)return r&&r(a);i(),Rt(t,e,r)})}function z(t){p("nop ::",t)}function T(t,e){let r,i=this;if(!(this instanceof T))return new T(t,e);this.options=e||{};for(r in La)typeof this.options[r]>"u"?this.options[r]=La[r]:this.options[r]=e[r];p("MqttClient :: options.protocol",e.protocol),p("MqttClient :: options.protocolVersion",e.protocolVersion),p("MqttClient :: options.username",e.username),p("MqttClient :: options.keepalive",e.keepalive),p("MqttClient :: options.reconnectPeriod",e.reconnectPeriod),p("MqttClient :: options.rejectUnauthorized",e.rejectUnauthorized),p("MqttClient :: options.topicAliasMaximum",e.topicAliasMaximum),this.options.clientId=typeof e.clientId=="string"?e.clientId:jd(),p("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=e.protocolVersion===5&&e.customHandleAcks?e.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=t,this.messageIdProvider=typeof this.options.messageIdProvider>"u"?new Md:this.options.messageIdProvider,this.outgoingStore=e.outgoingStore||new Gr,this.incomingStore=e.incomingStore||new Gr,this.queueQoSZero=e.queueQoSZero===void 0?!0:e.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,e.topicAliasMaximum>0&&(e.topicAliasMaximum>65535?p("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new kd(e.topicAliasMaximum)),this.on("connect",function(){let n=this.queue;function s(){let o=n.shift();p("deliver :: entry %o",o);let a=null;if(!o){i._resubscribe();return}a=o.packet,p("deliver :: call _sendPacket for %o",a);let u=!0;a.messageId&&a.messageId!==0&&(i.messageIdProvider.register(a.messageId)||(u=!1)),u?i._sendPacket(a,function(l){o.cb&&o.cb(l),s()}):(p("messageId: %d has already used. The message is skipped and removed.",a.messageId),s())}p("connect :: sending queued packets"),s()}),this.on("close",function(){p("close :: connected set to `false`"),this.connected=!1,p("close :: clearing connackTimer"),clearTimeout(this.connackTimer),p("close :: clearing ping timer"),i.pingTimer!==null&&(i.pingTimer.clear(),i.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),p("close :: calling _setupReconnect"),this._setupReconnect()}),qa.call(this),p("MqttClient :: setting up stream"),this._setupStream()}Nd(T,qa);T.prototype._setupStream=function(){let t=this,e=new qd,r=Na.parser(this.options),i=null,n=[];p("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),p("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",function(l){p("parser :: on packet push to packets array."),n.push(l)});function s(){if(n.length)cn(o);else{let l=i;i=null,l()}}function o(){p("work :: getting next packet in queue");let l=n.shift();if(l)p("work :: packet pulled from queue"),t._handlePacket(l,s);else{p("work :: no packets in queue");let f=i;i=null,p("work :: done flag is %s",!!f),f&&f()}}e._write=function(l,f,h){i=h,p("writable stream :: parsing buffer"),r.parse(l),o()};function a(l){p("streamErrorHandler :: error",l.message),Ud.includes(l.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",l)):z(l)}p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(e),this.stream.on("error",a),this.stream.on("close",function(){p("(%s)stream :: on close",t.options.clientId),Vd(t.outgoing),p("stream: emit close to MqttClient"),t.emit("close")}),p("_setupStream: sending packet `connect`");let u=Object.create(this.options);if(u.cmd="connect",this.topicAliasRecv&&(u.properties||(u.properties={}),this.topicAliasRecv&&(u.properties.topicAliasMaximum=this.topicAliasRecv.max)),Rt(this,u),r.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"){let l=Yr({cmd:"auth",reasonCode:0},this.options.authPacket);Rt(this,l)}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){p("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)},this.options.connectTimeout)};T.prototype._handlePacket=function(t,e){let r=this.options;if(r.protocolVersion===5&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<t.length)return this.emit("error",new Error("exceeding packets size "+t.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(p("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",t),t.cmd){case"publish":this._handlePublish(t,e);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(t),e();break;case"pubrel":this._handlePubrel(t,e);break;case"connack":this._handleConnack(t),e();break;case"auth":this._handleAuth(t),e();break;case"pingresp":this._handlePingresp(t),e();break;case"disconnect":this._handleDisconnect(t),e();break;default:break}};T.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t&&t!==z?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting};T.prototype.publish=function(t,e,r,i){p("publish :: message `%s` to topic `%s`",e,t);let n=this.options;if(typeof r=="function"&&(i=r,r=null),r=Yr({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(i))return this;let o=this,a=function(){let u=0;if((r.qos===1||r.qos===2)&&(u=o._nextId(),u===null))return p("No messageId left"),!1;let l={cmd:"publish",topic:t,payload:e,qos:r.qos,retain:r.retain,messageId:u,dup:r.dup};switch(n.protocolVersion===5&&(l.properties=r.properties),p("publish :: qos",r.qos),r.qos){case 1:case 2:o.outgoing[l.messageId]={volatile:!1,cb:i||z},p("MqttClient:publish: packet cmd: %s",l.cmd),o._sendPacket(l,void 0,r.cbStorePut);break;default:p("MqttClient:publish: packet cmd: %s",l.cmd),o._sendPacket(l,i,r.cbStorePut);break}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!a())&&this._storeProcessingQueue.push({invoke:a,cbStorePut:r.cbStorePut,callback:i}),this};T.prototype.subscribe=function(){let t=this,e=new Array(arguments.length);for(let h=0;h<arguments.length;h++)e[h]=arguments[h];let r=[],i=e.shift(),n=i.resubscribe,s=e.pop()||z,o=e.pop(),a=this.options.protocolVersion;delete i.resubscribe,typeof i=="string"&&(i=[i]),typeof s!="function"&&(o=s,s=z);let u=Ua.validateTopics(i);if(u!==null)return hn(s,new Error("Invalid topic "+u)),this;if(this._checkDisconnecting(s))return p("subscribe: discconecting true"),this;let l={qos:0};if(a===5&&(l.nl=!1,l.rap=!1,l.rh=0),o=Yr(l,o),Array.isArray(i)?i.forEach(function(h){if(p("subscribe: array topic %s",h),!Object.prototype.hasOwnProperty.call(t._resubscribeTopics,h)||t._resubscribeTopics[h].qos<o.qos||n){let c={topic:h,qos:o.qos};a===5&&(c.nl=o.nl,c.rap=o.rap,c.rh=o.rh,c.properties=o.properties),p("subscribe: pushing topic `%s` and qos `%s` to subs list",c.topic,c.qos),r.push(c)}}):Object.keys(i).forEach(function(h){if(p("subscribe: object topic %s",h),!Object.prototype.hasOwnProperty.call(t._resubscribeTopics,h)||t._resubscribeTopics[h].qos<i[h].qos||n){let c={topic:h,qos:i[h].qos};a===5&&(c.nl=i[h].nl,c.rap=i[h].rap,c.rh=i[h].rh,c.properties=o.properties),p("subscribe: pushing `%s` to subs list",c),r.push(c)}}),!r.length)return s(null,[]),this;let f=function(){let h=t._nextId();if(h===null)return p("No messageId left"),!1;let c={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:h};if(o.properties&&(c.properties=o.properties),t.options.resubscribe){p("subscribe :: resubscribe true");let d=[];r.forEach(function(m){if(t.options.reconnectPeriod>0){let y={qos:m.qos};a===5&&(y.nl=m.nl||!1,y.rap=m.rap||!1,y.rh=m.rh||0,y.properties=m.properties),t._resubscribeTopics[m.topic]=y,d.push(m.topic)}}),t.messageIdToTopic[c.messageId]=d}return t.outgoing[c.messageId]={volatile:!0,cb:function(d,m){if(!d){let y=m.granted;for(let v=0;v<y.length;v+=1)r[v].qos=y[v]}s(d,r)}},p("subscribe :: call _sendPacket"),t._sendPacket(c),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!f())&&this._storeProcessingQueue.push({invoke:f,callback:s}),this};T.prototype.unsubscribe=function(){let t=this,e=new Array(arguments.length);for(let a=0;a<arguments.length;a++)e[a]=arguments[a];let r=e.shift(),i=e.pop()||z,n=e.pop();typeof r=="string"&&(r=[r]),typeof i!="function"&&(n=i,i=z);let s=Ua.validateTopics(r);if(s!==null)return hn(i,new Error("Invalid topic "+s)),this;if(t._checkDisconnecting(i))return this;let o=function(){let a=t._nextId();if(a===null)return p("No messageId left"),!1;let u={cmd:"unsubscribe",qos:1,messageId:a};return typeof r=="string"?u.unsubscriptions=[r]:Array.isArray(r)&&(u.unsubscriptions=r),t.options.resubscribe&&u.unsubscriptions.forEach(function(l){delete t._resubscribeTopics[l]}),typeof n=="object"&&n.properties&&(u.properties=n.properties),t.outgoing[u.messageId]={volatile:!0,cb:i},p("unsubscribe: call _sendPacket"),t._sendPacket(u),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!o())&&this._storeProcessingQueue.push({invoke:o,callback:i}),this};T.prototype.end=function(t,e,r){let i=this;p("end :: (%s)",this.options.clientId),(t==null||typeof t!="boolean")&&(r=e||z,e=t,t=!1,typeof e!="object"&&(r=e,e=null,typeof r!="function"&&(r=z))),typeof e!="object"&&(r=e,e=null),p("end :: cb? %s",!!r),r=r||z;function n(){p("end :: closeStores: closing incoming and outgoing stores"),i.disconnected=!0,i.incomingStore.close(function(o){i.outgoingStore.close(function(a){if(p("end :: closeStores: emitting end"),i.emit("end"),r){let u=o||a;p("end :: closeStores: invoking callback with args"),r(u)}})}),i._deferredReconnect&&i._deferredReconnect()}function s(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",i.options.clientId,t),i._cleanUp(t,()=>{p("end :: finish :: calling process.nextTick on closeStores"),cn(n.bind(i))},e)}return this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!t&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",i.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,s,10))):(p("end :: (%s) :: immediately calling finish",i.options.clientId),s()),this)};T.prototype.removeOutgoingMessage=function(t){let e=this.outgoing[t]?this.outgoing[t].cb:null;return delete this.outgoing[t],this.outgoingStore.del({messageId:t},function(){e(new Error("Message removed"))}),this};T.prototype.reconnect=function(t){p("client reconnect");let e=this,r=function(){t?(e.options.incomingStore=t.incomingStore,e.options.outgoingStore=t.outgoingStore):(e.options.incomingStore=null,e.options.outgoingStore=null),e.incomingStore=e.options.incomingStore||new Gr,e.outgoingStore=e.options.outgoingStore||new Gr,e.disconnecting=!1,e.disconnected=!1,e._deferredReconnect=null,e._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this};T.prototype._reconnect=function(){p("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),p("client already connected. disconnecting first.")):(p("_reconnect: calling _setupStream"),this._setupStream())};T.prototype._setupReconnect=function(){let t=this;!t.disconnecting&&!t.reconnectTimer&&t.options.reconnectPeriod>0?(this.reconnecting||(p("_setupReconnect :: emit `offline` state"),this.emit("offline"),p("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),p("_setupReconnect :: setting reconnectTimer for %d ms",t.options.reconnectPeriod),t.reconnectTimer=setInterval(function(){p("reconnectTimer :: reconnect triggered!"),t._reconnect()},t.options.reconnectPeriod)):p("_setupReconnect :: doing nothing...")};T.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)};T.prototype._cleanUp=function(t,e){let r=arguments[2];if(e&&(p("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",e)),p("_cleanUp :: forced? %s",t),t)this.options.reconnectPeriod===0&&this.options.clean&&Wd(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{let i=Yr({cmd:"disconnect"},r);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(i,hn.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(p("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(p("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),e&&!this.connected&&(p("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",e),e())};T.prototype._sendPacket=function(t,e,r){p("_sendPacket :: (%s) :: start",this.options.clientId),r=r||z,e=e||z;let i=Fd(this,t);if(i){e(i);return}if(!this.connected){if(t.cmd==="auth"){this._shiftPingInterval(),Rt(this,t,e);return}p("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(t,e,r);return}switch(this._shiftPingInterval(),t.cmd){case"publish":break;case"pubrel":Ma(this,t,e,r);return;default:Rt(this,t,e);return}switch(t.qos){case 2:case 1:Ma(this,t,e,r);break;case 0:default:Rt(this,t,e);break}p("_sendPacket :: (%s) :: end",this.options.clientId)};T.prototype._storePacket=function(t,e,r){p("_storePacket :: packet: %o",t),p("_storePacket :: cb? %s",!!e),r=r||z;let i=t;if(i.cmd==="publish"){i=Da(t);let n=ja(this,i);if(n)return e&&e(n)}(i.qos||0)===0&&this.queueQoSZero||i.cmd!=="publish"?this.queue.push({packet:i,cb:e}):i.qos>0?(e=this.outgoing[i.messageId]?this.outgoing[i.messageId].cb:null,this.outgoingStore.put(i,function(n){if(n)return e&&e(n);r()})):e&&e(new Error("No connection to broker"))};T.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);let t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=Dd(function(){t._checkPing()},this.options.keepalive*1e3))};T.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)};T.prototype._checkPing=function(){p("_checkPing :: checking ping..."),this.pingResp?(p("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(p("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))};T.prototype._handlePingresp=function(){this.pingResp=!0};T.prototype._handleConnack=function(t){p("_handleConnack");let e=this.options,i=e.protocolVersion===5?t.reasonCode:t.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,t.properties){if(t.properties.topicAliasMaximum){if(t.properties.topicAliasMaximum>65535){this.emit("error",new Error("topicAliasMaximum from broker is out of range"));return}t.properties.topicAliasMaximum>0&&(this.topicAliasSend=new Ld(t.properties.topicAliasMaximum))}t.properties.serverKeepAlive&&e.keepalive&&(e.keepalive=t.properties.serverKeepAlive,this._shiftPingInterval()),t.properties.maximumPacketSize&&(e.properties||(e.properties={}),e.properties.maximumPacketSize=t.properties.maximumPacketSize)}if(i===0)this.reconnecting=!1,this._onConnect(t);else if(i>0){let n=new Error("Connection refused: "+Qr[i]);n.code=i,this.emit("error",n)}};T.prototype._handleAuth=function(t){let r=this.options.protocolVersion,i=r===5?t.reasonCode:t.returnCode;if(r!==5){let s=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+r);s.code=i,this.emit("error",s);return}let n=this;this.handleAuth(t,function(s,o){if(s){n.emit("error",s);return}if(i===24)n.reconnecting=!1,n._sendPacket(o);else{let a=new Error("Connection refused: "+Qr[i]);s.code=i,n.emit("error",a)}})};T.prototype.handleAuth=function(t,e){e()};T.prototype._handlePublish=function(t,e){p("_handlePublish: packet %o",t),e=typeof e<"u"?e:z;let r=t.topic.toString(),i=t.payload,n=t.qos,s=t.messageId,o=this,a=this.options,u=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let l;if(t.properties&&(l=t.properties.topicAlias),typeof l<"u")if(r.length===0)if(l>0&&l<=65535){let f=this.topicAliasRecv.getTopicByAlias(l);if(f)r=f,p("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,l);else{p("_handlePublish :: unregistered topic alias. alias: %d",l),this.emit("error",new Error("Received unregistered Topic Alias"));return}}else{p("_handlePublish :: topic alias out of range. alias: %d",l),this.emit("error",new Error("Received Topic Alias is out of range"));return}else if(this.topicAliasRecv.put(r,l))p("_handlePublish :: registered topic: %s - alias: %d",r,l);else{p("_handlePublish :: topic alias out of range. alias: %d",l),this.emit("error",new Error("Received Topic Alias is out of range"));return}}switch(p("_handlePublish: qos %d",n),n){case 2:{a.customHandleAcks(r,i,t,function(l,f){if(l instanceof Error||(f=l,l=null),l)return o.emit("error",l);if(u.indexOf(f)===-1)return o.emit("error",new Error("Wrong reason code for pubrec"));f?o._sendPacket({cmd:"pubrec",messageId:s,reasonCode:f},e):o.incomingStore.put(t,function(){o._sendPacket({cmd:"pubrec",messageId:s},e)})});break}case 1:{a.customHandleAcks(r,i,t,function(l,f){if(l instanceof Error||(f=l,l=null),l)return o.emit("error",l);if(u.indexOf(f)===-1)return o.emit("error",new Error("Wrong reason code for puback"));f||o.emit("message",r,i,t),o.handleMessage(t,function(h){if(h)return e&&e(h);o._sendPacket({cmd:"puback",messageId:s,reasonCode:f},e)})});break}case 0:this.emit("message",r,i,t),this.handleMessage(t,e);break;default:p("_handlePublish: unknown QoS. Doing nothing.");break}};T.prototype.handleMessage=function(t,e){e()};T.prototype._handleAck=function(t){let e=t.messageId,r=t.cmd,i=null,n=this.outgoing[e]?this.outgoing[e].cb:null,s=this,o;if(!n){p("_handleAck :: Server sent an ack in error. Ignoring.");return}switch(p("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{let a=t.reasonCode;a&&a>0&&a!==16&&(o=new Error("Publish error: "+Qr[a]),o.code=a,n(o,t)),delete this.outgoing[e],this.outgoingStore.del(t,n),this.messageIdProvider.deallocate(e),this._invokeStoreProcessingQueue();break}case"pubrec":{i={cmd:"pubrel",qos:2,messageId:e};let a=t.reasonCode;a&&a>0&&a!==16?(o=new Error("Publish error: "+Qr[a]),o.code=a,n(o,t)):this._sendPacket(i);break}case"suback":{delete this.outgoing[e],this.messageIdProvider.deallocate(e);for(let a=0;a<t.granted.length;a++)if((t.granted[a]&128)!==0){let u=this.messageIdToTopic[e];u&&u.forEach(function(l){delete s._resubscribeTopics[l]})}this._invokeStoreProcessingQueue(),n(null,t);break}case"unsuback":{delete this.outgoing[e],this.messageIdProvider.deallocate(e),this._invokeStoreProcessingQueue(),n(null);break}default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&Object.keys(this.outgoing).length===0&&this.emit("outgoingEmpty")};T.prototype._handlePubrel=function(t,e){p("handling pubrel packet"),e=typeof e<"u"?e:z;let r=t.messageId,i=this,n={cmd:"pubcomp",messageId:r};i.incomingStore.get(t,function(s,o){s?i._sendPacket(n,e):(i.emit("message",o.topic,o.payload,o),i.handleMessage(o,function(a){if(a)return e(a);i.incomingStore.del(o,z),i._sendPacket(n,e)}))})};T.prototype._handleDisconnect=function(t){this.emit("disconnect",t)};T.prototype._nextId=function(){return this.messageIdProvider.allocate()};T.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()};T.prototype._resubscribe=function(){p("_resubscribe");let t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion===5&&!this.connackPacket.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){p("_resubscribe: protocolVersion 5");for(let e=0;e<t.length;e++){let r={};r[t[e]]=this._resubscribeTopics[t[e]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[e]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1};T.prototype._onConnect=function(t){if(this.disconnected){this.emit("connect",t);return}let e=this;this.connackPacket=t,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0;function r(){let i=e.outgoingStore.createStream();function n(){e._storeProcessing=!1,e._packetIdsDuringStoreProcessing={}}e.once("close",s),i.on("error",function(a){n(),e._flushStoreProcessingQueue(),e.removeListener("close",s),e.emit("error",a)});function s(){i.destroy(),i=null,e._flushStoreProcessingQueue(),n()}function o(){if(!i)return;e._storeProcessing=!0;let a=i.read(1),u;if(!a){i.once("readable",o);return}if(e._packetIdsDuringStoreProcessing[a.messageId]){o();return}!e.disconnecting&&!e.reconnectTimer?(u=e.outgoing[a.messageId]?e.outgoing[a.messageId].cb:null,e.outgoing[a.messageId]={volatile:!1,cb:function(l,f){u&&u(l,f),o()}},e._packetIdsDuringStoreProcessing[a.messageId]=!0,e.messageIdProvider.register(a.messageId)?e._sendPacket(a):p("messageId: %d has already used.",a.messageId)):i.destroy&&i.destroy()}i.on("end",function(){let a=!0;for(let u in e._packetIdsDuringStoreProcessing)if(!e._packetIdsDuringStoreProcessing[u]){a=!1;break}a?(n(),e.removeListener("close",s),e._invokeAllStoreProcessingQueue(),e.emit("connect",t)):r()}),o()}r()};T.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){let t=this._storeProcessingQueue[0];if(t&&t.invoke())return this._storeProcessingQueue.shift(),!0}return!1};T.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););};T.prototype._flushStoreProcessingQueue=function(){for(let t of this._storeProcessingQueue)t.cbStorePut&&t.cbStorePut(new Error("Connection closed")),t.callback&&t.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)};Fa.exports=T});var pn=g((om,Wa)=>{"use strict";var Hd=require("net"),Kd=_e()("mqttjs:tcp");function zd(t,e){e.port=e.port||1883,e.hostname=e.hostname||e.host||"localhost";let r=e.port,i=e.hostname;return Kd("port %d and host %s",r,i),Hd.createConnection(r,i)}Wa.exports=zd});var Xr=g((am,Va)=>{"use strict";var $d=require("tls"),Gd=require("net"),Qd=_e()("mqttjs:tls");function Yd(t,e){e.port=e.port||8883,e.host=e.hostname||e.host||"localhost",Gd.isIP(e.host)===0&&(e.servername=e.host),e.rejectUnauthorized=e.rejectUnauthorized!==!1,delete e.path,Qd("port %d host %s rejectUnauthorized %b",e.port,e.host,e.rejectUnauthorized);let r=$d.connect(e);r.on("secureConnect",function(){e.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",i)});function i(n){e.rejectUnauthorized&&t.emit("error",n),r.end()}return r.on("error",i),r}Va.exports=Yd});var za=g((lm,Ka)=>{"use strict";Ka.exports=Ha;function Ha(t,e){if(t&&e)return Ha(t)(e);if(typeof t!="function")throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(i){r[i]=t[i]}),r;function r(){for(var i=new Array(arguments.length),n=0;n<i.length;n++)i[n]=arguments[n];var s=t.apply(this,i),o=i[i.length-1];return typeof s=="function"&&s!==o&&Object.keys(o).forEach(function(a){s[a]=o[a]}),s}}});var Qa=g((um,gn)=>{"use strict";var $a=za();gn.exports=$a(Jr);gn.exports.strict=$a(Ga);Jr.proto=Jr(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Jr(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Ga(this)},configurable:!0})});function Jr(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function Ga(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}});var Ja=g((fm,Xa)=>{"use strict";var Xd=Qa(),Jd=function(){},Zd=function(t){return t.setHeader&&typeof t.abort=="function"},ep=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3},Ya=function(t,e,r){if(typeof e=="function")return Ya(t,null,e);e||(e={}),r=Xd(r||Jd);var i=t._writableState,n=t._readableState,s=e.readable||e.readable!==!1&&t.readable,o=e.writable||e.writable!==!1&&t.writable,a=!1,u=function(){t.writable||l()},l=function(){o=!1,s||r.call(t)},f=function(){s=!1,o||r.call(t)},h=function(v){r.call(t,v?new Error("exited with error code: "+v):null)},c=function(v){r.call(t,v)},d=function(){process.nextTick(m)},m=function(){if(!a){if(s&&!(n&&n.ended&&!n.destroyed))return r.call(t,new Error("premature close"));if(o&&!(i&&i.ended&&!i.destroyed))return r.call(t,new Error("premature close"))}},y=function(){t.req.on("finish",l)};return Zd(t)?(t.on("complete",l),t.on("abort",d),t.req?y():t.on("request",y)):o&&!i&&(t.on("end",u),t.on("close",u)),ep(t)&&t.on("exit",h),t.on("end",f),t.on("finish",l),e.error!==!1&&t.on("error",c),t.on("close",d),function(){a=!0,t.removeListener("complete",l),t.removeListener("abort",d),t.removeListener("request",y),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("exit",h),t.removeListener("end",f),t.removeListener("error",c),t.removeListener("close",d)}};Xa.exports=Ya});var el=g((cm,Za)=>{"use strict";Za.exports=tp;function tp(t){var e=t._readableState;return e?e.objectMode||typeof t._duplexState=="number"?t.read():t.read(rp(e)):null}function rp(t){return t.buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length}});var ei=g((hm,nl)=>{"use strict";var Zr=Ne(),tl=Ja(),ip=we(),np=el(),rl=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),yn=function(t,e){t._corked?t.once("uncork",e):e()},sp=function(t,e){t._autoDestroy&&t.destroy(e)},il=function(t,e){return function(r){r?sp(t,r.message==="premature close"?null:r):e&&!t._ended&&t.end()}},op=function(t,e){if(!t||t._writableState&&t._writableState.finished)return e();if(t._writableState)return t.end(e);t.end(),e()},ap=function(){},lp=function(t){return new Zr.Readable({objectMode:!0,highWaterMark:16}).wrap(t)},$=function(t,e,r){if(!(this instanceof $))return new $(t,e,r);Zr.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,t&&this.setWritable(t),e&&this.setReadable(e)};ip($,Zr.Duplex);$.obj=function(t,e,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new $(t,e,r)};$.prototype.cork=function(){++this._corked===1&&this.emit("cork")};$.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};$.prototype.setWritable=function(t){if(this._unwrite&&this._unwrite(),this.destroyed){t&&t.destroy&&t.destroy();return}if(t===null||t===!1){this.end();return}var e=this,r=tl(t,{writable:!0,readable:!1},il(this,this._forwardEnd)),i=function(){var s=e._ondrain;e._ondrain=null,s&&s()},n=function(){e._writable.removeListener("drain",i),r()};this._unwrite&&process.nextTick(i),this._writable=t,this._writable.on("drain",i),this._unwrite=n,this.uncork()};$.prototype.setReadable=function(t){if(this._unread&&this._unread(),this.destroyed){t&&t.destroy&&t.destroy();return}if(t===null||t===!1){this.push(null),this.resume();return}var e=this,r=tl(t,{writable:!1,readable:!0},il(this)),i=function(){e._forward()},n=function(){e.push(null)},s=function(){e._readable2.removeListener("readable",i),e._readable2.removeListener("end",n),r()};this._drained=!0,this._readable=t,this._readable2=t._readableState?t:lp(t),this._readable2.on("readable",i),this._readable2.on("end",n),this._unread=s,this._forward()};$.prototype._read=function(){this._drained=!0,this._forward()};$.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var t;this._drained&&(t=np(this._readable2))!==null;)this.destroyed||(this._drained=this.push(t));this._forwarding=!1}};$.prototype.destroy=function(t,e){if(e||(e=ap),this.destroyed)return e(null);this.destroyed=!0;var r=this;process.nextTick(function(){r._destroy(t),e(null)})};$.prototype._destroy=function(t){if(t){var e=this._ondrain;this._ondrain=null,e?e(t):this.emit("error",t)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")};$.prototype._write=function(t,e,r){if(!this.destroyed){if(this._corked)return yn(this,this._write.bind(this,t,e,r));if(t===rl)return this._finish(r);if(!this._writable)return r();this._writable.write(t)===!1?this._ondrain=r:this.destroyed||r()}};$.prototype._finish=function(t){var e=this;this.emit("preend"),yn(this,function(){op(e._forwardEnd&&e._writable,function(){e._writableState.prefinished===!1&&(e._writableState.prefinished=!0),e.emit("prefinish"),yn(e,t)})})};$.prototype.end=function(t,e,r){return typeof t=="function"?this.end(null,null,t):typeof e=="function"?this.end(t,null,e):(this._ended=!0,t&&this.write(t),!this._writableState.ending&&!this._writableState.destroyed&&this.write(rl),Zr.Writable.prototype.end.call(this,r))};nl.exports=$});var _n=g((dm,ol)=>{"use strict";var{Buffer:sl}=require("buffer"),up=Ne().Transform,fp=ei(),Pe,ti,re;function cp(){let t=new up;return t._write=function(e,r,i){Pe.send({data:e.buffer,success:function(){i()},fail:function(n){i(new Error(n))}})},t._flush=function(r){Pe.close({success:function(){r()}})},t}function hp(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}function dp(t,e){let r=t.protocol==="wxs"?"wss":"ws",i=r+"://"+t.hostname+t.path;return t.port&&t.port!==80&&t.port!==443&&(i=r+"://"+t.hostname+":"+t.port+t.path),typeof t.transformWsUrl=="function"&&(i=t.transformWsUrl(i,t,e)),i}function pp(){Pe.onOpen(function(){re.setReadable(ti),re.setWritable(ti),re.emit("connect")}),Pe.onMessage(function(t){let e=t.data;e instanceof ArrayBuffer?e=sl.from(e):e=sl.from(e,"utf8"),ti.push(e)}),Pe.onClose(function(){re.end(),re.destroy()}),Pe.onError(function(t){re.destroy(new Error(t.errMsg))})}function gp(t,e){if(e.hostname=e.hostname||e.host,!e.hostname)throw new Error("Could not determine host. Specify host manually.");let r=e.protocolId==="MQIsdp"&&e.protocolVersion===3?"mqttv3.1":"mqtt";hp(e);let i=dp(e,t);Pe=wx.connectSocket({url:i,protocols:[r]}),ti=cp(),re=fp.obj(),re._destroy=function(s,o){Pe.close({success:function(){o&&o(s)}})};let n=re.destroy;return re.destroy=function(){re.destroy=n;let s=this;setTimeout(function(){Pe.close({fail:function(){s._destroy(new Error)}})},0)}.bind(re),pp(),re}ol.exports=gp});var vn=g((pm,ll)=>{"use strict";var{Buffer:mn}=require("buffer"),yp=Ne().Transform,_p=ei(),$e,Yt,ze,al=!1;function mp(){let t=new yp;return t._write=function(e,r,i){$e.sendSocketMessage({data:e.buffer,success:function(){i()},fail:function(){i(new Error)}})},t._flush=function(r){$e.closeSocket({success:function(){r()}})},t}function vp(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}function bp(t,e){let r=t.protocol==="alis"?"wss":"ws",i=r+"://"+t.hostname+t.path;return t.port&&t.port!==80&&t.port!==443&&(i=r+"://"+t.hostname+":"+t.port+t.path),typeof t.transformWsUrl=="function"&&(i=t.transformWsUrl(i,t,e)),i}function wp(){al||(al=!0,$e.onSocketOpen(function(){ze.setReadable(Yt),ze.setWritable(Yt),ze.emit("connect")}),$e.onSocketMessage(function(t){if(typeof t.data=="string"){let e=mn.from(t.data,"base64");Yt.push(e)}else{let e=new FileReader;e.addEventListener("load",function(){let r=e.result;r instanceof ArrayBuffer?r=mn.from(r):r=mn.from(r,"utf8"),Yt.push(r)}),e.readAsArrayBuffer(t.data)}}),$e.onSocketClose(function(){ze.end(),ze.destroy()}),$e.onSocketError(function(t){ze.destroy(t)}))}function Sp(t,e){if(e.hostname=e.hostname||e.host,!e.hostname)throw new Error("Could not determine host. Specify host manually.");let r=e.protocolId==="MQIsdp"&&e.protocolVersion===3?"mqttv3.1":"mqtt";vp(e);let i=bp(e,t);return $e=e.my,$e.connectSocket({url:i,protocols:r}),Yt=mp(),ze=_p.obj(),wp(),ze}ll.exports=Sp});var ct=g((gm,ul)=>{"use strict";ul.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 Xt=g((ym,bn)=>{"use strict";var{EMPTY_BUFFER:Ep}=ct();function fl(t,e){if(t.length===0)return Ep;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let n=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return i<e?r.slice(0,i):r}function cl(t,e,r,i,n){for(let s=0;s<n;s++)r[i+s]=t[s]^e[s&3]}function hl(t,e){let r=t.length;for(let i=0;i<r;i++)t[i]^=e[i&3]}function dl(t){return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function ri(t){if(ri.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=Buffer.from(t):ArrayBuffer.isView(t)?e=Buffer.from(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ri.readOnly=!1),e}try{let t=require("bufferutil"),e=t.BufferUtil||t;bn.exports={concat:fl,mask(r,i,n,s,o){o<48?cl(r,i,n,s,o):e.mask(r,i,n,s,o)},toArrayBuffer:dl,toBuffer:ri,unmask(r,i){r.length<32?hl(r,i):e.unmask(r,i)}}}catch{bn.exports={concat:fl,mask:cl,toArrayBuffer:dl,toBuffer:ri,unmask:hl}}});var yl=g((_m,gl)=>{"use strict";var pl=Symbol("kDone"),wn=Symbol("kRun"),Sn=class{constructor(e){this[pl]=()=>{this.pending--,this[wn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[wn]()}[wn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[pl])}}};gl.exports=Sn});var er=g((mm,bl)=>{"use strict";var Jt=require("zlib"),_l=Xt(),xp=yl(),{kStatusCode:ml,NOOP:Tp}=ct(),Cp=Buffer.from([0,0,255,255]),si=Symbol("permessage-deflate"),Oe=Symbol("total-length"),Zt=Symbol("callback"),Ge=Symbol("buffers"),ni=Symbol("error"),ii,En=class{constructor(e,r,i){if(this._maxPayload=i|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!ii){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ii=new xp(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Zt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.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(e){let r=e[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(e){return e.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})}),e}decompress(e,r,i){ii.add(n=>{this._decompress(e,r,(s,o)=>{n(),i(s,o)})})}compress(e,r,i){ii.add(n=>{this._compress(e,r,(s,o)=>{n(),i(s,o)})})}_decompress(e,r,i){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Jt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Jt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[si]=this,this._inflate[Oe]=0,this._inflate[Ge]=[],this._inflate.on("error",Op),this._inflate.on("data",vl)}this._inflate[Zt]=i,this._inflate.write(e),r&&this._inflate.write(Cp),this._inflate.flush(()=>{let s=this._inflate[ni];if(s){this._inflate.close(),this._inflate=null,i(s);return}let o=_l.concat(this._inflate[Ge],this._inflate[Oe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Oe]=0,this._inflate[Ge]=[],r&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),i(null,o)})}_compress(e,r,i){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Jt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Jt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[Oe]=0,this._deflate[Ge]=[],this._deflate.on("error",Tp),this._deflate.on("data",Pp)}this._deflate[Zt]=i,this._deflate.write(e),this._deflate.flush(Jt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=_l.concat(this._deflate[Ge],this._deflate[Oe]);r&&(s=s.slice(0,s.length-4)),this._deflate[Zt]=null,this._deflate[Oe]=0,this._deflate[Ge]=[],r&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),i(null,s)})}};bl.exports=En;function Pp(t){this[Ge].push(t),this[Oe]+=t.length}function vl(t){if(this[Oe]+=t.length,this[si]._maxPayload<1||this[Oe]<=this[si]._maxPayload){this[Ge].push(t);return}this[ni]=new RangeError("Max payload size exceeded"),this[ni].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ni][ml]=1009,this.removeListener("data",vl),this.reset()}function Op(t){this[si]._inflate=null,t[ml]=1007,this[Zt](t)}});var Tn=g((vm,xn)=>{"use strict";function wl(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Sl(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}try{let t=require("utf-8-validate");typeof t=="object"&&(t=t.Validation.isValidUTF8),xn.exports={isValidStatusCode:wl,isValidUTF8(e){return e.length<150?Sl(e):t(e)}}}catch{xn.exports={isValidStatusCode:wl,isValidUTF8:Sl}}});var In=g((bm,Ol)=>{"use strict";var{Writable:Ip}=require("stream"),El=er(),{BINARY_TYPES:Rp,EMPTY_BUFFER:Ap,kStatusCode:Bp,kWebSocket:kp}=ct(),{concat:Cn,toArrayBuffer:Lp,unmask:Mp}=Xt(),{isValidStatusCode:qp,isValidUTF8:xl}=Tn(),tr=0,Tl=1,Cl=2,Pl=3,Pn=4,Np=5,On=class extends Ip{constructor(e,r,i,n){super(),this._binaryType=e||Rp[0],this[kp]=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=tr,this._loop=!1}_write(e,r,i){if(this._opcode===8&&this._state==tr)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=i.slice(e),i.slice(0,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],n=r.length-e;e>=i.length?r.set(this._buffers.shift(),n):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),n),this._buffers[0]=i.slice(e)),e-=i.length}while(e>0);return r}startLoop(e){let r;this._loop=!0;do switch(this._state){case tr:r=this.getInfo();break;case Tl:r=this.getPayloadLength16();break;case Cl:r=this.getPayloadLength64();break;case Pl:this.getMask();break;case Pn:r=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(r)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if((e[0]&48)!==0)return this._loop=!1,j(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let r=(e[0]&64)===64;if(r&&!this._extensions[El.extensionName])return this._loop=!1,j(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(r)return this._loop=!1,j(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,j(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,j(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,j(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(r)return this._loop=!1,j(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,j(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,j(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,j(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,j(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Tl;else if(this._payloadLength===127)this._state=Cl;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 e=this.consume(8),r=e.readUInt32BE(0);return r>Math.pow(2,21)-1?(this._loop=!1,j(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=r*Math.pow(2,32)+e.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,j(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Pl:this._state=Pn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Pn}getData(e){let r=Ap;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&Mp(r,this._mask)}if(this._opcode>7)return this.controlMessage(r);if(this._compressed){this._state=Np,this.decompress(r,e);return}return r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage()}decompress(e,r){this._extensions[El.extensionName].decompress(e,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(j(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 e=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=Cn(r,e):this._binaryType==="arraybuffer"?i=Lp(Cn(r,e)):i=r,this.emit("message",i)}else{let i=Cn(r,e);if(!xl(i))return this._loop=!1,j(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",i.toString())}}this._state=tr}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,""),this.end();else{if(e.length===1)return j(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let r=e.readUInt16BE(0);if(!qp(r))return j(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let i=e.slice(2);if(!xl(i))return j(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",e):this.emit("pong",e);this._state=tr}};Ol.exports=On;function j(t,e,r,i,n){let s=new t(r?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,j),s.code=n,s[Bp]=i,s}});var An=g((Em,Al)=>{"use strict";var wm=require("net"),Sm=require("tls"),{randomFillSync:Dp}=require("crypto"),Il=er(),{EMPTY_BUFFER:Up}=ct(),{isValidStatusCode:jp}=Tn(),{mask:Rl,toBuffer:Ie}=Xt(),ht=Buffer.alloc(4),Rn=class t{constructor(e,r){this._extensions=r||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,r){let i=r.mask&&r.readOnly,n=r.mask?6:2,s=e.length;e.length>=65536?(n+=8,s=127):e.length>125&&(n+=2,s=126);let o=Buffer.allocUnsafe(i?e.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(e.length,2):s===127&&(o.writeUInt32BE(0,2),o.writeUInt32BE(e.length,6)),r.mask?(Dp(ht,0,4),o[1]|=128,o[n-4]=ht[0],o[n-3]=ht[1],o[n-2]=ht[2],o[n-1]=ht[3],i?(Rl(e,ht,o,n,e.length),[o]):(Rl(e,ht,e,0,e.length),[o,e])):[o,e]}close(e,r,i,n){let s;if(e===void 0)s=Up;else{if(typeof e!="number"||!jp(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||r==="")s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,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(e,0),s.write(r,2)}}this._deflating?this.enqueue([this.doClose,s,i,n]):this.doClose(s,i,n)}doClose(e,r,i){this.sendFrame(t.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:r,readOnly:!1}),i)}ping(e,r,i){let n=Ie(e);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,Ie.readOnly,i]):this.doPing(n,r,Ie.readOnly,i)}doPing(e,r,i,n){this.sendFrame(t.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:r,readOnly:i}),n)}pong(e,r,i){let n=Ie(e);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,Ie.readOnly,i]):this.doPong(n,r,Ie.readOnly,i)}doPong(e,r,i,n){this.sendFrame(t.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:r,readOnly:i}),n)}send(e,r,i){let n=Ie(e),s=this._extensions[Il.extensionName],o=r.binary?2:1,a=r.compress;if(this._firstFragment?(this._firstFragment=!1,a&&s&&(a=n.length>=s._threshold),this._compress=a):(a=!1,o=0),r.fin&&(this._firstFragment=!0),s){let u={fin:r.fin,rsv1:a,opcode:o,mask:r.mask,readOnly:Ie.readOnly};this._deflating?this.enqueue([this.dispatch,n,this._compress,u,i]):this.dispatch(n,this._compress,u,i)}else this.sendFrame(t.frame(n,{fin:r.fin,rsv1:!1,opcode:o,mask:r.mask,readOnly:Ie.readOnly}),i)}dispatch(e,r,i,n){if(!r){this.sendFrame(t.frame(e,i),n);return}let s=this._extensions[Il.extensionName];this._bufferedBytes+=e.length,this._deflating=!0,s.compress(e,i.fin,(o,a)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(u);for(let l=0;l<this._queue.length;l++){let f=this._queue[l][4];typeof f=="function"&&f(u)}return}this._bufferedBytes-=e.length,this._deflating=!1,i.readOnly=!1,this.sendFrame(t.frame(a,i),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[1].length,Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[1].length,this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Al.exports=Rn});var kl=g((xm,Bl)=>{"use strict";var At=class{constructor(e,r){this.target=r,this.type=e}},Bn=class extends At{constructor(e,r){super("message",r),this.data=e}},kn=class extends At{constructor(e,r,i){super("close",i),this.wasClean=i._closeFrameReceived&&i._closeFrameSent,this.reason=r,this.code=e}},Ln=class extends At{constructor(e){super("open",e)}},Mn=class extends At{constructor(e,r){super("error",r),this.message=e.message,this.error=e}},Fp={addEventListener(t,e,r){if(typeof e!="function")return;function i(u){e.call(this,new Bn(u,this))}function n(u,l){e.call(this,new kn(u,l,this))}function s(u){e.call(this,new Mn(u,this))}function o(){e.call(this,new Ln(this))}let a=r&&r.once?"once":"on";t==="message"?(i._listener=e,this[a](t,i)):t==="close"?(n._listener=e,this[a](t,n)):t==="error"?(s._listener=e,this[a](t,s)):t==="open"?(o._listener=e,this[a](t,o)):this[a](t,e)},removeEventListener(t,e){let r=this.listeners(t);for(let i=0;i<r.length;i++)(r[i]===e||r[i]._listener===e)&&this.removeListener(t,r[i])}};Bl.exports=Fp});var qn=g((Tm,Ll)=>{"use strict";var rr=[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 be(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Wp(t){let e=Object.create(null);if(t===void 0||t==="")return e;let r=Object.create(null),i=!1,n=!1,s=!1,o,a,u=-1,l=-1,f=0;for(;f<t.length;f++){let c=t.charCodeAt(f);if(o===void 0)if(l===-1&&rr[c]===1)u===-1&&(u=f);else if(c===32||c===9)l===-1&&u!==-1&&(l=f);else if(c===59||c===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=t.slice(u,l);c===44?(be(e,d,r),r=Object.create(null)):o=d,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)if(l===-1&&rr[c]===1)u===-1&&(u=f);else if(c===32||c===9)l===-1&&u!==-1&&(l=f);else if(c===59||c===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),be(r,t.slice(u,l),!0),c===44&&(be(e,o,r),r=Object.create(null),o=void 0),u=l=-1}else if(c===61&&u!==-1&&l===-1)a=t.slice(u,f),u=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(rr[c]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1?u=f:i||(i=!0),n=!1}else if(s)if(rr[c]===1)u===-1&&(u=f);else if(c===34&&u!==-1)s=!1,l=f;else if(c===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===34&&t.charCodeAt(f-1)===61)s=!0;else if(l===-1&&rr[c]===1)u===-1&&(u=f);else if(u!==-1&&(c===32||c===9))l===-1&&(l=f);else if(c===59||c===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=t.slice(u,l);i&&(d=d.replace(/\\/g,""),i=!1),be(r,a,d),c===44&&(be(e,o,r),r=Object.create(null),o=void 0),a=void 0,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`)}if(u===-1||s)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let h=t.slice(u,l);return o===void 0?be(e,h,r):(a===void 0?be(r,h,!0):i?be(r,a,h.replace(/\\/g,"")):be(r,a,h),be(e,o,r)),e}function Vp(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].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(", ")}Ll.exports={format:Vp,parse:Wp}});var Wn=g((Pm,Hl)=>{"use strict";var Hp=require("events"),Kp=require("https"),zp=require("http"),Nl=require("net"),$p=require("tls"),{randomBytes:Gp,createHash:Qp}=require("crypto"),{Readable:Cm}=require("stream"),{URL:Nn}=require("url"),Qe=er(),Yp=In(),Xp=An(),{BINARY_TYPES:Ml,EMPTY_BUFFER:Dn,GUID:Jp,kStatusCode:Zp,kWebSocket:Q,NOOP:Dl}=ct(),{addEventListener:eg,removeEventListener:tg}=kl(),{format:rg,parse:ig}=qn(),{toBuffer:ng}=Xt(),Re=["CONNECTING","OPEN","CLOSING","CLOSED"],Un=[8,13],sg=30*1e3,N=class t extends Hp{constructor(e,r,i){super(),this._binaryType=Ml[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==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),Ul(this,e,r,i)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Ml.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}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(e){}get onerror(){}set onerror(e){}get onopen(){}set onopen(e){}get onmessage(){}set onmessage(e){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let n=new Yp(this.binaryType,this._extensions,this._isServer,i);this._sender=new Xp(e,this._extensions),this._receiver=n,this._socket=e,n[Q]=this,e[Q]=this,n.on("conclude",lg),n.on("drain",ug),n.on("error",fg),n.on("message",cg),n.on("ping",hg),n.on("pong",dg),e.setTimeout(0),e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Fl),e.on("data",oi),e.on("end",Wl),e.on("error",Vl),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Qe.extensionName]&&this._extensions[Qe.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING)return ie(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,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),sg)}}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Fn(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Dn,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Fn(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Dn,r,i)}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Fn(this,e,i);return}let n={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Qe.extensionName]||(n.compress=!1),this._sender.send(e||Dn,n,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING)return ie(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(N,"CONNECTING",{enumerable:!0,value:Re.indexOf("CONNECTING")});Object.defineProperty(N.prototype,"CONNECTING",{enumerable:!0,value:Re.indexOf("CONNECTING")});Object.defineProperty(N,"OPEN",{enumerable:!0,value:Re.indexOf("OPEN")});Object.defineProperty(N.prototype,"OPEN",{enumerable:!0,value:Re.indexOf("OPEN")});Object.defineProperty(N,"CLOSING",{enumerable:!0,value:Re.indexOf("CLOSING")});Object.defineProperty(N.prototype,"CLOSING",{enumerable:!0,value:Re.indexOf("CLOSING")});Object.defineProperty(N,"CLOSED",{enumerable:!0,value:Re.indexOf("CLOSED")});Object.defineProperty(N.prototype,"CLOSED",{enumerable:!0,value:Re.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(t=>{Object.defineProperty(N.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(N.prototype,`on${t}`,{enumerable:!0,get(){let e=this.listeners(t);for(let r=0;r<e.length;r++)if(e[r]._listener)return e[r]._listener},set(e){let r=this.listeners(t);for(let i=0;i<r.length;i++)r[i]._listener&&this.removeListener(t,r[i]);this.addEventListener(t,e)}})});N.prototype.addEventListener=eg;N.prototype.removeEventListener=tg;Hl.exports=N;function Ul(t,e,r,i){let n={protocolVersion:Un[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(!Un.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Un.join(", ")})`);let s;e instanceof Nn?(s=e,t._url=e.href):(s=new Nn(e),t._url=e);let o=s.protocol==="ws+unix:";if(!s.host&&(!o||!s.pathname)){let d=new Error(`Invalid URL: ${t.url}`);if(t._redirects===0)throw d;jn(t,d);return}let a=s.protocol==="wss:"||s.protocol==="https:",u=a?443:80,l=Gp(16).toString("base64"),f=a?Kp.get:zp.get,h;if(n.createConnection=a?ag:og,n.defaultPort=n.defaultPort||u,n.port=s.port||u,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 Qe(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=rg({[Qe.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(t._redirects===0){t._originalUnixSocket=o,t._originalSecure=a,t._originalHostOrSocketPath=o?n.socketPath:s.host;let d=i&&i.headers;if(i={...i,headers:{}},d)for(let[m,y]of Object.entries(d))i.headers[m.toLowerCase()]=y}else{let d=o?t._originalUnixSocket?n.socketPath===t._originalHostOrSocketPath:!1:t._originalUnixSocket?!1:s.host===t._originalHostOrSocketPath;(!d||t._originalSecure&&!a)&&(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=t._req=f(n);n.timeout&&c.on("timeout",()=>{ie(t,c,"Opening handshake has timed out")}),c.on("error",d=>{c===null||c.aborted||(c=t._req=null,jn(t,d))}),c.on("response",d=>{let m=d.headers.location,y=d.statusCode;if(m&&n.followRedirects&&y>=300&&y<400){if(++t._redirects>n.maxRedirects){ie(t,c,"Maximum redirects exceeded");return}c.abort();let v;try{v=new Nn(m,e)}catch(b){jn(t,b);return}Ul(t,v,r,i)}else t.emit("unexpected-response",c,d)||ie(t,c,`Unexpected server response: ${d.statusCode}`)}),c.on("upgrade",(d,m,y)=>{if(t.emit("upgrade",d),t.readyState!==N.CONNECTING)return;if(c=t._req=null,d.headers.upgrade.toLowerCase()!=="websocket"){ie(t,m,"Invalid Upgrade header");return}let v=Qp("sha1").update(l+Jp).digest("base64");if(d.headers["sec-websocket-accept"]!==v){ie(t,m,"Invalid Sec-WebSocket-Accept header");return}let b=d.headers["sec-websocket-protocol"],C=(r||"").split(/, */),D;if(!r&&b?D="Server sent a subprotocol but none was requested":r&&!b?D="Server sent no subprotocol":b&&!C.includes(b)&&(D="Server sent an invalid subprotocol"),D){ie(t,m,D);return}b&&(t._protocol=b);let K=d.headers["sec-websocket-extensions"];if(K!==void 0){if(!h){ie(t,m,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let F;try{F=ig(K)}catch{ie(t,m,"Invalid Sec-WebSocket-Extensions header");return}let Xe=Object.keys(F);if(Xe.length){if(Xe.length!==1||Xe[0]!==Qe.extensionName){ie(t,m,"Server indicated an extension that was not requested");return}try{h.accept(F[Qe.extensionName])}catch{ie(t,m,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Qe.extensionName]=h}}t.setSocket(m,y,n.maxPayload)})}function jn(t,e){t._readyState=N.CLOSING,t.emit("error",e),t.emitClose()}function og(t){return t.path=t.socketPath,Nl.connect(t)}function ag(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Nl.isIP(t.host)?"":t.host),$p.connect(t)}function ie(t,e,r){t._readyState=N.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ie),e.setHeader?(e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),e.once("abort",t.emitClose.bind(t)),t.emit("error",i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Fn(t,e,r){if(e){let i=ng(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Re[t.readyState]})`);r(i)}}function lg(t,e){let r=this[Q];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Q]!==void 0&&(r._socket.removeListener("data",oi),process.nextTick(jl,r._socket),t===1005?r.close():r.close(t,e))}function ug(){this[Q]._socket.resume()}function fg(t){let e=this[Q];e._socket[Q]!==void 0&&(e._socket.removeListener("data",oi),process.nextTick(jl,e._socket),e.close(t[Zp])),e.emit("error",t)}function ql(){this[Q].emitClose()}function cg(t){this[Q].emit("message",t)}function hg(t){let e=this[Q];e.pong(t,!e._isServer,Dl),e.emit("ping",t)}function dg(t){this[Q].emit("pong",t)}function jl(t){t.resume()}function Fl(){let t=this[Q];this.removeListener("close",Fl),this.removeListener("data",oi),this.removeListener("end",Wl),t._readyState=N.CLOSING;let e;!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&(e=t._socket.read())!==null&&t._receiver.write(e),t._receiver.end(),this[Q]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",ql),t._receiver.on("finish",ql))}function oi(t){this[Q]._receiver.write(t)||this.pause()}function Wl(){let t=this[Q];t._readyState=N.CLOSING,t._receiver.end(),this.end()}function Vl(){let t=this[Q];this.removeListener("error",Vl),this.on("error",Dl),t&&(t._readyState=N.CLOSING,this.destroy())}});var Gl=g((Om,$l)=>{"use strict";var{Duplex:pg}=require("stream");function Kl(t){t.emit("close")}function gg(){!this.destroyed&&this._writableState.finished&&this.destroy()}function zl(t){this.removeListener("error",zl),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function yg(t,e){let r=!0,i=!0;function n(){r&&t._socket.resume()}t.readyState===t.CONNECTING?t.once("open",function(){t._receiver.removeAllListeners("drain"),t._receiver.on("drain",n)}):(t._receiver.removeAllListeners("drain"),t._receiver.on("drain",n));let s=new pg({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(a){s.push(a)||(r=!1,t._socket.pause())}),t.once("error",function(a){s.destroyed||(i=!1,s.destroy(a))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(o,a){if(t.readyState===t.CLOSED){a(o),process.nextTick(Kl,s);return}let u=!1;t.once("error",function(f){u=!0,a(f)}),t.once("close",function(){u||a(o),process.nextTick(Kl,s)}),i&&t.terminate()},s._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},s._read=function(){(t.readyState===t.OPEN||t.readyState===t.CLOSING)&&!r&&(r=!0,t._receiver._writableState.needDrain||t._socket.resume())},s._write=function(o,a,u){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(o,a,u)});return}t.send(o,u)},s.on("end",gg),s.on("error",zl),s}$l.exports=yg});var Zl=g((Bm,Jl)=>{"use strict";var _g=require("events"),ai=require("http"),Im=require("https"),Rm=require("net"),Am=require("tls"),{createHash:mg}=require("crypto"),dt=er(),vg=Wn(),{format:bg,parse:wg}=qn(),{GUID:Sg,kWebSocket:Eg}=ct(),xg=/^[+/0-9A-Za-z]{22}==$/,Ql=0,Yl=1,Xl=2,Hn=class extends _g{constructor(e,r){if(super(),e={maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=ai.createServer((i,n)=>{let s=ai.STATUS_CODES[426];n.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),n.end(s)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=Tg(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,s,o)=>{this.handleUpgrade(n,s,o,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set),this.options=e,this._state=Ql}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(e&&this.once("close",e),this._state===Xl){process.nextTick(Vn,this);return}if(this._state===Yl)return;if(this._state=Yl,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(Vn.bind(void 0,this));return}process.nextTick(Vn,this)}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,n){r.on("error",Kn);let s=e.headers["sec-websocket-key"]!==void 0?e.headers["sec-websocket-key"].trim():!1,o=+e.headers["sec-websocket-version"],a={};if(e.method!=="GET"||e.headers.upgrade.toLowerCase()!=="websocket"||!s||!xg.test(s)||o!==8&&o!==13||!this.shouldHandle(e))return ir(r,400);if(this.options.perMessageDeflate){let u=new dt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let l=wg(e.headers["sec-websocket-extensions"]);l[dt.extensionName]&&(u.accept(l[dt.extensionName]),a[dt.extensionName]=u)}catch{return ir(r,400)}}if(this.options.verifyClient){let u={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(u,(l,f,h,c)=>{if(!l)return ir(r,f||401,h,c);this.completeUpgrade(s,a,e,r,i,n)});return}if(!this.options.verifyClient(u))return ir(r,401)}this.completeUpgrade(s,a,e,r,i,n)}completeUpgrade(e,r,i,n,s,o){if(!n.readable||!n.writable)return n.destroy();if(n[Eg])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ql)return ir(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mg("sha1").update(e+Sg).digest("base64")}`],l=new vg(null),f=i.headers["sec-websocket-protocol"];if(f&&(f=f.split(",").map(Cg),this.options.handleProtocols?f=this.options.handleProtocols(f,i):f=f[0],f&&(u.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)),r[dt.extensionName]){let h=r[dt.extensionName].params,c=bg({[dt.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${c}`),l._extensions=r}this.emit("headers",u,i),n.write(u.concat(`\r
6
- `).join(`\r
7
- `)),n.removeListener("error",Kn),l.setSocket(n,s,this.options.maxPayload),this.clients&&(this.clients.add(l),l.on("close",()=>this.clients.delete(l))),o(l,i)}};Jl.exports=Hn;function Tg(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function Vn(t){t._state=Xl,t.emit("close")}function Kn(){this.destroy()}function ir(t,e,r,i){t.writable&&(r=r||ai.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},t.write(`HTTP/1.1 ${e} ${ai.STATUS_CODES[e]}\r
8
- `+Object.keys(i).map(n=>`${n}: ${i[n]}`).join(`\r
9
- `)+`\r
10
- \r
11
- `+r)),t.removeListener("error",Kn),t.destroy()}function Cg(t){return t.trim()}});var tu=g((km,eu)=>{"use strict";var nr=Wn();nr.createWebSocketStream=Gl();nr.Server=Zl();nr.Receiver=In();nr.Sender=An();eu.exports=nr});var $n=g((Lm,zn)=>{"use strict";var{Buffer:sr}=require("buffer"),ru=tu(),or=_e()("mqttjs:ws"),Pg=ei(),Og=Ne().Transform,Ig=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],iu=typeof process<"u"&&process.title==="browser"||typeof __webpack_require__=="function";function nu(t,e){let r=t.protocol+"://"+t.hostname+":"+t.port+t.path;return typeof t.transformWsUrl=="function"&&(r=t.transformWsUrl(r,t,e)),r}function su(t){let e=t;return t.hostname||(e.hostname="localhost"),t.port||(t.protocol==="wss"?e.port=443:e.port=80),t.path||(e.path="/"),t.wsOptions||(e.wsOptions={}),!iu&&t.protocol==="wss"&&Ig.forEach(function(r){Object.prototype.hasOwnProperty.call(t,r)&&!Object.prototype.hasOwnProperty.call(t.wsOptions,r)&&(e.wsOptions[r]=t[r])}),e}function Rg(t){let e=su(t);if(e.hostname||(e.hostname=e.host),!e.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");let r=new URL(document.URL);e.hostname=r.hostname,e.port||(e.port=r.port)}return e.objectMode===void 0&&(e.objectMode=!(e.binary===!0||e.binary===void 0)),e}function Ag(t,e,r){or("createWebSocket"),or("protocol: "+r.protocolId+" "+r.protocolVersion);let i=r.protocolId==="MQIsdp"&&r.protocolVersion===3?"mqttv3.1":"mqtt";return or("creating new Websocket for url: "+e+" and protocol: "+i),new ru(e,[i],r.wsOptions)}function Bg(t,e){let r=e.protocolId==="MQIsdp"&&e.protocolVersion===3?"mqttv3.1":"mqtt",i=nu(e,t),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}function kg(t,e){or("streamBuilder");let r=su(e),i=nu(r,t),n=Ag(t,i,r),s=ru.createWebSocketStream(n,r.wsOptions);return s.url=i,n.on("close",()=>{s.destroy()}),s}function Lg(t,e){or("browserStreamBuilder");let r,n=Rg(e).browserBufferSize||1024*512,s=e.browserBufferTimeout||1e3,o=!e.objectMode,a=Bg(t,e),u=f(e,v,b);e.objectMode||(u._writev=y),u.on("close",()=>{a.close()});let l=typeof a.addEventListener<"u";a.readyState===a.OPEN?r=u:(r=r=Pg(void 0,void 0,e),e.objectMode||(r._writev=y),l?a.addEventListener("open",h):a.onopen=h),r.socket=a,l?(a.addEventListener("close",c),a.addEventListener("error",d),a.addEventListener("message",m)):(a.onclose=c,a.onerror=d,a.onmessage=m);function f(C,D,K){let F=new Og({objectModeMode:C.objectMode});return F._write=D,F._flush=K,F}function h(){r.setReadable(u),r.setWritable(u),r.emit("connect")}function c(){r.end(),r.destroy()}function d(C){r.destroy(C)}function m(C){let D=C.data;D instanceof ArrayBuffer?D=sr.from(D):D=sr.from(D,"utf8"),u.push(D)}function y(C,D){let K=new Array(C.length);for(let F=0;F<C.length;F++)typeof C[F].chunk=="string"?K[F]=sr.from(C[F],"utf8"):K[F]=C[F].chunk;this._write(sr.concat(K),"binary",D)}function v(C,D,K){a.bufferedAmount>n&&setTimeout(v,s,C,D,K),o&&typeof C=="string"&&(C=sr.from(C,"utf8"));try{a.send(C)}catch(F){return K(F)}K()}function b(C){a.close(),C()}return r}iu?zn.exports=Lg:zn.exports=kg});var uu=g((Mm,ar)=>{"use strict";var au=dn(),Mg=Ir(),qg=require("url"),Ng=dr(),ou=_e()("mqttjs"),ee={};typeof process<"u"&&process.title!=="browser"||typeof __webpack_require__!="function"?(ee.mqtt=pn(),ee.tcp=pn(),ee.ssl=Xr(),ee.tls=Xr(),ee.mqtts=Xr()):(ee.wx=_n(),ee.wxs=_n(),ee.ali=vn(),ee.alis=vn());ee.ws=$n();ee.wss=$n();function Dg(t){let e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function lu(t,e){if(ou("connecting to an MQTT broker..."),typeof t=="object"&&!e&&(e=t,t=null),e=e||{},t){let n=qg.parse(t,!0);if(n.port!=null&&(n.port=Number(n.port)),e=Ng(n,e),e.protocol===null)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(Dg(e),e.query&&typeof e.query.clientId=="string"&&(e.clientId=e.query.clientId),e.cert&&e.key)if(e.protocol){if(["mqtts","wss","wxs","alis"].indexOf(e.protocol)===-1)switch(e.protocol){case"mqtt":e.protocol="mqtts";break;case"ws":e.protocol="wss";break;case"wx":e.protocol="wxs";break;case"ali":e.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+e.protocol+'"!')}}else throw new Error("Missing secure protocol key");if(!ee[e.protocol]){let n=["mqtts","wss"].indexOf(e.protocol)!==-1;e.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(s,o){return n&&o%2===0?!1:typeof ee[s]=="function"})[0]}if(e.clean===!1&&!e.clientId)throw new Error("Missing clientId for unclean clients");e.protocol&&(e.defaultProtocol=e.protocol);function r(n){return e.servers&&((!n._reconnectCount||n._reconnectCount===e.servers.length)&&(n._reconnectCount=0),e.host=e.servers[n._reconnectCount].host,e.port=e.servers[n._reconnectCount].port,e.protocol=e.servers[n._reconnectCount].protocol?e.servers[n._reconnectCount].protocol:e.defaultProtocol,e.hostname=e.host,n._reconnectCount++),ou("calling streambuilder for",e.protocol),ee[e.protocol](n,e)}let i=new au(r,e);return i.on("error",function(){}),i}ar.exports=lu;ar.exports.connect=lu;ar.exports.MqttClient=au;ar.exports.Store=Mg});var cu=g((qm,fu)=>{"use strict";var Ug=Zi().NumberAllocator;function Ye(){if(!(this instanceof Ye))return new Ye;this.numberAllocator=new Ug(1,65535)}Ye.prototype.allocate=function(){return this.lastId=this.numberAllocator.alloc(),this.lastId};Ye.prototype.getLastAllocated=function(){return this.lastId};Ye.prototype.register=function(t){return this.numberAllocator.use(t)};Ye.prototype.deallocate=function(t){this.numberAllocator.free(t)};Ye.prototype.clear=function(){this.numberAllocator.clear()};fu.exports=Ye});var du=g((Nm,pt)=>{"use strict";var hu=dn(),jg=uu(),Fg=Ir(),Wg=fn(),Vg=cu();pt.exports.connect=jg;pt.exports.MqttClient=hu;pt.exports.Client=hu;pt.exports.Store=Fg;pt.exports.DefaultMessageIdProvider=Wg;pt.exports.UniqueMessageIdProvider=Vg});var Gg={};Gn(Gg,{default:()=>li});module.exports=Yn(Gg);var vu=ui(require("async-mqtt"),1),pv=ui(du(),1),bu=require("vestaboard-api");var pu=require("fs"),gu=require("fs"),yu=require("path"),{readFile:Hg,writeFile:Kg}=gu.promises,te=class t{static currentData={};static currentFetch;static file=(0,yu.join)(process.env.HOME||"~",".vestaboard2mqtt");namespace;constructor(e){this.namespace=e}static async fetch(){if(this.currentFetch)return this.currentFetch;let e=this.fetchFromFile();return this.currentFetch=e,e}static async fetchFromFile(){if((0,pu.existsSync)(this.file))try{let e=await Hg(this.file,{encoding:"utf8"});this.currentData=JSON.parse(e)}catch(e){console.warn(`Unable to parse cache file: ${e}`)}}static isCacheItemObject(e){return e!==null&&typeof e=="object"&&"updated"in e&&typeof e.updated=="number"&&"value"in e&&typeof e.value<"u"}static async save(){await Kg(this.file,JSON.stringify(this.currentData,null," "))}async delete(e){!t.currentData||!t.currentData[this.namespace]||(delete t.currentData[this.namespace][e],Object.keys(t.currentData[this.namespace]).length===0&&delete t.currentData[this.namespace],await t.save().catch(r=>{console.warn(`Unable to update cache: ${r}`)}))}async get(e,r=0){if(await t.fetch(),!t.currentData||!t.currentData[this.namespace]||!t.currentData[this.namespace][e])return null;let i=t.currentData[this.namespace][e];return!t.isCacheItemObject(i)&&r>0?null:t.isCacheItemObject(i)?r>0&&new Date().getTime()-i.updated>r?null:i.value:i}async set(e,r){if(await t.fetch(),!t.currentData)throw new Error("Unable to set value: currentData is empty!");t.currentData[this.namespace]=t.currentData[this.namespace]||{},t.currentData[this.namespace][e]={updated:new Date().getTime(),value:r},await t.save().catch(i=>{console.warn(`Unable to update cache: ${i}`)})}};var k=class{static get board(){if(this.loaded&&this.data?.board)return this.data.board;throw new Error("Unable to access board config, is config loaded?")}static get calendar(){if(this.loaded&&this.data?.calendar)return this.data.calendar;throw new Error("Unable to access calendar config, is config loaded?")}static get loaded(){return!!this.data&&!!this.cache}static get mqtt(){if(this.loaded&&this.data?.mqtt)return this.data.mqtt;throw new Error("Unable to access mqtt config, is config loaded?")}static cache=new te("config");static data;static async load(){let e=await this.cache.get("default");if(!e)throw new Error("Unable to load configuration, try to run the setup script\u2026");this.data=e}static async save(e){this.data=e,await this.cache.set("default",e)}static async updateDisabled(e){e===this.data?.board.disabled||!this.loaded||!this.data?.mqtt||(this.data.board.disabled=e,await this.save(this.data))}};var Ae=require("vestaboard-api/lib/cjs/values.js");var zg=[["\xE4",[1,5]],["\xC4",[1,5]],["\xF6",[15,5]],["\xD6",[15,5]],["\xFC",[21,5]],["\xDC",[21,5]],["\xDF",[19,19]],["\u{1F7E5}",[63]],["\u{1F7E7}",[64]],["\u{1F7E8}",[65]],["\u{1F7E9}",[66]],["\u{1F7E6}",[67]],["\u{1F7EA}",[68]],["\u2B1C\uFE0F",[69]],["\u2B1C",[69]],["\u2B1B\uFE0F",[0]],["\u2B1B",[0]],["\uFE6B",[38]],["\uFF20",[38]],["0\uFE0F\u20E3",[36]],["1\uFE0F\u20E3",[27]],["2\uFE0F\u20E3",[28]],["3\uFE0F\u20E3",[29]],["4\uFE0F\u20E3",[30]],["5\uFE0F\u20E3",[31]],["6\uFE0F\u20E3",[32]],["7\uFE0F\u20E3",[33]],["8\uFE0F\u20E3",[34]],["9\uFE0F\u20E3",[35]],["\u2755",[37]],["\u203C\uFE0F",[37,37]],["\u2757\uFE0F",[37]],["\u2049\uFE0F",[37,60]],["\u26A0\uFE0F",[65]],["#\uFE0F\u20E3",[39]],["\u{1F4B8}",[40]],["\u{1F4B2}",[40]],["\u{1F4B5}",[40]],["\u{1F4B0}",[40]],["$",[40]],["\uFE69",[40]],["\uFF04",[40]],["\u2190",[44]],["\u2192",[44]],["\u27A1",[44]],["\u2B05",[44]],["\u2794",[44]],["\u2194",[44]],["\u2013",[44]],["\u2795",[46]],["+",[46]],["\uFE6A",[54]],["\uFF05",[54]],["\u2753",[60]],["\u2754",[60]],["\u2103",[62,3]],["\u2109",[62,6]]],pe=class t{board;currentLine=null;isFilled=!1;constructor(e=t.newBoardCharArray()){this.board=e}static char2char(e){let r=Object.entries(Ae.characterCode).find(([n])=>e===n);if(r)return[r[1]];let i=zg.find(([n])=>e===n);return i&&Array.isArray(i[1])?i[1]:[60]}static charToString(e){let r=Object.entries(Ae.characterCode).filter(([i])=>i.length<=2).find(([,i])=>i===e);if(r)return r[0].toUpperCase()+" ";switch(e){case 63:return"\u{1F7E5}";case 64:return"\u{1F7E7}";case 65:return"\u{1F7E8}";case 66:return"\u{1F7E9}";case 67:return"\u{1F7E6}";case 68:return"\u{1F7EA}";case 69:return"\u2B1C\uFE0F";default:return" "}}static newBoardCharArray(){return JSON.parse(JSON.stringify(Ae.emptyBoard))}static word2chars(e){let r=[];for(let i of e)r.push(...this.char2char(i));return r}center(){let e=[this.board.findIndex(i=>i.find(n=>n!==0)),Math.min(...this.board.map(i=>i.find(n=>n!==0)?i.slice().reverse().findIndex(n=>n!==0):i.length)),this.board.slice().reverse().findIndex(i=>i.find(n=>n!==0)),Math.min(...this.board.map(i=>i.find(n=>n!==0)?i.findIndex(n=>n!==0):i.length))],r=[Math.floor((e[0]+e[2])/2),Math.floor((e[1]+e[3])/2)];if(e[0]!==r[0]){let i=r[0]-e[0];this.board.splice(e[0]<r[0]?0:this.board.length-i,0,...this.board.splice(this.board.length-i,i))}if(e[3]!==r[1]){let i=r[1]-e[3];this.board.forEach(n=>{n.splice(e[3]<r[1]?0:n.length-i,0,...n.splice(n.length-i,i))})}}centerLines(){this.board.forEach(e=>{let r=[e.findIndex(s=>s!==0),e.slice().reverse().findIndex(s=>s!==0)];if(r[0]===-1||r[1]===-1)return;let i=e.slice(r[0],e.length-r[1]),n=Math.floor((r[0]+r[1])/2);e.fill(0,0,n),e.splice(n,i.length,...i),e.fill(0,n+i.length)})}export(){return this.board}isEmpty(){return!this.board.find(e=>e.find(r=>r!==0))}repeat(e,r={}){this.board[r.line||0].fill(t.char2char(e)[0])}toString(){return"#="+"=".repeat(Ae.LINE_LENGTH*2)+`=#
12
- `+this.board.map(e=>"# "+e.map(r=>t.charToString(r)).join("")+` #
13
- `).join("")+"#="+"=".repeat(Ae.LINE_LENGTH*2)+`=#
14
- `}write(e,r={}){let i=0;if(this.isFilled)return;if(r.line==="CURRENT")i=this.currentLine||0;else if(r.line==="NEXT"&&this.currentLine===null)this.currentLine=0,i=this.currentLine;else if(r.line==="NEXT"&&typeof this.currentLine=="number"&&this.currentLine<this.board.length-1)this.currentLine++,i=this.currentLine;else if(r.line==="NEXT"){this.isFilled=!0;return}else r.line!==void 0&&(i=r.line);let n={firstLine:i,firstRow:r.row||0,lastLine:this.board.length-1,lastRow:Ae.LINE_LENGTH-1},s=[n.firstRow,n.firstLine];e.split(/\s+/).forEach((a,u)=>{u!==0&&s[0]!==n.firstRow&&(this.board[s[1]][s[0]]=0,s[0]++);let l=n.lastRow-s[0]+1,f=t.word2chars(a);f.filter(h=>h===60).length===f.length&&f.length>0||(f.length>l&&f.length<=n.lastRow-n.firstRow+1&&s[1]<n.lastLine&&(s[0]=n.firstRow,s[1]++,l=n.lastRow-s[0]),f.length<=l?(this.board[s[1]].splice(s[0],f.length,...f),s[0]+=f.length):f.length>l&&l>5&&(this.board[s[1]].splice(s[0],l,...f.slice(0,l)),s[0]+=l))}),this.currentLine=s[1]}};var mu=ui(require("node-ical"),1);var gt=class{static cache=new te("calendar");parseConfig(e,r,i){let n={};return console.log("parseConfig",i),e==="min-temp"&&Array.isArray(i.temp)?n.temp=[parseInt(r||""),Math.max(...i.temp)]:e==="min-temp"?n.temp=[parseInt(r||""),parseInt(r||"")]:e==="max-temp"&&Array.isArray(i.temp)?n.temp=[Math.min(...i.temp),parseInt(r||"")]:e==="max-temp"?n.temp=[parseInt(r||""),parseInt(r||"")]:e==="precip"?n.precip=parseInt(r||"",10):e==="locale"&&(n.locale=String(r)),n}parsePayload(e){try{return JSON.parse(e||"")}catch{return{}}}async render(e,r){let i=new pe,n=new Date,s=Object.assign({locale:"en",precip:void 0,temp:void 0},r,e);i.write(n.toLocaleString(s.locale,{weekday:"long"})),i.write(n.toLocaleString(s.locale,{day:"numeric",month:"long"}),{line:"NEXT"}),i.write("",{line:"NEXT"});let o=[];Array.isArray(s.temp)&&o.push(`${Math.min(...s.temp)}-${Math.max(...s.temp)}\xB0C`),typeof s.precip=="number"&&s.precip>0&&o.push(`${s.precip}%`),o.length&&i.write(o.join(", "),{line:"NEXT"}),i.center();let a=new Date;return a.setHours(24,0,0,0),{message:i,validTill:a}}};var lr=class t{static cache=new te("calendar");static getTimeStr(e,r=!1){return this.isMidnight(e.start)&&this.isMidnight(e.end)&&this.isSameDay(new Date,e.start)?"Heute":this.isMidnight(e.start)&&this.isMidnight(e.end)&&this.isSameDay(new Date(new Date().getTime()+1e3*60*60*24),e.start)?r?"Morgen":"Morgn":e.start.getHours().toString().padStart(2,"\u2B1B\uFE0F")+":"+e.start.getMinutes().toString().padStart(2,"0")}static isMidnight(e){return!e.getHours()&&!e.getMinutes()&&!e.getSeconds()&&!e.getMilliseconds()}static isSameDay(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}async fetchURL(e){let r=await t.cache.get(e,6e5);if(!r){let i=await mu.default.async.fromURL(e);r=Object.values(i).filter(s=>s&&s.type==="VEVENT"&&s.start&&s.end&&s.summary).map(s=>({end:new Date(String(s.end)),start:new Date(String(s.start)),summary:String(s.summary).trim()})).filter(s=>s.end>new Date).sort((s,o)=>s.end.getTime()-o.end.getTime()).slice(0,6),await t.cache.set(e,r)}return r.map(i=>({end:new Date(String(i.end)),start:new Date(String(i.start)),summary:String(i.summary)})).filter(i=>i.end>new Date)}async fetchURLs(e){let r=await Promise.all(e.map(i=>this.fetchURL(i)));return[].concat(...r).filter(i=>i.end>new Date).sort((i,n)=>i.end.getTime()-n.end.getTime())}parseConfig(){return{}}parsePayload(e){return{calendars:(e||"").split(",")}}async render(e){let r=new pe,i=e.calendars.map(o=>k.calendar.urls[o]).filter(Boolean),n=await this.fetchURLs(i).then(o=>o.filter(a=>t.isMidnight(a.start)&&t.isMidnight(a.end)?t.isSameDay(new Date,a.start)||new Date().getHours()>=20&&t.isSameDay(new Date(new Date().getTime()+1e3*60*60*24),a.start):a.start<new Date(new Date().getTime()+1e3*60*60*12)));if(!n.length){let o=new gt,u=await new te("page-config").get("today");return o.render({},u||{})}let s=new Date(new Date().getTime()+1e3*60*10);return n.forEach(o=>{r.write(t.getTimeStr(o,n.length===1),{line:"NEXT"}),r.write(o.summary,{line:"CURRENT",row:6}),r.write("",{line:"NEXT"}),o.end<s&&(s=o.end)}),r.center(),{message:r,validTill:s}}};var ur=class{static cache=new te("calendar");parseConfig(){return{}}parsePayload(e){return e||""}async render(e){let r=new pe;return e.split(`
15
- `).forEach(i=>{r.write(i,{line:"NEXT"})}),r.centerLines(),r.center(),{message:r}}};var $g={calendar:new lr,message:new ur,today:new gt},fr=$g;var li=class t{board;currentMessage;currentTimer;mqtt;pageConfig=new te("page-config");subscriptionIds;constructor(){this.board=new bu.Vesta({apiKey:k.board.key,apiSecret:k.board.secret}),this.mqtt=vu.default.connect(k.mqtt.url,{will:{payload:"offline",qos:0,retain:!0,topic:k.mqtt.prefix+"/status"}}),this.mqtt.on("connect",()=>{this.mqtt.publish(k.mqtt.prefix+"/status","online",{retain:!0}),this.setupBrokerSubscriptions().catch(e=>{console.error(new Error(`Unable to setup mqtt subscriptions: ${e.stack}`)),process.exit(1)})}),this.mqtt.on("message",(e,r)=>{this.handleMessage(e,r.toString()).catch(i=>{this.debug(`Unable to handle message: ${i.stack}`)})})}static async run(){return await k.load(),new t}debug(e){let r=String(e);this.mqtt.publish(k.mqtt.prefix+"/debug",r),console.log(r)}async handleMessage(e,r){if(![k.mqtt.prefix+"/debug",k.mqtt.prefix+"/status"].includes(e))if(e===k.mqtt.prefix+"/disabled"){let i=["1","true","TRUE"].includes(r);await k.updateDisabled(i),i||(this.debug("Board not disabled anymore, update with latest message"),await this.updateCurrentMessage())}else if(Object.keys(fr).map(i=>k.mqtt.prefix+"/"+i).includes(e)){let i=fr[e.substr(k.mqtt.prefix.length+1)];await this.renderMessage(i,r)}else{let i=Object.entries(fr).find(([u])=>e.startsWith(k.mqtt.prefix+"/"+u+"/"));if(!i){this.debug(`Unknown topic ${e}, I'm sorry`);return}let n=e.substr((k.mqtt.prefix+"/"+i[0]+"/").length),s=await this.pageConfig.get(i[0]),o=i[1].parseConfig(n,r,s||{}),a=Object.assign(s||{},o);await this.pageConfig.set(i[0],a),await this.updateCurrentMessage(),this.debug(`Update config for page module ${i[0]}: ${JSON.stringify(a,null," ")}`)}}async renderMessage(e,r){this.currentMessage={page:e,payload:r};let i=Object.entries(fr).find(([,a])=>a===e);if(k.board.disabled||!i)return;let n=await e.parsePayload(r),s=await this.pageConfig.get(i[0]),o=await e.render(n,s||{});o.message&&await this.sendMessage(o.message),this.currentTimer&&(clearTimeout(this.currentTimer),delete this.currentTimer),o.validTill&&(this.debug(`Set timer for ${o.validTill.toString()} to update message`),this.currentTimer=setTimeout(()=>{this.debug("Here I am again, updating the message now\u2026"),this.renderMessage(e,r).catch(a=>{this.debug(`Unable to update page: ${a}`)})},o.validTill.getTime()-new Date().getTime()))}async sendMessage(e=new pe){let r=e.export();if(!this.subscriptionIds){let i=await this.board.getSubscriptions();this.subscriptionIds=i.map(n=>n._id)}this.debug(`Sending Message:
16
-
17
- `+e.toString()),await Promise.all(this.subscriptionIds.map(i=>this.board.postMessage(i,r)))}async setupBrokerSubscriptions(){if(!this.mqtt)throw new Error("Unable to setup subscriptions: client not set.");await this.mqtt.subscribe(k.mqtt.prefix+"/#")}async updateCurrentMessage(){this.currentMessage&&await this.renderMessage(this.currentMessage.page,this.currentMessage.payload)}};
18
- /*! Bundled license information:
19
-
20
- safe-buffer/index.js:
21
- (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
22
- */
23
- //# sourceMappingURL=index.cjs.map
1
+ const e=require(`../lib-CVoPRS8D.cjs`);module.exports=e.t;