@sebbo2002/vestaboard2mqtt 5.0.2-develop.11 → 5.0.2-develop.13
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.
- package/README.md +1 -4
- package/dist/bin/start.cjs +9 -9
- package/dist/bin/start.cjs.map +1 -1
- package/dist/bin/start.js +1 -1
- package/dist/bin/start.js.map +1 -1
- package/dist/{chunk-B7GBNBHM.js → chunk-JCVHJVDZ.js} +10 -10
- package/dist/{chunk-B7GBNBHM.js.map → chunk-JCVHJVDZ.js.map} +1 -1
- package/dist/lib/index.cjs +9 -9
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +6 -6
- package/dist/lib/index.d.ts +6 -6
- package/dist/lib/index.js +1 -1
- package/package.json +76 -72
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var gu=Object.create;var hr=Object.defineProperty;var yu=Object.getOwnPropertyDescriptor;var _u=Object.getOwnPropertyNames;var mu=Object.getPrototypeOf,vu=Object.prototype.hasOwnProperty;var b=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(t&&(e=t(t=0)),e);var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bu=(t,e)=>{for(var r in e)hr(t,r,{get:e[r],enumerable:!0})},Gn=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _u(e))!vu.call(t,n)&&n!==r&&hr(t,n,{get:()=>e[n],enumerable:!(i=yu(e,n))||i.enumerable});return t};var wu=(t,e,r)=>(r=t!=null?gu(mu(t)):{},Gn(e||!t||!t.__esModule?hr(r,"default",{value:t,enumerable:!0}):r,t)),Su=t=>Gn(hr({},"__esModule",{value:!0}),t);var dr=g((ny,Qn)=>{"use strict";Qn.exports=Iu;var Ou=Object.prototype.hasOwnProperty;function Iu(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var i in r)Ou.call(r,i)&&(t[i]=r[i])}return t}});var li=g((sy,Yn)=>{"use strict";Yn.exports=b("stream")});var es=g((oy,Zn)=>{"use strict";function Xn(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 Ru(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xn(Object(r),!0).forEach(function(i){Au(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xn(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function Au(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Bu(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Jn(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 ku(t,e,r){return e&&Jn(t.prototype,e),r&&Jn(t,r),t}var Lu=b("buffer"),pr=Lu.Buffer,Mu=b("util"),ui=Mu.inspect,qu=ui&&ui.custom||"inspect";function Nu(t,e,r){pr.prototype.copy.call(t,e,r)}Zn.exports=function(){function t(){Bu(this,t),this.head=null,this.tail=null,this.length=0}return ku(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;)Nu(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:qu,value:function(r,i){return ui(this,Ru({},i,{depth:0,customInspect:!1}))}}]),t}()});var ci=g((ay,rs)=>{"use strict";function Du(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(fi,this,t)):process.nextTick(fi,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(ts,r,s)):process.nextTick(ts,r,s):e?(process.nextTick(gr,r),e(s)):process.nextTick(gr,r)}),this)}function ts(t,e){fi(t,e),gr(t)}function gr(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function Uu(){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 fi(t,e){t.emit("error",e)}function ju(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}rs.exports={destroy:Du,undestroy:Uu,errorOrDestroy:ju}});var Be=g((ly,ss)=>{"use strict";var ns={};function se(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,ns[t]=n}function is(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 Fu(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function Wu(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function Vu(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}se("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);se("ERR_INVALID_ARG_TYPE",function(t,e,r){let i;typeof e=="string"&&Fu(e,"not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be";let n;if(Wu(t," argument"))n=`The ${t} ${i} ${is(e,"type")}`;else{let s=Vu(t,".")?"property":"argument";n=`The "${t}" ${s} ${i} ${is(e,"type")}`}return n+=`. Received type ${typeof r}`,n},TypeError);se("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");se("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});se("ERR_STREAM_PREMATURE_CLOSE","Premature close");se("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});se("ERR_MULTIPLE_CALLBACK","Callback called multiple times");se("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");se("ERR_STREAM_WRITE_AFTER_END","write after end");se("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);se("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);se("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ss.exports.codes=ns});var hi=g((uy,os)=>{"use strict";var Hu=Be().codes.ERR_INVALID_OPT_VALUE;function Ku(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function zu(t,e,r,i){var n=Ku(e,i,r);if(n!=null){if(!(isFinite(n)&&Math.floor(n)===n)||n<0){var s=i?r:"highWaterMark";throw new Hu(s,n)}return Math.floor(n)}return t.objectMode?16:16*1024}os.exports={getHighWaterMark:zu}});var as=g((fy,di)=>{"use strict";typeof Object.create=="function"?di.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:di.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 Se=g((cy,gi)=>{"use strict";try{if(pi=b("util"),typeof pi.inherits!="function")throw"";gi.exports=pi.inherits}catch{gi.exports=as()}var pi});var us=g((hy,ls)=>{"use strict";ls.exports=b("util").deprecate});var mi=g((dy,gs)=>{"use strict";gs.exports=M;function cs(t){var e=this;this.next=null,this.entry=null,this.finish=function(){bf(e,t)}}var yt;M.WritableState=Lt;var $u={deprecate:us()},hs=li(),_r=b("buffer").Buffer,Gu=global.Uint8Array||function(){};function Qu(t){return _r.from(t)}function Yu(t){return _r.isBuffer(t)||t instanceof Gu}var _i=ci(),Xu=hi(),Ju=Xu.getHighWaterMark,ke=Be().codes,Zu=ke.ERR_INVALID_ARG_TYPE,ef=ke.ERR_METHOD_NOT_IMPLEMENTED,tf=ke.ERR_MULTIPLE_CALLBACK,rf=ke.ERR_STREAM_CANNOT_PIPE,nf=ke.ERR_STREAM_DESTROYED,sf=ke.ERR_STREAM_NULL_VALUES,of=ke.ERR_STREAM_WRITE_AFTER_END,af=ke.ERR_UNKNOWN_ENCODING,_t=_i.errorOrDestroy;Se()(M,hs);function lf(){}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=Ju(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){gf(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 cs(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:$u.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(M,Symbol.hasInstance,{value:function(e){return yr.call(this,e)?!0:this!==M?!1:e&&e._writableState instanceof Lt}})):yr=function(e){return e instanceof this};function M(t){yt=yt||Je();var e=this instanceof yt;if(!e&&!yr.call(M,this))return new M(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)),hs.call(this)}M.prototype.pipe=function(){_t(this,new rf)};function uf(t,e){var r=new of;_t(t,r),process.nextTick(e,r)}function ff(t,e,r,i){var n;return r===null?n=new sf:typeof r!="string"&&!e.objectMode&&(n=new Zu("chunk",["string","Buffer"],r)),n?(_t(t,n),process.nextTick(i,n),!1):!0}M.prototype.write=function(t,e,r){var i=this._writableState,n=!1,s=!i.objectMode&&Yu(t);return s&&!_r.isBuffer(t)&&(t=Qu(t)),typeof e=="function"&&(r=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),typeof r!="function"&&(r=lf),i.ending?uf(this,r):(s||ff(this,i,t,r))&&(i.pendingcb++,n=hf(this,i,s,t,e,r)),n};M.prototype.cork=function(){this._writableState.corked++};M.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&ds(this,t))};M.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 af(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(M.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function cf(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=_r.from(e,r)),e}Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function hf(t,e,r,i,n,s){if(!r){var o=cf(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 yi(t,e,!1,a,i,n,s);return u}function yi(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new nf("write")):r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function df(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 pf(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function gf(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if(typeof n!="function")throw new tf;if(pf(r),e)df(t,r,i,e,n);else{var s=ps(r)||t.destroyed;!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&ds(t,r),i?process.nextTick(fs,t,r,s,n):fs(t,r,s,n)}}function fs(t,e,r,i){r||yf(t,e),e.pendingcb--,i(),kt(t,e)}function yf(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function ds(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,yi(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 cs(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,f=r.callback,h=e.objectMode?1:u.length;if(yi(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}M.prototype._write=function(t,e,r){r(new ef("_write()"))};M.prototype._writev=null;M.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||vf(this,i,r),this};Object.defineProperty(M.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function ps(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}function _f(t,e){t._final(function(r){e.pendingcb--,r&&_t(t,r),e.prefinished=!0,t.emit("prefinish"),kt(t,e)})}function mf(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(_f,t,e)):(e.prefinished=!0,t.emit("prefinish")))}function kt(t,e){var r=ps(e);if(r&&(mf(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 vf(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 bf(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(M.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});M.prototype.destroy=_i.destroy;M.prototype._undestroy=_i.undestroy;M.prototype._destroy=function(t,e){e(t)}});var Je=g((py,_s)=>{"use strict";var wf=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};_s.exports=ye;var ys=wi(),bi=mi();Se()(ye,ys);for(vi=wf(bi.prototype),mr=0;mr<vi.length;mr++)vr=vi[mr],ye.prototype[vr]||(ye.prototype[vr]=bi.prototype[vr]);var vi,vr,mr;function ye(t){if(!(this instanceof ye))return new ye(t);ys.call(this,t),bi.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",Sf)))}Object.defineProperty(ye.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(ye.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(ye.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Sf(){this._writableState.ended||process.nextTick(Ef,this)}function Ef(t){t.end()}Object.defineProperty(ye.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 bs=g((Si,vs)=>{"use strict";var br=b("buffer"),_e=br.Buffer;function ms(t,e){for(var r in t)e[r]=t[r]}_e.from&&_e.alloc&&_e.allocUnsafe&&_e.allocUnsafeSlow?vs.exports=br:(ms(br,Si),Si.Buffer=Ze);function Ze(t,e,r){return _e(t,e,r)}Ze.prototype=Object.create(_e.prototype);ms(_e,Ze);Ze.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return _e(t,e,r)};Ze.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var i=_e(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 _e(t)};Ze.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return br.SlowBuffer(t)}});var Ti=g(Ss=>{"use strict";var xi=bs().Buffer,ws=xi.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 xf(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 Tf(t){var e=xf(t);if(typeof e!="string"&&(xi.isEncoding===ws||!ws(t)))throw new Error("Unknown encoding: "+t);return e||t}Ss.StringDecoder=Mt;function Mt(t){this.encoding=Tf(t);var e;switch(this.encoding){case"utf16le":this.text=Af,this.end=Bf,e=4;break;case"utf8":this.fillLast=Of,e=4;break;case"base64":this.text=kf,this.end=Lf,e=3;break;default:this.write=Mf,this.end=qf;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=xi.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=Rf;Mt.prototype.text=If;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 Ei(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function Cf(t,e,r){var i=e.length-1;if(i<r)return 0;var n=Ei(e[i]);return n>=0?(n>0&&(t.lastNeed=n-1),n):--i<r||n===-2?0:(n=Ei(e[i]),n>=0?(n>0&&(t.lastNeed=n-2),n):--i<r||n===-2?0:(n=Ei(e[i]),n>=0?(n>0&&(n===2?n=0:t.lastNeed=n-3),n):0))}function Pf(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 Of(t){var e=this.lastTotal-this.lastNeed,r=Pf(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 If(t,e){var r=Cf(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 Rf(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Af(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 Bf(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 kf(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 Lf(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function Mf(t){return t.toString(this.encoding)}function qf(t){return t&&t.length?this.write(t):""}});var wr=g((yy,Ts)=>{"use strict";var Es=Be().codes.ERR_STREAM_PREMATURE_CLOSE;function Nf(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 Df(){}function Uf(t){return t.setHeader&&typeof t.abort=="function"}function xs(t,e,r){if(typeof e=="function")return xs(t,null,e);e||(e={}),r=Nf(r||Df);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 Es),r.call(t,m);if(n&&!o)return(!t._writableState||!t._writableState.ended)&&(m=new Es),r.call(t,m)},c=function(){t.req.on("finish",a)};return Uf(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)}}Ts.exports=xs});var Ps=g((_y,Cs)=>{"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 jf=wr(),Me=Symbol("lastResolve"),et=Symbol("lastReject"),qt=Symbol("error"),Er=Symbol("ended"),tt=Symbol("lastPromise"),Ci=Symbol("handlePromise"),rt=Symbol("stream");function qe(t,e){return{value:t,done:e}}function Ff(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 Wf(t){process.nextTick(Ff,t)}function Vf(t,e){return function(r,i){t.then(function(){if(e[Er]){r(qe(void 0,!0));return}e[Ci](r,i)},i)}}var Hf=Object.getPrototypeOf(function(){}),Kf=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(Vf(i,this));else{var s=this[rt].read();if(s!==null)return Promise.resolve(qe(s,!1));n=new Promise(this[Ci])}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),Hf),zf=function(e){var r,i=Object.create(Kf,(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,Ci,{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,jf(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",Wf.bind(null,i)),i};Cs.exports=zf});var As=g((my,Rs)=>{"use strict";function Os(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 $f(t){return function(){var e=this,r=arguments;return new Promise(function(i,n){var s=t.apply(e,r);function o(u){Os(s,i,n,o,a,"next",u)}function a(u){Os(s,i,n,o,a,"throw",u)}o(void 0)})}}function Is(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 Gf(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Is(Object(r),!0).forEach(function(i){Qf(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Is(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function Qf(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Yf=Be().codes.ERR_INVALID_ARG_TYPE;function Xf(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 Yf("iterable",["Iterable"],e);var n=new t(Gf({objectMode:!0},r)),s=!1;n._read=function(){s||(s=!0,o())};function o(){return a.apply(this,arguments)}function a(){return a=$f(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}Rs.exports=Xf});var wi=g((by,Fs)=>{"use strict";Fs.exports=O;var mt;O.ReadableState=Ms;var vy=b("events").EventEmitter,Ls=function(e,r){return e.listeners(r).length},Dt=li(),xr=b("buffer").Buffer,Jf=global.Uint8Array||function(){};function Zf(t){return xr.from(t)}function ec(t){return xr.isBuffer(t)||t instanceof Jf}var Pi=b("util"),T;Pi&&Pi.debuglog?T=Pi.debuglog("stream"):T=function(){};var tc=es(),Li=ci(),rc=hi(),ic=rc.getHighWaterMark,Tr=Be().codes,nc=Tr.ERR_INVALID_ARG_TYPE,sc=Tr.ERR_STREAM_PUSH_AFTER_EOF,oc=Tr.ERR_METHOD_NOT_IMPLEMENTED,ac=Tr.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,vt,Oi,Ii;Se()(O,Dt);var Nt=Li.errorOrDestroy,Ri=["error","close","destroy","pause","resume"];function lc(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 Ms(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=ic(this,t,"readableHighWaterMark",r),this.buffer=new tc,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=Ti().StringDecoder),this.decoder=new vt(t.encoding),this.encoding=t.encoding)}function O(t){if(mt=mt||Je(),!(this instanceof O))return new O(t);var e=this instanceof mt;this._readableState=new Ms(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(O.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});O.prototype.destroy=Li.destroy;O.prototype._undestroy=Li.undestroy;O.prototype._destroy=function(t,e){e(t)};O.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),qs(this,t,e,!1,i)};O.prototype.unshift=function(t){return qs(this,t,null,!0,!1)};function qs(t,e,r,i,n){T("readableAddChunk",e);var s=t._readableState;if(e===null)s.reading=!1,cc(t,s);else{var o;if(n||(o=uc(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=Zf(e)),i)s.endEmitted?Nt(t,new ac):Ai(t,s,e,!0);else if(s.ended)Nt(t,new sc);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||e.length!==0?Ai(t,s,e,!1):ki(t,s)):Ai(t,s,e,!1)}else i||(s.reading=!1,ki(t,s))}return!s.ended&&(s.length<s.highWaterMark||s.length===0)}function Ai(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)),ki(t,e)}function uc(t,e){var r;return!ec(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new nc("chunk",["string","Buffer","Uint8Array"],e)),r}O.prototype.isPaused=function(){return this._readableState.flowing===!1};O.prototype.setEncoding=function(t){vt||(vt=Ti().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 Bs=1073741824;function fc(t){return t>=Bs?t=Bs:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function ks(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=fc(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}O.prototype.read=function(t){T("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 T("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Bi(this):Cr(this),null;if(t=ks(t,e),t===0&&e.ended)return e.length===0&&Bi(this),null;var i=e.needReadable;T("need readable",i),(e.length===0||e.length-t<e.highWaterMark)&&(i=!0,T("length less than watermark",i)),e.ended||e.reading?(i=!1,T("reading or ended",i)):i&&(T("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=ks(r,e)));var n;return t>0?n=Us(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&&Bi(this)),n!==null&&this.emit("data",n),n};function cc(t,e){if(T("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,Ns(t)))}}function Cr(t){var e=t._readableState;T("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(T("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(Ns,t))}function Ns(t){var e=t._readableState;T("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,Mi(t)}function ki(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(hc,t,e))}function hc(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(T("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}O.prototype._read=function(t){Nt(this,new oc("_read()"))};O.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,T("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,w){T("onunpipe"),v===r&&w&&w.hasUnpiped===!1&&(w.hasUnpiped=!0,f())}function a(){T("onend"),t.end()}var u=dc(r);t.on("drain",u);var l=!1;function f(){T("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){T("ondata");var w=t.write(v);T("dest.write",w),w===!1&&((i.pipesCount===1&&i.pipes===t||i.pipesCount>1&&js(i.pipes,t)!==-1)&&!l&&(T("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function c(v){T("onerror",v),y(),t.removeListener("error",c),Ls(t,"error")===0&&Nt(t,v)}lc(t,"error",c);function d(){t.removeListener("finish",m),y()}t.once("close",d);function m(){T("onfinish"),t.removeListener("close",d),y()}t.once("finish",m);function y(){T("unpipe"),r.unpipe(t)}return t.emit("pipe",r),i.flowing||(T("pipe resume"),r.resume()),t};function dc(t){return function(){var r=t._readableState;T("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Ls(t,"data")&&(r.flowing=!0,Mi(t))}}O.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=js(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)};O.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,T("on readable",i.length,i.reading),i.length?Cr(this):i.reading||process.nextTick(pc,this)),r};O.prototype.addListener=O.prototype.on;O.prototype.removeListener=function(t,e){var r=Dt.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(Ds,this),r};O.prototype.removeAllListeners=function(t){var e=Dt.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(Ds,this),e};function Ds(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 pc(t){T("readable nexttick read 0"),t.read(0)}O.prototype.resume=function(){var t=this._readableState;return t.flowing||(T("resume"),t.flowing=!t.readableListening,gc(this,t)),t.paused=!1,this};function gc(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(yc,t,e))}function yc(t,e){T("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Mi(t),e.flowing&&!e.reading&&t.read(0)}O.prototype.pause=function(){return T("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(T("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Mi(t){var e=t._readableState;for(T("flow",e.flowing);e.flowing&&t.read()!==null;);}O.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;t.on("end",function(){if(T("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(T("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<Ri.length;s++)t.on(Ri[s],this.emit.bind(this,Ri[s]));return this._read=function(o){T("wrapped _read",o),i&&(i=!1,t.resume())},this};typeof Symbol=="function"&&(O.prototype[Symbol.asyncIterator]=function(){return Oi===void 0&&(Oi=Ps()),Oi(this)});Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}});O._fromList=Us;Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function Us(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 Bi(t){var e=t._readableState;T("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(_c,e,t))}function _c(t,e){if(T("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"&&(O.from=function(t,e){return Ii===void 0&&(Ii=As()),Ii(O,t,e)});function js(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}});var qi=g((wy,Vs)=>{"use strict";Vs.exports=Ee;var Pr=Be().codes,mc=Pr.ERR_METHOD_NOT_IMPLEMENTED,vc=Pr.ERR_MULTIPLE_CALLBACK,bc=Pr.ERR_TRANSFORM_ALREADY_TRANSFORMING,wc=Pr.ERR_TRANSFORM_WITH_LENGTH_0,Or=Je();Se()(Ee,Or);function Sc(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new vc);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 Ee(t){if(!(this instanceof Ee))return new Ee(t);Or.call(this,t),this._transformState={afterTransform:Sc.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",Ec)}function Ec(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){Ws(t,e,r)}):Ws(this,null,null)}Ee.prototype.push=function(t,e){return this._transformState.needTransform=!1,Or.prototype.push.call(this,t,e)};Ee.prototype._transform=function(t,e,r){r(new mc("_transform()"))};Ee.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)}};Ee.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};Ee.prototype._destroy=function(t,e){Or.prototype._destroy.call(this,t,function(r){e(r)})};function Ws(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new wc;if(t._transformState.transforming)throw new bc;return t.push(null)}});var zs=g((Sy,Ks)=>{"use strict";Ks.exports=Ut;var Hs=qi();Se()(Ut,Hs);function Ut(t){if(!(this instanceof Ut))return new Ut(t);Hs.call(this,t)}Ut.prototype._transform=function(t,e,r){r(null,t)}});var Xs=g((Ey,Ys)=>{"use strict";var Ni;function xc(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var Qs=Be().codes,Tc=Qs.ERR_MISSING_ARGS,Cc=Qs.ERR_STREAM_DESTROYED;function $s(t){if(t)throw t}function Pc(t){return t.setHeader&&typeof t.abort=="function"}function Oc(t,e,r,i){i=xc(i);var n=!1;t.on("close",function(){n=!0}),Ni===void 0&&(Ni=wr()),Ni(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,Pc(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();i(o||new Cc("pipe"))}}}function Gs(t){t()}function Ic(t,e){return t.pipe(e)}function Rc(t){return!t.length||typeof t[t.length-1]!="function"?$s:t.pop()}function Ac(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i=Rc(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Tc("streams");var n,s=e.map(function(o,a){var u=a<e.length-1,l=a>0;return Oc(o,u,l,function(f){n||(n=f),f&&s.forEach(Gs),!u&&(s.forEach(Gs),i(n))})});return e.reduce(Ic)}Ys.exports=Ac});var Ne=g((oe,Ft)=>{"use strict";var jt=b("stream");process.env.READABLE_STREAM==="disable"&&jt?(Ft.exports=jt.Readable,Object.assign(Ft.exports,jt),Ft.exports.Stream=jt):(oe=Ft.exports=wi(),oe.Stream=jt||oe,oe.Readable=oe,oe.Writable=mi(),oe.Duplex=Je(),oe.Transform=qi(),oe.PassThrough=zs(),oe.finished=wr(),oe.pipeline=Xs())});var Ir=g((xy,Js)=>{"use strict";var Bc=dr(),kc=Ne().Readable,Lc={objectMode:!0},Mc={clean:!0};function De(t){if(!(this instanceof De))return new De(t);this.options=t||{},this.options=Bc(Mc,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 kc(Lc),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()};Js.exports=De});var eo=g((Ty,Zs)=>{"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={}};Zs.exports=bt});var ro=g((Cy,to)=>{"use strict";to.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var no=g((Py,io)=>{"use strict";io.exports=I;I.Node=it;I.create=I;function I(t){var e=this;if(e instanceof I||(e=new I),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}I.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};I.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++}};I.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++}};I.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)Nc(this,arguments[t]);return this.length};I.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)Dc(this,arguments[t]);return this.length};I.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}};I.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}};I.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};I.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};I.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};I.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};I.prototype.map=function(t,e){e=e||this;for(var r=new I,i=this.head;i!==null;)r.push(t.call(e,i.value,this)),i=i.next;return r};I.prototype.mapReverse=function(t,e){e=e||this;for(var r=new I,i=this.tail;i!==null;)r.push(t.call(e,i.value,this)),i=i.prev;return r};I.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};I.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};I.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};I.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};I.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 I;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};I.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 I;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};I.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=qc(this,n,r[i]);return s};I.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 qc(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 Nc(t,e){t.tail=new it(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function Dc(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{ro()(I)}catch{}});var uo=g((Oy,lo)=>{"use strict";var Uc=no(),nt=Symbol("max"),Te=Symbol("length"),wt=Symbol("lengthCalculator"),Vt=Symbol("allowStale"),st=Symbol("maxAge"),xe=Symbol("dispose"),so=Symbol("noDisposeOnSet"),V=Symbol("lruList"),fe=Symbol("cache"),ao=Symbol("updateAgeOnGet"),Di=()=>1,ji=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||Di;if(this[wt]=typeof i!="function"?Di: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[xe]=e.dispose,this[so]=e.noDisposeOnSet||!1,this[ao]=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=Di),e!==this[wt]&&(this[wt]=e,this[Te]=0,this[V].forEach(r=>{r.length=this[wt](r.value,r.key),this[Te]+=r.length})),Wt(this)}get lengthCalculator(){return this[wt]}get length(){return this[Te]}get itemCount(){return this[V].length}rforEach(e,r){r=r||this;for(let i=this[V].tail;i!==null;){let n=i.prev;oo(this,e,i,r),i=n}}forEach(e,r){r=r||this;for(let i=this[V].head;i!==null;){let n=i.next;oo(this,e,i,r),i=n}}keys(){return this[V].toArray().map(e=>e.key)}values(){return this[V].toArray().map(e=>e.value)}reset(){this[xe]&&this[V]&&this[V].length&&this[V].forEach(e=>this[xe](e.key,e.value)),this[fe]=new Map,this[V]=new Uc,this[Te]=0}dump(){return this[V].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[V]}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[fe].has(e)){if(s>this[nt])return St(this,this[fe].get(e)),!1;let u=this[fe].get(e).value;return this[xe]&&(this[so]||this[xe](e,u.value)),u.now=n,u.maxAge=i,u.value=r,this[Te]+=s-u.length,u.length=s,this.get(e),Wt(this),!0}let o=new Fi(e,r,s,n,i);return o.length>this[nt]?(this[xe]&&this[xe](e,r),!1):(this[Te]+=o.length,this[V].unshift(o),this[fe].set(e,this[V].head),Wt(this),!0)}has(e){if(!this[fe].has(e))return!1;let r=this[fe].get(e).value;return!Rr(this,r)}get(e){return Ui(this,e,!0)}peek(e){return Ui(this,e,!1)}pop(){let e=this[V].tail;return e?(St(this,e),e.value):null}del(e){St(this,this[fe].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[fe].forEach((e,r)=>Ui(this,r,!1))}},Ui=(t,e,r)=>{let i=t[fe].get(e);if(i){let n=i.value;if(Rr(t,n)){if(St(t,i),!t[Vt])return}else r&&(t[ao]&&(i.value.now=Date.now()),t[V].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[Te]>t[nt])for(let e=t[V].tail;t[Te]>t[nt]&&e!==null;){let r=e.prev;St(t,e),e=r}},St=(t,e)=>{if(e){let r=e.value;t[xe]&&t[xe](r.key,r.value),t[Te]-=r.length,t[fe].delete(r.key),t[V].removeNode(e)}},Fi=class{constructor(e,r,i,n,s){this.key=e,this.value=r,this.length=i,this.now=n,this.maxAge=s||0}},oo=(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)};lo.exports=ji});var jc,B,Ce,Et,X=j(()=>{"use strict";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)}}(),B=function(){function t(e){e===void 0&&(e=t.NORMAL),this.iteratorType=e}return t.NORMAL=!1,t.REVERSE=!0,t}(),Ce=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){jc(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ce)});var Fc,Wc,fo,co=j(()=>{"use strict";X();Fc=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)}}(),Wc=function(t){Fc(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}(Ce),fo=Wc});var Vc,Hc,Ue,Ht=j(()=>{"use strict";X();Vc=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)}}(),Hc=function(t){Vc(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Et),Ue=Hc});function k(t,e,r){if(t<e||t>r)throw new RangeError}var je=j(()=>{"use strict"});var Kc,Ar,Wi=j(()=>{"use strict";je();X();Kc=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){Kc(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===B.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 k(this.node,0,this.size()-1),this.getElementByPos(this.node)},set:function(r){k(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}(B)});var ho,zc,$c,Gc,ot,Qc,Br,Vi=j(()=>{"use strict";Ht();je();X();Wi();ho=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)}}(),zc=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}}},$c=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},Gc=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){ho(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),Qc=function(t){ho(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]=Gc([],$c(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,B.REVERSE)},e.prototype.rEnd=function(){return new ot(-1,this.size,this.getElementByPos,this.setElementByPos,B.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){k(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){k(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),k(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(k(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 zc(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=Qc});var Yc,Xc,po,go=j(()=>{"use strict";Vi();X();Yc=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)}}(),Xc=function(t){Yc(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}(Ce),po=Xc});var Jc,kr,Zc,eh,yo,_o=j(()=>{"use strict";X();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)}}(),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},Zc=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))},eh=function(t){Jc(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?Zc([],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}(Ce),yo=eh});var bo,th,mo,vo,rh,at,ih,q,Lr=j(()=>{"use strict";Ht();je();X();Wi();bo=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)}}(),th=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}}},mo=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},vo=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))},rh=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){bo(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),ih=function(t){bo(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?vo([],mo(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,B.REVERSE)},e.prototype.rEnd=function(){return new at(-1,this.size,this.getElementByPos,this.setElementByPos,B.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 k(r,0,this.length-1),this.vector[r]},e.prototype.eraseElementByPos=function(r){k(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){k(r,0,this.length-1),this.vector[r]=i},e.prototype.insert=function(r,i,n){var s;n===void 0&&(n=1),k(r,0,this.length),(s=this.vector).splice.apply(s,vo([r,0],mo(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 th(this,function(r){switch(r.label){case 0:return[5,rh(this.vector)];case 1:return[2,r.sent()]}})}.bind(this)()},e}(Ue),q=ih});var wo,nh,Kt,lt,sh,So,Eo=j(()=>{"use strict";Ht();je();X();wo=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)}}(),nh=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){wo(e,t);function e(r,i,n){var s=t.call(this,n)||this;return s.node=r,s.header=i,s.iteratorType===B.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}(B),sh=function(t){wo(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,B.REVERSE)},e.prototype.rEnd=function(){return new lt(this.header,this.header,B.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){k(r,0,this.length-1);for(var i=this.head;r--;)i=i.next;return i.value},e.prototype.eraseElementByPos=function(r){if(k(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){k(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),k(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 nh(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),So=sh});var oh,S,xo=j(()=>{"use strict";oh=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}(),S=oh});var ah,To,lh,xt,Mr=j(()=>{"use strict";xo();X();je();ah=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)}}(),To=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},lh=function(t){ah(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 S,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===S.RED){r.color=S.BLACK;return}if(r===i.left){var n=i.right;if(n.color===S.RED)n.color=S.BLACK,i.color=S.RED,i===this.root?this.root=i.rotateLeft():i.rotateLeft();else if(n.color===S.BLACK)if(n.right&&n.right.color===S.RED){n.color=i.color,i.color=S.BLACK,n.right.color=S.BLACK,i===this.root?this.root=i.rotateLeft():i.rotateLeft();return}else n.left&&n.left.color===S.RED?(n.color=S.RED,n.left.color=S.BLACK,n.rotateRight()):(n.color=S.RED,r=i)}else{var n=i.left;if(n.color===S.RED)n.color=S.BLACK,i.color=S.RED,i===this.root?this.root=i.rotateRight():i.rotateRight();else if(n.left&&n.left.color===S.RED){n.color=i.color,i.color=S.BLACK,n.left.color=S.BLACK,i===this.root?this.root=i.rotateRight():i.rotateRight();return}else n.right&&n.right.color===S.RED?(n.color=S.RED,n.right.color=S.BLACK,n.rotateLeft()):(n.color=S.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=To([s.key,r.key],2),r.key=i[0],s.key=i[1],n=To([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=S.BLACK},e.prototype.insertNodeSelfBalance=function(r){for(;;){var i=r.parent;if(i.color===S.BLACK)return;var n=i.parent;if(i===n.left){var s=n.right;if(s&&s.color===S.RED){if(s.color=i.color=S.BLACK,n===this.root)return;n.color=S.RED,r=n;continue}else if(r===i.right){if(r.color=S.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=S.BLACK,n===this.root?this.root=n.rotateRight():n.rotateRight();n.color=S.RED}else{var s=n.left;if(s&&s.color===S.RED){if(s.color=i.color=S.BLACK,n===this.root)return;n.color=S.RED,r=n;continue}else if(r===i.left){if(r.color=S.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=S.BLACK,n===this.root?this.root=n.rotateLeft():n.rotateLeft();n.color=S.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 S(r,i),this.root.color=S.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 S(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 S(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 S(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 S(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 S(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;k(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=lh});var uh,fh,qr,Hi=j(()=>{"use strict";X();uh=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){uh(e,t);function e(r,i,n){var s=t.call(this,n)||this;return s.node=r,s.header=i,s.iteratorType===B.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}(B),qr=fh});var Co,ch,Nr,ce,hh,Pe,Ki=j(()=>{"use strict";Mr();X();je();Hi();Co=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)}}(),ch=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.")},ce=function(t){Co(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),hh=function(t){Co(e,t);function e(r,i){r===void 0&&(r=[]);var n=t.call(this,i)||this;return n.iterationFunc=function(s){return ch(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 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,B.REVERSE)},e.prototype.rEnd=function(){return new ce(this.header,this.header,B.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;k(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 ce(i,this.header):this.end()},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.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),Pe=hh});var Oo,dh,Po,Dr,he,ph,de,zi=j(()=>{"use strict";X();je();Mr();Hi();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)}}(),dh=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}}},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},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.")},he=function(t){Oo(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),ph=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 dh(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=Po(s,2),a=o[0],u=o[1];return n.setElement(a,u)}),n}return e.prototype.begin=function(){return new he(this.header.left||this.header,this.header)},e.prototype.end=function(){return new he(this.header,this.header)},e.prototype.rBegin=function(){return new he(this.header.right||this.header,this.header,B.REVERSE)},e.prototype.rEnd=function(){return new he(this.header,this.header,B.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 he(i,this.header)},e.prototype.upperBound=function(r){var i=this._upperBound(this.root,r);return new he(i,this.header)},e.prototype.reverseLowerBound=function(r){var i=this._reverseLowerBound(this.root,r);return new he(i,this.header)},e.prototype.reverseUpperBound=function(r){var i=this._reverseUpperBound(this.root,r);return new he(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 he(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;k(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=Po(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),de=ph});var gh,yh,N,Ur=j(()=>{"use strict";X();gh=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)}}(),yh=function(t){gh(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}(Ce),N=yh});var _h,mh,vh,bh,Io,Ro=j(()=>{"use strict";Ur();Lr();Ki();_h=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)}}(),mh=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}}},vh=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.")},bh=function(t){_h(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>=N.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 q([m],!1),"continue"}var y=[],v=[];c.forEach(function(w){var P=r.hashFunc(w);(P&n)===0?y.push(w):v.push(w)}),c instanceof Pe?(y.length>N.untreeifyThreshold?i[h]=new Pe(y):y.length&&(i[h]=new q(y,!1)),v.length>N.untreeifyThreshold?i[h+n]=new Pe(v):v.length&&(i[h+n]=new q(v,!1))):(y.length>=N.treeifyThreshold?i[h]=new Pe(y):y.length&&(i[h]=new q(y,!1)),v.length>=N.treeifyThreshold?i[h+n]=new Pe(v):v.length&&(i[h+n]=new q(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 q([r],!1),this.length+=1;else{var s=n.size();if(n instanceof q){if(!n.find(r).equals(n.end()))return;if(n.pushBack(r),s+1>=N.treeifyThreshold){if(this.bucketNum<=N.minTreeifySize){this.length+=1,this.reAllocate();return}this.hashTable[i]=new Pe(n)}this.length+=1}else{n.insert(r);var o=n.size();this.length+=o-s}}this.length>this.bucketNum*N.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 q){n.eraseElementByValue(r);var o=n.size();this.length+=o-s}else{n.eraseElementByKey(r);var o=n.size();this.length+=o-s,o<=N.untreeifyThreshold&&(this.hashTable[i]=new q(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 mh(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,vh(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}(N),Io=bh});var wh,Sh,zt,Eh,Ao,Bo=j(()=>{"use strict";Ur();Lr();zi();wh=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)}}(),Sh=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.")},Eh=function(t){wh(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>=N.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 q([m],!1),"continue"}var y=[],v=[];c.forEach(function(w){var P=r.hashFunc(w[0]);(P&n)===0?y.push(w):v.push(w)}),c instanceof de?(y.length>N.untreeifyThreshold?i[h]=new de(y):y.length&&(i[h]=new q(y,!1)),v.length>N.untreeifyThreshold?i[h+n]=new de(v):v.length&&(i[h+n]=new q(v,!1))):(y.length>=N.treeifyThreshold?i[h]=new de(y):y.length&&(i[h]=new q(y,!1)),v.length>=N.treeifyThreshold?i[h+n]=new de(v):v.length&&(i[h+n]=new q(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 q([[r,i]],!1);else{var u=a.size();if(a instanceof q){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 de(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 de)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 q){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<=N.untreeifyThreshold&&(this.hashTable[s]=new q(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 de)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 Sh(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}(N),Ao=Eh});var ko={};bu(ko,{Container:()=>Et,ContainerIterator:()=>B,Deque:()=>Br,DequeIterator:()=>ot,HashContainer:()=>N,HashMap:()=>Ao,HashSet:()=>Io,LinkList:()=>So,LinkListIterator:()=>lt,OrderedMap:()=>de,OrderedMapIterator:()=>he,OrderedSet:()=>Pe,OrderedSetIterator:()=>ce,PriorityQueue:()=>yo,Queue:()=>po,SequentialContainer:()=>Ue,Stack:()=>fo,TreeContainer:()=>xt,Vector:()=>q,VectorIterator:()=>at});var Lo=j(()=>{"use strict";co();go();_o();Lr();Eo();Vi();Ki();zi();Ro();Bo();X();Ht();Mr();Ur()});var qo=g((H_,Mo)=>{"use strict";var Tt=1e3,Ct=Tt*60,Pt=Ct*60,ut=Pt*24,xh=ut*7,Th=ut*365.25;Mo.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Ch(t);if(r==="number"&&isFinite(t))return e.long?Oh(t):Ph(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Ch(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*Th;case"weeks":case"week":case"w":return r*xh;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 Ph(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 Oh(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 $i=g((K_,No)=>{"use strict";function Ih(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=n,r.enabled=a,r.humanize=qo(),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 w=y,P=Number(new Date),U=P-(h||P);w.diff=U,w.prev=h,w.curr=P,h=P,v[0]=r.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let z=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(Xe,Bt)=>{if(Xe==="%%")return"%";z++;let cr=r.formatters[Bt];if(typeof cr=="function"){let pu=v[z];Xe=cr.call(w,pu),v.splice(z,1),z--}return Xe}),r.formatArgs.call(w,v),(w.log||r.log).apply(w,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(" ",",").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}No.exports=Ih});var Do=g((re,Fr)=>{"use strict";re.formatArgs=Ah;re.save=Bh;re.load=kh;re.useColors=Rh;re.storage=Lh();re.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`."))}})();re.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 Rh(){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 Ah(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)}re.log=console.debug||console.log||(()=>{});function Bh(t){try{t?re.storage.setItem("debug",t):re.storage.removeItem("debug")}catch{}}function kh(){let t;try{t=re.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Lh(){try{return localStorage}catch{}}Fr.exports=$i()(re);var{formatters:Mh}=Fr.exports;Mh.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var jo=g((z_,Uo)=>{"use strict";Uo.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 Vo=g(($_,Wo)=>{"use strict";var qh=b("os"),Fo=b("tty"),ae=jo(),{env:H}=process,Fe;ae("no-color")||ae("no-colors")||ae("color=false")||ae("color=never")?Fe=0:(ae("color")||ae("colors")||ae("color=true")||ae("color=always"))&&(Fe=1);"FORCE_COLOR"in H&&(H.FORCE_COLOR==="true"?Fe=1:H.FORCE_COLOR==="false"?Fe=0:Fe=H.FORCE_COLOR.length===0?1:Math.min(parseInt(H.FORCE_COLOR,10),3));function Gi(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Qi(t,e){if(Fe===0)return 0;if(ae("color=16m")||ae("color=full")||ae("color=truecolor"))return 3;if(ae("color=256"))return 2;if(t&&!e&&Fe===void 0)return 0;let r=Fe||0;if(H.TERM==="dumb")return r;if(process.platform==="win32"){let i=qh.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in H)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(i=>i in H)||H.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in H)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(H.TEAMCITY_VERSION)?1:0;if(H.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in H){let i=parseInt((H.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(H.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(H.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(H.TERM)||"COLORTERM"in H?1:r}function Nh(t){let e=Qi(t,t&&t.isTTY);return Gi(e)}Wo.exports={supportsColor:Nh,stdout:Gi(Qi(!0,Fo.isatty(1))),stderr:Gi(Qi(!0,Fo.isatty(2)))}});var Ko=g((K,Vr)=>{"use strict";var Dh=b("tty"),Wr=b("util");K.init=Kh;K.log=Wh;K.formatArgs=jh;K.save=Vh;K.load=Hh;K.useColors=Uh;K.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`.");K.colors=[6,2,3,4,5,1];try{let t=Vo();t&&(t.stderr||t).level>=2&&(K.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{}K.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 Uh(){return"colors"in K.inspectOpts?!!K.inspectOpts.colors:Dh.isatty(process.stderr.fd)}function jh(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(`
|
|
1
|
+
var gu=Object.create;var hr=Object.defineProperty;var yu=Object.getOwnPropertyDescriptor;var _u=Object.getOwnPropertyNames;var mu=Object.getPrototypeOf,vu=Object.prototype.hasOwnProperty;var b=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(t&&(e=t(t=0)),e);var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bu=(t,e)=>{for(var r in e)hr(t,r,{get:e[r],enumerable:!0})},Gn=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _u(e))!vu.call(t,n)&&n!==r&&hr(t,n,{get:()=>e[n],enumerable:!(i=yu(e,n))||i.enumerable});return t};var wu=(t,e,r)=>(r=t!=null?gu(mu(t)):{},Gn(e||!t||!t.__esModule?hr(r,"default",{value:t,enumerable:!0}):r,t)),Su=t=>Gn(hr({},"__esModule",{value:!0}),t);var dr=g((Jg,Qn)=>{"use strict";Qn.exports=xu;var Eu=Object.prototype.hasOwnProperty;function xu(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var i in r)Eu.call(r,i)&&(t[i]=r[i])}return t}});var li=g((Zg,Yn)=>{"use strict";Yn.exports=b("stream")});var es=g((ey,Zn)=>{"use strict";function Xn(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 Tu(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xn(Object(r),!0).forEach(function(i){Cu(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xn(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function Cu(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pu(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Jn(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 Ou(t,e,r){return e&&Jn(t.prototype,e),r&&Jn(t,r),t}var Iu=b("buffer"),pr=Iu.Buffer,Ru=b("util"),ui=Ru.inspect,Au=ui&&ui.custom||"inspect";function Bu(t,e,r){pr.prototype.copy.call(t,e,r)}Zn.exports=function(){function t(){Pu(this,t),this.head=null,this.tail=null,this.length=0}return Ou(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;)Bu(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:Au,value:function(r,i){return ui(this,Tu({},i,{depth:0,customInspect:!1}))}}]),t}()});var ci=g((ty,rs)=>{"use strict";function ku(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(fi,this,t)):process.nextTick(fi,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(ts,r,s)):process.nextTick(ts,r,s):e?(process.nextTick(gr,r),e(s)):process.nextTick(gr,r)}),this)}function ts(t,e){fi(t,e),gr(t)}function gr(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function Lu(){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 fi(t,e){t.emit("error",e)}function Mu(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}rs.exports={destroy:ku,undestroy:Lu,errorOrDestroy:Mu}});var Be=g((ry,ss)=>{"use strict";var ns={};function se(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,ns[t]=n}function is(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 qu(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function Nu(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function Du(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}se("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);se("ERR_INVALID_ARG_TYPE",function(t,e,r){let i;typeof e=="string"&&qu(e,"not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be";let n;if(Nu(t," argument"))n=`The ${t} ${i} ${is(e,"type")}`;else{let s=Du(t,".")?"property":"argument";n=`The "${t}" ${s} ${i} ${is(e,"type")}`}return n+=`. Received type ${typeof r}`,n},TypeError);se("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");se("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});se("ERR_STREAM_PREMATURE_CLOSE","Premature close");se("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});se("ERR_MULTIPLE_CALLBACK","Callback called multiple times");se("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");se("ERR_STREAM_WRITE_AFTER_END","write after end");se("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);se("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);se("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ss.exports.codes=ns});var hi=g((iy,os)=>{"use strict";var Uu=Be().codes.ERR_INVALID_OPT_VALUE;function ju(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Fu(t,e,r,i){var n=ju(e,i,r);if(n!=null){if(!(isFinite(n)&&Math.floor(n)===n)||n<0){var s=i?r:"highWaterMark";throw new Uu(s,n)}return Math.floor(n)}return t.objectMode?16:16*1024}os.exports={getHighWaterMark:Fu}});var as=g((ny,di)=>{"use strict";typeof Object.create=="function"?di.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:di.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 Se=g((sy,gi)=>{"use strict";try{if(pi=b("util"),typeof pi.inherits!="function")throw"";gi.exports=pi.inherits}catch{gi.exports=as()}var pi});var us=g((oy,ls)=>{"use strict";ls.exports=b("util").deprecate});var mi=g((ay,gs)=>{"use strict";gs.exports=M;function cs(t){var e=this;this.next=null,this.entry=null,this.finish=function(){gf(e,t)}}var yt;M.WritableState=Lt;var Wu={deprecate:us()},hs=li(),_r=b("buffer").Buffer,Vu=global.Uint8Array||function(){};function Hu(t){return _r.from(t)}function Ku(t){return _r.isBuffer(t)||t instanceof Vu}var _i=ci(),zu=hi(),$u=zu.getHighWaterMark,ke=Be().codes,Gu=ke.ERR_INVALID_ARG_TYPE,Qu=ke.ERR_METHOD_NOT_IMPLEMENTED,Yu=ke.ERR_MULTIPLE_CALLBACK,Xu=ke.ERR_STREAM_CANNOT_PIPE,Ju=ke.ERR_STREAM_DESTROYED,Zu=ke.ERR_STREAM_NULL_VALUES,ef=ke.ERR_STREAM_WRITE_AFTER_END,tf=ke.ERR_UNKNOWN_ENCODING,_t=_i.errorOrDestroy;Se()(M,hs);function rf(){}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=$u(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){ff(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 cs(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:Wu.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(M,Symbol.hasInstance,{value:function(e){return yr.call(this,e)?!0:this!==M?!1:e&&e._writableState instanceof Lt}})):yr=function(e){return e instanceof this};function M(t){yt=yt||Je();var e=this instanceof yt;if(!e&&!yr.call(M,this))return new M(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)),hs.call(this)}M.prototype.pipe=function(){_t(this,new Xu)};function nf(t,e){var r=new ef;_t(t,r),process.nextTick(e,r)}function sf(t,e,r,i){var n;return r===null?n=new Zu:typeof r!="string"&&!e.objectMode&&(n=new Gu("chunk",["string","Buffer"],r)),n?(_t(t,n),process.nextTick(i,n),!1):!0}M.prototype.write=function(t,e,r){var i=this._writableState,n=!1,s=!i.objectMode&&Ku(t);return s&&!_r.isBuffer(t)&&(t=Hu(t)),typeof e=="function"&&(r=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),typeof r!="function"&&(r=rf),i.ending?nf(this,r):(s||sf(this,i,t,r))&&(i.pendingcb++,n=af(this,i,s,t,e,r)),n};M.prototype.cork=function(){this._writableState.corked++};M.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&ds(this,t))};M.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 tf(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(M.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function of(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=_r.from(e,r)),e}Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function af(t,e,r,i,n,s){if(!r){var o=of(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 yi(t,e,!1,a,i,n,s);return u}function yi(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new Ju("write")):r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function lf(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 uf(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function ff(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if(typeof n!="function")throw new Yu;if(uf(r),e)lf(t,r,i,e,n);else{var s=ps(r)||t.destroyed;!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&ds(t,r),i?process.nextTick(fs,t,r,s,n):fs(t,r,s,n)}}function fs(t,e,r,i){r||cf(t,e),e.pendingcb--,i(),kt(t,e)}function cf(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function ds(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,yi(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 cs(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,f=r.callback,h=e.objectMode?1:u.length;if(yi(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}M.prototype._write=function(t,e,r){r(new Qu("_write()"))};M.prototype._writev=null;M.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||pf(this,i,r),this};Object.defineProperty(M.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function ps(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}function hf(t,e){t._final(function(r){e.pendingcb--,r&&_t(t,r),e.prefinished=!0,t.emit("prefinish"),kt(t,e)})}function df(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(hf,t,e)):(e.prefinished=!0,t.emit("prefinish")))}function kt(t,e){var r=ps(e);if(r&&(df(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 pf(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 gf(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(M.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});M.prototype.destroy=_i.destroy;M.prototype._undestroy=_i.undestroy;M.prototype._destroy=function(t,e){e(t)}});var Je=g((ly,_s)=>{"use strict";var yf=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};_s.exports=ye;var ys=wi(),bi=mi();Se()(ye,ys);for(vi=yf(bi.prototype),mr=0;mr<vi.length;mr++)vr=vi[mr],ye.prototype[vr]||(ye.prototype[vr]=bi.prototype[vr]);var vi,vr,mr;function ye(t){if(!(this instanceof ye))return new ye(t);ys.call(this,t),bi.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",_f)))}Object.defineProperty(ye.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(ye.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(ye.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function _f(){this._writableState.ended||process.nextTick(mf,this)}function mf(t){t.end()}Object.defineProperty(ye.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 bs=g((Si,vs)=>{"use strict";var br=b("buffer"),_e=br.Buffer;function ms(t,e){for(var r in t)e[r]=t[r]}_e.from&&_e.alloc&&_e.allocUnsafe&&_e.allocUnsafeSlow?vs.exports=br:(ms(br,Si),Si.Buffer=Ze);function Ze(t,e,r){return _e(t,e,r)}Ze.prototype=Object.create(_e.prototype);ms(_e,Ze);Ze.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return _e(t,e,r)};Ze.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var i=_e(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 _e(t)};Ze.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return br.SlowBuffer(t)}});var Ti=g(Ss=>{"use strict";var xi=bs().Buffer,ws=xi.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 vf(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 bf(t){var e=vf(t);if(typeof e!="string"&&(xi.isEncoding===ws||!ws(t)))throw new Error("Unknown encoding: "+t);return e||t}Ss.StringDecoder=Mt;function Mt(t){this.encoding=bf(t);var e;switch(this.encoding){case"utf16le":this.text=Cf,this.end=Pf,e=4;break;case"utf8":this.fillLast=Ef,e=4;break;case"base64":this.text=Of,this.end=If,e=3;break;default:this.write=Rf,this.end=Af;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=xi.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=Tf;Mt.prototype.text=xf;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 Ei(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function wf(t,e,r){var i=e.length-1;if(i<r)return 0;var n=Ei(e[i]);return n>=0?(n>0&&(t.lastNeed=n-1),n):--i<r||n===-2?0:(n=Ei(e[i]),n>=0?(n>0&&(t.lastNeed=n-2),n):--i<r||n===-2?0:(n=Ei(e[i]),n>=0?(n>0&&(n===2?n=0:t.lastNeed=n-3),n):0))}function Sf(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 Ef(t){var e=this.lastTotal-this.lastNeed,r=Sf(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 xf(t,e){var r=wf(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 Tf(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Cf(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 Pf(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 Of(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 If(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function Rf(t){return t.toString(this.encoding)}function Af(t){return t&&t.length?this.write(t):""}});var wr=g((fy,Ts)=>{"use strict";var Es=Be().codes.ERR_STREAM_PREMATURE_CLOSE;function Bf(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 kf(){}function Lf(t){return t.setHeader&&typeof t.abort=="function"}function xs(t,e,r){if(typeof e=="function")return xs(t,null,e);e||(e={}),r=Bf(r||kf);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 Es),r.call(t,m);if(n&&!o)return(!t._writableState||!t._writableState.ended)&&(m=new Es),r.call(t,m)},c=function(){t.req.on("finish",a)};return Lf(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)}}Ts.exports=xs});var Ps=g((cy,Cs)=>{"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 Mf=wr(),Me=Symbol("lastResolve"),et=Symbol("lastReject"),qt=Symbol("error"),Er=Symbol("ended"),tt=Symbol("lastPromise"),Ci=Symbol("handlePromise"),rt=Symbol("stream");function qe(t,e){return{value:t,done:e}}function qf(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 Nf(t){process.nextTick(qf,t)}function Df(t,e){return function(r,i){t.then(function(){if(e[Er]){r(qe(void 0,!0));return}e[Ci](r,i)},i)}}var Uf=Object.getPrototypeOf(function(){}),jf=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(Df(i,this));else{var s=this[rt].read();if(s!==null)return Promise.resolve(qe(s,!1));n=new Promise(this[Ci])}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),Uf),Ff=function(e){var r,i=Object.create(jf,(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,Ci,{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,Mf(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",Nf.bind(null,i)),i};Cs.exports=Ff});var As=g((hy,Rs)=>{"use strict";function Os(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 Wf(t){return function(){var e=this,r=arguments;return new Promise(function(i,n){var s=t.apply(e,r);function o(u){Os(s,i,n,o,a,"next",u)}function a(u){Os(s,i,n,o,a,"throw",u)}o(void 0)})}}function Is(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 Vf(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Is(Object(r),!0).forEach(function(i){Hf(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Is(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}function Hf(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Kf=Be().codes.ERR_INVALID_ARG_TYPE;function zf(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 Kf("iterable",["Iterable"],e);var n=new t(Vf({objectMode:!0},r)),s=!1;n._read=function(){s||(s=!0,o())};function o(){return a.apply(this,arguments)}function a(){return a=Wf(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}Rs.exports=zf});var wi=g((py,Fs)=>{"use strict";Fs.exports=O;var mt;O.ReadableState=Ms;var dy=b("events").EventEmitter,Ls=function(e,r){return e.listeners(r).length},Dt=li(),xr=b("buffer").Buffer,$f=global.Uint8Array||function(){};function Gf(t){return xr.from(t)}function Qf(t){return xr.isBuffer(t)||t instanceof $f}var Pi=b("util"),T;Pi&&Pi.debuglog?T=Pi.debuglog("stream"):T=function(){};var Yf=es(),Li=ci(),Xf=hi(),Jf=Xf.getHighWaterMark,Tr=Be().codes,Zf=Tr.ERR_INVALID_ARG_TYPE,ec=Tr.ERR_STREAM_PUSH_AFTER_EOF,tc=Tr.ERR_METHOD_NOT_IMPLEMENTED,rc=Tr.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,vt,Oi,Ii;Se()(O,Dt);var Nt=Li.errorOrDestroy,Ri=["error","close","destroy","pause","resume"];function ic(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 Ms(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=Jf(this,t,"readableHighWaterMark",r),this.buffer=new Yf,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=Ti().StringDecoder),this.decoder=new vt(t.encoding),this.encoding=t.encoding)}function O(t){if(mt=mt||Je(),!(this instanceof O))return new O(t);var e=this instanceof mt;this._readableState=new Ms(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(O.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});O.prototype.destroy=Li.destroy;O.prototype._undestroy=Li.undestroy;O.prototype._destroy=function(t,e){e(t)};O.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),qs(this,t,e,!1,i)};O.prototype.unshift=function(t){return qs(this,t,null,!0,!1)};function qs(t,e,r,i,n){T("readableAddChunk",e);var s=t._readableState;if(e===null)s.reading=!1,oc(t,s);else{var o;if(n||(o=nc(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=Gf(e)),i)s.endEmitted?Nt(t,new rc):Ai(t,s,e,!0);else if(s.ended)Nt(t,new ec);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||e.length!==0?Ai(t,s,e,!1):ki(t,s)):Ai(t,s,e,!1)}else i||(s.reading=!1,ki(t,s))}return!s.ended&&(s.length<s.highWaterMark||s.length===0)}function Ai(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)),ki(t,e)}function nc(t,e){var r;return!Qf(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new Zf("chunk",["string","Buffer","Uint8Array"],e)),r}O.prototype.isPaused=function(){return this._readableState.flowing===!1};O.prototype.setEncoding=function(t){vt||(vt=Ti().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 Bs=1073741824;function sc(t){return t>=Bs?t=Bs:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function ks(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=sc(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}O.prototype.read=function(t){T("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 T("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Bi(this):Cr(this),null;if(t=ks(t,e),t===0&&e.ended)return e.length===0&&Bi(this),null;var i=e.needReadable;T("need readable",i),(e.length===0||e.length-t<e.highWaterMark)&&(i=!0,T("length less than watermark",i)),e.ended||e.reading?(i=!1,T("reading or ended",i)):i&&(T("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=ks(r,e)));var n;return t>0?n=Us(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&&Bi(this)),n!==null&&this.emit("data",n),n};function oc(t,e){if(T("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,Ns(t)))}}function Cr(t){var e=t._readableState;T("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(T("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(Ns,t))}function Ns(t){var e=t._readableState;T("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,Mi(t)}function ki(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(ac,t,e))}function ac(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(T("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}O.prototype._read=function(t){Nt(this,new tc("_read()"))};O.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,T("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,w){T("onunpipe"),v===r&&w&&w.hasUnpiped===!1&&(w.hasUnpiped=!0,f())}function a(){T("onend"),t.end()}var u=lc(r);t.on("drain",u);var l=!1;function f(){T("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){T("ondata");var w=t.write(v);T("dest.write",w),w===!1&&((i.pipesCount===1&&i.pipes===t||i.pipesCount>1&&js(i.pipes,t)!==-1)&&!l&&(T("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function c(v){T("onerror",v),y(),t.removeListener("error",c),Ls(t,"error")===0&&Nt(t,v)}ic(t,"error",c);function d(){t.removeListener("finish",m),y()}t.once("close",d);function m(){T("onfinish"),t.removeListener("close",d),y()}t.once("finish",m);function y(){T("unpipe"),r.unpipe(t)}return t.emit("pipe",r),i.flowing||(T("pipe resume"),r.resume()),t};function lc(t){return function(){var r=t._readableState;T("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Ls(t,"data")&&(r.flowing=!0,Mi(t))}}O.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=js(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)};O.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,T("on readable",i.length,i.reading),i.length?Cr(this):i.reading||process.nextTick(uc,this)),r};O.prototype.addListener=O.prototype.on;O.prototype.removeListener=function(t,e){var r=Dt.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(Ds,this),r};O.prototype.removeAllListeners=function(t){var e=Dt.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(Ds,this),e};function Ds(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 uc(t){T("readable nexttick read 0"),t.read(0)}O.prototype.resume=function(){var t=this._readableState;return t.flowing||(T("resume"),t.flowing=!t.readableListening,fc(this,t)),t.paused=!1,this};function fc(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(cc,t,e))}function cc(t,e){T("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Mi(t),e.flowing&&!e.reading&&t.read(0)}O.prototype.pause=function(){return T("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(T("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Mi(t){var e=t._readableState;for(T("flow",e.flowing);e.flowing&&t.read()!==null;);}O.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;t.on("end",function(){if(T("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(T("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<Ri.length;s++)t.on(Ri[s],this.emit.bind(this,Ri[s]));return this._read=function(o){T("wrapped _read",o),i&&(i=!1,t.resume())},this};typeof Symbol=="function"&&(O.prototype[Symbol.asyncIterator]=function(){return Oi===void 0&&(Oi=Ps()),Oi(this)});Object.defineProperty(O.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(O.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(O.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}});O._fromList=Us;Object.defineProperty(O.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function Us(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 Bi(t){var e=t._readableState;T("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(hc,e,t))}function hc(t,e){if(T("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"&&(O.from=function(t,e){return Ii===void 0&&(Ii=As()),Ii(O,t,e)});function js(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}});var qi=g((gy,Vs)=>{"use strict";Vs.exports=Ee;var Pr=Be().codes,dc=Pr.ERR_METHOD_NOT_IMPLEMENTED,pc=Pr.ERR_MULTIPLE_CALLBACK,gc=Pr.ERR_TRANSFORM_ALREADY_TRANSFORMING,yc=Pr.ERR_TRANSFORM_WITH_LENGTH_0,Or=Je();Se()(Ee,Or);function _c(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new pc);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 Ee(t){if(!(this instanceof Ee))return new Ee(t);Or.call(this,t),this._transformState={afterTransform:_c.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",mc)}function mc(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){Ws(t,e,r)}):Ws(this,null,null)}Ee.prototype.push=function(t,e){return this._transformState.needTransform=!1,Or.prototype.push.call(this,t,e)};Ee.prototype._transform=function(t,e,r){r(new dc("_transform()"))};Ee.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)}};Ee.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};Ee.prototype._destroy=function(t,e){Or.prototype._destroy.call(this,t,function(r){e(r)})};function Ws(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new yc;if(t._transformState.transforming)throw new gc;return t.push(null)}});var zs=g((yy,Ks)=>{"use strict";Ks.exports=Ut;var Hs=qi();Se()(Ut,Hs);function Ut(t){if(!(this instanceof Ut))return new Ut(t);Hs.call(this,t)}Ut.prototype._transform=function(t,e,r){r(null,t)}});var Xs=g((_y,Ys)=>{"use strict";var Ni;function vc(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var Qs=Be().codes,bc=Qs.ERR_MISSING_ARGS,wc=Qs.ERR_STREAM_DESTROYED;function $s(t){if(t)throw t}function Sc(t){return t.setHeader&&typeof t.abort=="function"}function Ec(t,e,r,i){i=vc(i);var n=!1;t.on("close",function(){n=!0}),Ni===void 0&&(Ni=wr()),Ni(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,Sc(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();i(o||new wc("pipe"))}}}function Gs(t){t()}function xc(t,e){return t.pipe(e)}function Tc(t){return!t.length||typeof t[t.length-1]!="function"?$s:t.pop()}function Cc(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i=Tc(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new bc("streams");var n,s=e.map(function(o,a){var u=a<e.length-1,l=a>0;return Ec(o,u,l,function(f){n||(n=f),f&&s.forEach(Gs),!u&&(s.forEach(Gs),i(n))})});return e.reduce(xc)}Ys.exports=Cc});var Ne=g((oe,Ft)=>{"use strict";var jt=b("stream");process.env.READABLE_STREAM==="disable"&&jt?(Ft.exports=jt.Readable,Object.assign(Ft.exports,jt),Ft.exports.Stream=jt):(oe=Ft.exports=wi(),oe.Stream=jt||oe,oe.Readable=oe,oe.Writable=mi(),oe.Duplex=Je(),oe.Transform=qi(),oe.PassThrough=zs(),oe.finished=wr(),oe.pipeline=Xs())});var Ir=g((my,Js)=>{"use strict";var Pc=dr(),Oc=Ne().Readable,Ic={objectMode:!0},Rc={clean:!0};function De(t){if(!(this instanceof De))return new De(t);this.options=t||{},this.options=Pc(Rc,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 Oc(Ic),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()};Js.exports=De});var eo=g((vy,Zs)=>{"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={}};Zs.exports=bt});var ro=g((by,to)=>{"use strict";to.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var no=g((wy,io)=>{"use strict";io.exports=I;I.Node=it;I.create=I;function I(t){var e=this;if(e instanceof I||(e=new I),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}I.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};I.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++}};I.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++}};I.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)Bc(this,arguments[t]);return this.length};I.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)kc(this,arguments[t]);return this.length};I.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}};I.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}};I.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};I.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};I.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};I.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};I.prototype.map=function(t,e){e=e||this;for(var r=new I,i=this.head;i!==null;)r.push(t.call(e,i.value,this)),i=i.next;return r};I.prototype.mapReverse=function(t,e){e=e||this;for(var r=new I,i=this.tail;i!==null;)r.push(t.call(e,i.value,this)),i=i.prev;return r};I.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};I.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};I.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};I.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};I.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 I;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};I.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 I;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};I.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=Ac(this,n,r[i]);return s};I.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 Ac(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 Bc(t,e){t.tail=new it(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function kc(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{ro()(I)}catch{}});var uo=g((Sy,lo)=>{"use strict";var Lc=no(),nt=Symbol("max"),Te=Symbol("length"),wt=Symbol("lengthCalculator"),Vt=Symbol("allowStale"),st=Symbol("maxAge"),xe=Symbol("dispose"),so=Symbol("noDisposeOnSet"),V=Symbol("lruList"),fe=Symbol("cache"),ao=Symbol("updateAgeOnGet"),Di=()=>1,ji=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||Di;if(this[wt]=typeof i!="function"?Di: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[xe]=e.dispose,this[so]=e.noDisposeOnSet||!1,this[ao]=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=Di),e!==this[wt]&&(this[wt]=e,this[Te]=0,this[V].forEach(r=>{r.length=this[wt](r.value,r.key),this[Te]+=r.length})),Wt(this)}get lengthCalculator(){return this[wt]}get length(){return this[Te]}get itemCount(){return this[V].length}rforEach(e,r){r=r||this;for(let i=this[V].tail;i!==null;){let n=i.prev;oo(this,e,i,r),i=n}}forEach(e,r){r=r||this;for(let i=this[V].head;i!==null;){let n=i.next;oo(this,e,i,r),i=n}}keys(){return this[V].toArray().map(e=>e.key)}values(){return this[V].toArray().map(e=>e.value)}reset(){this[xe]&&this[V]&&this[V].length&&this[V].forEach(e=>this[xe](e.key,e.value)),this[fe]=new Map,this[V]=new Lc,this[Te]=0}dump(){return this[V].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[V]}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[fe].has(e)){if(s>this[nt])return St(this,this[fe].get(e)),!1;let u=this[fe].get(e).value;return this[xe]&&(this[so]||this[xe](e,u.value)),u.now=n,u.maxAge=i,u.value=r,this[Te]+=s-u.length,u.length=s,this.get(e),Wt(this),!0}let o=new Fi(e,r,s,n,i);return o.length>this[nt]?(this[xe]&&this[xe](e,r),!1):(this[Te]+=o.length,this[V].unshift(o),this[fe].set(e,this[V].head),Wt(this),!0)}has(e){if(!this[fe].has(e))return!1;let r=this[fe].get(e).value;return!Rr(this,r)}get(e){return Ui(this,e,!0)}peek(e){return Ui(this,e,!1)}pop(){let e=this[V].tail;return e?(St(this,e),e.value):null}del(e){St(this,this[fe].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[fe].forEach((e,r)=>Ui(this,r,!1))}},Ui=(t,e,r)=>{let i=t[fe].get(e);if(i){let n=i.value;if(Rr(t,n)){if(St(t,i),!t[Vt])return}else r&&(t[ao]&&(i.value.now=Date.now()),t[V].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[Te]>t[nt])for(let e=t[V].tail;t[Te]>t[nt]&&e!==null;){let r=e.prev;St(t,e),e=r}},St=(t,e)=>{if(e){let r=e.value;t[xe]&&t[xe](r.key,r.value),t[Te]-=r.length,t[fe].delete(r.key),t[V].removeNode(e)}},Fi=class{constructor(e,r,i,n,s){this.key=e,this.value=r,this.length=i,this.now=n,this.maxAge=s||0}},oo=(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)};lo.exports=ji});var Mc,B,Ce,Et,X=j(()=>{"use strict";Mc=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)}}(),B=function(){function t(e){e===void 0&&(e=t.NORMAL),this.iteratorType=e}return t.NORMAL=!1,t.REVERSE=!0,t}(),Ce=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){Mc(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ce)});var qc,Nc,fo,co=j(()=>{"use strict";X();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)}}(),Nc=function(t){qc(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}(Ce),fo=Nc});var Dc,Uc,Ue,Ht=j(()=>{"use strict";X();Dc=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)}}(),Uc=function(t){Dc(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Et),Ue=Uc});function k(t,e,r){if(t<e||t>r)throw new RangeError}var je=j(()=>{"use strict"});var jc,Ar,Wi=j(()=>{"use strict";je();X();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)}}(),Ar=function(t){jc(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===B.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 k(this.node,0,this.size()-1),this.getElementByPos(this.node)},set:function(r){k(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}(B)});var ho,Fc,Wc,Vc,ot,Hc,Br,Vi=j(()=>{"use strict";Ht();je();X();Wi();ho=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,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}}},Wc=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},Vc=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){ho(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),Hc=function(t){ho(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]=Vc([],Wc(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,B.REVERSE)},e.prototype.rEnd=function(){return new ot(-1,this.size,this.getElementByPos,this.setElementByPos,B.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){k(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){k(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),k(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(k(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 Fc(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=Hc});var Kc,zc,po,go=j(()=>{"use strict";Vi();X();Kc=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)}}(),zc=function(t){Kc(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}(Ce),po=zc});var $c,kr,Gc,Qc,yo,_o=j(()=>{"use strict";X();$c=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},Gc=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))},Qc=function(t){$c(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?Gc([],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}(Ce),yo=Qc});var bo,Yc,mo,vo,Xc,at,Jc,q,Lr=j(()=>{"use strict";Ht();je();X();Wi();bo=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,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}}},mo=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},vo=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))},Xc=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){bo(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),Jc=function(t){bo(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?vo([],mo(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,B.REVERSE)},e.prototype.rEnd=function(){return new at(-1,this.size,this.getElementByPos,this.setElementByPos,B.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 k(r,0,this.length-1),this.vector[r]},e.prototype.eraseElementByPos=function(r){k(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){k(r,0,this.length-1),this.vector[r]=i},e.prototype.insert=function(r,i,n){var s;n===void 0&&(n=1),k(r,0,this.length),(s=this.vector).splice.apply(s,vo([r,0],mo(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 Yc(this,function(r){switch(r.label){case 0:return[5,Xc(this.vector)];case 1:return[2,r.sent()]}})}.bind(this)()},e}(Ue),q=Jc});var wo,Zc,Kt,lt,eh,So,Eo=j(()=>{"use strict";Ht();je();X();wo=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)}}(),Zc=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){wo(e,t);function e(r,i,n){var s=t.call(this,n)||this;return s.node=r,s.header=i,s.iteratorType===B.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}(B),eh=function(t){wo(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,B.REVERSE)},e.prototype.rEnd=function(){return new lt(this.header,this.header,B.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){k(r,0,this.length-1);for(var i=this.head;r--;)i=i.next;return i.value},e.prototype.eraseElementByPos=function(r){if(k(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){k(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),k(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 Zc(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),So=eh});var th,S,xo=j(()=>{"use strict";th=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}(),S=th});var rh,To,ih,xt,Mr=j(()=>{"use strict";xo();X();je();rh=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)}}(),To=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},ih=function(t){rh(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 S,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===S.RED){r.color=S.BLACK;return}if(r===i.left){var n=i.right;if(n.color===S.RED)n.color=S.BLACK,i.color=S.RED,i===this.root?this.root=i.rotateLeft():i.rotateLeft();else if(n.color===S.BLACK)if(n.right&&n.right.color===S.RED){n.color=i.color,i.color=S.BLACK,n.right.color=S.BLACK,i===this.root?this.root=i.rotateLeft():i.rotateLeft();return}else n.left&&n.left.color===S.RED?(n.color=S.RED,n.left.color=S.BLACK,n.rotateRight()):(n.color=S.RED,r=i)}else{var n=i.left;if(n.color===S.RED)n.color=S.BLACK,i.color=S.RED,i===this.root?this.root=i.rotateRight():i.rotateRight();else if(n.left&&n.left.color===S.RED){n.color=i.color,i.color=S.BLACK,n.left.color=S.BLACK,i===this.root?this.root=i.rotateRight():i.rotateRight();return}else n.right&&n.right.color===S.RED?(n.color=S.RED,n.right.color=S.BLACK,n.rotateLeft()):(n.color=S.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=To([s.key,r.key],2),r.key=i[0],s.key=i[1],n=To([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=S.BLACK},e.prototype.insertNodeSelfBalance=function(r){for(;;){var i=r.parent;if(i.color===S.BLACK)return;var n=i.parent;if(i===n.left){var s=n.right;if(s&&s.color===S.RED){if(s.color=i.color=S.BLACK,n===this.root)return;n.color=S.RED,r=n;continue}else if(r===i.right){if(r.color=S.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=S.BLACK,n===this.root?this.root=n.rotateRight():n.rotateRight();n.color=S.RED}else{var s=n.left;if(s&&s.color===S.RED){if(s.color=i.color=S.BLACK,n===this.root)return;n.color=S.RED,r=n;continue}else if(r===i.left){if(r.color=S.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=S.BLACK,n===this.root?this.root=n.rotateLeft():n.rotateLeft();n.color=S.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 S(r,i),this.root.color=S.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 S(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 S(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 S(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 S(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 S(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;k(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=ih});var nh,sh,qr,Hi=j(()=>{"use strict";X();nh=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)}}(),sh=function(t){nh(e,t);function e(r,i,n){var s=t.call(this,n)||this;return s.node=r,s.header=i,s.iteratorType===B.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}(B),qr=sh});var Co,oh,Nr,ce,ah,Pe,Ki=j(()=>{"use strict";Mr();X();je();Hi();Co=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)}}(),oh=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.")},ce=function(t){Co(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),ah=function(t){Co(e,t);function e(r,i){r===void 0&&(r=[]);var n=t.call(this,i)||this;return n.iterationFunc=function(s){return oh(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 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,B.REVERSE)},e.prototype.rEnd=function(){return new ce(this.header,this.header,B.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;k(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 ce(i,this.header):this.end()},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.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),Pe=ah});var Oo,lh,Po,Dr,he,uh,de,zi=j(()=>{"use strict";X();je();Mr();Hi();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)}}(),lh=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}}},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},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.")},he=function(t){Oo(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),uh=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 lh(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=Po(s,2),a=o[0],u=o[1];return n.setElement(a,u)}),n}return e.prototype.begin=function(){return new he(this.header.left||this.header,this.header)},e.prototype.end=function(){return new he(this.header,this.header)},e.prototype.rBegin=function(){return new he(this.header.right||this.header,this.header,B.REVERSE)},e.prototype.rEnd=function(){return new he(this.header,this.header,B.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 he(i,this.header)},e.prototype.upperBound=function(r){var i=this._upperBound(this.root,r);return new he(i,this.header)},e.prototype.reverseLowerBound=function(r){var i=this._reverseLowerBound(this.root,r);return new he(i,this.header)},e.prototype.reverseUpperBound=function(r){var i=this._reverseUpperBound(this.root,r);return new he(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 he(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;k(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=Po(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),de=uh});var fh,ch,N,Ur=j(()=>{"use strict";X();fh=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)}}(),ch=function(t){fh(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}(Ce),N=ch});var hh,dh,ph,gh,Io,Ro=j(()=>{"use strict";Ur();Lr();Ki();hh=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)}}(),dh=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}}},ph=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.")},gh=function(t){hh(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>=N.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 q([m],!1),"continue"}var y=[],v=[];c.forEach(function(w){var P=r.hashFunc(w);(P&n)===0?y.push(w):v.push(w)}),c instanceof Pe?(y.length>N.untreeifyThreshold?i[h]=new Pe(y):y.length&&(i[h]=new q(y,!1)),v.length>N.untreeifyThreshold?i[h+n]=new Pe(v):v.length&&(i[h+n]=new q(v,!1))):(y.length>=N.treeifyThreshold?i[h]=new Pe(y):y.length&&(i[h]=new q(y,!1)),v.length>=N.treeifyThreshold?i[h+n]=new Pe(v):v.length&&(i[h+n]=new q(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 q([r],!1),this.length+=1;else{var s=n.size();if(n instanceof q){if(!n.find(r).equals(n.end()))return;if(n.pushBack(r),s+1>=N.treeifyThreshold){if(this.bucketNum<=N.minTreeifySize){this.length+=1,this.reAllocate();return}this.hashTable[i]=new Pe(n)}this.length+=1}else{n.insert(r);var o=n.size();this.length+=o-s}}this.length>this.bucketNum*N.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 q){n.eraseElementByValue(r);var o=n.size();this.length+=o-s}else{n.eraseElementByKey(r);var o=n.size();this.length+=o-s,o<=N.untreeifyThreshold&&(this.hashTable[i]=new q(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 dh(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,ph(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}(N),Io=gh});var yh,_h,zt,mh,Ao,Bo=j(()=>{"use strict";Ur();Lr();zi();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}}},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.")},mh=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.setElement(o[0],o[1])}),s}return e.prototype.reAllocate=function(){var r=this;if(!(this.bucketNum>=N.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 q([m],!1),"continue"}var y=[],v=[];c.forEach(function(w){var P=r.hashFunc(w[0]);(P&n)===0?y.push(w):v.push(w)}),c instanceof de?(y.length>N.untreeifyThreshold?i[h]=new de(y):y.length&&(i[h]=new q(y,!1)),v.length>N.untreeifyThreshold?i[h+n]=new de(v):v.length&&(i[h+n]=new q(v,!1))):(y.length>=N.treeifyThreshold?i[h]=new de(y):y.length&&(i[h]=new q(y,!1)),v.length>=N.treeifyThreshold?i[h+n]=new de(v):v.length&&(i[h+n]=new q(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 q([[r,i]],!1);else{var u=a.size();if(a instanceof q){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 de(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 de)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 q){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<=N.untreeifyThreshold&&(this.hashTable[s]=new q(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 de)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 _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,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}(N),Ao=mh});var ko={};bu(ko,{Container:()=>Et,ContainerIterator:()=>B,Deque:()=>Br,DequeIterator:()=>ot,HashContainer:()=>N,HashMap:()=>Ao,HashSet:()=>Io,LinkList:()=>So,LinkListIterator:()=>lt,OrderedMap:()=>de,OrderedMapIterator:()=>he,OrderedSet:()=>Pe,OrderedSetIterator:()=>ce,PriorityQueue:()=>yo,Queue:()=>po,SequentialContainer:()=>Ue,Stack:()=>fo,TreeContainer:()=>xt,Vector:()=>q,VectorIterator:()=>at});var Lo=j(()=>{"use strict";co();go();_o();Lr();Eo();Vi();Ki();zi();Ro();Bo();X();Ht();Mr();Ur()});var qo=g((D_,Mo)=>{"use strict";var Tt=1e3,Ct=Tt*60,Pt=Ct*60,ut=Pt*24,vh=ut*7,bh=ut*365.25;Mo.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return wh(t);if(r==="number"&&isFinite(t))return e.long?Eh(t):Sh(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function wh(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*bh;case"weeks":case"week":case"w":return r*vh;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 Sh(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 Eh(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 $i=g((U_,No)=>{"use strict";function xh(t){r.debug=r,r.default=r,r.coerce=u,r.disable=o,r.enable=n,r.enabled=a,r.humanize=qo(),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 w=y,P=Number(new Date),U=P-(h||P);w.diff=U,w.prev=h,w.curr=P,h=P,v[0]=r.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let z=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(Xe,Bt)=>{if(Xe==="%%")return"%";z++;let cr=r.formatters[Bt];if(typeof cr=="function"){let pu=v[z];Xe=cr.call(w,pu),v.splice(z,1),z--}return Xe}),r.formatArgs.call(w,v),(w.log||r.log).apply(w,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(" ",",").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}No.exports=xh});var Do=g((re,Fr)=>{"use strict";re.formatArgs=Ch;re.save=Ph;re.load=Oh;re.useColors=Th;re.storage=Ih();re.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`."))}})();re.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 Th(){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 Ch(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)}re.log=console.debug||console.log||(()=>{});function Ph(t){try{t?re.storage.setItem("debug",t):re.storage.removeItem("debug")}catch{}}function Oh(){let t;try{t=re.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Ih(){try{return localStorage}catch{}}Fr.exports=$i()(re);var{formatters:Rh}=Fr.exports;Rh.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var jo=g((j_,Uo)=>{"use strict";Uo.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 Vo=g((F_,Wo)=>{"use strict";var Ah=b("os"),Fo=b("tty"),ae=jo(),{env:H}=process,Fe;ae("no-color")||ae("no-colors")||ae("color=false")||ae("color=never")?Fe=0:(ae("color")||ae("colors")||ae("color=true")||ae("color=always"))&&(Fe=1);"FORCE_COLOR"in H&&(H.FORCE_COLOR==="true"?Fe=1:H.FORCE_COLOR==="false"?Fe=0:Fe=H.FORCE_COLOR.length===0?1:Math.min(parseInt(H.FORCE_COLOR,10),3));function Gi(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Qi(t,e){if(Fe===0)return 0;if(ae("color=16m")||ae("color=full")||ae("color=truecolor"))return 3;if(ae("color=256"))return 2;if(t&&!e&&Fe===void 0)return 0;let r=Fe||0;if(H.TERM==="dumb")return r;if(process.platform==="win32"){let i=Ah.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in H)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(i=>i in H)||H.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in H)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(H.TEAMCITY_VERSION)?1:0;if(H.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in H){let i=parseInt((H.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(H.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(H.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(H.TERM)||"COLORTERM"in H?1:r}function Bh(t){let e=Qi(t,t&&t.isTTY);return Gi(e)}Wo.exports={supportsColor:Bh,stdout:Gi(Qi(!0,Fo.isatty(1))),stderr:Gi(Qi(!0,Fo.isatty(2)))}});var Ko=g((K,Vr)=>{"use strict";var kh=b("tty"),Wr=b("util");K.init=jh;K.log=Nh;K.formatArgs=Mh;K.save=Dh;K.load=Uh;K.useColors=Lh;K.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`.");K.colors=[6,2,3,4,5,1];try{let t=Vo();t&&(t.stderr||t).level>=2&&(K.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{}K.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 Lh(){return"colors"in K.inspectOpts?!!K.inspectOpts.colors:kh.isatty(process.stderr.fd)}function Mh(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
2
|
`).join(`
|
|
3
|
-
`+s),t.push(n+"m+"+Vr.exports.humanize(this.diff)+"\x1B[0m")}else t[0]=
|
|
4
|
-
`)}function
|
|
5
|
-
`).map(e=>e.trim()).join(" ")};Ho.O=function(t){return this.inspectOpts.colors=this.useColors,Wr.inspect(t,this.inspectOpts)}});var me=g((G_,Yi)=>{"use strict";typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Yi.exports=Do():Yi.exports=Ko()});var $o=g((Q_,zo)=>{"use strict";var zh=(Lo(),Su(ko)).OrderedSet,ve=me()("number-allocator:trace"),$h=me()("number-allocator:error");function J(t,e){this.low=t,this.high=e}J.prototype.equals=function(t){return this.low===t.low&&this.high===t.high};J.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 be(t,e){if(!(this instanceof be))return new be(t,e);this.min=t,this.max=e,this.ss=new zh([],(r,i)=>r.compare(i)),ve("Create"),this.clear()}be.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low};be.prototype.alloc=function(){if(this.ss.size()===0)return ve("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 J(e+1,r)):this.ss.eraseElementByPos(0),ve("alloc():"+i),i};be.prototype.use=function(t){let e=new J(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),ve("use():"+t),!0):i>t?!1:i===t?(this.ss.updateKeyByIterator(r,new J(i+1,n)),ve("use():"+t),!0):n===t?(this.ss.updateKeyByIterator(r,new J(i,n-1)),ve("use():"+t),!0):(this.ss.updateKeyByIterator(r,new J(t+1,n)),this.ss.insert(new J(i,t-1)),ve("use():"+t),!0)}return ve("use():failed"),!1};be.prototype.free=function(t){if(t<this.min||t>this.max){$h("free():"+t+" is out of range");return}let e=new J(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 J(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 J(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 J(s,a))}else this.ss.updateKeyByIterator(r,new J(s,t));else t+1===i?(this.ss.eraseElementByIterator(r.next()),this.ss.insert(new J(t,n))):this.ss.insert(e)}ve("free():"+t)};be.prototype.clear=function(){ve("clear()"),this.ss.clear(),this.ss.insert(new J(this.min,this.max))};be.prototype.intervalCount=function(){return this.ss.size()};be.prototype.dump=function(){console.log("length:"+this.ss.size());for(let t of this.ss)console.log(t)};zo.exports=be});var Xi=g((Y_,Go)=>{"use strict";var Gh=$o();Go.exports.NumberAllocator=Gh});var Yo=g((X_,Qo)=>{"use strict";var Qh=uo(),Yh=Xi().NumberAllocator;function We(t){if(!(this instanceof We))return new We(t);t>0&&(this.aliasToTopic=new Qh({max:t}),this.topicToAlias={},this.numberAllocator=new Yh(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]};Qo.exports=We});var Zo=g((J_,Jo)=>{"use strict";var{Buffer:pe}=b("buffer"),Xo=Symbol.for("BufferList");function A(t){if(!(this instanceof A))return new A(t);A._init.call(this,t)}A._init=function(e){Object.defineProperty(this,Xo,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)};A.prototype._new=function(e){return new A(e)};A.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}};A.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};A.prototype.get=function(e){if(e>this.length||e<0)return;let r=this._offset(e);return this._bufs[r[0]][r[1]]};A.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)};A.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||pe.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]:pe.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=pe.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};A.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)};A.prototype.toString=function(e,r,i){return this.slice(r,i).toString(e)};A.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};A.prototype.duplicate=function(){let e=this._new();for(let r=0;r<this._bufs.length;r++)e.append(this._bufs[r]);return e};A.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(pe.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(pe.from(e));return this};A.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length};A.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=pe.from([t]):typeof t=="string"?t=pe.from(t,r):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=pe.from(t.buffer,t.byteOffset,t.byteLength):pe.isBuffer(t)||(t=pe.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};A.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?A.prototype[r]=function(i,n){return this.slice(i,i+n)[r](0,n)}:A.prototype[r]=function(i=0){return this.slice(i,i+t[r])[r](0)}})(e)})();A.prototype._isBufferList=function(e){return e instanceof A||A.isBufferList(e)};A.isBufferList=function(e){return e!=null&&e[Xo]};Jo.exports=A});var ea=g((Z_,Hr)=>{"use strict";var Ji=Ne().Duplex,Xh=Se(),$t=Zo();function Q(t){if(!(this instanceof Q))return new Q(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),Ji.call(this)}Xh(Q,Ji);Object.assign(Q.prototype,$t.prototype);Q.prototype._new=function(e){return new Q(e)};Q.prototype._write=function(e,r,i){this._appendBuffer(e),typeof i=="function"&&i()};Q.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)};Q.prototype.end=function(e){Ji.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)};Q.prototype._destroy=function(e,r){this._bufs.length=0,this.length=0,r(e)};Q.prototype._isBufferList=function(e){return e instanceof Q||e instanceof $t||Q.isBufferList(e)};Q.isBufferList=$t.isBufferList;Hr.exports=Q;Hr.exports.BufferListStream=Q;Hr.exports.BufferList=$t});var ra=g((em,ta)=>{"use strict";var Zi=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}};ta.exports=Zi});var en=g((tm,ia)=>{"use strict";var _=ia.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 oa=g((rm,sa)=>{"use strict";var Jh=ea(),Zh=b("events"),na=ra(),R=en(),E=me()("mqtt-packet:parser"),tn=class t extends Zh{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(){E("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new na,this.error=null,this._list=Jh(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),E("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++,E("parse: state complete. _stateCounter is now: %d",this._stateCounter),E("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return E("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=R.types[e>>R.CMD_SHIFT],this.packet.retain=(e&R.RETAIN_MASK)!==0,this.packet.qos=e>>R.QOS_SHIFT&R.QOS_MASK,this.packet.dup=(e&R.DUP_MASK)!==0,E("_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)),E("_parseLength %d",e.value),!!e}_parsePayload(){E("_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 E("_parsePayload complete result: %s",e),e}_parseConnect(){E("_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)&R.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&R.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&R.WILL_FLAG_MASK,s.will&&(o.will={},o.will.retain=(this._list.readUInt8(this._pos)&R.WILL_RETAIN_MASK)!==0,o.will.qos=(this._list.readUInt8(this._pos)&R.WILL_QOS_MASK)>>R.WILL_QOS_SHIFT),o.clean=(this._list.readUInt8(this._pos)&R.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,E("_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,E("_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,E("_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,E("_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,E("_parseConnect: complete"),o}_parseConnack(){E("_parseConnack");let e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&R.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)}E("_parseConnack: complete")}_parsePublish(){E("_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),E("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){E("_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&R.SUBSCRIBE_OPTIONS_QOS_MASK,a=(i>>R.SUBSCRIBE_OPTIONS_NL_SHIFT&R.SUBSCRIBE_OPTIONS_NL_MASK)!==0,o=(i>>R.SUBSCRIBE_OPTIONS_RAP_SHIFT&R.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,s=i>>R.SUBSCRIBE_OPTIONS_RH_SHIFT&R.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),E("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_parseSuback(){E("_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(){E("_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"));E("_parseUnsubscribe: push topic `%s` to unsubscriptions",r),e.unsubscriptions.push(r)}}}_parseUnsuback(){E("_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(){E("_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(),E("_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(E("_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 E("_parseDisconnect result: true"),!0}_parseAuth(){E("_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),E("_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):(E("_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,E("_parseString: result: %s",n),n}_parseStringPair(){return E("_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,E("_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,E("_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,E("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){E("_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&R.VARBYTEINT_MASK),n*=128,(a&R.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,E("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),E("_parseByte: result: %o",e),e}_parseByType(e){switch(E("_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(){E("_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=R.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(R.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(R.propertiesTypes[o])):(n[o]=[n[o]],n[o].push(this._parseByType(R.propertiesTypes[o]))):n[o]=this._parseByType(R.propertiesTypes[o])}return n}_newPacket(){return E("_newPacket"),this.packet&&(this._list.consume(this.packet.length),E("_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)),E("_newPacket: new packet"),this.packet=new na,this._pos=0,!0}_emitError(e){E("_emitError"),this.error=e,this.emit("error",e)}};sa.exports=tn});var fa=g((im,ua)=>{"use strict";var aa={},ed=Buffer.isBuffer(Buffer.from([1,2]).subarray(0,1));function la(t){let e=Buffer.allocUnsafe(2);return e.writeUInt8(t>>8,0),e.writeUInt8(t&255,1),e}function td(){for(let t=0;t<65536;t++)aa[t]=la(t)}function rd(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),ed?n.subarray(0,i):n.slice(0,i)}function id(t){let e=Buffer.allocUnsafe(4);return e.writeUInt32BE(t,0),e}ua.exports={cache:aa,generateCache:td,generateNumber:la,genBufVariableByteInt:rd,generate4ByteBuffer:id}});var ca=g((nm,rn)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?rn.exports={nextTick:nd}:rn.exports=process;function nd(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 on=g((sm,va)=>{"use strict";var x=en(),sd=Buffer.allocUnsafe(0),od=Buffer.from([0]),Gt=fa(),ad=ca().nextTick,le=me()("mqtt-packet:writeToStream"),Kr=Gt.cache,ld=Gt.generateNumber,ud=Gt.generateCache,nn=Gt.genBufVariableByteInt,fd=Gt.generate4ByteBuffer,Z=sn,zr=!0;function _a(t,e,r){switch(le("generate called"),e.cork&&(e.cork(),ad(cd,e)),zr&&(zr=!1,ud()),le("generate: packet.cmd: %s",t.cmd),t.cmd){case"connect":return hd(t,e,r);case"connack":return dd(t,e,r);case"publish":return pd(t,e,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return gd(t,e,r);case"subscribe":return yd(t,e,r);case"suback":return _d(t,e,r);case"unsubscribe":return md(t,e,r);case"unsuback":return vd(t,e,r);case"pingreq":case"pingresp":return bd(t,e,r);case"disconnect":return wd(t,e,r);case"auth":return Sd(t,e,r);default:return e.emit("error",new Error("Unknown command")),!1}}Object.defineProperty(_a,"cacheNumbers",{get(){return Z===sn},set(t){t?((!Kr||Object.keys(Kr).length===0)&&(zr=!0),Z=sn):(zr=!1,Z=Ed)}});function cd(t){t.uncork()}function hd(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(ya(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(ya(h))d+=ma(h)+2;else return e.emit("error",new Error("Invalid password")),!1}e.write(x.CONNECT_HEADER),ue(e,d),Ot(e,n),i.bridgeMode&&(s+=128),e.write(s===131?x.VERSION131:s===132?x.VERSION132:s===4?x.VERSION4:s===5?x.VERSION5:x.VERSION3);let w=0;return w|=f!=null?x.USERNAME_MASK:0,w|=h!=null?x.PASSWORD_MASK:0,w|=o&&o.retain?x.WILL_RETAIN_MASK:0,w|=o&&o.qos?o.qos<<x.WILL_QOS_SHIFT:0,w|=o?x.WILL_FLAG_MASK:0,w|=a?x.CLEAN_SESSION_MASK:0,e.write(Buffer.from([w])),Z(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 dd(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(x.CONNACK_HEADER),ue(e,a),e.write(n.sessionPresent?x.SESSIONPRESENT_HEADER:od),e.write(Buffer.from([s])),u?.write(),!0}function pd(t,e,r){le("publish: packet: %o",t);let i=r?r.protocolVersion:4,n=t||{},s=n.qos||0,o=n.retain?x.RETAIN_MASK:0,a=n.topic,u=n.payload||sd,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(x.PUBLISH_HEADER[s][n.dup?1:0][o?1:0]),ue(e,h),Z(e,ma(a)),e.write(a),s>0&&Z(e,l),c?.write(),le("publish: payload: %o",u),e.write(u)}function gd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.cmd||"puback",o=n.messageId,a=n.dup&&s==="pubrel"?x.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(x.ACKS[s][u][a][0]),ue(e,h),Z(e,o),i===5&&e.write(Buffer.from([l])),c!==null&&c.write(),!0}function yd(t,e,r){le("subscribe: packet: ");let i=r?r.protocolVersion:4,n=t||{},s=n.dup?x.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 w=a[c].rh||0;if(typeof w!="number"||w>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;le("subscribe: writing to stream: %o",x.SUBSCRIBE_HEADER),e.write(x.SUBSCRIBE_HEADER[1][s?1:0][0]),ue(e,l),Z(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,w=c.rh,P;ft(e,d),P=x.SUBSCRIBE_OPTIONS_QOS[m],i===5&&(P|=y?x.SUBSCRIBE_OPTIONS_NL:0,P|=v?x.SUBSCRIBE_OPTIONS_RAP:0,P|=w?x.SUBSCRIBE_OPTIONS_RH[w]:0),h=e.write(Buffer.from([P]))}return h}function _d(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(x.SUBACK_HEADER),ue(e,u),Z(e,s),l!==null&&l.write(),e.write(Buffer.from(o))}function md(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.dup?x.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(x.UNSUBSCRIBE_HEADER[1][o?1:0][0]),ue(e,l),Z(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 vd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.dup?x.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(x.ACKS[l][f][o][0]),ue(e,h),Z(e,s),c!==null&&c.write(),i===5&&e.write(Buffer.from(a)),!0}function bd(t,e,r){return e.write(x.EMPTY[t.cmd])}function wd(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([x.codes.disconnect<<4])),ue(e,a),i===5&&e.write(Buffer.from([s])),u!==null&&u.write(),!0}function Sd(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([x.codes.auth<<4])),ue(e,a),e.write(Buffer.from([s])),u!==null&&u.write(),!0):!1}var ha={};function ue(t,e){if(e>x.VARBYTEINT_MAX)return t.emit("error",new Error(`Invalid variable byte integer: ${e}`)),!1;let r=ha[e];return r||(r=nn(e),e<16384&&(ha[e]=r)),le("writeVarByteInt: writing to stream: %o",r),t.write(r)}function ft(t,e){let r=Buffer.byteLength(e);return Z(t,r),le("writeString: %s",e),t.write(e,"utf8")}function da(t,e,r){ft(t,e),ft(t,r)}function sn(t,e){return le("writeNumberCached: number: %d",e),le("writeNumberCached: %o",Kr[e]),t.write(Kr[e])}function Ed(t,e){let r=ld(e);return le("writeNumberGenerated: %o",r),t.write(r)}function xd(t,e){let r=fd(e);return le("write4ByteNumber: %o",r),t.write(r)}function Ot(t,e){typeof e=="string"?ft(t,e):e?(Z(t,e.length),t.write(e)):Z(t,0)}function He(t,e){if(typeof e!="object"||e.length!=null)return{length:1,write(){ga(t,{},0)}};let r=0;function i(s,o){let a=x.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(nn(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(nn(r))+r,write(){ga(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 pa(t,e,r){switch(x.propertiesTypes[e]){case"byte":{t.write(Buffer.from([x.properties[e]])),t.write(Buffer.from([+r]));break}case"int8":{t.write(Buffer.from([x.properties[e]])),t.write(Buffer.from([r]));break}case"binary":{t.write(Buffer.from([x.properties[e]])),Ot(t,r);break}case"int16":{t.write(Buffer.from([x.properties[e]])),Z(t,r);break}case"int32":{t.write(Buffer.from([x.properties[e]])),xd(t,r);break}case"var":{t.write(Buffer.from([x.properties[e]])),ue(t,r);break}case"string":{t.write(Buffer.from([x.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([x.properties[e]])),da(t,n.toString(),o.toString())}):(t.write(Buffer.from([x.properties[e]])),da(t,n.toString(),s.toString()))});break}default:return t.emit("error",new Error(`Invalid property ${e} value: ${r}`)),!1}}function ga(t,e,r){ue(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++)pa(t,i,n[s]);else pa(t,i,n)}}function ma(t){return t?t instanceof Buffer?t.length:Buffer.byteLength(t):0}function ya(t){return typeof t=="string"||t instanceof Buffer}va.exports=_a});var wa=g((om,ba)=>{"use strict";var Td=on(),Cd=b("events");function Pd(t,e){let r=new an;return Td(t,r,e),r.concat()}var an=class extends Cd{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}};ba.exports=Pd});var Sa=g($r=>{"use strict";$r.parser=oa().parser;$r.generate=wa();$r.writeToStream=on()});var ln=g((lm,Ea)=>{"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(){};Ea.exports=Ke});var Ta=g((um,xa)=>{"use strict";function Od(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 Id(){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 Od(arguments[0],arguments[1],t)}xa.exports=Id});var Pa=g((fm,Ca)=>{"use strict";Ca.exports=Rd;function It(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function Rd(t){if(t=t||{},t.circles)return Ad(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 Ad(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 Ia=g((cm,Oa)=>{"use strict";Oa.exports=Pa()()});var Aa=g((hm,Ra)=>{"use strict";function Bd(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 kd(t){if(t.length===0)return"empty_topic_list";for(let e=0;e<t.length;e++)if(!Bd(t[e]))return t[e];return null}Ra.exports={validateTopics:kd}});var cn=g((dm,Ua)=>{"use strict";var La=b("events").EventEmitter,Gr=Ir(),Ld=eo(),Md=Yo(),Ma=Sa(),qd=ln(),Nd=Ne().Writable,Dd=Se(),Ud=Ta(),qa=Ia(),Na=Aa(),Yr=dr(),p=me()("mqttjs:client"),un=process?process.nextTick:function(t){setTimeout(t,0)},fn=global.setImmediate||function(t){un(t)},Ba={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},jd=["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 Fd(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function Wd(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 Da(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=Ma.writeToStream(e,t.stream,t.options);p("sendPacket :: writeToStream result %s",i),!i&&r&&r!==$?(p("sendPacket :: handle events on `drain` once through callback."),t.stream.once("drain",r)):r&&(p("sendPacket :: invoking cb"),r())}function Vd(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 Hd(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 ka(t,e,r,i){p("storeAndSend :: store packet with cmd %s to outgoingStore",e.cmd);let n=e,s;if(n.cmd==="publish"&&(n=qa(e),s=Da(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 $(t){p("nop ::",t)}function C(t,e){let r,i=this;if(!(this instanceof C))return new C(t,e);this.options=e||{};for(r in Ba)typeof this.options[r]>"u"?this.options[r]=Ba[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:Fd(),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 qd: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 Ld(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()}),La.call(this),p("MqttClient :: setting up stream"),this._setupStream()}Dd(C,La);C.prototype._setupStream=function(){let t=this,e=new Nd,r=Ma.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)un(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),jd.includes(l.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",l)):$(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),Hd(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)};C.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}};C.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t&&t!==$?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting};C.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||$},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};C.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()||$,o=e.pop(),a=this.options.protocolVersion;delete i.resubscribe,typeof i=="string"&&(i=[i]),typeof s!="function"&&(o=s,s=$);let u=Na.validateTopics(i);if(u!==null)return fn(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};C.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()||$,n=e.pop();typeof r=="string"&&(r=[r]),typeof i!="function"&&(n=i,i=$);let s=Na.validateTopics(r);if(s!==null)return fn(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};C.prototype.end=function(t,e,r){let i=this;p("end :: (%s)",this.options.clientId),(t==null||typeof t!="boolean")&&(r=e||$,e=t,t=!1,typeof e!="object"&&(r=e,e=null,typeof r!="function"&&(r=$))),typeof e!="object"&&(r=e,e=null),p("end :: cb? %s",!!r),r=r||$;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"),un(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)};C.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};C.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};C.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())};C.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...")};C.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)};C.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&&Vd(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,fn.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())};C.prototype._sendPacket=function(t,e,r){p("_sendPacket :: (%s) :: start",this.options.clientId),r=r||$,e=e||$;let i=Wd(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":ka(this,t,e,r);return;default:Rt(this,t,e);return}switch(t.qos){case 2:case 1:ka(this,t,e,r);break;case 0:default:Rt(this,t,e);break}p("_sendPacket :: (%s) :: end",this.options.clientId)};C.prototype._storePacket=function(t,e,r){p("_storePacket :: packet: %o",t),p("_storePacket :: cb? %s",!!e),r=r||$;let i=t;if(i.cmd==="publish"){i=qa(t);let n=Da(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"))};C.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);let t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=Ud(function(){t._checkPing()},this.options.keepalive*1e3))};C.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)};C.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))};C.prototype._handlePingresp=function(){this.pingResp=!0};C.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 Md(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)}};C.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)}})};C.prototype.handleAuth=function(t,e){e()};C.prototype._handlePublish=function(t,e){p("_handlePublish: packet %o",t),e=typeof e<"u"?e:$;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}};C.prototype.handleMessage=function(t,e){e()};C.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")};C.prototype._handlePubrel=function(t,e){p("handling pubrel packet"),e=typeof e<"u"?e:$;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,$),i._sendPacket(n,e)}))})};C.prototype._handleDisconnect=function(t){this.emit("disconnect",t)};C.prototype._nextId=function(){return this.messageIdProvider.allocate()};C.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()};C.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};C.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()};C.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){let t=this._storeProcessingQueue[0];if(t&&t.invoke())return this._storeProcessingQueue.shift(),!0}return!1};C.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););};C.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)};Ua.exports=C});var hn=g((pm,ja)=>{"use strict";var Kd=b("net"),zd=me()("mqttjs:tcp");function $d(t,e){e.port=e.port||1883,e.hostname=e.hostname||e.host||"localhost";let r=e.port,i=e.hostname;return zd("port %d and host %s",r,i),Kd.createConnection(r,i)}ja.exports=$d});var Xr=g((gm,Fa)=>{"use strict";var Gd=b("tls"),Qd=b("net"),Yd=me()("mqttjs:tls");function Xd(t,e){e.port=e.port||8883,e.host=e.hostname||e.host||"localhost",Qd.isIP(e.host)===0&&(e.servername=e.host),e.rejectUnauthorized=e.rejectUnauthorized!==!1,delete e.path,Yd("port %d host %s rejectUnauthorized %b",e.port,e.host,e.rejectUnauthorized);let r=Gd.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}Fa.exports=Xd});var Ha=g((ym,Va)=>{"use strict";Va.exports=Wa;function Wa(t,e){if(t&&e)return Wa(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 $a=g((_m,dn)=>{"use strict";var Ka=Ha();dn.exports=Ka(Jr);dn.exports.strict=Ka(za);Jr.proto=Jr(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Jr(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return za(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 za(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 Ya=g((mm,Qa)=>{"use strict";var Jd=$a(),Zd=function(){},ep=function(t){return t.setHeader&&typeof t.abort=="function"},tp=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3},Ga=function(t,e,r){if(typeof e=="function")return Ga(t,null,e);e||(e={}),r=Jd(r||Zd);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 ep(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)),tp(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)}};Qa.exports=Ga});var Ja=g((vm,Xa)=>{"use strict";Xa.exports=rp;function rp(t){var e=t._readableState;return e?e.objectMode||typeof t._duplexState=="number"?t.read():t.read(ip(e)):null}function ip(t){return t.buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length}});var ei=g((bm,rl)=>{"use strict";var Zr=Ne(),Za=Ya(),np=Se(),sp=Ja(),el=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),pn=function(t,e){t._corked?t.once("uncork",e):e()},op=function(t,e){t._autoDestroy&&t.destroy(e)},tl=function(t,e){return function(r){r?op(t,r.message==="premature close"?null:r):e&&!t._ended&&t.end()}},ap=function(t,e){if(!t||t._writableState&&t._writableState.finished)return e();if(t._writableState)return t.end(e);t.end(),e()},lp=function(){},up=function(t){return new Zr.Readable({objectMode:!0,highWaterMark:16}).wrap(t)},G=function(t,e,r){if(!(this instanceof G))return new G(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)};np(G,Zr.Duplex);G.obj=function(t,e,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new G(t,e,r)};G.prototype.cork=function(){++this._corked===1&&this.emit("cork")};G.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};G.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=Za(t,{writable:!0,readable:!1},tl(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()};G.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=Za(t,{writable:!1,readable:!0},tl(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:up(t),this._readable2.on("readable",i),this._readable2.on("end",n),this._unread=s,this._forward()};G.prototype._read=function(){this._drained=!0,this._forward()};G.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var t;this._drained&&(t=sp(this._readable2))!==null;)this.destroyed||(this._drained=this.push(t));this._forwarding=!1}};G.prototype.destroy=function(t,e){if(e||(e=lp),this.destroyed)return e(null);this.destroyed=!0;var r=this;process.nextTick(function(){r._destroy(t),e(null)})};G.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")};G.prototype._write=function(t,e,r){if(!this.destroyed){if(this._corked)return pn(this,this._write.bind(this,t,e,r));if(t===el)return this._finish(r);if(!this._writable)return r();this._writable.write(t)===!1?this._ondrain=r:this.destroyed||r()}};G.prototype._finish=function(t){var e=this;this.emit("preend"),pn(this,function(){ap(e._forwardEnd&&e._writable,function(){e._writableState.prefinished===!1&&(e._writableState.prefinished=!0),e.emit("prefinish"),pn(e,t)})})};G.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(el),Zr.Writable.prototype.end.call(this,r))};rl.exports=G});var gn=g((wm,nl)=>{"use strict";var{Buffer:il}=b("buffer"),fp=Ne().Transform,cp=ei(),Oe,ti,ie;function hp(){let t=new fp;return t._write=function(e,r,i){Oe.send({data:e.buffer,success:function(){i()},fail:function(n){i(new Error(n))}})},t._flush=function(r){Oe.close({success:function(){r()}})},t}function dp(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}function pp(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 gp(){Oe.onOpen(function(){ie.setReadable(ti),ie.setWritable(ti),ie.emit("connect")}),Oe.onMessage(function(t){let e=t.data;e instanceof ArrayBuffer?e=il.from(e):e=il.from(e,"utf8"),ti.push(e)}),Oe.onClose(function(){ie.end(),ie.destroy()}),Oe.onError(function(t){ie.destroy(new Error(t.errMsg))})}function yp(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";dp(e);let i=pp(e,t);Oe=wx.connectSocket({url:i,protocols:[r]}),ti=hp(),ie=cp.obj(),ie._destroy=function(s,o){Oe.close({success:function(){o&&o(s)}})};let n=ie.destroy;return ie.destroy=function(){ie.destroy=n;let s=this;setTimeout(function(){Oe.close({fail:function(){s._destroy(new Error)}})},0)}.bind(ie),gp(),ie}nl.exports=yp});var _n=g((Sm,ol)=>{"use strict";var{Buffer:yn}=b("buffer"),_p=Ne().Transform,mp=ei(),$e,Yt,ze,sl=!1;function vp(){let t=new _p;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 bp(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}function wp(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 Sp(){sl||(sl=!0,$e.onSocketOpen(function(){ze.setReadable(Yt),ze.setWritable(Yt),ze.emit("connect")}),$e.onSocketMessage(function(t){if(typeof t.data=="string"){let e=yn.from(t.data,"base64");Yt.push(e)}else{let e=new FileReader;e.addEventListener("load",function(){let r=e.result;r instanceof ArrayBuffer?r=yn.from(r):r=yn.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 Ep(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";bp(e);let i=wp(e,t);return $e=e.my,$e.connectSocket({url:i,protocols:r}),Yt=vp(),ze=mp.obj(),Sp(),ze}ol.exports=Ep});var ct=g((Em,al)=>{"use strict";al.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((xm,mn)=>{"use strict";var{EMPTY_BUFFER:xp}=ct();function ll(t,e){if(t.length===0)return xp;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 ul(t,e,r,i,n){for(let s=0;s<n;s++)r[i+s]=t[s]^e[s&3]}function fl(t,e){let r=t.length;for(let i=0;i<r;i++)t[i]^=e[i&3]}function cl(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=b("bufferutil"),e=t.BufferUtil||t;mn.exports={concat:ll,mask(r,i,n,s,o){o<48?ul(r,i,n,s,o):e.mask(r,i,n,s,o)},toArrayBuffer:cl,toBuffer:ri,unmask(r,i){r.length<32?fl(r,i):e.unmask(r,i)}}}catch{mn.exports={concat:ll,mask:ul,toArrayBuffer:cl,toBuffer:ri,unmask:fl}}});var pl=g((Tm,dl)=>{"use strict";var hl=Symbol("kDone"),vn=Symbol("kRun"),bn=class{constructor(e){this[hl]=()=>{this.pending--,this[vn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[vn]()}[vn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[hl])}}};dl.exports=bn});var er=g((Cm,ml)=>{"use strict";var Jt=b("zlib"),gl=Xt(),Tp=pl(),{kStatusCode:yl,NOOP:Cp}=ct(),Pp=Buffer.from([0,0,255,255]),si=Symbol("permessage-deflate"),Ie=Symbol("total-length"),Zt=Symbol("callback"),Ge=Symbol("buffers"),ni=Symbol("error"),ii,wn=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 Tp(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[Ie]=0,this._inflate[Ge]=[],this._inflate.on("error",Ip),this._inflate.on("data",_l)}this._inflate[Zt]=i,this._inflate.write(e),r&&this._inflate.write(Pp),this._inflate.flush(()=>{let s=this._inflate[ni];if(s){this._inflate.close(),this._inflate=null,i(s);return}let o=gl.concat(this._inflate[Ge],this._inflate[Ie]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ie]=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[Ie]=0,this._deflate[Ge]=[],this._deflate.on("error",Cp),this._deflate.on("data",Op)}this._deflate[Zt]=i,this._deflate.write(e),this._deflate.flush(Jt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=gl.concat(this._deflate[Ge],this._deflate[Ie]);r&&(s=s.slice(0,s.length-4)),this._deflate[Zt]=null,this._deflate[Ie]=0,this._deflate[Ge]=[],r&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),i(null,s)})}};ml.exports=wn;function Op(t){this[Ge].push(t),this[Ie]+=t.length}function _l(t){if(this[Ie]+=t.length,this[si]._maxPayload<1||this[Ie]<=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][yl]=1009,this.removeListener("data",_l),this.reset()}function Ip(t){this[si]._inflate=null,t[yl]=1007,this[Zt](t)}});var En=g((Pm,Sn)=>{"use strict";function vl(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function bl(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=b("utf-8-validate");typeof t=="object"&&(t=t.Validation.isValidUTF8),Sn.exports={isValidStatusCode:vl,isValidUTF8(e){return e.length<150?bl(e):t(e)}}}catch{Sn.exports={isValidStatusCode:vl,isValidUTF8:bl}}});var Pn=g((Om,Cl)=>{"use strict";var{Writable:Rp}=b("stream"),wl=er(),{BINARY_TYPES:Ap,EMPTY_BUFFER:Bp,kStatusCode:kp,kWebSocket:Lp}=ct(),{concat:xn,toArrayBuffer:Mp,unmask:qp}=Xt(),{isValidStatusCode:Np,isValidUTF8:Sl}=En(),tr=0,El=1,xl=2,Tl=3,Tn=4,Dp=5,Cn=class extends Rp{constructor(e,r,i,n){super(),this._binaryType=e||Ap[0],this[Lp]=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 El:r=this.getPayloadLength16();break;case xl:r=this.getPayloadLength64();break;case Tl:this.getMask();break;case Tn: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,F(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[wl.extensionName])return this._loop=!1,F(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,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,F(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,F(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,F(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(r)return this._loop=!1,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,F(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,F(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,F(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,F(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=El;else if(this._payloadLength===127)this._state=xl;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,F(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,F(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Tl:this._state=Tn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Tn}getData(e){let r=Bp;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&qp(r,this._mask)}if(this._opcode>7)return this.controlMessage(r);if(this._compressed){this._state=Dp,this.decompress(r,e);return}return r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage()}decompress(e,r){this._extensions[wl.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(F(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=xn(r,e):this._binaryType==="arraybuffer"?i=Mp(xn(r,e)):i=r,this.emit("message",i)}else{let i=xn(r,e);if(!Sl(i))return this._loop=!1,F(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 F(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let r=e.readUInt16BE(0);if(!Np(r))return F(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let i=e.slice(2);if(!Sl(i))return F(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}};Cl.exports=Cn;function F(t,e,r,i,n){let s=new t(r?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,F),s.code=n,s[kp]=i,s}});var In=g((Am,Il)=>{"use strict";var Im=b("net"),Rm=b("tls"),{randomFillSync:Up}=b("crypto"),Pl=er(),{EMPTY_BUFFER:jp}=ct(),{isValidStatusCode:Fp}=En(),{mask:Ol,toBuffer:Re}=Xt(),ht=Buffer.alloc(4),On=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?(Up(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?(Ol(e,ht,o,n,e.length),[o]):(Ol(e,ht,e,0,e.length),[o,e])):[o,e]}close(e,r,i,n){let s;if(e===void 0)s=jp;else{if(typeof e!="number"||!Fp(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=Re(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,Re.readOnly,i]):this.doPing(n,r,Re.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=Re(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,Re.readOnly,i]):this.doPong(n,r,Re.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=Re(e),s=this._extensions[Pl.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:Re.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:Re.readOnly}),i)}dispatch(e,r,i,n){if(!r){this.sendFrame(t.frame(e,i),n);return}let s=this._extensions[Pl.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)}};Il.exports=On});var Al=g((Bm,Rl)=>{"use strict";var At=class{constructor(e,r){this.target=r,this.type=e}},Rn=class extends At{constructor(e,r){super("message",r),this.data=e}},An=class extends At{constructor(e,r,i){super("close",i),this.wasClean=i._closeFrameReceived&&i._closeFrameSent,this.reason=r,this.code=e}},Bn=class extends At{constructor(e){super("open",e)}},kn=class extends At{constructor(e,r){super("error",r),this.message=e.message,this.error=e}},Wp={addEventListener(t,e,r){if(typeof e!="function")return;function i(u){e.call(this,new Rn(u,this))}function n(u,l){e.call(this,new An(u,l,this))}function s(u){e.call(this,new kn(u,this))}function o(){e.call(this,new Bn(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])}};Rl.exports=Wp});var Ln=g((km,Bl)=>{"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 we(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Vp(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?(we(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),we(r,t.slice(u,l),!0),c===44&&(we(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),we(r,a,d),c===44&&(we(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?we(e,h,r):(a===void 0?we(r,h,!0):i?we(r,a,h.replace(/\\/g,"")):we(r,a,h),we(e,o,r)),e}function Hp(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(", ")}Bl.exports={format:Hp,parse:Vp}});var jn=g((Mm,Wl)=>{"use strict";var Kp=b("events"),zp=b("https"),$p=b("http"),Ml=b("net"),Gp=b("tls"),{randomBytes:Qp,createHash:Yp}=b("crypto"),{Readable:Lm}=b("stream"),{URL:Mn}=b("url"),Qe=er(),Xp=Pn(),Jp=In(),{BINARY_TYPES:kl,EMPTY_BUFFER:qn,GUID:Zp,kStatusCode:eg,kWebSocket:Y,NOOP:ql}=ct(),{addEventListener:tg,removeEventListener:rg}=Al(),{format:ig,parse:ng}=Ln(),{toBuffer:sg}=Xt(),Ae=["CONNECTING","OPEN","CLOSING","CLOSED"],Nn=[8,13],og=30*1e3,D=class t extends Kp{constructor(e,r,i){super(),this._binaryType=kl[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),Nl(this,e,r,i)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){kl.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 Xp(this.binaryType,this._extensions,this._isServer,i);this._sender=new Jp(e,this._extensions),this._receiver=n,this._socket=e,n[Y]=this,e[Y]=this,n.on("conclude",ug),n.on("drain",fg),n.on("error",cg),n.on("message",hg),n.on("ping",dg),n.on("pong",pg),e.setTimeout(0),e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Ul),e.on("data",oi),e.on("end",jl),e.on("error",Fl),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 ne(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),og)}}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){Un(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||qn,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){Un(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||qn,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){Un(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||qn,n,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING)return ne(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:Ae.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:Ae.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:Ae.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:Ae.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:Ae.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:Ae.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:Ae.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:Ae.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(t=>{Object.defineProperty(D.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(D.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)}})});D.prototype.addEventListener=tg;D.prototype.removeEventListener=rg;Wl.exports=D;function Nl(t,e,r,i){let n={protocolVersion:Nn[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(!Nn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Nn.join(", ")})`);let s;e instanceof Mn?(s=e,t._url=e.href):(s=new Mn(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;Dn(t,d);return}let a=s.protocol==="wss:"||s.protocol==="https:",u=a?443:80,l=Qp(16).toString("base64"),f=a?zp.get:$p.get,h;if(n.createConnection=a?lg:ag,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"]=ig({[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",()=>{ne(t,c,"Opening handshake has timed out")}),c.on("error",d=>{c===null||c.aborted||(c=t._req=null,Dn(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){ne(t,c,"Maximum redirects exceeded");return}c.abort();let v;try{v=new Mn(m,e)}catch(w){Dn(t,w);return}Nl(t,v,r,i)}else t.emit("unexpected-response",c,d)||ne(t,c,`Unexpected server response: ${d.statusCode}`)}),c.on("upgrade",(d,m,y)=>{if(t.emit("upgrade",d),t.readyState!==D.CONNECTING)return;if(c=t._req=null,d.headers.upgrade.toLowerCase()!=="websocket"){ne(t,m,"Invalid Upgrade header");return}let v=Yp("sha1").update(l+Zp).digest("base64");if(d.headers["sec-websocket-accept"]!==v){ne(t,m,"Invalid Sec-WebSocket-Accept header");return}let w=d.headers["sec-websocket-protocol"],P=(r||"").split(/, */),U;if(!r&&w?U="Server sent a subprotocol but none was requested":r&&!w?U="Server sent no subprotocol":w&&!P.includes(w)&&(U="Server sent an invalid subprotocol"),U){ne(t,m,U);return}w&&(t._protocol=w);let z=d.headers["sec-websocket-extensions"];if(z!==void 0){if(!h){ne(t,m,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let W;try{W=ng(z)}catch{ne(t,m,"Invalid Sec-WebSocket-Extensions header");return}let Xe=Object.keys(W);if(Xe.length){if(Xe.length!==1||Xe[0]!==Qe.extensionName){ne(t,m,"Server indicated an extension that was not requested");return}try{h.accept(W[Qe.extensionName])}catch{ne(t,m,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Qe.extensionName]=h}}t.setSocket(m,y,n.maxPayload)})}function Dn(t,e){t._readyState=D.CLOSING,t.emit("error",e),t.emitClose()}function ag(t){return t.path=t.socketPath,Ml.connect(t)}function lg(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ml.isIP(t.host)?"":t.host),Gp.connect(t)}function ne(t,e,r){t._readyState=D.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ne),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 Un(t,e,r){if(e){let i=sg(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ae[t.readyState]})`);r(i)}}function ug(t,e){let r=this[Y];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Y]!==void 0&&(r._socket.removeListener("data",oi),process.nextTick(Dl,r._socket),t===1005?r.close():r.close(t,e))}function fg(){this[Y]._socket.resume()}function cg(t){let e=this[Y];e._socket[Y]!==void 0&&(e._socket.removeListener("data",oi),process.nextTick(Dl,e._socket),e.close(t[eg])),e.emit("error",t)}function Ll(){this[Y].emitClose()}function hg(t){this[Y].emit("message",t)}function dg(t){let e=this[Y];e.pong(t,!e._isServer,ql),e.emit("ping",t)}function pg(t){this[Y].emit("pong",t)}function Dl(t){t.resume()}function Ul(){let t=this[Y];this.removeListener("close",Ul),this.removeListener("data",oi),this.removeListener("end",jl),t._readyState=D.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[Y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ll),t._receiver.on("finish",Ll))}function oi(t){this[Y]._receiver.write(t)||this.pause()}function jl(){let t=this[Y];t._readyState=D.CLOSING,t._receiver.end(),this.end()}function Fl(){let t=this[Y];this.removeListener("error",Fl),this.on("error",ql),t&&(t._readyState=D.CLOSING,this.destroy())}});var zl=g((qm,Kl)=>{"use strict";var{Duplex:gg}=b("stream");function Vl(t){t.emit("close")}function yg(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Hl(t){this.removeListener("error",Hl),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function _g(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 gg({...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(Vl,s);return}let u=!1;t.once("error",function(f){u=!0,a(f)}),t.once("close",function(){u||a(o),process.nextTick(Vl,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",yg),s.on("error",Hl),s}Kl.exports=_g});var Xl=g((jm,Yl)=>{"use strict";var mg=b("events"),ai=b("http"),Nm=b("https"),Dm=b("net"),Um=b("tls"),{createHash:vg}=b("crypto"),dt=er(),bg=jn(),{format:wg,parse:Sg}=Ln(),{GUID:Eg,kWebSocket:xg}=ct(),Tg=/^[+/0-9A-Za-z]{22}==$/,$l=0,Gl=1,Ql=2,Wn=class extends mg{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=Cg(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=$l}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===Ql){process.nextTick(Fn,this);return}if(this._state===Gl)return;if(this._state=Gl,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(Fn.bind(void 0,this));return}process.nextTick(Fn,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",Vn);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||!Tg.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=Sg(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[xg])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>$l)return ir(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${vg("sha1").update(e+Eg).digest("base64")}`],l=new bg(null),f=i.headers["sec-websocket-protocol"];if(f&&(f=f.split(",").map(Pg),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=wg({[dt.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${c}`),l._extensions=r}this.emit("headers",u,i),n.write(u.concat(`\r
|
|
3
|
+
`+s),t.push(n+"m+"+Vr.exports.humanize(this.diff)+"\x1B[0m")}else t[0]=qh()+e+" "+t[0]}function qh(){return K.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Nh(...t){return process.stderr.write(Wr.formatWithOptions(K.inspectOpts,...t)+`
|
|
4
|
+
`)}function Dh(t){t?process.env.DEBUG=t:delete process.env.DEBUG}function Uh(){return process.env.DEBUG}function jh(t){t.inspectOpts={};let e=Object.keys(K.inspectOpts);for(let r=0;r<e.length;r++)t.inspectOpts[e[r]]=K.inspectOpts[e[r]]}Vr.exports=$i()(K);var{formatters:Ho}=Vr.exports;Ho.o=function(t){return this.inspectOpts.colors=this.useColors,Wr.inspect(t,this.inspectOpts).split(`
|
|
5
|
+
`).map(e=>e.trim()).join(" ")};Ho.O=function(t){return this.inspectOpts.colors=this.useColors,Wr.inspect(t,this.inspectOpts)}});var me=g((W_,Yi)=>{"use strict";typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Yi.exports=Do():Yi.exports=Ko()});var $o=g((V_,zo)=>{"use strict";var Fh=(Lo(),Su(ko)).OrderedSet,ve=me()("number-allocator:trace"),Wh=me()("number-allocator:error");function J(t,e){this.low=t,this.high=e}J.prototype.equals=function(t){return this.low===t.low&&this.high===t.high};J.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 be(t,e){if(!(this instanceof be))return new be(t,e);this.min=t,this.max=e,this.ss=new Fh([],(r,i)=>r.compare(i)),ve("Create"),this.clear()}be.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low};be.prototype.alloc=function(){if(this.ss.size()===0)return ve("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 J(e+1,r)):this.ss.eraseElementByPos(0),ve("alloc():"+i),i};be.prototype.use=function(t){let e=new J(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),ve("use():"+t),!0):i>t?!1:i===t?(this.ss.updateKeyByIterator(r,new J(i+1,n)),ve("use():"+t),!0):n===t?(this.ss.updateKeyByIterator(r,new J(i,n-1)),ve("use():"+t),!0):(this.ss.updateKeyByIterator(r,new J(t+1,n)),this.ss.insert(new J(i,t-1)),ve("use():"+t),!0)}return ve("use():failed"),!1};be.prototype.free=function(t){if(t<this.min||t>this.max){Wh("free():"+t+" is out of range");return}let e=new J(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 J(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 J(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 J(s,a))}else this.ss.updateKeyByIterator(r,new J(s,t));else t+1===i?(this.ss.eraseElementByIterator(r.next()),this.ss.insert(new J(t,n))):this.ss.insert(e)}ve("free():"+t)};be.prototype.clear=function(){ve("clear()"),this.ss.clear(),this.ss.insert(new J(this.min,this.max))};be.prototype.intervalCount=function(){return this.ss.size()};be.prototype.dump=function(){console.log("length:"+this.ss.size());for(let t of this.ss)console.log(t)};zo.exports=be});var Xi=g((H_,Go)=>{"use strict";var Vh=$o();Go.exports.NumberAllocator=Vh});var Yo=g((K_,Qo)=>{"use strict";var Hh=uo(),Kh=Xi().NumberAllocator;function We(t){if(!(this instanceof We))return new We(t);t>0&&(this.aliasToTopic=new Hh({max:t}),this.topicToAlias={},this.numberAllocator=new Kh(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]};Qo.exports=We});var Zo=g((z_,Jo)=>{"use strict";var{Buffer:pe}=b("buffer"),Xo=Symbol.for("BufferList");function A(t){if(!(this instanceof A))return new A(t);A._init.call(this,t)}A._init=function(e){Object.defineProperty(this,Xo,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)};A.prototype._new=function(e){return new A(e)};A.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}};A.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};A.prototype.get=function(e){if(e>this.length||e<0)return;let r=this._offset(e);return this._bufs[r[0]][r[1]]};A.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)};A.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||pe.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]:pe.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=pe.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};A.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)};A.prototype.toString=function(e,r,i){return this.slice(r,i).toString(e)};A.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};A.prototype.duplicate=function(){let e=this._new();for(let r=0;r<this._bufs.length;r++)e.append(this._bufs[r]);return e};A.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(pe.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(pe.from(e));return this};A.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length};A.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=pe.from([t]):typeof t=="string"?t=pe.from(t,r):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=pe.from(t.buffer,t.byteOffset,t.byteLength):pe.isBuffer(t)||(t=pe.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};A.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?A.prototype[r]=function(i,n){return this.slice(i,i+n)[r](0,n)}:A.prototype[r]=function(i=0){return this.slice(i,i+t[r])[r](0)}})(e)})();A.prototype._isBufferList=function(e){return e instanceof A||A.isBufferList(e)};A.isBufferList=function(e){return e!=null&&e[Xo]};Jo.exports=A});var ea=g(($_,Hr)=>{"use strict";var Ji=Ne().Duplex,zh=Se(),$t=Zo();function Q(t){if(!(this instanceof Q))return new Q(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),Ji.call(this)}zh(Q,Ji);Object.assign(Q.prototype,$t.prototype);Q.prototype._new=function(e){return new Q(e)};Q.prototype._write=function(e,r,i){this._appendBuffer(e),typeof i=="function"&&i()};Q.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)};Q.prototype.end=function(e){Ji.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)};Q.prototype._destroy=function(e,r){this._bufs.length=0,this.length=0,r(e)};Q.prototype._isBufferList=function(e){return e instanceof Q||e instanceof $t||Q.isBufferList(e)};Q.isBufferList=$t.isBufferList;Hr.exports=Q;Hr.exports.BufferListStream=Q;Hr.exports.BufferList=$t});var ra=g((G_,ta)=>{"use strict";var Zi=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}};ta.exports=Zi});var en=g((Q_,ia)=>{"use strict";var _=ia.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 oa=g((Y_,sa)=>{"use strict";var $h=ea(),Gh=b("events"),na=ra(),R=en(),E=me()("mqtt-packet:parser"),tn=class t extends Gh{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(){E("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new na,this.error=null,this._list=$h(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),E("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++,E("parse: state complete. _stateCounter is now: %d",this._stateCounter),E("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return E("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=R.types[e>>R.CMD_SHIFT],this.packet.retain=(e&R.RETAIN_MASK)!==0,this.packet.qos=e>>R.QOS_SHIFT&R.QOS_MASK,this.packet.dup=(e&R.DUP_MASK)!==0,E("_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)),E("_parseLength %d",e.value),!!e}_parsePayload(){E("_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 E("_parsePayload complete result: %s",e),e}_parseConnect(){E("_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)&R.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&R.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&R.WILL_FLAG_MASK,s.will&&(o.will={},o.will.retain=(this._list.readUInt8(this._pos)&R.WILL_RETAIN_MASK)!==0,o.will.qos=(this._list.readUInt8(this._pos)&R.WILL_QOS_MASK)>>R.WILL_QOS_SHIFT),o.clean=(this._list.readUInt8(this._pos)&R.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,E("_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,E("_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,E("_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,E("_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,E("_parseConnect: complete"),o}_parseConnack(){E("_parseConnack");let e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&R.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)}E("_parseConnack: complete")}_parsePublish(){E("_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),E("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){E("_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&R.SUBSCRIBE_OPTIONS_QOS_MASK,a=(i>>R.SUBSCRIBE_OPTIONS_NL_SHIFT&R.SUBSCRIBE_OPTIONS_NL_MASK)!==0,o=(i>>R.SUBSCRIBE_OPTIONS_RAP_SHIFT&R.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,s=i>>R.SUBSCRIBE_OPTIONS_RH_SHIFT&R.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),E("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_parseSuback(){E("_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(){E("_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"));E("_parseUnsubscribe: push topic `%s` to unsubscriptions",r),e.unsubscriptions.push(r)}}}_parseUnsuback(){E("_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(){E("_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(),E("_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(E("_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 E("_parseDisconnect result: true"),!0}_parseAuth(){E("_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),E("_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):(E("_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,E("_parseString: result: %s",n),n}_parseStringPair(){return E("_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,E("_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,E("_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,E("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){E("_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&R.VARBYTEINT_MASK),n*=128,(a&R.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,E("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),E("_parseByte: result: %o",e),e}_parseByType(e){switch(E("_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(){E("_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=R.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(R.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(R.propertiesTypes[o])):(n[o]=[n[o]],n[o].push(this._parseByType(R.propertiesTypes[o]))):n[o]=this._parseByType(R.propertiesTypes[o])}return n}_newPacket(){return E("_newPacket"),this.packet&&(this._list.consume(this.packet.length),E("_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)),E("_newPacket: new packet"),this.packet=new na,this._pos=0,!0}_emitError(e){E("_emitError"),this.error=e,this.emit("error",e)}};sa.exports=tn});var fa=g((X_,ua)=>{"use strict";var aa={},Qh=Buffer.isBuffer(Buffer.from([1,2]).subarray(0,1));function la(t){let e=Buffer.allocUnsafe(2);return e.writeUInt8(t>>8,0),e.writeUInt8(t&255,1),e}function Yh(){for(let t=0;t<65536;t++)aa[t]=la(t)}function Xh(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),Qh?n.subarray(0,i):n.slice(0,i)}function Jh(t){let e=Buffer.allocUnsafe(4);return e.writeUInt32BE(t,0),e}ua.exports={cache:aa,generateCache:Yh,generateNumber:la,genBufVariableByteInt:Xh,generate4ByteBuffer:Jh}});var ca=g((J_,rn)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?rn.exports={nextTick:Zh}:rn.exports=process;function Zh(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 on=g((Z_,va)=>{"use strict";var x=en(),ed=Buffer.allocUnsafe(0),td=Buffer.from([0]),Gt=fa(),rd=ca().nextTick,le=me()("mqtt-packet:writeToStream"),Kr=Gt.cache,id=Gt.generateNumber,nd=Gt.generateCache,nn=Gt.genBufVariableByteInt,sd=Gt.generate4ByteBuffer,Z=sn,zr=!0;function _a(t,e,r){switch(le("generate called"),e.cork&&(e.cork(),rd(od,e)),zr&&(zr=!1,nd()),le("generate: packet.cmd: %s",t.cmd),t.cmd){case"connect":return ad(t,e,r);case"connack":return ld(t,e,r);case"publish":return ud(t,e,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return fd(t,e,r);case"subscribe":return cd(t,e,r);case"suback":return hd(t,e,r);case"unsubscribe":return dd(t,e,r);case"unsuback":return pd(t,e,r);case"pingreq":case"pingresp":return gd(t,e,r);case"disconnect":return yd(t,e,r);case"auth":return _d(t,e,r);default:return e.emit("error",new Error("Unknown command")),!1}}Object.defineProperty(_a,"cacheNumbers",{get(){return Z===sn},set(t){t?((!Kr||Object.keys(Kr).length===0)&&(zr=!0),Z=sn):(zr=!1,Z=md)}});function od(t){t.uncork()}function ad(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(ya(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(ya(h))d+=ma(h)+2;else return e.emit("error",new Error("Invalid password")),!1}e.write(x.CONNECT_HEADER),ue(e,d),Ot(e,n),i.bridgeMode&&(s+=128),e.write(s===131?x.VERSION131:s===132?x.VERSION132:s===4?x.VERSION4:s===5?x.VERSION5:x.VERSION3);let w=0;return w|=f!=null?x.USERNAME_MASK:0,w|=h!=null?x.PASSWORD_MASK:0,w|=o&&o.retain?x.WILL_RETAIN_MASK:0,w|=o&&o.qos?o.qos<<x.WILL_QOS_SHIFT:0,w|=o?x.WILL_FLAG_MASK:0,w|=a?x.CLEAN_SESSION_MASK:0,e.write(Buffer.from([w])),Z(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 ld(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(x.CONNACK_HEADER),ue(e,a),e.write(n.sessionPresent?x.SESSIONPRESENT_HEADER:td),e.write(Buffer.from([s])),u?.write(),!0}function ud(t,e,r){le("publish: packet: %o",t);let i=r?r.protocolVersion:4,n=t||{},s=n.qos||0,o=n.retain?x.RETAIN_MASK:0,a=n.topic,u=n.payload||ed,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(x.PUBLISH_HEADER[s][n.dup?1:0][o?1:0]),ue(e,h),Z(e,ma(a)),e.write(a),s>0&&Z(e,l),c?.write(),le("publish: payload: %o",u),e.write(u)}function fd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.cmd||"puback",o=n.messageId,a=n.dup&&s==="pubrel"?x.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(x.ACKS[s][u][a][0]),ue(e,h),Z(e,o),i===5&&e.write(Buffer.from([l])),c!==null&&c.write(),!0}function cd(t,e,r){le("subscribe: packet: ");let i=r?r.protocolVersion:4,n=t||{},s=n.dup?x.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 w=a[c].rh||0;if(typeof w!="number"||w>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;le("subscribe: writing to stream: %o",x.SUBSCRIBE_HEADER),e.write(x.SUBSCRIBE_HEADER[1][s?1:0][0]),ue(e,l),Z(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,w=c.rh,P;ft(e,d),P=x.SUBSCRIBE_OPTIONS_QOS[m],i===5&&(P|=y?x.SUBSCRIBE_OPTIONS_NL:0,P|=v?x.SUBSCRIBE_OPTIONS_RAP:0,P|=w?x.SUBSCRIBE_OPTIONS_RH[w]:0),h=e.write(Buffer.from([P]))}return h}function hd(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(x.SUBACK_HEADER),ue(e,u),Z(e,s),l!==null&&l.write(),e.write(Buffer.from(o))}function dd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.dup?x.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(x.UNSUBSCRIBE_HEADER[1][o?1:0][0]),ue(e,l),Z(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 pd(t,e,r){let i=r?r.protocolVersion:4,n=t||{},s=n.messageId,o=n.dup?x.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(x.ACKS[l][f][o][0]),ue(e,h),Z(e,s),c!==null&&c.write(),i===5&&e.write(Buffer.from(a)),!0}function gd(t,e,r){return e.write(x.EMPTY[t.cmd])}function yd(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([x.codes.disconnect<<4])),ue(e,a),i===5&&e.write(Buffer.from([s])),u!==null&&u.write(),!0}function _d(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([x.codes.auth<<4])),ue(e,a),e.write(Buffer.from([s])),u!==null&&u.write(),!0):!1}var ha={};function ue(t,e){if(e>x.VARBYTEINT_MAX)return t.emit("error",new Error(`Invalid variable byte integer: ${e}`)),!1;let r=ha[e];return r||(r=nn(e),e<16384&&(ha[e]=r)),le("writeVarByteInt: writing to stream: %o",r),t.write(r)}function ft(t,e){let r=Buffer.byteLength(e);return Z(t,r),le("writeString: %s",e),t.write(e,"utf8")}function da(t,e,r){ft(t,e),ft(t,r)}function sn(t,e){return le("writeNumberCached: number: %d",e),le("writeNumberCached: %o",Kr[e]),t.write(Kr[e])}function md(t,e){let r=id(e);return le("writeNumberGenerated: %o",r),t.write(r)}function vd(t,e){let r=sd(e);return le("write4ByteNumber: %o",r),t.write(r)}function Ot(t,e){typeof e=="string"?ft(t,e):e?(Z(t,e.length),t.write(e)):Z(t,0)}function He(t,e){if(typeof e!="object"||e.length!=null)return{length:1,write(){ga(t,{},0)}};let r=0;function i(s,o){let a=x.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(nn(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(nn(r))+r,write(){ga(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 pa(t,e,r){switch(x.propertiesTypes[e]){case"byte":{t.write(Buffer.from([x.properties[e]])),t.write(Buffer.from([+r]));break}case"int8":{t.write(Buffer.from([x.properties[e]])),t.write(Buffer.from([r]));break}case"binary":{t.write(Buffer.from([x.properties[e]])),Ot(t,r);break}case"int16":{t.write(Buffer.from([x.properties[e]])),Z(t,r);break}case"int32":{t.write(Buffer.from([x.properties[e]])),vd(t,r);break}case"var":{t.write(Buffer.from([x.properties[e]])),ue(t,r);break}case"string":{t.write(Buffer.from([x.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([x.properties[e]])),da(t,n.toString(),o.toString())}):(t.write(Buffer.from([x.properties[e]])),da(t,n.toString(),s.toString()))});break}default:return t.emit("error",new Error(`Invalid property ${e} value: ${r}`)),!1}}function ga(t,e,r){ue(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++)pa(t,i,n[s]);else pa(t,i,n)}}function ma(t){return t?t instanceof Buffer?t.length:Buffer.byteLength(t):0}function ya(t){return typeof t=="string"||t instanceof Buffer}va.exports=_a});var wa=g((em,ba)=>{"use strict";var bd=on(),wd=b("events");function Sd(t,e){let r=new an;return bd(t,r,e),r.concat()}var an=class extends wd{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}};ba.exports=Sd});var Sa=g($r=>{"use strict";$r.parser=oa().parser;$r.generate=wa();$r.writeToStream=on()});var ln=g((rm,Ea)=>{"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(){};Ea.exports=Ke});var Ta=g((im,xa)=>{"use strict";function Ed(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 xd(){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 Ed(arguments[0],arguments[1],t)}xa.exports=xd});var Pa=g((nm,Ca)=>{"use strict";Ca.exports=Td;function It(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function Td(t){if(t=t||{},t.circles)return Cd(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 Cd(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 Ia=g((sm,Oa)=>{"use strict";Oa.exports=Pa()()});var Aa=g((om,Ra)=>{"use strict";function Pd(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 Od(t){if(t.length===0)return"empty_topic_list";for(let e=0;e<t.length;e++)if(!Pd(t[e]))return t[e];return null}Ra.exports={validateTopics:Od}});var cn=g((am,Ua)=>{"use strict";var La=b("events").EventEmitter,Gr=Ir(),Id=eo(),Rd=Yo(),Ma=Sa(),Ad=ln(),Bd=Ne().Writable,kd=Se(),Ld=Ta(),qa=Ia(),Na=Aa(),Yr=dr(),p=me()("mqttjs:client"),un=process?process.nextTick:function(t){setTimeout(t,0)},fn=global.setImmediate||function(t){un(t)},Ba={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},Md=["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 qd(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function Nd(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 Da(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=Ma.writeToStream(e,t.stream,t.options);p("sendPacket :: writeToStream result %s",i),!i&&r&&r!==$?(p("sendPacket :: handle events on `drain` once through callback."),t.stream.once("drain",r)):r&&(p("sendPacket :: invoking cb"),r())}function Dd(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 Ud(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 ka(t,e,r,i){p("storeAndSend :: store packet with cmd %s to outgoingStore",e.cmd);let n=e,s;if(n.cmd==="publish"&&(n=qa(e),s=Da(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 $(t){p("nop ::",t)}function C(t,e){let r,i=this;if(!(this instanceof C))return new C(t,e);this.options=e||{};for(r in Ba)typeof this.options[r]>"u"?this.options[r]=Ba[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:qd(),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 Ad: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 Id(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()}),La.call(this),p("MqttClient :: setting up stream"),this._setupStream()}kd(C,La);C.prototype._setupStream=function(){let t=this,e=new Bd,r=Ma.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)un(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),Md.includes(l.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",l)):$(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),Ud(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)};C.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}};C.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t&&t!==$?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting};C.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||$},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};C.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()||$,o=e.pop(),a=this.options.protocolVersion;delete i.resubscribe,typeof i=="string"&&(i=[i]),typeof s!="function"&&(o=s,s=$);let u=Na.validateTopics(i);if(u!==null)return fn(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};C.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()||$,n=e.pop();typeof r=="string"&&(r=[r]),typeof i!="function"&&(n=i,i=$);let s=Na.validateTopics(r);if(s!==null)return fn(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};C.prototype.end=function(t,e,r){let i=this;p("end :: (%s)",this.options.clientId),(t==null||typeof t!="boolean")&&(r=e||$,e=t,t=!1,typeof e!="object"&&(r=e,e=null,typeof r!="function"&&(r=$))),typeof e!="object"&&(r=e,e=null),p("end :: cb? %s",!!r),r=r||$;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"),un(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)};C.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};C.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};C.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())};C.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...")};C.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)};C.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&&Dd(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,fn.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())};C.prototype._sendPacket=function(t,e,r){p("_sendPacket :: (%s) :: start",this.options.clientId),r=r||$,e=e||$;let i=Nd(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":ka(this,t,e,r);return;default:Rt(this,t,e);return}switch(t.qos){case 2:case 1:ka(this,t,e,r);break;case 0:default:Rt(this,t,e);break}p("_sendPacket :: (%s) :: end",this.options.clientId)};C.prototype._storePacket=function(t,e,r){p("_storePacket :: packet: %o",t),p("_storePacket :: cb? %s",!!e),r=r||$;let i=t;if(i.cmd==="publish"){i=qa(t);let n=Da(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"))};C.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);let t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=Ld(function(){t._checkPing()},this.options.keepalive*1e3))};C.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)};C.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))};C.prototype._handlePingresp=function(){this.pingResp=!0};C.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 Rd(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)}};C.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)}})};C.prototype.handleAuth=function(t,e){e()};C.prototype._handlePublish=function(t,e){p("_handlePublish: packet %o",t),e=typeof e<"u"?e:$;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}};C.prototype.handleMessage=function(t,e){e()};C.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")};C.prototype._handlePubrel=function(t,e){p("handling pubrel packet"),e=typeof e<"u"?e:$;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,$),i._sendPacket(n,e)}))})};C.prototype._handleDisconnect=function(t){this.emit("disconnect",t)};C.prototype._nextId=function(){return this.messageIdProvider.allocate()};C.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()};C.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};C.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()};C.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){let t=this._storeProcessingQueue[0];if(t&&t.invoke())return this._storeProcessingQueue.shift(),!0}return!1};C.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););};C.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)};Ua.exports=C});var hn=g((lm,ja)=>{"use strict";var jd=b("net"),Fd=me()("mqttjs:tcp");function Wd(t,e){e.port=e.port||1883,e.hostname=e.hostname||e.host||"localhost";let r=e.port,i=e.hostname;return Fd("port %d and host %s",r,i),jd.createConnection(r,i)}ja.exports=Wd});var Xr=g((um,Fa)=>{"use strict";var Vd=b("tls"),Hd=b("net"),Kd=me()("mqttjs:tls");function zd(t,e){e.port=e.port||8883,e.host=e.hostname||e.host||"localhost",Hd.isIP(e.host)===0&&(e.servername=e.host),e.rejectUnauthorized=e.rejectUnauthorized!==!1,delete e.path,Kd("port %d host %s rejectUnauthorized %b",e.port,e.host,e.rejectUnauthorized);let r=Vd.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}Fa.exports=zd});var Ha=g((fm,Va)=>{"use strict";Va.exports=Wa;function Wa(t,e){if(t&&e)return Wa(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 $a=g((cm,dn)=>{"use strict";var Ka=Ha();dn.exports=Ka(Jr);dn.exports.strict=Ka(za);Jr.proto=Jr(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Jr(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return za(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 za(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 Ya=g((hm,Qa)=>{"use strict";var $d=$a(),Gd=function(){},Qd=function(t){return t.setHeader&&typeof t.abort=="function"},Yd=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3},Ga=function(t,e,r){if(typeof e=="function")return Ga(t,null,e);e||(e={}),r=$d(r||Gd);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 Qd(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)),Yd(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)}};Qa.exports=Ga});var Ja=g((dm,Xa)=>{"use strict";Xa.exports=Xd;function Xd(t){var e=t._readableState;return e?e.objectMode||typeof t._duplexState=="number"?t.read():t.read(Jd(e)):null}function Jd(t){return t.buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length}});var ei=g((pm,rl)=>{"use strict";var Zr=Ne(),Za=Ya(),Zd=Se(),ep=Ja(),el=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),pn=function(t,e){t._corked?t.once("uncork",e):e()},tp=function(t,e){t._autoDestroy&&t.destroy(e)},tl=function(t,e){return function(r){r?tp(t,r.message==="premature close"?null:r):e&&!t._ended&&t.end()}},rp=function(t,e){if(!t||t._writableState&&t._writableState.finished)return e();if(t._writableState)return t.end(e);t.end(),e()},ip=function(){},np=function(t){return new Zr.Readable({objectMode:!0,highWaterMark:16}).wrap(t)},G=function(t,e,r){if(!(this instanceof G))return new G(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)};Zd(G,Zr.Duplex);G.obj=function(t,e,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new G(t,e,r)};G.prototype.cork=function(){++this._corked===1&&this.emit("cork")};G.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};G.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=Za(t,{writable:!0,readable:!1},tl(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()};G.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=Za(t,{writable:!1,readable:!0},tl(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:np(t),this._readable2.on("readable",i),this._readable2.on("end",n),this._unread=s,this._forward()};G.prototype._read=function(){this._drained=!0,this._forward()};G.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var t;this._drained&&(t=ep(this._readable2))!==null;)this.destroyed||(this._drained=this.push(t));this._forwarding=!1}};G.prototype.destroy=function(t,e){if(e||(e=ip),this.destroyed)return e(null);this.destroyed=!0;var r=this;process.nextTick(function(){r._destroy(t),e(null)})};G.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")};G.prototype._write=function(t,e,r){if(!this.destroyed){if(this._corked)return pn(this,this._write.bind(this,t,e,r));if(t===el)return this._finish(r);if(!this._writable)return r();this._writable.write(t)===!1?this._ondrain=r:this.destroyed||r()}};G.prototype._finish=function(t){var e=this;this.emit("preend"),pn(this,function(){rp(e._forwardEnd&&e._writable,function(){e._writableState.prefinished===!1&&(e._writableState.prefinished=!0),e.emit("prefinish"),pn(e,t)})})};G.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(el),Zr.Writable.prototype.end.call(this,r))};rl.exports=G});var gn=g((gm,nl)=>{"use strict";var{Buffer:il}=b("buffer"),sp=Ne().Transform,op=ei(),Oe,ti,ie;function ap(){let t=new sp;return t._write=function(e,r,i){Oe.send({data:e.buffer,success:function(){i()},fail:function(n){i(new Error(n))}})},t._flush=function(r){Oe.close({success:function(){r()}})},t}function lp(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}function up(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 fp(){Oe.onOpen(function(){ie.setReadable(ti),ie.setWritable(ti),ie.emit("connect")}),Oe.onMessage(function(t){let e=t.data;e instanceof ArrayBuffer?e=il.from(e):e=il.from(e,"utf8"),ti.push(e)}),Oe.onClose(function(){ie.end(),ie.destroy()}),Oe.onError(function(t){ie.destroy(new Error(t.errMsg))})}function cp(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";lp(e);let i=up(e,t);Oe=wx.connectSocket({url:i,protocols:[r]}),ti=ap(),ie=op.obj(),ie._destroy=function(s,o){Oe.close({success:function(){o&&o(s)}})};let n=ie.destroy;return ie.destroy=function(){ie.destroy=n;let s=this;setTimeout(function(){Oe.close({fail:function(){s._destroy(new Error)}})},0)}.bind(ie),fp(),ie}nl.exports=cp});var _n=g((ym,ol)=>{"use strict";var{Buffer:yn}=b("buffer"),hp=Ne().Transform,dp=ei(),$e,Yt,ze,sl=!1;function pp(){let t=new hp;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 gp(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}function yp(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 _p(){sl||(sl=!0,$e.onSocketOpen(function(){ze.setReadable(Yt),ze.setWritable(Yt),ze.emit("connect")}),$e.onSocketMessage(function(t){if(typeof t.data=="string"){let e=yn.from(t.data,"base64");Yt.push(e)}else{let e=new FileReader;e.addEventListener("load",function(){let r=e.result;r instanceof ArrayBuffer?r=yn.from(r):r=yn.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 mp(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";gp(e);let i=yp(e,t);return $e=e.my,$e.connectSocket({url:i,protocols:r}),Yt=pp(),ze=dp.obj(),_p(),ze}ol.exports=mp});var ct=g((_m,al)=>{"use strict";al.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((mm,mn)=>{"use strict";var{EMPTY_BUFFER:vp}=ct();function ll(t,e){if(t.length===0)return vp;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 ul(t,e,r,i,n){for(let s=0;s<n;s++)r[i+s]=t[s]^e[s&3]}function fl(t,e){let r=t.length;for(let i=0;i<r;i++)t[i]^=e[i&3]}function cl(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=b("bufferutil"),e=t.BufferUtil||t;mn.exports={concat:ll,mask(r,i,n,s,o){o<48?ul(r,i,n,s,o):e.mask(r,i,n,s,o)},toArrayBuffer:cl,toBuffer:ri,unmask(r,i){r.length<32?fl(r,i):e.unmask(r,i)}}}catch{mn.exports={concat:ll,mask:ul,toArrayBuffer:cl,toBuffer:ri,unmask:fl}}});var pl=g((vm,dl)=>{"use strict";var hl=Symbol("kDone"),vn=Symbol("kRun"),bn=class{constructor(e){this[hl]=()=>{this.pending--,this[vn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[vn]()}[vn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[hl])}}};dl.exports=bn});var er=g((bm,ml)=>{"use strict";var Jt=b("zlib"),gl=Xt(),bp=pl(),{kStatusCode:yl,NOOP:wp}=ct(),Sp=Buffer.from([0,0,255,255]),si=Symbol("permessage-deflate"),Ie=Symbol("total-length"),Zt=Symbol("callback"),Ge=Symbol("buffers"),ni=Symbol("error"),ii,wn=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 bp(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[Ie]=0,this._inflate[Ge]=[],this._inflate.on("error",xp),this._inflate.on("data",_l)}this._inflate[Zt]=i,this._inflate.write(e),r&&this._inflate.write(Sp),this._inflate.flush(()=>{let s=this._inflate[ni];if(s){this._inflate.close(),this._inflate=null,i(s);return}let o=gl.concat(this._inflate[Ge],this._inflate[Ie]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ie]=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[Ie]=0,this._deflate[Ge]=[],this._deflate.on("error",wp),this._deflate.on("data",Ep)}this._deflate[Zt]=i,this._deflate.write(e),this._deflate.flush(Jt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=gl.concat(this._deflate[Ge],this._deflate[Ie]);r&&(s=s.slice(0,s.length-4)),this._deflate[Zt]=null,this._deflate[Ie]=0,this._deflate[Ge]=[],r&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),i(null,s)})}};ml.exports=wn;function Ep(t){this[Ge].push(t),this[Ie]+=t.length}function _l(t){if(this[Ie]+=t.length,this[si]._maxPayload<1||this[Ie]<=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][yl]=1009,this.removeListener("data",_l),this.reset()}function xp(t){this[si]._inflate=null,t[yl]=1007,this[Zt](t)}});var En=g((wm,Sn)=>{"use strict";function vl(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function bl(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=b("utf-8-validate");typeof t=="object"&&(t=t.Validation.isValidUTF8),Sn.exports={isValidStatusCode:vl,isValidUTF8(e){return e.length<150?bl(e):t(e)}}}catch{Sn.exports={isValidStatusCode:vl,isValidUTF8:bl}}});var Pn=g((Sm,Cl)=>{"use strict";var{Writable:Tp}=b("stream"),wl=er(),{BINARY_TYPES:Cp,EMPTY_BUFFER:Pp,kStatusCode:Op,kWebSocket:Ip}=ct(),{concat:xn,toArrayBuffer:Rp,unmask:Ap}=Xt(),{isValidStatusCode:Bp,isValidUTF8:Sl}=En(),tr=0,El=1,xl=2,Tl=3,Tn=4,kp=5,Cn=class extends Tp{constructor(e,r,i,n){super(),this._binaryType=e||Cp[0],this[Ip]=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 El:r=this.getPayloadLength16();break;case xl:r=this.getPayloadLength64();break;case Tl:this.getMask();break;case Tn: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,F(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[wl.extensionName])return this._loop=!1,F(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,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,F(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,F(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,F(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(r)return this._loop=!1,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,F(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,F(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,F(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,F(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=El;else if(this._payloadLength===127)this._state=xl;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,F(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,F(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Tl:this._state=Tn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Tn}getData(e){let r=Pp;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&Ap(r,this._mask)}if(this._opcode>7)return this.controlMessage(r);if(this._compressed){this._state=kp,this.decompress(r,e);return}return r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage()}decompress(e,r){this._extensions[wl.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(F(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=xn(r,e):this._binaryType==="arraybuffer"?i=Rp(xn(r,e)):i=r,this.emit("message",i)}else{let i=xn(r,e);if(!Sl(i))return this._loop=!1,F(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 F(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let r=e.readUInt16BE(0);if(!Bp(r))return F(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let i=e.slice(2);if(!Sl(i))return F(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}};Cl.exports=Cn;function F(t,e,r,i,n){let s=new t(r?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,F),s.code=n,s[Op]=i,s}});var In=g((Tm,Il)=>{"use strict";var Em=b("net"),xm=b("tls"),{randomFillSync:Lp}=b("crypto"),Pl=er(),{EMPTY_BUFFER:Mp}=ct(),{isValidStatusCode:qp}=En(),{mask:Ol,toBuffer:Re}=Xt(),ht=Buffer.alloc(4),On=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?(Lp(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?(Ol(e,ht,o,n,e.length),[o]):(Ol(e,ht,e,0,e.length),[o,e])):[o,e]}close(e,r,i,n){let s;if(e===void 0)s=Mp;else{if(typeof e!="number"||!qp(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=Re(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,Re.readOnly,i]):this.doPing(n,r,Re.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=Re(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,Re.readOnly,i]):this.doPong(n,r,Re.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=Re(e),s=this._extensions[Pl.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:Re.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:Re.readOnly}),i)}dispatch(e,r,i,n){if(!r){this.sendFrame(t.frame(e,i),n);return}let s=this._extensions[Pl.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)}};Il.exports=On});var Al=g((Cm,Rl)=>{"use strict";var At=class{constructor(e,r){this.target=r,this.type=e}},Rn=class extends At{constructor(e,r){super("message",r),this.data=e}},An=class extends At{constructor(e,r,i){super("close",i),this.wasClean=i._closeFrameReceived&&i._closeFrameSent,this.reason=r,this.code=e}},Bn=class extends At{constructor(e){super("open",e)}},kn=class extends At{constructor(e,r){super("error",r),this.message=e.message,this.error=e}},Np={addEventListener(t,e,r){if(typeof e!="function")return;function i(u){e.call(this,new Rn(u,this))}function n(u,l){e.call(this,new An(u,l,this))}function s(u){e.call(this,new kn(u,this))}function o(){e.call(this,new Bn(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])}};Rl.exports=Np});var Ln=g((Pm,Bl)=>{"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 we(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Dp(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?(we(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),we(r,t.slice(u,l),!0),c===44&&(we(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),we(r,a,d),c===44&&(we(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?we(e,h,r):(a===void 0?we(r,h,!0):i?we(r,a,h.replace(/\\/g,"")):we(r,a,h),we(e,o,r)),e}function Up(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(", ")}Bl.exports={format:Up,parse:Dp}});var jn=g((Im,Wl)=>{"use strict";var jp=b("events"),Fp=b("https"),Wp=b("http"),Ml=b("net"),Vp=b("tls"),{randomBytes:Hp,createHash:Kp}=b("crypto"),{Readable:Om}=b("stream"),{URL:Mn}=b("url"),Qe=er(),zp=Pn(),$p=In(),{BINARY_TYPES:kl,EMPTY_BUFFER:qn,GUID:Gp,kStatusCode:Qp,kWebSocket:Y,NOOP:ql}=ct(),{addEventListener:Yp,removeEventListener:Xp}=Al(),{format:Jp,parse:Zp}=Ln(),{toBuffer:eg}=Xt(),Ae=["CONNECTING","OPEN","CLOSING","CLOSED"],Nn=[8,13],tg=30*1e3,D=class t extends jp{constructor(e,r,i){super(),this._binaryType=kl[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),Nl(this,e,r,i)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){kl.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 zp(this.binaryType,this._extensions,this._isServer,i);this._sender=new $p(e,this._extensions),this._receiver=n,this._socket=e,n[Y]=this,e[Y]=this,n.on("conclude",ng),n.on("drain",sg),n.on("error",og),n.on("message",ag),n.on("ping",lg),n.on("pong",ug),e.setTimeout(0),e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Ul),e.on("data",oi),e.on("end",jl),e.on("error",Fl),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 ne(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),tg)}}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){Un(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||qn,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){Un(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||qn,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){Un(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||qn,n,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING)return ne(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:Ae.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:Ae.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:Ae.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:Ae.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:Ae.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:Ae.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:Ae.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:Ae.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(t=>{Object.defineProperty(D.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(D.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)}})});D.prototype.addEventListener=Yp;D.prototype.removeEventListener=Xp;Wl.exports=D;function Nl(t,e,r,i){let n={protocolVersion:Nn[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(!Nn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Nn.join(", ")})`);let s;e instanceof Mn?(s=e,t._url=e.href):(s=new Mn(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;Dn(t,d);return}let a=s.protocol==="wss:"||s.protocol==="https:",u=a?443:80,l=Hp(16).toString("base64"),f=a?Fp.get:Wp.get,h;if(n.createConnection=a?ig:rg,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"]=Jp({[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",()=>{ne(t,c,"Opening handshake has timed out")}),c.on("error",d=>{c===null||c.aborted||(c=t._req=null,Dn(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){ne(t,c,"Maximum redirects exceeded");return}c.abort();let v;try{v=new Mn(m,e)}catch(w){Dn(t,w);return}Nl(t,v,r,i)}else t.emit("unexpected-response",c,d)||ne(t,c,`Unexpected server response: ${d.statusCode}`)}),c.on("upgrade",(d,m,y)=>{if(t.emit("upgrade",d),t.readyState!==D.CONNECTING)return;if(c=t._req=null,d.headers.upgrade.toLowerCase()!=="websocket"){ne(t,m,"Invalid Upgrade header");return}let v=Kp("sha1").update(l+Gp).digest("base64");if(d.headers["sec-websocket-accept"]!==v){ne(t,m,"Invalid Sec-WebSocket-Accept header");return}let w=d.headers["sec-websocket-protocol"],P=(r||"").split(/, */),U;if(!r&&w?U="Server sent a subprotocol but none was requested":r&&!w?U="Server sent no subprotocol":w&&!P.includes(w)&&(U="Server sent an invalid subprotocol"),U){ne(t,m,U);return}w&&(t._protocol=w);let z=d.headers["sec-websocket-extensions"];if(z!==void 0){if(!h){ne(t,m,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let W;try{W=Zp(z)}catch{ne(t,m,"Invalid Sec-WebSocket-Extensions header");return}let Xe=Object.keys(W);if(Xe.length){if(Xe.length!==1||Xe[0]!==Qe.extensionName){ne(t,m,"Server indicated an extension that was not requested");return}try{h.accept(W[Qe.extensionName])}catch{ne(t,m,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Qe.extensionName]=h}}t.setSocket(m,y,n.maxPayload)})}function Dn(t,e){t._readyState=D.CLOSING,t.emit("error",e),t.emitClose()}function rg(t){return t.path=t.socketPath,Ml.connect(t)}function ig(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ml.isIP(t.host)?"":t.host),Vp.connect(t)}function ne(t,e,r){t._readyState=D.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ne),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 Un(t,e,r){if(e){let i=eg(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ae[t.readyState]})`);r(i)}}function ng(t,e){let r=this[Y];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Y]!==void 0&&(r._socket.removeListener("data",oi),process.nextTick(Dl,r._socket),t===1005?r.close():r.close(t,e))}function sg(){this[Y]._socket.resume()}function og(t){let e=this[Y];e._socket[Y]!==void 0&&(e._socket.removeListener("data",oi),process.nextTick(Dl,e._socket),e.close(t[Qp])),e.emit("error",t)}function Ll(){this[Y].emitClose()}function ag(t){this[Y].emit("message",t)}function lg(t){let e=this[Y];e.pong(t,!e._isServer,ql),e.emit("ping",t)}function ug(t){this[Y].emit("pong",t)}function Dl(t){t.resume()}function Ul(){let t=this[Y];this.removeListener("close",Ul),this.removeListener("data",oi),this.removeListener("end",jl),t._readyState=D.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[Y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ll),t._receiver.on("finish",Ll))}function oi(t){this[Y]._receiver.write(t)||this.pause()}function jl(){let t=this[Y];t._readyState=D.CLOSING,t._receiver.end(),this.end()}function Fl(){let t=this[Y];this.removeListener("error",Fl),this.on("error",ql),t&&(t._readyState=D.CLOSING,this.destroy())}});var zl=g((Rm,Kl)=>{"use strict";var{Duplex:fg}=b("stream");function Vl(t){t.emit("close")}function cg(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Hl(t){this.removeListener("error",Hl),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function hg(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 fg({...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(Vl,s);return}let u=!1;t.once("error",function(f){u=!0,a(f)}),t.once("close",function(){u||a(o),process.nextTick(Vl,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",cg),s.on("error",Hl),s}Kl.exports=hg});var Xl=g((Lm,Yl)=>{"use strict";var dg=b("events"),ai=b("http"),Am=b("https"),Bm=b("net"),km=b("tls"),{createHash:pg}=b("crypto"),dt=er(),gg=jn(),{format:yg,parse:_g}=Ln(),{GUID:mg,kWebSocket:vg}=ct(),bg=/^[+/0-9A-Za-z]{22}==$/,$l=0,Gl=1,Ql=2,Wn=class extends dg{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=wg(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=$l}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===Ql){process.nextTick(Fn,this);return}if(this._state===Gl)return;if(this._state=Gl,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(Fn.bind(void 0,this));return}process.nextTick(Fn,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",Vn);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||!bg.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=_g(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[vg])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>$l)return ir(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${pg("sha1").update(e+mg).digest("base64")}`],l=new gg(null),f=i.headers["sec-websocket-protocol"];if(f&&(f=f.split(",").map(Sg),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=yg({[dt.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${c}`),l._extensions=r}this.emit("headers",u,i),n.write(u.concat(`\r
|
|
6
6
|
`).join(`\r
|
|
7
|
-
`)),n.removeListener("error",Vn),l.setSocket(n,s,this.options.maxPayload),this.clients&&(this.clients.add(l),l.on("close",()=>this.clients.delete(l))),o(l,i)}};Yl.exports=Wn;function
|
|
7
|
+
`)),n.removeListener("error",Vn),l.setSocket(n,s,this.options.maxPayload),this.clients&&(this.clients.add(l),l.on("close",()=>this.clients.delete(l))),o(l,i)}};Yl.exports=Wn;function wg(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 Fn(t){t._state=Ql,t.emit("close")}function Vn(){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
8
|
`+Object.keys(i).map(n=>`${n}: ${i[n]}`).join(`\r
|
|
9
9
|
`)+`\r
|
|
10
10
|
\r
|
|
11
|
-
`+r)),t.removeListener("error",Vn),t.destroy()}function Pg(t){return t.trim()}});var Zl=g((Fm,Jl)=>{"use strict";var nr=jn();nr.createWebSocketStream=zl();nr.Server=Xl();nr.Receiver=Pn();nr.Sender=In();Jl.exports=nr});var Kn=g((Wm,Hn)=>{"use strict";var{Buffer:sr}=b("buffer"),eu=Zl(),or=me()("mqttjs:ws"),Og=ei(),Ig=Ne().Transform,Rg=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],tu=typeof process<"u"&&process.title==="browser"||typeof __webpack_require__=="function";function ru(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 iu(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={}),!tu&&t.protocol==="wss"&&Rg.forEach(function(r){Object.prototype.hasOwnProperty.call(t,r)&&!Object.prototype.hasOwnProperty.call(t.wsOptions,r)&&(e.wsOptions[r]=t[r])}),e}function Ag(t){let e=iu(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 Bg(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 eu(e,[i],r.wsOptions)}function kg(t,e){let r=e.protocolId==="MQIsdp"&&e.protocolVersion===3?"mqttv3.1":"mqtt",i=ru(e,t),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}function Lg(t,e){or("streamBuilder");let r=iu(e),i=ru(r,t),n=Bg(t,i,r),s=eu.createWebSocketStream(n,r.wsOptions);return s.url=i,n.on("close",()=>{s.destroy()}),s}function Mg(t,e){or("browserStreamBuilder");let r,n=Ag(e).browserBufferSize||1024*512,s=e.browserBufferTimeout||1e3,o=!e.objectMode,a=kg(t,e),u=f(e,v,w);e.objectMode||(u._writev=y),u.on("close",()=>{a.close()});let l=typeof a.addEventListener<"u";a.readyState===a.OPEN?r=u:(r=r=Og(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(P,U,z){let W=new Ig({objectModeMode:P.objectMode});return W._write=U,W._flush=z,W}function h(){r.setReadable(u),r.setWritable(u),r.emit("connect")}function c(){r.end(),r.destroy()}function d(P){r.destroy(P)}function m(P){let U=P.data;U instanceof ArrayBuffer?U=sr.from(U):U=sr.from(U,"utf8"),u.push(U)}function y(P,U){let z=new Array(P.length);for(let W=0;W<P.length;W++)typeof P[W].chunk=="string"?z[W]=sr.from(P[W],"utf8"):z[W]=P[W].chunk;this._write(sr.concat(z),"binary",U)}function v(P,U,z){a.bufferedAmount>n&&setTimeout(v,s,P,U,z),o&&typeof P=="string"&&(P=sr.from(P,"utf8"));try{a.send(P)}catch(W){return z(W)}z()}function w(P){a.close(),P()}return r}tu?Hn.exports=Mg:Hn.exports=Lg});var au=g((Vm,ar)=>{"use strict";var su=cn(),qg=Ir(),Ng=b("url"),Dg=dr(),nu=me()("mqttjs"),te={};typeof process<"u"&&process.title!=="browser"||typeof __webpack_require__!="function"?(te.mqtt=hn(),te.tcp=hn(),te.ssl=Xr(),te.tls=Xr(),te.mqtts=Xr()):(te.wx=gn(),te.wxs=gn(),te.ali=_n(),te.alis=_n());te.ws=Kn();te.wss=Kn();function Ug(t){let e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function ou(t,e){if(nu("connecting to an MQTT broker..."),typeof t=="object"&&!e&&(e=t,t=null),e=e||{},t){let n=Ng.parse(t,!0);if(n.port!=null&&(n.port=Number(n.port)),e=Dg(n,e),e.protocol===null)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(Ug(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(!te[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 te[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++),nu("calling streambuilder for",e.protocol),te[e.protocol](n,e)}let i=new su(r,e);return i.on("error",function(){}),i}ar.exports=ou;ar.exports.connect=ou;ar.exports.MqttClient=su;ar.exports.Store=qg});var uu=g((Hm,lu)=>{"use strict";var jg=Xi().NumberAllocator;function Ye(){if(!(this instanceof Ye))return new Ye;this.numberAllocator=new jg(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()};lu.exports=Ye});var cu=g((Km,pt)=>{"use strict";var fu=cn(),Fg=au(),Wg=Ir(),Vg=ln(),Hg=uu();pt.exports.connect=Fg;pt.exports.MqttClient=fu;pt.exports.Client=fu;pt.exports.Store=Wg;pt.exports.DefaultMessageIdProvider=Vg;pt.exports.UniqueMessageIdProvider=Hg});import Qg from"async-mqtt";import{join as Eu}from"path";import{existsSync as xu}from"fs";import{promises as Tu}from"fs";var{readFile:Cu,writeFile:Pu}=Tu,ee=class t{static file=Eu(process.env.HOME||"~",".vestaboard2mqtt");namespace;static currentFetch;static currentData={};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(xu(this.file))try{let e=await Cu(this.file,{encoding:"utf8"});this.currentData=JSON.parse(e)}catch(e){console.warn(`Unable to parse cache file: ${e}`)}}static isCacheItemObject(e){return typeof e=="object"&&typeof e.updated=="number"&&typeof e.value<"u"}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}`)})}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}`)}))}static async save(){await Pu(this.file,JSON.stringify(this.currentData,null," "))}};var L=class{static cache=new ee("config");static data;static get loaded(){return!!this.data&&!!this.cache}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 mqtt(){if(this.loaded&&this.data?.mqtt)return this.data.mqtt;throw new Error("Unable to access mqtt 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 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 xv=wu(cu(),1);import{characterCode as hu,emptyBoard as Kg,LINE_LENGTH as zn}from"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]]],ge=class t{board;currentLine=null;isFilled=!1;constructor(e=t.newBoardCharArray()){this.board=e}static newBoardCharArray(){return JSON.parse(JSON.stringify(Kg))}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,lastLine:this.board.length-1,firstRow:r.row||0,lastRow:zn-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]}static word2chars(e){let r=[];for(let i of e)r.push(...this.char2char(i));return r}static char2char(e){let r=Object.entries(hu).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]}repeat(e,r={}){this.board[r.line||0].fill(t.char2char(e)[0])}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)})}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))})}}isEmpty(){return!this.board.find(e=>e.find(r=>r!==0))}toString(){return"#="+"=".repeat(zn*2)+`=#
|
|
11
|
+
`+r)),t.removeListener("error",Vn),t.destroy()}function Sg(t){return t.trim()}});var Zl=g((Mm,Jl)=>{"use strict";var nr=jn();nr.createWebSocketStream=zl();nr.Server=Xl();nr.Receiver=Pn();nr.Sender=In();Jl.exports=nr});var Kn=g((qm,Hn)=>{"use strict";var{Buffer:sr}=b("buffer"),eu=Zl(),or=me()("mqttjs:ws"),Eg=ei(),xg=Ne().Transform,Tg=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],tu=typeof process<"u"&&process.title==="browser"||typeof __webpack_require__=="function";function ru(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 iu(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={}),!tu&&t.protocol==="wss"&&Tg.forEach(function(r){Object.prototype.hasOwnProperty.call(t,r)&&!Object.prototype.hasOwnProperty.call(t.wsOptions,r)&&(e.wsOptions[r]=t[r])}),e}function Cg(t){let e=iu(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 Pg(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 eu(e,[i],r.wsOptions)}function Og(t,e){let r=e.protocolId==="MQIsdp"&&e.protocolVersion===3?"mqttv3.1":"mqtt",i=ru(e,t),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}function Ig(t,e){or("streamBuilder");let r=iu(e),i=ru(r,t),n=Pg(t,i,r),s=eu.createWebSocketStream(n,r.wsOptions);return s.url=i,n.on("close",()=>{s.destroy()}),s}function Rg(t,e){or("browserStreamBuilder");let r,n=Cg(e).browserBufferSize||1024*512,s=e.browserBufferTimeout||1e3,o=!e.objectMode,a=Og(t,e),u=f(e,v,w);e.objectMode||(u._writev=y),u.on("close",()=>{a.close()});let l=typeof a.addEventListener<"u";a.readyState===a.OPEN?r=u:(r=r=Eg(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(P,U,z){let W=new xg({objectModeMode:P.objectMode});return W._write=U,W._flush=z,W}function h(){r.setReadable(u),r.setWritable(u),r.emit("connect")}function c(){r.end(),r.destroy()}function d(P){r.destroy(P)}function m(P){let U=P.data;U instanceof ArrayBuffer?U=sr.from(U):U=sr.from(U,"utf8"),u.push(U)}function y(P,U){let z=new Array(P.length);for(let W=0;W<P.length;W++)typeof P[W].chunk=="string"?z[W]=sr.from(P[W],"utf8"):z[W]=P[W].chunk;this._write(sr.concat(z),"binary",U)}function v(P,U,z){a.bufferedAmount>n&&setTimeout(v,s,P,U,z),o&&typeof P=="string"&&(P=sr.from(P,"utf8"));try{a.send(P)}catch(W){return z(W)}z()}function w(P){a.close(),P()}return r}tu?Hn.exports=Rg:Hn.exports=Ig});var au=g((Nm,ar)=>{"use strict";var su=cn(),Ag=Ir(),Bg=b("url"),kg=dr(),nu=me()("mqttjs"),ee={};typeof process<"u"&&process.title!=="browser"||typeof __webpack_require__!="function"?(ee.mqtt=hn(),ee.tcp=hn(),ee.ssl=Xr(),ee.tls=Xr(),ee.mqtts=Xr()):(ee.wx=gn(),ee.wxs=gn(),ee.ali=_n(),ee.alis=_n());ee.ws=Kn();ee.wss=Kn();function Lg(t){let e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function ou(t,e){if(nu("connecting to an MQTT broker..."),typeof t=="object"&&!e&&(e=t,t=null),e=e||{},t){let n=Bg.parse(t,!0);if(n.port!=null&&(n.port=Number(n.port)),e=kg(n,e),e.protocol===null)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(Lg(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++),nu("calling streambuilder for",e.protocol),ee[e.protocol](n,e)}let i=new su(r,e);return i.on("error",function(){}),i}ar.exports=ou;ar.exports.connect=ou;ar.exports.MqttClient=su;ar.exports.Store=Ag});var uu=g((Dm,lu)=>{"use strict";var Mg=Xi().NumberAllocator;function Ye(){if(!(this instanceof Ye))return new Ye;this.numberAllocator=new Mg(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()};lu.exports=Ye});var cu=g((Um,pt)=>{"use strict";var fu=cn(),qg=au(),Ng=Ir(),Dg=ln(),Ug=uu();pt.exports.connect=qg;pt.exports.MqttClient=fu;pt.exports.Client=fu;pt.exports.Store=Ng;pt.exports.DefaultMessageIdProvider=Dg;pt.exports.UniqueMessageIdProvider=Ug});var Sv=wu(cu(),1);import Qg from"async-mqtt";import{Vesta as Yg}from"vestaboard-api";import{existsSync as jg}from"fs";import{promises as Fg}from"fs";import{join as Wg}from"path";var{readFile:Vg,writeFile:Hg}=Fg,te=class t{static currentData={};static currentFetch;static file=Wg(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(jg(this.file))try{let e=await Vg(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 Hg(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 L=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))}};import{characterCode as hu,emptyBoard as Kg,LINE_LENGTH as zn}from"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]]],ge=class t{board;currentLine=null;isFilled=!1;constructor(e=t.newBoardCharArray()){this.board=e}static char2char(e){let r=Object.entries(hu).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(hu).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(Kg))}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(zn*2)+`=#
|
|
12
12
|
`+this.board.map(e=>"# "+e.map(r=>t.charToString(r)).join("")+` #
|
|
13
13
|
`).join("")+"#="+"=".repeat(zn*2)+`=#
|
|
14
|
-
`}
|
|
15
|
-
`).forEach(i=>{r.write(i,{line:"NEXT"})}),r.centerLines(),r.center(),{message:r}}};
|
|
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:zn-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]}};import $g from"node-ical";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 ge,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 $g.async.fromURL(e);r=Object.values(i).filter(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 ge,i=e.calendars.map(o=>L.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 ge;return e.split(`
|
|
15
|
+
`).forEach(i=>{r.write(i,{line:"NEXT"})}),r.centerLines(),r.center(),{message:r}}};var Gg={calendar:new lr,message:new ur,today:new gt},fr=Gg;var $n=class t{board;currentMessage;currentTimer;mqtt;pageConfig=new te("page-config");subscriptionIds;constructor(){this.board=new Yg({apiKey:L.board.key,apiSecret:L.board.secret}),this.mqtt=Qg.connect(L.mqtt.url,{will:{payload:"offline",qos:0,retain:!0,topic:L.mqtt.prefix+"/status"}}),this.mqtt.on("connect",()=>{this.mqtt.publish(L.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 L.load(),new t}debug(e){let r=String(e);this.mqtt.publish(L.mqtt.prefix+"/debug",r),console.log(r)}async handleMessage(e,r){if(![L.mqtt.prefix+"/debug",L.mqtt.prefix+"/status"].includes(e))if(e===L.mqtt.prefix+"/disabled"){let i=["1","true","TRUE"].includes(r);await L.updateDisabled(i),i||(this.debug("Board not disabled anymore, update with latest message"),await this.updateCurrentMessage())}else if(Object.keys(fr).map(i=>L.mqtt.prefix+"/"+i).includes(e)){let i=fr[e.substr(L.mqtt.prefix.length+1)];await this.renderMessage(i,r)}else{let i=Object.entries(fr).find(([u])=>e.startsWith(L.mqtt.prefix+"/"+u+"/"));if(!i){this.debug(`Unknown topic ${e}, I'm sorry`);return}let n=e.substr((L.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(L.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 ge){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
16
|
|
|
17
|
-
`+e.toString()),await Promise.all(this.subscriptionIds.map(i=>this.board.postMessage(i,r)))}};export{$n as a};
|
|
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(L.mqtt.prefix+"/#")}async updateCurrentMessage(){this.currentMessage&&await this.renderMessage(this.currentMessage.page,this.currentMessage.payload)}};export{$n as a};
|
|
18
18
|
/*! Bundled license information:
|
|
19
19
|
|
|
20
20
|
safe-buffer/index.js:
|
|
21
21
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
22
22
|
*/
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-JCVHJVDZ.js.map
|