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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`async-mqtt`);l=c(l,1);let u=require(`vestaboard-api`),d=require(`fs`),f=require(`path`),p=require(`vestaboard-api/lib/cjs/values.js`),m=require(`node-ical`);m=c(m,1);var h=o(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),g=o(((e,t)=>{t.exports=require(`stream`)})),_=o(((e,t)=>{function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t];t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var c=require(`buffer`).Buffer,l=require(`util`).inspect,u=l&&l.custom||`inspect`;function d(e,t,n){c.prototype.copy.call(e,t,n)}t.exports=function(){function e(){a(this,e),this.head=null,this.tail=null,this.length=0}return s(e,[{key:`push`,value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:`unshift`,value:function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:`shift`,value:function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:`clear`,value:function(){this.head=this.tail=null,this.length=0}},{key:`join`,value:function(e){if(this.length===0)return``;for(var t=this.head,n=``+t.data;t=t.next;)n+=e+t.data;return n}},{key:`concat`,value:function(e){if(this.length===0)return c.alloc(0);for(var t=c.allocUnsafe(e>>>0),n=this.head,r=0;n;)d(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:`consume`,value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:`first`,value:function(){return this.head.data}},{key:`_getString`,value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),e-=a,e===0){a===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(a));break}++n}return this.length-=n,r}},{key:`_getBuffer`,value:function(e){var t=c.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),e-=a,e===0){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:u,value:function(e,t){return l(this,r({},t,{depth:0,customInspect:!1}))}}]),e}()})),v=o(((e,t)=>{function n(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(o,this,e)):process.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?process.nextTick(i,n):(n._writableState.errorEmitted=!0,process.nextTick(r,n,e)):process.nextTick(r,n,e):t?(process.nextTick(i,n),t(e)):process.nextTick(i,n)}),this)}function r(e,t){o(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(`close`)}function a(){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 o(e,t){e.emit(`error`,t)}function s(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit(`error`,t)}t.exports={destroy:n,undestroy:a,errorOrDestroy:s}})),y=o(((e,t)=>{let n={};function r(e,t,r){r||=Error;function i(e,n,r){return typeof t==`string`?t:t(e,n,r)}class a extends r{constructor(e,t,n){super(i(e,t,n))}}a.prototype.name=r.name,a.prototype.code=e,n[e]=a}function i(e,t){if(Array.isArray(e)){let n=e.length;return e=e.map(e=>String(e)),n>2?`one of ${t} ${e.slice(0,n-1).join(`, `)}, or `+e[n-1]:n===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}else return`of ${t} ${String(e)}`}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function o(e,t,n){return(n===void 0||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function s(e,t,n){return typeof n!=`number`&&(n=0),n+t.length>e.length?!1:e.indexOf(t,n)!==-1}r(`ERR_INVALID_OPT_VALUE`,function(e,t){return`The value "`+t+`" is invalid for option "`+e+`"`},TypeError),r(`ERR_INVALID_ARG_TYPE`,function(e,t,n){let r;typeof t==`string`&&a(t,`not `)?(r=`must not be`,t=t.replace(/^not /,``)):r=`must be`;let c;return c=o(e,` argument`)?`The ${e} ${r} ${i(t,`type`)}`:`The "${e}" ${s(e,`.`)?`property`:`argument`} ${r} ${i(t,`type`)}`,c+=`. Received type ${typeof n}`,c},TypeError),r(`ERR_STREAM_PUSH_AFTER_EOF`,`stream.push() after EOF`),r(`ERR_METHOD_NOT_IMPLEMENTED`,function(e){return`The `+e+` method is not implemented`}),r(`ERR_STREAM_PREMATURE_CLOSE`,`Premature close`),r(`ERR_STREAM_DESTROYED`,function(e){return`Cannot call `+e+` after a stream was destroyed`}),r(`ERR_MULTIPLE_CALLBACK`,`Callback called multiple times`),r(`ERR_STREAM_CANNOT_PIPE`,`Cannot pipe, not readable`),r(`ERR_STREAM_WRITE_AFTER_END`,`write after end`),r(`ERR_STREAM_NULL_VALUES`,`May not write null values to stream`,TypeError),r(`ERR_UNKNOWN_ENCODING`,function(e){return`Unknown encoding: `+e},TypeError),r(`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,`stream.unshift() after end event`),t.exports.codes=n})),b=o(((e,t)=>{var n=y().codes.ERR_INVALID_OPT_VALUE;function r(e,t,n){return e.highWaterMark==null?t?e[n]:null:e.highWaterMark}function i(e,t,i,a){var o=r(t,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(a?i:`highWaterMark`,o);return Math.floor(o)}return e.objectMode?16:16*1024}t.exports={getHighWaterMark:i}})),x=o(((e,t)=>{typeof Object.create==`function`?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),S=o(((e,t)=>{try{var n=require(`util`);if(typeof n.inherits!=`function`)throw``;t.exports=n.inherits}catch{t.exports=x()}})),C=o(((e,t)=>{t.exports=require(`util`).deprecate})),w=o(((e,t)=>{t.exports=M;function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){q(t,e)}}var r;M.WritableState=A;var i={deprecate:C()},a=g(),o=require(`buffer`).Buffer,s=global.Uint8Array||function(){};function c(e){return o.from(e)}function l(e){return o.isBuffer(e)||e instanceof s}var u=v(),d=b().getHighWaterMark,f=y().codes,p=f.ERR_INVALID_ARG_TYPE,m=f.ERR_METHOD_NOT_IMPLEMENTED,h=f.ERR_MULTIPLE_CALLBACK,_=f.ERR_STREAM_CANNOT_PIPE,x=f.ERR_STREAM_DESTROYED,w=f.ERR_STREAM_NULL_VALUES,E=f.ERR_STREAM_WRITE_AFTER_END,D=f.ERR_UNKNOWN_ENCODING,O=u.errorOrDestroy;S()(M,a);function k(){}function A(e,t,i){r||=T(),e||={},typeof i!=`boolean`&&(i=t instanceof r),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=d(this,e,`writableHighWaterMark`,i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=e.decodeStrings===!1;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){z(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(A.prototype,`buffer`,{get:i.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var j;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(j=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(e){return j.call(this,e)?!0:this===M?e&&e._writableState instanceof A:!1}})):j=function(e){return e instanceof this};function M(e){r||=T();var t=this instanceof r;if(!t&&!j.call(M,this))return new M(e);this._writableState=new A(e,this,t),this.writable=!0,e&&(typeof e.write==`function`&&(this._write=e.write),typeof e.writev==`function`&&(this._writev=e.writev),typeof e.destroy==`function`&&(this._destroy=e.destroy),typeof e.final==`function`&&(this._final=e.final)),a.call(this)}M.prototype.pipe=function(){O(this,new _)};function N(e,t){var n=new E;O(e,n),process.nextTick(t,n)}function ee(e,t,n,r){var i;return n===null?i=new w:typeof n!=`string`&&!t.objectMode&&(i=new p(`chunk`,[`string`,`Buffer`],n)),i?(O(e,i),process.nextTick(r,i),!1):!0}M.prototype.write=function(e,t,n){var r=this._writableState,i=!1,a=!r.objectMode&&l(e);return a&&!o.isBuffer(e)&&(e=c(e)),typeof t==`function`&&(n=t,t=null),a?t=`buffer`:t||=r.defaultEncoding,typeof n!=`function`&&(n=k),r.ending?N(this,n):(a||ee(this,r,e,n))&&(r.pendingcb++,i=F(this,r,a,e,t,n)),i},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&H(this,e))},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 D(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(M.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function P(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=o.from(t,n)),t}Object.defineProperty(M.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function F(e,t,n,r,i,a){if(!n){var o=P(t,r,i);r!==o&&(n=!0,i=`buffer`,r=o)}var s=t.objectMode?1:r.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else I(e,t,!1,s,r,i,a);return c}function I(e,t,n,r,i,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new x(`write`)):n?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function L(e,t,n,r,i){--t.pendingcb,n?(process.nextTick(i,r),process.nextTick(K,e,t),e._writableState.errorEmitted=!0,O(e,r)):(i(r),e._writableState.errorEmitted=!0,O(e,r),K(e,t))}function R(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function z(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new h;if(R(n),t)L(e,n,r,t,i);else{var a=U(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&H(e,n),r?process.nextTick(B,e,n,a,i):B(e,n,a,i)}}function B(e,t,n,r){n||V(e,t),t.pendingcb--,r(),K(e,t)}function V(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function H(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,a=Array(i),o=t.corkedRequestsFree;o.entry=r;for(var s=0,c=!0;r;)a[s]=r,r.isBuf||(c=!1),r=r.next,s+=1;a.allBuffers=c,I(e,t,!0,t.length,a,``,o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new n(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,u=r.encoding,d=r.callback;if(I(e,t,!1,t.objectMode?1:l.length,l,u,d),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}M.prototype._write=function(e,t,n){n(new m(`_write()`))},M.prototype._writev=null,M.prototype.end=function(e,t,n){var r=this._writableState;return typeof e==`function`?(n=e,e=null,t=null):typeof t==`function`&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||te(this,r,n),this},Object.defineProperty(M.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function U(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function W(e,t){e._final(function(n){t.pendingcb--,n&&O(e,n),t.prefinished=!0,e.emit(`prefinish`),K(e,t)})}function G(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,process.nextTick(W,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function K(e,t){var n=U(t);if(n&&(G(e,t),t.pendingcb===0&&(t.finished=!0,e.emit(`finish`),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function te(e,t,n){t.ending=!0,K(e,t),n&&(t.finished?process.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function q(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}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=u.destroy,M.prototype._undestroy=u.undestroy,M.prototype._destroy=function(e,t){t(e)}})),T=o(((e,t)=>{var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=c;var r=j(),i=w();S()(c,r);for(var a=n(i.prototype),o=0;o<a.length;o++){var s=a[o];c.prototype[s]||(c.prototype[s]=i.prototype[s])}function c(e){if(!(this instanceof c))return new c(e);r.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once(`end`,l)))}Object.defineProperty(c.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function l(){this._writableState.ended||process.nextTick(u,this)}function u(e){e.end()}Object.defineProperty(c.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)}})})),E=o(((e,t)=>{
2
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
3
+ var n=require(`buffer`),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),D=o((e=>{var t=E().Buffer,n=t.isEncoding||function(e){switch(e=``+e,e&&e.toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:case`raw`:return!0;default:return!1}};function r(e){if(!e)return`utf8`;for(var t;;)switch(e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:if(t)return;e=(``+e).toLowerCase(),t=!0}}function i(e){var i=r(e);if(typeof i!=`string`&&(t.isEncoding===n||!n(e)))throw Error(`Unknown encoding: `+e);return i||e}e.StringDecoder=a;function a(e){this.encoding=i(e);var n;switch(this.encoding){case`utf16le`:this.text=f,this.end=p,n=4;break;case`utf8`:this.fillLast=l,n=4;break;case`base64`:this.text=m,this.end=h,n=3;break;default:this.write=g,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}a.prototype.write=function(e){if(e.length===0)return``;var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return``;n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||``},a.prototype.end=d,a.prototype.text=u,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var i=o(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function c(e,t,n){if((t[0]&192)!=128)return e.lastNeed=0,`�`;if(e.lastNeed>1&&t.length>1){if((t[1]&192)!=128)return e.lastNeed=1,`�`;if(e.lastNeed>2&&t.length>2&&(t[2]&192)!=128)return e.lastNeed=2,`�`}}function l(e){var t=this.lastTotal-this.lastNeed,n=c(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function u(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString(`utf8`,t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString(`utf8`,t,r)}function d(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+`�`:t}function f(e,t){if((e.length-t)%2==0){var n=e.toString(`utf16le`,t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(`utf16le`,t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):``;if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(`utf16le`,0,n)}return t}function m(e,t){var n=(e.length-t)%3;return n===0?e.toString(`base64`,t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(`base64`,t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+this.lastChar.toString(`base64`,0,3-this.lastNeed):t}function g(e){return e.toString(this.encoding)}function _(e){return e&&e.length?this.write(e):``}})),O=o(((e,t)=>{var n=y().codes.ERR_STREAM_PREMATURE_CLOSE;function r(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}function i(){}function a(e){return e.setHeader&&typeof e.abort==`function`}function o(e,t,s){if(typeof t==`function`)return o(e,null,t);t||={},s=r(s||i);var c=t.readable||t.readable!==!1&&e.readable,l=t.writable||t.writable!==!1&&e.writable,u=function(){e.writable||f()},d=e._writableState&&e._writableState.finished,f=function(){l=!1,d=!0,c||s.call(e)},p=e._readableState&&e._readableState.endEmitted,m=function(){c=!1,p=!0,l||s.call(e)},h=function(t){s.call(e,t)},g=function(){var t;if(c&&!p)return(!e._readableState||!e._readableState.ended)&&(t=new n),s.call(e,t);if(l&&!d)return(!e._writableState||!e._writableState.ended)&&(t=new n),s.call(e,t)},_=function(){e.req.on(`finish`,f)};return a(e)?(e.on(`complete`,f),e.on(`abort`,g),e.req?_():e.on(`request`,_)):l&&!e._writableState&&(e.on(`end`,u),e.on(`close`,u)),e.on(`end`,m),e.on(`finish`,f),t.error!==!1&&e.on(`error`,h),e.on(`close`,g),function(){e.removeListener(`complete`,f),e.removeListener(`abort`,g),e.removeListener(`request`,_),e.req&&e.req.removeListener(`finish`,f),e.removeListener(`end`,u),e.removeListener(`close`,u),e.removeListener(`finish`,f),e.removeListener(`end`,m),e.removeListener(`error`,h),e.removeListener(`close`,g)}}t.exports=o})),k=o(((e,t)=>{var n;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=O(),a=Symbol(`lastResolve`),o=Symbol(`lastReject`),s=Symbol(`error`),c=Symbol(`ended`),l=Symbol(`lastPromise`),u=Symbol(`handlePromise`),d=Symbol(`stream`);function f(e,t){return{value:e,done:t}}function p(e){var t=e[a];if(t!==null){var n=e[d].read();n!==null&&(e[l]=null,e[a]=null,e[o]=null,t(f(n,!1)))}}function m(e){process.nextTick(p,e)}function h(e,t){return function(n,r){e.then(function(){if(t[c]){n(f(void 0,!0));return}t[u](n,r)},r)}}var g=Object.getPrototypeOf(function(){}),_=Object.setPrototypeOf((n={get stream(){return this[d]},next:function(){var e=this,t=this[s];if(t!==null)return Promise.reject(t);if(this[c])return Promise.resolve(f(void 0,!0));if(this[d].destroyed)return new Promise(function(t,n){process.nextTick(function(){e[s]?n(e[s]):t(f(void 0,!0))})});var n=this[l],r;if(n)r=new Promise(h(n,this));else{var i=this[d].read();if(i!==null)return Promise.resolve(f(i,!1));r=new Promise(this[u])}return this[l]=r,r}},r(n,Symbol.asyncIterator,function(){return this}),r(n,`return`,function(){var e=this;return new Promise(function(t,n){e[d].destroy(null,function(e){if(e){n(e);return}t(f(void 0,!0))})})}),n),g);t.exports=function(e){var t,n=Object.create(_,(t={},r(t,d,{value:e,writable:!0}),r(t,a,{value:null,writable:!0}),r(t,o,{value:null,writable:!0}),r(t,s,{value:null,writable:!0}),r(t,c,{value:e._readableState.endEmitted,writable:!0}),r(t,u,{value:function(e,t){var r=n[d].read();r?(n[l]=null,n[a]=null,n[o]=null,e(f(r,!1))):(n[a]=e,n[o]=t)},writable:!0}),t));return n[l]=null,i(e,function(e){if(e&&e.code!==`ERR_STREAM_PREMATURE_CLOSE`){var t=n[o];t!==null&&(n[l]=null,n[a]=null,n[o]=null,t(e)),n[s]=e;return}var r=n[a];r!==null&&(n[l]=null,n[a]=null,n[o]=null,r(f(void 0,!0))),n[c]=!0}),e.on(`readable`,m.bind(null,n)),n}})),A=o(((e,t)=>{function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,`next`,e)}function c(e){n(o,i,a,s,c,`throw`,e)}s(void 0)})}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=y().codes.ERR_INVALID_ARG_TYPE;function c(e,t,n){var i;if(t&&typeof t.next==`function`)i=t;else if(t&&t[Symbol.asyncIterator])i=t[Symbol.asyncIterator]();else if(t&&t[Symbol.iterator])i=t[Symbol.iterator]();else throw new s(`iterable`,[`Iterable`],t);var o=new e(a({objectMode:!0},n)),c=!1;o._read=function(){c||(c=!0,l())};function l(){return u.apply(this,arguments)}function u(){return u=r(function*(){try{var e=yield i.next(),t=e.value;e.done?o.push(null):o.push(yield t)?l():c=!1}catch(e){o.destroy(e)}}),u.apply(this,arguments)}return o}t.exports=c})),j=o(((e,t)=>{t.exports=F;var n;F.ReadableState=P,require(`events`).EventEmitter;var r=function(e,t){return e.listeners(t).length},i=g(),a=require(`buffer`).Buffer,o=global.Uint8Array||function(){};function s(e){return a.from(e)}function c(e){return a.isBuffer(e)||e instanceof o}var l=require(`util`),u=l&&l.debuglog?l.debuglog(`stream`):function(){},d=_(),f=v(),p=b().getHighWaterMark,m=y().codes,h=m.ERR_INVALID_ARG_TYPE,x=m.ERR_STREAM_PUSH_AFTER_EOF,C=m.ERR_METHOD_NOT_IMPLEMENTED,w=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,E,O,j;S()(F,i);var M=f.errorOrDestroy,N=[`error`,`close`,`destroy`,`pause`,`resume`];function ee(e,t,n){if(typeof e.prependListener==`function`)return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function P(e,t,r){n||=T(),e||={},typeof r!=`boolean`&&(r=t instanceof n),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=p(this,e,`readableHighWaterMark`,r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(E||=D().StringDecoder,this.decoder=new E(e.encoding),this.encoding=e.encoding)}function F(e){if(n||=T(),!(this instanceof F))return new F(e);var t=this instanceof n;this._readableState=new P(e,this,t),this.readable=!0,e&&(typeof e.read==`function`&&(this._read=e.read),typeof e.destroy==`function`&&(this._destroy=e.destroy)),i.call(this)}Object.defineProperty(F.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),F.prototype.destroy=f.destroy,F.prototype._undestroy=f.undestroy,F.prototype._destroy=function(e,t){t(e)},F.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:typeof e==`string`&&(t||=n.defaultEncoding,t!==n.encoding&&(e=a.from(e,t),t=``),r=!0),I(this,e,t,!1,r)},F.prototype.unshift=function(e){return I(this,e,null,!0,!1)};function I(e,t,n,r,i){u(`readableAddChunk`,t);var o=e._readableState;if(t===null)o.reading=!1,H(e,o);else{var c;if(i||(c=R(o,t)),c)M(e,c);else if(o.objectMode||t&&t.length>0)if(typeof t!=`string`&&!o.objectMode&&Object.getPrototypeOf(t)!==a.prototype&&(t=s(t)),r)o.endEmitted?M(e,new w):L(e,o,t,!0);else if(o.ended)M(e,new x);else if(o.destroyed)return!1;else o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||t.length!==0?L(e,o,t,!1):G(e,o)):L(e,o,t,!1);else r||(o.reading=!1,G(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function L(e,t,n,r){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit(`data`,n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&U(e)),G(e,t)}function R(e,t){var n;return!c(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new h(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}F.prototype.isPaused=function(){return this._readableState.flowing===!1},F.prototype.setEncoding=function(e){E||=D().StringDecoder;var t=new E(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r=``;n!==null;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),r!==``&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var z=1073741824;function B(e){return e>=z?e=z:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function V(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=B(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}F.prototype.read=function(e){u(`read`,e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark===0?t.length>0:t.length>=t.highWaterMark)||t.ended))return u(`read: emitReadable`,t.length,t.ended),t.length===0&&t.ended?Y(this):U(this),null;if(e=V(e,t),e===0&&t.ended)return t.length===0&&Y(this),null;var r=t.needReadable;u(`need readable`,r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,u(`length less than watermark`,r)),t.ended||t.reading?(r=!1,u(`reading or ended`,r)):r&&(u(`do read`),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=V(n,t)));var i=e>0?ae(e,t):null;return i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&Y(this)),i!==null&&this.emit(`data`,i),i};function H(e,t){if(u(`onEofChunk`),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?U(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,W(e)))}}function U(e){var t=e._readableState;u(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u(`emitReadable`,t.flowing),t.emittedReadable=!0,process.nextTick(W,e))}function W(e){var t=e._readableState;u(`emitReadable_`,t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit(`readable`),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,J(e)}function G(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(K,e,t))}function K(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var n=t.length;if(u(`maybeReadMore read 0`),e.read(0),n===t.length)break}t.readingMore=!1}F.prototype._read=function(e){M(this,new C(`_read()`))},F.prototype.pipe=function(e,t){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,u(`pipe count=%d opts=%j`,i.pipesCount,t);var a=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr?s:g;i.endEmitted?process.nextTick(a):n.once(`end`,a),e.on(`unpipe`,o);function o(e,t){u(`onunpipe`),e===n&&t&&t.hasUnpiped===!1&&(t.hasUnpiped=!0,d())}function s(){u(`onend`),e.end()}var c=te(n);e.on(`drain`,c);var l=!1;function d(){u(`cleanup`),e.removeListener(`close`,m),e.removeListener(`finish`,h),e.removeListener(`drain`,c),e.removeListener(`error`,p),e.removeListener(`unpipe`,o),n.removeListener(`end`,s),n.removeListener(`end`,g),n.removeListener(`data`,f),l=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}n.on(`data`,f);function f(t){u(`ondata`);var r=e.write(t);u(`dest.write`,r),r===!1&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&se(i.pipes,e)!==-1)&&!l&&(u(`false write response, pause`,i.awaitDrain),i.awaitDrain++),n.pause())}function p(t){u(`onerror`,t),g(),e.removeListener(`error`,p),r(e,`error`)===0&&M(e,t)}ee(e,`error`,p);function m(){e.removeListener(`finish`,h),g()}e.once(`close`,m);function h(){u(`onfinish`),e.removeListener(`close`,m),g()}e.once(`finish`,h);function g(){u(`unpipe`),n.unpipe(e)}return e.emit(`pipe`,n),i.flowing||(u(`pipe resume`),n.resume()),e};function te(e){return function(){var t=e._readableState;u(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&r(e,`data`)&&(t.flowing=!0,J(e))}}F.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||=t.pipes,t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit(`unpipe`,this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)r[a].emit(`unpipe`,this,{hasUnpiped:!1});return this}var o=se(t.pipes,e);return o===-1?this:(t.pipes.splice(o,1),--t.pipesCount,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit(`unpipe`,this,n),this)},F.prototype.on=function(e,t){var n=i.prototype.on.call(this,e,t),r=this._readableState;return e===`data`?(r.readableListening=this.listenerCount(`readable`)>0,r.flowing!==!1&&this.resume()):e===`readable`&&!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,u(`on readable`,r.length,r.reading),r.length?U(this):r.reading||process.nextTick(ne,this)),n},F.prototype.addListener=F.prototype.on,F.prototype.removeListener=function(e,t){var n=i.prototype.removeListener.call(this,e,t);return e===`readable`&&process.nextTick(q,this),n},F.prototype.removeAllListeners=function(e){var t=i.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&process.nextTick(q,this),t};function q(e){var t=e._readableState;t.readableListening=e.listenerCount(`readable`)>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount(`data`)>0&&e.resume()}function ne(e){u(`readable nexttick read 0`),e.read(0)}F.prototype.resume=function(){var e=this._readableState;return e.flowing||(u(`resume`),e.flowing=!e.readableListening,re(this,e)),e.paused=!1,this};function re(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(ie,e,t))}function ie(e,t){u(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),J(e),t.flowing&&!t.reading&&e.read(0)}F.prototype.pause=function(){return u(`call pause flowing=%j`,this._readableState.flowing),this._readableState.flowing!==!1&&(u(`pause`),this._readableState.flowing=!1,this.emit(`pause`)),this._readableState.paused=!0,this};function J(e){var t=e._readableState;for(u(`flow`,t.flowing);t.flowing&&e.read()!==null;);}F.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(`end`,function(){if(u(`wrapped end`),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on(`data`,function(i){u(`wrapped data`),n.decoder&&(i=n.decoder.write(i)),!(n.objectMode&&i==null)&&(!n.objectMode&&(!i||!i.length)||t.push(i)||(r=!0,e.pause()))}),e)this[i]===void 0&&typeof e[i]==`function`&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<N.length;a++)e.on(N[a],this.emit.bind(this,N[a]));return this._read=function(t){u(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(F.prototype[Symbol.asyncIterator]=function(){return O===void 0&&(O=k()),O(this)}),Object.defineProperty(F.prototype,`readableHighWaterMark`,{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(F.prototype,`readableBuffer`,{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(F.prototype,`readableFlowing`,{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),F._fromList=ae,Object.defineProperty(F.prototype,`readableLength`,{enumerable:!1,get:function(){return this._readableState.length}});function ae(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(``):t.buffer.length===1?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function Y(e){var t=e._readableState;u(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(oe,t,e))}function oe(e,t){if(u(`endReadableNT`,e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit(`end`),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}typeof Symbol==`function`&&(F.from=function(e,t){return j===void 0&&(j=A()),j(F,e,t)});function se(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),M=o(((e,t)=>{t.exports=l;var n=y().codes,r=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=n.ERR_TRANSFORM_WITH_LENGTH_0,s=T();S()(l,s);function c(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(r===null)return this.emit(`error`,new i);n.writechunk=null,n.writecb=null,t!=null&&this.push(t),r(e);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);s.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform==`function`&&(this._transform=e.transform),typeof e.flush==`function`&&(this._flush=e.flush)),this.on(`prefinish`,u)}function u(){var e=this;typeof this._flush==`function`&&!this._readableState.destroyed?this._flush(function(t,n){d(e,t,n)}):d(this,null,null)}l.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new r(`_transform()`))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},l.prototype._destroy=function(e,t){s.prototype._destroy.call(this,e,function(e){t(e)})};function d(e,t,n){if(t)return e.emit(`error`,t);if(n!=null&&e.push(n),e._writableState.length)throw new o;if(e._transformState.transforming)throw new a;return e.push(null)}})),N=o(((e,t)=>{t.exports=r;var n=M();S()(r,n);function r(e){if(!(this instanceof r))return new r(e);n.call(this,e)}r.prototype._transform=function(e,t,n){n(null,e)}})),ee=o(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=y().codes,a=i.ERR_MISSING_ARGS,o=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function c(e){return e.setHeader&&typeof e.abort==`function`}function l(e,t,i,a){a=r(a);var s=!1;e.on(`close`,function(){s=!0}),n===void 0&&(n=O()),n(e,{readable:t,writable:i},function(e){if(e)return a(e);s=!0,a()});var l=!1;return function(t){if(!s&&!l){if(l=!0,c(e))return e.abort();if(typeof e.destroy==`function`)return e.destroy();a(t||new o(`pipe`))}}}function u(e){e()}function d(e,t){return e.pipe(t)}function f(e){return!e.length||typeof e[e.length-1]!=`function`?s:e.pop()}function p(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new a(`streams`);var i,o=t.map(function(e,n){var a=n<t.length-1;return l(e,a,n>0,function(e){i||=e,e&&o.forEach(u),!a&&(o.forEach(u),r(i))})});return t.reduce(d)}t.exports=p})),P=o(((e,t)=>{var n=require(`stream`);process.env.READABLE_STREAM===`disable`&&n?(t.exports=n.Readable,Object.assign(t.exports,n),t.exports.Stream=n):(e=t.exports=j(),e.Stream=n||e,e.Readable=e,e.Writable=w(),e.Duplex=T(),e.Transform=M(),e.PassThrough=N(),e.finished=O(),e.pipeline=ee())})),F=o(((e,t)=>{let n=h(),r=P().Readable,i={objectMode:!0},a={clean:!0};function o(e){if(!(this instanceof o))return new o(e);this.options=e||{},this.options=n(a,e),this._inflights=new Map}o.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},o.prototype.createStream=function(){let e=new r(i),t=[],n=!1,a=0;return this._inflights.forEach(function(e,n){t.push(e)}),e._read=function(){!n&&a<t.length?this.push(t[a++]):this.push(null)},e.destroy=function(){if(n)return;let e=this;n=!0,setTimeout(function(){e.emit(`close`)},0)},e},o.prototype.del=function(e,t){return e=this._inflights.get(e.messageId),e?(this._inflights.delete(e.messageId),t(null,e)):t&&t(Error(`missing packet`)),this},o.prototype.get=function(e,t){return e=this._inflights.get(e.messageId),e?t(null,e):t&&t(Error(`missing packet`)),this},o.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=o})),I=o(((e,t)=>{function n(e){if(!(this instanceof n))return new n(e);this.aliasToTopic={},this.max=e}n.prototype.put=function(e,t){return t===0||t>this.max?!1:(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,!0)},n.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},n.prototype.clear=function(){this.aliasToTopic={}},t.exports=n})),L=o(((e,t)=>{t.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}})),R=o(((e,t)=>{t.exports=n,n.Node=o,n.create=n;function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&typeof e.forEach==`function`)e.forEach(function(e){t.push(e)});else if(arguments.length>0)for(var r=0,i=arguments.length;r<i;r++)t.push(arguments[r]);return t}n.prototype.removeNode=function(e){if(e.list!==this)throw Error(`removing node which does not belong to this list`);var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},n.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||=e,this.length++}},n.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||=e,this.length++}},n.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},n.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)a(this,arguments[e]);return this.length},n.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},n.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},n.prototype.forEach=function(e,t){t||=this;for(var n=this.head,r=0;n!==null;r++)e.call(t,n.value,r,this),n=n.next},n.prototype.forEachReverse=function(e,t){t||=this;for(var n=this.tail,r=this.length-1;n!==null;r--)e.call(t,n.value,r,this),n=n.prev},n.prototype.get=function(e){for(var t=0,n=this.head;n!==null&&t<e;t++)n=n.next;if(t===e&&n!==null)return n.value},n.prototype.getReverse=function(e){for(var t=0,n=this.tail;n!==null&&t<e;t++)n=n.prev;if(t===e&&n!==null)return n.value},n.prototype.map=function(e,t){t||=this;for(var r=new n,i=this.head;i!==null;)r.push(e.call(t,i.value,this)),i=i.next;return r},n.prototype.mapReverse=function(e,t){t||=this;for(var r=new n,i=this.tail;i!==null;)r.push(e.call(t,i.value,this)),i=i.prev;return r},n.prototype.reduce=function(e,t){var n,r=this.head;if(arguments.length>1)n=t;else if(this.head)r=this.head.next,n=this.head.value;else throw TypeError(`Reduce of empty list with no initial value`);for(var i=0;r!==null;i++)n=e(n,r.value,i),r=r.next;return n},n.prototype.reduceReverse=function(e,t){var n,r=this.tail;if(arguments.length>1)n=t;else if(this.tail)r=this.tail.prev,n=this.tail.value;else throw TypeError(`Reduce of empty list with no initial value`);for(var i=this.length-1;r!==null;i--)n=e(n,r.value,i),r=r.prev;return n},n.prototype.toArray=function(){for(var e=Array(this.length),t=0,n=this.head;n!==null;t++)e[t]=n.value,n=n.next;return e},n.prototype.toArrayReverse=function(){for(var e=Array(this.length),t=0,n=this.tail;n!==null;t++)e[t]=n.value,n=n.prev;return e},n.prototype.slice=function(e,t){t||=this.length,t<0&&(t+=this.length),e||=0,e<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var i=0,a=this.head;a!==null&&i<e;i++)a=a.next;for(;a!==null&&i<t;i++,a=a.next)r.push(a.value);return r},n.prototype.sliceReverse=function(e,t){t||=this.length,t<0&&(t+=this.length),e||=0,e<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var i=this.length,a=this.tail;a!==null&&i>t;i--)a=a.prev;for(;a!==null&&i>e;i--,a=a.prev)r.push(a.value);return r},n.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var i=0,a=this.head;a!==null&&i<e;i++)a=a.next;for(var o=[],i=0;a&&i<t;i++)o.push(a.value),a=this.removeNode(a);a===null&&(a=this.tail),a!==this.head&&a!==this.tail&&(a=a.prev);for(var i=0;i<n.length;i++)a=r(this,a,n[i]);return o},n.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;n!==null;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=t,this.tail=e,this};function r(e,t,n){var r=t===e.head?new o(n,null,t,e):new o(n,t,t.next,e);return r.next===null&&(e.tail=r),r.prev===null&&(e.head=r),e.length++,r}function i(e,t){e.tail=new o(t,e.tail,null,e),e.head||=e.tail,e.length++}function a(e,t){e.head=new o(t,null,e.head,e),e.tail||=e.head,e.length++}function o(e,t,n,r){if(!(this instanceof o))return new o(e,t,n,r);this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}try{L()(n)}catch{}})),z=o(((e,t)=>{let n=R(),r=Symbol(`max`),i=Symbol(`length`),a=Symbol(`lengthCalculator`),o=Symbol(`allowStale`),s=Symbol(`maxAge`),c=Symbol(`dispose`),l=Symbol(`noDisposeOnSet`),u=Symbol(`lruList`),d=Symbol(`cache`),f=Symbol(`updateAgeOnGet`),p=()=>1;var m=class{constructor(e){if(typeof e==`number`&&(e={max:e}),e||={},e.max&&(typeof e.max!=`number`||e.max<0))throw TypeError(`max must be a non-negative number`);this[r]=e.max||1/0;let t=e.length||p;if(this[a]=typeof t==`function`?t:p,this[o]=e.stale||!1,e.maxAge&&typeof e.maxAge!=`number`)throw TypeError(`maxAge must be a number`);this[s]=e.maxAge||0,this[c]=e.dispose,this[l]=e.noDisposeOnSet||!1,this[f]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!=`number`||e<0)throw TypeError(`max must be a non-negative number`);this[r]=e||1/0,_(this)}get max(){return this[r]}set allowStale(e){this[o]=!!e}get allowStale(){return this[o]}set maxAge(e){if(typeof e!=`number`)throw TypeError(`maxAge must be a non-negative number`);this[s]=e,_(this)}get maxAge(){return this[s]}set lengthCalculator(e){typeof e!=`function`&&(e=p),e!==this[a]&&(this[a]=e,this[i]=0,this[u].forEach(e=>{e.length=this[a](e.value,e.key),this[i]+=e.length})),_(this)}get lengthCalculator(){return this[a]}get length(){return this[i]}get itemCount(){return this[u].length}rforEach(e,t){t||=this;for(let n=this[u].tail;n!==null;){let r=n.prev;b(this,e,n,t),n=r}}forEach(e,t){t||=this;for(let n=this[u].head;n!==null;){let r=n.next;b(this,e,n,t),n=r}}keys(){return this[u].toArray().map(e=>e.key)}values(){return this[u].toArray().map(e=>e.value)}reset(){this[c]&&this[u]&&this[u].length&&this[u].forEach(e=>this[c](e.key,e.value)),this[d]=new Map,this[u]=new n,this[i]=0}dump(){return this[u].map(e=>g(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[u]}set(e,t,n){if(n||=this[s],n&&typeof n!=`number`)throw TypeError(`maxAge must be a number`);let o=n?Date.now():0,f=this[a](t,e);if(this[d].has(e)){if(f>this[r])return v(this,this[d].get(e)),!1;let a=this[d].get(e).value;return this[c]&&(this[l]||this[c](e,a.value)),a.now=o,a.maxAge=n,a.value=t,this[i]+=f-a.length,a.length=f,this.get(e),_(this),!0}let p=new y(e,t,f,o,n);return p.length>this[r]?(this[c]&&this[c](e,t),!1):(this[i]+=p.length,this[u].unshift(p),this[d].set(e,this[u].head),_(this),!0)}has(e){if(!this[d].has(e))return!1;let t=this[d].get(e).value;return!g(this,t)}get(e){return h(this,e,!0)}peek(e){return h(this,e,!1)}pop(){let e=this[u].tail;return e?(v(this,e),e.value):null}del(e){v(this,this[d].get(e))}load(e){this.reset();let t=Date.now();for(let n=e.length-1;n>=0;n--){let r=e[n],i=r.e||0;if(i===0)this.set(r.k,r.v);else{let e=i-t;e>0&&this.set(r.k,r.v,e)}}}prune(){this[d].forEach((e,t)=>h(this,t,!1))}};let h=(e,t,n)=>{let r=e[d].get(t);if(r){let t=r.value;if(g(e,t)){if(v(e,r),!e[o])return}else n&&(e[f]&&(r.value.now=Date.now()),e[u].unshiftNode(r));return t.value}},g=(e,t)=>{if(!t||!t.maxAge&&!e[s])return!1;let n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[s]&&n>e[s]},_=e=>{if(e[i]>e[r])for(let t=e[u].tail;e[i]>e[r]&&t!==null;){let n=t.prev;v(e,t),t=n}},v=(e,t)=>{if(t){let n=t.value;e[c]&&e[c](n.key,n.value),e[i]-=n.length,e[d].delete(n.key),e[u].removeNode(t)}};var y=class{constructor(e,t,n,r,i){this.key=e,this.value=t,this.length=n,this.now=r,this.maxAge=i||0}};let b=(e,t,n,r)=>{let i=n.value;g(e,i)&&(v(e,n),e[o]||(i=void 0)),i&&t.call(r,i.value,i.key,e)};t.exports=m})),B=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Container=e.Base=e.ContainerIterator=void 0;var t=class e{constructor(t=e.NORMAL){this.iteratorType=t}};e.ContainerIterator=t,t.NORMAL=!1,t.REVERSE=!0;var n=class{constructor(){this.length=0}size(){return this.length}empty(){return this.length===0}};e.Base=n,e.Container=class extends n{}})),V=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=B();e.default=class extends t.Base{constructor(e=[]){super(),this.stack=[],e.forEach(e=>this.push(e))}clear(){this.length=0,this.stack.length=0}push(e){this.stack.push(e),this.length+=1}pop(){this.stack.pop(),this.length>0&&--this.length}top(){return this.stack[this.length-1]}}})),H=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=B();e.default=class extends t.Container{}})),U=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkWithinAccessParams=void 0;function t(e,t,n){if(e<t||e>n)throw RangeError()}e.checkWithinAccessParams=t})),W=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RandomIterator=void 0;let t=U(),n=B();e.RandomIterator=class extends n.ContainerIterator{constructor(e,t,r,i,a){super(a),this.node=e,this.size=t,this.getElementByPos=r,this.setElementByPos=i,this.iteratorType===n.ContainerIterator.NORMAL?(this.pre=function(){if(this.node===0)throw RangeError(`Deque iterator access denied!`);return--this.node,this},this.next=function(){if(this.node===this.size())throw RangeError(`Deque Iterator access denied!`);return this.node+=1,this}):(this.pre=function(){if(this.node===this.size()-1)throw RangeError(`Deque iterator access denied!`);return this.node+=1,this},this.next=function(){if(this.node===-1)throw RangeError(`Deque iterator access denied!`);return--this.node,this})}get pointer(){return(0,t.checkWithinAccessParams)(this.node,0,this.size()-1),this.getElementByPos(this.node)}set pointer(e){(0,t.checkWithinAccessParams)(this.node,0,this.size()-1),this.setElementByPos(this.node,e)}equals(e){return this.node===e.node}}})),G=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.DequeIterator=void 0;let n=t(H()),r=U(),i=B(),a=W();var o=class e extends a.RandomIterator{copy(){return new e(this.node,this.size,this.getElementByPos,this.setElementByPos,this.iteratorType)}};e.DequeIterator=o,e.default=class extends n.default{constructor(e=[],t=4096){super(),this.first=0,this.curFirst=0,this.last=0,this.curLast=0,this.bucketNum=0,this.map=[];let n;if(`size`in e)n=typeof e.size==`number`?e.size:e.size();else if(`length`in e)n=e.length;else throw RangeError(`Can't get container's size!`);this.bucketSize=t,this.bucketNum=Math.max(Math.ceil(n/this.bucketSize),1);for(let e=0;e<this.bucketNum;++e)this.map.push(Array(this.bucketSize));let r=Math.ceil(n/this.bucketSize);this.first=this.last=(this.bucketNum>>1)-(r>>1),this.curFirst=this.curLast=this.bucketSize-n%this.bucketSize>>1,e.forEach(e=>this.pushBack(e)),this.size=this.size.bind(this),this.getElementByPos=this.getElementByPos.bind(this),this.setElementByPos=this.setElementByPos.bind(this)}reAllocate(){let e=[],t=Math.max(this.bucketNum>>1,1);for(let n=0;n<t;++n)e[n]=Array(this.bucketSize);for(let t=this.first;t<this.bucketNum;++t)e[e.length]=this.map[t];for(let t=0;t<this.last;++t)e[e.length]=this.map[t];e[e.length]=[...this.map[this.last]],this.first=t,this.last=e.length-1;for(let n=0;n<t;++n)e[e.length]=Array(this.bucketSize);this.map=e,this.bucketNum=e.length}getElementIndex(e){let t=this.curFirst+e+1,n=t%this.bucketSize,r=n-1,i=this.first+(t-n)/this.bucketSize;return n===0&&--i,i%=this.bucketNum,r<0&&(r+=this.bucketSize),{curNodeBucketIndex:i,curNodePointerIndex:r}}clear(){this.map=[[]],this.bucketNum=1,this.first=this.last=this.length=0,this.curFirst=this.curLast=this.bucketSize>>1}front(){return this.map[this.first][this.curFirst]}back(){return this.map[this.last][this.curLast]}begin(){return new o(0,this.size,this.getElementByPos,this.setElementByPos)}end(){return new o(this.length,this.size,this.getElementByPos,this.setElementByPos)}rBegin(){return new o(this.length-1,this.size,this.getElementByPos,this.setElementByPos,i.ContainerIterator.REVERSE)}rEnd(){return new o(-1,this.size,this.getElementByPos,this.setElementByPos,i.ContainerIterator.REVERSE)}pushBack(e){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]=e}popBack(){this.length&&(this.map[this.last][this.curLast]=void 0,this.length!==1&&(this.curLast>0?--this.curLast:this.last>0?(--this.last,this.curLast=this.bucketSize-1):(this.last=this.bucketNum-1,this.curLast=this.bucketSize-1)),--this.length)}pushFront(e){this.length&&(this.curFirst>0?--this.curFirst:this.first>0?(--this.first,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]=e}popFront(){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)}forEach(e){for(let t=0;t<this.length;++t)e(this.getElementByPos(t),t)}getElementByPos(e){(0,r.checkWithinAccessParams)(e,0,this.length-1);let{curNodeBucketIndex:t,curNodePointerIndex:n}=this.getElementIndex(e);return this.map[t][n]}setElementByPos(e,t){(0,r.checkWithinAccessParams)(e,0,this.length-1);let{curNodeBucketIndex:n,curNodePointerIndex:i}=this.getElementIndex(e);this.map[n][i]=t}insert(e,t,n=1){if((0,r.checkWithinAccessParams)(e,0,this.length),e===0)for(;n--;)this.pushFront(t);else if(e===this.length)for(;n--;)this.pushBack(t);else{let r=[];for(let t=e;t<this.length;++t)r.push(this.getElementByPos(t));this.cut(e-1);for(let e=0;e<n;++e)this.pushBack(t);for(let e=0;e<r.length;++e)this.pushBack(r[e])}}cut(e){if(e<0){this.clear();return}let{curNodeBucketIndex:t,curNodePointerIndex:n}=this.getElementIndex(e);this.last=t,this.curLast=n,this.length=e+1}eraseElementByPos(e){if((0,r.checkWithinAccessParams)(e,0,this.length-1),e===0)this.popFront();else if(e===this.length-1)this.popBack();else{let t=[];for(let n=e+1;n<this.length;++n)t.push(this.getElementByPos(n));this.cut(e),this.popBack(),t.forEach(e=>this.pushBack(e))}}eraseElementByValue(e){if(!this.length)return;let t=[];for(let n=0;n<this.length;++n){let r=this.getElementByPos(n);r!==e&&t.push(r)}let n=t.length;for(let e=0;e<n;++e)this.setElementByPos(e,t[e]);this.cut(n-1)}eraseElementByIterator(e){let t=e.node;return this.eraseElementByPos(t),e=e.next(),e}find(e){for(let t=0;t<this.length;++t)if(this.getElementByPos(t)===e)return new o(t,this.size,this.getElementByPos,this.setElementByPos);return this.end()}reverse(){let e=0,t=this.length-1;for(;e<t;){let n=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,n),e+=1,--t}}unique(){if(this.length<=1)return;let e=1,t=this.getElementByPos(0);for(let n=1;n<this.length;++n){let r=this.getElementByPos(n);r!==t&&(t=r,this.setElementByPos(e++,r))}for(;this.length>e;)this.popBack()}sort(e){let t=[];for(let e=0;e<this.length;++e)t.push(this.getElementByPos(e));t.sort(e);for(let e=0;e<this.length;++e)this.setElementByPos(e,t[e])}shrinkToFit(){if(!this.length)return;let e=[];this.forEach(t=>e.push(t)),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(let e=0;e<this.bucketNum;++e)this.map.push(Array(this.bucketSize));for(let t=0;t<e.length;++t)this.pushBack(e[t])}[Symbol.iterator](){return function*(){for(let e=0;e<this.length;++e)yield this.getElementByPos(e)}.bind(this)()}}})),K=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0});let n=t(G()),r=B();e.default=class extends r.Base{constructor(e=[]){super(),this.queue=new n.default(e),this.length=this.queue.size()}clear(){this.queue.clear(),this.length=0}push(e){this.queue.pushBack(e),this.length+=1}pop(){this.queue.popFront(),this.length&&--this.length}front(){return this.queue.front()}}})),te=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=B();e.default=class extends t.Base{constructor(e=[],t=(e,t)=>e>t?-1:+(e<t),n=!0){super(),this.cmp=t,Array.isArray(e)?this.priorityQueue=n?[...e]:e:(this.priorityQueue=[],e.forEach(e=>this.priorityQueue.push(e))),this.length=this.priorityQueue.length;for(let e=this.length-1>>1;e>=0;--e){let t=e,n=t<<1|1;for(;n<this.length;){let e=n,r=e+1,i=e;if(r<this.length&&this.cmp(this.priorityQueue[e],this.priorityQueue[r])>0&&(i=r),this.cmp(this.priorityQueue[t],this.priorityQueue[i])<=0)break;[this.priorityQueue[t],this.priorityQueue[i]]=[this.priorityQueue[i],this.priorityQueue[t]],t=i,n=t<<1|1}}}adjust(e){let t=e<<1|1,n=(e<<1)+2;t<this.length&&this.cmp(this.priorityQueue[e],this.priorityQueue[t])>0&&([this.priorityQueue[e],this.priorityQueue[t]]=[this.priorityQueue[t],this.priorityQueue[e]]),n<this.length&&this.cmp(this.priorityQueue[e],this.priorityQueue[n])>0&&([this.priorityQueue[e],this.priorityQueue[n]]=[this.priorityQueue[n],this.priorityQueue[e]])}clear(){this.length=0,this.priorityQueue.length=0}push(e){if(this.priorityQueue.push(e),this.length+=1,this.length===1)return;let t=this.length-1;for(;t>0;){let n=t-1>>1;if(this.cmp(this.priorityQueue[n],e)<=0)break;this.adjust(n),t=n}}pop(){if(!this.length)return;let e=this.priorityQueue[this.length-1];--this.length;let t=0;for(;t<this.length;){let n=t<<1|1,r=(t<<1)+2;if(n>=this.length)break;let i=n;if(r<this.length&&this.cmp(this.priorityQueue[n],this.priorityQueue[r])>0&&(i=r),this.cmp(this.priorityQueue[i],e)>=0)break;this.priorityQueue[t]=this.priorityQueue[i],t=i}this.priorityQueue[t]=e,this.priorityQueue.pop()}top(){return this.priorityQueue[0]}}})),q=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.VectorIterator=void 0;let n=t(H()),r=U(),i=B(),a=W();var o=class e extends a.RandomIterator{copy(){return new e(this.node,this.size,this.getElementByPos,this.setElementByPos,this.iteratorType)}};e.VectorIterator=o,e.default=class extends n.default{constructor(e=[],t=!0){super(),Array.isArray(e)?(this.vector=t?[...e]:e,this.length=e.length):(this.vector=[],e.forEach(e=>this.pushBack(e))),this.size=this.size.bind(this),this.getElementByPos=this.getElementByPos.bind(this),this.setElementByPos=this.setElementByPos.bind(this)}clear(){this.length=0,this.vector.length=0}begin(){return new o(0,this.size,this.getElementByPos,this.setElementByPos)}end(){return new o(this.length,this.size,this.getElementByPos,this.setElementByPos)}rBegin(){return new o(this.length-1,this.size,this.getElementByPos,this.setElementByPos,i.ContainerIterator.REVERSE)}rEnd(){return new o(-1,this.size,this.getElementByPos,this.setElementByPos,i.ContainerIterator.REVERSE)}front(){return this.vector[0]}back(){return this.vector[this.length-1]}forEach(e){for(let t=0;t<this.length;++t)e(this.vector[t],t)}getElementByPos(e){return(0,r.checkWithinAccessParams)(e,0,this.length-1),this.vector[e]}eraseElementByPos(e){(0,r.checkWithinAccessParams)(e,0,this.length-1),this.vector.splice(e,1),--this.length}eraseElementByValue(e){let t=0;for(let n=0;n<this.length;++n)this.vector[n]!==e&&(this.vector[t++]=this.vector[n]);this.length=this.vector.length=t}eraseElementByIterator(e){let t=e.node;return e=e.next(),this.eraseElementByPos(t),e}pushBack(e){this.vector.push(e),this.length+=1}popBack(){this.length&&(this.vector.pop(),--this.length)}setElementByPos(e,t){(0,r.checkWithinAccessParams)(e,0,this.length-1),this.vector[e]=t}insert(e,t,n=1){(0,r.checkWithinAccessParams)(e,0,this.length),this.vector.splice(e,0,...Array(n).fill(t)),this.length+=n}find(e){for(let t=0;t<this.length;++t)if(this.vector[t]===e)return new o(t,this.size,this.getElementByPos,this.getElementByPos);return this.end()}reverse(){this.vector.reverse()}unique(){let e=1;for(let t=1;t<this.length;++t)this.vector[t]!==this.vector[t-1]&&(this.vector[e++]=this.vector[t]);this.length=this.vector.length=e}sort(e){this.vector.sort(e)}[Symbol.iterator](){return function*(){return yield*this.vector}.bind(this)()}}})),ne=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.LinkListIterator=e.LinkNode=void 0;let n=t(H()),r=U(),i=B();var a=class{constructor(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e}};e.LinkNode=a;var o=class e extends i.ContainerIterator{constructor(e,t,n){super(n),this.node=e,this.header=t,this.iteratorType===i.ContainerIterator.NORMAL?(this.pre=function(){if(this.node.pre===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.pre,this},this.next=function(){if(this.node===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.next,this}):(this.pre=function(){if(this.node.next===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.next,this},this.next=function(){if(this.node===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.pre,this})}get pointer(){if(this.node===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node.value}set pointer(e){if(this.node===this.header)throw RangeError(`LinkList iterator access denied!`);this.node.value=e}equals(e){return this.node===e.node}copy(){return new e(this.node,this.header,this.iteratorType)}};e.LinkListIterator=o,e.default=class extends n.default{constructor(e=[]){super(),this.header=new a,this.head=void 0,this.tail=void 0,e.forEach(e=>this.pushBack(e))}clear(){this.length=0,this.head=this.tail=void 0,this.header.pre=this.header.next=void 0}begin(){return new o(this.head||this.header,this.header)}end(){return new o(this.header,this.header)}rBegin(){return new o(this.tail||this.header,this.header,i.ContainerIterator.REVERSE)}rEnd(){return new o(this.header,this.header,i.ContainerIterator.REVERSE)}front(){return this.head?this.head.value:void 0}back(){return this.tail?this.tail.value:void 0}forEach(e){if(!this.length)return;let t=this.head,n=0;for(;t!==this.header;)e(t.value,n++),t=t.next}getElementByPos(e){(0,r.checkWithinAccessParams)(e,0,this.length-1);let t=this.head;for(;e--;)t=t.next;return t.value}eraseElementByPos(e){if((0,r.checkWithinAccessParams)(e,0,this.length-1),e===0)this.popFront();else if(e===this.length-1)this.popBack();else{let t=this.head;for(;e--;)t=t.next;t=t;let n=t.pre,r=t.next;r.pre=n,n.next=r,--this.length}}eraseElementByValue(e){for(;this.head&&this.head.value===e;)this.popFront();for(;this.tail&&this.tail.value===e;)this.popBack();if(!this.head)return;let t=this.head;for(;t!==this.header;){if(t.value===e){let e=t.pre,n=t.next;n&&(n.pre=e),e&&(e.next=n),--this.length}t=t.next}}eraseElementByIterator(e){let t=e.node;if(t===this.header)throw RangeError(`Invalid iterator`);if(e=e.next(),this.head===t)this.popFront();else if(this.tail===t)this.popBack();else{let e=t.pre,n=t.next;n&&(n.pre=e),e&&(e.next=n),--this.length}return e}pushBack(e){this.length+=1;let t=new a(e);this.tail?(this.tail.next=t,t.pre=this.tail,this.tail=t):(this.head=this.tail=t,this.header.next=this.head,this.head.pre=this.header),this.tail.next=this.header,this.header.pre=this.tail}popBack(){this.tail&&(--this.length,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))}setElementByPos(e,t){(0,r.checkWithinAccessParams)(e,0,this.length-1);let n=this.head;for(;e--;)n=n.next;n.value=t}insert(e,t,n=1){if((0,r.checkWithinAccessParams)(e,0,this.length),!(n<=0))if(e===0)for(;n--;)this.pushFront(t);else if(e===this.length)for(;n--;)this.pushBack(t);else{let r=this.head;for(let t=1;t<e;++t)r=r.next;let i=r.next;for(this.length+=n;n--;)r.next=new a(t),r.next.pre=r,r=r.next;r.next=i,i&&(i.pre=r)}}find(e){if(!this.head)return this.end();let t=this.head;for(;t!==this.header;){if(t.value===e)return new o(t,this.header);t=t.next}return this.end()}reverse(){if(this.length<=1)return;let e=this.head,t=this.tail,n=0;for(;n<<1<this.length;){let r=e.value;e.value=t.value,t.value=r,e=e.next,t=t.pre,n+=1}}unique(){if(this.length<=1)return;let e=this.head;for(;e!==this.header;){let t=e;for(;t.next&&t.value===t.next.value;)t=t.next,--this.length;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}}sort(e){if(this.length<=1)return;let t=[];this.forEach(e=>t.push(e)),t.sort(e);let n=this.head;t.forEach(e=>{n.value=e,n=n.next})}pushFront(e){this.length+=1;let t=new a(e);this.head?(t.next=this.head,this.head.pre=t,this.head=t):(this.head=this.tail=t,this.tail.next=this.header,this.header.pre=this.tail),this.header.next=this.head,this.head.pre=this.header}popFront(){this.head&&(--this.length,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)}merge(e){if(!this.head){e.forEach(e=>this.pushBack(e));return}let t=this.head;e.forEach(e=>{for(;t&&t!==this.header&&t.value<=e;)t=t.next;if(t===this.header)this.pushBack(e),t=this.tail;else if(t===this.head)this.pushFront(e),t=this.head;else{this.length+=1;let n=t.pre;n.next=new a(e),n.next.pre=n,n.next.next=t,t.pre=n.next}})}[Symbol.iterator](){return function*(){if(!this.head)return;let e=this.head;for(;e!==this.header;)yield e.value,e=e.next}.bind(this)()}}})),re=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=class e{constructor(e,t){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=t}pre(){let t=this;if(t.color===e.RED&&t.parent.parent===t)t=t.right;else if(t.left)for(t=t.left;t.right;)t=t.right;else{let e=t.parent;for(;e.left===t;)t=e,e=t.parent;t=e}return t}next(){let e=this;if(e.right)for(e=e.right;e.left;)e=e.left;else{let t=e.parent;for(;t.right===e;)e=t,t=e.parent;e.right!==t&&(e=t)}return e}rotateLeft(){let e=this.parent,t=this.right,n=t.left;return e.parent===this?e.parent=t:e.left===this?e.left=t:e.right=t,t.parent=e,t.left=this,this.parent=t,this.right=n,n&&(n.parent=this),t}rotateRight(){let e=this.parent,t=this.left,n=t.right;return e.parent===this?e.parent=t:e.left===this?e.left=t:e.right=t,t.parent=e,t.right=this,this.parent=t,this.left=n,n&&(n.parent=this),t}remove(){let e=this.parent;this===e.left?e.left=void 0:e.right=void 0}};t.RED=!0,t.BLACK=!1,e.default=t})),ie=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0});let n=t(re()),r=B(),i=U();e.default=class extends r.Container{constructor(e=(e,t)=>e<t?-1:+(e>t)){super(),this.root=void 0,this.header=new n.default,this.inOrderTraversal=(e,t)=>e===void 0?!1:this.inOrderTraversal(e.left,t)||t(e)?!0:this.inOrderTraversal(e.right,t),this.cmp=e}_lowerBound(e,t){let n;for(;e;){let r=this.cmp(e.key,t);if(r<0)e=e.right;else if(r>0)n=e,e=e.left;else return e}return n===void 0?this.header:n}_upperBound(e,t){let n;for(;e;){let r=this.cmp(e.key,t);r<=0?e=e.right:r>0&&(n=e,e=e.left)}return n===void 0?this.header:n}_reverseLowerBound(e,t){let n;for(;e;){let r=this.cmp(e.key,t);if(r<0)n=e,e=e.right;else if(r>0)e=e.left;else return e}return n===void 0?this.header:n}_reverseUpperBound(e,t){let n;for(;e;){let r=this.cmp(e.key,t);r<0?(n=e,e=e.right):r>=0&&(e=e.left)}return n===void 0?this.header:n}eraseNodeSelfBalance(e){for(;;){let t=e.parent;if(t===this.header)return;if(e.color===n.default.RED){e.color=n.default.BLACK;return}if(e===t.left){let r=t.right;if(r.color===n.default.RED)r.color=n.default.BLACK,t.color=n.default.RED,t===this.root?this.root=t.rotateLeft():t.rotateLeft();else if(r.color===n.default.BLACK)if(r.right&&r.right.color===n.default.RED){r.color=t.color,t.color=n.default.BLACK,r.right.color=n.default.BLACK,t===this.root?this.root=t.rotateLeft():t.rotateLeft();return}else r.left&&r.left.color===n.default.RED?(r.color=n.default.RED,r.left.color=n.default.BLACK,r.rotateRight()):(r.color=n.default.RED,e=t)}else{let r=t.left;if(r.color===n.default.RED)r.color=n.default.BLACK,t.color=n.default.RED,t===this.root?this.root=t.rotateRight():t.rotateRight();else if(r.left&&r.left.color===n.default.RED){r.color=t.color,t.color=n.default.BLACK,r.left.color=n.default.BLACK,t===this.root?this.root=t.rotateRight():t.rotateRight();return}else r.right&&r.right.color===n.default.RED?(r.color=n.default.RED,r.right.color=n.default.BLACK,r.rotateLeft()):(r.color=n.default.RED,e=t)}}}eraseNode(e){if(this.length===1){this.clear();return}let t=e;for(;t.left||t.right;){if(t.right)for(t=t.right;t.left;)t=t.left;else t.left&&(t=t.left);[e.key,t.key]=[t.key,e.key],[e.value,t.value]=[t.value,e.value],e=t}this.header.left===t?this.header.left=t.parent:this.header.right===t&&(this.header.right=t.parent),this.eraseNodeSelfBalance(t),t.remove(),--this.length,this.root.color=n.default.BLACK}insertNodeSelfBalance(e){for(;;){let t=e.parent;if(t.color===n.default.BLACK)return;let r=t.parent;if(t===r.left){let i=r.right;if(i&&i.color===n.default.RED){if(i.color=t.color=n.default.BLACK,r===this.root)return;r.color=n.default.RED,e=r;continue}else if(e===t.right){if(e.color=n.default.BLACK,e.left&&(e.left.parent=t),e.right&&(e.right.parent=r),t.right=e.left,r.left=e.right,e.left=t,e.right=r,r===this.root)this.root=e,this.header.parent=e;else{let t=r.parent;t.left===r?t.left=e:t.right=e}e.parent=r.parent,t.parent=e,r.parent=e}else t.color=n.default.BLACK,r===this.root?this.root=r.rotateRight():r.rotateRight();r.color=n.default.RED}else{let i=r.left;if(i&&i.color===n.default.RED){if(i.color=t.color=n.default.BLACK,r===this.root)return;r.color=n.default.RED,e=r;continue}else if(e===t.left){if(e.color=n.default.BLACK,e.left&&(e.left.parent=r),e.right&&(e.right.parent=t),r.right=e.left,t.left=e.right,e.left=r,e.right=t,r===this.root)this.root=e,this.header.parent=e;else{let t=r.parent;t.left===r?t.left=e:t.right=e}e.parent=r.parent,t.parent=e,r.parent=e}else t.color=n.default.BLACK,r===this.root?this.root=r.rotateLeft():r.rotateLeft();r.color=n.default.RED}return}}findElementNode(e,t){for(;e;){let n=this.cmp(e.key,t);if(n<0)e=e.right;else if(n>0)e=e.left;else return e}return e}set(e,t,r){if(this.root===void 0){this.length+=1,this.root=new n.default(e,t),this.root.color=n.default.BLACK,this.root.parent=this.header,this.header.parent=this.root,this.header.left=this.root,this.header.right=this.root;return}let i,a=this.header.left,o=this.cmp(a.key,e);if(o===0){a.value=t;return}else if(o>0)a.left=new n.default(e,t),a.left.parent=a,i=a.left,this.header.left=i;else{let a=this.header.right,o=this.cmp(a.key,e);if(o===0){a.value=t;return}else if(o<0)a.right=new n.default(e,t),a.right.parent=a,i=a.right,this.header.right=i;else{if(r!==void 0){let a=r.node;if(a!==this.header){let r=this.cmp(a.key,e);if(r===0){a.value=t;return}else if(r>0){let r=a.pre(),o=this.cmp(r.key,e);if(o===0){r.value=t;return}else o<0&&(i=new n.default(e,t),r.right===void 0?(r.right=i,i.parent=r):(a.left=i,i.parent=a))}}}if(i===void 0)for(i=this.root;;){let r=this.cmp(i.key,e);if(r>0){if(i.left===void 0){i.left=new n.default(e,t),i.left.parent=i,i=i.left;break}i=i.left}else if(r<0){if(i.right===void 0){i.right=new n.default(e,t),i.right.parent=i,i=i.right;break}i=i.right}else{i.value=t;return}}}}this.length+=1,this.insertNodeSelfBalance(i)}clear(){this.length=0,this.root=void 0,this.header.parent=void 0,this.header.left=this.header.right=void 0}updateKeyByIterator(e,t){let n=e.node;if(n===this.header)throw TypeError(`Invalid iterator!`);if(this.length===1)return n.key=t,!0;if(n===this.header.left)return this.cmp(n.next().key,t)>0?(n.key=t,!0):!1;if(n===this.header.right)return this.cmp(n.pre().key,t)<0?(n.key=t,!0):!1;let r=n.pre().key;if(this.cmp(r,t)>=0)return!1;let i=n.next().key;return this.cmp(i,t)<=0?!1:(n.key=t,!0)}eraseElementByPos(e){(0,i.checkWithinAccessParams)(e,0,this.length-1);let t=0;this.inOrderTraversal(this.root,n=>e===t?(this.eraseNode(n),!0):(t+=1,!1))}eraseElementByKey(e){if(!this.length)return;let t=this.findElementNode(this.root,e);t!==void 0&&this.eraseNode(t)}eraseElementByIterator(e){let t=e.node;if(t===this.header)throw RangeError(`Invalid iterator`);return t.right===void 0&&(e=e.next()),this.eraseNode(t),e}getHeight(){if(!this.length)return 0;let e=t=>t?Math.max(e(t.left),e(t.right))+1:0;return e(this.root)}}})),J=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=B();e.default=class extends t.ContainerIterator{constructor(e,n,r){super(r),this.node=e,this.header=n,this.iteratorType===t.ContainerIterator.NORMAL?(this.pre=function(){if(this.node===this.header.left)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.pre(),this},this.next=function(){if(this.node===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.next(),this}):(this.pre=function(){if(this.node===this.header.right)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.next(),this},this.next=function(){if(this.node===this.header)throw RangeError(`LinkList iterator access denied!`);return this.node=this.node.pre(),this})}equals(e){return this.node===e.node}}})),ae=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.OrderedSetIterator=void 0;let n=t(ie()),r=B(),i=U(),a=t(J());var o=class e extends a.default{get pointer(){if(this.node===this.header)throw RangeError(`OrderedSet iterator access denied!`);return this.node.key}copy(){return new e(this.node,this.header,this.iteratorType)}};e.OrderedSetIterator=o,e.default=class extends n.default{constructor(e=[],t){super(t),this.iterationFunc=function*(e){e!==void 0&&(yield*this.iterationFunc(e.left),yield e.key,yield*this.iterationFunc(e.right))},e.forEach(e=>this.insert(e)),this.iterationFunc=this.iterationFunc.bind(this)}begin(){return new o(this.header.left||this.header,this.header)}end(){return new o(this.header,this.header)}rBegin(){return new o(this.header.right||this.header,this.header,r.ContainerIterator.REVERSE)}rEnd(){return new o(this.header,this.header,r.ContainerIterator.REVERSE)}front(){return this.header.left?this.header.left.key:void 0}back(){return this.header.right?this.header.right.key:void 0}forEach(e){let t=0;for(let n of this)e(n,t++)}getElementByPos(e){(0,i.checkWithinAccessParams)(e,0,this.length-1);let t,n=0;for(let r of this)n===e&&(t=r),n+=1;return t}insert(e,t){this.set(e,void 0,t)}find(e){let t=this.findElementNode(this.root,e);return t===void 0?this.end():new o(t,this.header)}lowerBound(e){return new o(this._lowerBound(this.root,e),this.header)}upperBound(e){return new o(this._upperBound(this.root,e),this.header)}reverseLowerBound(e){return new o(this._reverseLowerBound(this.root,e),this.header)}reverseUpperBound(e){return new o(this._reverseUpperBound(this.root,e),this.header)}union(e){e.forEach(e=>this.insert(e))}[Symbol.iterator](){return this.iterationFunc(this.root)}}})),Y=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.OrderedMapIterator=void 0;let n=B(),r=U(),i=t(ie()),a=t(J());var o=class e extends a.default{get pointer(){if(this.node===this.header)throw RangeError(`OrderedMap iterator access denied`);return new Proxy([],{get:(e,t)=>{if(t===`0`)return this.node.key;if(t===`1`)return this.node.value},set:(e,t,n)=>{if(t!==`1`)throw TypeError(`props must be 1`);return this.node.value=n,!0}})}copy(){return new e(this.node,this.header,this.iteratorType)}};e.OrderedMapIterator=o,e.default=class extends i.default{constructor(e=[],t){super(t),this.iterationFunc=function*(e){e!==void 0&&(yield*this.iterationFunc(e.left),yield[e.key,e.value],yield*this.iterationFunc(e.right))},this.iterationFunc=this.iterationFunc.bind(this),e.forEach(([e,t])=>this.setElement(e,t))}begin(){return new o(this.header.left||this.header,this.header)}end(){return new o(this.header,this.header)}rBegin(){return new o(this.header.right||this.header,this.header,n.ContainerIterator.REVERSE)}rEnd(){return new o(this.header,this.header,n.ContainerIterator.REVERSE)}front(){if(!this.length)return;let e=this.header.left;return[e.key,e.value]}back(){if(!this.length)return;let e=this.header.right;return[e.key,e.value]}forEach(e){let t=0;for(let n of this)e(n,t++)}lowerBound(e){return new o(this._lowerBound(this.root,e),this.header)}upperBound(e){return new o(this._upperBound(this.root,e),this.header)}reverseLowerBound(e){return new o(this._reverseLowerBound(this.root,e),this.header)}reverseUpperBound(e){return new o(this._reverseUpperBound(this.root,e),this.header)}setElement(e,t,n){this.set(e,t,n)}find(e){let t=this.findElementNode(this.root,e);return t===void 0?this.end():new o(t,this.header)}getElementByKey(e){let t=this.findElementNode(this.root,e);return t?t.value:void 0}getElementByPos(e){(0,r.checkWithinAccessParams)(e,0,this.length-1);let t,n=0;for(let r of this){if(n===e){t=r;break}n+=1}return t}union(e){e.forEach(([e,t])=>this.setElement(e,t))}[Symbol.iterator](){return this.iterationFunc(this.root)}}})),oe=o((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=B();var n=class extends t.Base{constructor(e=16,t=e=>{let t;t=typeof e==`string`?e:JSON.stringify(e);let n=0,r=t.length;for(let e=0;e<r;e++){let r=t.charCodeAt(e);n=(n<<5)-n+r,n|=0}return n>>>0}){if(super(),e<16||e&e-1)throw RangeError(`InitBucketNum range error`);this.bucketNum=this.initBucketNum=e,this.hashFunc=t}clear(){this.length=0,this.bucketNum=this.initBucketNum,this.hashTable=[]}};n.sigma=.75,n.treeifyThreshold=8,n.untreeifyThreshold=6,n.minTreeifySize=64,n.maxBucketNum=1<<30,e.default=n})),se=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0});let n=t(oe()),r=t(q()),i=t(ae());e.default=class extends n.default{constructor(e=[],t,n){super(t,n),this.hashTable=[],e.forEach(e=>this.insert(e))}reAllocate(){if(this.bucketNum>=n.default.maxBucketNum)return;let e=[],t=this.bucketNum;this.bucketNum<<=1;let a=Object.keys(this.hashTable),o=a.length;for(let s=0;s<o;++s){let o=parseInt(a[s]),c=this.hashTable[o],l=c.size();if(l===0)continue;if(l===1){let t=c.front();e[this.hashFunc(t)&this.bucketNum-1]=new r.default([t],!1);continue}let u=[],d=[];c.forEach(e=>{(this.hashFunc(e)&t)===0?u.push(e):d.push(e)}),c instanceof i.default?(u.length>n.default.untreeifyThreshold?e[o]=new i.default(u):u.length&&(e[o]=new r.default(u,!1)),d.length>n.default.untreeifyThreshold?e[o+t]=new i.default(d):d.length&&(e[o+t]=new r.default(d,!1))):(u.length>=n.default.treeifyThreshold?e[o]=new i.default(u):u.length&&(e[o]=new r.default(u,!1)),d.length>=n.default.treeifyThreshold?e[o+t]=new i.default(d):d.length&&(e[o+t]=new r.default(d,!1)))}this.hashTable=e}forEach(e){let t=Object.values(this.hashTable),n=t.length,r=0;for(let i=0;i<n;++i)t[i].forEach(t=>e(t,r++))}insert(e){let t=this.hashFunc(e)&this.bucketNum-1,a=this.hashTable[t];if(!a)this.hashTable[t]=new r.default([e],!1),this.length+=1;else{let o=a.size();if(a instanceof r.default){if(!a.find(e).equals(a.end()))return;if(a.pushBack(e),o+1>=n.default.treeifyThreshold){if(this.bucketNum<=n.default.minTreeifySize){this.length+=1,this.reAllocate();return}this.hashTable[t]=new i.default(a)}this.length+=1}else{a.insert(e);let t=a.size();this.length+=t-o}}this.length>this.bucketNum*n.default.sigma&&this.reAllocate()}eraseElementByKey(e){let t=this.hashFunc(e)&this.bucketNum-1,i=this.hashTable[t];if(!i)return;let a=i.size();if(a!==0)if(i instanceof r.default){i.eraseElementByValue(e);let t=i.size();this.length+=t-a}else{i.eraseElementByKey(e);let o=i.size();this.length+=o-a,o<=n.default.untreeifyThreshold&&(this.hashTable[t]=new r.default(i))}}find(e){let t=this.hashFunc(e)&this.bucketNum-1,n=this.hashTable[t];return n?!n.find(e).equals(n.end()):!1}[Symbol.iterator](){return function*(){let e=Object.values(this.hashTable),t=e.length;for(let n=0;n<t;++n){let t=e[n];for(let e of t)yield e}}.bind(this)()}}})),ce=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0});let n=t(oe()),r=t(q()),i=t(Y());e.default=class e extends n.default{constructor(e=[],t,n){super(t,n),this.hashTable=[],e.forEach(e=>this.setElement(e[0],e[1]))}reAllocate(){if(this.bucketNum>=n.default.maxBucketNum)return;let e=[],t=this.bucketNum;this.bucketNum<<=1;let a=Object.keys(this.hashTable),o=a.length;for(let s=0;s<o;++s){let o=parseInt(a[s]),c=this.hashTable[o],l=c.size();if(l===0)continue;if(l===1){let t=c.front();e[this.hashFunc(t[0])&this.bucketNum-1]=new r.default([t],!1);continue}let u=[],d=[];c.forEach(e=>{(this.hashFunc(e[0])&t)===0?u.push(e):d.push(e)}),c instanceof i.default?(u.length>n.default.untreeifyThreshold?e[o]=new i.default(u):u.length&&(e[o]=new r.default(u,!1)),d.length>n.default.untreeifyThreshold?e[o+t]=new i.default(d):d.length&&(e[o+t]=new r.default(d,!1))):(u.length>=n.default.treeifyThreshold?e[o]=new i.default(u):u.length&&(e[o]=new r.default(u,!1)),d.length>=n.default.treeifyThreshold?e[o+t]=new i.default(d):d.length&&(e[o+t]=new r.default(d,!1)))}this.hashTable=e}forEach(e){let t=Object.values(this.hashTable),n=t.length,r=0;for(let i=0;i<n;++i)t[i].forEach(t=>e(t,r++))}setElement(t,n){let a=this.hashFunc(t)&this.bucketNum-1,o=this.hashTable[a];if(!o)this.length+=1,this.hashTable[a]=new r.default([[t,n]],!1);else{let s=o.size();if(o instanceof r.default){for(let e of o)if(e[0]===t){e[1]=n;return}if(o.pushBack([t,n]),s+1>=e.treeifyThreshold){if(this.bucketNum<=e.minTreeifySize){this.length+=1,this.reAllocate();return}this.hashTable[a]=new i.default(this.hashTable[a])}this.length+=1}else{o.setElement(t,n);let e=o.size();this.length+=e-s}}this.length>this.bucketNum*e.sigma&&this.reAllocate()}getElementByKey(e){let t=this.hashFunc(e)&this.bucketNum-1,n=this.hashTable[t];if(n){if(n instanceof i.default)return n.getElementByKey(e);for(let t of n)if(t[0]===e)return t[1]}}eraseElementByKey(e){let t=this.hashFunc(e)&this.bucketNum-1,i=this.hashTable[t];if(i)if(i instanceof r.default){let t=0;for(let n of i){if(n[0]===e){i.eraseElementByPos(t),--this.length;return}t+=1}}else{let a=i.size();i.eraseElementByKey(e);let o=i.size();this.length+=o-a,o<=n.default.untreeifyThreshold&&(this.hashTable[t]=new r.default(i))}}find(e){let t=this.hashFunc(e)&this.bucketNum-1,n=this.hashTable[t];if(!n)return!1;if(n instanceof i.default)return!n.find(e).equals(n.end());for(let t of n)if(t[0]===e)return!0;return!1}[Symbol.iterator](){return function*(){let e=Object.values(this.hashTable),t=e.length;for(let n=0;n<t;++n){let t=e[n];for(let e of t)yield e}}.bind(this)()}}})),le=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.HashContainer=e.TreeContainer=e.SequentialContainer=e.ContainerIterator=e.Container=e.HashMap=e.HashSet=e.OrderedMapIterator=e.OrderedMap=e.OrderedSetIterator=e.OrderedSet=e.DequeIterator=e.Deque=e.LinkListIterator=e.LinkList=e.VectorIterator=e.Vector=e.PriorityQueue=e.Queue=e.Stack=void 0;var n=V();Object.defineProperty(e,`Stack`,{enumerable:!0,get:function(){return t(n).default}});var r=K();Object.defineProperty(e,`Queue`,{enumerable:!0,get:function(){return t(r).default}});var i=te();Object.defineProperty(e,`PriorityQueue`,{enumerable:!0,get:function(){return t(i).default}});var a=q();Object.defineProperty(e,`Vector`,{enumerable:!0,get:function(){return t(a).default}}),Object.defineProperty(e,`VectorIterator`,{enumerable:!0,get:function(){return a.VectorIterator}});var o=ne();Object.defineProperty(e,`LinkList`,{enumerable:!0,get:function(){return t(o).default}}),Object.defineProperty(e,`LinkListIterator`,{enumerable:!0,get:function(){return o.LinkListIterator}});var s=G();Object.defineProperty(e,`Deque`,{enumerable:!0,get:function(){return t(s).default}}),Object.defineProperty(e,`DequeIterator`,{enumerable:!0,get:function(){return s.DequeIterator}});var c=ae();Object.defineProperty(e,`OrderedSet`,{enumerable:!0,get:function(){return t(c).default}}),Object.defineProperty(e,`OrderedSetIterator`,{enumerable:!0,get:function(){return c.OrderedSetIterator}});var l=Y();Object.defineProperty(e,`OrderedMap`,{enumerable:!0,get:function(){return t(l).default}}),Object.defineProperty(e,`OrderedMapIterator`,{enumerable:!0,get:function(){return l.OrderedMapIterator}});var u=se();Object.defineProperty(e,`HashSet`,{enumerable:!0,get:function(){return t(u).default}});var d=ce();Object.defineProperty(e,`HashMap`,{enumerable:!0,get:function(){return t(d).default}});var f=B();Object.defineProperty(e,`Container`,{enumerable:!0,get:function(){return f.Container}}),Object.defineProperty(e,`ContainerIterator`,{enumerable:!0,get:function(){return f.ContainerIterator}});var p=H();Object.defineProperty(e,`SequentialContainer`,{enumerable:!0,get:function(){return t(p).default}});var m=ie();Object.defineProperty(e,`TreeContainer`,{enumerable:!0,get:function(){return t(m).default}});var h=oe();Object.defineProperty(e,`HashContainer`,{enumerable:!0,get:function(){return t(h).default}})})),ue=o(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),de=o(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=ue(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}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 n.enable(n.load()),n}t.exports=n})),fe=o(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.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`.split(`.`);function n(){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 e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=de()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),pe=o(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),me=o(((e,t)=>{let n=require(`os`),r=require(`tty`),i=pe(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1),`FORCE_COLOR`in a&&(o=a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(parseInt(a.FORCE_COLOR,10),3));function s(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function c(e,t){if(o===0)return 0;if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2;if(e&&!t&&o===void 0)return 0;let r=o||0;if(a.TERM===`dumb`)return r;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:r;if(`TEAMCITY_VERSION`in a)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION);if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:r}function l(e){return s(c(e,e&&e.isTTY))}t.exports={supportsColor:l,stdout:s(c(!0,r.isatty(1))),stderr:s(c(!0,r.isatty(2)))}})),he=o(((e,t)=>{let n=require(`tty`),r=require(`util`);e.init=u,e.log=s,e.formatArgs=a,e.save=c,e.load=l,e.useColors=i,e.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=me();t&&(t.stderr||t).level>=2&&(e.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{}e.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function i(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:n.isatty(process.stderr.fd)}function a(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \u001B[0m`;e[0]=a+e[0].split(`
4
+ `).join(`
5
+ `+a),e.push(i+`m+`+t.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=o()+n+` `+e[0]}function o(){return e.inspectOpts.hideDate?``:new Date().toISOString()+` `}function s(...t){return process.stderr.write(r.formatWithOptions(e.inspectOpts,...t)+`
6
+ `)}function c(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function l(){return process.env.DEBUG}function u(t){t.inspectOpts={};let n=Object.keys(e.inspectOpts);for(let r=0;r<n.length;r++)t.inspectOpts[n[r]]=e.inspectOpts[n[r]]}t.exports=de()(e);let{formatters:d}=t.exports;d.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split(`
7
+ `).map(e=>e.trim()).join(` `)},d.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}})),X=o(((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=fe():t.exports=he()})),ge=o(((e,t)=>{let n=le().OrderedSet,r=X()(`number-allocator:trace`),i=X()(`number-allocator:error`);function a(e,t){this.low=e,this.high=t}a.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},a.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:+(e.low<this.low&&e.high<this.low)};function o(e,t){if(!(this instanceof o))return new o(e,t);this.min=e,this.max=t,this.ss=new n([],(e,t)=>e.compare(t)),r(`Create`),this.clear()}o.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low},o.prototype.alloc=function(){if(this.ss.size()===0)return r(`alloc():empty`),null;let e=this.ss.begin(),t=e.pointer.low,n=e.pointer.high,i=t;return i+1<=n?this.ss.updateKeyByIterator(e,new a(t+1,n)):this.ss.eraseElementByPos(0),r(`alloc():`+i),i},o.prototype.use=function(e){let t=new a(e,e),n=this.ss.lowerBound(t);if(!n.equals(this.ss.end())){let i=n.pointer.low,o=n.pointer.high;return n.pointer.equals(t)?(this.ss.eraseElementByIterator(n),r(`use():`+e),!0):i>e?!1:i===e?(this.ss.updateKeyByIterator(n,new a(i+1,o)),r(`use():`+e),!0):o===e?(this.ss.updateKeyByIterator(n,new a(i,o-1)),r(`use():`+e),!0):(this.ss.updateKeyByIterator(n,new a(e+1,o)),this.ss.insert(new a(i,e-1)),r(`use():`+e),!0)}return r(`use():failed`),!1},o.prototype.free=function(e){if(e<this.min||e>this.max){i(`free():`+e+` is out of range`);return}let t=new a(e,e),n=this.ss.upperBound(t);if(n.equals(this.ss.end())){if(n.equals(this.ss.begin())){this.ss.insert(t);return}n.pre();let r=n.pointer.high;n.pointer.high+1===e?this.ss.updateKeyByIterator(n,new a(r,e)):this.ss.insert(t)}else if(n.equals(this.ss.begin()))if(e+1===n.pointer.low){let e=n.pointer.high-1,t=n.pointer.high;this.ss.updateKeyByIterator(n,new a(e,t))}else this.ss.insert(t);else{let r=n.pointer.low,i=n.pointer.high;n.pre();let o=n.pointer.low;if(n.pointer.high+1===e)if(e+1===r){this.ss.eraseElementByIterator(n);let e=n.pointer.high;this.ss.updateKeyByIterator(n,new a(o,e))}else this.ss.updateKeyByIterator(n,new a(o,e));else e+1===r?(this.ss.eraseElementByIterator(n.next()),this.ss.insert(new a(e,i))):this.ss.insert(t)}r(`free():`+e)},o.prototype.clear=function(){r(`clear()`),this.ss.clear(),this.ss.insert(new a(this.min,this.max))},o.prototype.intervalCount=function(){return this.ss.size()},o.prototype.dump=function(){console.log(`length:`+this.ss.size());for(let e of this.ss)console.log(e)},t.exports=o})),_e=o(((e,t)=>{let n=ge();t.exports.NumberAllocator=n})),ve=o(((e,t)=>{let n=z(),r=_e().NumberAllocator;function i(e){if(!(this instanceof i))return new i(e);e>0&&(this.aliasToTopic=new n({max:e}),this.topicToAlias={},this.numberAllocator=new r(1,e),this.max=e,this.length=0)}i.prototype.put=function(e,t){if(t===0||t>this.max)return!1;let n=this.aliasToTopic.get(t);return n&&delete this.topicToAlias[n],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},i.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},i.prototype.getAliasByTopic=function(e){let t=this.topicToAlias[e];return t!==void 0&&this.aliasToTopic.get(t),t},i.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},i.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=i})),ye=o(((e,t)=>{let{Buffer:n}=require(`buffer`),r=Symbol.for(`BufferList`);function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,r,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(e===0)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){let r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){let t=e[0],n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},i.prototype.get=function(e){if(e>this.length||e<0)return;let t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return typeof e==`number`&&e<0&&(e+=this.length),typeof t==`number`&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,r,i){if((typeof r!=`number`||r<0)&&(r=0),(typeof i!=`number`||i>this.length)&&(i=this.length),r>=this.length||i<=0)return e||n.alloc(0);let a=!!e,o=this._offset(r),s=i-r,c=s,l=a&&t||0,u=o[1];if(r===0&&i===this.length){if(!a)return this._bufs.length===1?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[o[0]].length-u)return a?this._bufs[o[0]].copy(e,t,u,u+c):this._bufs[o[0]].slice(u,u+c);a||(e=n.allocUnsafe(s));for(let t=o[0];t<this._bufs.length;t++){let n=this._bufs[t].length-u;if(c>n)this._bufs[t].copy(e,l,u),l+=n;else{this._bufs[t].copy(e,l,u,u+c),l+=n;break}c-=n,u&&=0}return e.length>l?e.slice(0,l):e},i.prototype.shallowSlice=function(e,t){if(e||=0,t=typeof t==`number`?t:this.length,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();let n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return r[1]===0?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),n[1]!==0&&(i[0]=i[0].slice(n[1])),this._new(i)},i.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},i.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},i.prototype.duplicate=function(){let e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else typeof e==`number`&&(e=e.toString()),this._appendBuffer(n.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,r){if(r===void 0&&typeof t==`string`&&(r=t,t=void 0),typeof e==`function`||Array.isArray(e))throw TypeError(`The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.`);if(typeof e==`number`?e=n.from([e]):typeof e==`string`?e=n.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let i=this._offset(t),a=i[0],o=i[1];for(;a<this._bufs.length;a++){let t=this._bufs[a];for(;o<t.length;)if(t.length-o>=e.length){let n=t.indexOf(e,o);if(n!==-1)return this._reverseOffset([a,n]);o=t.length-e.length+1}else{let t=this._reverseOffset([a,o]);if(this._match(t,e))return t;o++}o=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},(function(){let e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let t in e)(function(t){e[t]===null?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+e[t])[t](0)}})(t)})(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return e!=null&&e[r]},t.exports=i})),be=o(((e,t)=>{let n=P().Duplex,r=S(),i=ye();function a(e){if(!(this instanceof a))return new a(e);if(typeof e==`function`){this._callback=e;let t=function(e){this._callback&&=(this._callback(e),null)}.bind(this);this.on(`pipe`,function(e){e.on(`error`,t)}),this.on(`unpipe`,function(e){e.removeListener(`error`,t)}),e=null}i._init.call(this,e),n.call(this)}r(a,n),Object.assign(a.prototype,i.prototype),a.prototype._new=function(e){return new a(e)},a.prototype._write=function(e,t,n){this._appendBuffer(e),typeof n==`function`&&n()},a.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)},a.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&=(this._callback(null,this.slice()),null)},a.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},a.prototype._isBufferList=function(e){return e instanceof a||e instanceof i||a.isBufferList(e)},a.isBufferList=i.isBufferList,t.exports=a,t.exports.BufferListStream=a,t.exports.BufferList=i})),xe=o(((e,t)=>{t.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}})),Se=o(((e,t)=>{let n=t.exports;n.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`},n.codes={};for(let e in n.types){let t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=Buffer.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=Buffer.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=Buffer.from([n.codes.connect<<n.CMD_SHIFT]),n.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},n.propertiesCodes={};for(let e in n.properties){let t=n.properties[e];n.propertiesCodes[t]=e}n.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 r(e){return[0,1,2].map(t=>[0,1].map(r=>[0,1].map(i=>{let a=Buffer.alloc(1);return a.writeUInt8(n.codes[e]<<n.CMD_SHIFT|(r?n.DUP_MASK:0)|t<<n.QOS_SHIFT|i,0,!0),a})))}n.PUBLISH_HEADER=r(`publish`),n.SUBSCRIBE_HEADER=r(`subscribe`),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r(`unsubscribe`),n.ACKS={unsuback:r(`unsuback`),puback:r(`puback`),pubcomp:r(`pubcomp`),pubrel:r(`pubrel`),pubrec:r(`pubrec`)},n.SUBACK_HEADER=Buffer.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=Buffer.from([3]),n.VERSION4=Buffer.from([4]),n.VERSION5=Buffer.from([5]),n.VERSION131=Buffer.from([131]),n.VERSION132=Buffer.from([132]),n.QOS=[0,1,2].map(e=>Buffer.from([e])),n.EMPTY={pingreq:Buffer.from([n.codes.pingreq<<4,0]),pingresp:Buffer.from([n.codes.pingresp<<4,0]),disconnect:Buffer.from([n.codes.disconnect<<4,0])}})),Ce=o(((e,t)=>{let n=be(),r=require(`events`),i=xe(),a=Se(),o=X()(`mqtt-packet:parser`);t.exports=class e extends r{constructor(){super(),this.parser=this.constructor.parser}static parser(t){return this instanceof e?(this.settings=t||{},this._states=[`_parseHeader`,`_parseLength`,`_parsePayload`,`_newPacket`],this._resetState(),this):new e().parser(t)}_resetState(){o(`_resetState: resetting packet, error, _list, and _stateCounter`),this.packet=new i,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),o(`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++,o(`parse: state complete. _stateCounter is now: %d`,this._stateCounter),o(`parse: packet.length: %d, buffer list length: %d`,this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return o(`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=a.types[e>>a.CMD_SHIFT],this.packet.retain=(e&a.RETAIN_MASK)!==0,this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=(e&a.DUP_MASK)!==0,o(`_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)),o(`_parseLength %d`,e.value),!!e}_parsePayload(){o(`_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(Error(`Not supported`))}e=!0}return o(`_parsePayload complete result: %s`,e),e}_parseConnect(){o(`_parseConnect`);let e,t,n,r,i={},s=this.packet,c=this._parseString();if(c===null)return this._emitError(Error(`Cannot parse protocolId`));if(c!==`MQTT`&&c!==`MQIsdp`)return this._emitError(Error(`Invalid protocolId`));if(s.protocolId=c,this._pos>=this._list.length)return this._emitError(Error(`Packet too short`));if(s.protocolVersion=this._list.readUInt8(this._pos),s.protocolVersion>=128&&(s.bridgeMode=!0,s.protocolVersion-=128),s.protocolVersion!==3&&s.protocolVersion!==4&&s.protocolVersion!==5)return this._emitError(Error(`Invalid protocol version`));if(this._pos++,this._pos>=this._list.length||(i.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,i.will&&(s.will={},s.will.retain=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK)!==0,s.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),s.clean=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK)!==0,this._pos++,s.keepalive=this._parseNum(),s.keepalive===-1))return this._emitError(Error(`Packet too short`));if(s.protocolVersion===5){let e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(s.properties=e)}let l=this._parseString();if(l===null)return this._emitError(Error(`Packet too short`));if(s.clientId=l,o(`_parseConnect: packet.clientId: %s`,s.clientId),i.will){if(s.protocolVersion===5){let e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(s.will.properties=e)}if(e=this._parseString(),e===null)return this._emitError(Error(`Cannot parse will topic`));if(s.will.topic=e,o(`_parseConnect: packet.will.topic: %s`,s.will.topic),t=this._parseBuffer(),t===null)return this._emitError(Error(`Cannot parse will payload`));s.will.payload=t,o(`_parseConnect: packet.will.paylaod: %s`,s.will.payload)}if(i.username){if(r=this._parseString(),r===null)return this._emitError(Error(`Cannot parse username`));s.username=r,o(`_parseConnect: packet.username: %s`,s.username)}if(i.password){if(n=this._parseBuffer(),n===null)return this._emitError(Error(`Cannot parse password`));s.password=n}return this.settings=s,o(`_parseConnect: complete`),s}_parseConnack(){o(`_parseConnack`);let e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.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(Error(`Cannot parse return code`));if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}o(`_parseConnack: complete`)}_parsePublish(){o(`_parsePublish`);let e=this.packet;if(e.topic=this._parseString(),e.topic===null)return this._emitError(Error(`Cannot parse topic`));if(!(e.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),o(`_parsePublish: payload from buffer list: %o`,e.payload)}}_parseSubscribe(){o(`_parseSubscribe`);let e=this.packet,t,n,r,i,s,c,l;if(e.qos!==1)return this._emitError(Error(`Wrong subscribe header`));if(e.subscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),t===null)return this._emitError(Error(`Cannot parse topic`));if(this._pos>=e.length)return this._emitError(Error(`Malformed Subscribe Payload`));n=this._parseByte(),r=n&a.SUBSCRIBE_OPTIONS_QOS_MASK,c=(n>>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK)!==0,s=(n>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,i=n>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:r},this.settings.protocolVersion===5?(l.nl=c,l.rap=s,l.rh=i):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),o("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){o(`_parseSuback`);let e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){o(`_parseUnsubscribe`);let e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){let t=this._parseString();if(t===null)return this._emitError(Error(`Cannot parse topic`));o("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){o(`_parseUnsuback`);let e=this.packet;if(!this._parseMessageId())return this._emitError(Error(`Cannot parse messageId`));if(this.settings.protocolVersion===5){let t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){o("_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(),o("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){let e=this.packet;if(o(`_parseDisconnect`),this.settings.protocolVersion===5){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;let t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return o(`_parseDisconnect result: true`),!0}_parseAuth(){o(`_parseAuth`);let e=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(Error(`Not supported auth packet for this version MQTT`));e.reasonCode=this._parseByte();let t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),o(`_parseAuth: result: true`),!0}_parseMessageId(){let e=this.packet;return e.messageId=this._parseNum(),e.messageId===null?(this._emitError(Error(`Cannot parse messageId`)),!1):(o(`_parseMessageId: packet.messageId %d`,e.messageId),!0)}_parseString(e){let t=this._parseNum(),n=t+this._pos;if(t===-1||n>this._list.length||n>this.packet.length)return null;let r=this._list.toString(`utf8`,this._pos,n);return this._pos+=t,o(`_parseString: result: %s`,r),r}_parseStringPair(){return o(`_parseStringPair`),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let e=this._parseNum(),t=e+this._pos;if(e===-1||t>this._list.length||t>this.packet.length)return null;let n=this._list.slice(this._pos,t);return this._pos+=e,o(`_parseBuffer: result: %o`,n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;let e=this._list.readUInt16BE(this._pos);return this._pos+=2,o(`_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,o(`_parse4ByteNum: result: %s`,e),e}_parseVarByteNum(e){o(`_parseVarByteNum`);let t=0,n=1,r=0,i=!1,s,c=this._pos?this._pos:0;for(;t<4&&c+t<this._list.length;){if(s=this._list.readUInt8(c+ t++),r+=n*(s&a.VARBYTEINT_MASK),n*=128,(s&a.VARBYTEINT_FIN_MASK)===0){i=!0;break}if(this._list.length<=t)break}return!i&&t===4&&this._list.length>=t&&this._emitError(Error(`Invalid variable byte integer`)),c&&(this._pos+=t),i=i?e?{bytes:t,value:r}:r:!1,o(`_parseVarByteNum: result: %o`,i),i}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),o(`_parseByte: result: %o`,e),e}_parseByType(e){switch(o(`_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(){o(`_parseProperties`);let e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){let e=this._parseByte();if(!e)return this._emitError(Error(`Cannot parse property code type`)),!1;let t=a.propertiesCodes[e];if(!t)return this._emitError(Error(`Unknown property`)),!1;if(t===`userProperties`){n[t]||(n[t]=Object.create(null));let e=this._parseByType(a.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{let r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value;continue}n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(a.propertiesTypes[t]))):n[t]=this._parseByType(a.propertiesTypes[t])}return n}_newPacket(){return o(`_newPacket`),this.packet&&(this._list.consume(this.packet.length),o(`_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)),o(`_newPacket: new packet`),this.packet=new i,this._pos=0,!0}_emitError(e){o(`_emitError`),this.error=e,this.emit(`error`,e)}}})),we=o(((e,t)=>{let n={},r=Buffer.isBuffer(Buffer.from([1,2]).subarray(0,1));function i(e){let t=Buffer.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(e&255,1),t}function a(){for(let e=0;e<65536;e++)n[e]=i(e)}function o(e){let t=0,n=0,i=Buffer.allocUnsafe(4);do t=e%128|0,e=e/128|0,e>0&&(t|=128),i.writeUInt8(t,n++);while(e>0&&n<4);return e>0&&(n=0),r?i.subarray(0,n):i.slice(0,n)}function s(e){let t=Buffer.allocUnsafe(4);return t.writeUInt32BE(e,0),t}t.exports={cache:n,generateCache:a,generateNumber:i,genBufVariableByteInt:o,generate4ByteBuffer:s}})),Te=o(((e,t)=>{typeof process>`u`||!process.version||process.version.indexOf(`v0.`)===0||process.version.indexOf(`v1.`)===0&&process.version.indexOf(`v1.8.`)!==0?t.exports={nextTick:n}:t.exports=process;function n(e,t,n,r){if(typeof e!=`function`)throw TypeError(`"callback" argument must be a function`);var i=arguments.length,a,o;switch(i){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,n)});case 4:return process.nextTick(function(){e.call(null,t,n,r)});default:for(a=Array(i-1),o=0;o<a.length;)a[o++]=arguments[o];return process.nextTick(function(){e.apply(null,a)})}}})),Ee=o(((e,t)=>{let n=Se(),r=Buffer.allocUnsafe(0),i=Buffer.from([0]),a=we(),o=Te().nextTick,s=X()(`mqtt-packet:writeToStream`),c=a.cache,l=a.generateNumber,u=a.generateCache,d=a.genBufVariableByteInt,f=a.generate4ByteBuffer,p=M,m=!0;function h(e,t,n){switch(s(`generate called`),t.cork&&(t.cork(),o(g,t)),m&&(m=!1,u()),s(`generate: packet.cmd: %s`,e.cmd),e.cmd){case`connect`:return _(e,t,n);case`connack`:return v(e,t,n);case`publish`:return y(e,t,n);case`puback`:case`pubrec`:case`pubrel`:case`pubcomp`:return b(e,t,n);case`subscribe`:return x(e,t,n);case`suback`:return S(e,t,n);case`unsubscribe`:return C(e,t,n);case`unsuback`:return w(e,t,n);case`pingreq`:case`pingresp`:return T(e,t,n);case`disconnect`:return E(e,t,n);case`auth`:return D(e,t,n);default:return t.emit(`error`,Error(`Unknown command`)),!1}}Object.defineProperty(h,`cacheNumbers`,{get(){return p===M},set(e){e?((!c||Object.keys(c).length===0)&&(m=!0),p=M):(m=!1,p=N)}});function g(e){e.uncork()}function _(e,t,r){let i=e||{},a=i.protocolId||`MQTT`,o=i.protocolVersion||4,s=i.will,c=i.clean,l=i.keepalive||0,u=i.clientId||``,d=i.username,f=i.password,m=i.properties;c===void 0&&(c=!0);let h=0;if(!a||typeof a!=`string`&&!Buffer.isBuffer(a))return t.emit(`error`,Error(`Invalid protocolId`)),!1;if(h+=a.length+2,o!==3&&o!==4&&o!==5)return t.emit(`error`,Error(`Invalid protocol version`)),!1;if(h+=1,(typeof u==`string`||Buffer.isBuffer(u))&&(u||o>=4)&&(u||c))h+=Buffer.byteLength(u)+2;else{if(o<4)return t.emit(`error`,Error(`clientId must be supplied before 3.1.1`)),!1;if(c*1==0)return t.emit(`error`,Error(`clientId must be given if cleanSession set to 0`)),!1}if(typeof l!=`number`||l<0||l>65535||l%1!=0)return t.emit(`error`,Error(`Invalid keepalive`)),!1;if(h+=2,h+=1,o===5){var g=F(t,m);if(!g)return!1;h+=g.length}if(s){if(typeof s!=`object`)return t.emit(`error`,Error(`Invalid will`)),!1;if(!s.topic||typeof s.topic!=`string`)return t.emit(`error`,Error(`Invalid will topic`)),!1;if(h+=Buffer.byteLength(s.topic)+2,h+=2,s.payload)if(s.payload.length>=0)typeof s.payload==`string`?h+=Buffer.byteLength(s.payload):h+=s.payload.length;else return t.emit(`error`,Error(`Invalid will payload`)),!1;var _={};if(o===5){if(_=F(t,s.properties),!_)return!1;h+=_.length}}let v=!1;if(d!=null)if(B(d))v=!0,h+=Buffer.byteLength(d)+2;else return t.emit(`error`,Error(`Invalid username`)),!1;if(f!=null){if(!v)return t.emit(`error`,Error(`Username is required to use password`)),!1;if(B(f))h+=z(f)+2;else return t.emit(`error`,Error(`Invalid password`)),!1}t.write(n.CONNECT_HEADER),k(t,h),P(t,a),i.bridgeMode&&(o+=128),t.write(o===131?n.VERSION131:o===132?n.VERSION132:o===4?n.VERSION4:o===5?n.VERSION5:n.VERSION3);let y=0;return y|=d==null?0:n.USERNAME_MASK,y|=f==null?0:n.PASSWORD_MASK,y|=s&&s.retain?n.WILL_RETAIN_MASK:0,y|=s&&s.qos?s.qos<<n.WILL_QOS_SHIFT:0,y|=s?n.WILL_FLAG_MASK:0,y|=c?n.CLEAN_SESSION_MASK:0,t.write(Buffer.from([y])),p(t,l),o===5&&g.write(),P(t,u),s&&(o===5&&_.write(),A(t,s.topic),P(t,s.payload)),d!=null&&P(t,d),f!=null&&P(t,f),!0}function v(e,t,r){let a=r?r.protocolVersion:4,o=e||{},s=a===5?o.reasonCode:o.returnCode,c=o.properties,l=2;if(typeof s!=`number`)return t.emit(`error`,Error(`Invalid return code`)),!1;let u=null;if(a===5){if(u=F(t,c),!u)return!1;l+=u.length}return t.write(n.CONNACK_HEADER),k(t,l),t.write(o.sessionPresent?n.SESSIONPRESENT_HEADER:i),t.write(Buffer.from([s])),u?.write(),!0}function y(e,t,i){s(`publish: packet: %o`,e);let a=i?i.protocolVersion:4,o=e||{},c=o.qos||0,l=o.retain?n.RETAIN_MASK:0,u=o.topic,d=o.payload||r,f=o.messageId,m=o.properties,h=0;if(typeof u==`string`)h+=Buffer.byteLength(u)+2;else if(Buffer.isBuffer(u))h+=u.length+2;else return t.emit(`error`,Error(`Invalid topic`)),!1;if(Buffer.isBuffer(d)?h+=d.length:h+=Buffer.byteLength(d),c&&typeof f!=`number`)return t.emit(`error`,Error(`Invalid messageId`)),!1;c&&(h+=2);let g=null;if(a===5){if(g=F(t,m),!g)return!1;h+=g.length}return t.write(n.PUBLISH_HEADER[c][+!!o.dup][+!!l]),k(t,h),p(t,z(u)),t.write(u),c>0&&p(t,f),g?.write(),s(`publish: payload: %o`,d),t.write(d)}function b(e,t,r){let i=r?r.protocolVersion:4,a=e||{},o=a.cmd||`puback`,s=a.messageId,c=a.dup&&o===`pubrel`?n.DUP_MASK:0,l=0,u=a.reasonCode,d=a.properties,f=i===5?3:2;if(o===`pubrel`&&(l=1),typeof s!=`number`)return t.emit(`error`,Error(`Invalid messageId`)),!1;let m=null;if(i===5&&typeof d==`object`){if(m=I(t,d,r,f),!m)return!1;f+=m.length}return t.write(n.ACKS[o][l][c][0]),k(t,f),p(t,s),i===5&&t.write(Buffer.from([u])),m!==null&&m.write(),!0}function x(e,t,r){s(`subscribe: packet: `);let i=r?r.protocolVersion:4,a=e||{},o=a.dup?n.DUP_MASK:0,c=a.messageId,l=a.subscriptions,u=a.properties,d=0;if(typeof c!=`number`)return t.emit(`error`,Error(`Invalid messageId`)),!1;d+=2;let f=null;if(i===5){if(f=F(t,u),!f)return!1;d+=f.length}if(typeof l==`object`&&l.length)for(let e=0;e<l.length;e+=1){let n=l[e].topic,r=l[e].qos;if(typeof n!=`string`)return t.emit(`error`,Error(`Invalid subscriptions - invalid topic`)),!1;if(typeof r!=`number`)return t.emit(`error`,Error(`Invalid subscriptions - invalid qos`)),!1;if(i===5){if(typeof(l[e].nl||!1)!=`boolean`)return t.emit(`error`,Error(`Invalid subscriptions - invalid No Local`)),!1;if(typeof(l[e].rap||!1)!=`boolean`)return t.emit(`error`,Error(`Invalid subscriptions - invalid Retain as Published`)),!1;let n=l[e].rh||0;if(typeof n!=`number`||n>2)return t.emit(`error`,Error(`Invalid subscriptions - invalid Retain Handling`)),!1}d+=Buffer.byteLength(n)+2+1}else return t.emit(`error`,Error(`Invalid subscriptions`)),!1;s(`subscribe: writing to stream: %o`,n.SUBSCRIBE_HEADER),t.write(n.SUBSCRIBE_HEADER[1][+!!o][0]),k(t,d),p(t,c),f!==null&&f.write();let m=!0;for(let e of l){let r=e.topic,a=e.qos,o=+e.nl,s=+e.rap,c=e.rh,l;A(t,r),l=n.SUBSCRIBE_OPTIONS_QOS[a],i===5&&(l|=o?n.SUBSCRIBE_OPTIONS_NL:0,l|=s?n.SUBSCRIBE_OPTIONS_RAP:0,l|=c?n.SUBSCRIBE_OPTIONS_RH[c]:0),m=t.write(Buffer.from([l]))}return m}function S(e,t,r){let i=r?r.protocolVersion:4,a=e||{},o=a.messageId,s=a.granted,c=a.properties,l=0;if(typeof o!=`number`)return t.emit(`error`,Error(`Invalid messageId`)),!1;if(l+=2,typeof s==`object`&&s.length)for(let e=0;e<s.length;e+=1){if(typeof s[e]!=`number`)return t.emit(`error`,Error(`Invalid qos vector`)),!1;l+=1}else return t.emit(`error`,Error(`Invalid qos vector`)),!1;let u=null;if(i===5){if(u=I(t,c,r,l),!u)return!1;l+=u.length}return t.write(n.SUBACK_HEADER),k(t,l),p(t,o),u!==null&&u.write(),t.write(Buffer.from(s))}function C(e,t,r){let i=r?r.protocolVersion:4,a=e||{},o=a.messageId,s=a.dup?n.DUP_MASK:0,c=a.unsubscriptions,l=a.properties,u=0;if(typeof o!=`number`)return t.emit(`error`,Error(`Invalid messageId`)),!1;if(u+=2,typeof c==`object`&&c.length)for(let e=0;e<c.length;e+=1){if(typeof c[e]!=`string`)return t.emit(`error`,Error(`Invalid unsubscriptions`)),!1;u+=Buffer.byteLength(c[e])+2}else return t.emit(`error`,Error(`Invalid unsubscriptions`)),!1;let d=null;if(i===5){if(d=F(t,l),!d)return!1;u+=d.length}t.write(n.UNSUBSCRIBE_HEADER[1][+!!s][0]),k(t,u),p(t,o),d!==null&&d.write();let f=!0;for(let e=0;e<c.length;e++)f=A(t,c[e]);return f}function w(e,t,r){let i=r?r.protocolVersion:4,a=e||{},o=a.messageId,s=a.dup?n.DUP_MASK:0,c=a.granted,l=a.properties,u=a.cmd,d=2;if(typeof o!=`number`)return t.emit(`error`,Error(`Invalid messageId`)),!1;if(i===5)if(typeof c==`object`&&c.length)for(let e=0;e<c.length;e+=1){if(typeof c[e]!=`number`)return t.emit(`error`,Error(`Invalid qos vector`)),!1;d+=1}else return t.emit(`error`,Error(`Invalid qos vector`)),!1;let f=null;if(i===5){if(f=I(t,l,r,d),!f)return!1;d+=f.length}return t.write(n.ACKS[u][0][s][0]),k(t,d),p(t,o),f!==null&&f.write(),i===5&&t.write(Buffer.from(c)),!0}function T(e,t,r){return t.write(n.EMPTY[e.cmd])}function E(e,t,r){let i=r?r.protocolVersion:4,a=e||{},o=a.reasonCode,s=a.properties,c=+(i===5),l=null;if(i===5){if(l=I(t,s,r,c),!l)return!1;c+=l.length}return t.write(Buffer.from([n.codes.disconnect<<4])),k(t,c),i===5&&t.write(Buffer.from([o])),l!==null&&l.write(),!0}function D(e,t,r){let i=r?r.protocolVersion:4,a=e||{},o=a.reasonCode,s=a.properties,c=+(i===5);i!==5&&t.emit(`error`,Error(`Invalid mqtt version for auth packet`));let l=I(t,s,r,c);return l?(c+=l.length,t.write(Buffer.from([n.codes.auth<<4])),k(t,c),t.write(Buffer.from([o])),l!==null&&l.write(),!0):!1}let O={};function k(e,t){if(t>n.VARBYTEINT_MAX)return e.emit(`error`,Error(`Invalid variable byte integer: ${t}`)),!1;let r=O[t];return r||(r=d(t),t<16384&&(O[t]=r)),s(`writeVarByteInt: writing to stream: %o`,r),e.write(r)}function A(e,t){let n=Buffer.byteLength(t);return p(e,n),s(`writeString: %s`,t),e.write(t,`utf8`)}function j(e,t,n){A(e,t),A(e,n)}function M(e,t){return s(`writeNumberCached: number: %d`,t),s(`writeNumberCached: %o`,c[t]),e.write(c[t])}function N(e,t){let n=l(t);return s(`writeNumberGenerated: %o`,n),e.write(n)}function ee(e,t){let n=f(t);return s(`write4ByteNumber: %o`,n),e.write(n)}function P(e,t){typeof t==`string`?A(e,t):t?(p(e,t.length),e.write(t)):p(e,0)}function F(e,t){if(typeof t!=`object`||t.length!=null)return{length:1,write(){R(e,{},0)}};let r=0;function i(t,r){let i=n.propertiesTypes[t],a=0;switch(i){case`byte`:if(typeof r!=`boolean`)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=2;break;case`int8`:if(typeof r!=`number`||r<0||r>255)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=2;break;case`binary`:if(r&&r===null)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=1+Buffer.byteLength(r)+2;break;case`int16`:if(typeof r!=`number`||r<0||r>65535)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=3;break;case`int32`:if(typeof r!=`number`||r<0||r>4294967295)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=5;break;case`var`:if(typeof r!=`number`||r<0||r>268435455)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=1+Buffer.byteLength(d(r));break;case`string`:if(typeof r!=`string`)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=3+Buffer.byteLength(r.toString());break;case`pair`:if(typeof r!=`object`)return e.emit(`error`,Error(`Invalid ${t}: ${r}`)),!1;a+=Object.getOwnPropertyNames(r).reduce((e,t)=>{let n=r[t];return Array.isArray(n)?e+=n.reduce((e,n)=>(e+=3+Buffer.byteLength(t.toString())+2+Buffer.byteLength(n.toString()),e),0):e+=3+Buffer.byteLength(t.toString())+2+Buffer.byteLength(r[t].toString()),e},0);break;default:return e.emit(`error`,Error(`Invalid property ${t}: ${r}`)),!1}return a}if(t)for(let e in t){let n=0,a=0,o=t[e];if(Array.isArray(o))for(let t=0;t<o.length;t++){if(a=i(e,o[t]),!a)return!1;n+=a}else{if(a=i(e,o),!a)return!1;n=a}if(!n)return!1;r+=n}return{length:Buffer.byteLength(d(r))+r,write(){R(e,t,r)}}}function I(e,t,n,r){let i=[`reasonString`,`userProperties`],a=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0,o=F(e,t);if(a)for(;r+o.length>a;){let n=i.shift();if(n&&t[n])delete t[n],o=F(e,t);else return!1}return o}function L(e,t,r){switch(n.propertiesTypes[t]){case`byte`:e.write(Buffer.from([n.properties[t]])),e.write(Buffer.from([+r]));break;case`int8`:e.write(Buffer.from([n.properties[t]])),e.write(Buffer.from([r]));break;case`binary`:e.write(Buffer.from([n.properties[t]])),P(e,r);break;case`int16`:e.write(Buffer.from([n.properties[t]])),p(e,r);break;case`int32`:e.write(Buffer.from([n.properties[t]])),ee(e,r);break;case`var`:e.write(Buffer.from([n.properties[t]])),k(e,r);break;case`string`:e.write(Buffer.from([n.properties[t]])),A(e,r);break;case`pair`:Object.getOwnPropertyNames(r).forEach(i=>{let a=r[i];Array.isArray(a)?a.forEach(r=>{e.write(Buffer.from([n.properties[t]])),j(e,i.toString(),r.toString())}):(e.write(Buffer.from([n.properties[t]])),j(e,i.toString(),a.toString()))});break;default:return e.emit(`error`,Error(`Invalid property ${t} value: ${r}`)),!1}}function R(e,t,n){k(e,n);for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==null){let r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)L(e,n,r[t]);else L(e,n,r)}}function z(e){return e?e instanceof Buffer?e.length:Buffer.byteLength(e):0}function B(e){return typeof e==`string`||e instanceof Buffer}t.exports=h})),De=o(((e,t)=>{let n=Ee(),r=require(`events`);function i(e,t){let r=new a;return n(e,r,t),r.concat()}var a=class extends r{constructor(){super(),this._array=Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0,t=Array(this._array.length),n=this._array,r=0,i;for(i=0;i<n.length&&n[i]!==void 0;i++)typeof n[i]==`string`?t[i]=Buffer.byteLength(n[i]):t[i]=n[i].length,e+=t[i];let a=Buffer.allocUnsafe(e);for(i=0;i<n.length&&n[i]!==void 0;i++)typeof n[i]==`string`?(a.write(n[i],r),r+=t[i]):(n[i].copy(a,r),r+=t[i]);return a}};t.exports=i})),Oe=o((e=>{e.parser=Ce().parser,e.generate=De(),e.writeToStream=Ee()})),ke=o(((e,t)=>{function n(){if(!(this instanceof n))return new n;this.nextId=Math.max(1,Math.floor(Math.random()*65535))}n.prototype.allocate=function(){let e=this.nextId++;return this.nextId===65536&&(this.nextId=1),e},n.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},n.prototype.register=function(e){return!0},n.prototype.deallocate=function(e){},n.prototype.clear=function(){},t.exports=n})),Ae=o(((e,t)=>{function n(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||=r._interval,r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&=(clearInterval(r._interval),void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function r(){if(typeof arguments[0]!=`function`)throw Error(`callback needed`);if(typeof arguments[1]!=`number`)throw Error(`interval needed`);var e;if(arguments.length>0){e=Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new n(arguments[0],arguments[1],e)}t.exports=r})),je=o(((e,t)=>{t.exports=r;function n(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function r(e){if(e||={},e.circles)return i(e);return e.proto?a:r;function t(e,t){for(var r=Object.keys(e),i=Array(r.length),a=0;a<r.length;a++){var o=r[a],s=e[o];typeof s!=`object`||!s?i[o]=s:s instanceof Date?i[o]=new Date(s):ArrayBuffer.isView(s)?i[o]=n(s):i[o]=t(s)}return i}function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,r);if(e instanceof Map)return new Map(t(Array.from(e),r));if(e instanceof Set)return new Set(t(Array.from(e),r));var i={};for(var a in e)if(Object.hasOwnProperty.call(e,a)!==!1){var o=e[a];typeof o!=`object`||!o?i[a]=o:o instanceof Date?i[a]=new Date(o):o instanceof Map?i[a]=new Map(t(Array.from(o),r)):o instanceof Set?i[a]=new Set(t(Array.from(o),r)):ArrayBuffer.isView(o)?i[a]=n(o):i[a]=r(o)}return i}function a(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,a);if(e instanceof Map)return new Map(t(Array.from(e),a));if(e instanceof Set)return new Set(t(Array.from(e),a));var r={};for(var i in e){var o=e[i];typeof o!=`object`||!o?r[i]=o:o instanceof Date?r[i]=new Date(o):o instanceof Map?r[i]=new Map(t(Array.from(o),a)):o instanceof Set?r[i]=new Set(t(Array.from(o),a)):ArrayBuffer.isView(o)?r[i]=n(o):r[i]=a(o)}return r}}function i(e){var t=[],r=[];return e.proto?o:a;function i(e,i){for(var a=Object.keys(e),o=Array(a.length),s=0;s<a.length;s++){var c=a[s],l=e[c];if(typeof l!=`object`||!l)o[c]=l;else if(l instanceof Date)o[c]=new Date(l);else if(ArrayBuffer.isView(l))o[c]=n(l);else{var u=t.indexOf(l);u===-1?o[c]=i(l):o[c]=r[u]}}return o}function a(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return i(e,a);if(e instanceof Map)return new Map(i(Array.from(e),a));if(e instanceof Set)return new Set(i(Array.from(e),a));var o={};for(var s in t.push(e),r.push(o),e)if(Object.hasOwnProperty.call(e,s)!==!1){var c=e[s];if(typeof c!=`object`||!c)o[s]=c;else if(c instanceof Date)o[s]=new Date(c);else if(c instanceof Map)o[s]=new Map(i(Array.from(c),a));else if(c instanceof Set)o[s]=new Set(i(Array.from(c),a));else if(ArrayBuffer.isView(c))o[s]=n(c);else{var l=t.indexOf(c);l===-1?o[s]=a(c):o[s]=r[l]}}return t.pop(),r.pop(),o}function o(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return i(e,o);if(e instanceof Map)return new Map(i(Array.from(e),o));if(e instanceof Set)return new Set(i(Array.from(e),o));var a={};for(var s in t.push(e),r.push(a),e){var c=e[s];if(typeof c!=`object`||!c)a[s]=c;else if(c instanceof Date)a[s]=new Date(c);else if(c instanceof Map)a[s]=new Map(i(Array.from(c),o));else if(c instanceof Set)a[s]=new Set(i(Array.from(c),o));else if(ArrayBuffer.isView(c))a[s]=n(c);else{var l=t.indexOf(c);l===-1?a[s]=o(c):a[s]=r[l]}}return t.pop(),r.pop(),a}}})),Me=o(((e,t)=>{t.exports=je()()})),Ne=o(((e,t)=>{function n(e){let t=e.split(`/`);for(let e=0;e<t.length;e++)if(t[e]!==`+`){if(t[e]===`#`)return e===t.length-1;if(t[e].indexOf(`+`)!==-1||t[e].indexOf(`#`)!==-1)return!1}return!0}function r(e){if(e.length===0)return`empty_topic_list`;for(let t=0;t<e.length;t++)if(!n(e[t]))return e[t];return null}t.exports={validateTopics:r}})),Pe=o(((e,t)=>{let n=require(`events`).EventEmitter,r=F(),i=I(),a=ve(),o=Oe(),s=ke(),c=P().Writable,l=S(),u=Ae(),d=Me(),f=Ne(),p=h(),m=X()(`mqttjs:client`),g=process?process.nextTick:function(e){setTimeout(e,0)},_=global.setImmediate||function(e){g(e)},v={keepalive:60,reschedulePings:!0,protocolId:`MQTT`,protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0},y=[`ECONNREFUSED`,`EADDRINUSE`,`ECONNRESET`,`ENOTFOUND`],b={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 x(){return`mqttjs_`+Math.random().toString(16).substr(2,8)}function C(e,t){if(e.options.protocolVersion===5&&t.cmd===`publish`){let n;t.properties&&(n=t.properties.topicAlias);let r=t.topic.toString();if(e.topicAliasSend)if(n){if(r.length!==0&&(m(`applyTopicAlias :: register topic: %s - alias: %d`,r,n),!e.topicAliasSend.put(r,n)))return m(`applyTopicAlias :: error out of range. topic: %s - alias: %d`,r,n),Error(`Sending Topic Alias out of range`)}else r.length!==0&&(e.options.autoAssignTopicAlias?(n=e.topicAliasSend.getAliasByTopic(r),n?(t.topic=``,t.properties={...t.properties,topicAlias:n},m(`applyTopicAlias :: auto assign(use) topic: %s - alias: %d`,r,n)):(n=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(r,n),t.properties={...t.properties,topicAlias:n},m(`applyTopicAlias :: auto assign topic: %s - alias: %d`,r,n))):e.options.autoUseTopicAlias&&(n=e.topicAliasSend.getAliasByTopic(r),n&&(t.topic=``,t.properties={...t.properties,topicAlias:n},m(`applyTopicAlias :: auto use topic: %s - alias: %d`,r,n))));else if(n)return m(`applyTopicAlias :: error out of range. topic: %s - alias: %d`,r,n),Error(`Sending Topic Alias out of range`)}}function w(e,t){let n;t.properties&&(n=t.properties.topicAlias);let r=t.topic.toString();if(r.length===0){if(n===void 0||(r=e.topicAliasSend.getTopicByAlias(n),r===void 0))return Error(`Unregistered Topic Alias`);t.topic=r}n&&delete t.properties.topicAlias}function T(e,t,n){m(`sendPacket :: packet: %O`,t),m("sendPacket :: emitting `packetsend`"),e.emit(`packetsend`,t),m(`sendPacket :: writing to stream`);let r=o.writeToStream(t,e.stream,e.options);m(`sendPacket :: writeToStream result %s`,r),!r&&n&&n!==k?(m("sendPacket :: handle events on `drain` once through callback."),e.stream.once(`drain`,n)):n&&(m(`sendPacket :: invoking cb`),n())}function E(e){e&&(m(`flush: queue exists? %b`,!!e),Object.keys(e).forEach(function(t){typeof e[t].cb==`function`&&(e[t].cb(Error(`Connection closed`)),delete e[t])}))}function D(e){e&&(m(`flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function`),Object.keys(e).forEach(function(t){e[t].volatile&&typeof e[t].cb==`function`&&(e[t].cb(Error(`Connection closed`)),delete e[t])}))}function O(e,t,n,r){m(`storeAndSend :: store packet with cmd %s to outgoingStore`,t.cmd);let i=t,a;if(i.cmd===`publish`&&(i=d(t),a=w(e,i),a))return n&&n(a);e.outgoingStore.put(i,function(i){if(i)return n&&n(i);r(),T(e,t,n)})}function k(e){m(`nop ::`,e)}function A(e,t){let a,o=this;if(!(this instanceof A))return new A(e,t);for(a in this.options=t||{},v)this.options[a]===void 0?this.options[a]=v[a]:this.options[a]=t[a];m(`MqttClient :: options.protocol`,t.protocol),m(`MqttClient :: options.protocolVersion`,t.protocolVersion),m(`MqttClient :: options.username`,t.username),m(`MqttClient :: options.keepalive`,t.keepalive),m(`MqttClient :: options.reconnectPeriod`,t.reconnectPeriod),m(`MqttClient :: options.rejectUnauthorized`,t.rejectUnauthorized),m(`MqttClient :: options.topicAliasMaximum`,t.topicAliasMaximum),this.options.clientId=typeof t.clientId==`string`?t.clientId:x(),m(`MqttClient :: clientId`,this.options.clientId),this.options.customHandleAcks=t.protocolVersion===5&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=this.options.messageIdProvider===void 0?new s:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new r,this.incomingStore=t.incomingStore||new r,this.queueQoSZero=t.queueQoSZero===void 0?!0:t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?m(`MqttClient :: options.topicAliasMaximum is out of range`):this.topicAliasRecv=new i(t.topicAliasMaximum)),this.on(`connect`,function(){let e=this.queue;function t(){let n=e.shift();m(`deliver :: entry %o`,n);let r=null;if(!n){o._resubscribe();return}r=n.packet,m(`deliver :: call _sendPacket for %o`,r);let i=!0;r.messageId&&r.messageId!==0&&(o.messageIdProvider.register(r.messageId)||(i=!1)),i?o._sendPacket(r,function(e){n.cb&&n.cb(e),t()}):(m(`messageId: %d has already used. The message is skipped and removed.`,r.messageId),t())}m(`connect :: sending queued packets`),t()}),this.on(`close`,function(){m("close :: connected set to `false`"),this.connected=!1,m(`close :: clearing connackTimer`),clearTimeout(this.connackTimer),m(`close :: clearing ping timer`),o.pingTimer!==null&&(o.pingTimer.clear(),o.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),m(`close :: calling _setupReconnect`),this._setupReconnect()}),n.call(this),m(`MqttClient :: setting up stream`),this._setupStream()}l(A,n),A.prototype._setupStream=function(){let e=this,t=new c,n=o.parser(this.options),r=null,i=[];m(`_setupStream :: calling method to clear reconnect`),this._clearReconnect(),m(`_setupStream :: using streamBuilder provided to client to create stream`),this.stream=this.streamBuilder(this),n.on(`packet`,function(e){m(`parser :: on packet push to packets array.`),i.push(e)});function a(){if(i.length)g(s);else{let e=r;r=null,e()}}function s(){m(`work :: getting next packet in queue`);let t=i.shift();if(t)m(`work :: packet pulled from queue`),e._handlePacket(t,a);else{m(`work :: no packets in queue`);let e=r;r=null,m(`work :: done flag is %s`,!!e),e&&e()}}t._write=function(e,t,i){r=i,m(`writable stream :: parsing buffer`),n.parse(e),s()};function l(t){m(`streamErrorHandler :: error`,t.message),y.includes(t.code)?(m(`streamErrorHandler :: emitting error`),e.emit(`error`,t)):k(t)}m(`_setupStream :: pipe stream to writable stream`),this.stream.pipe(t),this.stream.on(`error`,l),this.stream.on(`close`,function(){m(`(%s)stream :: on close`,e.options.clientId),D(e.outgoing),m(`stream: emit close to MqttClient`),e.emit(`close`)}),m("_setupStream: sending packet `connect`");let u=Object.create(this.options);if(u.cmd=`connect`,this.topicAliasRecv&&(u.properties||={},this.topicAliasRecv&&(u.properties.topicAliasMaximum=this.topicAliasRecv.max)),T(this,u),n.on(`error`,this.emit.bind(this,`error`)),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end(()=>this.emit(`error`,Error(`Packet has no Authentication Method`))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket==`object`){let e=p({cmd:`auth`,reasonCode:0},this.options.authPacket);T(this,e)}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){m("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)},this.options.connectTimeout)},A.prototype._handlePacket=function(e,t){let n=this.options;if(n.protocolVersion===5&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<e.length)return this.emit(`error`,Error(`exceeding packets size `+e.cmd)),this.end({reasonCode:149,properties:{reasonString:`Maximum packet size was exceeded`}}),this;switch(m(`_handlePacket :: emitting packetreceive`),this.emit(`packetreceive`,e),e.cmd){case`publish`:this._handlePublish(e,t);break;case`puback`:case`pubrec`:case`pubcomp`:case`suback`:case`unsuback`:this._handleAck(e),t();break;case`pubrel`:this._handlePubrel(e,t);break;case`connack`:this._handleConnack(e),t();break;case`auth`:this._handleAuth(e),t();break;case`pingresp`:this._handlePingresp(e),t();break;case`disconnect`:this._handleDisconnect(e),t();break;default:break}},A.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==k?e(Error(`client disconnecting`)):this.emit(`error`,Error(`client disconnecting`))),this.disconnecting},A.prototype.publish=function(e,t,n,r){m("publish :: message `%s` to topic `%s`",t,e);let i=this.options;if(typeof n==`function`&&(r=n,n=null),n=p({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;let a=this,o=function(){let o=0;if((n.qos===1||n.qos===2)&&(o=a._nextId(),o===null))return m(`No messageId left`),!1;let s={cmd:`publish`,topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:o,dup:n.dup};switch(i.protocolVersion===5&&(s.properties=n.properties),m(`publish :: qos`,n.qos),n.qos){case 1:case 2:a.outgoing[s.messageId]={volatile:!1,cb:r||k},m(`MqttClient:publish: packet cmd: %s`,s.cmd),a._sendPacket(s,void 0,n.cbStorePut);break;default:m(`MqttClient:publish: packet cmd: %s`,s.cmd),a._sendPacket(s,r,n.cbStorePut);break}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!o())&&this._storeProcessingQueue.push({invoke:o,cbStorePut:n.cbStorePut,callback:r}),this},A.prototype.subscribe=function(){let e=this,t=Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let n=[],r=t.shift(),i=r.resubscribe,a=t.pop()||k,o=t.pop(),s=this.options.protocolVersion;delete r.resubscribe,typeof r==`string`&&(r=[r]),typeof a!=`function`&&(o=a,a=k);let c=f.validateTopics(r);if(c!==null)return _(a,Error(`Invalid topic `+c)),this;if(this._checkDisconnecting(a))return m(`subscribe: discconecting true`),this;let l={qos:0};if(s===5&&(l.nl=!1,l.rap=!1,l.rh=0),o=p(l,o),Array.isArray(r)?r.forEach(function(t){if(m(`subscribe: array topic %s`,t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<o.qos||i){let e={topic:t,qos:o.qos};s===5&&(e.nl=o.nl,e.rap=o.rap,e.rh=o.rh,e.properties=o.properties),m("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),n.push(e)}}):Object.keys(r).forEach(function(t){if(m(`subscribe: object topic %s`,t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<r[t].qos||i){let e={topic:t,qos:r[t].qos};s===5&&(e.nl=r[t].nl,e.rap=r[t].rap,e.rh=r[t].rh,e.properties=o.properties),m("subscribe: pushing `%s` to subs list",e),n.push(e)}}),!n.length)return a(null,[]),this;let u=function(){let t=e._nextId();if(t===null)return m(`No messageId left`),!1;let r={cmd:`subscribe`,subscriptions:n,qos:1,retain:!1,dup:!1,messageId:t};if(o.properties&&(r.properties=o.properties),e.options.resubscribe){m(`subscribe :: resubscribe true`);let t=[];n.forEach(function(n){if(e.options.reconnectPeriod>0){let r={qos:n.qos};s===5&&(r.nl=n.nl||!1,r.rap=n.rap||!1,r.rh=n.rh||0,r.properties=n.properties),e._resubscribeTopics[n.topic]=r,t.push(n.topic)}}),e.messageIdToTopic[r.messageId]=t}return e.outgoing[r.messageId]={volatile:!0,cb:function(e,t){if(!e){let e=t.granted;for(let t=0;t<e.length;t+=1)n[t].qos=e[t]}a(e,n)}},m(`subscribe :: call _sendPacket`),e._sendPacket(r),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:a}),this},A.prototype.unsubscribe=function(){let e=this,t=Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let n=t.shift(),r=t.pop()||k,i=t.pop();typeof n==`string`&&(n=[n]),typeof r!=`function`&&(i=r,r=k);let a=f.validateTopics(n);if(a!==null)return _(r,Error(`Invalid topic `+a)),this;if(e._checkDisconnecting(r))return this;let o=function(){let t=e._nextId();if(t===null)return m(`No messageId left`),!1;let a={cmd:`unsubscribe`,qos:1,messageId:t};return typeof n==`string`?a.unsubscriptions=[n]:Array.isArray(n)&&(a.unsubscriptions=n),e.options.resubscribe&&a.unsubscriptions.forEach(function(t){delete e._resubscribeTopics[t]}),typeof i==`object`&&i.properties&&(a.properties=i.properties),e.outgoing[a.messageId]={volatile:!0,cb:r},m(`unsubscribe: call _sendPacket`),e._sendPacket(a),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!o())&&this._storeProcessingQueue.push({invoke:o,callback:r}),this},A.prototype.end=function(e,t,n){let r=this;m(`end :: (%s)`,this.options.clientId),(e==null||typeof e!=`boolean`)&&(n=t||k,t=e,e=!1,typeof t!=`object`&&(n=t,t=null,typeof n!=`function`&&(n=k))),typeof t!=`object`&&(n=t,t=null),m(`end :: cb? %s`,!!n),n||=k;function i(){m(`end :: closeStores: closing incoming and outgoing stores`),r.disconnected=!0,r.incomingStore.close(function(e){r.outgoingStore.close(function(t){if(m(`end :: closeStores: emitting end`),r.emit(`end`),n){let r=e||t;m(`end :: closeStores: invoking callback with args`),n(r)}})}),r._deferredReconnect&&r._deferredReconnect()}function a(){m(`end :: (%s) :: finish :: calling _cleanUp with force %s`,r.options.clientId,e),r._cleanUp(e,()=>{m(`end :: finish :: calling process.nextTick on closeStores`),g(i.bind(r))},t)}return this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(m(`end :: (%s) :: calling finish in 10ms once outgoing is empty`,r.options.clientId),this.once(`outgoingEmpty`,setTimeout.bind(null,a,10))):(m(`end :: (%s) :: immediately calling finish`,r.options.clientId),a()),this)},A.prototype.removeOutgoingMessage=function(e){let t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},function(){t(Error(`Message removed`))}),this},A.prototype.reconnect=function(e){m(`client reconnect`);let t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new r,t.outgoingStore=t.options.outgoingStore||new r,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},A.prototype._reconnect=function(){m(`_reconnect: emitting reconnect to client`),this.emit(`reconnect`),this.connected?(this.end(()=>{this._setupStream()}),m(`client already connected. disconnecting first.`)):(m(`_reconnect: calling _setupStream`),this._setupStream())},A.prototype._setupReconnect=function(){let e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||=(m("_setupReconnect :: emit `offline` state"),this.emit(`offline`),m("_setupReconnect :: set `reconnecting` to `true`"),!0),m(`_setupReconnect :: setting reconnectTimer for %d ms`,e.options.reconnectPeriod),e.reconnectTimer=setInterval(function(){m(`reconnectTimer :: reconnect triggered!`),e._reconnect()},e.options.reconnectPeriod)):m(`_setupReconnect :: doing nothing...`)},A.prototype._clearReconnect=function(){m(`_clearReconnect : clearing reconnect timer`),this.reconnectTimer&&=(clearInterval(this.reconnectTimer),null)},A.prototype._cleanUp=function(e,t){let n=arguments[2];if(t&&(m(`_cleanUp :: done callback provided for on stream close`),this.stream.on(`close`,t)),m(`_cleanUp :: forced? %s`,e),e)this.options.reconnectPeriod===0&&this.options.clean&&E(this.outgoing),m(`_cleanUp :: (%s) :: destroying stream`,this.options.clientId),this.stream.destroy();else{let e=p({cmd:`disconnect`},n);m(`_cleanUp :: (%s) :: call _sendPacket with disconnect packet`,this.options.clientId),this._sendPacket(e,_.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(m(`_cleanUp :: client not disconnecting. Clearing and resetting reconnect.`),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(m(`_cleanUp :: clearing pingTimer`),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(m("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener(`close`,t),t())},A.prototype._sendPacket=function(e,t,n){m(`_sendPacket :: (%s) :: start`,this.options.clientId),n||=k,t||=k;let r=C(this,e);if(r){t(r);return}if(!this.connected){if(e.cmd===`auth`){this._shiftPingInterval(),T(this,e,t);return}m(`_sendPacket :: client not connected. Storing packet offline.`),this._storePacket(e,t,n);return}switch(this._shiftPingInterval(),e.cmd){case`publish`:break;case`pubrel`:O(this,e,t,n);return;default:T(this,e,t);return}switch(e.qos){case 2:case 1:O(this,e,t,n);break;default:T(this,e,t);break}m(`_sendPacket :: (%s) :: end`,this.options.clientId)},A.prototype._storePacket=function(e,t,n){m(`_storePacket :: packet: %o`,e),m(`_storePacket :: cb? %s`,!!t),n||=k;let r=e;if(r.cmd===`publish`){r=d(e);let n=w(this,r);if(n)return t&&t(n)}(r.qos||0)===0&&this.queueQoSZero||r.cmd!==`publish`?this.queue.push({packet:r,cb:t}):r.qos>0?(t=this.outgoing[r.messageId]?this.outgoing[r.messageId].cb:null,this.outgoingStore.put(r,function(e){if(e)return t&&t(e);n()})):t&&t(Error(`No connection to broker`))},A.prototype._setupPingTimer=function(){m(`_setupPingTimer :: keepalive %d (seconds)`,this.options.keepalive);let e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=u(function(){e._checkPing()},this.options.keepalive*1e3))},A.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(this.options.keepalive*1e3)},A.prototype._checkPing=function(){m(`_checkPing :: checking ping...`),this.pingResp?(m("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:`pingreq`})):(m(`_checkPing :: calling _cleanUp with force true`),this._cleanUp(!0))},A.prototype._handlePingresp=function(){this.pingResp=!0},A.prototype._handleConnack=function(e){m(`_handleConnack`);let t=this.options,n=t.protocolVersion===5?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535){this.emit(`error`,Error(`topicAliasMaximum from broker is out of range`));return}e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||={},t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(n===0)this.reconnecting=!1,this._onConnect(e);else if(n>0){let e=Error(`Connection refused: `+b[n]);e.code=n,this.emit(`error`,e)}},A.prototype._handleAuth=function(e){let t=this.options.protocolVersion,n=t===5?e.reasonCode:e.returnCode;if(t!==5){let e=Error(`Protocol error: Auth packets are only supported in MQTT 5. Your version:`+t);e.code=n,this.emit(`error`,e);return}let r=this;this.handleAuth(e,function(e,t){if(e){r.emit(`error`,e);return}if(n===24)r.reconnecting=!1,r._sendPacket(t);else{let t=Error(`Connection refused: `+b[n]);e.code=n,r.emit(`error`,t)}})},A.prototype.handleAuth=function(e,t){t()},A.prototype._handlePublish=function(e,t){m(`_handlePublish: packet %o`,e),t=t===void 0?k:t;let n=e.topic.toString(),r=e.payload,i=e.qos,a=e.messageId,o=this,s=this.options,c=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let t;if(e.properties&&(t=e.properties.topicAlias),t!==void 0)if(n.length===0)if(t>0&&t<=65535){let e=this.topicAliasRecv.getTopicByAlias(t);if(e)n=e,m(`_handlePublish :: topic complemented by alias. topic: %s - alias: %d`,n,t);else{m(`_handlePublish :: unregistered topic alias. alias: %d`,t),this.emit(`error`,Error(`Received unregistered Topic Alias`));return}}else{m(`_handlePublish :: topic alias out of range. alias: %d`,t),this.emit(`error`,Error(`Received Topic Alias is out of range`));return}else if(this.topicAliasRecv.put(n,t))m(`_handlePublish :: registered topic: %s - alias: %d`,n,t);else{m(`_handlePublish :: topic alias out of range. alias: %d`,t),this.emit(`error`,Error(`Received Topic Alias is out of range`));return}}switch(m(`_handlePublish: qos %d`,i),i){case 2:s.customHandleAcks(n,r,e,function(n,r){if(n instanceof Error||(r=n,n=null),n)return o.emit(`error`,n);if(c.indexOf(r)===-1)return o.emit(`error`,Error(`Wrong reason code for pubrec`));r?o._sendPacket({cmd:`pubrec`,messageId:a,reasonCode:r},t):o.incomingStore.put(e,function(){o._sendPacket({cmd:`pubrec`,messageId:a},t)})});break;case 1:s.customHandleAcks(n,r,e,function(i,s){if(i instanceof Error||(s=i,i=null),i)return o.emit(`error`,i);if(c.indexOf(s)===-1)return o.emit(`error`,Error(`Wrong reason code for puback`));s||o.emit(`message`,n,r,e),o.handleMessage(e,function(e){if(e)return t&&t(e);o._sendPacket({cmd:`puback`,messageId:a,reasonCode:s},t)})});break;case 0:this.emit(`message`,n,r,e),this.handleMessage(e,t);break;default:m(`_handlePublish: unknown QoS. Doing nothing.`);break}},A.prototype.handleMessage=function(e,t){t()},A.prototype._handleAck=function(e){let t=e.messageId,n=e.cmd,r=null,i=this.outgoing[t]?this.outgoing[t].cb:null,a=this,o;if(!i){m(`_handleAck :: Server sent an ack in error. Ignoring.`);return}switch(m(`_handleAck :: packet type`,n),n){case`pubcomp`:case`puback`:{let n=e.reasonCode;n&&n>0&&n!==16&&(o=Error(`Publish error: `+b[n]),o.code=n,i(o,e)),delete this.outgoing[t],this.outgoingStore.del(e,i),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case`pubrec`:{r={cmd:`pubrel`,qos:2,messageId:t};let n=e.reasonCode;n&&n>0&&n!==16?(o=Error(`Publish error: `+b[n]),o.code=n,i(o,e)):this._sendPacket(r);break}case`suback`:delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let n=0;n<e.granted.length;n++)if(e.granted[n]&128){let e=this.messageIdToTopic[t];e&&e.forEach(function(e){delete a._resubscribeTopics[e]})}this._invokeStoreProcessingQueue(),i(null,e);break;case`unsuback`:delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),i(null);break;default:a.emit(`error`,Error(`unrecognized packet type`))}this.disconnecting&&Object.keys(this.outgoing).length===0&&this.emit(`outgoingEmpty`)},A.prototype._handlePubrel=function(e,t){m(`handling pubrel packet`),t=t===void 0?k:t;let n=e.messageId,r=this,i={cmd:`pubcomp`,messageId:n};r.incomingStore.get(e,function(e,n){e?r._sendPacket(i,t):(r.emit(`message`,n.topic,n.payload,n),r.handleMessage(n,function(e){if(e)return t(e);r.incomingStore.del(n,k),r._sendPacket(i,t)}))})},A.prototype._handleDisconnect=function(e){this.emit(`disconnect`,e)},A.prototype._nextId=function(){return this.messageIdProvider.allocate()},A.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},A.prototype._resubscribe=function(){m(`_resubscribe`);let e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion===5&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){m(`_resubscribe: protocolVersion 5`);for(let t=0;t<e.length;t++){let n={};n[e[t]]=this._resubscribeTopics[e[t]],n.resubscribe=!0,this.subscribe(n,{properties:n[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},A.prototype._onConnect=function(e){if(this.disconnected){this.emit(`connect`,e);return}let t=this;this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0;function n(){let r=t.outgoingStore.createStream();function i(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}t.once(`close`,a),r.on(`error`,function(e){i(),t._flushStoreProcessingQueue(),t.removeListener(`close`,a),t.emit(`error`,e)});function a(){r.destroy(),r=null,t._flushStoreProcessingQueue(),i()}function o(){if(!r)return;t._storeProcessing=!0;let e=r.read(1),n;if(!e){r.once(`readable`,o);return}if(t._packetIdsDuringStoreProcessing[e.messageId]){o();return}!t.disconnecting&&!t.reconnectTimer?(n=t.outgoing[e.messageId]?t.outgoing[e.messageId].cb:null,t.outgoing[e.messageId]={volatile:!1,cb:function(e,t){n&&n(e,t),o()}},t._packetIdsDuringStoreProcessing[e.messageId]=!0,t.messageIdProvider.register(e.messageId)?t._sendPacket(e):m(`messageId: %d has already used.`,e.messageId)):r.destroy&&r.destroy()}r.on(`end`,function(){let r=!0;for(let e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){r=!1;break}r?(i(),t.removeListener(`close`,a),t._invokeAllStoreProcessingQueue(),t.emit(`connect`,e)):n()}),o()}n()},A.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){let e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},A.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},A.prototype._flushStoreProcessingQueue=function(){for(let e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(Error(`Connection closed`)),e.callback&&e.callback(Error(`Connection closed`));this._storeProcessingQueue.splice(0)},t.exports=A})),Fe=o(((e,t)=>{let n=require(`net`),r=X()(`mqttjs:tcp`);function i(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||`localhost`;let i=t.port,a=t.hostname;return r(`port %d and host %s`,i,a),n.createConnection(i,a)}t.exports=i})),Ie=o(((e,t)=>{let n=require(`tls`),r=require(`net`),i=X()(`mqttjs:tls`);function a(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||`localhost`,r.isIP(t.host)===0&&(t.servername=t.host),t.rejectUnauthorized=t.rejectUnauthorized!==!1,delete t.path,i(`port %d host %s rejectUnauthorized %b`,t.port,t.host,t.rejectUnauthorized);let a=n.connect(t);a.on(`secureConnect`,function(){t.rejectUnauthorized&&!a.authorized?a.emit(`error`,Error(`TLS not authorized`)):a.removeListener(`error`,o)});function o(n){t.rejectUnauthorized&&e.emit(`error`,n),a.end()}return a.on(`error`,o),a}t.exports=a})),Le=o(((e,t)=>{t.exports=n;function n(e,t){if(e&&t)return n(e)(t);if(typeof e!=`function`)throw TypeError(`need wrapper function`);return Object.keys(e).forEach(function(t){r[t]=e[t]}),r;function r(){for(var t=Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),i=t[t.length-1];return typeof r==`function`&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}}})),Re=o(((e,t)=>{var n=Le();t.exports=n(r),t.exports.strict=n(i),r.proto=r(function(){Object.defineProperty(Function.prototype,`once`,{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,`onceStrict`,{value:function(){return i(this)},configurable:!0})});function r(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)};return t.onceError=(e.name||"Function wrapped with `once`")+` shouldn't be called more than once`,t.called=!1,t}})),ze=o(((e,t)=>{var n=Re(),r=function(){},i=function(e){return e.setHeader&&typeof e.abort==`function`},a=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3},o=function(e,t,s){if(typeof t==`function`)return o(e,null,t);t||={},s=n(s||r);var c=e._writableState,l=e._readableState,u=t.readable||t.readable!==!1&&e.readable,d=t.writable||t.writable!==!1&&e.writable,f=!1,p=function(){e.writable||m()},m=function(){d=!1,u||s.call(e)},h=function(){u=!1,d||s.call(e)},g=function(t){s.call(e,t?Error(`exited with error code: `+t):null)},_=function(t){s.call(e,t)},v=function(){process.nextTick(y)},y=function(){if(!f&&(u&&!(l&&l.ended&&!l.destroyed)||d&&!(c&&c.ended&&!c.destroyed)))return s.call(e,Error(`premature close`))},b=function(){e.req.on(`finish`,m)};return i(e)?(e.on(`complete`,m),e.on(`abort`,v),e.req?b():e.on(`request`,b)):d&&!c&&(e.on(`end`,p),e.on(`close`,p)),a(e)&&e.on(`exit`,g),e.on(`end`,h),e.on(`finish`,m),t.error!==!1&&e.on(`error`,_),e.on(`close`,v),function(){f=!0,e.removeListener(`complete`,m),e.removeListener(`abort`,v),e.removeListener(`request`,b),e.req&&e.req.removeListener(`finish`,m),e.removeListener(`end`,p),e.removeListener(`close`,p),e.removeListener(`finish`,m),e.removeListener(`exit`,g),e.removeListener(`end`,h),e.removeListener(`error`,_),e.removeListener(`close`,v)}};t.exports=o})),Be=o(((e,t)=>{t.exports=n;function n(e){var t=e._readableState;return t?t.objectMode||typeof e._duplexState==`number`?e.read():e.read(r(t)):null}function r(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}})),Ve=o(((e,t)=>{var n=P(),r=ze(),i=S(),a=Be(),o=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),s=function(e,t){e._corked?e.once(`uncork`,t):t()},c=function(e,t){e._autoDestroy&&e.destroy(t)},l=function(e,t){return function(n){n?c(e,n.message===`premature close`?null:n):t&&!e._ended&&e.end()}},u=function(e,t){if(!e||e._writableState&&e._writableState.finished)return t();if(e._writableState)return e.end(t);e.end(),t()},d=function(){},f=function(e){return new n.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},p=function(e,t,r){if(!(this instanceof p))return new p(e,t,r);n.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||r.autoDestroy!==!1,this._forwardDestroy=!r||r.destroy!==!1,this._forwardEnd=!r||r.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};i(p,n.Duplex),p.obj=function(e,t,n){return n||={},n.objectMode=!0,n.highWaterMark=16,new p(e,t,n)},p.prototype.cork=function(){++this._corked===1&&this.emit(`cork`)},p.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit(`uncork`)},p.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.end();return}var t=this,n=r(e,{writable:!0,readable:!1},l(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()},a=function(){t._writable.removeListener(`drain`,i),n()};this._unwrite&&process.nextTick(i),this._writable=e,this._writable.on(`drain`,i),this._unwrite=a,this.uncork()},p.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.push(null),this.resume();return}var t=this,n=r(e,{writable:!1,readable:!0},l(this)),i=function(){t._forward()},a=function(){t.push(null)},o=function(){t._readable2.removeListener(`readable`,i),t._readable2.removeListener(`end`,a),n()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:f(e),this._readable2.on(`readable`,i),this._readable2.on(`end`,a),this._unread=o,this._forward()},p.prototype._read=function(){this._drained=!0,this._forward()},p.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var e;this._drained&&(e=a(this._readable2))!==null;)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},p.prototype.destroy=function(e,t){if(t||=d,this.destroyed)return t(null);this.destroyed=!0;var n=this;process.nextTick(function(){n._destroy(e),t(null)})},p.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit(`error`,e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit(`close`)},p.prototype._write=function(e,t,n){if(!this.destroyed){if(this._corked)return s(this,this._write.bind(this,e,t,n));if(e===o)return this._finish(n);if(!this._writable)return n();this._writable.write(e)===!1?this._ondrain=n:this.destroyed||n()}},p.prototype._finish=function(e){var t=this;this.emit(`preend`),s(this,function(){u(t._forwardEnd&&t._writable,function(){t._writableState.prefinished===!1&&(t._writableState.prefinished=!0),t.emit(`prefinish`),s(t,e)})})},p.prototype.end=function(e,t,r){return typeof e==`function`?this.end(null,null,e):typeof t==`function`?this.end(e,null,t):(this._ended=!0,e&&this.write(e),!this._writableState.ending&&!this._writableState.destroyed&&this.write(o),n.Writable.prototype.end.call(this,r))},t.exports=p})),He=o(((e,t)=>{let{Buffer:n}=require(`buffer`),r=P().Transform,i=Ve(),a,o,s;function c(){let e=new r;return e._write=function(e,t,n){a.send({data:e.buffer,success:function(){n()},fail:function(e){n(Error(e))}})},e._flush=function(e){a.close({success:function(){e()}})},e}function l(e){e.hostname||=`localhost`,e.path||=`/`,e.wsOptions||={}}function u(e,t){let n=e.protocol===`wxs`?`wss`:`ws`,r=n+`://`+e.hostname+e.path;return e.port&&e.port!==80&&e.port!==443&&(r=n+`://`+e.hostname+`:`+e.port+e.path),typeof e.transformWsUrl==`function`&&(r=e.transformWsUrl(r,e,t)),r}function d(){a.onOpen(function(){s.setReadable(o),s.setWritable(o),s.emit(`connect`)}),a.onMessage(function(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,`utf8`),o.push(t)}),a.onClose(function(){s.end(),s.destroy()}),a.onError(function(e){s.destroy(Error(e.errMsg))})}function f(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw Error(`Could not determine host. Specify host manually.`);let n=t.protocolId===`MQIsdp`&&t.protocolVersion===3?`mqttv3.1`:`mqtt`;l(t);let r=u(t,e);a=wx.connectSocket({url:r,protocols:[n]}),o=c(),s=i.obj(),s._destroy=function(e,t){a.close({success:function(){t&&t(e)}})};let f=s.destroy;return s.destroy=function(){s.destroy=f;let e=this;setTimeout(function(){a.close({fail:function(){e._destroy(Error())}})},0)}.bind(s),d(),s}t.exports=f})),Ue=o(((e,t)=>{let{Buffer:n}=require(`buffer`),r=P().Transform,i=Ve(),a,o,s,c=!1;function l(){let e=new r;return e._write=function(e,t,n){a.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(Error())}})},e._flush=function(e){a.closeSocket({success:function(){e()}})},e}function u(e){e.hostname||=`localhost`,e.path||=`/`,e.wsOptions||={}}function d(e,t){let n=e.protocol===`alis`?`wss`:`ws`,r=n+`://`+e.hostname+e.path;return e.port&&e.port!==80&&e.port!==443&&(r=n+`://`+e.hostname+`:`+e.port+e.path),typeof e.transformWsUrl==`function`&&(r=e.transformWsUrl(r,e,t)),r}function f(){c||(c=!0,a.onSocketOpen(function(){s.setReadable(o),s.setWritable(o),s.emit(`connect`)}),a.onSocketMessage(function(e){if(typeof e.data==`string`){let t=n.from(e.data,`base64`);o.push(t)}else{let t=new FileReader;t.addEventListener(`load`,function(){let e=t.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,`utf8`),o.push(e)}),t.readAsArrayBuffer(e.data)}}),a.onSocketClose(function(){s.end(),s.destroy()}),a.onSocketError(function(e){s.destroy(e)}))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw Error(`Could not determine host. Specify host manually.`);let n=t.protocolId===`MQIsdp`&&t.protocolVersion===3?`mqttv3.1`:`mqtt`;u(t);let r=d(t,e);return a=t.my,a.connectSocket({url:r,protocols:n}),o=l(),s=i.obj(),f(),s}t.exports=p})),Z=o(((e,t)=>{t.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:()=>{}}})),We=o(((e,t)=>{let{EMPTY_BUFFER:n}=Z();function r(e,t){if(e.length===0)return n;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),i=0;for(let t=0;t<e.length;t++){let n=e[t];r.set(n,i),i+=n.length}return i<t?r.slice(0,i):r}function i(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function a(e,t){let n=e.length;for(let r=0;r<n;r++)e[r]^=t[r&3]}function o(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function s(e){if(s.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=Buffer.from(e):ArrayBuffer.isView(e)?t=Buffer.from(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),s.readOnly=!1),t}try{let e=require(`bufferutil`),n=e.BufferUtil||e;t.exports={concat:r,mask(e,t,r,a,o){o<48?i(e,t,r,a,o):n.mask(e,t,r,a,o)},toArrayBuffer:o,toBuffer:s,unmask(e,t){e.length<32?a(e,t):n.unmask(e,t)}}}catch{t.exports={concat:r,mask:i,toArrayBuffer:o,toBuffer:s,unmask:a}}})),Ge=o(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),Ke=o(((e,t)=>{let n=require(`zlib`),r=We(),i=Ge(),{kStatusCode:a,NOOP:o}=Z(),s=Buffer.from([0,0,255,255]),c=Symbol(`permessage-deflate`),l=Symbol(`total-length`),u=Symbol(`callback`),d=Symbol(`buffers`),f=Symbol(`error`),p;t.exports=class{constructor(e,t,n){this._maxPayload=n|0,this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,p||=new i(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}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??(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(),null),this._deflate){let e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){p.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){p.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,i){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on(`error`,g),this._inflate.on(`data`,h)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(s),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,i(e);return}let n=r.concat(this._inflate[d],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),i(null,n)})}_compress(e,t,i){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[d]=[],this._deflate.on(`error`,o),this._deflate.on(`data`,m)}this._deflate[u]=i,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[d],this._deflate[l]);t&&(e=e.slice(0,e.length-4)),this._deflate[u]=null,this._deflate[l]=0,this._deflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),i(null,e)})}};function m(e){this[d].push(e),this[l]+=e.length}function h(e){if(this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload){this[d].push(e);return}this[f]=RangeError(`Max payload size exceeded`),this[f].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[f][a]=1009,this.removeListener(`data`,h),this.reset()}function g(e){this[c]._inflate=null,e[a]=1007,this[u](e)}})),qe=o(((e,t)=>{function n(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function r(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}try{let e=require(`utf-8-validate`);typeof e==`object`&&(e=e.Validation.isValidUTF8),t.exports={isValidStatusCode:n,isValidUTF8(t){return t.length<150?r(t):e(t)}}}catch{t.exports={isValidStatusCode:n,isValidUTF8:r}}})),Je=o(((e,t)=>{let{Writable:n}=require(`stream`),r=Ke(),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:o,kWebSocket:s}=Z(),{concat:c,toArrayBuffer:l,unmask:u}=We(),{isValidStatusCode:d,isValidUTF8:f}=qe();t.exports=class extends n{constructor(e,t,n,r){super(),this._binaryType=e||i[0],this[s]=void 0,this._extensions=t||{},this._isServer=!!n,this._maxPayload=r|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=0,this._loop=!1}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=t.slice(e),t.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=n.slice(e)),e-=n.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,p(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`);let t=(e[0]&64)==64;if(t&&!this._extensions[r.extensionName])return this._loop=!1,p(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(t)return this._loop=!1,p(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`);if(!this._fragmented)return this._loop=!1,p(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,p(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`);this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,p(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`);if(t)return this._loop=!1,p(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`);if(this._payloadLength>125)return this._loop=!1,p(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`)}else return this._loop=!1,p(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,p(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`)}else if(this._masked)return this._loop=!1,p(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`);if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;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),t=e.readUInt32BE(0);return t>2**21-1?(this._loop=!1,p(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`)):(this._payloadLength=t*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,p(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`);this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&u(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=5,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(p(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));this._fragments.push(n)}let r=this.dataMessage();if(r)return t(r);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let n;n=this._binaryType===`nodebuffer`?c(t,e):this._binaryType===`arraybuffer`?l(c(t,e)):t,this.emit(`message`,n)}else{let n=c(t,e);if(!f(n))return this._loop=!1,p(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`);this.emit(`message`,n.toString())}}this._state=0}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 p(RangeError,`invalid payload length 1`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`);else{let t=e.readUInt16BE(0);if(!d(t))return p(RangeError,`invalid status code ${t}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`);let n=e.slice(2);if(!f(n))return p(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`);this.emit(`conclude`,t,n.toString()),this.end()}else this._opcode===9?this.emit(`ping`,e):this.emit(`pong`,e);this._state=0}};function p(e,t,n,r,i){let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,p),a.code=i,a[o]=r,a}})),Ye=o(((e,t)=>{require(`net`),require(`tls`);let{randomFillSync:n}=require(`crypto`),r=Ke(),{EMPTY_BUFFER:i}=Z(),{isValidStatusCode:a}=qe(),{mask:o,toBuffer:s}=We(),c=Buffer.alloc(4);t.exports=class e{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r=t.mask&&t.readOnly,i=t.mask?6:2,a=e.length;e.length>=65536?(i+=8,a=127):e.length>125&&(i+=2,a=126);let s=Buffer.allocUnsafe(r?e.length+i:i);return s[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(s[0]|=64),s[1]=a,a===126?s.writeUInt16BE(e.length,2):a===127&&(s.writeUInt32BE(0,2),s.writeUInt32BE(e.length,6)),t.mask?(n(c,0,4),s[1]|=128,s[i-4]=c[0],s[i-3]=c[1],s[i-2]=c[2],s[i-1]=c[3],r?(o(e,c,s,i,e.length),[s]):(o(e,c,e,0,e.length),[s,e])):[s,e]}close(e,t,n,r){let o;if(e===void 0)o=i;else if(typeof e!=`number`||!a(e))throw TypeError(`First argument must be a valid error code number`);else if(t===void 0||t===``)o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0);else{let n=Buffer.byteLength(t);if(n>123)throw RangeError(`The message must not be greater than 123 bytes`);o=Buffer.allocUnsafe(2+n),o.writeUInt16BE(e,0),o.write(t,2)}this._deflating?this.enqueue([this.doClose,o,n,r]):this.doClose(o,n,r)}doClose(t,n,r){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:8,mask:n,readOnly:!1}),r)}ping(e,t,n){let r=s(e);if(r.length>125)throw RangeError(`The data size must not be greater than 125 bytes`);this._deflating?this.enqueue([this.doPing,r,t,s.readOnly,n]):this.doPing(r,t,s.readOnly,n)}doPing(t,n,r,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:9,mask:n,readOnly:r}),i)}pong(e,t,n){let r=s(e);if(r.length>125)throw RangeError(`The data size must not be greater than 125 bytes`);this._deflating?this.enqueue([this.doPong,r,t,s.readOnly,n]):this.doPong(r,t,s.readOnly,n)}doPong(t,n,r,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:10,mask:n,readOnly:r}),i)}send(t,n,i){let a=s(t),o=this._extensions[r.extensionName],c=n.binary?2:1,l=n.compress;if(this._firstFragment?(this._firstFragment=!1,l&&o&&(l=a.length>=o._threshold),this._compress=l):(l=!1,c=0),n.fin&&(this._firstFragment=!0),o){let e={fin:n.fin,rsv1:l,opcode:c,mask:n.mask,readOnly:s.readOnly};this._deflating?this.enqueue([this.dispatch,a,this._compress,e,i]):this.dispatch(a,this._compress,e,i)}else this.sendFrame(e.frame(a,{fin:n.fin,rsv1:!1,opcode:c,mask:n.mask,readOnly:s.readOnly}),i)}dispatch(t,n,i,a){if(!n){this.sendFrame(e.frame(t,i),a);return}let o=this._extensions[r.extensionName];this._bufferedBytes+=t.length,this._deflating=!0,o.compress(t,i.fin,(n,r)=>{if(this._socket.destroyed){let e=Error(`The socket was closed while data was being compressed`);typeof a==`function`&&a(e);for(let t=0;t<this._queue.length;t++){let n=this._queue[t][4];typeof n==`function`&&n(e)}return}this._bufferedBytes-=t.length,this._deflating=!1,i.readOnly=!1,this.sendFrame(e.frame(r,i),a),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,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}})),Xe=o(((e,t)=>{var n=class{constructor(e,t){this.target=t,this.type=e}},r=class extends n{constructor(e,t){super(`message`,t),this.data=e}},i=class extends n{constructor(e,t,n){super(`close`,n),this.wasClean=n._closeFrameReceived&&n._closeFrameSent,this.reason=t,this.code=e}},a=class extends n{constructor(e){super(`open`,e)}},o=class extends n{constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}};t.exports={addEventListener(e,t,n){if(typeof t!=`function`)return;function s(e){t.call(this,new r(e,this))}function c(e,n){t.call(this,new i(e,n,this))}function l(e){t.call(this,new o(e,this))}function u(){t.call(this,new a(this))}let d=n&&n.once?`once`:`on`;e===`message`?(s._listener=t,this[d](e,s)):e===`close`?(c._listener=t,this[d](e,c)):e===`error`?(l._listener=t,this[d](e,l)):e===`open`?(u._listener=t,this[d](e,u)):this[d](e,t)},removeEventListener(e,t){let n=this.listeners(e);for(let r=0;r<n.length;r++)(n[r]===t||n[r]._listener===t)&&this.removeListener(e,n[r])}}})),Ze=o(((e,t)=>{let n=[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 r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null);if(e===void 0||e===``)return t;let i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=0;for(;f<e.length;f++){let p=e.charCodeAt(f);if(c===void 0)if(d===-1&&n[p]===1)u===-1&&(u=f);else if(p===32||p===9)d===-1&&u!==-1&&(d=f);else if(p===59||p===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${f}`);d===-1&&(d=f);let n=e.slice(u,d);p===44?(r(t,n,i),i=Object.create(null)):c=n,u=d=-1}else throw SyntaxError(`Unexpected character at index ${f}`);else if(l===void 0)if(d===-1&&n[p]===1)u===-1&&(u=f);else if(p===32||p===9)d===-1&&u!==-1&&(d=f);else if(p===59||p===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${f}`);d===-1&&(d=f),r(i,e.slice(u,d),!0),p===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=d=-1}else if(p===61&&u!==-1&&d===-1)l=e.slice(u,f),u=d=-1;else throw SyntaxError(`Unexpected character at index ${f}`);else if(o){if(n[p]!==1)throw SyntaxError(`Unexpected character at index ${f}`);u===-1?u=f:a||=!0,o=!1}else if(s)if(n[p]===1)u===-1&&(u=f);else if(p===34&&u!==-1)s=!1,d=f;else if(p===92)o=!0;else throw SyntaxError(`Unexpected character at index ${f}`);else if(p===34&&e.charCodeAt(f-1)===61)s=!0;else if(d===-1&&n[p]===1)u===-1&&(u=f);else if(u!==-1&&(p===32||p===9))d===-1&&(d=f);else if(p===59||p===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${f}`);d===-1&&(d=f);let n=e.slice(u,d);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),p===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=d=-1}else throw SyntaxError(`Unexpected character at index ${f}`)}if(u===-1||s)throw SyntaxError(`Unexpected end of input`);d===-1&&(d=f);let p=e.slice(u,d);return c===void 0?r(t,p,i):(l===void 0?r(i,p,!0):a?r(i,l,p.replace(/\\/g,``)):r(i,l,p),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),Qe=o(((e,t)=>{let n=require(`events`),r=require(`https`),i=require(`http`),a=require(`net`),o=require(`tls`),{randomBytes:s,createHash:c}=require(`crypto`),{Readable:l}=require(`stream`),{URL:u}=require(`url`),d=Ke(),f=Je(),p=Ye(),{BINARY_TYPES:m,EMPTY_BUFFER:h,GUID:g,kStatusCode:_,kWebSocket:v,NOOP:y}=Z(),{addEventListener:b,removeEventListener:x}=Xe(),{format:S,parse:C}=Ze(),{toBuffer:w}=We(),T=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],E=[8,13];var D=class e extends n{constructor(t,n,r){super(),this._binaryType=m[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=``,this._closeTimer=null,this._extensions={},this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?this._isServer=!0:(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(n)?n=n.join(`, `):typeof n==`object`&&n&&(r=n,n=void 0),O(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){m.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(t,n,r){let i=new f(this.binaryType,this._extensions,this._isServer,r);this._sender=new p(t,this._extensions),this._receiver=i,this._socket=t,i[v]=this,t[v]=this,i.on(`conclude`,ee),i.on(`drain`,P),i.on(`error`,F),i.on(`message`,L),i.on(`ping`,R),i.on(`pong`,z),t.setTimeout(0),t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,V),t.on(`data`,H),t.on(`end`,U),t.on(`error`,W),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[d.extensionName]&&this._extensions[d.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING)return M(this,this._req,`WebSocket was closed before the connection was established`);if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)}}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){N(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||h,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){N(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||h,n,r)}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){N(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[d.extensionName]||(i.compress=!1),this._sender.send(t||h,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING)return M(this,this._req,`WebSocket was closed before the connection was established`);this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,`CONNECTING`,{enumerable:!0,value:T.indexOf(`CONNECTING`)}),Object.defineProperty(D.prototype,`CONNECTING`,{enumerable:!0,value:T.indexOf(`CONNECTING`)}),Object.defineProperty(D,`OPEN`,{enumerable:!0,value:T.indexOf(`OPEN`)}),Object.defineProperty(D.prototype,`OPEN`,{enumerable:!0,value:T.indexOf(`OPEN`)}),Object.defineProperty(D,`CLOSING`,{enumerable:!0,value:T.indexOf(`CLOSING`)}),Object.defineProperty(D.prototype,`CLOSING`,{enumerable:!0,value:T.indexOf(`CLOSING`)}),Object.defineProperty(D,`CLOSED`,{enumerable:!0,value:T.indexOf(`CLOSED`)}),Object.defineProperty(D.prototype,`CLOSED`,{enumerable:!0,value:T.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(D.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(D.prototype,`on${e}`,{enumerable:!0,get(){let t=this.listeners(e);for(let e=0;e<t.length;e++)if(t[e]._listener)return t[e]._listener},set(t){let n=this.listeners(e);for(let t=0;t<n.length;t++)n[t]._listener&&this.removeListener(e,n[t]);this.addEventListener(e,t)}})}),D.prototype.addEventListener=b,D.prototype.removeEventListener=x,t.exports=D;function O(e,t,n,a){let o={protocolVersion:E[1],maxPayload:100*1024*1024,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,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(!E.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${E.join(`, `)})`);let l;t instanceof u?(l=t,e._url=t.href):(l=new u(t),e._url=t);let f=l.protocol===`ws+unix:`;if(!l.host&&(!f||!l.pathname)){let t=Error(`Invalid URL: ${e.url}`);if(e._redirects===0)throw t;k(e,t);return}let p=l.protocol===`wss:`||l.protocol===`https:`,m=p?443:80,h=s(16).toString(`base64`),_=p?r.get:i.get,v;if(o.createConnection=p?j:A,o.defaultPort=o.defaultPort||m,o.port=l.port||m,o.host=l.hostname.startsWith(`[`)?l.hostname.slice(1,-1):l.hostname,o.headers={"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":h,Connection:`Upgrade`,Upgrade:`websocket`,...o.headers},o.path=l.pathname+l.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(v=new d(o.perMessageDeflate===!0?{}:o.perMessageDeflate,!1,o.maxPayload),o.headers[`Sec-WebSocket-Extensions`]=S({[d.extensionName]:v.offer()})),n&&(o.headers[`Sec-WebSocket-Protocol`]=n),o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(l.username||l.password)&&(o.auth=`${l.username}:${l.password}`),f){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}if(o.followRedirects){if(e._redirects===0){e._originalUnixSocket=f,e._originalSecure=p,e._originalHostOrSocketPath=f?o.socketPath:l.host;let t=a&&a.headers;if(a={...a,headers:{}},t)for(let[e,n]of Object.entries(t))a.headers[e.toLowerCase()]=n}else{let t=f?e._originalUnixSocket?o.socketPath===e._originalHostOrSocketPath:!1:e._originalUnixSocket?!1:l.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!p)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!a.headers.authorization&&(a.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`))}let y=e._req=_(o);o.timeout&&y.on(`timeout`,()=>{M(e,y,`Opening handshake has timed out`)}),y.on(`error`,t=>{y===null||y.aborted||(y=e._req=null,k(e,t))}),y.on(`response`,r=>{let i=r.headers.location,s=r.statusCode;if(i&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){M(e,y,`Maximum redirects exceeded`);return}y.abort();let r;try{r=new u(i,t)}catch(t){k(e,t);return}O(e,r,n,a)}else e.emit(`unexpected-response`,y,r)||M(e,y,`Unexpected server response: ${r.statusCode}`)}),y.on(`upgrade`,(t,r,i)=>{if(e.emit(`upgrade`,t),e.readyState!==D.CONNECTING)return;if(y=e._req=null,t.headers.upgrade.toLowerCase()!==`websocket`){M(e,r,`Invalid Upgrade header`);return}let a=c(`sha1`).update(h+g).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){M(e,r,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],l=(n||``).split(/, */),u;if(!n&&s?u=`Server sent a subprotocol but none was requested`:n&&!s?u=`Server sent no subprotocol`:s&&!l.includes(s)&&(u=`Server sent an invalid subprotocol`),u){M(e,r,u);return}s&&(e._protocol=s);let f=t.headers[`sec-websocket-extensions`];if(f!==void 0){if(!v){M(e,r,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=C(f)}catch{M(e,r,`Invalid Sec-WebSocket-Extensions header`);return}let n=Object.keys(t);if(n.length){if(n.length!==1||n[0]!==d.extensionName){M(e,r,`Server indicated an extension that was not requested`);return}try{v.accept(t[d.extensionName])}catch{M(e,r,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[d.extensionName]=v}}e.setSocket(r,i,o.maxPayload)})}function k(e,t){e._readyState=D.CLOSING,e.emit(`error`,t),e.emitClose()}function A(e){return e.path=e.socketPath,a.connect(e)}function j(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=a.isIP(e.host)?``:e.host),o.connect(e)}function M(e,t,n){e._readyState=D.CLOSING;let r=Error(n);Error.captureStackTrace(r,M),t.setHeader?(t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),t.once(`abort`,e.emitClose.bind(e)),e.emit(`error`,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function N(e,t,n){if(t){let n=w(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}n&&n(Error(`WebSocket is not open: readyState ${e.readyState} (${T[e.readyState]})`))}function ee(e,t){let n=this[v];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[v]!==void 0&&(n._socket.removeListener(`data`,H),process.nextTick(B,n._socket),e===1005?n.close():n.close(e,t))}function P(){this[v]._socket.resume()}function F(e){let t=this[v];t._socket[v]!==void 0&&(t._socket.removeListener(`data`,H),process.nextTick(B,t._socket),t.close(e[_])),t.emit(`error`,e)}function I(){this[v].emitClose()}function L(e){this[v].emit(`message`,e)}function R(e){let t=this[v];t.pong(e,!t._isServer,y),t.emit(`ping`,e)}function z(e){this[v].emit(`pong`,e)}function B(e){e.resume()}function V(){let e=this[v];this.removeListener(`close`,V),this.removeListener(`data`,H),this.removeListener(`end`,U),e._readyState=D.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[v]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,I),e._receiver.on(`finish`,I))}function H(e){this[v]._receiver.write(e)||this.pause()}function U(){let e=this[v];e._readyState=D.CLOSING,e._receiver.end(),this.end()}function W(){let e=this[v];this.removeListener(`error`,W),this.on(`error`,y),e&&(e._readyState=D.CLOSING,this.destroy())}})),$e=o(((e,t)=>{let{Duplex:n}=require(`stream`);function r(e){e.emit(`close`)}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener(`error`,a),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function o(e,t){let o=!0,s=!0;function c(){o&&e._socket.resume()}e.readyState===e.CONNECTING?e.once(`open`,function(){e._receiver.removeAllListeners(`drain`),e._receiver.on(`drain`,c)}):(e._receiver.removeAllListeners(`drain`),e._receiver.on(`drain`,c));let l=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t){l.push(t)||(o=!1,e._socket.pause())}),e.once(`error`,function(e){l.destroyed||(s=!1,l.destroy(e))}),e.once(`close`,function(){l.destroyed||l.push(null)}),l._destroy=function(t,n){if(e.readyState===e.CLOSED){n(t),process.nextTick(r,l);return}let i=!1;e.once(`error`,function(e){i=!0,n(e)}),e.once(`close`,function(){i||n(t),process.nextTick(r,l)}),s&&e.terminate()},l._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){l._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),l._readableState.endEmitted&&l.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},l._read=function(){(e.readyState===e.OPEN||e.readyState===e.CLOSING)&&!o&&(o=!0,e._receiver._writableState.needDrain||e._socket.resume())},l._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){l._write(t,n,r)});return}e.send(t,r)},l.on(`end`,i),l.on(`error`,a),l}t.exports=o})),et=o(((e,t)=>{let n=require(`events`),r=require(`http`);require(`https`),require(`net`),require(`tls`);let{createHash:i}=require(`crypto`),a=Ke(),o=Qe(),{format:s,parse:c}=Ze(),{GUID:l,kWebSocket:u}=Z(),d=/^[+/0-9A-Za-z]{22}==$/;t.exports=class extends n{constructor(e,t){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 TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=r.createServer((e,t)=>{let n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=f(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set),this.options=e,this._state=0}address(){if(this.options.noServer)throw 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===2){process.nextTick(p,this);return}if(this._state===1)return;if(this._state=1,this.clients)for(let e of this.clients)e.terminate();let t=this._server;if(t&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){t.close(p.bind(void 0,this));return}process.nextTick(p,this)}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,m);let i=e.headers[`sec-websocket-key`]===void 0?!1:e.headers[`sec-websocket-key`].trim(),o=+e.headers[`sec-websocket-version`],s={};if(e.method!==`GET`||e.headers.upgrade.toLowerCase()!==`websocket`||!i||!d.test(i)||o!==8&&o!==13||!this.shouldHandle(e))return h(t,400);if(this.options.perMessageDeflate){let n=new a(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let t=c(e.headers[`sec-websocket-extensions`]);t[a.extensionName]&&(n.accept(t[a.extensionName]),s[a.extensionName]=n)}catch{return h(t,400)}}if(this.options.verifyClient){let a={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(a,(a,o,c,l)=>{if(!a)return h(t,o||401,c,l);this.completeUpgrade(i,s,e,t,n,r)});return}if(!this.options.verifyClient(a))return h(t,401)}this.completeUpgrade(i,s,e,t,n,r)}completeUpgrade(e,t,n,r,c,d){if(!r.readable||!r.writable)return r.destroy();if(r[u])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return h(r,503);let f=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${i(`sha1`).update(e+l).digest(`base64`)}`],p=new o(null),_=n.headers[`sec-websocket-protocol`];if(_&&(_=_.split(`,`).map(g),_=this.options.handleProtocols?this.options.handleProtocols(_,n):_[0],_&&(f.push(`Sec-WebSocket-Protocol: ${_}`),p._protocol=_)),t[a.extensionName]){let e=t[a.extensionName].params,n=s({[a.extensionName]:[e]});f.push(`Sec-WebSocket-Extensions: ${n}`),p._extensions=t}this.emit(`headers`,f,n),r.write(f.concat(`\r
8
+ `).join(`\r
9
+ `)),r.removeListener(`error`,m),p.setSocket(r,c,this.options.maxPayload),this.clients&&(this.clients.add(p),p.on(`close`,()=>this.clients.delete(p))),d(p,n)}};function f(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function p(e){e._state=2,e.emit(`close`)}function m(){this.destroy()}function h(e,t,n,i){e.writable&&(n||=r.STATUS_CODES[t],i={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...i},e.write(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n`+Object.keys(i).map(e=>`${e}: ${i[e]}`).join(`\r
10
+ `)+`\r
11
+ \r
12
+ `+n)),e.removeListener(`error`,m),e.destroy()}function g(e){return e.trim()}})),tt=o(((e,t)=>{let n=Qe();n.createWebSocketStream=$e(),n.Server=et(),n.Receiver=Je(),n.Sender=Ye(),t.exports=n})),nt=o(((e,t)=>{let{Buffer:n}=require(`buffer`),r=tt(),i=X()(`mqttjs:ws`),a=Ve(),o=P().Transform,s=[`rejectUnauthorized`,`ca`,`cert`,`key`,`pfx`,`passphrase`],c=typeof process<`u`&&process.title===`browser`||typeof __webpack_require__==`function`;function l(e,t){let n=e.protocol+`://`+e.hostname+`:`+e.port+e.path;return typeof e.transformWsUrl==`function`&&(n=e.transformWsUrl(n,e,t)),n}function u(e){let t=e;return e.hostname||(t.hostname=`localhost`),e.port||(e.protocol===`wss`?t.port=443:t.port=80),e.path||(t.path=`/`),e.wsOptions||(t.wsOptions={}),!c&&e.protocol===`wss`&&s.forEach(function(n){Object.prototype.hasOwnProperty.call(e,n)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,n)&&(t.wsOptions[n]=e[n])}),t}function d(e){let t=u(e);if(t.hostname||=t.host,!t.hostname){if(typeof document>`u`)throw Error(`Could not determine host. Specify host manually.`);let e=new URL(document.URL);t.hostname=e.hostname,t.port||=e.port}return t.objectMode===void 0&&(t.objectMode=!(t.binary===!0||t.binary===void 0)),t}function f(e,t,n){i(`createWebSocket`),i(`protocol: `+n.protocolId+` `+n.protocolVersion);let a=n.protocolId===`MQIsdp`&&n.protocolVersion===3?`mqttv3.1`:`mqtt`;return i(`creating new Websocket for url: `+t+` and protocol: `+a),new r(t,[a],n.wsOptions)}function p(e,t){let n=t.protocolId===`MQIsdp`&&t.protocolVersion===3?`mqttv3.1`:`mqtt`,r=l(t,e),i=new WebSocket(r,[n]);return i.binaryType=`arraybuffer`,i}function m(e,t){i(`streamBuilder`);let n=u(t),a=l(n,e),o=f(e,a,n),s=r.createWebSocketStream(o,n.wsOptions);return s.url=a,o.on(`close`,()=>{s.destroy()}),s}function h(e,t){i(`browserStreamBuilder`);let r,s=d(t).browserBufferSize||1024*512,c=t.browserBufferTimeout||1e3,l=!t.objectMode,u=p(e,t),f=h(t,x,S);t.objectMode||(f._writev=b),f.on(`close`,()=>{u.close()});let m=u.addEventListener!==void 0;u.readyState===u.OPEN?r=f:(r=r=a(void 0,void 0,t),t.objectMode||(r._writev=b),m?u.addEventListener(`open`,g):u.onopen=g),r.socket=u,m?(u.addEventListener(`close`,_),u.addEventListener(`error`,v),u.addEventListener(`message`,y)):(u.onclose=_,u.onerror=v,u.onmessage=y);function h(e,t,n){let r=new o({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){r.setReadable(f),r.setWritable(f),r.emit(`connect`)}function _(){r.end(),r.destroy()}function v(e){r.destroy(e)}function y(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,`utf8`),f.push(t)}function b(e,t){let r=Array(e.length);for(let t=0;t<e.length;t++)typeof e[t].chunk==`string`?r[t]=n.from(e[t],`utf8`):r[t]=e[t].chunk;this._write(n.concat(r),`binary`,t)}function x(e,t,r){u.bufferedAmount>s&&setTimeout(x,c,e,t,r),l&&typeof e==`string`&&(e=n.from(e,`utf8`));try{u.send(e)}catch(e){return r(e)}r()}function S(e){u.close(),e()}return r}c?t.exports=h:t.exports=m})),rt=o(((e,t)=>{let n=Pe(),r=F(),i=require(`url`),a=h(),o=X()(`mqttjs`),s={};typeof process<`u`&&process.title!==`browser`||typeof __webpack_require__!=`function`?(s.mqtt=Fe(),s.tcp=Fe(),s.ssl=Ie(),s.tls=Ie(),s.mqtts=Ie()):(s.wx=He(),s.wxs=He(),s.ali=Ue(),s.alis=Ue()),s.ws=nt(),s.wss=nt();function c(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function l(e,t){if(o(`connecting to an MQTT broker...`),typeof e==`object`&&!t&&(t=e,e=null),t||={},e){let n=i.parse(e,!0);if(n.port!=null&&(n.port=Number(n.port)),t=a(n,t),t.protocol===null)throw Error(`Missing protocol`);t.protocol=t.protocol.replace(/:$/,``)}if(c(t),t.query&&typeof t.query.clientId==`string`&&(t.clientId=t.query.clientId),t.cert&&t.key)if(t.protocol){if([`mqtts`,`wss`,`wxs`,`alis`].indexOf(t.protocol)===-1)switch(t.protocol){case`mqtt`:t.protocol=`mqtts`;break;case`ws`:t.protocol=`wss`;break;case`wx`:t.protocol=`wxs`;break;case`ali`:t.protocol=`alis`;break;default:throw Error(`Unknown protocol for secure connection: "`+t.protocol+`"!`)}}else throw Error(`Missing secure protocol key`);if(!s[t.protocol]){let e=[`mqtts`,`wss`].indexOf(t.protocol)!==-1;t.protocol=[`mqtt`,`mqtts`,`ws`,`wss`,`wx`,`wxs`,`ali`,`alis`].filter(function(t,n){return e&&n%2==0?!1:typeof s[t]==`function`})[0]}if(t.clean===!1&&!t.clientId)throw Error(`Missing clientId for unclean clients`);t.protocol&&(t.defaultProtocol=t.protocol);function r(e){return t.servers&&((!e._reconnectCount||e._reconnectCount===t.servers.length)&&(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),o(`calling streambuilder for`,t.protocol),s[t.protocol](e,t)}let l=new n(r,t);return l.on(`error`,function(){}),l}t.exports=l,t.exports.connect=l,t.exports.MqttClient=n,t.exports.Store=r})),it=o(((e,t)=>{let n=_e().NumberAllocator;function r(){if(!(this instanceof r))return new r;this.numberAllocator=new n(1,65535)}r.prototype.allocate=function(){return this.lastId=this.numberAllocator.alloc(),this.lastId},r.prototype.getLastAllocated=function(){return this.lastId},r.prototype.register=function(e){return this.numberAllocator.use(e)},r.prototype.deallocate=function(e){this.numberAllocator.free(e)},r.prototype.clear=function(){this.numberAllocator.clear()},t.exports=r}));o(((e,t)=>{let n=Pe(),r=rt(),i=F(),a=ke(),o=it();t.exports.connect=r,t.exports.MqttClient=n,t.exports.Client=n,t.exports.Store=i,t.exports.DefaultMessageIdProvider=a,t.exports.UniqueMessageIdProvider=o}))();const{readFile:at,writeFile:ot}=d.promises;var Q=class e{static currentData={};static currentFetch;static file=(0,f.join)(process.env.HOME||`~`,`.vestaboard2mqtt`);namespace;constructor(e){this.namespace=e}static async fetch(){if(this.currentFetch)return this.currentFetch;let e=this.fetchFromFile();return this.currentFetch=e,e}static async fetchFromFile(){if((0,d.existsSync)(this.file))try{let e=await at(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`&&!!e&&`updated`in e&&typeof e.updated==`number`&&`value`in e&&e.value!==void 0}static async save(){await ot(this.file,JSON.stringify(this.currentData,null,` `))}async delete(t){!e.currentData||!e.currentData[this.namespace]||(delete e.currentData[this.namespace][t],Object.keys(e.currentData[this.namespace]).length===0&&delete e.currentData[this.namespace],await e.save().catch(e=>{console.warn(`Unable to update cache: ${e}`)}))}async get(t,n=0){if(await e.fetch(),!e.currentData||!e.currentData[this.namespace]||!e.currentData[this.namespace][t])return null;let r=e.currentData[this.namespace][t];return!e.isCacheItemObject(r)&&n>0?null:e.isCacheItemObject(r)?n>0&&new Date().getTime()-r.updated>n?null:r.value:r}async set(t,n){if(await e.fetch(),!e.currentData)throw Error(`Unable to set value: currentData is empty!`);e.currentData[this.namespace]=e.currentData[this.namespace]||{},e.currentData[this.namespace][t]={updated:new Date().getTime(),value:n},await e.save().catch(e=>{console.warn(`Unable to update cache: ${e}`)})}},$=class{static get board(){if(this.loaded&&this.data?.board)return this.data.board;throw Error(`Unable to access board config, is config loaded?`)}static get calendar(){if(this.loaded&&this.data?.calendar)return this.data.calendar;throw 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 Error(`Unable to access mqtt config, is config loaded?`)}static cache=new Q(`config`);static data;static async load(){let e=await this.cache.get(`default`);if(!e)throw Error(`Unable to load configuration, try to run the setup script…`);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))}};const st=[[`ä`,[1,5]],[`Ä`,[1,5]],[`ö`,[15,5]],[`Ö`,[15,5]],[`ü`,[21,5]],[`Ü`,[21,5]],[`ß`,[19,19]],[`🟥`,[63]],[`🟧`,[64]],[`🟨`,[65]],[`🟩`,[66]],[`🟦`,[67]],[`🟪`,[68]],[`⬜️`,[69]],[`⬜`,[69]],[`⬛️`,[0]],[`⬛`,[0]],[`﹫`,[38]],[`@`,[38]],[`0️⃣`,[36]],[`1️⃣`,[27]],[`2️⃣`,[28]],[`3️⃣`,[29]],[`4️⃣`,[30]],[`5️⃣`,[31]],[`6️⃣`,[32]],[`7️⃣`,[33]],[`8️⃣`,[34]],[`9️⃣`,[35]],[`❕`,[37]],[`‼️`,[37,37]],[`❗️`,[37]],[`⁉️`,[37,60]],[`⚠️`,[65]],[`#️⃣`,[39]],[`💸`,[40]],[`💲`,[40]],[`💵`,[40]],[`💰`,[40]],[`$`,[40]],[`﹩`,[40]],[`$`,[40]],[`←`,[44]],[`→`,[44]],[`➡`,[44]],[`⬅`,[44]],[`➔`,[44]],[`↔`,[44]],[`–`,[44]],[`➕`,[46]],[`+`,[46]],[`﹪`,[54]],[`%`,[54]],[`❓`,[60]],[`❔`,[60]],[`℃`,[62,3]],[`℉`,[62,6]]];var ct=class e{board;currentLine=null;isFilled=!1;constructor(t=e.newBoardCharArray()){this.board=t}static char2char(e){let t=Object.entries(p.characterCode).find(([t])=>e===t);if(t)return[t[1]];let n=st.find(([t])=>e===t);return n&&Array.isArray(n[1])?n[1]:[60]}static charToString(e){let t=Object.entries(p.characterCode).filter(([e])=>e.length<=2).find(([,t])=>t===e);if(t)return t[0].toUpperCase()+` `;switch(e){case 63:return`🟥`;case 64:return`🟧`;case 65:return`🟨`;case 66:return`🟩`;case 67:return`🟦`;case 68:return`🟪`;case 69:return`⬜️`;default:return` `}}static newBoardCharArray(){return JSON.parse(JSON.stringify(p.emptyBoard))}static word2chars(e){let t=[];for(let n of e)t.push(...this.char2char(n));return t}center(){let e=[this.board.findIndex(e=>e.find(e=>e!==0)),Math.min(...this.board.map(e=>e.find(e=>e!==0)?e.slice().reverse().findIndex(e=>e!==0):e.length)),this.board.slice().reverse().findIndex(e=>e.find(e=>e!==0)),Math.min(...this.board.map(e=>e.find(e=>e!==0)?e.findIndex(e=>e!==0):e.length))],t=[Math.floor((e[0]+e[2])/2),Math.floor((e[1]+e[3])/2)];if(e[0]!==t[0]){let n=t[0]-e[0];this.board.splice(e[0]<t[0]?0:this.board.length-n,0,...this.board.splice(this.board.length-n,n))}if(e[3]!==t[1]){let n=t[1]-e[3];this.board.forEach(r=>{r.splice(e[3]<t[1]?0:r.length-n,0,...r.splice(r.length-n,n))})}}centerLines(){this.board.forEach(e=>{let t=[e.findIndex(e=>e!==0),e.slice().reverse().findIndex(e=>e!==0)];if(t[0]===-1||t[1]===-1)return;let n=e.slice(t[0],e.length-t[1]),r=Math.floor((t[0]+t[1])/2);e.fill(0,0,r),e.splice(r,n.length,...n),e.fill(0,r+n.length)})}export(){return this.board}isEmpty(){return!this.board.find(e=>e.find(e=>e!==0))}repeat(t,n={}){this.board[n.line||0].fill(e.char2char(t)[0])}toString(){return`#=`+`=`.repeat(p.LINE_LENGTH*2)+`=#
13
+ `+this.board.map(t=>`# `+t.map(t=>e.charToString(t)).join(``)+` #
14
+ `).join(``)+`#=`+`=`.repeat(p.LINE_LENGTH*2)+`=#
15
+ `}write(t,n={}){let r=0;if(this.isFilled)return;if(n.line===`CURRENT`)r=this.currentLine||0;else if(n.line===`NEXT`&&this.currentLine===null)this.currentLine=0,r=this.currentLine;else if(n.line===`NEXT`&&typeof this.currentLine==`number`&&this.currentLine<this.board.length-1)this.currentLine++,r=this.currentLine;else if(n.line===`NEXT`){this.isFilled=!0;return}else n.line!==void 0&&(r=n.line);let i={firstLine:r,firstRow:n.row||0,lastLine:this.board.length-1,lastRow:p.LINE_LENGTH-1},a=[i.firstRow,i.firstLine];t.split(/\s+/).forEach((t,n)=>{n!==0&&a[0]!==i.firstRow&&(this.board[a[1]][a[0]]=0,a[0]++);let r=i.lastRow-a[0]+1,o=e.word2chars(t);o.filter(e=>e===60).length===o.length&&o.length>0||(o.length>r&&o.length<=i.lastRow-i.firstRow+1&&a[1]<i.lastLine&&(a[0]=i.firstRow,a[1]++,r=i.lastRow-a[0]),o.length<=r?(this.board[a[1]].splice(a[0],o.length,...o),a[0]+=o.length):o.length>r&&r>5&&(this.board[a[1]].splice(a[0],r,...o.slice(0,r)),a[0]+=r))}),this.currentLine=a[1]}},lt=class{static cache=new Q(`calendar`);parseConfig(e,t,n){let r={};return console.log(`parseConfig`,n),e===`min-temp`&&Array.isArray(n.temp)?r.temp=[parseInt(t||``),Math.max(...n.temp)]:e===`min-temp`?r.temp=[parseInt(t||``),parseInt(t||``)]:e===`max-temp`&&Array.isArray(n.temp)?r.temp=[Math.min(...n.temp),parseInt(t||``)]:e===`max-temp`?r.temp=[parseInt(t||``),parseInt(t||``)]:e===`precip`?r.precip=parseInt(t||``,10):e===`locale`&&(r.locale=String(t)),r}parsePayload(e){try{return JSON.parse(e||``)}catch{return{}}}async render(e,t){let n=new ct,r=new Date,i=Object.assign({locale:`en`,precip:void 0,temp:void 0},t,e);n.write(r.toLocaleString(i.locale,{weekday:`long`})),n.write(r.toLocaleString(i.locale,{day:`numeric`,month:`long`}),{line:`NEXT`}),n.write(``,{line:`NEXT`});let a=[];Array.isArray(i.temp)&&a.push(`${Math.min(...i.temp)}-${Math.max(...i.temp)}°C`),typeof i.precip==`number`&&i.precip>0&&a.push(`${i.precip}%`),a.length&&n.write(a.join(`, `),{line:`NEXT`}),n.center();let o=new Date;return o.setHours(24,0,0,0),{message:n,validTill:o}}},ut=class e{static cache=new Q(`calendar`);static getTimeStr(e,t=!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)?t?`Morgen`:`Morgn`:e.start.getHours().toString().padStart(2,`⬛️`)+`:`+e.start.getMinutes().toString().padStart(2,`0`)}static isMidnight(e){return!e.getHours()&&!e.getMinutes()&&!e.getSeconds()&&!e.getMilliseconds()}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}async fetchURL(t){let n=await e.cache.get(t,1e3*60*10);if(!n){let r=await m.default.async.fromURL(t);n=Object.values(r).filter(e=>e&&e.type===`VEVENT`&&e.start&&e.end&&e.summary).map(e=>({end:new Date(String(e.end)),start:new Date(String(e.start)),summary:String(e.summary).trim()})).filter(e=>e.end>new Date).sort((e,t)=>e.end.getTime()-t.end.getTime()).slice(0,6),await e.cache.set(t,n)}return n.map(e=>({end:new Date(String(e.end)),start:new Date(String(e.start)),summary:String(e.summary)})).filter(e=>e.end>new Date)}async fetchURLs(e){let t=await Promise.all(e.map(e=>this.fetchURL(e)));return[].concat(...t).filter(e=>e.end>new Date).sort((e,t)=>e.end.getTime()-t.end.getTime())}parseConfig(){return{}}parsePayload(e){return{calendars:(e||``).split(`,`)}}async render(t){let n=new ct,r=t.calendars.map(e=>$.calendar.urls[e]).filter(Boolean),i=await this.fetchURLs(r).then(t=>t.filter(t=>e.isMidnight(t.start)&&e.isMidnight(t.end)?e.isSameDay(new Date,t.start)||new Date().getHours()>=20&&e.isSameDay(new Date(new Date().getTime()+1e3*60*60*24),t.start):t.start<new Date(new Date().getTime()+1e3*60*60*12)));if(!i.length){let e=new lt,t=await new Q(`page-config`).get(`today`);return e.render({},t||{})}let a=new Date(new Date().getTime()+1e3*60*10);return i.forEach(t=>{n.write(e.getTimeStr(t,i.length===1),{line:`NEXT`}),n.write(t.summary,{line:`CURRENT`,row:6}),n.write(``,{line:`NEXT`}),t.end<a&&(a=t.end)}),n.center(),{message:n,validTill:a}}},dt=class{static cache=new Q(`calendar`);parseConfig(){return{}}parsePayload(e){return e||``}async render(e){let t=new ct;return e.split(`
16
+ `).forEach(e=>{t.write(e,{line:`NEXT`})}),t.centerLines(),t.center(),{message:t}}};const ft={calendar:new ut,message:new dt,today:new lt};var pt=class e{board;currentMessage;currentTimer;mqtt;pageConfig=new Q(`page-config`);subscriptionIds;constructor(){this.board=new u.Vesta({apiKey:$.board.key,apiSecret:$.board.secret}),this.mqtt=l.default.connect($.mqtt.url,{will:{payload:`offline`,qos:0,retain:!0,topic:$.mqtt.prefix+`/status`}}),this.mqtt.on(`connect`,()=>{this.mqtt.publish($.mqtt.prefix+`/status`,`online`,{retain:!0}),this.setupBrokerSubscriptions().catch(e=>{console.error(Error(`Unable to setup mqtt subscriptions: ${e.stack}`)),process.exit(1)})}),this.mqtt.on(`message`,(e,t)=>{this.handleMessage(e,t.toString()).catch(e=>{this.debug(`Unable to handle message: ${e.stack}`)})})}static async run(){return await $.load(),new e}debug(e){let t=String(e);this.mqtt.publish($.mqtt.prefix+`/debug`,t),console.log(t)}async handleMessage(e,t){if(![$.mqtt.prefix+`/debug`,$.mqtt.prefix+`/status`].includes(e))if(e===$.mqtt.prefix+`/disabled`){let e=[`1`,`true`,`TRUE`].includes(t);await $.updateDisabled(e),e||(this.debug(`Board not disabled anymore, update with latest message`),await this.updateCurrentMessage())}else if(Object.keys(ft).map(e=>$.mqtt.prefix+`/`+e).includes(e)){let n=ft[e.substr($.mqtt.prefix.length+1)];await this.renderMessage(n,t)}else{let n=Object.entries(ft).find(([t])=>e.startsWith($.mqtt.prefix+`/`+t+`/`));if(!n){this.debug(`Unknown topic ${e}, I'm sorry`);return}let r=e.substr(($.mqtt.prefix+`/`+n[0]+`/`).length),i=await this.pageConfig.get(n[0]),a=n[1].parseConfig(r,t,i||{}),o=Object.assign(i||{},a);await this.pageConfig.set(n[0],o),await this.updateCurrentMessage(),this.debug(`Update config for page module ${n[0]}: ${JSON.stringify(o,null,` `)}`)}}async renderMessage(e,t){this.currentMessage={page:e,payload:t};let n=Object.entries(ft).find(([,t])=>t===e);if($.board.disabled||!n)return;let r=await e.parsePayload(t),i=await this.pageConfig.get(n[0]),a=await e.render(r,i||{});a.message&&await this.sendMessage(a.message),this.currentTimer&&(clearTimeout(this.currentTimer),delete this.currentTimer),a.validTill&&(this.debug(`Set timer for ${a.validTill.toString()} to update message`),this.currentTimer=setTimeout(()=>{this.debug(`Here I am again, updating the message now…`),this.renderMessage(e,t).catch(e=>{this.debug(`Unable to update page: ${e}`)})},a.validTill.getTime()-new Date().getTime()))}async sendMessage(e=new ct){let t=e.export();if(!this.subscriptionIds){let e=await this.board.getSubscriptions();this.subscriptionIds=e.map(e=>e._id)}this.debug(`Sending Message:
17
+
18
+ `+e.toString()),await Promise.all(this.subscriptionIds.map(e=>this.board.postMessage(e,t)))}async setupBrokerSubscriptions(){if(!this.mqtt)throw Error(`Unable to setup subscriptions: client not set.`);await this.mqtt.subscribe($.mqtt.prefix+`/#`)}async updateCurrentMessage(){this.currentMessage&&await this.renderMessage(this.currentMessage.page,this.currentMessage.payload)}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return pt}});
19
+ //# sourceMappingURL=lib-CVoPRS8D.cjs.map